From 3562e78743202e43aec8727005182a2558117eca Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 28 Jun 2009 22:07:26 +0000 Subject: Checked in the following released items: xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz --- xorg-server/hw/xfree86/Makefile.am | 119 + xorg-server/hw/xfree86/Makefile.in | 971 ++ xorg-server/hw/xfree86/Options | 409 + xorg-server/hw/xfree86/common/Makefile.am | 97 + xorg-server/hw/xfree86/common/Makefile.in | 836 ++ xorg-server/hw/xfree86/common/atKeynames.h | 295 + xorg-server/hw/xfree86/common/compiler.h | 1774 +++ xorg-server/hw/xfree86/common/extramodes | 27 + xorg-server/hw/xfree86/common/fourcc.h | 160 + xorg-server/hw/xfree86/common/modeline2c.awk | 96 + xorg-server/hw/xfree86/common/scoasm.h | 142 + xorg-server/hw/xfree86/common/vesamodes | 111 + xorg-server/hw/xfree86/common/xf86.h | 430 + xorg-server/hw/xfree86/common/xf86AutoConfig.c | 478 + xorg-server/hw/xfree86/common/xf86Build.h | 2 + xorg-server/hw/xfree86/common/xf86Build.h.in | 2 + xorg-server/hw/xfree86/common/xf86Bus.c | 2998 +++++ xorg-server/hw/xfree86/common/xf86Bus.h | 147 + xorg-server/hw/xfree86/common/xf86Config.c | 2673 +++++ xorg-server/hw/xfree86/common/xf86Config.h | 74 + xorg-server/hw/xfree86/common/xf86Configure.c | 940 ++ xorg-server/hw/xfree86/common/xf86Cursor.c | 820 ++ xorg-server/hw/xfree86/common/xf86DGA.c | 1296 ++ xorg-server/hw/xfree86/common/xf86DPMS.c | 225 + xorg-server/hw/xfree86/common/xf86Date.h | 36 + xorg-server/hw/xfree86/common/xf86Debug.c | 77 + xorg-server/hw/xfree86/common/xf86DoProbe.c | 116 + xorg-server/hw/xfree86/common/xf86Events.c | 1018 ++ xorg-server/hw/xfree86/common/xf86Globals.c | 209 + xorg-server/hw/xfree86/common/xf86Helper.c | 2959 +++++ xorg-server/hw/xfree86/common/xf86InPriv.h | 46 + xorg-server/hw/xfree86/common/xf86Init.c | 2095 ++++ xorg-server/hw/xfree86/common/xf86MiscExt.c | 561 + xorg-server/hw/xfree86/common/xf86Mode.c | 2022 ++++ xorg-server/hw/xfree86/common/xf86Module.h | 225 + xorg-server/hw/xfree86/common/xf86Opt.h | 113 + xorg-server/hw/xfree86/common/xf86Option.c | 883 ++ xorg-server/hw/xfree86/common/xf86PM.c | 220 + xorg-server/hw/xfree86/common/xf86PciInfo.h | 731 ++ xorg-server/hw/xfree86/common/xf86Priv.h | 200 + xorg-server/hw/xfree86/common/xf86Privstr.h | 209 + xorg-server/hw/xfree86/common/xf86RandR.c | 457 + xorg-server/hw/xfree86/common/xf86Resources.h | 137 + xorg-server/hw/xfree86/common/xf86Version.h | 56 + xorg-server/hw/xfree86/common/xf86Versions.c | 77 + xorg-server/hw/xfree86/common/xf86VidMode.c | 672 ++ xorg-server/hw/xfree86/common/xf86XKB.c | 80 + xorg-server/hw/xfree86/common/xf86Xinput.c | 865 ++ xorg-server/hw/xfree86/common/xf86Xinput.h | 215 + xorg-server/hw/xfree86/common/xf86cmap.c | 1111 ++ xorg-server/hw/xfree86/common/xf86cmap.h | 75 + xorg-server/hw/xfree86/common/xf86fbBus.c | 96 + xorg-server/hw/xfree86/common/xf86fbman.c | 1450 +++ xorg-server/hw/xfree86/common/xf86fbman.h | 226 + xorg-server/hw/xfree86/common/xf86isaBus.c | 141 + xorg-server/hw/xfree86/common/xf86noBus.c | 74 + xorg-server/hw/xfree86/common/xf86pciBus.c | 962 ++ xorg-server/hw/xfree86/common/xf86pciBus.h | 75 + xorg-server/hw/xfree86/common/xf86sbusBus.c | 703 ++ xorg-server/hw/xfree86/common/xf86sbusBus.h | 97 + xorg-server/hw/xfree86/common/xf86str.h | 1162 ++ xorg-server/hw/xfree86/common/xf86xv.c | 2087 ++++ xorg-server/hw/xfree86/common/xf86xv.h | 273 + xorg-server/hw/xfree86/common/xf86xvmc.c | 229 + xorg-server/hw/xfree86/common/xf86xvmc.h | 163 + xorg-server/hw/xfree86/common/xf86xvpriv.h | 87 + xorg-server/hw/xfree86/common/xisb.c | 175 + xorg-server/hw/xfree86/common/xisb.h | 65 + xorg-server/hw/xfree86/common/xorgHelper.c | 23 + xorg-server/hw/xfree86/common/xorgVersion.h | 49 + xorg-server/hw/xfree86/ddc/DDC.HOWTO | 97 + xorg-server/hw/xfree86/ddc/Makefile.am | 12 + xorg-server/hw/xfree86/ddc/Makefile.in | 683 ++ xorg-server/hw/xfree86/ddc/ddcPriv.h | 9 + xorg-server/hw/xfree86/ddc/ddcProperty.c | 117 + xorg-server/hw/xfree86/ddc/edid.c | 140 + xorg-server/hw/xfree86/ddc/edid.h | 549 + xorg-server/hw/xfree86/ddc/interpret_edid.c | 447 + xorg-server/hw/xfree86/ddc/print_edid.c | 489 + xorg-server/hw/xfree86/ddc/xf86DDC.c | 292 + xorg-server/hw/xfree86/ddc/xf86DDC.h | 58 + xorg-server/hw/xfree86/dixmods/Makefile.am | 114 + xorg-server/hw/xfree86/dixmods/Makefile.in | 1110 ++ xorg-server/hw/xfree86/dixmods/afbmodule.c | 57 + xorg-server/hw/xfree86/dixmods/cfb32module.c | 57 + xorg-server/hw/xfree86/dixmods/cfbmodule.c | 57 + xorg-server/hw/xfree86/dixmods/dbemodule.c | 46 + xorg-server/hw/xfree86/dixmods/extmod/Makefile.am | 38 + xorg-server/hw/xfree86/dixmods/extmod/Makefile.in | 733 ++ xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h | 144 + xorg-server/hw/xfree86/dixmods/extmod/modinit.c | 286 + xorg-server/hw/xfree86/dixmods/extmod/modinit.h | 151 + .../hw/xfree86/dixmods/extmod/vidmodeproc.h | 77 + xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c | 309 + xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c | 754 ++ xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h | 10 + xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c | 821 ++ .../hw/xfree86/dixmods/extmod/xf86miscproc.h | 69 + xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c | 2186 ++++ xorg-server/hw/xfree86/dixmods/extmod/xvmod.c | 23 + xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h | 13 + xorg-server/hw/xfree86/dixmods/fbmodule.c | 52 + xorg-server/hw/xfree86/dixmods/ftmodule.c | 75 + xorg-server/hw/xfree86/dixmods/glxmodule.c | 122 + xorg-server/hw/xfree86/dixmods/mfbmodule.c | 47 + xorg-server/hw/xfree86/dixmods/recordmod.c | 44 + xorg-server/hw/xfree86/dixmods/shmodule.c | 54 + xorg-server/hw/xfree86/dixmods/xf86XTrapModule.c | 45 + xorg-server/hw/xfree86/dixmods/xkbKillSrv.c | 55 + xorg-server/hw/xfree86/dixmods/xkbPrivate.c | 41 + xorg-server/hw/xfree86/dixmods/xkbVT.c | 65 + xorg-server/hw/xfree86/doc/Makefile.am | 10 + xorg-server/hw/xfree86/doc/Makefile.in | 696 ++ xorg-server/hw/xfree86/doc/README.DRI | 1256 ++ xorg-server/hw/xfree86/doc/README.fonts | 1158 ++ xorg-server/hw/xfree86/doc/README.rapidaccess | 48 + xorg-server/hw/xfree86/doc/devel/DebuggingHints | 192 + xorg-server/hw/xfree86/doc/devel/Domain.note | 159 + xorg-server/hw/xfree86/doc/devel/Makefile.am | 10 + xorg-server/hw/xfree86/doc/devel/Makefile.in | 542 + xorg-server/hw/xfree86/doc/devel/RAC.Notes | 696 ++ xorg-server/hw/xfree86/doc/devel/README.DRIcomp | 556 + xorg-server/hw/xfree86/doc/devel/Registry | 409 + xorg-server/hw/xfree86/doc/devel/exa-driver.txt | 94 + xorg-server/hw/xfree86/doc/man/Makefile.am | 24 + xorg-server/hw/xfree86/doc/man/Makefile.in | 646 + xorg-server/hw/xfree86/doc/man/Xorg.man.pre | 693 ++ xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre | 2223 ++++ xorg-server/hw/xfree86/doc/sgml/DESIGN.sgml | 7414 ++++++++++++ xorg-server/hw/xfree86/doc/sgml/Makefile.am | 54 + xorg-server/hw/xfree86/doc/sgml/Makefile.in | 581 + xorg-server/hw/xfree86/dri/Makefile.am | 22 + xorg-server/hw/xfree86/dri/Makefile.in | 741 ++ xorg-server/hw/xfree86/dri/dri.c | 2478 ++++ xorg-server/hw/xfree86/dri/dri.h | 384 + xorg-server/hw/xfree86/dri/drimodule.c | 93 + xorg-server/hw/xfree86/dri/dristruct.h | 126 + xorg-server/hw/xfree86/dri/sarea.h | 97 + xorg-server/hw/xfree86/dri/xf86dri.c | 680 ++ xorg-server/hw/xfree86/dri2/Makefile.am | 16 + xorg-server/hw/xfree86/dri2/Makefile.in | 725 ++ xorg-server/hw/xfree86/dri2/dri2.c | 493 + xorg-server/hw/xfree86/dri2/dri2.h | 81 + xorg-server/hw/xfree86/dri2/dri2ext.c | 361 + xorg-server/hw/xfree86/dummylib/Makefile.am | 38 + xorg-server/hw/xfree86/dummylib/Makefile.in | 750 ++ xorg-server/hw/xfree86/dummylib/README | 7 + xorg-server/hw/xfree86/dummylib/dixprivates.c | 19 + xorg-server/hw/xfree86/dummylib/dummylib.h | 9 + xorg-server/hw/xfree86/dummylib/fatalerror.c | 25 + xorg-server/hw/xfree86/dummylib/logvwrite.c | 21 + xorg-server/hw/xfree86/dummylib/verrorf.c | 19 + xorg-server/hw/xfree86/dummylib/xalloc.c | 111 + xorg-server/hw/xfree86/dummylib/xf86addrestolist.c | 24 + xorg-server/hw/xfree86/dummylib/xf86allocscripi.c | 19 + xorg-server/hw/xfree86/dummylib/xf86drvmsg.c | 24 + xorg-server/hw/xfree86/dummylib/xf86drvmsgverb.c | 24 + xorg-server/hw/xfree86/dummylib/xf86errorf.c | 33 + xorg-server/hw/xfree86/dummylib/xf86errorfverb.c | 24 + xorg-server/hw/xfree86/dummylib/xf86getverb.c | 19 + xorg-server/hw/xfree86/dummylib/xf86info.c | 12 + xorg-server/hw/xfree86/dummylib/xf86msg.c | 24 + xorg-server/hw/xfree86/dummylib/xf86msgverb.c | 24 + xorg-server/hw/xfree86/dummylib/xf86opt.c | 25 + xorg-server/hw/xfree86/dummylib/xf86screens.c | 12 + xorg-server/hw/xfree86/dummylib/xf86servisinit.c | 19 + xorg-server/hw/xfree86/dummylib/xf86verbose.c | 12 + xorg-server/hw/xfree86/exa/Makefile.am | 28 + xorg-server/hw/xfree86/exa/Makefile.in | 761 ++ xorg-server/hw/xfree86/exa/exa.man.pre | 46 + xorg-server/hw/xfree86/exa/examodule.c | 203 + xorg-server/hw/xfree86/fbdevhw/Makefile.am | 28 + xorg-server/hw/xfree86/fbdevhw/Makefile.in | 782 ++ xorg-server/hw/xfree86/fbdevhw/README | 16 + xorg-server/hw/xfree86/fbdevhw/fbdevhw.c | 1017 ++ xorg-server/hw/xfree86/fbdevhw/fbdevhw.h | 62 + xorg-server/hw/xfree86/fbdevhw/fbdevhw.man.pre | 22 + xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c | 196 + xorg-server/hw/xfree86/fbdevhw/fbpriv.h | 265 + xorg-server/hw/xfree86/i2c/Makefile.am | 43 + xorg-server/hw/xfree86/i2c/Makefile.in | 810 ++ xorg-server/hw/xfree86/i2c/bt829.c | 745 ++ xorg-server/hw/xfree86/i2c/bt829.h | 97 + xorg-server/hw/xfree86/i2c/bt829_module.c | 28 + xorg-server/hw/xfree86/i2c/fi1236.c | 609 + xorg-server/hw/xfree86/i2c/fi1236.h | 110 + xorg-server/hw/xfree86/i2c/fi1236_module.c | 32 + xorg-server/hw/xfree86/i2c/i2c_def.h | 14 + xorg-server/hw/xfree86/i2c/msp3430.c | 726 ++ xorg-server/hw/xfree86/i2c/msp3430.h | 114 + xorg-server/hw/xfree86/i2c/msp3430_module.c | 32 + xorg-server/hw/xfree86/i2c/tda8425.c | 78 + xorg-server/hw/xfree86/i2c/tda8425.h | 42 + xorg-server/hw/xfree86/i2c/tda8425_module.c | 32 + xorg-server/hw/xfree86/i2c/tda9850.c | 112 + xorg-server/hw/xfree86/i2c/tda9850.h | 39 + xorg-server/hw/xfree86/i2c/tda9850_module.c | 32 + xorg-server/hw/xfree86/i2c/tda9885.c | 104 + xorg-server/hw/xfree86/i2c/tda9885.h | 60 + xorg-server/hw/xfree86/i2c/tda9885_module.c | 32 + xorg-server/hw/xfree86/i2c/uda1380.c | 183 + xorg-server/hw/xfree86/i2c/uda1380.h | 75 + xorg-server/hw/xfree86/i2c/uda1380_module.c | 32 + xorg-server/hw/xfree86/i2c/xf86i2c.c | 890 ++ xorg-server/hw/xfree86/i2c/xf86i2c.h | 96 + xorg-server/hw/xfree86/int10/INT10.HOWTO | 344 + xorg-server/hw/xfree86/int10/Makefile.am | 44 + xorg-server/hw/xfree86/int10/Makefile.in | 762 ++ xorg-server/hw/xfree86/int10/generic.c | 506 + xorg-server/hw/xfree86/int10/helper_exec.c | 729 ++ xorg-server/hw/xfree86/int10/helper_mem.c | 330 + xorg-server/hw/xfree86/int10/stub.c | 69 + xorg-server/hw/xfree86/int10/x86emu.c | 12 + xorg-server/hw/xfree86/int10/xf86int10.c | 851 ++ xorg-server/hw/xfree86/int10/xf86int10.h | 183 + xorg-server/hw/xfree86/int10/xf86int10module.c | 64 + xorg-server/hw/xfree86/int10/xf86x86emu.c | 89 + xorg-server/hw/xfree86/int10/xf86x86emu.h | 54 + xorg-server/hw/xfree86/loader/Makefile.am | 35 + xorg-server/hw/xfree86/loader/Makefile.in | 714 ++ xorg-server/hw/xfree86/loader/SparcMulDiv.S | 87 + xorg-server/hw/xfree86/loader/dixsym.c | 538 + xorg-server/hw/xfree86/loader/dlloader.c | 179 + xorg-server/hw/xfree86/loader/dlloader.h | 33 + xorg-server/hw/xfree86/loader/extsym.c | 77 + xorg-server/hw/xfree86/loader/fontsym.c | 109 + xorg-server/hw/xfree86/loader/loader.c | 389 + xorg-server/hw/xfree86/loader/loader.h | 106 + xorg-server/hw/xfree86/loader/loaderProcs.h | 106 + xorg-server/hw/xfree86/loader/loadext.c | 440 + xorg-server/hw/xfree86/loader/loadfont.c | 81 + xorg-server/hw/xfree86/loader/loadmod.c | 1295 ++ xorg-server/hw/xfree86/loader/misym.c | 211 + xorg-server/hw/xfree86/loader/os.c | 80 + xorg-server/hw/xfree86/loader/sym.h | 41 + xorg-server/hw/xfree86/loader/xf86sym.c | 1080 ++ xorg-server/hw/xfree86/modes/Makefile.am | 30 + xorg-server/hw/xfree86/modes/Makefile.in | 709 ++ xorg-server/hw/xfree86/modes/xf86Crtc.c | 2768 +++++ xorg-server/hw/xfree86/modes/xf86Crtc.h | 801 ++ xorg-server/hw/xfree86/modes/xf86Cursors.c | 652 ++ xorg-server/hw/xfree86/modes/xf86DiDGA.c | 286 + xorg-server/hw/xfree86/modes/xf86EdidModes.c | 765 ++ xorg-server/hw/xfree86/modes/xf86Modes.c | 697 ++ xorg-server/hw/xfree86/modes/xf86Modes.h | 110 + xorg-server/hw/xfree86/modes/xf86RandR12.c | 1133 ++ xorg-server/hw/xfree86/modes/xf86RandR12.h | 41 + xorg-server/hw/xfree86/modes/xf86Rename.h | 93 + xorg-server/hw/xfree86/modes/xf86Rotate.c | 661 ++ xorg-server/hw/xfree86/modes/xf86cvt.c | 301 + xorg-server/hw/xfree86/modes/xf86gtf.c | 384 + xorg-server/hw/xfree86/os-support/Makefile.am | 28 + xorg-server/hw/xfree86/os-support/Makefile.in | 810 ++ xorg-server/hw/xfree86/os-support/README.OS-lib | 505 + xorg-server/hw/xfree86/os-support/assyntax.h | 749 ++ xorg-server/hw/xfree86/os-support/bsd/Makefile.am | 86 + xorg-server/hw/xfree86/os-support/bsd/Makefile.in | 822 ++ .../hw/xfree86/os-support/bsd/alpha_video.c | 732 ++ xorg-server/hw/xfree86/os-support/bsd/arm_video.c | 687 ++ .../hw/xfree86/os-support/bsd/bsdResource.c | 92 + xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c | 94 + xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c | 139 + xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c | 72 + xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c | 86 + xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c | 90 + xorg-server/hw/xfree86/os-support/bsd/bsd_init.c | 739 ++ xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c | 183 + xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c | 28 + .../hw/xfree86/os-support/bsd/bsd_kqueue_apm.c | 201 + xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c | 791 ++ xorg-server/hw/xfree86/os-support/bsd/i386_video.c | 1006 ++ .../hw/xfree86/os-support/bsd/libusb/data.c | 92 + .../hw/xfree86/os-support/bsd/libusb/descr.c | 73 + .../hw/xfree86/os-support/bsd/libusb/parse.c | 401 + .../hw/xfree86/os-support/bsd/libusb/usage.c | 196 + xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 | 191 + xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h | 92 + .../xfree86/os-support/bsd/libusb/usb_hid_usages | 1079 ++ .../hw/xfree86/os-support/bsd/libusb/usbvar.h | 31 + xorg-server/hw/xfree86/os-support/bsd/memrange.h | 69 + xorg-server/hw/xfree86/os-support/bsd/ppc_video.c | 171 + .../hw/xfree86/os-support/bsd/sparc64_video.c | 109 + xorg-server/hw/xfree86/os-support/bus/Makefile.am | 38 + xorg-server/hw/xfree86/os-support/bus/Makefile.in | 705 ++ xorg-server/hw/xfree86/os-support/bus/Pci.c | 193 + xorg-server/hw/xfree86/os-support/bus/Pci.h | 269 + xorg-server/hw/xfree86/os-support/bus/Sbus.c | 636 + xorg-server/hw/xfree86/os-support/bus/bsd_pci.c | 86 + xorg-server/hw/xfree86/os-support/bus/ix86Pci.c | 718 ++ xorg-server/hw/xfree86/os-support/bus/linuxPci.c | 606 + xorg-server/hw/xfree86/os-support/bus/ppcPci.c | 82 + xorg-server/hw/xfree86/os-support/bus/sparcPci.c | 979 ++ xorg-server/hw/xfree86/os-support/bus/xf86Pci.h | 265 + xorg-server/hw/xfree86/os-support/bus/xf86Sbus.h | 69 + xorg-server/hw/xfree86/os-support/hurd/Makefile.am | 15 + xorg-server/hw/xfree86/os-support/hurd/Makefile.in | 715 ++ xorg-server/hw/xfree86/os-support/hurd/hurd_bell.c | 37 + xorg-server/hw/xfree86/os-support/hurd/hurd_init.c | 89 + xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c | 95 + .../hw/xfree86/os-support/hurd/hurd_mouse.c | 242 + .../hw/xfree86/os-support/hurd/hurd_video.c | 170 + xorg-server/hw/xfree86/os-support/int10Defines.h | 89 + .../hw/xfree86/os-support/linux/Makefile.am | 58 + .../hw/xfree86/os-support/linux/Makefile.in | 795 ++ .../hw/xfree86/os-support/linux/int10/linux.c | 557 + .../os-support/linux/int10/vm86/linux_vm86.c | 302 + xorg-server/hw/xfree86/os-support/linux/lnx.h | 53 + .../hw/xfree86/os-support/linux/lnxResource.c | 104 + xorg-server/hw/xfree86/os-support/linux/lnx_acpi.c | 181 + xorg-server/hw/xfree86/os-support/linux/lnx_agp.c | 374 + xorg-server/hw/xfree86/os-support/linux/lnx_apm.c | 206 + xorg-server/hw/xfree86/os-support/linux/lnx_axp.c | 199 + xorg-server/hw/xfree86/os-support/linux/lnx_bell.c | 45 + xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c | 150 + xorg-server/hw/xfree86/os-support/linux/lnx_font.c | 291 + xorg-server/hw/xfree86/os-support/linux/lnx_init.c | 466 + xorg-server/hw/xfree86/os-support/linux/lnx_jstk.c | 180 + xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c | 112 + .../hw/xfree86/os-support/linux/lnx_mouse.c | 221 + xorg-server/hw/xfree86/os-support/linux/lnx_pci.c | 193 + .../hw/xfree86/os-support/linux/lnx_video.c | 1106 ++ .../hw/xfree86/os-support/lynxos/Makefile.am | 8 + .../hw/xfree86/os-support/lynxos/Makefile.in | 540 + .../hw/xfree86/os-support/lynxos/lynx_init.c | 192 + .../hw/xfree86/os-support/lynxos/lynx_mmap.c | 72 + .../hw/xfree86/os-support/lynxos/lynx_mouse.c | 33 + .../hw/xfree86/os-support/lynxos/lynx_noinline.c | 177 + .../hw/xfree86/os-support/lynxos/lynx_ppc.S | 70 + .../hw/xfree86/os-support/lynxos/lynx_ppc.c | 51 + .../hw/xfree86/os-support/lynxos/lynx_video.c | 710 ++ xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.S | 153 + xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.c | 412 + xorg-server/hw/xfree86/os-support/misc/Delay.c | 39 + xorg-server/hw/xfree86/os-support/misc/IODelay.S | 53 + xorg-server/hw/xfree86/os-support/misc/IODelay.c | 24 + xorg-server/hw/xfree86/os-support/misc/Makefile.am | 23 + xorg-server/hw/xfree86/os-support/misc/Makefile.in | 663 ++ xorg-server/hw/xfree86/os-support/misc/PortIO.S | 57 + xorg-server/hw/xfree86/os-support/misc/SlowBcopy.S | 108 + xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c | 127 + .../hw/xfree86/os-support/misc/xf86_IlHack.c | 16 + xorg-server/hw/xfree86/os-support/misc/xf86_Util.c | 94 + xorg-server/hw/xfree86/os-support/sco/Makefile.am | 6 + xorg-server/hw/xfree86/os-support/sco/Makefile.in | 538 + xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c | 117 + xorg-server/hw/xfree86/os-support/sco/sco_init.c | 294 + xorg-server/hw/xfree86/os-support/sco/sco_iop.c | 134 + xorg-server/hw/xfree86/os-support/sco/sco_mouse.c | 258 + xorg-server/hw/xfree86/os-support/sco/sco_video.c | 294 + .../hw/xfree86/os-support/shared/VTsw_noop.c | 54 + .../hw/xfree86/os-support/shared/VTsw_usl.c | 90 + .../hw/xfree86/os-support/shared/agp_noop.c | 103 + .../hw/xfree86/os-support/shared/bios_devmem.c | 75 + .../hw/xfree86/os-support/shared/bios_mmap.c | 162 + xorg-server/hw/xfree86/os-support/shared/ia64Pci.c | 188 + xorg-server/hw/xfree86/os-support/shared/inout.S | 111 + .../hw/xfree86/os-support/shared/ioperm_noop.c | 49 + .../hw/xfree86/os-support/shared/kmod_noop.c | 38 + xorg-server/hw/xfree86/os-support/shared/pm_noop.c | 47 + .../hw/xfree86/os-support/shared/posix_tty.c | 686 ++ xorg-server/hw/xfree86/os-support/shared/sigio.c | 282 + .../hw/xfree86/os-support/shared/sigiostubs.c | 71 + .../hw/xfree86/os-support/shared/stdResource.c | 116 + xorg-server/hw/xfree86/os-support/shared/vidmem.c | 296 + xorg-server/hw/xfree86/os-support/shared/xf86Axp.c | 49 + xorg-server/hw/xfree86/os-support/shared/xf86Axp.h | 34 + .../hw/xfree86/os-support/solaris/Makefile.am | 37 + .../hw/xfree86/os-support/solaris/Makefile.in | 818 ++ .../hw/xfree86/os-support/solaris/agpgart.h | 108 + .../hw/xfree86/os-support/solaris/apSolaris.shar | 806 ++ .../hw/xfree86/os-support/solaris/solaris-amd64.S | 73 + .../hw/xfree86/os-support/solaris/solaris-ia32.S | 73 + .../os-support/solaris/solaris-sparcv8plus.S | 144 + .../hw/xfree86/os-support/solaris/sun_agp.c | 338 + .../hw/xfree86/os-support/solaris/sun_apm.c | 232 + .../hw/xfree86/os-support/solaris/sun_bell.c | 185 + .../hw/xfree86/os-support/solaris/sun_bios.c | 103 + .../hw/xfree86/os-support/solaris/sun_init.c | 357 + .../hw/xfree86/os-support/solaris/sun_mouse.c | 717 ++ .../hw/xfree86/os-support/solaris/sun_vid.c | 236 + xorg-server/hw/xfree86/os-support/sysv/Makefile.am | 1 + xorg-server/hw/xfree86/os-support/sysv/Makefile.in | 532 + xorg-server/hw/xfree86/os-support/sysv/sysv_init.c | 252 + .../hw/xfree86/os-support/sysv/sysv_mouse.c | 60 + .../hw/xfree86/os-support/sysv/sysv_video.c | 367 + xorg-server/hw/xfree86/os-support/usl/Makefile.am | 6 + xorg-server/hw/xfree86/os-support/usl/Makefile.in | 538 + xorg-server/hw/xfree86/os-support/usl/usl_init.c | 357 + xorg-server/hw/xfree86/os-support/usl/usl_iop.c | 106 + xorg-server/hw/xfree86/os-support/usl/usl_mouse.c | 177 + xorg-server/hw/xfree86/os-support/usl/usl_video.c | 109 + xorg-server/hw/xfree86/os-support/usl/usl_vtsw.c | 95 + xorg-server/hw/xfree86/os-support/xf86OSmouse.h | 294 + xorg-server/hw/xfree86/os-support/xf86OSpriv.h | 56 + xorg-server/hw/xfree86/os-support/xf86_OSlib.h | 683 ++ xorg-server/hw/xfree86/os-support/xf86_OSproc.h | 248 + xorg-server/hw/xfree86/os-support/xorgos.c | 0 xorg-server/hw/xfree86/osandcommon.c | 0 xorg-server/hw/xfree86/parser/Configint.h | 226 + xorg-server/hw/xfree86/parser/DRI.c | 187 + xorg-server/hw/xfree86/parser/Device.c | 382 + xorg-server/hw/xfree86/parser/Extensions.c | 111 + xorg-server/hw/xfree86/parser/Files.c | 273 + xorg-server/hw/xfree86/parser/Flags.c | 516 + xorg-server/hw/xfree86/parser/Input.c | 217 + xorg-server/hw/xfree86/parser/Layout.c | 534 + xorg-server/hw/xfree86/parser/Makefile.am | 41 + xorg-server/hw/xfree86/parser/Makefile.in | 759 ++ xorg-server/hw/xfree86/parser/Module.c | 279 + xorg-server/hw/xfree86/parser/Monitor.c | 904 ++ xorg-server/hw/xfree86/parser/Pointer.c | 237 + xorg-server/hw/xfree86/parser/Screen.c | 569 + xorg-server/hw/xfree86/parser/Vendor.c | 244 + xorg-server/hw/xfree86/parser/Video.c | 296 + xorg-server/hw/xfree86/parser/configProcs.h | 113 + xorg-server/hw/xfree86/parser/cpconfig.c | 122 + xorg-server/hw/xfree86/parser/read.c | 311 + xorg-server/hw/xfree86/parser/scan.c | 1031 ++ xorg-server/hw/xfree86/parser/write.c | 227 + xorg-server/hw/xfree86/parser/xf86Optrec.h | 112 + xorg-server/hw/xfree86/parser/xf86Parser.h | 484 + xorg-server/hw/xfree86/parser/xf86tokens.h | 278 + xorg-server/hw/xfree86/rac/Makefile.am | 8 + xorg-server/hw/xfree86/rac/Makefile.in | 674 ++ xorg-server/hw/xfree86/rac/xf86RAC.c | 1157 ++ xorg-server/hw/xfree86/rac/xf86RAC.h | 17 + xorg-server/hw/xfree86/ramdac/BT.c | 165 + xorg-server/hw/xfree86/ramdac/BT.h | 32 + xorg-server/hw/xfree86/ramdac/BTPriv.h | 20 + xorg-server/hw/xfree86/ramdac/CURSOR.NOTES | 191 + xorg-server/hw/xfree86/ramdac/IBM.c | 639 + xorg-server/hw/xfree86/ramdac/IBM.h | 385 + xorg-server/hw/xfree86/ramdac/IBMPriv.h | 27 + xorg-server/hw/xfree86/ramdac/Makefile.am | 19 + xorg-server/hw/xfree86/ramdac/Makefile.in | 697 ++ xorg-server/hw/xfree86/ramdac/TI.c | 719 ++ xorg-server/hw/xfree86/ramdac/TI.h | 95 + xorg-server/hw/xfree86/ramdac/TIPriv.h | 29 + xorg-server/hw/xfree86/ramdac/xf86BitOrder.c | 2 + xorg-server/hw/xfree86/ramdac/xf86Cursor.c | 403 + xorg-server/hw/xfree86/ramdac/xf86Cursor.h | 51 + xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h | 50 + xorg-server/hw/xfree86/ramdac/xf86HWCurs.c | 527 + xorg-server/hw/xfree86/ramdac/xf86RamDac.c | 154 + xorg-server/hw/xfree86/ramdac/xf86RamDac.h | 123 + xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c | 74 + xorg-server/hw/xfree86/ramdac/xf86RamDacPriv.h | 13 + xorg-server/hw/xfree86/shadowfb/Makefile.am | 9 + xorg-server/hw/xfree86/shadowfb/Makefile.in | 701 ++ xorg-server/hw/xfree86/shadowfb/sfbmodule.c | 21 + xorg-server/hw/xfree86/shadowfb/shadow.c | 1746 +++ xorg-server/hw/xfree86/shadowfb/shadowfb.h | 43 + xorg-server/hw/xfree86/utils/Makefile.am | 7 + xorg-server/hw/xfree86/utils/Makefile.in | 697 ++ xorg-server/hw/xfree86/utils/cvt/Makefile.am | 47 + xorg-server/hw/xfree86/utils/cvt/Makefile.in | 836 ++ xorg-server/hw/xfree86/utils/cvt/cvt.c | 236 + xorg-server/hw/xfree86/utils/cvt/cvt.man.pre | 42 + xorg-server/hw/xfree86/utils/gtf/Makefile.am | 50 + xorg-server/hw/xfree86/utils/gtf/Makefile.in | 800 ++ xorg-server/hw/xfree86/utils/gtf/gtf.c | 746 ++ xorg-server/hw/xfree86/utils/gtf/gtf.man.pre | 45 + xorg-server/hw/xfree86/utils/ioport/Makefile.am | 58 + xorg-server/hw/xfree86/utils/ioport/Makefile.in | 739 ++ xorg-server/hw/xfree86/utils/ioport/ioport.c | 491 + xorg-server/hw/xfree86/utils/kbd_mode/Makefile.am | 70 + xorg-server/hw/xfree86/utils/kbd_mode/Makefile.in | 829 ++ .../hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c | 91 + .../hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre | 36 + .../hw/xfree86/utils/kbd_mode/sun-kbd_mode.c | 152 + .../hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre | 53 + xorg-server/hw/xfree86/utils/xorgcfg/Makefile.am | 164 + xorg-server/hw/xfree86/utils/xorgcfg/Makefile.in | 1305 +++ xorg-server/hw/xfree86/utils/xorgcfg/TODO | 33 + xorg-server/hw/xfree86/utils/xorgcfg/XOrgCfg.pre | 1852 +++ xorg-server/hw/xfree86/utils/xorgcfg/accessx.c | 681 ++ xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.c | 433 + xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.h | 43 + xorg-server/hw/xfree86/utils/xorgcfg/card.xbm | 59 + xorg-server/hw/xfree86/utils/xorgcfg/card.xpm | 81 + xorg-server/hw/xfree86/utils/xorgcfg/cards.c | 695 ++ xorg-server/hw/xfree86/utils/xorgcfg/cards.h | 89 + xorg-server/hw/xfree86/utils/xorgcfg/computer.xpm | 91 + xorg-server/hw/xfree86/utils/xorgcfg/config.c | 301 + xorg-server/hw/xfree86/utils/xorgcfg/config.h | 226 + xorg-server/hw/xfree86/utils/xorgcfg/down.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/expert.c | 4839 ++++++++ xorg-server/hw/xfree86/utils/xorgcfg/help.c | 1785 +++ xorg-server/hw/xfree86/utils/xorgcfg/help.h | 40 + xorg-server/hw/xfree86/utils/xorgcfg/interface.c | 2278 ++++ .../hw/xfree86/utils/xorgcfg/keyboard-cfg.c | 1378 +++ .../hw/xfree86/utils/xorgcfg/keyboard-cfg.h | 73 + xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xbm | 59 + xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xpm | 66 + xorg-server/hw/xfree86/utils/xorgcfg/left.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/loader.c | 405 + xorg-server/hw/xfree86/utils/xorgcfg/loader.h | 170 + xorg-server/hw/xfree86/utils/xorgcfg/loadmod.c | 663 ++ xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.c | 456 + xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.h | 47 + xorg-server/hw/xfree86/utils/xorgcfg/monitor.xbm | 59 + xorg-server/hw/xfree86/utils/xorgcfg/monitor.xpm | 79 + xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.c | 449 + xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.h | 42 + xorg-server/hw/xfree86/utils/xorgcfg/mouse.xbm | 59 + xorg-server/hw/xfree86/utils/xorgcfg/mouse.xpm | 76 + xorg-server/hw/xfree86/utils/xorgcfg/narrower.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/options.c | 787 ++ xorg-server/hw/xfree86/utils/xorgcfg/options.h | 50 + xorg-server/hw/xfree86/utils/xorgcfg/right.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.c | 555 + xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.h | 43 + xorg-server/hw/xfree86/utils/xorgcfg/screen.c | 983 ++ xorg-server/hw/xfree86/utils/xorgcfg/screen.h | 51 + xorg-server/hw/xfree86/utils/xorgcfg/shorter.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/startx.c | 146 + xorg-server/hw/xfree86/utils/xorgcfg/stubs.c | 65 + xorg-server/hw/xfree86/utils/xorgcfg/stubs.h | 42 + xorg-server/hw/xfree86/utils/xorgcfg/taller.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/text-mode.c | 3379 ++++++ xorg-server/hw/xfree86/utils/xorgcfg/up.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/vidmode.c | 1346 +++ xorg-server/hw/xfree86/utils/xorgcfg/vidmode.h | 63 + xorg-server/hw/xfree86/utils/xorgcfg/wider.xbm | 8 + xorg-server/hw/xfree86/utils/xorgcfg/xf86config.c | 982 ++ xorg-server/hw/xfree86/utils/xorgcfg/xf86config.h | 110 + .../hw/xfree86/utils/xorgcfg/xorgcfg.man.pre | 148 + xorg-server/hw/xfree86/utils/xorgconfig/Cards | 3135 +++++ xorg-server/hw/xfree86/utils/xorgconfig/Cards98 | 647 + .../hw/xfree86/utils/xorgconfig/Makefile.am | 70 + .../hw/xfree86/utils/xorgconfig/Makefile.in | 857 ++ xorg-server/hw/xfree86/utils/xorgconfig/cards.c | 278 + xorg-server/hw/xfree86/utils/xorgconfig/cards.h | 30 + .../hw/xfree86/utils/xorgconfig/xorgconfig.c | 2890 +++++ .../hw/xfree86/utils/xorgconfig/xorgconfig.man.pre | 22 + xorg-server/hw/xfree86/vbe/Makefile.am | 10 + xorg-server/hw/xfree86/vbe/Makefile.in | 704 ++ xorg-server/hw/xfree86/vbe/vbe.c | 1146 ++ xorg-server/hw/xfree86/vbe/vbe.h | 347 + xorg-server/hw/xfree86/vbe/vbeModes.c | 453 + xorg-server/hw/xfree86/vbe/vbeModes.h | 90 + xorg-server/hw/xfree86/vbe/vbe_module.c | 31 + xorg-server/hw/xfree86/vgahw/Makefile.am | 9 + xorg-server/hw/xfree86/vgahw/Makefile.in | 702 ++ xorg-server/hw/xfree86/vgahw/vgaCmap.c | 302 + xorg-server/hw/xfree86/vgahw/vgaHW.c | 2004 ++++ xorg-server/hw/xfree86/vgahw/vgaHW.h | 236 + xorg-server/hw/xfree86/vgahw/vgaHWmodule.c | 24 + xorg-server/hw/xfree86/x86emu/Makefile.am | 27 + xorg-server/hw/xfree86/x86emu/Makefile.in | 670 ++ xorg-server/hw/xfree86/x86emu/debug.c | 430 + xorg-server/hw/xfree86/x86emu/decode.c | 1092 ++ xorg-server/hw/xfree86/x86emu/fpu.c | 965 ++ xorg-server/hw/xfree86/x86emu/ops.c | 11697 +++++++++++++++++++ xorg-server/hw/xfree86/x86emu/ops2.c | 2897 +++++ xorg-server/hw/xfree86/x86emu/prim_ops.c | 2722 +++++ xorg-server/hw/xfree86/x86emu/sys.c | 663 ++ xorg-server/hw/xfree86/x86emu/validate.c | 765 ++ xorg-server/hw/xfree86/x86emu/x86emu.h | 198 + xorg-server/hw/xfree86/x86emu/x86emu/debug.h | 210 + xorg-server/hw/xfree86/x86emu/x86emu/decode.h | 88 + xorg-server/hw/xfree86/x86emu/x86emu/fpu.h | 61 + xorg-server/hw/xfree86/x86emu/x86emu/fpu_regs.h | 119 + xorg-server/hw/xfree86/x86emu/x86emu/ops.h | 45 + xorg-server/hw/xfree86/x86emu/x86emu/prim_asm.h | 970 ++ xorg-server/hw/xfree86/x86emu/x86emu/prim_ops.h | 142 + .../hw/xfree86/x86emu/x86emu/prim_x86_gcc.h | 79 + xorg-server/hw/xfree86/x86emu/x86emu/regs.h | 337 + xorg-server/hw/xfree86/x86emu/x86emu/types.h | 106 + xorg-server/hw/xfree86/x86emu/x86emu/x86emui.h | 102 + xorg-server/hw/xfree86/xaa/Makefile.am | 74 + xorg-server/hw/xfree86/xaa/Makefile.in | 836 ++ xorg-server/hw/xfree86/xaa/XAA.HOWTO | 1427 +++ xorg-server/hw/xfree86/xaa/l-xaaBitmap.c | 2 + xorg-server/hw/xfree86/xaa/l-xaaStipple.c | 2 + xorg-server/hw/xfree86/xaa/l-xaaTEGlyph.c | 2 + xorg-server/hw/xfree86/xaa/l3-xaaBitmap.c | 3 + xorg-server/hw/xfree86/xaa/l3-xaaStipple.c | 3 + xorg-server/hw/xfree86/xaa/lf-xaaBitmap.c | 3 + xorg-server/hw/xfree86/xaa/lf-xaaStipple.c | 3 + xorg-server/hw/xfree86/xaa/lf-xaaTEGlyph.c | 3 + xorg-server/hw/xfree86/xaa/lf3-xaaBitmap.c | 4 + xorg-server/hw/xfree86/xaa/lf3-xaaStipple.c | 4 + xorg-server/hw/xfree86/xaa/m-xaaBitmap.c | 2 + xorg-server/hw/xfree86/xaa/m-xaaStipple.c | 2 + xorg-server/hw/xfree86/xaa/m-xaaTEGlyph.c | 2 + xorg-server/hw/xfree86/xaa/m3-xaaBitmap.c | 3 + xorg-server/hw/xfree86/xaa/m3-xaaStipple.c | 3 + xorg-server/hw/xfree86/xaa/mf-xaaBitmap.c | 3 + xorg-server/hw/xfree86/xaa/mf-xaaStipple.c | 3 + xorg-server/hw/xfree86/xaa/mf-xaaTEGlyph.c | 3 + xorg-server/hw/xfree86/xaa/mf3-xaaBitmap.c | 4 + xorg-server/hw/xfree86/xaa/mf3-xaaStipple.c | 4 + xorg-server/hw/xfree86/xaa/s-xaaDashLine.c | 2 + xorg-server/hw/xfree86/xaa/s-xaaLine.c | 2 + xorg-server/hw/xfree86/xaa/xaa.h | 1399 +++ xorg-server/hw/xfree86/xaa/xaaBitBlt.c | 221 + xorg-server/hw/xfree86/xaa/xaaBitOrder.c | 16 + xorg-server/hw/xfree86/xaa/xaaBitmap.c | 476 + xorg-server/hw/xfree86/xaa/xaaCpyArea.c | 387 + xorg-server/hw/xfree86/xaa/xaaCpyPlane.c | 210 + xorg-server/hw/xfree86/xaa/xaaCpyWin.c | 82 + xorg-server/hw/xfree86/xaa/xaaDashLine.c | 334 + xorg-server/hw/xfree86/xaa/xaaFallback.c | 352 + xorg-server/hw/xfree86/xaa/xaaFillArc.c | 217 + xorg-server/hw/xfree86/xaa/xaaFillPoly.c | 962 ++ xorg-server/hw/xfree86/xaa/xaaFillRect.c | 1095 ++ xorg-server/hw/xfree86/xaa/xaaGC.c | 656 ++ xorg-server/hw/xfree86/xaa/xaaGCmisc.c | 429 + xorg-server/hw/xfree86/xaa/xaaImage.c | 521 + xorg-server/hw/xfree86/xaa/xaaInit.c | 622 + xorg-server/hw/xfree86/xaa/xaaInitAccel.c | 1505 +++ xorg-server/hw/xfree86/xaa/xaaLine.c | 394 + xorg-server/hw/xfree86/xaa/xaaLineMisc.c | 151 + xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c | 200 + xorg-server/hw/xfree86/xaa/xaaNonTEText.c | 592 + xorg-server/hw/xfree86/xaa/xaaOffscreen.c | 162 + xorg-server/hw/xfree86/xaa/xaaOverlay.c | 129 + xorg-server/hw/xfree86/xaa/xaaOverlayDF.c | 1049 ++ xorg-server/hw/xfree86/xaa/xaaPCache.c | 2377 ++++ xorg-server/hw/xfree86/xaa/xaaPict.c | 643 + xorg-server/hw/xfree86/xaa/xaaROP.c | 184 + xorg-server/hw/xfree86/xaa/xaaRect.c | 136 + xorg-server/hw/xfree86/xaa/xaaSpans.c | 882 ++ xorg-server/hw/xfree86/xaa/xaaStateChange.c | 1631 +++ xorg-server/hw/xfree86/xaa/xaaStipple.c | 866 ++ xorg-server/hw/xfree86/xaa/xaaTEGlyph.c | 1077 ++ xorg-server/hw/xfree86/xaa/xaaTEGlyphBlt.S | 964 ++ xorg-server/hw/xfree86/xaa/xaaTEText.c | 312 + xorg-server/hw/xfree86/xaa/xaaTables.c | 87 + xorg-server/hw/xfree86/xaa/xaaWideLine.c | 921 ++ xorg-server/hw/xfree86/xaa/xaaWrapper.c | 484 + xorg-server/hw/xfree86/xaa/xaaWrapper.h | 10 + xorg-server/hw/xfree86/xaa/xaacexp.h | 127 + xorg-server/hw/xfree86/xaa/xaalocal.h | 1758 +++ xorg-server/hw/xfree86/xaa/xaarop.h | 311 + xorg-server/hw/xfree86/xaa/xaawrap.h | 81 + xorg-server/hw/xfree86/xf1bpp/Makefile.am | 178 + xorg-server/hw/xfree86/xf1bpp/Makefile.in | 929 ++ xorg-server/hw/xfree86/xf1bpp/maskbits.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbbitblt.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbbltC.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbbltCI.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbbltG.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbbltO.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbbltX.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbbres.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbbresd.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbclip.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbcmap.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbfillarc.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbfillrct.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbfillsp.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbfont.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbgc.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbgetsp.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbhrzvert.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbigbblak.c | 4 + xorg-server/hw/xfree86/xf1bpp/mfbigbwht.c | 4 + xorg-server/hw/xfree86/xf1bpp/mfbimage.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbline.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbmap.h | 122 + xorg-server/hw/xfree86/xf1bpp/mfbmap.sh | 25 + xorg-server/hw/xfree86/xf1bpp/mfbmisc.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbmodule.c | 47 + xorg-server/hw/xfree86/xf1bpp/mfbpablack.c | 6 + xorg-server/hw/xfree86/xf1bpp/mfbpainv.c | 6 + xorg-server/hw/xfree86/xf1bpp/mfbpawhite.c | 6 + xorg-server/hw/xfree86/xf1bpp/mfbpgbblak.c | 4 + xorg-server/hw/xfree86/xf1bpp/mfbpgbinv.c | 4 + xorg-server/hw/xfree86/xf1bpp/mfbpgbwht.c | 4 + xorg-server/hw/xfree86/xf1bpp/mfbpixmap.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbplyblack.c | 5 + xorg-server/hw/xfree86/xf1bpp/mfbplyinv.c | 5 + xorg-server/hw/xfree86/xf1bpp/mfbplywhite.c | 5 + xorg-server/hw/xfree86/xf1bpp/mfbpolypnt.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbpushpxl.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbscrclse.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbscrinit.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbseg.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbsetsp.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbteblack.c | 5 + xorg-server/hw/xfree86/xf1bpp/mfbtewhite.c | 5 + xorg-server/hw/xfree86/xf1bpp/mfbtileC.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbtileG.c | 3 + xorg-server/hw/xfree86/xf1bpp/mfbunmap.h | 114 + xorg-server/hw/xfree86/xf1bpp/mfbunmap.sh | 23 + xorg-server/hw/xfree86/xf1bpp/mfbwindow.c | 2 + xorg-server/hw/xfree86/xf1bpp/mfbzerarc.c | 2 + xorg-server/hw/xfree86/xf1bpp/xf1bpp.h | 36 + xorg-server/hw/xfree86/xf4bpp/Makefile.am | 57 + xorg-server/hw/xfree86/xf4bpp/Makefile.in | 791 ++ xorg-server/hw/xfree86/xf4bpp/NOTES | 194 + xorg-server/hw/xfree86/xf4bpp/OScompiler.h | 58 + xorg-server/hw/xfree86/xf4bpp/emulOpStip.c | 102 + xorg-server/hw/xfree86/xf4bpp/emulRepAre.c | 69 + xorg-server/hw/xfree86/xf4bpp/emulTile.c | 352 + xorg-server/hw/xfree86/xf4bpp/ibmTrace.h | 1 + xorg-server/hw/xfree86/xf4bpp/mfbbres.c | 164 + xorg-server/hw/xfree86/xf4bpp/mfbbresd.c | 205 + xorg-server/hw/xfree86/xf4bpp/mfbfillarc.c | 301 + xorg-server/hw/xfree86/xf4bpp/mfbhrzvert.c | 135 + xorg-server/hw/xfree86/xf4bpp/mfbimggblt.c | 505 + xorg-server/hw/xfree86/xf4bpp/mfbline.c | 976 ++ xorg-server/hw/xfree86/xf4bpp/mfbseg.c | 2 + xorg-server/hw/xfree86/xf4bpp/mfbzerarc.c | 267 + xorg-server/hw/xfree86/xf4bpp/offscreen.c | 342 + xorg-server/hw/xfree86/xf4bpp/ppcArea.c | 97 + xorg-server/hw/xfree86/xf4bpp/ppcCReduce.c | 237 + xorg-server/hw/xfree86/xf4bpp/ppcClip.c | 157 + xorg-server/hw/xfree86/xf4bpp/ppcCpArea.c | 470 + xorg-server/hw/xfree86/xf4bpp/ppcDepth.c | 53 + xorg-server/hw/xfree86/xf4bpp/ppcFillRct.c | 215 + xorg-server/hw/xfree86/xf4bpp/ppcGC.c | 446 + xorg-server/hw/xfree86/xf4bpp/ppcGCstr.h | 71 + xorg-server/hw/xfree86/xf4bpp/ppcGetSp.c | 141 + xorg-server/hw/xfree86/xf4bpp/ppcIO.c | 233 + xorg-server/hw/xfree86/xf4bpp/ppcImg.c | 122 + xorg-server/hw/xfree86/xf4bpp/ppcPixFS.c | 502 + xorg-server/hw/xfree86/xf4bpp/ppcPixmap.c | 151 + xorg-server/hw/xfree86/xf4bpp/ppcPolyPnt.c | 143 + xorg-server/hw/xfree86/xf4bpp/ppcQuery.c | 46 + xorg-server/hw/xfree86/xf4bpp/ppcRslvC.c | 177 + xorg-server/hw/xfree86/xf4bpp/ppcSetSp.c | 319 + xorg-server/hw/xfree86/xf4bpp/ppcSpMcro.h | 43 + xorg-server/hw/xfree86/xf4bpp/ppcWinFS.c | 280 + xorg-server/hw/xfree86/xf4bpp/ppcWindow.c | 220 + xorg-server/hw/xfree86/xf4bpp/vgaBitBlt.c | 749 ++ xorg-server/hw/xfree86/xf4bpp/vgaGC.c | 213 + xorg-server/hw/xfree86/xf4bpp/vgaImages.c | 460 + xorg-server/hw/xfree86/xf4bpp/vgaReg.h | 137 + xorg-server/hw/xfree86/xf4bpp/vgaSolid.c | 574 + xorg-server/hw/xfree86/xf4bpp/vgaStipple.c | 720 ++ xorg-server/hw/xfree86/xf4bpp/vgaVideo.h | 93 + xorg-server/hw/xfree86/xf4bpp/vgamodule.c | 57 + xorg-server/hw/xfree86/xf4bpp/wm3.c | 203 + xorg-server/hw/xfree86/xf4bpp/wm3.h | 73 + xorg-server/hw/xfree86/xf4bpp/xf4bpp.h | 622 + xorg-server/hw/xfree86/xf8_16bpp/Makefile.am | 11 + xorg-server/hw/xfree86/xf8_16bpp/Makefile.in | 700 ++ xorg-server/hw/xfree86/xf8_16bpp/cfb8_16.h | 36 + xorg-server/hw/xfree86/xf8_16bpp/xf8_16module.c | 77 + xorg-server/hw/xfree86/xf8_32bpp/Makefile.am | 37 + xorg-server/hw/xfree86/xf8_32bpp/Makefile.in | 739 ++ xorg-server/hw/xfree86/xf8_32bpp/cfb8_32.h | 191 + xorg-server/hw/xfree86/xf8_32bpp/cfb8_32module.c | 39 + xorg-server/hw/xfree86/xf8_32bpp/cfbcpyarea.c | 549 + xorg-server/hw/xfree86/xf8_32bpp/cfbcpyplane.c | 41 + xorg-server/hw/xfree86/xf8_32bpp/cfbgc.c | 646 + xorg-server/hw/xfree86/xf8_32bpp/cfbgc32.c | 2 + xorg-server/hw/xfree86/xf8_32bpp/cfbgc8.c | 2 + xorg-server/hw/xfree86/xf8_32bpp/cfbgcmisc.c | 150 + xorg-server/hw/xfree86/xf8_32bpp/cfbgcunder.c | 620 + xorg-server/hw/xfree86/xf8_32bpp/cfbimage.c | 174 + xorg-server/hw/xfree86/xf8_32bpp/cfbpntwin.c | 51 + xorg-server/hw/xfree86/xf8_32bpp/cfbscrinit.c | 311 + xorg-server/hw/xfree86/xf8_32bpp/cfbwindow.c | 116 + xorg-server/hw/xfree86/xf8_32bpp/xf86overlay.c | 1179 ++ xorg-server/hw/xfree86/xorg.c | 0 xorg-server/hw/xfree86/xorgconf.cpp | 604 + 760 files changed, 277314 insertions(+) create mode 100644 xorg-server/hw/xfree86/Makefile.am create mode 100644 xorg-server/hw/xfree86/Makefile.in create mode 100644 xorg-server/hw/xfree86/Options create mode 100644 xorg-server/hw/xfree86/common/Makefile.am create mode 100644 xorg-server/hw/xfree86/common/Makefile.in create mode 100644 xorg-server/hw/xfree86/common/atKeynames.h create mode 100644 xorg-server/hw/xfree86/common/compiler.h create mode 100644 xorg-server/hw/xfree86/common/extramodes create mode 100644 xorg-server/hw/xfree86/common/fourcc.h create mode 100644 xorg-server/hw/xfree86/common/modeline2c.awk create mode 100644 xorg-server/hw/xfree86/common/scoasm.h create mode 100644 xorg-server/hw/xfree86/common/vesamodes create mode 100644 xorg-server/hw/xfree86/common/xf86.h create mode 100644 xorg-server/hw/xfree86/common/xf86AutoConfig.c create mode 100644 xorg-server/hw/xfree86/common/xf86Build.h create mode 100644 xorg-server/hw/xfree86/common/xf86Build.h.in create mode 100644 xorg-server/hw/xfree86/common/xf86Bus.c create mode 100644 xorg-server/hw/xfree86/common/xf86Bus.h create mode 100644 xorg-server/hw/xfree86/common/xf86Config.c create mode 100644 xorg-server/hw/xfree86/common/xf86Config.h create mode 100644 xorg-server/hw/xfree86/common/xf86Configure.c create mode 100644 xorg-server/hw/xfree86/common/xf86Cursor.c create mode 100644 xorg-server/hw/xfree86/common/xf86DGA.c create mode 100644 xorg-server/hw/xfree86/common/xf86DPMS.c create mode 100644 xorg-server/hw/xfree86/common/xf86Date.h create mode 100644 xorg-server/hw/xfree86/common/xf86Debug.c create mode 100644 xorg-server/hw/xfree86/common/xf86DoProbe.c create mode 100644 xorg-server/hw/xfree86/common/xf86Events.c create mode 100644 xorg-server/hw/xfree86/common/xf86Globals.c create mode 100644 xorg-server/hw/xfree86/common/xf86Helper.c create mode 100644 xorg-server/hw/xfree86/common/xf86InPriv.h create mode 100644 xorg-server/hw/xfree86/common/xf86Init.c create mode 100644 xorg-server/hw/xfree86/common/xf86MiscExt.c create mode 100644 xorg-server/hw/xfree86/common/xf86Mode.c create mode 100644 xorg-server/hw/xfree86/common/xf86Module.h create mode 100644 xorg-server/hw/xfree86/common/xf86Opt.h create mode 100644 xorg-server/hw/xfree86/common/xf86Option.c create mode 100644 xorg-server/hw/xfree86/common/xf86PM.c create mode 100644 xorg-server/hw/xfree86/common/xf86PciInfo.h create mode 100644 xorg-server/hw/xfree86/common/xf86Priv.h create mode 100644 xorg-server/hw/xfree86/common/xf86Privstr.h create mode 100644 xorg-server/hw/xfree86/common/xf86RandR.c create mode 100644 xorg-server/hw/xfree86/common/xf86Resources.h create mode 100644 xorg-server/hw/xfree86/common/xf86Version.h create mode 100644 xorg-server/hw/xfree86/common/xf86Versions.c create mode 100644 xorg-server/hw/xfree86/common/xf86VidMode.c create mode 100644 xorg-server/hw/xfree86/common/xf86XKB.c create mode 100644 xorg-server/hw/xfree86/common/xf86Xinput.c create mode 100644 xorg-server/hw/xfree86/common/xf86Xinput.h create mode 100644 xorg-server/hw/xfree86/common/xf86cmap.c create mode 100644 xorg-server/hw/xfree86/common/xf86cmap.h create mode 100644 xorg-server/hw/xfree86/common/xf86fbBus.c create mode 100644 xorg-server/hw/xfree86/common/xf86fbman.c create mode 100644 xorg-server/hw/xfree86/common/xf86fbman.h create mode 100644 xorg-server/hw/xfree86/common/xf86isaBus.c create mode 100644 xorg-server/hw/xfree86/common/xf86noBus.c create mode 100644 xorg-server/hw/xfree86/common/xf86pciBus.c create mode 100644 xorg-server/hw/xfree86/common/xf86pciBus.h create mode 100644 xorg-server/hw/xfree86/common/xf86sbusBus.c create mode 100644 xorg-server/hw/xfree86/common/xf86sbusBus.h create mode 100644 xorg-server/hw/xfree86/common/xf86str.h create mode 100644 xorg-server/hw/xfree86/common/xf86xv.c create mode 100644 xorg-server/hw/xfree86/common/xf86xv.h create mode 100644 xorg-server/hw/xfree86/common/xf86xvmc.c create mode 100644 xorg-server/hw/xfree86/common/xf86xvmc.h create mode 100644 xorg-server/hw/xfree86/common/xf86xvpriv.h create mode 100644 xorg-server/hw/xfree86/common/xisb.c create mode 100644 xorg-server/hw/xfree86/common/xisb.h create mode 100644 xorg-server/hw/xfree86/common/xorgHelper.c create mode 100644 xorg-server/hw/xfree86/common/xorgVersion.h create mode 100644 xorg-server/hw/xfree86/ddc/DDC.HOWTO create mode 100644 xorg-server/hw/xfree86/ddc/Makefile.am create mode 100644 xorg-server/hw/xfree86/ddc/Makefile.in create mode 100644 xorg-server/hw/xfree86/ddc/ddcPriv.h create mode 100644 xorg-server/hw/xfree86/ddc/ddcProperty.c create mode 100644 xorg-server/hw/xfree86/ddc/edid.c create mode 100644 xorg-server/hw/xfree86/ddc/edid.h create mode 100644 xorg-server/hw/xfree86/ddc/interpret_edid.c create mode 100644 xorg-server/hw/xfree86/ddc/print_edid.c create mode 100644 xorg-server/hw/xfree86/ddc/xf86DDC.c create mode 100644 xorg-server/hw/xfree86/ddc/xf86DDC.h create mode 100644 xorg-server/hw/xfree86/dixmods/Makefile.am create mode 100644 xorg-server/hw/xfree86/dixmods/Makefile.in create mode 100644 xorg-server/hw/xfree86/dixmods/afbmodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/cfb32module.c create mode 100644 xorg-server/hw/xfree86/dixmods/cfbmodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/dbemodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/Makefile.am create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/Makefile.in create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/modinit.c create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/modinit.h create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xvmod.c create mode 100644 xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h create mode 100644 xorg-server/hw/xfree86/dixmods/fbmodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/ftmodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/glxmodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/mfbmodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/recordmod.c create mode 100644 xorg-server/hw/xfree86/dixmods/shmodule.c create mode 100644 xorg-server/hw/xfree86/dixmods/xf86XTrapModule.c create mode 100644 xorg-server/hw/xfree86/dixmods/xkbKillSrv.c create mode 100644 xorg-server/hw/xfree86/dixmods/xkbPrivate.c create mode 100644 xorg-server/hw/xfree86/dixmods/xkbVT.c create mode 100644 xorg-server/hw/xfree86/doc/Makefile.am create mode 100644 xorg-server/hw/xfree86/doc/Makefile.in create mode 100644 xorg-server/hw/xfree86/doc/README.DRI create mode 100644 xorg-server/hw/xfree86/doc/README.fonts create mode 100644 xorg-server/hw/xfree86/doc/README.rapidaccess create mode 100644 xorg-server/hw/xfree86/doc/devel/DebuggingHints create mode 100644 xorg-server/hw/xfree86/doc/devel/Domain.note create mode 100644 xorg-server/hw/xfree86/doc/devel/Makefile.am create mode 100644 xorg-server/hw/xfree86/doc/devel/Makefile.in create mode 100644 xorg-server/hw/xfree86/doc/devel/RAC.Notes create mode 100644 xorg-server/hw/xfree86/doc/devel/README.DRIcomp create mode 100644 xorg-server/hw/xfree86/doc/devel/Registry create mode 100644 xorg-server/hw/xfree86/doc/devel/exa-driver.txt create mode 100644 xorg-server/hw/xfree86/doc/man/Makefile.am create mode 100644 xorg-server/hw/xfree86/doc/man/Makefile.in create mode 100644 xorg-server/hw/xfree86/doc/man/Xorg.man.pre create mode 100644 xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre create mode 100644 xorg-server/hw/xfree86/doc/sgml/DESIGN.sgml create mode 100644 xorg-server/hw/xfree86/doc/sgml/Makefile.am create mode 100644 xorg-server/hw/xfree86/doc/sgml/Makefile.in create mode 100644 xorg-server/hw/xfree86/dri/Makefile.am create mode 100644 xorg-server/hw/xfree86/dri/Makefile.in create mode 100644 xorg-server/hw/xfree86/dri/dri.c create mode 100644 xorg-server/hw/xfree86/dri/dri.h create mode 100644 xorg-server/hw/xfree86/dri/drimodule.c create mode 100644 xorg-server/hw/xfree86/dri/dristruct.h create mode 100644 xorg-server/hw/xfree86/dri/sarea.h create mode 100644 xorg-server/hw/xfree86/dri/xf86dri.c create mode 100644 xorg-server/hw/xfree86/dri2/Makefile.am create mode 100644 xorg-server/hw/xfree86/dri2/Makefile.in create mode 100644 xorg-server/hw/xfree86/dri2/dri2.c create mode 100644 xorg-server/hw/xfree86/dri2/dri2.h create mode 100644 xorg-server/hw/xfree86/dri2/dri2ext.c create mode 100644 xorg-server/hw/xfree86/dummylib/Makefile.am create mode 100644 xorg-server/hw/xfree86/dummylib/Makefile.in create mode 100644 xorg-server/hw/xfree86/dummylib/README create mode 100644 xorg-server/hw/xfree86/dummylib/dixprivates.c create mode 100644 xorg-server/hw/xfree86/dummylib/dummylib.h create mode 100644 xorg-server/hw/xfree86/dummylib/fatalerror.c create mode 100644 xorg-server/hw/xfree86/dummylib/logvwrite.c create mode 100644 xorg-server/hw/xfree86/dummylib/verrorf.c create mode 100644 xorg-server/hw/xfree86/dummylib/xalloc.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86addrestolist.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86allocscripi.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86drvmsg.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86drvmsgverb.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86errorf.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86errorfverb.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86getverb.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86info.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86msg.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86msgverb.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86opt.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86screens.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86servisinit.c create mode 100644 xorg-server/hw/xfree86/dummylib/xf86verbose.c create mode 100644 xorg-server/hw/xfree86/exa/Makefile.am create mode 100644 xorg-server/hw/xfree86/exa/Makefile.in create mode 100644 xorg-server/hw/xfree86/exa/exa.man.pre create mode 100644 xorg-server/hw/xfree86/exa/examodule.c create mode 100644 xorg-server/hw/xfree86/fbdevhw/Makefile.am create mode 100644 xorg-server/hw/xfree86/fbdevhw/Makefile.in create mode 100644 xorg-server/hw/xfree86/fbdevhw/README create mode 100644 xorg-server/hw/xfree86/fbdevhw/fbdevhw.c create mode 100644 xorg-server/hw/xfree86/fbdevhw/fbdevhw.h create mode 100644 xorg-server/hw/xfree86/fbdevhw/fbdevhw.man.pre create mode 100644 xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c create mode 100644 xorg-server/hw/xfree86/fbdevhw/fbpriv.h create mode 100644 xorg-server/hw/xfree86/i2c/Makefile.am create mode 100644 xorg-server/hw/xfree86/i2c/Makefile.in create mode 100644 xorg-server/hw/xfree86/i2c/bt829.c create mode 100644 xorg-server/hw/xfree86/i2c/bt829.h create mode 100644 xorg-server/hw/xfree86/i2c/bt829_module.c create mode 100644 xorg-server/hw/xfree86/i2c/fi1236.c create mode 100644 xorg-server/hw/xfree86/i2c/fi1236.h create mode 100644 xorg-server/hw/xfree86/i2c/fi1236_module.c create mode 100644 xorg-server/hw/xfree86/i2c/i2c_def.h create mode 100644 xorg-server/hw/xfree86/i2c/msp3430.c create mode 100644 xorg-server/hw/xfree86/i2c/msp3430.h create mode 100644 xorg-server/hw/xfree86/i2c/msp3430_module.c create mode 100644 xorg-server/hw/xfree86/i2c/tda8425.c create mode 100644 xorg-server/hw/xfree86/i2c/tda8425.h create mode 100644 xorg-server/hw/xfree86/i2c/tda8425_module.c create mode 100644 xorg-server/hw/xfree86/i2c/tda9850.c create mode 100644 xorg-server/hw/xfree86/i2c/tda9850.h create mode 100644 xorg-server/hw/xfree86/i2c/tda9850_module.c create mode 100644 xorg-server/hw/xfree86/i2c/tda9885.c create mode 100644 xorg-server/hw/xfree86/i2c/tda9885.h create mode 100644 xorg-server/hw/xfree86/i2c/tda9885_module.c create mode 100644 xorg-server/hw/xfree86/i2c/uda1380.c create mode 100644 xorg-server/hw/xfree86/i2c/uda1380.h create mode 100644 xorg-server/hw/xfree86/i2c/uda1380_module.c create mode 100644 xorg-server/hw/xfree86/i2c/xf86i2c.c create mode 100644 xorg-server/hw/xfree86/i2c/xf86i2c.h create mode 100644 xorg-server/hw/xfree86/int10/INT10.HOWTO create mode 100644 xorg-server/hw/xfree86/int10/Makefile.am create mode 100644 xorg-server/hw/xfree86/int10/Makefile.in create mode 100644 xorg-server/hw/xfree86/int10/generic.c create mode 100644 xorg-server/hw/xfree86/int10/helper_exec.c create mode 100644 xorg-server/hw/xfree86/int10/helper_mem.c create mode 100644 xorg-server/hw/xfree86/int10/stub.c create mode 100644 xorg-server/hw/xfree86/int10/x86emu.c create mode 100644 xorg-server/hw/xfree86/int10/xf86int10.c create mode 100644 xorg-server/hw/xfree86/int10/xf86int10.h create mode 100644 xorg-server/hw/xfree86/int10/xf86int10module.c create mode 100644 xorg-server/hw/xfree86/int10/xf86x86emu.c create mode 100644 xorg-server/hw/xfree86/int10/xf86x86emu.h create mode 100644 xorg-server/hw/xfree86/loader/Makefile.am create mode 100644 xorg-server/hw/xfree86/loader/Makefile.in create mode 100644 xorg-server/hw/xfree86/loader/SparcMulDiv.S create mode 100644 xorg-server/hw/xfree86/loader/dixsym.c create mode 100644 xorg-server/hw/xfree86/loader/dlloader.c create mode 100644 xorg-server/hw/xfree86/loader/dlloader.h create mode 100644 xorg-server/hw/xfree86/loader/extsym.c create mode 100644 xorg-server/hw/xfree86/loader/fontsym.c create mode 100644 xorg-server/hw/xfree86/loader/loader.c create mode 100644 xorg-server/hw/xfree86/loader/loader.h create mode 100644 xorg-server/hw/xfree86/loader/loaderProcs.h create mode 100644 xorg-server/hw/xfree86/loader/loadext.c create mode 100644 xorg-server/hw/xfree86/loader/loadfont.c create mode 100644 xorg-server/hw/xfree86/loader/loadmod.c create mode 100644 xorg-server/hw/xfree86/loader/misym.c create mode 100644 xorg-server/hw/xfree86/loader/os.c create mode 100644 xorg-server/hw/xfree86/loader/sym.h create mode 100644 xorg-server/hw/xfree86/loader/xf86sym.c create mode 100644 xorg-server/hw/xfree86/modes/Makefile.am create mode 100644 xorg-server/hw/xfree86/modes/Makefile.in create mode 100644 xorg-server/hw/xfree86/modes/xf86Crtc.c create mode 100644 xorg-server/hw/xfree86/modes/xf86Crtc.h create mode 100644 xorg-server/hw/xfree86/modes/xf86Cursors.c create mode 100644 xorg-server/hw/xfree86/modes/xf86DiDGA.c create mode 100644 xorg-server/hw/xfree86/modes/xf86EdidModes.c create mode 100644 xorg-server/hw/xfree86/modes/xf86Modes.c create mode 100644 xorg-server/hw/xfree86/modes/xf86Modes.h create mode 100644 xorg-server/hw/xfree86/modes/xf86RandR12.c create mode 100644 xorg-server/hw/xfree86/modes/xf86RandR12.h create mode 100644 xorg-server/hw/xfree86/modes/xf86Rename.h create mode 100644 xorg-server/hw/xfree86/modes/xf86Rotate.c create mode 100644 xorg-server/hw/xfree86/modes/xf86cvt.c create mode 100644 xorg-server/hw/xfree86/modes/xf86gtf.c create mode 100644 xorg-server/hw/xfree86/os-support/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/README.OS-lib create mode 100644 xorg-server/hw/xfree86/os-support/assyntax.h create mode 100644 xorg-server/hw/xfree86/os-support/bsd/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/bsd/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/bsd/alpha_video.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/arm_video.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsdResource.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_init.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/i386_video.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/data.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/descr.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/parse.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/usage.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/usb_hid_usages create mode 100644 xorg-server/hw/xfree86/os-support/bsd/libusb/usbvar.h create mode 100644 xorg-server/hw/xfree86/os-support/bsd/memrange.h create mode 100644 xorg-server/hw/xfree86/os-support/bsd/ppc_video.c create mode 100644 xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/bus/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/bus/Pci.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/Pci.h create mode 100644 xorg-server/hw/xfree86/os-support/bus/Sbus.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/bsd_pci.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/ix86Pci.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/linuxPci.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/ppcPci.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/sparcPci.c create mode 100644 xorg-server/hw/xfree86/os-support/bus/xf86Pci.h create mode 100644 xorg-server/hw/xfree86/os-support/bus/xf86Sbus.h create mode 100644 xorg-server/hw/xfree86/os-support/hurd/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/hurd/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/hurd/hurd_bell.c create mode 100644 xorg-server/hw/xfree86/os-support/hurd/hurd_init.c create mode 100644 xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c create mode 100644 xorg-server/hw/xfree86/os-support/hurd/hurd_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/hurd/hurd_video.c create mode 100644 xorg-server/hw/xfree86/os-support/int10Defines.h create mode 100644 xorg-server/hw/xfree86/os-support/linux/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/linux/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/linux/int10/linux.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx.h create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnxResource.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_acpi.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_agp.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_apm.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_axp.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_bell.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_font.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_init.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_jstk.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_pci.c create mode 100644 xorg-server/hw/xfree86/os-support/linux/lnx_video.c create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/lynx_init.c create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/lynx_mmap.c create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/lynx_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/lynx_noinline.c create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.S create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.c create mode 100644 xorg-server/hw/xfree86/os-support/lynxos/lynx_video.c create mode 100644 xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.S create mode 100644 xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.c create mode 100644 xorg-server/hw/xfree86/os-support/misc/Delay.c create mode 100644 xorg-server/hw/xfree86/os-support/misc/IODelay.S create mode 100644 xorg-server/hw/xfree86/os-support/misc/IODelay.c create mode 100644 xorg-server/hw/xfree86/os-support/misc/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/misc/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/misc/PortIO.S create mode 100644 xorg-server/hw/xfree86/os-support/misc/SlowBcopy.S create mode 100644 xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c create mode 100644 xorg-server/hw/xfree86/os-support/misc/xf86_IlHack.c create mode 100644 xorg-server/hw/xfree86/os-support/misc/xf86_Util.c create mode 100644 xorg-server/hw/xfree86/os-support/sco/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/sco/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c create mode 100644 xorg-server/hw/xfree86/os-support/sco/sco_init.c create mode 100644 xorg-server/hw/xfree86/os-support/sco/sco_iop.c create mode 100644 xorg-server/hw/xfree86/os-support/sco/sco_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/sco/sco_video.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/agp_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/bios_devmem.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/bios_mmap.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/ia64Pci.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/inout.S create mode 100644 xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/kmod_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/pm_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/posix_tty.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/sigio.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/sigiostubs.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/stdResource.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/vidmem.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/xf86Axp.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/xf86Axp.h create mode 100644 xorg-server/hw/xfree86/os-support/solaris/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/solaris/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/solaris/agpgart.h create mode 100644 xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar create mode 100644 xorg-server/hw/xfree86/os-support/solaris/solaris-amd64.S create mode 100644 xorg-server/hw/xfree86/os-support/solaris/solaris-ia32.S create mode 100644 xorg-server/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S create mode 100644 xorg-server/hw/xfree86/os-support/solaris/sun_agp.c create mode 100644 xorg-server/hw/xfree86/os-support/solaris/sun_apm.c create mode 100644 xorg-server/hw/xfree86/os-support/solaris/sun_bell.c create mode 100644 xorg-server/hw/xfree86/os-support/solaris/sun_bios.c create mode 100644 xorg-server/hw/xfree86/os-support/solaris/sun_init.c create mode 100644 xorg-server/hw/xfree86/os-support/solaris/sun_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/solaris/sun_vid.c create mode 100644 xorg-server/hw/xfree86/os-support/sysv/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/sysv/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/sysv/sysv_init.c create mode 100644 xorg-server/hw/xfree86/os-support/sysv/sysv_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/sysv/sysv_video.c create mode 100644 xorg-server/hw/xfree86/os-support/usl/Makefile.am create mode 100644 xorg-server/hw/xfree86/os-support/usl/Makefile.in create mode 100644 xorg-server/hw/xfree86/os-support/usl/usl_init.c create mode 100644 xorg-server/hw/xfree86/os-support/usl/usl_iop.c create mode 100644 xorg-server/hw/xfree86/os-support/usl/usl_mouse.c create mode 100644 xorg-server/hw/xfree86/os-support/usl/usl_video.c create mode 100644 xorg-server/hw/xfree86/os-support/usl/usl_vtsw.c create mode 100644 xorg-server/hw/xfree86/os-support/xf86OSmouse.h create mode 100644 xorg-server/hw/xfree86/os-support/xf86OSpriv.h create mode 100644 xorg-server/hw/xfree86/os-support/xf86_OSlib.h create mode 100644 xorg-server/hw/xfree86/os-support/xf86_OSproc.h create mode 100644 xorg-server/hw/xfree86/os-support/xorgos.c create mode 100644 xorg-server/hw/xfree86/osandcommon.c create mode 100644 xorg-server/hw/xfree86/parser/Configint.h create mode 100644 xorg-server/hw/xfree86/parser/DRI.c create mode 100644 xorg-server/hw/xfree86/parser/Device.c create mode 100644 xorg-server/hw/xfree86/parser/Extensions.c create mode 100644 xorg-server/hw/xfree86/parser/Files.c create mode 100644 xorg-server/hw/xfree86/parser/Flags.c create mode 100644 xorg-server/hw/xfree86/parser/Input.c create mode 100644 xorg-server/hw/xfree86/parser/Layout.c create mode 100644 xorg-server/hw/xfree86/parser/Makefile.am create mode 100644 xorg-server/hw/xfree86/parser/Makefile.in create mode 100644 xorg-server/hw/xfree86/parser/Module.c create mode 100644 xorg-server/hw/xfree86/parser/Monitor.c create mode 100644 xorg-server/hw/xfree86/parser/Pointer.c create mode 100644 xorg-server/hw/xfree86/parser/Screen.c create mode 100644 xorg-server/hw/xfree86/parser/Vendor.c create mode 100644 xorg-server/hw/xfree86/parser/Video.c create mode 100644 xorg-server/hw/xfree86/parser/configProcs.h create mode 100644 xorg-server/hw/xfree86/parser/cpconfig.c create mode 100644 xorg-server/hw/xfree86/parser/read.c create mode 100644 xorg-server/hw/xfree86/parser/scan.c create mode 100644 xorg-server/hw/xfree86/parser/write.c create mode 100644 xorg-server/hw/xfree86/parser/xf86Optrec.h create mode 100644 xorg-server/hw/xfree86/parser/xf86Parser.h create mode 100644 xorg-server/hw/xfree86/parser/xf86tokens.h create mode 100644 xorg-server/hw/xfree86/rac/Makefile.am create mode 100644 xorg-server/hw/xfree86/rac/Makefile.in create mode 100644 xorg-server/hw/xfree86/rac/xf86RAC.c create mode 100644 xorg-server/hw/xfree86/rac/xf86RAC.h create mode 100644 xorg-server/hw/xfree86/ramdac/BT.c create mode 100644 xorg-server/hw/xfree86/ramdac/BT.h create mode 100644 xorg-server/hw/xfree86/ramdac/BTPriv.h create mode 100644 xorg-server/hw/xfree86/ramdac/CURSOR.NOTES create mode 100644 xorg-server/hw/xfree86/ramdac/IBM.c create mode 100644 xorg-server/hw/xfree86/ramdac/IBM.h create mode 100644 xorg-server/hw/xfree86/ramdac/IBMPriv.h create mode 100644 xorg-server/hw/xfree86/ramdac/Makefile.am create mode 100644 xorg-server/hw/xfree86/ramdac/Makefile.in create mode 100644 xorg-server/hw/xfree86/ramdac/TI.c create mode 100644 xorg-server/hw/xfree86/ramdac/TI.h create mode 100644 xorg-server/hw/xfree86/ramdac/TIPriv.h create mode 100644 xorg-server/hw/xfree86/ramdac/xf86BitOrder.c create mode 100644 xorg-server/hw/xfree86/ramdac/xf86Cursor.c create mode 100644 xorg-server/hw/xfree86/ramdac/xf86Cursor.h create mode 100644 xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h create mode 100644 xorg-server/hw/xfree86/ramdac/xf86HWCurs.c create mode 100644 xorg-server/hw/xfree86/ramdac/xf86RamDac.c create mode 100644 xorg-server/hw/xfree86/ramdac/xf86RamDac.h create mode 100644 xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c create mode 100644 xorg-server/hw/xfree86/ramdac/xf86RamDacPriv.h create mode 100644 xorg-server/hw/xfree86/shadowfb/Makefile.am create mode 100644 xorg-server/hw/xfree86/shadowfb/Makefile.in create mode 100644 xorg-server/hw/xfree86/shadowfb/sfbmodule.c create mode 100644 xorg-server/hw/xfree86/shadowfb/shadow.c create mode 100644 xorg-server/hw/xfree86/shadowfb/shadowfb.h create mode 100644 xorg-server/hw/xfree86/utils/Makefile.am create mode 100644 xorg-server/hw/xfree86/utils/Makefile.in create mode 100644 xorg-server/hw/xfree86/utils/cvt/Makefile.am create mode 100644 xorg-server/hw/xfree86/utils/cvt/Makefile.in create mode 100644 xorg-server/hw/xfree86/utils/cvt/cvt.c create mode 100644 xorg-server/hw/xfree86/utils/cvt/cvt.man.pre create mode 100644 xorg-server/hw/xfree86/utils/gtf/Makefile.am create mode 100644 xorg-server/hw/xfree86/utils/gtf/Makefile.in create mode 100644 xorg-server/hw/xfree86/utils/gtf/gtf.c create mode 100644 xorg-server/hw/xfree86/utils/gtf/gtf.man.pre create mode 100644 xorg-server/hw/xfree86/utils/ioport/Makefile.am create mode 100644 xorg-server/hw/xfree86/utils/ioport/Makefile.in create mode 100644 xorg-server/hw/xfree86/utils/ioport/ioport.c create mode 100644 xorg-server/hw/xfree86/utils/kbd_mode/Makefile.am create mode 100644 xorg-server/hw/xfree86/utils/kbd_mode/Makefile.in create mode 100644 xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c create mode 100644 xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre create mode 100644 xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c create mode 100644 xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/Makefile.am create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/Makefile.in create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/TODO create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/XOrgCfg.pre create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/accessx.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/card.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/card.xpm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/cards.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/cards.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/computer.xpm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/config.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/config.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/down.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/expert.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/help.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/help.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/interface.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xpm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/left.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/loader.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/loader.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/loadmod.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/monitor.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/monitor.xpm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/mouse.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/mouse.xpm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/narrower.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/options.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/options.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/right.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/screen.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/screen.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/shorter.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/startx.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/stubs.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/stubs.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/taller.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/text-mode.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/up.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/vidmode.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/vidmode.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/wider.xbm create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/xf86config.c create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/xf86config.h create mode 100644 xorg-server/hw/xfree86/utils/xorgcfg/xorgcfg.man.pre create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/Cards create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/Cards98 create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/Makefile.am create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/Makefile.in create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/cards.c create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/cards.h create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.c create mode 100644 xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.man.pre create mode 100644 xorg-server/hw/xfree86/vbe/Makefile.am create mode 100644 xorg-server/hw/xfree86/vbe/Makefile.in create mode 100644 xorg-server/hw/xfree86/vbe/vbe.c create mode 100644 xorg-server/hw/xfree86/vbe/vbe.h create mode 100644 xorg-server/hw/xfree86/vbe/vbeModes.c create mode 100644 xorg-server/hw/xfree86/vbe/vbeModes.h create mode 100644 xorg-server/hw/xfree86/vbe/vbe_module.c create mode 100644 xorg-server/hw/xfree86/vgahw/Makefile.am create mode 100644 xorg-server/hw/xfree86/vgahw/Makefile.in create mode 100644 xorg-server/hw/xfree86/vgahw/vgaCmap.c create mode 100644 xorg-server/hw/xfree86/vgahw/vgaHW.c create mode 100644 xorg-server/hw/xfree86/vgahw/vgaHW.h create mode 100644 xorg-server/hw/xfree86/vgahw/vgaHWmodule.c create mode 100644 xorg-server/hw/xfree86/x86emu/Makefile.am create mode 100644 xorg-server/hw/xfree86/x86emu/Makefile.in create mode 100644 xorg-server/hw/xfree86/x86emu/debug.c create mode 100644 xorg-server/hw/xfree86/x86emu/decode.c create mode 100644 xorg-server/hw/xfree86/x86emu/fpu.c create mode 100644 xorg-server/hw/xfree86/x86emu/ops.c create mode 100644 xorg-server/hw/xfree86/x86emu/ops2.c create mode 100644 xorg-server/hw/xfree86/x86emu/prim_ops.c create mode 100644 xorg-server/hw/xfree86/x86emu/sys.c create mode 100644 xorg-server/hw/xfree86/x86emu/validate.c create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/debug.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/decode.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/fpu.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/fpu_regs.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/ops.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/prim_asm.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/prim_ops.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/regs.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/types.h create mode 100644 xorg-server/hw/xfree86/x86emu/x86emu/x86emui.h create mode 100644 xorg-server/hw/xfree86/xaa/Makefile.am create mode 100644 xorg-server/hw/xfree86/xaa/Makefile.in create mode 100644 xorg-server/hw/xfree86/xaa/XAA.HOWTO create mode 100644 xorg-server/hw/xfree86/xaa/l-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/l-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/l-xaaTEGlyph.c create mode 100644 xorg-server/hw/xfree86/xaa/l3-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/l3-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/lf-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/lf-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/lf-xaaTEGlyph.c create mode 100644 xorg-server/hw/xfree86/xaa/lf3-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/lf3-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/m-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/m-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/m-xaaTEGlyph.c create mode 100644 xorg-server/hw/xfree86/xaa/m3-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/m3-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/mf-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/mf-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/mf-xaaTEGlyph.c create mode 100644 xorg-server/hw/xfree86/xaa/mf3-xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/mf3-xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/s-xaaDashLine.c create mode 100644 xorg-server/hw/xfree86/xaa/s-xaaLine.c create mode 100644 xorg-server/hw/xfree86/xaa/xaa.h create mode 100644 xorg-server/hw/xfree86/xaa/xaaBitBlt.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaBitOrder.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaBitmap.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaCpyArea.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaCpyPlane.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaCpyWin.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaDashLine.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaFallback.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaFillArc.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaFillPoly.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaFillRect.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaGC.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaGCmisc.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaImage.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaInit.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaInitAccel.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaLine.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaLineMisc.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaNonTEText.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaOffscreen.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaOverlay.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaOverlayDF.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaPCache.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaPict.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaROP.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaRect.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaSpans.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaStateChange.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaStipple.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaTEGlyph.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaTEGlyphBlt.S create mode 100644 xorg-server/hw/xfree86/xaa/xaaTEText.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaTables.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaWideLine.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaWrapper.c create mode 100644 xorg-server/hw/xfree86/xaa/xaaWrapper.h create mode 100644 xorg-server/hw/xfree86/xaa/xaacexp.h create mode 100644 xorg-server/hw/xfree86/xaa/xaalocal.h create mode 100644 xorg-server/hw/xfree86/xaa/xaarop.h create mode 100644 xorg-server/hw/xfree86/xaa/xaawrap.h create mode 100644 xorg-server/hw/xfree86/xf1bpp/Makefile.am create mode 100644 xorg-server/hw/xfree86/xf1bpp/Makefile.in create mode 100644 xorg-server/hw/xfree86/xf1bpp/maskbits.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbitblt.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbltC.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbltCI.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbltG.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbltO.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbltX.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbres.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbbresd.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbclip.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbcmap.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbfillarc.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbfillrct.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbfillsp.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbfont.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbgc.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbgetsp.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbhrzvert.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbigbblak.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbigbwht.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbimage.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbline.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbmap.h create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbmap.sh create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbmisc.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbmodule.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpablack.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpainv.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpawhite.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpgbblak.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpgbinv.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpgbwht.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpixmap.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbplyblack.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbplyinv.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbplywhite.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpolypnt.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbpushpxl.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbscrclse.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbscrinit.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbseg.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbsetsp.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbteblack.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbtewhite.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbtileC.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbtileG.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbunmap.h create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbunmap.sh create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbwindow.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/mfbzerarc.c create mode 100644 xorg-server/hw/xfree86/xf1bpp/xf1bpp.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/Makefile.am create mode 100644 xorg-server/hw/xfree86/xf4bpp/Makefile.in create mode 100644 xorg-server/hw/xfree86/xf4bpp/NOTES create mode 100644 xorg-server/hw/xfree86/xf4bpp/OScompiler.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/emulOpStip.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/emulRepAre.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/emulTile.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ibmTrace.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbbres.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbbresd.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbfillarc.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbhrzvert.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbimggblt.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbline.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbseg.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/mfbzerarc.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/offscreen.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcArea.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcCReduce.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcClip.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcCpArea.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcDepth.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcFillRct.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcGC.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcGCstr.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcGetSp.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcIO.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcImg.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcPixFS.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcPixmap.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcPolyPnt.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcQuery.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcRslvC.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcSetSp.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcSpMcro.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcWinFS.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/ppcWindow.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgaBitBlt.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgaGC.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgaImages.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgaReg.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgaSolid.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgaStipple.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgaVideo.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/vgamodule.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/wm3.c create mode 100644 xorg-server/hw/xfree86/xf4bpp/wm3.h create mode 100644 xorg-server/hw/xfree86/xf4bpp/xf4bpp.h create mode 100644 xorg-server/hw/xfree86/xf8_16bpp/Makefile.am create mode 100644 xorg-server/hw/xfree86/xf8_16bpp/Makefile.in create mode 100644 xorg-server/hw/xfree86/xf8_16bpp/cfb8_16.h create mode 100644 xorg-server/hw/xfree86/xf8_16bpp/xf8_16module.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/Makefile.am create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/Makefile.in create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfb8_32.h create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfb8_32module.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbcpyarea.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbcpyplane.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbgc.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbgc32.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbgc8.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbgcmisc.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbgcunder.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbimage.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbpntwin.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbscrinit.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/cfbwindow.c create mode 100644 xorg-server/hw/xfree86/xf8_32bpp/xf86overlay.c create mode 100644 xorg-server/hw/xfree86/xorg.c create mode 100644 xorg-server/hw/xfree86/xorgconf.cpp (limited to 'xorg-server/hw/xfree86') diff --git a/xorg-server/hw/xfree86/Makefile.am b/xorg-server/hw/xfree86/Makefile.am new file mode 100644 index 000000000..03c2c3a3f --- /dev/null +++ b/xorg-server/hw/xfree86/Makefile.am @@ -0,0 +1,119 @@ +include $(top_srcdir)/cpprules.in + +if DRI +DRI_SUBDIR = dri +endif + +if DRI2 +DRI2_SUBDIR = dri2 +endif + +if XF86UTILS +XF86UTILS_SUBDIR = utils +endif + +if MFB +MFB_SUBDIR = xf1bpp xf4bpp +endif + +if CFB +CFB_SUBDIR = xf8_32bpp +endif + +DOC_SUBDIR = doc + +SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support parser rac \ + ramdac shadowfb vbe vgahw xaa $(MFB_SUBDIR) $(CFB_SUBDIR) \ + xf8_16bpp loader dixmods exa modes \ + $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) $(DOC_SUBDIR) + +DIST_SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support \ + parser rac ramdac shadowfb vbe vgahw xaa xf1bpp xf4bpp \ + xf8_16bpp xf8_32bpp loader dixmods dri dri2 exa modes \ + utils doc + +bin_PROGRAMS = Xorg + +AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ +INCLUDES = @XORG_INCS@ + +Xorg_SOURCES = xorg.c + +# libxorgos and libcommon need symbols from each other +noinst_LTLIBRARIES = libosandcommon.la +libosandcommon_la_SOURCES = osandcommon.c +libosandcommon_la_LIBADD = \ + os-support/libxorgos.la \ + common/libcommon.la + +osandcommon.c xorg.c: + touch $@ + +DISTCLEANFILES = osandcommon.c xorg.c + +XORG_LIBS = \ + $(XSERVER_LIBS) \ + common/libinit.a \ + loader/libloader.a \ + libosandcommon.la \ + rac/librac.a \ + parser/libxf86config.a \ + dixmods/libdixmods.la \ + modes/libxf86modes.a \ + ramdac/libramdac.a \ + ddc/libddc.a \ + i2c/libi2c.a \ + dixmods/libxorgxkb.la \ + $(top_builddir)/mi/libmi.la \ + $(top_builddir)/os/libos.la \ + @XORG_LIBS@ \ + dixmods/libxorgxkb.la + +Xorg_DEPENDENCIES = $(XORG_LIBS) +Xorg_LDADD = $(XORG_LIBS) $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) + +Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) + +BUILT_SOURCES = xorg.conf.example +DISTCLEANFILES += xorg.conf.example xorg.conf.example.pre +EXTRA_DIST = xorgconf.cpp + +if SOLARIS_ASM_INLINE +# Needs to be built before any files are compiled when using Sun compilers +# so in*/out* inline definitions are properly processed. + +BUILT_SOURCES += os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il + +os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il: + cd os-support/solaris ; make solaris-@SOLARIS_INOUT_ARCH@.il +endif + +# do not use $(mkdir_p) if you want automake 1.7 to work +install-data-local: + mkdir -p $(DESTDIR)$(logdir) + + +install-exec-local: install-binPROGRAMS + (cd $(DESTDIR)$(bindir) && rm -f X && ln -s Xorg X) +if INSTALL_SETUID + chown root $(DESTDIR)$(bindir)/Xorg + chmod u+s $(DESTDIR)$(bindir)/Xorg +endif + +optionsdir = $(libdir)/X11 +dist_options_DATA = Options + +CPP_FILES_FLAGS = \ + -DLOCALFONTPATH="\"$(BASE_FONT_PATH)/local\"" \ + -DMISCFONTPATH="\"$(BASE_FONT_PATH)/misc\"" \ + -DT1FONTPATH="\"$(BASE_FONT_PATH)/Type1\"" \ + -DTRUETYPEFONTPATH="\"$(BASE_FONT_PATH)/TTF\"" \ + -DDPI75FONTPATH="\"$(BASE_FONT_PATH)/75dpi\"" \ + -DDPI100FONTPATH="\"$(BASE_FONT_PATH)/100dpi\"" \ + -DMODULEPATH=\"$(DEFAULT_MODULE_PATH)\" + +relink: + rm -f Xorg && $(MAKE) Xorg + +xorg.conf.example.pre: xorgconf.cpp + cp $(srcdir)/xorgconf.cpp $@ diff --git a/xorg-server/hw/xfree86/Makefile.in b/xorg-server/hw/xfree86/Makefile.in new file mode 100644 index 000000000..7bfe644b5 --- /dev/null +++ b/xorg-server/hw/xfree86/Makefile.in @@ -0,0 +1,971 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(dist_options_DATA) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/cpprules.in +bin_PROGRAMS = Xorg$(EXEEXT) + +# Needs to be built before any files are compiled when using Sun compilers +# so in*/out* inline definitions are properly processed. +@SOLARIS_ASM_INLINE_TRUE@am__append_1 = os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il +subdir = hw/xfree86 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libosandcommon_la_DEPENDENCIES = os-support/libxorgos.la \ + common/libcommon.la +am_libosandcommon_la_OBJECTS = osandcommon.lo +libosandcommon_la_OBJECTS = $(am_libosandcommon_la_OBJECTS) +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(optionsdir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_Xorg_OBJECTS = xorg.$(OBJEXT) +Xorg_OBJECTS = $(am_Xorg_OBJECTS) +am__DEPENDENCIES_1 = +am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) common/libinit.a \ + loader/libloader.a libosandcommon.la rac/librac.a \ + parser/libxf86config.a dixmods/libdixmods.la \ + modes/libxf86modes.a ramdac/libramdac.a ddc/libddc.a \ + i2c/libi2c.a dixmods/libxorgxkb.la $(top_builddir)/mi/libmi.la \ + $(top_builddir)/os/libos.la dixmods/libxorgxkb.la +Xorg_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xorg_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libosandcommon_la_SOURCES) $(Xorg_SOURCES) +DIST_SOURCES = $(libosandcommon_la_SOURCES) $(Xorg_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +dist_optionsDATA_INSTALL = $(INSTALL_DATA) +DATA = $(dist_options_DATA) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = \ + $(XSERVER_LIBS) \ + common/libinit.a \ + loader/libloader.a \ + libosandcommon.la \ + rac/librac.a \ + parser/libxf86config.a \ + dixmods/libdixmods.la \ + modes/libxf86modes.a \ + ramdac/libramdac.a \ + ddc/libddc.a \ + i2c/libi2c.a \ + dixmods/libxorgxkb.la \ + $(top_builddir)/mi/libmi.la \ + $(top_builddir)/os/libos.la \ + @XORG_LIBS@ \ + dixmods/libxorgxkb.la + +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +SUFFIXES = .pre .man .man.pre + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + +@DRI_TRUE@DRI_SUBDIR = dri +@DRI2_TRUE@DRI2_SUBDIR = dri2 +@XF86UTILS_TRUE@XF86UTILS_SUBDIR = utils +@MFB_TRUE@MFB_SUBDIR = xf1bpp xf4bpp +@CFB_TRUE@CFB_SUBDIR = xf8_32bpp +DOC_SUBDIR = doc +SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support parser rac \ + ramdac shadowfb vbe vgahw xaa $(MFB_SUBDIR) $(CFB_SUBDIR) \ + xf8_16bpp loader dixmods exa modes \ + $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) $(DOC_SUBDIR) + +DIST_SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support \ + parser rac ramdac shadowfb vbe vgahw xaa xf1bpp xf4bpp \ + xf8_16bpp xf8_32bpp loader dixmods dri dri2 exa modes \ + utils doc + +AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ +INCLUDES = @XORG_INCS@ +Xorg_SOURCES = xorg.c + +# libxorgos and libcommon need symbols from each other +noinst_LTLIBRARIES = libosandcommon.la +libosandcommon_la_SOURCES = osandcommon.c +libosandcommon_la_LIBADD = \ + os-support/libxorgos.la \ + common/libcommon.la + +DISTCLEANFILES = osandcommon.c xorg.c xorg.conf.example \ + xorg.conf.example.pre +Xorg_DEPENDENCIES = $(XORG_LIBS) +Xorg_LDADD = $(XORG_LIBS) $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) +Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) +BUILT_SOURCES = xorg.conf.example $(am__append_1) +EXTRA_DIST = xorgconf.cpp +optionsdir = $(libdir)/X11 +dist_options_DATA = Options +CPP_FILES_FLAGS = \ + -DLOCALFONTPATH="\"$(BASE_FONT_PATH)/local\"" \ + -DMISCFONTPATH="\"$(BASE_FONT_PATH)/misc\"" \ + -DT1FONTPATH="\"$(BASE_FONT_PATH)/Type1\"" \ + -DTRUETYPEFONTPATH="\"$(BASE_FONT_PATH)/TTF\"" \ + -DDPI75FONTPATH="\"$(BASE_FONT_PATH)/75dpi\"" \ + -DDPI100FONTPATH="\"$(BASE_FONT_PATH)/100dpi\"" \ + -DMODULEPATH=\"$(DEFAULT_MODULE_PATH)\" + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libosandcommon.la: $(libosandcommon_la_OBJECTS) $(libosandcommon_la_DEPENDENCIES) + $(LINK) $(libosandcommon_la_OBJECTS) $(libosandcommon_la_LIBADD) $(LIBS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +Xorg$(EXEEXT): $(Xorg_OBJECTS) $(Xorg_DEPENDENCIES) + @rm -f Xorg$(EXEEXT) + $(Xorg_LINK) $(Xorg_OBJECTS) $(Xorg_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osandcommon.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-dist_optionsDATA: $(dist_options_DATA) + @$(NORMAL_INSTALL) + test -z "$(optionsdir)" || $(MKDIR_P) "$(DESTDIR)$(optionsdir)" + @list='$(dist_options_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(dist_optionsDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(optionsdir)/$$f'"; \ + $(dist_optionsDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(optionsdir)/$$f"; \ + done + +uninstall-dist_optionsDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_options_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(optionsdir)/$$f'"; \ + rm -f "$(DESTDIR)$(optionsdir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(optionsdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-data-local install-dist_optionsDATA + +install-dvi: install-dvi-recursive + +install-exec-am: install-binPROGRAMS install-exec-local + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-dist_optionsDATA + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool clean-noinstLTLIBRARIES ctags \ + ctags-recursive distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-data-local \ + install-dist_optionsDATA install-dvi install-dvi-am \ + install-exec install-exec-am install-exec-local install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-dist_optionsDATA + + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ + +osandcommon.c xorg.c: + touch $@ + +@SOLARIS_ASM_INLINE_TRUE@os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il: +@SOLARIS_ASM_INLINE_TRUE@ cd os-support/solaris ; make solaris-@SOLARIS_INOUT_ARCH@.il + +# do not use $(mkdir_p) if you want automake 1.7 to work +install-data-local: + mkdir -p $(DESTDIR)$(logdir) + +install-exec-local: install-binPROGRAMS + (cd $(DESTDIR)$(bindir) && rm -f X && ln -s Xorg X) +@INSTALL_SETUID_TRUE@ chown root $(DESTDIR)$(bindir)/Xorg +@INSTALL_SETUID_TRUE@ chmod u+s $(DESTDIR)$(bindir)/Xorg + +relink: + rm -f Xorg && $(MAKE) Xorg + +xorg.conf.example.pre: xorgconf.cpp + cp $(srcdir)/xorgconf.cpp $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/Options b/xorg-server/hw/xfree86/Options new file mode 100644 index 000000000..c963cd3ce --- /dev/null +++ b/xorg-server/hw/xfree86/Options @@ -0,0 +1,409 @@ +!! +!! Copyright (c) 2001 by The XFree86 Project, Inc. +!! +!! Permission is hereby granted, free of charge, to any person obtaining a +!! copy of this software and associated documentation files (the "Software"), +!! to deal in the Software without restriction, including without limitation +!! the rights to use, copy, modify, merge, publish, distribute, sublicense, +!! and/or sell copies of the Software, and to permit persons to whom the +!! Software is furnished to do so, subject to the following conditions: +!! +!! The above copyright notice and this permission notice shall be included in +!! all copies or substantial portions of the Software. +!! +!! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +!! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +!! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +!! THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +!! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +!! OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +!! SOFTWARE. +!! +!! Except as contained in this notice, the name of the XFree86 Project shall +!! not be used in advertising or otherwise to promote the sale, use or other +!! dealings in this Software without prior written authorization from the +!! XFree86 Project. +!! +!! $XFree86: xc/programs/Xserver/hw/xfree86/Options,v 1.10 2003/02/15 06:46:30 paulo Exp $ + +!! XAA options +xaa.XaaNoCPUToScreenColorExpandFill:\ +Disables accelerated rectangular expansion blits from source patterns \ +stored in system memory (using a memory-mapped aperture). + +xaa.XaaNoColor8x8PatternFillRect:\ +Disables accelerated fills of a rectangular region with a full-color pattern. + +xaa.XaaNoColor8x8PatternFillTrap:\ +Disables accelerated fills of a trapezoidal region with a full-color pattern. + +xaa.XaaNoDashedBresenhamLine:\ +Disables accelerated dashed Bresenham line draws. + +xaa.XaaNoDashedTwoPointLine:\ +Disables accelerated dashed line draws between two arbitrary points. + +xaa.XaaNoImageWriteRect:\ +Disables acclerated transfers of full-color rectangular patterns from \ +system memory to video memory (using a memory-mapped aperture). + +xaa.XaaNoMono8x8PatternFillRect:\ +Disables accelerated fills of a rectangular region with a monochrome pattern. + +xaa.XaaNoMono8x8PatternFillTrap:\ +Disables accelerated fills of a trapezoidal region with a monochrome pattern. + +xaa.XaaNoOffscreenPixmaps:\ +Disables accelerated draws into pixmaps stored in offscreen video memory. + +xaa.XaaNoPixmapCache:\ +Disables caching of patterns in offscreen video memory. + +xaa.XaaNoScanlineCPUToScreenColorExpandFill:\ +Disables accelerated rectangular expansion blits from source patterns \ +stored in system memory (one scan line at a time). + +xaa.XaaNoScanlineImageWriteRect:\ +Disables accelerated transfers of full-color rectangular patterns from \ +system memory to video memory (one scan line at a time). + +xaa.XaaNoScreenToScreenColorExpandFill:\ +Disables accelerated rectangular expansion blits from source patterns \ +stored in off-screen video memory. + +xaa.XaaNoScreenToScreenCopy:\ +Disables accelerated copies of rectangular regions from one part of video \ +memory to another part of video memory. + +xaa.XaaNoSolidBresenhamLine:\ +Disables accelerated solid Bresenham line draws. + +xaa.XaaNoSolidFillRect:\ +Disables accelerated solid-color fills of rectangles. + +xaa.XaaNoSolidFillTrap:\ +Disables accelerated solid-color fills of Bresenham trapezoids. + +xaa.XaaNoSolidHorVertLine:\ +Disables accelerated solid horizontal and vertical line draws. + +xaa.XaaNoSolidTwoPointLine:\ +Disables accelerated solid line draws between two arbitrary points. + + +!! DDC Options +ddc.NoDDC:\ +Disables DDC (Display Data Channel) so that the Xserver doesn't try to talk to\ +the Monitor. \ +Default: off, implies DDC is used. + +ddc.NoDDC1:\ +Disables use of DDC version 1 (DDC using vertical refresh). \ +Default: off, implies DDC1 is used. + +ddc.NoDDC2:\ +Disables use of DDC version 2 (DDC using I2C - usually over vga connector). \ +Default: off, implies DDC2 is used. + + +!! FBDev options +fbdev.fbdev:\ +The framebuffer device to use. \ +Default: /dev/fb0. + +fbdev.ShadowFB:\ +Enable or disable use of the shadow framebuffer layer. \ +Default: on. + +fbdev.Rotate:\ +Enable rotation of the display. The supported values are "CW" (clockwise, \ +90 degrees), "UD" (upside down, 180 degrees) and "CCW" (counter clockwise, \ +270 degrees). Implies use of the shadow framebuffer layer. \ +Default: off. + + +!! MGA options +mga.ColorKey:\ +Set the colormap index used for the transparency key for the depth 8 plane \ +when operating in 8+24 overlay mode. The value must be in the range 2-255. \ +Default: 255. + +!mga.HWcursor:\ +!Enable or disable the HW cursor. Default: on. + +mga.MGASDRAM:\ +Specify whether G100, G200 or G400 cards have SDRAM. The driver attempts to \ +auto-detect this based on the card's PCI subsystem ID. This option may be \ +used to override that auto-detection. The mga driver is not able to \ +auto-detect the presence of of SDRAM on secondary heads in multihead \ +configurations so this option will often need to be specified in multihead \ +configurations. Default: auto-detected. + +mga.NoAccel:\ +Disable or enable 2D hardware acceleration. Default: acceleration is enabled. + +mga.OverclockMem:\ +Set clocks to values used by some commercial X-Servers (G100, G200 and \ +G400 only). Default: off. + +mga.Overlay:\ +Enable 8+24 overlay mode. Only appropriate for depth 24. (Note: the G100 is \ +unaccelerated in the 8+24 overlay mode due to a missing hardware feature). \ +Default: off. + +mga.PciRetry:\ +Enable or disable PCI retries. Default: off. + +mga.Rotate:\ +Rotate the display clockwise or counterclockwise. This mode is unaccelerated. \ +Default: no rotation. + +mga.ShadowFB:\ +Enable or disable use of the shadow framebuffer layer. Default: off. \ + +mga.SyncOnGreen:\ +Enable or disable combining the sync signals with the green signal. \ +Default: off. + +mga.UseFBDev:\ +Enable or disable use of on OS-specific fb interface (and is not supported \ +on all OSs). See fbdevhw(4) for further information. Default: off. + +mga.VideoKey:\ +This sets the default pixel value for the YUV video overlay key. \ +Default: undefined. + +mga.TexturedVideo:\ +This has XvImage support use the texture engine rather than the video \ +overlay. This option is only supported by the G200 and G400, and only in \ +16 and 32 bits per pixel. Default: off. + +mga.NoHal:\ +Matrox provides a "Hardware Abstraction Layer", \ +a separate binary which enables extra hardware features from G400 onwards. \ +Default: HAL is used. + +!mga.DigitalScreen:\ +! Option Ignored. Drivers auto-detect Digital output if they support it at all. +!Default: Auto-detected. + +! mga.TV:\ +! Option Ignored. Drivers auto-detect TV if they support TV out at all. +!Default: Auto-detected. + +mga.TVStandard:\ +(HAL only) Picture standard for TV out. Use "PAL" for 50Hz PAL. \ +Default: 60Hz NTSC. + +mga.CableType:\ +(HAL only) Set the cable type for TV out. Options are "SCART_RGB", \ +"SCART_COMPOSITE", or "SCART_TYPE2". Any other string enables the default. \ +Default: YC_COMPOSITE. + +mga.SwappedHead:\ +(HAL only) For Dual Head cards, reverse relationship between CRTC picture \ +generators and video output sockets. \ +Especially useful with TV or digital outputs. \ +Default: CRTC1 generates output for socket 1 and CRTC2 generates output for socket 2. + +mga.Crtc2Half:\ +In dual head mode, allow CRTC2 to use half of the video memory. \ +Default: CRTC2 uses min{8MB, half video RAM}, but see also Crtc2Ram. + +mga.Crtc2Ram:\ +In dual head mode, CRTC2 will use this many KB of video memory. \ +Overrrides Crtc2Half. \ +Default: CRTC2 uses min{8MB, half video RAM}, but see also Crtc2Half. + +mga.ShowCache:\ +An option for hackers. The pixmap cache lives in off-screen video memory. \ +This option extends the virtual desktop to show this part of video memory. \ +Default: Off. + +mga.AGPMode:\ +AGP bus speed multiplier, used by DRI. \ +Default: x1 (slowest but most stable). + + +!! R128 options + +!r128.SWcursor: \ +!Selects software cursor. \ +!Default: off. + +r128.NoAccel:\ +Enables or disables all hardware acceleration. \ +Default: on. + +r128.Dac6Bit:\ +Enables or disables the use of 6 bits per color component when in 8 bpp \ +mode (emulates VGA mode). \ +Default: off. + +r128.VideoKey:\ +This overrides the default pixel value for the YUV video overlay key. \ +Default: undefined. + +r128.Display:\ +Select display mode for devices which support flat panels. Supported\ +modes are "FP", "CRT", "Mirror", "BIOS". \ +Default: "FP". + +r128.ProgramFPRegs:\ +Enable or disable programming of the flat panel registers.\ +Beware that this may damage your panel, so use at your own risk. \ +Default: device dependant. + +r128.PanelWidth:\ +Override flat panel width in pixels. \ +Default: determined using BIOS. + +r128.PanelHeight:\ +Override flat panel height in pixels. \ +Default: determined using BIOS. + +r128.UseFBDev:\ +Enable or disable use of on OS-specific fb interface (and is not supported \ +on all OSs). See fbdevhw(4) for further information. Default: off. + +r128.DMAForXv:\ +Try or don't try to use DMA for Xv image transfers. This will reduce CPU \ +usage when playing big videos like DVDs, but may cause instabilities. \ +Default: off. + + +!! Radeon options + +radeon.SWcursor:\ +Selects software cursor. Default: off. + +radeon.NoAccel:\ +Disables all hardware acceleration. Default: off. + +radeon.Dac6Bit:\ +Enables or disables the use of 6 bits per color component when in 8 bpp \ +mode (emulates VGA mode). Default: off. + +radeon.VideoKey:\ +This overrides the default pixel value for the YUV video overlay key. \ +Default: undefined. + +radeon.UseFBDev:\ +Enable or disable use of an OS-specific framebuffer device interface \ +(which is not supported on all OSs). Default: off. + +radeon.AGPMode:\ +Set AGP data transfer rate. (used only when DRI is enabled) \ +Valid choices: 1 (default), 2 and 4 + +radeon.AGPFastWrite:\ +Enable AGP fast write. (used only when DRI is enabled) \ +Default: off. + +radeon.ForcePCIMode:\ +Force to use PCI GART for DRI acceleration. (used only when DRI is enabled) \ +Default: off. + +radeon.DDCMode:\ +Force to use the modes queried from the connected monitor. Default: off. + +radeon.CloneDisplay:\ +This option is only used for dual-head cards with only single screen section \ +specified in the configuration file. Valid choices: \ +0 - disable (one CRTC used for both heads) \ +1 - auto-detect (default) \ +2 - force on \ +3 - auto-detect + 2nd head overlay \ +4 - force on + 2nd head overlay \ + +radeon.CloneMode:\ +Set the first mode for the secondary head. It can be different from the modes \ +used for the primary head. If you don't have this line while clone is on, the \ +modes specified for the primary head will be used for the secondary head. + +radeon.CloneHSync:\ +Set the horizontal sync range for the secondary monitor. It is not required if \ +a DDC capable monitor is connected. Default: undefined. + +radeon.CloneVRefresh:\ +Set the vertical refresh range for the secondary monitor. It is not required \ +if a DDC capable monitor is connected. Default: undefined. + +radeon.PanelOff:\ +Disable panel output. Only used when clone is enabled. Default: off. + +radeon.EnablePageFlip:\ +Enable page flipping for 3D acceleration. This will increase performance but \ +not work correctly in some rare cases. Default: off. + + +!! NeoMagic options + +neo.StrangeLockups:\ +Before XFree86 version 4.2.0 many NeoMagic systems experienced \ +strange lockups unless they used the options \ +"XaaNoScanlineImageWriteRect" and "XaaNoScanlineCPUToScreenColorExpandFill". \ +Setting this to "No" is faster but will lock some machines. \ +Default: Yes. + +!! Vesa options +vesa.ShadowFB:\ +Enable or disable use of the shadow framebuffer layer. See shadowfb(4)\ +for further information. Default: on. + + +!! SiS Options +sis.NoAccel:\ +Disable or enable acceleration. \ +Default: acceleration is enabled. + +!sis.HWcursor:\ +!Enable or disable the HW cursor. \ +!Default: on. + +!sis.SWcursor:\ +!The opposite of HWCursor. \ +!Default: on. + +sis.NoXVideo:\ +Disable XV (XVideo) extension support. \ +Default: off. + +sis.SetMClk:\ +Set the memory clock in MHz. \ +Default: autodetect. + +sis.PciRetry:\ +Enable or disable PCI retries. \ +Default: on. + +sis.TurboQueue:\ +Enable or disable TurboQueue mode. \ +Default: off for SIS530, on for the others. + +sis.FastVram:\ +Enable or disable FastVram mode. \ +Default: on. + +sis.Rotate:\ +Rotate the display clockwise (CW) or counterclockwise (CCW). \ +This mode is unaccelerated, and uses the Shadow Frame Buffer layer \ +Default: no rotation. + +sis.ForceCRT2Type:\ +Force display type to one of: TV, LCD or VGA. \ +Default: autodetect. + +sis.ShadowFB:\ +Enable or disable use of the shadow framebuffer layer. See shadowfb(4) for \ +further information. Default: off. + +!! Generic driver options, apply to many drivers + +*.SWcursor:\ +See also HWcursor.\ +Default: Usually Off. + +*.HWcursor:\ +Use the hardware cursor. See also SWcursor. \ +Default: usually HWcursor, but some drivers may default to software. diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am new file mode 100644 index 000000000..1379f457c --- /dev/null +++ b/xorg-server/hw/xfree86/common/Makefile.am @@ -0,0 +1,97 @@ +noinst_LIBRARIES = libinit.a +noinst_LTLIBRARIES = libcommon.la + +if XORG_BUS_SPARC +SBUS_SOURCES = xf86sbusBus.c +endif + +if DEBUG +DEBUGSOURCES = xf86Debug.c +endif + +if XV +XVSOURCES = xf86xv.c xf86xvmc.c +XVSDKINCS = xf86xv.h xf86xvmc.h +endif + +XKBSOURCES = xf86XKB.c +XISOURCES = xf86Xinput.c xisb.c +XISDKINCS = xf86Xinput.h xisb.h +RANDRSOURCES = xf86RandR.c + +BUSSOURCES = xf86isaBus.c xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES) + +MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes + +xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES) + cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@ + echo >> $@ + +BUILT_SOURCES = xf86DefModeSet.c + +AM_LDFLAGS = -r +libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \ + xf86Cursor.c xf86DGA.c xf86DPMS.c \ + xf86DoProbe.c xf86Events.c \ + xf86Globals.c xf86AutoConfig.c \ + xf86MiscExt.c xf86Option.c \ + xf86VidMode.c xf86fbman.c xf86cmap.c \ + xf86Helper.c xf86PM.c \ + xf86Mode.c xf86Build.h xorgHelper.c xf86Versions.c \ + $(XVSOURCES) $(BUSSOURCES) $(XKBSOURCES) \ + $(DEBUGSOURCES) $(XISOURCES) $(RANDRSOURCES) +nodist_libcommon_la_SOURCES = xf86DefModeSet.c +libinit_a_SOURCES = xf86Build.h xf86Init.c + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ + -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod + +sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \ + xf86PciInfo.h xf86Priv.h xf86Privstr.h xf86Resources.h \ + xf86cmap.h xf86fbman.h xf86str.h $(XISDKINCS) \ + $(XVSDKINCS) atKeynames.h xf86Version.h xorgVersion.h \ + xf86sbusBus.h xf86xv.h xf86xvmc.h xf86xvpriv.h + +DISTCLEANFILES = xf86Build.h +CLEANFILES = $(BUILT_SOURCES) + +EXTRA_DIST = \ + atKeynames.h \ + compiler.h \ + fourcc.h \ + scoasm.h \ + xf86.h \ + xf86Build.h \ + xf86Bus.h \ + xf86Config.h \ + xf86InPriv.h \ + xf86Module.h \ + xf86Opt.h \ + xf86PciInfo.h \ + xf86Priv.h \ + xf86Privstr.h \ + xf86Resources.h \ + xf86Xinput.h \ + xf86cmap.h \ + xf86fbman.h \ + xf86pciBus.h \ + xf86str.h \ + xf86xv.h \ + xf86xvmc.h \ + xf86xvpriv.h \ + xisb.h \ + xf86Build.h.in \ + xf86Version.h \ + xorgVersion.h \ + xf86Date.h \ + $(MODEDEFSOURCES) \ + modeline2c.awk \ + $(DISTKBDSOURCES) + +if LNXACPI +XORG_CFLAGS += -DHAVE_ACPI +endif + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xfree86/common/Makefile.in b/xorg-server/hw/xfree86/common/Makefile.in new file mode 100644 index 000000000..443492823 --- /dev/null +++ b/xorg-server/hw/xfree86/common/Makefile.in @@ -0,0 +1,836 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@LNXACPI_TRUE@am__append_1 = -DHAVE_ACPI +subdir = hw/xfree86/common +DIST_COMMON = $(am__sdk_HEADERS_DIST) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/xf86Build.h.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = xf86Build.h +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libinit_a_AR = $(AR) $(ARFLAGS) +libinit_a_LIBADD = +am_libinit_a_OBJECTS = xf86Init.$(OBJEXT) +libinit_a_OBJECTS = $(am_libinit_a_OBJECTS) +LTLIBRARIES = $(noinst_LTLIBRARIES) +libcommon_la_LIBADD = +am__libcommon_la_SOURCES_DIST = xf86Configure.c xf86Bus.c xf86Config.c \ + xf86Cursor.c xf86DGA.c xf86DPMS.c xf86DoProbe.c xf86Events.c \ + xf86Globals.c xf86AutoConfig.c xf86MiscExt.c xf86Option.c \ + xf86VidMode.c xf86fbman.c xf86cmap.c xf86Helper.c xf86PM.c \ + xf86Mode.c xf86Build.h xorgHelper.c xf86Versions.c xf86xv.c \ + xf86xvmc.c xf86isaBus.c xf86pciBus.c xf86fbBus.c xf86noBus.c \ + xf86sbusBus.c xf86XKB.c xf86Debug.c xf86Xinput.c xisb.c \ + xf86RandR.c +@XV_TRUE@am__objects_1 = xf86xv.lo xf86xvmc.lo +@XORG_BUS_SPARC_TRUE@am__objects_2 = xf86sbusBus.lo +am__objects_3 = xf86isaBus.lo xf86pciBus.lo xf86fbBus.lo xf86noBus.lo \ + $(am__objects_2) +am__objects_4 = xf86XKB.lo +@DEBUG_TRUE@am__objects_5 = xf86Debug.lo +am__objects_6 = xf86Xinput.lo xisb.lo +am__objects_7 = xf86RandR.lo +am_libcommon_la_OBJECTS = xf86Configure.lo xf86Bus.lo xf86Config.lo \ + xf86Cursor.lo xf86DGA.lo xf86DPMS.lo xf86DoProbe.lo \ + xf86Events.lo xf86Globals.lo xf86AutoConfig.lo xf86MiscExt.lo \ + xf86Option.lo xf86VidMode.lo xf86fbman.lo xf86cmap.lo \ + xf86Helper.lo xf86PM.lo xf86Mode.lo xorgHelper.lo \ + xf86Versions.lo $(am__objects_1) $(am__objects_3) \ + $(am__objects_4) $(am__objects_5) $(am__objects_6) \ + $(am__objects_7) +nodist_libcommon_la_OBJECTS = xf86DefModeSet.lo +libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) \ + $(nodist_libcommon_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libinit_a_SOURCES) $(libcommon_la_SOURCES) \ + $(nodist_libcommon_la_SOURCES) +DIST_SOURCES = $(libinit_a_SOURCES) $(am__libcommon_la_SOURCES_DIST) +am__sdk_HEADERS_DIST = compiler.h fourcc.h xf86.h xf86Module.h \ + xf86Opt.h xf86PciInfo.h xf86Priv.h xf86Privstr.h \ + xf86Resources.h xf86cmap.h xf86fbman.h xf86str.h xf86Xinput.h \ + xisb.h xf86xv.h xf86xvmc.h atKeynames.h xf86Version.h \ + xorgVersion.h xf86sbusBus.h xf86xvpriv.h +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ $(am__append_1) +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = libinit.a +noinst_LTLIBRARIES = libcommon.la +@XORG_BUS_SPARC_TRUE@SBUS_SOURCES = xf86sbusBus.c +@DEBUG_TRUE@DEBUGSOURCES = xf86Debug.c +@XV_TRUE@XVSOURCES = xf86xv.c xf86xvmc.c +@XV_TRUE@XVSDKINCS = xf86xv.h xf86xvmc.h +XKBSOURCES = xf86XKB.c +XISOURCES = xf86Xinput.c xisb.c +XISDKINCS = xf86Xinput.h xisb.h +RANDRSOURCES = xf86RandR.c +BUSSOURCES = xf86isaBus.c xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES) +MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes +BUILT_SOURCES = xf86DefModeSet.c +AM_LDFLAGS = -r +libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \ + xf86Cursor.c xf86DGA.c xf86DPMS.c \ + xf86DoProbe.c xf86Events.c \ + xf86Globals.c xf86AutoConfig.c \ + xf86MiscExt.c xf86Option.c \ + xf86VidMode.c xf86fbman.c xf86cmap.c \ + xf86Helper.c xf86PM.c \ + xf86Mode.c xf86Build.h xorgHelper.c xf86Versions.c \ + $(XVSOURCES) $(BUSSOURCES) $(XKBSOURCES) \ + $(DEBUGSOURCES) $(XISOURCES) $(RANDRSOURCES) + +nodist_libcommon_la_SOURCES = xf86DefModeSet.c +libinit_a_SOURCES = xf86Build.h xf86Init.c +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ + -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod + +sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \ + xf86PciInfo.h xf86Priv.h xf86Privstr.h xf86Resources.h \ + xf86cmap.h xf86fbman.h xf86str.h $(XISDKINCS) \ + $(XVSDKINCS) atKeynames.h xf86Version.h xorgVersion.h \ + xf86sbusBus.h xf86xv.h xf86xvmc.h xf86xvpriv.h + +DISTCLEANFILES = xf86Build.h +CLEANFILES = $(BUILT_SOURCES) +EXTRA_DIST = \ + atKeynames.h \ + compiler.h \ + fourcc.h \ + scoasm.h \ + xf86.h \ + xf86Build.h \ + xf86Bus.h \ + xf86Config.h \ + xf86InPriv.h \ + xf86Module.h \ + xf86Opt.h \ + xf86PciInfo.h \ + xf86Priv.h \ + xf86Privstr.h \ + xf86Resources.h \ + xf86Xinput.h \ + xf86cmap.h \ + xf86fbman.h \ + xf86pciBus.h \ + xf86str.h \ + xf86xv.h \ + xf86xvmc.h \ + xf86xvpriv.h \ + xisb.h \ + xf86Build.h.in \ + xf86Version.h \ + xorgVersion.h \ + xf86Date.h \ + $(MODEDEFSOURCES) \ + modeline2c.awk \ + $(DISTKBDSOURCES) + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/common/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/common/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +xf86Build.h: $(top_builddir)/config.status $(srcdir)/xf86Build.h.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libinit.a: $(libinit_a_OBJECTS) $(libinit_a_DEPENDENCIES) + -rm -f libinit.a + $(libinit_a_AR) libinit.a $(libinit_a_OBJECTS) $(libinit_a_LIBADD) + $(RANLIB) libinit.a + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libcommon.la: $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) + $(LINK) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86AutoConfig.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Bus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Configure.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Cursor.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DGA.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DPMS.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Debug.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DefModeSet.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DoProbe.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Events.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Globals.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Helper.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86MiscExt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Mode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Option.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86PM.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86RandR.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Versions.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86VidMode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86XKB.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Xinput.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86cmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86fbBus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86fbman.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86isaBus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86noBus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86pciBus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86sbusBus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86xv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86xvmc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xisb.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgHelper.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-sdkHEADERS + + +xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES) + cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@ + echo >> $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/common/atKeynames.h b/xorg-server/hw/xfree86/common/atKeynames.h new file mode 100644 index 000000000..85f13ac32 --- /dev/null +++ b/xorg-server/hw/xfree86/common/atKeynames.h @@ -0,0 +1,295 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * 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 Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _ATKEYNAMES_H +#define _ATKEYNAMES_H + +#define XK_TECHNICAL +#define XK_KATAKANA +#include +#include + +#define GLYPHS_PER_KEY 4 +#define NUM_KEYCODES 248 +#define MIN_KEYCODE 8 +#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1) + +#define AltMask Mod1Mask +#define NumLockMask Mod2Mask +#define AltLangMask Mod3Mask +#define KanaMask Mod4Mask +#define ScrollLockMask Mod5Mask + +#define KeyPressed(k) (keyc->postdown[k >> 3] & (1 << (k & 7))) +#define ModifierDown(k) ((keyc->state & (k)) == (k)) + +/* + * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three) + * sets of scancodes. Set3 can only be generated by a MF keyboard. + * Set2 sends a makecode for keypress, and the same code prefixed by a + * F0 for keyrelease. This is a little bit ugly to handle. Thus we use + * here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes. + * Bit 7 ist set if the key is released. The code E0 switches to a + * different meaning to add the new MF cursorkeys, while not breaking old + * applications. E1 is another special prefix. Since I assume that there + * will be further versions of PC/XT scancode compatible keyboards, we + * may be in trouble one day. + * + * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3. + * 2) Use the keyboards native set and translate it to common keysyms. + */ + +/* + * definition of the AT84/MF101/MF102 Keyboard: + * ============================================================ + * Defined Key Cap Glyphs Pressed value + * Key Name Main Also (hex) (dec) + * ---------------- ---------- ------- ------ ------ + */ + +#define KEY_Escape /* Escape 0x01 */ 1 +#define KEY_1 /* 1 ! 0x02 */ 2 +#define KEY_2 /* 2 @ 0x03 */ 3 +#define KEY_3 /* 3 # 0x04 */ 4 +#define KEY_4 /* 4 $ 0x05 */ 5 +#define KEY_5 /* 5 % 0x06 */ 6 +#define KEY_6 /* 6 ^ 0x07 */ 7 +#define KEY_7 /* 7 & 0x08 */ 8 +#define KEY_8 /* 8 * 0x09 */ 9 +#define KEY_9 /* 9 ( 0x0a */ 10 +#define KEY_0 /* 0 ) 0x0b */ 11 +#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12 +#define KEY_Equal /* = (Equal) + 0x0d */ 13 +#define KEY_BackSpace /* Back Space 0x0e */ 14 +#define KEY_Tab /* Tab 0x0f */ 15 +#define KEY_Q /* Q 0x10 */ 16 +#define KEY_W /* W 0x11 */ 17 +#define KEY_E /* E 0x12 */ 18 +#define KEY_R /* R 0x13 */ 19 +#define KEY_T /* T 0x14 */ 20 +#define KEY_Y /* Y 0x15 */ 21 +#define KEY_U /* U 0x16 */ 22 +#define KEY_I /* I 0x17 */ 23 +#define KEY_O /* O 0x18 */ 24 +#define KEY_P /* P 0x19 */ 25 +#define KEY_LBrace /* [ { 0x1a */ 26 +#define KEY_RBrace /* ] } 0x1b */ 27 +#define KEY_Enter /* Enter 0x1c */ 28 +#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29 +#define KEY_A /* A 0x1e */ 30 +#define KEY_S /* S 0x1f */ 31 +#define KEY_D /* D 0x20 */ 32 +#define KEY_F /* F 0x21 */ 33 +#define KEY_G /* G 0x22 */ 34 +#define KEY_H /* H 0x23 */ 35 +#define KEY_J /* J 0x24 */ 36 +#define KEY_K /* K 0x25 */ 37 +#define KEY_L /* L 0x26 */ 38 +#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39 +#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40 +#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41 +#define KEY_ShiftL /* Shift(left) 0x2a */ 42 +#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43 +#define KEY_Z /* Z 0x2c */ 44 +#define KEY_X /* X 0x2d */ 45 +#define KEY_C /* C 0x2e */ 46 +#define KEY_V /* V 0x2f */ 47 +#define KEY_B /* B 0x30 */ 48 +#define KEY_N /* N 0x31 */ 49 +#define KEY_M /* M 0x32 */ 50 +#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51 +#define KEY_Period /* . (Period) >(Greater)0x34 */ 52 +#define KEY_Slash /* / (Slash) ? 0x35 */ 53 +#define KEY_ShiftR /* Shift(right) 0x36 */ 54 +#define KEY_KP_Multiply /* * 0x37 */ 55 +#define KEY_Alt /* Alt(left) 0x38 */ 56 +#define KEY_Space /* (SpaceBar) 0x39 */ 57 +#define KEY_CapsLock /* CapsLock 0x3a */ 58 +#define KEY_F1 /* F1 0x3b */ 59 +#define KEY_F2 /* F2 0x3c */ 60 +#define KEY_F3 /* F3 0x3d */ 61 +#define KEY_F4 /* F4 0x3e */ 62 +#define KEY_F5 /* F5 0x3f */ 63 +#define KEY_F6 /* F6 0x40 */ 64 +#define KEY_F7 /* F7 0x41 */ 65 +#define KEY_F8 /* F8 0x42 */ 66 +#define KEY_F9 /* F9 0x43 */ 67 +#define KEY_F10 /* F10 0x44 */ 68 +#define KEY_NumLock /* NumLock 0x45 */ 69 +#define KEY_ScrollLock /* ScrollLock 0x46 */ 70 +#define KEY_KP_7 /* 7 Home 0x47 */ 71 +#define KEY_KP_8 /* 8 Up 0x48 */ 72 +#define KEY_KP_9 /* 9 PgUp 0x49 */ 73 +#define KEY_KP_Minus /* - (Minus) 0x4a */ 74 +#define KEY_KP_4 /* 4 Left 0x4b */ 75 +#define KEY_KP_5 /* 5 0x4c */ 76 +#define KEY_KP_6 /* 6 Right 0x4d */ 77 +#define KEY_KP_Plus /* + (Plus) 0x4e */ 78 +#define KEY_KP_1 /* 1 End 0x4f */ 79 +#define KEY_KP_2 /* 2 Down 0x50 */ 80 +#define KEY_KP_3 /* 3 PgDown 0x51 */ 81 +#define KEY_KP_0 /* 0 Insert 0x52 */ 82 +#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83 +#define KEY_SysReqest /* SysReqest 0x54 */ 84 + /* NOTUSED 0x55 */ +#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86 +#define KEY_F11 /* F11 0x57 */ 87 +#define KEY_F12 /* F12 0x58 */ 88 + +#define KEY_Prefix0 /* special 0x60 */ 96 +#define KEY_Prefix1 /* specail 0x61 */ 97 + +/* + * The 'scancodes' below are generated by the server, because the MF101/102 + * keyboard sends them as sequence of other scancodes + */ +#define KEY_Home /* Home 0x59 */ 89 +#define KEY_Up /* Up 0x5a */ 90 +#define KEY_PgUp /* PgUp 0x5b */ 91 +#define KEY_Left /* Left 0x5c */ 92 +#define KEY_Begin /* Begin 0x5d */ 93 +#define KEY_Right /* Right 0x5e */ 94 +#define KEY_End /* End 0x5f */ 95 +#define KEY_Down /* Down 0x60 */ 96 +#define KEY_PgDown /* PgDown 0x61 */ 97 +#define KEY_Insert /* Insert 0x62 */ 98 +#define KEY_Delete /* Delete 0x63 */ 99 +#define KEY_KP_Enter /* Enter 0x64 */ 100 +#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101 +#define KEY_Pause /* Pause 0x66 */ 102 +#define KEY_Print /* Print 0x67 */ 103 +#define KEY_KP_Divide /* Divide 0x68 */ 104 +#define KEY_AltLang /* AtlLang(right) 0x69 */ 105 +#define KEY_Break /* Break 0x6a */ 106 +#define KEY_LMeta /* Left Meta 0x6b */ 107 +#define KEY_RMeta /* Right Meta 0x6c */ 108 +#define KEY_Menu /* Menu 0x6d */ 109 +#define KEY_F13 /* F13 0x6e */ 110 +#define KEY_F14 /* F14 0x6f */ 111 +#define KEY_F15 /* F15 0x70 */ 112 +#define KEY_HKTG /* Hirugana/Katakana tog 0x70 */ 112 +#define KEY_F16 /* F16 0x71 */ 113 +#define KEY_F17 /* F17 0x72 */ 114 +#define KEY_KP_DEC /* KP_DEC 0x73 */ 115 +#define KEY_BSlash2 /* \ _ 0x73 */ 115 +#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118 +#define KEY_XFER /* Kanji Transfer 0x79 */ 121 +#define KEY_NFER /* No Kanji Transfer 0x7b */ 123 +#define KEY_Yen /* Yen 0x7d */ 125 + +#define KEY_Power /* Power Key 0x84 */ 132 +#define KEY_Mute /* Audio Mute 0x85 */ 133 +#define KEY_AudioLower /* Audio Lower 0x86 */ 134 +#define KEY_AudioRaise /* Audio Raise 0x87 */ 135 +#define KEY_Help /* Help 0x88 */ 136 +#define KEY_L1 /* Stop 0x89 */ 137 +#define KEY_L2 /* Again 0x8a */ 138 +#define KEY_L3 /* Props 0x8b */ 139 +#define KEY_L4 /* Undo 0x8c */ 140 +#define KEY_L5 /* Front 0x8d */ 141 +#define KEY_L6 /* Copy 0x8e */ 142 +#define KEY_L7 /* Open 0x8f */ 143 +#define KEY_L8 /* Paste 0x90 */ 144 +#define KEY_L9 /* Find 0x91 */ 145 +#define KEY_L10 /* Cut 0x92 */ 146 + +/* + * Fake 'scancodes' in the following ranges are generated for 2-byte + * codes not handled elsewhere. These correspond to most extended keys + * on so-called "Internet" keyboards: + * + * 0x79-0x93 + * 0x96-0xa1 + * 0xa3-0xac + * 0xb1-0xb4 + * 0xba-0xbd + * 0xc2 + * 0xcc-0xd2 + * 0xd6-0xf7 + */ + +/* + * Remapped 'scancodes' are generated for single-byte codes in the range + * 0x59-0x5f,0x62-0x76. These are used for some extra keys on some keyboards. + */ + +#define KEY_0x59 0x95 +#define KEY_0x5A 0xA2 +#define KEY_0x5B 0xAD +#define KEY_0x5C KEY_KP_EQUAL +#define KEY_0x5D 0xAE +#define KEY_0x5E 0xAF +#define KEY_0x5F 0xB0 +#define KEY_0x62 0xB5 +#define KEY_0x63 0xB6 +#define KEY_0x64 0xB7 +#define KEY_0x65 0xB8 +#define KEY_0x66 0xB9 +#define KEY_0x67 0xBE +#define KEY_0x68 0xBF +#define KEY_0x69 0xC0 +#define KEY_0x6A 0xC1 +#define KEY_0x6B 0xC3 +#define KEY_0x6C 0xC4 +#define KEY_0x6D 0xC5 +#define KEY_0x6E 0xC6 +#define KEY_0x6F 0xC7 +#define KEY_0x70 0xC8 +#define KEY_0x71 0xC9 +#define KEY_0x72 0xCA +#define KEY_0x73 0xCB +#define KEY_0x74 0xD3 +#define KEY_0x75 0xD4 +#define KEY_0x76 0xD5 + +/* These are for "notused" and "unknown" entries in translation maps. */ +#define KEY_NOTUSED 0 +#define KEY_UNKNOWN 255 + +#endif /* _ATKEYNAMES_H */ diff --git a/xorg-server/hw/xfree86/common/compiler.h b/xorg-server/hw/xfree86/common/compiler.h new file mode 100644 index 000000000..7b65da844 --- /dev/null +++ b/xorg-server/hw/xfree86/common/compiler.h @@ -0,0 +1,1774 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * 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 Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _COMPILER_H + +# define _COMPILER_H + +#if defined(__SUNPRO_C) +# define DO_PROTOTYPES +#endif + +/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */ +# ifndef __inline__ +# if defined(__GNUC__) + /* gcc has __inline__ */ +# elif defined(__HIGHC__) +# define __inline__ _Inline +# else +# define __inline__ /**/ +# endif +# endif /* __inline__ */ +# ifndef __inline +# if defined(__GNUC__) + /* gcc has __inline */ +# elif defined(__HIGHC__) +# define __inline _Inline +# else +# define __inline /**/ +# endif +# endif /* __inline */ + +# if defined(IODEBUG) && defined(__GNUC__) +# define outb RealOutb +# define outw RealOutw +# define outl RealOutl +# define inb RealInb +# define inw RealInw +# define inl RealInl +# endif + +# if defined(QNX4) /* Do this for now to keep Watcom happy */ +# define outb outp +# define outw outpw +# define outl outpd +# define inb inp +# define inw inpw +# define inl inpd + +/* Define the ffs function for inlining */ +extern int ffs(unsigned long); +# pragma aux ffs_ = \ + "bsf edx, eax" \ + "jnz bits_set" \ + "xor eax, eax" \ + "jmp exit1" \ + "bits_set:" \ + "mov eax, edx" \ + "inc eax" \ + "exit1:" \ + __parm [eax] \ + __modify [eax edx] \ + __value [eax] \ + ; +# endif + +# if defined(__SUNPRO_C) +# define DO_PROTOTYPES +# endif + +# if defined(NO_INLINE) || defined(DO_PROTOTYPES) + +# if !defined(__arm__) +# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) \ + && !(defined(__alpha__) && defined(linux)) \ + && !(defined(__ia64__) && defined(linux)) \ + +extern void outb(unsigned short, unsigned char); +extern void outw(unsigned short, unsigned short); +extern void outl(unsigned short, unsigned int); +extern unsigned int inb(unsigned short); +extern unsigned int inw(unsigned short); +extern unsigned int inl(unsigned short); + +# else /* __sparc__, __arm32__, __alpha__*/ + +extern void outb(unsigned long, unsigned char); +extern void outw(unsigned long, unsigned short); +extern void outl(unsigned long, unsigned int); +extern unsigned int inb(unsigned long); +extern unsigned int inw(unsigned long); +extern unsigned int inl(unsigned long); + +# endif /* __sparc__, __arm32__, __alpha__ */ +# endif /* __arm__ */ + +extern unsigned long ldq_u(unsigned long *); +extern unsigned long ldl_u(unsigned int *); +extern unsigned long ldw_u(unsigned short *); +extern void stq_u(unsigned long, unsigned long *); +extern void stl_u(unsigned long, unsigned int *); +extern void stw_u(unsigned long, unsigned short *); +extern void mem_barrier(void); +extern void write_mem_barrier(void); +extern void stl_brx(unsigned long, volatile unsigned char *, int); +extern void stw_brx(unsigned short, volatile unsigned char *, int); +extern unsigned long ldl_brx(volatile unsigned char *, int); +extern unsigned short ldw_brx(volatile unsigned char *, int); + +# endif + +# ifndef NO_INLINE +# ifdef __GNUC__ +# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__)) + +# ifdef linux +/* for Linux on Alpha, we use the LIBC _inx/_outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +extern void (*_alpha_outb)(char val, unsigned long port); +static __inline__ void +outb(unsigned long port, unsigned char val) +{ + _alpha_outb(val, port); +} + +extern void (*_alpha_outw)(short val, unsigned long port); +static __inline__ void +outw(unsigned long port, unsigned short val) +{ + _alpha_outw(val, port); +} + +extern void (*_alpha_outl)(int val, unsigned long port); +static __inline__ void +outl(unsigned long port, unsigned int val) +{ + _alpha_outl(val, port); +} + +extern unsigned int (*_alpha_inb)(unsigned long port); +static __inline__ unsigned int +inb(unsigned long port) +{ + return _alpha_inb(port); +} + +extern unsigned int (*_alpha_inw)(unsigned long port); +static __inline__ unsigned int +inw(unsigned long port) +{ + return _alpha_inw(port); +} + +extern unsigned int (*_alpha_inl)(unsigned long port); +static __inline__ unsigned int +inl(unsigned long port) +{ + return _alpha_inl(port); +} + +# endif /* linux */ + +# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \ + && !defined(DO_PROTOTYPES) + +/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */ +/* inx/outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +extern void outb(unsigned int port, unsigned char val); +extern void outw(unsigned int port, unsigned short val); +extern void outl(unsigned int port, unsigned int val); +extern unsigned char inb(unsigned int port); +extern unsigned short inw(unsigned int port); +extern unsigned int inl(unsigned int port); + +# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */ + + +#if defined(__NetBSD__) +#include +#endif /* __NetBSD__ */ + +/* + * inline functions to do unaligned accesses + * from linux/include/asm-alpha/unaligned.h + */ + +/* + * EGCS 1.1 knows about arbitrary unaligned loads. Define some + * packed structures to talk about such things with. + */ + +struct __una_u64 { unsigned long x __attribute__((packed)); }; +struct __una_u32 { unsigned int x __attribute__((packed)); }; +struct __una_u16 { unsigned short x __attribute__((packed)); }; + +/* + * Elemental unaligned loads + */ +/* let's try making these things static */ + +static __inline__ unsigned long ldq_u(unsigned long * r11) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u64 *ptr = (const struct __una_u64 *) r11; + return ptr->x; +# else + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extql %0,%2,%0\n\t" + "extqh %1,%2,%1" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(const unsigned long *)(7+(char *) r11))); + return r1 | r2; +# endif +} + +static __inline__ unsigned long ldl_u(unsigned int * r11) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u32 *ptr = (const struct __una_u32 *) r11; + return ptr->x; +# else + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extll %0,%2,%0\n\t" + "extlh %1,%2,%1" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(const unsigned long *)(3+(char *) r11))); + return r1 | r2; +# endif +} + +static __inline__ unsigned long ldw_u(unsigned short * r11) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u16 *ptr = (const struct __una_u16 *) r11; + return ptr->x; +# else + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extwl %0,%2,%0\n\t" + "extwh %1,%2,%1" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(const unsigned long *)(1+(char *) r11))); + return r1 | r2; +# endif +} + +/* + * Elemental unaligned stores + */ + +static __inline__ void stq_u(unsigned long r5, unsigned long * r11) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u64 *ptr = (struct __una_u64 *) r11; + ptr->x = r5; +# else + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "insqh %6,%7,%5\n\t" + "insql %6,%7,%4\n\t" + "mskqh %3,%7,%3\n\t" + "mskql %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(7+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +# endif +} + +static __inline__ void stl_u(unsigned long r5, unsigned int * r11) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u32 *ptr = (struct __una_u32 *) r11; + ptr->x = r5; +# else + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inslh %6,%7,%5\n\t" + "insll %6,%7,%4\n\t" + "msklh %3,%7,%3\n\t" + "mskll %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(3+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +# endif +} + +static __inline__ void stw_u(unsigned long r5, unsigned short * r11) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u16 *ptr = (struct __una_u16 *) r11; + ptr->x = r5; +# else + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inswh %6,%7,%5\n\t" + "inswl %6,%7,%4\n\t" + "mskwh %3,%7,%3\n\t" + "mskwl %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(1+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +# endif +} + +/* to flush the I-cache before jumping to code which just got loaded */ +# define PAL_imb 134 +# define istream_mem_barrier() \ + __asm__ __volatile__("call_pal %0 #imb" : : "i" (PAL_imb) : "memory") +# define mem_barrier() __asm__ __volatile__("mb" : : : "memory") +# ifdef __ELF__ +# define write_mem_barrier() __asm__ __volatile__("wmb" : : : "memory") +# else /* ECOFF gas 2.6 doesn't know "wmb" :-( */ +# define write_mem_barrier() mem_barrier() +# endif + + +# elif defined(linux) && defined(__ia64__) + +# include + +# include + +struct __una_u64 { uint64_t x __attribute__((packed)); }; +struct __una_u32 { uint32_t x __attribute__((packed)); }; +struct __una_u16 { uint16_t x __attribute__((packed)); }; + +static __inline__ unsigned long +__uldq (const unsigned long * r11) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *) r11; + return ptr->x; +} + +static __inline__ unsigned long +__uldl (const unsigned int * r11) +{ + const struct __una_u32 *ptr = (const struct __una_u32 *) r11; + return ptr->x; +} + +static __inline__ unsigned long +__uldw (const unsigned short * r11) +{ + const struct __una_u16 *ptr = (const struct __una_u16 *) r11; + return ptr->x; +} + +static __inline__ void +__ustq (unsigned long r5, unsigned long * r11) +{ + struct __una_u64 *ptr = (struct __una_u64 *) r11; + ptr->x = r5; +} + +static __inline__ void +__ustl (unsigned long r5, unsigned int * r11) +{ + struct __una_u32 *ptr = (struct __una_u32 *) r11; + ptr->x = r5; +} + +static __inline__ void +__ustw (unsigned long r5, unsigned short * r11) +{ + struct __una_u16 *ptr = (struct __una_u16 *) r11; + ptr->x = r5; +} + +# define ldq_u(p) __uldq(p) +# define ldl_u(p) __uldl(p) +# define ldw_u(p) __uldw(p) +# define stq_u(v,p) __ustq(v,p) +# define stl_u(v,p) __ustl(v,p) +# define stw_u(v,p) __ustw(v,p) + +# ifndef __INTEL_COMPILER +# define mem_barrier() __asm__ __volatile__ ("mf" ::: "memory") +# define write_mem_barrier() __asm__ __volatile__ ("mf" ::: "memory") +# else +# include "ia64intrin.h" +# define mem_barrier() __mf() +# define write_mem_barrier() __mf() +# endif + +/* + * This is overkill, but for different reasons depending on where it is used. + * This is thus general enough to be used everywhere cache flushes are needed. + * It doesn't handle memory access serialisation by other processors, though. + */ +# ifndef __INTEL_COMPILER +# define ia64_flush_cache(Addr) \ + __asm__ __volatile__ ( \ + "fc.i %0;;;" \ + "sync.i;;;" \ + "mf;;;" \ + "srlz.i;;;" \ + :: "r"(Addr) : "memory") +# else +# define ia64_flush_cache(Addr) { \ + __fc(Addr);\ + __synci();\ + __mf();\ + __isrlz();\ + } +# endif +# undef outb +# undef outw +# undef outl +# undef inb +# undef inw +# undef inl +extern void outb(unsigned long port, unsigned char val); +extern void outw(unsigned long port, unsigned short val); +extern void outl(unsigned long port, unsigned int val); +extern unsigned int inb(unsigned long port); +extern unsigned int inw(unsigned long port); +extern unsigned int inl(unsigned long port); + +# elif defined(linux) && (defined(__amd64__) || defined(__x86_64__)) + +# include + +# define ldq_u(p) (*((unsigned long *)(p))) +# define ldl_u(p) (*((unsigned int *)(p))) +# define ldw_u(p) (*((unsigned short *)(p))) +# define stq_u(v,p) (*(unsigned long *)(p)) = (v) +# define stl_u(v,p) (*(unsigned int *)(p)) = (v) +# define stw_u(v,p) (*(unsigned short *)(p)) = (v) + +# define mem_barrier() \ + __asm__ __volatile__ ("lock; addl $0,0(%%rsp)": : :"memory") +# define write_mem_barrier() \ + __asm__ __volatile__ ("": : :"memory") + + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ + __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); +} + + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ + __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ + __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + unsigned char ret; + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + unsigned short ret; + __asm__ __volatile__("inw %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + unsigned int ret; + __asm__ __volatile__("inl %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +# elif (defined(linux) || defined(Lynx) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__) + +# if !defined(Lynx) +# ifndef ASI_PL +# define ASI_PL 0x88 +# endif + +# define barrier() __asm__ __volatile__(".word 0x8143e00a": : :"memory") + +static __inline__ void +outb(unsigned long port, unsigned char val) +{ + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +outw(unsigned long port, unsigned short val) +{ + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +outl(unsigned long port, unsigned int val) +{ + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); +} + +static __inline__ unsigned int +inb(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lduba [%1] %2, %0" + : "=r" (ret) + : "r" (port), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lduha [%1] %2, %0" + : "=r" (ret) + : "r" (port), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lda [%1] %2, %0" + : "=r" (ret) + : "r" (port), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned char +xf86ReadMmio8(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned char ret; + + __asm__ __volatile__("lduba [%1] %2, %0" + : "=r" (ret) + : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned short +xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduh [%1], %0" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned short +xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduha [%1] %2, %0" + : "=r" (ret) + : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("ld [%1], %0" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned int +xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("lda [%1] %2, %0" + : "=r" (ret) + : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ void +xf86WriteMmio8(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sth %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void +xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("st %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void +xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +static __inline__ void +xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sth %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void +xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +static __inline__ void +xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("st %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void +xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +# endif /* !Lynx */ + +/* + * EGCS 1.1 knows about arbitrary unaligned loads. Define some + * packed structures to talk about such things with. + */ + +# if defined(__arch64__) || defined(__sparcv9) +struct __una_u64 { unsigned long x __attribute__((packed)); }; +# endif +struct __una_u32 { unsigned int x __attribute__((packed)); }; +struct __una_u16 { unsigned short x __attribute__((packed)); }; + +static __inline__ unsigned long ldq_u(unsigned long *p) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) +# if defined(__arch64__) || defined(__sparcv9) + const struct __una_u64 *ptr = (const struct __una_u64 *) p; +# else + const struct __una_u32 *ptr = (const struct __una_u32 *) p; +# endif + return ptr->x; +# else + unsigned long ret; + memmove(&ret, p, sizeof(*p)); + return ret; +# endif +} + +static __inline__ unsigned long ldl_u(unsigned int *p) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u32 *ptr = (const struct __una_u32 *) p; + return ptr->x; +# else + unsigned int ret; + memmove(&ret, p, sizeof(*p)); + return ret; +# endif +} + +static __inline__ unsigned long ldw_u(unsigned short *p) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u16 *ptr = (const struct __una_u16 *) p; + return ptr->x; +# else + unsigned short ret; + memmove(&ret, p, sizeof(*p)); + return ret; +# endif +} + +static __inline__ void stq_u(unsigned long val, unsigned long *p) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) +# if defined(__arch64__) || defined(__sparcv9) + struct __una_u64 *ptr = (struct __una_u64 *) p; +# else + struct __una_u32 *ptr = (struct __una_u32 *) p; +# endif + ptr->x = val; +# else + unsigned long tmp = val; + memmove(p, &tmp, sizeof(*p)); +# endif +} + +static __inline__ void stl_u(unsigned long val, unsigned int *p) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u32 *ptr = (struct __una_u32 *) p; + ptr->x = val; +# else + unsigned int tmp = val; + memmove(p, &tmp, sizeof(*p)); +# endif +} + +static __inline__ void stw_u(unsigned long val, unsigned short *p) +{ +# if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u16 *ptr = (struct __una_u16 *) p; + ptr->x = val; +# else + unsigned short tmp = val; + memmove(p, &tmp, sizeof(*p)); +# endif +} + +# define mem_barrier() /* XXX: nop for now */ +# define write_mem_barrier() /* XXX: nop for now */ + +# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__)) +# ifdef __arm32__ +# define PORT_SIZE long +# else +# define PORT_SIZE short +# endif + +unsigned int IOPortBase; /* Memory mapped I/O port area */ + +static __inline__ void +outb(unsigned PORT_SIZE port, unsigned char val) +{ + *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; +} + +static __inline__ void +outw(unsigned PORT_SIZE port, unsigned short val) +{ + *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; +} + +static __inline__ void +outl(unsigned PORT_SIZE port, unsigned int val) +{ + *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; +} + +static __inline__ unsigned int +inb(unsigned PORT_SIZE port) +{ + return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase); +} + +static __inline__ unsigned int +inw(unsigned PORT_SIZE port) +{ + return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase); +} + +static __inline__ unsigned int +inl(unsigned PORT_SIZE port) +{ + return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase); +} + + +# if defined(__mips__) +static __inline__ unsigned long ldq_u(unsigned long * r11) +{ + unsigned long r1; + __asm__("lwr %0,%2\n\t" + "lwl %0,%3\n\t" + :"=&r" (r1) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(3+(char *) r11))); + return r1; +} + +static __inline__ unsigned long ldl_u(unsigned int * r11) +{ + unsigned long r1; + __asm__("lwr %0,%2\n\t" + "lwl %0,%3\n\t" + :"=&r" (r1) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(3+(char *) r11))); + return r1; +} + +static __inline__ unsigned long ldw_u(unsigned short * r11) +{ + unsigned long r1; + __asm__("lwr %0,%2\n\t" + "lwl %0,%3\n\t" + :"=&r" (r1) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(1+(char *) r11))); + return r1; +} + +# ifdef linux /* don't mess with other OSs */ + +/* + * EGCS 1.1 knows about arbitrary unaligned loads (and we don't support older + * versions anyway. Define some packed structures to talk about such things + * with. + */ + +struct __una_u32 { unsigned int x __attribute__((packed)); }; +struct __una_u16 { unsigned short x __attribute__((packed)); }; + +static __inline__ void stw_u(unsigned long val, unsigned short *p) +{ + struct __una_u16 *ptr = (struct __una_u16 *) p; + ptr->x = val; +} + +static __inline__ void stl_u(unsigned long val, unsigned int *p) +{ + struct __una_u32 *ptr = (struct __una_u32 *) p; + ptr->x = val; +} + +# if X_BYTE_ORDER == X_BIG_ENDIAN +static __inline__ unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("lw %0, 0(%1)" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sw %0, 0(%1)" + : /* No outputs */ + : "r" (val), "r" (addr)); +} +# endif + +# define mem_barrier() \ + __asm__ __volatile__( \ + "# prevent instructions being moved around\n\t" \ + ".set\tnoreorder\n\t" \ + "# 8 nops to fool the R4400 pipeline\n\t" \ + "nop;nop;nop;nop;nop;nop;nop;nop\n\t" \ + ".set\treorder" \ + : /* no output */ \ + : /* no input */ \ + : "memory") +# define write_mem_barrier() mem_barrier() + +# else /* !linux */ + +# define stq_u(v,p) stl_u(v,p) +# define stl_u(v,p) (*(unsigned char *)(p)) = (v); \ + (*(unsigned char *)(p)+1) = ((v) >> 8); \ + (*(unsigned char *)(p)+2) = ((v) >> 16); \ + (*(unsigned char *)(p)+3) = ((v) >> 24) + +# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \ + (*(unsigned char *)(p)+1) = ((v) >> 8) + +# define mem_barrier() /* NOP */ +# endif /* !linux */ +# endif /* __mips__ */ + +# if defined(__arm32__) +# define ldq_u(p) (*((unsigned long *)(p))) +# define ldl_u(p) (*((unsigned int *)(p))) +# define ldw_u(p) (*((unsigned short *)(p))) +# define stq_u(v,p) (*(unsigned long *)(p)) = (v) +# define stl_u(v,p) (*(unsigned int *)(p)) = (v) +# define stw_u(v,p) (*(unsigned short *)(p)) = (v) +# define mem_barrier() /* NOP */ +# define write_mem_barrier() /* NOP */ +# endif /* __arm32__ */ + +# elif (defined(Lynx) || defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__) + +# ifndef MAP_FAILED +# define MAP_FAILED ((void *)-1) +# endif + +extern volatile unsigned char *ioBase; + +#if defined(linux) && defined(__powerpc64__) +# include +# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) +# include +# endif +#endif /* defined(linux) && defined(__powerpc64__) */ +#ifndef eieio /* We deal with arch-specific eieio() routines above... */ +# define eieio() __asm__ __volatile__ ("eieio" ::: "memory") +#endif /* eieio */ + +static __inline__ unsigned char +xf86ReadMmio8(__volatile__ void *base, const unsigned long offset) +{ + register unsigned char val; + __asm__ __volatile__( + "lbzx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned short +xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset) +{ + register unsigned short val; + __asm__ __volatile__( + "lhzx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned short +xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset) +{ + register unsigned short val; + __asm__ __volatile__( + "lhbrx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + register unsigned int val; + __asm__ __volatile__( + "lwzx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned int +xf86ReadMmio32Le(__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; +} + +static __inline__ void +xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset, + const unsigned char val) +{ + __asm__ __volatile__( + "stbx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + __asm__ __volatile__( + "sthbrx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + __asm__ __volatile__( + "sthx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + __asm__ __volatile__( + "stwbrx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + __asm__ __volatile__( + "stwx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmio8(__volatile__ void *base, const unsigned long offset, + const unsigned char val) +{ + xf86WriteMmioNB8(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + xf86WriteMmioNB16Le(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + xf86WriteMmioNB16Be(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + xf86WriteMmioNB32Le(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + xf86WriteMmioNB32Be(base, offset, val); + eieio(); +} + + +static __inline__ void +outb(unsigned short port, unsigned char value) +{ + if(ioBase == MAP_FAILED) return; + xf86WriteMmio8((void *)ioBase, port, value); +} + +static __inline__ void +outw(unsigned short port, unsigned short value) +{ + if(ioBase == MAP_FAILED) return; + xf86WriteMmio16Le((void *)ioBase, port, value); +} + +static __inline__ void +outl(unsigned short port, unsigned int value) +{ + if(ioBase == MAP_FAILED) return; + xf86WriteMmio32Le((void *)ioBase, port, value); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + if(ioBase == MAP_FAILED) return 0; + return xf86ReadMmio8((void *)ioBase, port); +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + if(ioBase == MAP_FAILED) return 0; + return xf86ReadMmio16Le((void *)ioBase, port); +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + if(ioBase == MAP_FAILED) return 0; + return xf86ReadMmio32Le((void *)ioBase, port); +} + +# define ldq_u(p) ldl_u(p) +# define ldl_u(p) ((*(unsigned char *)(p)) | \ + (*((unsigned char *)(p)+1)<<8) | \ + (*((unsigned char *)(p)+2)<<16) | \ + (*((unsigned char *)(p)+3)<<24)) +# define ldw_u(p) ((*(unsigned char *)(p)) | \ + (*((unsigned char *)(p)+1)<<8)) + +# define stq_u(v,p) stl_u(v,p) +# define stl_u(v,p) (*(unsigned char *)(p)) = (v); \ + (*((unsigned char *)(p)+1)) = ((v) >> 8); \ + (*((unsigned char *)(p)+2)) = ((v) >> 16); \ + (*((unsigned char *)(p)+3)) = ((v) >> 24) +# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \ + (*((unsigned char *)(p)+1)) = ((v) >> 8) + +# define mem_barrier() eieio() +# define write_mem_barrier() eieio() + +#elif defined(__arm__) && defined(__linux__) + +#define ldq_u(p) (*((unsigned long *)(p))) +#define ldl_u(p) (*((unsigned int *)(p))) +#define ldw_u(p) (*((unsigned short *)(p))) +#define stq_u(v,p) (*(unsigned long *)(p)) = (v) +#define stl_u(v,p) (*(unsigned int *)(p)) = (v) +#define stw_u(v,p) (*(unsigned short *)(p)) = (v) +#define mem_barrier() /* NOP */ +#define write_mem_barrier() /* NOP */ + +/* for Linux on ARM, we use the LIBC inx/outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +#include + +static __inline__ void +xf_outb(unsigned short port, unsigned char val) +{ + outb(val, port); +} + +static __inline__ void +xf_outw(unsigned short port, unsigned short val) +{ + outw(val, port); +} + +static __inline__ void +xf_outl(unsigned short port, unsigned int val) +{ + outl(val, port); +} + +#define outb xf_outb +#define outw xf_outw +#define outl xf_outl + +#define arm_flush_cache(addr) \ +do { \ + register unsigned long _beg __asm ("a1") = (unsigned long) (addr); \ + register unsigned long _end __asm ("a2") = (unsigned long) (addr) + 4;\ + register unsigned long _flg __asm ("a3") = 0; \ + __asm __volatile ("swi 0x9f0002 @ sys_cacheflush" \ + : "=r" (_beg) \ + : "0" (_beg), "r" (_end), "r" (_flg)); \ +} while (0) + +# else /* ix86 */ + +# define ldq_u(p) (*((unsigned long *)(p))) +# define ldl_u(p) (*((unsigned int *)(p))) +# define ldw_u(p) (*((unsigned short *)(p))) +# define stq_u(v,p) (*(unsigned long *)(p)) = (v) +# define stl_u(v,p) (*(unsigned int *)(p)) = (v) +# define stw_u(v,p) (*(unsigned short *)(p)) = (v) +# define mem_barrier() /* NOP */ +# define write_mem_barrier() /* NOP */ + +# if !defined(__SUNPRO_C) +# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) +# ifdef GCCUSESGAS + +/* + * If gcc uses gas rather than the native assembler, the syntax of these + * inlines has to be different. DHD + */ + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ + __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); +} + + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ + __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ + __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + unsigned char ret; + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + unsigned short ret; + __asm__ __volatile__("inw %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + unsigned int ret; + __asm__ __volatile__("inl %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +# else /* GCCUSESGAS */ + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ + __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ + __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ + __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + unsigned char ret; + __asm__ __volatile__("in%B0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + unsigned short ret; + __asm__ __volatile__("in%W0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + unsigned int ret; + __asm__ __volatile__("in%L0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +# endif /* GCCUSESGAS */ + +# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/ + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ +} + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + return 0; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + return 0; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + return 0; +} + +# endif /* FAKEIT */ +# endif /* __SUNPRO_C */ + +# endif /* ix86 */ + +# else /* !GNUC */ +# if !defined(QNX4) +# if defined(__STDC__) && (__STDC__ == 1) +# ifndef asm +# define asm __asm +# endif +# endif +# ifndef SCO325 +# if defined(__UNIXWARE__) +# /* avoid including for on UnixWare */ +# define ushort unsigned short +# define ushort_t unsigned short +# define ulong unsigned long +# define ulong_t unsigned long +# define uint_t unsigned int +# define uchar_t unsigned char +# endif /* __UNIXWARE__ */ +# if !defined(sgi) && !defined(__SUNPRO_C) +# include +# endif +# else +# include "scoasm.h" +# endif +# if (!defined(__HIGHC__) && !defined(sgi) && !defined(__SUNPRO_C)) || \ + defined(__USLC__) +# pragma asm partial_optimization outl +# pragma asm partial_optimization outw +# pragma asm partial_optimization outb +# pragma asm partial_optimization inl +# pragma asm partial_optimization inw +# pragma asm partial_optimization inb +# endif +# endif +# define ldq_u(p) (*((unsigned long *)(p))) +# define ldl_u(p) (*((unsigned int *)(p))) +# define ldw_u(p) (*((unsigned short *)(p))) +# define stq_u(v,p) (*(unsigned long *)(p)) = (v) +# define stl_u(v,p) (*(unsigned int *)(p)) = (v) +# define stw_u(v,p) (*(unsigned short *)(p)) = (v) +# define mem_barrier() /* NOP */ +# define write_mem_barrier() /* NOP */ +# endif /* __GNUC__ */ + +# if defined(QNX4) +# include +extern unsigned inb(unsigned port); +extern unsigned inw(unsigned port); +extern unsigned inl(unsigned port); +extern void outb(unsigned port, unsigned val); +extern void outw(unsigned port, unsigned val); +extern void outl(unsigned port, unsigned val); +# endif /* QNX4 */ + +# if defined(IODEBUG) && defined(__GNUC__) +# undef inb +# undef inw +# undef inl +# undef outb +# undef outw +# undef outl +# define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) +# define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) +# define inl(a) __extension__ ({unsigned int __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) + +# define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b)) +# define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b)) +# define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b)) +# endif + +# endif /* NO_INLINE */ + +# ifdef __alpha__ +/* entry points for Mmio memory access routines */ +extern int (*xf86ReadMmio8)(void *, unsigned long); +extern int (*xf86ReadMmio16)(void *, unsigned long); +# ifndef STANDALONE_MMIO +extern int (*xf86ReadMmio32)(void *, unsigned long); +# else +/* Some DRI 3D drivers need MMIO_IN32. */ +static __inline__ int +xf86ReadMmio32(void *Base, unsigned long Offset) +{ + __asm__ __volatile__("mb" : : : "memory"); + return *(volatile unsigned int*)((unsigned long)Base+(Offset)); +} +# endif +extern void (*xf86WriteMmio8)(int, void *, unsigned long); +extern void (*xf86WriteMmio16)(int, void *, unsigned long); +extern void (*xf86WriteMmio32)(int, void *, unsigned long); +extern void (*xf86WriteMmioNB8)(int, void *, unsigned long); +extern void (*xf86WriteMmioNB16)(int, void *, unsigned long); +extern void (*xf86WriteMmioNB32)(int, void *, unsigned long); +extern void xf86JensenMemToBus(char *, long, long, int); +extern void xf86JensenBusToMem(char *, char *, unsigned long, int); +extern void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int); +extern void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int); + +/* Some macros to hide the system dependencies for MMIO accesses */ +/* Changed to kill noise generated by gcc's -Wcast-align */ +# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset) +# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset) +# ifndef STANDALONE_MMIO +# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset) +# else +# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset) +# endif + +# if defined (JENSEN_SUPPORT) +# define MMIO_OUT32(base, offset, val) \ + (*xf86WriteMmio32)((CARD32)(val), base, offset) +# define MMIO_ONB32(base, offset, val) \ + (*xf86WriteMmioNB32)((CARD32)(val), base, offset) +# else +# define MMIO_OUT32(base, offset, val) \ + do { \ + write_mem_barrier(); \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \ + } while (0) +# define MMIO_ONB32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +# endif + +# define MMIO_OUT8(base, offset, val) \ + (*xf86WriteMmio8)((CARD8)(val), base, offset) +# define MMIO_OUT16(base, offset, val) \ + (*xf86WriteMmio16)((CARD16)(val), base, offset) +# define MMIO_ONB8(base, offset, val) \ + (*xf86WriteMmioNB8)((CARD8)(val), base, offset) +# define MMIO_ONB16(base, offset, val) \ + (*xf86WriteMmioNB16)((CARD16)(val), base, offset) +# define MMIO_MOVE32(base, offset, val) \ + MMIO_OUT32(base, offset, val) + +# elif defined(__powerpc__) + /* + * we provide byteswapping and no byteswapping functions here + * with byteswapping as default, + * drivers that don't need byteswapping should define PPC_MMIO_IS_BE + */ +# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) +# define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8(base, offset, (CARD8)(val)) +# define MMIO_ONB8(base, offset, val) \ + xf86WriteMmioNB8(base, offset, (CARD8)(val)) + +# if defined(PPC_MMIO_IS_BE) /* No byteswapping */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Be(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16Be(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32Be(base, offset, (CARD32)(val)) +# else /* byteswapping is the default */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Le(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Le(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16Le(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32Le(base, offset, (CARD32)(val)) +# endif + +# define MMIO_MOVE32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) + +static __inline__ void ppc_flush_icache(char *addr) +{ + __asm__ volatile ( + "dcbf 0,%0;" + "sync;" + "icbi 0,%0;" + "sync;" + "isync;" + : : "r"(addr) : "memory"); +} + +# elif defined(__sparc__) || defined(sparc) || defined(__sparc) + /* + * Like powerpc, we provide byteswapping and no byteswapping functions + * here with byteswapping as default, drivers that don't need byteswapping + * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we + * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places + * of drivers?). + */ +# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) +# define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8(base, offset, (CARD8)(val)) +# define MMIO_ONB8(base, offset, val) \ + xf86WriteMmio8NB(base, offset, (CARD8)(val)) + +# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Be(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmio16BeNB(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmio32BeNB(base, offset, (CARD32)(val)) +# else /* byteswapping is the default */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Le(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Le(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmio16LeNB(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmio32LeNB(base, offset, (CARD32)(val)) +# endif + +# define MMIO_MOVE32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) + +# else /* !__alpha__ && !__powerpc__ && !__sparc__ */ + +# define MMIO_IN8(base, offset) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) +# define MMIO_IN16(base, offset) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) +# define MMIO_IN32(base, offset) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +# define MMIO_OUT8(base, offset, val) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val) +# define MMIO_OUT16(base, offset, val) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +# define MMIO_OUT32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val) +# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val) +# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val) + +# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val) + +# endif /* __alpha__ */ + +/* + * With Intel, the version in os-support/misc/SlowBcopy.s is used. + * This avoids port I/O during the copy (which causes problems with + * some hardware). + */ +# ifdef __alpha__ +# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count) +# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count) +# else /* __alpha__ */ +# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count) +# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count) +# endif /* __alpha__ */ + +#endif /* _COMPILER_H */ diff --git a/xorg-server/hw/xfree86/common/extramodes b/xorg-server/hw/xfree86/common/extramodes new file mode 100644 index 000000000..450502670 --- /dev/null +++ b/xorg-server/hw/xfree86/common/extramodes @@ -0,0 +1,27 @@ +// +// Extra modes to include as default modes in the X server. +// +// $XFree86: xc/programs/Xserver/hw/xfree86/etc/extramodes,v 1.5 2002/06/05 19:43:05 dawes Exp $ +// + +# 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz +ModeLine "832x624" 57.284 832 864 928 1152 624 625 628 667 -Hsync -Vsync + +# 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz +ModeLine "1400x1050" 122.0 1400 1488 1640 1880 1050 1052 1064 1082 +hsync +vsync + +# 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz +ModeLine "1400x1050" 155.8 1400 1464 1784 1912 1050 1052 1064 1090 +hsync +vsync + +# 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz +Modeline "1920x1440" 341.35 1920 2072 2288 2656 1440 1441 1444 1512 -hsync +vsync + +# 2048x1536 @ 60Hz (VESA GTF) hsync: 95.3kHz +Modeline "2048x1536" 266.95 2048 2200 2424 2800 1536 1537 1540 1589 -hsync +vsync + +# 2048x1536 @ 75Hz (VESA GTF) hsync: 120.2kHz +Modeline "2048x1536" 340.48 2048 2216 2440 2832 1536 1537 1540 1603 -hsync +vsync + +# 2048x1536 @ 85Hz (VESA GTF) hsync: 137.0kHz +Modeline "2048x1536" 388.04 2048 2216 2440 2832 1536 1537 1540 1612 -hsync +vsync + diff --git a/xorg-server/hw/xfree86/common/fourcc.h b/xorg-server/hw/xfree86/common/fourcc.h new file mode 100644 index 000000000..853657e86 --- /dev/null +++ b/xorg-server/hw/xfree86/common/fourcc.h @@ -0,0 +1,160 @@ + +/* + * Copyright (c) 2000-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + This header file contains listings of STANDARD guids for video formats. + Please do not place non-registered, or incomplete entries in this file. + A list of some popular fourcc's are at: http://www.webartz.com/fourcc/ + For an explanation of fourcc <-> guid mappings see RFC2361. +*/ + +#ifndef _XF86_FOURCC_H_ +#define _XF86_FOURCC_H_ 1 + +#define FOURCC_YUY2 0x32595559 +#define XVIMAGE_YUY2 \ + { \ + FOURCC_YUY2, \ + XvYUV, \ + LSBFirst, \ + {'Y','U','Y','2', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 1, 1, \ + {'Y','U','Y','V', \ + 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}, \ + XvTopToBottom \ + } + +#define FOURCC_YV12 0x32315659 +#define XVIMAGE_YV12 \ + { \ + FOURCC_YV12, \ + XvYUV, \ + LSBFirst, \ + {'Y','V','1','2', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 12, \ + XvPlanar, \ + 3, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 2, 2, \ + {'Y','V','U', \ + 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}, \ + XvTopToBottom \ + } + +#define FOURCC_I420 0x30323449 +#define XVIMAGE_I420 \ + { \ + FOURCC_I420, \ + XvYUV, \ + LSBFirst, \ + {'I','4','2','0', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 12, \ + XvPlanar, \ + 3, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 2, 2, \ + {'Y','U','V', \ + 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}, \ + XvTopToBottom \ + } + + +#define FOURCC_UYVY 0x59565955 +#define XVIMAGE_UYVY \ + { \ + FOURCC_UYVY, \ + XvYUV, \ + LSBFirst, \ + {'U','Y','V','Y', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 16, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 2, 2, \ + 1, 1, 1, \ + {'U','Y','V','Y', \ + 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}, \ + XvTopToBottom \ + } + +#define FOURCC_IA44 0x34344149 +#define XVIMAGE_IA44 \ + { \ + FOURCC_IA44, \ + XvYUV, \ + LSBFirst, \ + {'I','A','4','4', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 8, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 1, 1, \ + 1, 1, 1, \ + {'A','I', \ + 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}, \ + XvTopToBottom \ + } + +#define FOURCC_AI44 0x34344941 +#define XVIMAGE_AI44 \ + { \ + FOURCC_AI44, \ + XvYUV, \ + LSBFirst, \ + {'A','I','4','4', \ + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \ + 8, \ + XvPacked, \ + 1, \ + 0, 0, 0, 0, \ + 8, 8, 8, \ + 1, 1, 1, \ + 1, 1, 1, \ + {'I','A', \ + 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}, \ + XvTopToBottom \ + } + +#endif /* _XF86_FOURCC_H_ */ diff --git a/xorg-server/hw/xfree86/common/modeline2c.awk b/xorg-server/hw/xfree86/common/modeline2c.awk new file mode 100644 index 000000000..71a956e05 --- /dev/null +++ b/xorg-server/hw/xfree86/common/modeline2c.awk @@ -0,0 +1,96 @@ +#!/usr/bin/awk -f +# +# Copyright (c) 2007 Joerg Sonnenberger . +# All rights reserved. +# +# Based on Perl script by Dirk Hohndel. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# Usage: modeline2c.awk < modefile > xf86DefModeSet.c +# + +BEGIN { + flagsdict[""] = "0" + + flagsdict["+hsync +vsync"] = "V_PHSYNC | V_PVSYNC" + flagsdict["+hsync -vsync"] = "V_PHSYNC | V_NVSYNC" + flagsdict["-hsync +vsync"] = "V_NHSYNC | V_PVSYNC" + flagsdict["-hsync -vsync"] = "V_NHSYNC | V_NVSYNC" + flagsdict["+hsync +vsync interlace"] = "V_PHSYNC | V_PVSYNC | V_INTERLACE" + flagsdict["+hsync -vsync interlace"] = "V_PHSYNC | V_NVSYNC | V_INTERLACE" + flagsdict["-hsync +vsync interlace"] = "V_NHSYNC | V_PVSYNC | V_INTERLACE" + flagsdict["-hsync -vsync interlace"] = "V_NHSYNC | V_NVSYNC | V_INTERLACE" + + print "/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at" + print " * modeline2c.awk */" + print "" + print "/*" + print " * Author: Joerg Sonnenberger " + print " * Based on Perl script from Dirk Hohndel " + print " */" + print "" + print "#ifdef HAVE_XORG_CONFIG_H" + print "#include " + print "#endif" + print "" + print "#ifdef __UNIXOS2__" + print "#define I_NEED_OS2_H" + print "#endif" + print "#include \"xf86.h\"" + print "#include \"xf86Config.h\"" + print "#include \"xf86Priv.h\"" + print "#include \"xf86_OSlib.h\"" + print "" + print "#include \"globals.h\"" + print "" + print "#define MODEPREFIX NULL, NULL, NULL, MODE_OK, M_T_DEFAULT" + print "#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0" + print "" + print "const DisplayModeRec xf86DefaultModes [] = {" + + modeline = "\t{MODEPREFIX,%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s, MODESUFFIX},\n" + modeline_data = "^[a-zA-Z]+[ \t]+[^ \t]+[ \t0-9.]+" +} + +/^[mM][oO][dD][eE][lL][iI][nN][eE]/ { + flags = $0 + gsub(modeline_data, "", flags) + flags = tolower(flags) + printf(modeline, $3 * 1000, $4, $5, $6, $7, + $8, $9, $10, $11, flagsdict[flags]) + # Half-width double scanned modes + printf(modeline, $3 * 500, $4/2, $5/2, $6/2, $7/2, + $8/2, $9/2, $10/2, $11/2, flagsdict[flags] " | V_DBLSCAN") +} + +/^#/ { + print "/*" substr($0, 2) " */" +} + +END { + print "};" + printf "const int xf86NumDefaultModes = sizeof(xf86DefaultModes) / sizeof(DisplayModeRec);" +} diff --git a/xorg-server/hw/xfree86/common/scoasm.h b/xorg-server/hw/xfree86/common/scoasm.h new file mode 100644 index 000000000..8f80e7b1e --- /dev/null +++ b/xorg-server/hw/xfree86/common/scoasm.h @@ -0,0 +1,142 @@ + +/* + * Copyright (c) 1996 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * scoasm.h - used to define inline versions of certain functions which + * do NOT appear in sys/inline.h. + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#if defined(__SCO__) && defined(__USLC__) +#ifndef _SCOASM_HDR_INC +#define _SCOASM_HDR_INC + +asm void outl(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + outl (%dx) +%reg port; mem val; + movl port, %edx + movl val, %eax + outl (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + outl (%dx) +%mem port,val; + movw port, %dx + movl val, %eax + outl (%dx) +} + +asm void outw(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + data16 + outl (%dx) +%reg port; mem val; + movl port, %edx + movw val, %ax + data16 + outl (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + data16 + outl (%dx) +%mem port,val; + movw port, %dx + movw val, %ax + data16 + outl (%dx) +} + +asm void outb(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + outb (%dx) +%reg port; mem val; + movl port, %edx + movb val, %al + outb (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + outb (%dx) +%mem port,val; + movw port, %dx + movb val, %al + outb (%dx) +} + +asm int inl(port) +{ +%reg port; + movl port, %edx + inl (%dx) +%mem port; + movw port, %dx + inl (%dx) +} + +asm int inw(port) +{ +%reg port; + subl %eax, %eax + movl port, %edx + data16 + inl (%dx) +%mem port; + subl %eax, %eax + movw port, %dx + data16 + inl (%dx) +} + +asm int inb(port) +{ +%reg port; + subl %eax, %eax + movl port, %edx + inb (%dx) +%mem port; + subl %eax, %eax + movw port, %dx + inb (%dx) +} + +#endif /* _SCOASM_HDR_INC */ +#endif /* __SCO__ && __USLC__ */ diff --git a/xorg-server/hw/xfree86/common/vesamodes b/xorg-server/hw/xfree86/common/vesamodes new file mode 100644 index 000000000..2bc886276 --- /dev/null +++ b/xorg-server/hw/xfree86/common/vesamodes @@ -0,0 +1,111 @@ +// +// Default modes distilled from +// "VESA and Industry Standards and Guide for Computer Display Monitor +// Timing", version 1.0, revision 0.8, adopted September 17, 1998. +// +// $XFree86: xc/programs/Xserver/hw/xfree86/etc/vesamodes,v 1.3 1999/11/16 03:28:03 tsi Exp $ + + +# 640x350 @ 85Hz (VESA) hsync: 37.9kHz +ModeLine "640x350" 31.5 640 672 736 832 350 382 385 445 +hsync -vsync + +# 640x400 @ 85Hz (VESA) hsync: 37.9kHz +ModeLine "640x400" 31.5 640 672 736 832 400 401 404 445 -hsync +vsync + +# 720x400 @ 85Hz (VESA) hsync: 37.9kHz +ModeLine "720x400" 35.5 720 756 828 936 400 401 404 446 -hsync +vsync + +# 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz +ModeLine "640x480" 25.175 640 656 752 800 480 490 492 525 -hsync -vsync + +# 640x480 @ 72Hz (VESA) hsync: 37.9kHz +ModeLine "640x480" 31.5 640 664 704 832 480 489 492 520 -hsync -vsync + +# 640x480 @ 75Hz (VESA) hsync: 37.5kHz +ModeLine "640x480" 31.5 640 656 720 840 480 481 484 500 -hsync -vsync + +# 640x480 @ 85Hz (VESA) hsync: 43.3kHz +ModeLine "640x480" 36.0 640 696 752 832 480 481 484 509 -hsync -vsync + +# 800x600 @ 56Hz (VESA) hsync: 35.2kHz +ModeLine "800x600" 36.0 800 824 896 1024 600 601 603 625 +hsync +vsync + +# 800x600 @ 60Hz (VESA) hsync: 37.9kHz +ModeLine "800x600" 40.0 800 840 968 1056 600 601 605 628 +hsync +vsync + +# 800x600 @ 72Hz (VESA) hsync: 48.1kHz +ModeLine "800x600" 50.0 800 856 976 1040 600 637 643 666 +hsync +vsync + +# 800x600 @ 75Hz (VESA) hsync: 46.9kHz +ModeLine "800x600" 49.5 800 816 896 1056 600 601 604 625 +hsync +vsync + +# 800x600 @ 85Hz (VESA) hsync: 53.7kHz +ModeLine "800x600" 56.3 800 832 896 1048 600 601 604 631 +hsync +vsync + +# 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz +ModeLine "1024x768" 44.9 1024 1032 1208 1264 768 768 776 817 +hsync +vsync Interlace + +# 1024x768 @ 60Hz (VESA) hsync: 48.4kHz +ModeLine "1024x768" 65.0 1024 1048 1184 1344 768 771 777 806 -hsync -vsync + +# 1024x768 @ 70Hz (VESA) hsync: 56.5kHz +ModeLine "1024x768" 75.0 1024 1048 1184 1328 768 771 777 806 -hsync -vsync + +# 1024x768 @ 75Hz (VESA) hsync: 60.0kHz +ModeLine "1024x768" 78.75 1024 1040 1136 1312 768 769 772 800 +hsync +vsync + +# 1024x768 @ 85Hz (VESA) hsync: 68.7kHz +ModeLine "1024x768" 94.5 1024 1072 1168 1376 768 769 772 808 +hsync +vsync + +# 1152x864 @ 75Hz (VESA) hsync: 67.5kHz +ModeLine "1152x864" 108.0 1152 1216 1344 1600 864 865 868 900 +hsync +vsync + +# 1280x960 @ 60Hz (VESA) hsync: 60.0kHz +ModeLine "1280x960" 108.0 1280 1376 1488 1800 960 961 964 1000 +hsync +vsync + +# 1280x960 @ 85Hz (VESA) hsync: 85.9kHz +ModeLine "1280x960" 148.5 1280 1344 1504 1728 960 961 964 1011 +hsync +vsync + +# 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz +ModeLine "1280x1024" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync + +# 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz +ModeLine "1280x1024" 135.0 1280 1296 1440 1688 1024 1025 1028 1066 +hsync +vsync + +# 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz +ModeLine "1280x1024" 157.5 1280 1344 1504 1728 1024 1025 1028 1072 +hsync +vsync + +# 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz +ModeLine "1600x1200" 162.0 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync + +# 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz +ModeLine "1600x1200" 175.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync + +# 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz +ModeLine "1600x1200" 189.0 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync + +# 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz +ModeLine "1600x1200" 202.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync + +# 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz +ModeLine "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync + +# 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz +ModeLine "1792x1344" 204.8 1792 1920 2120 2448 1344 1345 1348 1394 -hsync +vsync + +# 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz +ModeLine "1792x1344" 261.0 1792 1888 2104 2456 1344 1345 1348 1417 -hsync +vsync + +# 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz +ModeLine "1856x1392" 218.3 1856 1952 2176 2528 1392 1393 1396 1439 -hsync +vsync + +# 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz +ModeLine "1856x1392" 288.0 1856 1984 2208 2560 1392 1393 1396 1500 -hsync +vsync + +# 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz +ModeLine "1920x1440" 234.0 1920 2048 2256 2600 1440 1441 1444 1500 -hsync +vsync + +# 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz +ModeLine "1920x1440" 297.0 1920 2064 2288 2640 1440 1441 1444 1500 -hsync +vsync + + diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h new file mode 100644 index 000000000..e91521770 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86.h @@ -0,0 +1,430 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains declarations for public XFree86 functions and variables, + * and definitions of public macros. + * + * "public" means available to video drivers. + */ + +#ifndef _XF86_H +#define _XF86_H + +#if HAVE_XORG_CONFIG_H +#include +#elif HAVE_DIX_CONFIG_H +#include +#endif + +#include + +#include "xf86str.h" +#include "xf86Opt.h" +#include +#include +#ifdef RANDR +#include +#endif + +#include "propertyst.h" + +/* General parameters */ +extern int xf86DoConfigure; +extern Bool xf86DoModalias; +extern Bool xf86DoConfigurePass1; +extern DevPrivateKey xf86ScreenKey; +extern DevPrivateKey xf86CreateRootWindowKey; +extern DevPrivateKey xf86PixmapKey; +extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ +extern const unsigned char byte_reversed[256]; +extern ScrnInfoPtr xf86CurrentScreen; +extern Bool pciSlotClaimed; +extern Bool isaSlotClaimed; +extern Bool fbSlotClaimed; +#if defined(__sparc__) || defined(__sparc) +extern Bool sbusSlotClaimed; +#endif +extern confDRIRec xf86ConfigDRI; +extern Bool xf86inSuspend; +extern Bool xf86DRI2Enabled(void); + +#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \ + xf86ScreenKey)) +#define XF86FLIP_PIXELS() \ + do { \ + if (xf86GetFlipPixels()) { \ + pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \ + pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \ + } \ + while (0) + +#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE") + +#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \ + (((p) == Pix24Use32) ? 32 : 0)) + +/* Function Prototypes */ +#ifndef _NO_XF86_PROTOTYPES + +/* xf86Bus.c */ + +Bool xf86CheckPciSlot( const struct pci_device * ); +int xf86ClaimPciSlot( struct pci_device *, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active); +Bool xf86ParsePciBusString(const char *busID, int *bus, int *device, + int *func); +Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func); +void xf86FormatPciBusNumber(int busnum, char *buffer); +void xf86PrintResList(int verb, resPtr list); +resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex); +int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); +int xf86GetIsaInfoForScreen(int scrnIndex); +int xf86GetFbInfoForScreen(int scrnIndex); +Bool xf86ParseIsaBusString(const char *busID); +int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); +int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); +void xf86EnableAccess(ScrnInfoPtr pScrn); +void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn); +Bool xf86IsPrimaryPci(struct pci_device * pPci); +Bool xf86IsPrimaryIsa(void); +/* new RAC */ +resPtr xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex); +resPtr xf86JoinResLists(resPtr rlist1, resPtr rlist2); +resPtr xf86DupResList(const resPtr rlist); +void xf86FreeResList(resPtr rlist); +void xf86ClaimFixedResources(resList list, int entityIndex); +Bool xf86DriverHasEntities(DriverPtr drvp); +void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex); +void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, + int instance); +int xf86GetNumEntityInstances(int entityIndex); +GDevPtr xf86GetDevFromEntity(int entityIndex, int instance); +void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex); +EntityInfoPtr xf86GetEntityInfo(int entityIndex); +struct pci_device * xf86GetPciInfoForEntity(int entityIndex); +Bool xf86SetEntityFuncs(int entityIndex, EntityProc init, + EntityProc enter, EntityProc leave, pointer); +void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type); +resPtr xf86RegisterResources(int entityIndex, resList list, + unsigned long Access); +Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base); +void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs, + xf86SetAccessFuncPtr oldFuncs); +Bool xf86IsEntityPrimary(int entityIndex); +resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes); +resPtr xf86SetOperatingState(resList list, int entityIndex, int mask); +void xf86EnterServerState(xf86State state); +memType xf86ChkConflict(resRange *rgp, int entityIndex); +ScrnInfoPtr xf86FindScreenForEntity(int entityIndex); +Bool xf86NoSharedResources(int screenIndex, resType res); +resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2); +void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg); +Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func); + +int xf86GetLastScrnFlag(int entityIndex); +void xf86SetLastScrnFlag(int entityIndex, int scrnIndex); +Bool xf86IsEntityShared(int entityIndex); +void xf86SetEntityShared(int entityIndex); +Bool xf86IsEntitySharable(int entityIndex); +void xf86SetEntitySharable(int entityIndex); +Bool xf86IsPrimInitDone(int entityIndex); +void xf86SetPrimInitDone(int entityIndex); +void xf86ClearPrimInitDone(int entityIndex); +int xf86AllocateEntityPrivateIndex(void); +DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex); + +/* xf86Configure.c */ +GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus, + void *busData, int chipset); +GDevPtr xf86AddDeviceToConfigure( const char *driver, + struct pci_device * pVideo, int chipset ); + +/* xf86Cursor.c */ + +void xf86LockZoom(ScreenPtr pScreen, int lock); +void xf86InitViewport(ScrnInfoPtr pScr); +void xf86SetViewport(ScreenPtr pScreen, int x, int y); +void xf86ZoomViewport(ScreenPtr pScreen, int zoom); +Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode); +void *xf86GetPointerScreenFuncs(void); +void xf86InitOrigins(void); +void xf86ReconfigureLayout(void); + +/* xf86cvt.c */ +DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, + Bool Reduced, Bool Interlaced); + +/* xf86DPMS.c */ + +Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags); + +/* xf86DGA.c */ + +Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, + int num); +Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num); +xf86SetDGAModeProc xf86SetDGAMode; + +/* xf86Events.c */ + +void SetTimeSinceLastInputEvent(void); +pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data); +int xf86RemoveInputHandler(pointer handler); +void xf86DisableInputHandler(pointer handler); +void xf86EnableInputHandler(pointer handler); +pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data); +int xf86RemoveGeneralHandler(pointer handler); +void xf86DisableGeneralHandler(pointer handler); +void xf86EnableGeneralHandler(pointer handler); +void xf86InterceptSignals(int *signo); +void xf86InterceptSigIll(void (*sigillhandler)(void)); +Bool xf86EnableVTSwitch(Bool new); +Bool xf86CommonSpecialKey(int key, Bool down, int modifiers); +void xf86ProcessActionEvent(ActionEvent action, void *arg); + +/* xf86Helper.c */ + +void xf86AddDriver(DriverPtr driver, pointer module, int flags); +void xf86DeleteDriver(int drvIndex); +ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags); +void xf86DeleteScreen(int scrnIndex, int flags); +int xf86AllocateScrnInfoPrivateIndex(void); +Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad); +Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp, + int depth24flags); +void xf86PrintDepthBpp(ScrnInfoPtr scrp); +Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask); +Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual); +Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma); +void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y); +void xf86SetBlackWhitePixels(ScreenPtr pScreen); +void xf86EnableDisableFBAccess(int scrnIndex, Bool enable); +void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, + const char *format, va_list args); +void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, + const char *format, ...) _printf_attribute(4,5); +void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...) + _printf_attribute(3,4); +void xf86MsgVerb(MessageType type, int verb, const char *format, ...) + _printf_attribute(3,4); +void xf86Msg(MessageType type, const char *format, ...) _printf_attribute(2,3); +void xf86ErrorFVerb(int verb, const char *format, ...) _printf_attribute(2,3); +void xf86ErrorF(const char *format, ...) _printf_attribute(1,2); +const char *xf86TokenToString(SymTabPtr table, int token); +int xf86StringToToken(SymTabPtr table, const char *string); +void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from); +void xf86PrintChipsets(const char *drvname, const char *drvmsg, + SymTabPtr chips); +int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist); +int xf86MatchPciInstances(const char *driverName, int vendorID, + SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, + int **foundEntities); +int xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets, + IsaChipsets *ISAchipsets, DriverPtr drvp, + FindIsaDevProc FindIsaDevice, GDevPtr *devList, + int numDevs, int **foundEntities); +void xf86GetClocks(ScrnInfoPtr pScrn, int num, + Bool (*ClockFunc)(ScrnInfoPtr, int), + void (*ProtectRegs)(ScrnInfoPtr, Bool), + void (*BlankScreen)(ScrnInfoPtr, Bool), + IOADDRESS vertsyncreg, int maskval, + int knownclkindex, int knownclkvalue); +void xf86SetPriority(Bool up); +const char *xf86GetVisualName(int visual); +int xf86GetVerbosity(void); +Pix24Flags xf86GetPix24(void); +int xf86GetDepth(void); +rgb xf86GetWeight(void); +Gamma xf86GetGamma(void); +Bool xf86GetFlipPixels(void); +const char *xf86GetServerName(void); +Bool xf86ServerIsExiting(void); +Bool xf86ServerIsResetting(void); +Bool xf86ServerIsInitialising(void); +Bool xf86ServerIsOnlyDetecting(void); +Bool xf86ServerIsOnlyProbing(void); +Bool xf86CaughtSignal(void); +Bool xf86GetVidModeAllowNonLocal(void); +Bool xf86GetVidModeEnabled(void); +Bool xf86GetModInDevAllowNonLocal(void); +Bool xf86GetModInDevEnabled(void); +Bool xf86GetAllowMouseOpenFail(void); +Bool xf86IsPc98(void); +void xf86DisableRandR(void); +CARD32 xf86GetVersion(void); +CARD32 xorgGetVersion(void); +CARD32 xf86GetModuleVersion(pointer module); +pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name); +pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name); +pointer xf86LoadOneModule(char *name, pointer optlist); +void xf86UnloadSubModule(pointer mod); +Bool xf86LoaderCheckSymbol(const char *name); +void xf86LoaderReqSymLists(const char **, ...); +void xf86LoaderReqSymbols(const char *, ...); +void xf86LoaderRefSymLists(const char **, ...); +void xf86LoaderRefSymbols(const char *, ...); +void xf86SetBackingStore(ScreenPtr pScreen); +void xf86SetSilkenMouse(ScreenPtr pScreen); +int xf86NewSerialNumber(WindowPtr p, pointer unused); +pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name, + char **adaptor_name, pointer *adaptor_options); +void xf86GetOS(const char **name, int *major, int *minor, int *teeny); +ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, + int entityIndex,PciChipsets *p_chip, + resList res, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag, + int entityIndex, IsaChipsets *i_chip, + resList res, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, + int entityIndex, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +/* Obsolete! don't use */ +Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, + int entityIndex,PciChipsets *p_chip, + resList res, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +/* Obsolete! don't use */ +Bool xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, + int entityIndex, IsaChipsets *i_chip, + resList res, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +void xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip, + resList res, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +void xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip, + resList res, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +void xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); +Bool xf86IsScreenPrimary(int scrnIndex); +int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, + int format, unsigned long len, + pointer value); +Bool xf86IsUnblank(int mode); + +_X_DEPRECATED void xf86AddModuleInfo(pointer info, pointer module); +_X_DEPRECATED void xf86DeleteModuleInfo(int idx); +void xf86getsecs(long *, long *); + +/* xf86Debug.c */ +#ifdef BUILDDEBUG +CARD8 xf86PeekFb8(CARD8 *p); +CARD16 xf86PeekFb16(CARD16 *p); +CARD32 xf86PeekFb32(CARD32 *p); +void xf86PokeFb8(CARD8 *p, CARD8 v); +void xf86PokeFb16(CARD16 *p, CARD16 v); +void xf86PokeFb32(CARD16 *p, CARD32 v); +CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset); +CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset); +CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset); +void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v); +void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v); +void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v); +#endif + +/* xf86Init.c */ + +PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth); +int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth); + +/* xf86Mode.c */ + +int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2, + int DivFactor, int MulFactor, int *divider); +const char *xf86ModeStatusToString(ModeStatus status); +ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, + ClockRangePtr clockRanges, LookupModeFlags strategy); +ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor); +ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, + ClockRangePtr clockRanges, + LookupModeFlags strategy, + int maxPitch, int virtualX, + int virtualY); +ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, + int flags); +int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, + char **modeNames, ClockRangePtr clockRanges, + int *linePitches, int minPitch, int maxPitch, + int minHeight, int maxHeight, int pitchInc, + int virtualX, int virtualY, int apertureSize, + LookupModeFlags strategy); +void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode); +void xf86PruneDriverModes(ScrnInfoPtr scrp); +void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags); +void xf86PrintModes(ScrnInfoPtr scrp); +void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges); +double xf86ModeHSync(DisplayModePtr mode); +double xf86ModeVRefresh(DisplayModePtr mode); +void xf86SetModeDefaultName(DisplayModePtr mode); +void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags); +DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode); +DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList); +Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2); +void xf86PrintModeline(int scrnIndex,DisplayModePtr mode); +DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new); + +/* xf86Option.c */ + +void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts); + + +/* xf86RandR.c */ +#ifdef RANDR +Bool xf86RandRInit (ScreenPtr pScreen); +void xf86RandRSetInitialMode (ScreenPtr pScreen); +Rotation xf86GetRotation(ScreenPtr pScreen); +Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen, + int newvirtX, int newvirtY, + int newmmWidth, int newmmHeight, Bool resetMode); +#endif + +/* xf86VidModeExtentionInit.c */ + +Bool VidModeExtensionInit(ScreenPtr pScreen); + +/* xf86Versions.c */ +CARD32 xf86GetBuiltinInterfaceVersion(BuiltinInterface iface, int flag); +Bool xf86RegisterBuiltinInterfaceVersion(BuiltinInterface iface, + CARD32 version, int flags); + + +#endif /* _NO_XF86_PROTOTYPES */ + +#endif /* _XF86_H */ diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c new file mode 100644 index 000000000..7e5fab412 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c @@ -0,0 +1,478 @@ +/* + * Copyright 2003 by David H. Dawes. + * Copyright 2003 by X-Oz Technologies. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + * + * Author: David Dawes . + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86.h" +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "xf86Config.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "dirent.h" + +/* Sections for the default built-in configuration. */ + +#define BUILTIN_DEVICE_NAME \ + "\"Builtin Default %s Device %d\"" + +#define BUILTIN_DEVICE_SECTION_PRE \ + "Section \"Device\"\n" \ + "\tIdentifier\t" BUILTIN_DEVICE_NAME "\n" \ + "\tDriver\t\"%s\"\n" + +#define BUILTIN_DEVICE_SECTION_POST \ + "EndSection\n\n" + +#define BUILTIN_DEVICE_SECTION \ + BUILTIN_DEVICE_SECTION_PRE \ + BUILTIN_DEVICE_SECTION_POST + +#define BUILTIN_SCREEN_NAME \ + "\"Builtin Default %s Screen %d\"" + +#define BUILTIN_SCREEN_SECTION \ + "Section \"Screen\"\n" \ + "\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \ + "\tDevice\t" BUILTIN_DEVICE_NAME "\n" \ + "EndSection\n\n" + +#define BUILTIN_LAYOUT_SECTION_PRE \ + "Section \"ServerLayout\"\n" \ + "\tIdentifier\t\"Builtin Default Layout\"\n" + +#define BUILTIN_LAYOUT_SCREEN_LINE \ + "\tScreen\t" BUILTIN_SCREEN_NAME "\n" + +#define BUILTIN_LAYOUT_SECTION_POST \ + "EndSection\n\n" + +static const char **builtinConfig = NULL; +static int builtinLines = 0; +static const char *deviceList[] = { + "fbdev", + "vesa", + NULL +}; + +/* + * A built-in config file is stored as an array of strings, with each string + * representing a single line. AppendToConfig() breaks up the string "s" + * into lines, and appends those lines it to builtinConfig. + */ + +static void +AppendToList(const char *s, const char ***list, int *lines) +{ + char *str, *newstr, *p; + + str = xnfstrdup(s); + for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) { + (*lines)++; + *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list)); + newstr = xnfalloc(strlen(p) + 2); + strcpy(newstr, p); + strcat(newstr, "\n"); + (*list)[*lines - 1] = newstr; + (*list)[*lines] = NULL; + } + xfree(str); +} + +static void +FreeList(const char ***list, int *lines) +{ + int i; + + for (i = 0; i < *lines; i++) { + if ((*list)[i]) + xfree((*list)[i]); + } + xfree(*list); + *list = NULL; + *lines = 0; +} + +static void +FreeConfig(void) +{ + FreeList(&builtinConfig, &builtinLines); +} + +static void +AppendToConfig(const char *s) +{ + AppendToList(s, &builtinConfig, &builtinLines); +} + +static const char * +videoPtrToDriverName(struct pci_device *dev) +{ + /* + * things not handled yet: + * cyrix/nsc. should be merged into geode anyway. + * xgi. + */ + + switch (dev->vendor_id) + { + case 0x1022: + if (dev->device_id == 0x2081) + return "geode"; + else + return NULL; + case 0x1142: return "apm"; + case 0xedd8: return "ark"; + case 0x1a03: return "ast"; + case 0x1002: return "ati"; + case 0x102c: return "chips"; + case 0x1013: return "cirrus"; + case 0x8086: + if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) + return "i740"; + else return "intel"; + case 0x102b: return "mga"; + case 0x10c8: return "neomagic"; + case 0x105d: return "i128"; + case 0x10de: case 0x12d2: return "nv"; + case 0x1163: return "rendition"; + case 0x5333: + switch (dev->device_id) + { + case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811: + case 0x8812: case 0x8814: case 0x8901: + return "s3"; + case 0x5631: case 0x883d: case 0x8a01: case 0x8a10: + case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13: + return "s3virge"; + default: + return "savage"; + } + case 0x1039: return "sis"; + case 0x126f: return "siliconmotion"; + case 0x121a: + if (dev->device_id < 0x0003) + return "voodoo"; + else + return "tdfx"; + case 0x3d3d: return "glint"; + case 0x1023: return "trident"; + case 0x100c: return "tseng"; + case 0x1106: return "openchrome"; + case 0x15ad: return "vmware"; + default: break; + } + return NULL; +} + +Bool +xf86AutoConfig(void) +{ + const char **p; + char buf[1024]; + const char *driver = NULL; + ConfigStatus ret; + + driver = chooseVideoDriver(); + + if (driver) { + snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE, + driver, 0, driver); + AppendToConfig(buf); + ErrorF("New driver is \"%s\"\n", driver); + buf[0] = '\t'; + AppendToConfig(BUILTIN_DEVICE_SECTION_POST); + snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, + driver, 0, driver, 0); + AppendToConfig(buf); + } + + for (p = deviceList; *p; p++) { + snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION, *p, 0, *p); + AppendToConfig(buf); + snprintf(buf, sizeof(buf), BUILTIN_SCREEN_SECTION, *p, 0, *p, 0); + AppendToConfig(buf); + } + + AppendToConfig(BUILTIN_LAYOUT_SECTION_PRE); + if (driver) { + snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, driver, 0); + AppendToConfig(buf); + } + for (p = deviceList; *p; p++) { + snprintf(buf, sizeof(buf), BUILTIN_LAYOUT_SCREEN_LINE, *p, 0); + AppendToConfig(buf); + } + AppendToConfig(BUILTIN_LAYOUT_SECTION_POST); + + xf86MsgVerb(X_DEFAULT, 0, + "Using default built-in configuration (%d lines)\n", + builtinLines); + + xf86MsgVerb(X_DEFAULT, 3, "--- Start of built-in configuration ---\n"); + for (p = builtinConfig; *p; p++) + xf86ErrorFVerb(3, "\t%s", *p); + xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n"); + + xf86setBuiltinConfig(builtinConfig); + ret = xf86HandleConfigFile(TRUE); + FreeConfig(); + + if (ret != CONFIG_OK) + xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n"); + + return (ret == CONFIG_OK); +} + +int +xchomp(char *line) +{ + size_t len = 0; + + if (!line) { + return 1; + } + + len = strlen(line); + if (line[len - 1] == '\n' && len > 0) { + line[len - 1] = '\0'; + } + return 0; +} + +GDevPtr +autoConfigDevice(GDevPtr preconf_device) +{ + GDevPtr ptr = NULL; + + if (!xf86configptr) { + return NULL; + } + + /* If there's a configured section with no driver chosen, use it */ + if (preconf_device) { + ptr = preconf_device; + } else { + ptr = (GDevPtr)xalloc(sizeof(GDevRec)); + if (!ptr) { + return NULL; + } + memset((GDevPtr)ptr, 0, sizeof(GDevRec)); + ptr->chipID = -1; + ptr->chipRev = -1; + ptr->irq = -1; + + ptr->active = TRUE; + ptr->claimed = FALSE; + ptr->identifier = "Autoconfigured Video Device"; + ptr->driver = NULL; + } + if (!ptr->driver) { + ptr->driver = chooseVideoDriver(); + } + + /* TODO Handle multiple screen sections */ + if (xf86ConfigLayout.screens && !xf86ConfigLayout.screens->screen->device) { + xf86ConfigLayout.screens->screen->device = ptr; + ptr->myScreenSection = xf86ConfigLayout.screens->screen; + } + xf86Msg(X_DEFAULT, "Assigned the driver to the xf86ConfigLayout\n"); + + return ptr; +} + +#ifdef __linux__ +/* This function is used to provide a workaround for binary drivers that + * don't export their PCI ID's properly. If distros don't end up using this + * feature it can and should be removed because the symbol-based resolution + * scheme should be the primary one */ +static void +matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip) +{ + DIR *idsdir; + FILE *fp; + struct dirent *direntry; + char *line = NULL; + size_t len; + ssize_t read; + char path_name[256], vendor_str[5], chip_str[5]; + uint16_t vendor, chip; + int i, j; + + idsdir = opendir(PCI_TXT_IDS_PATH); + if (!idsdir) + return; + + xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH); + direntry = readdir(idsdir); + /* Read the directory */ + while (direntry) { + if (direntry->d_name[0] == '.') { + direntry = readdir(idsdir); + continue; + } + len = strlen(direntry->d_name); + /* A tiny bit of sanity checking. We should probably do better */ + if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) { + /* We need the full path name to open the file */ + strncpy(path_name, PCI_TXT_IDS_PATH, 256); + strncat(path_name, "/", 1); + strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1)); + fp = fopen(path_name, "r"); + if (fp == NULL) { + xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name); + goto end; + } + /* Read the file */ +#ifdef __GLIBC__ + while ((read = getline(&line, &len, fp)) != -1) { +#else + while ((line = fgetln(fp, &len)) != (char *)NULL) { +#endif /* __GLIBC __ */ + xchomp(line); + if (isdigit(line[0])) { + strncpy(vendor_str, line, 4); + vendor_str[4] = '\0'; + vendor = (int)strtol(vendor_str, NULL, 16); + if ((strlen(&line[4])) == 0) { + chip_str[0] = '\0'; + chip = -1; + } else { + /* Handle trailing whitespace */ + if (isspace(line[4])) { + chip_str[0] = '\0'; + chip = -1; + } else { + /* Ok, it's a real ID */ + strncpy(chip_str, &line[4], 4); + chip_str[4] = '\0'; + chip = (int)strtol(chip_str, NULL, 16); + } + } + if (vendor == match_vendor && chip == match_chip ) { + i = 0; + while (matches[i]) { + i++; + } + matches[i] = (char*)xalloc(sizeof(char) * strlen(direntry->d_name) - 3); + if (!matches[i]) { + xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n"); + goto end; + } + /* hack off the .ids suffix. This should guard + * against other problems, but it will end up + * taking off anything after the first '.' */ + for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) { + if (direntry->d_name[j] == '.') { + matches[i][j] = '\0'; + break; + } else { + matches[i][j] = direntry->d_name[j]; + } + } + xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name); + } + } else { + /* TODO Handle driver overrides here */ + } + } + fclose(fp); + } + direntry = readdir(idsdir); + } + end: + xfree(line); + closedir(idsdir); +} +#endif /* __linux__ */ + +char* +chooseVideoDriver(void) +{ + struct pci_device * info = NULL; + struct pci_device_iterator *iter; + char *chosen_driver = NULL; + int i; + char *matches[20]; /* If we have more than 20 drivers we're in trouble */ + + for (i=0 ; i<20 ; i++) + matches[i] = NULL; + + /* Find the primary device, and get some information about it. */ + iter = pci_slot_match_iterator_create(NULL); + while ((info = pci_device_next(iter)) != NULL) { + if (xf86IsPrimaryPci(info)) { + break; + } + } + + pci_iterator_destroy(iter); + + if (!info) { + ErrorF("Primary device is not PCI\n"); + } +#ifdef __linux__ + else { + matchDriverFromFiles(matches, info->vendor_id, info->device_id); + } +#endif /* __linux__ */ + + /* TODO Handle multiple drivers claiming to support the same PCI ID */ + if (matches[0]) { + chosen_driver = matches[0]; + } else { + if (info != NULL) + chosen_driver = videoPtrToDriverName(info); + if (chosen_driver == NULL) { +#if defined __i386__ || defined __amd64__ || defined __x86_64__ || defined __hurd__ + chosen_driver = "vesa"; +#elif defined __sparc__ + chosen_driver = "sunffb"; +#else + chosen_driver = "fbdev"; +#endif + } + } + + xf86Msg(X_DEFAULT, "Matched %s for the autoconfigured driver\n", chosen_driver); + + i = 0; + while (matches[i]) { + if (matches[i] != chosen_driver) { + xfree(matches[i]); + } + i++; + } + + return chosen_driver; +} diff --git a/xorg-server/hw/xfree86/common/xf86Build.h b/xorg-server/hw/xfree86/common/xf86Build.h new file mode 100644 index 000000000..e261f1b5c --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Build.h @@ -0,0 +1,2 @@ +#define BUILD_DATE 20081105 +#define BUILD_TIME 1144728 diff --git a/xorg-server/hw/xfree86/common/xf86Build.h.in b/xorg-server/hw/xfree86/common/xf86Build.h.in new file mode 100644 index 000000000..a4f56b0ae --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Build.h.in @@ -0,0 +1,2 @@ +#define BUILD_DATE @BUILD_DATE@ +#define BUILD_TIME @BUILD_TIME@ diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c new file mode 100644 index 000000000..f7ffac85e --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Bus.c @@ -0,0 +1,2998 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#define REDUCER +/* + * This file contains the interfaces to the bus-specific code + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Resources.h" + +/* Bus-specific headers */ + +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#define NEED_OS_RAC_PROTOS +#include "xf86_OSproc.h" + +#include "xf86RAC.h" +#include "Pci.h" + +/* Entity data */ +EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */ +int xf86NumEntities = 0; +static int xf86EntityPrivateCount = 0; +BusAccPtr xf86BusAccInfo = NULL; + +xf86AccessRec AccessNULL = {NULL,NULL,NULL}; + +xf86CurrentAccessRec xf86CurrentAccess = {NULL,NULL}; + +BusRec primaryBus = { BUS_NONE, {{0}}}; + +static Bool xf86ResAccessEnter = FALSE; + +#ifdef REDUCER +/* Resources that temporarily conflict with estimated resources */ +static resPtr AccReducers = NULL; +#endif + +/* resource lists */ +resPtr Acc = NULL; + +/* predefined special resources */ +_X_EXPORT resRange resVgaExclusive[] = {_VGA_EXCLUSIVE, _END}; +_X_EXPORT resRange resVgaShared[] = {_VGA_SHARED, _END}; +_X_EXPORT resRange resVgaMemShared[] = {_VGA_SHARED_MEM,_END}; +_X_EXPORT resRange resVgaIoShared[] = {_VGA_SHARED_IO,_END}; +_X_EXPORT resRange resVgaUnusedExclusive[] = {_VGA_EXCLUSIVE_UNUSED, _END}; +_X_EXPORT resRange resVgaUnusedShared[] = {_VGA_SHARED_UNUSED, _END}; +_X_EXPORT resRange resVgaSparseExclusive[] = {_VGA_EXCLUSIVE_SPARSE, _END}; +_X_EXPORT resRange resVgaSparseShared[] = {_VGA_SHARED_SPARSE, _END}; +_X_EXPORT resRange res8514Exclusive[] = {_8514_EXCLUSIVE, _END}; +_X_EXPORT resRange res8514Shared[] = {_8514_SHARED, _END}; + +/* Flag: do we need RAC ? */ +static Bool needRAC = FALSE; +static Bool doFramebufferMode = FALSE; + +/* state change notification callback list */ +static StateChangeNotificationPtr StateChangeNotificationList; +static void notifyStateChange(xf86NotifyState state); + +#undef MIN +#define MIN(x,y) ((xentityInit) { + if (xf86Entities[i]->access->busAcc) + ((BusAccPtr)xf86Entities[i]->access->busAcc)->set_f + (xf86Entities[i]->access->busAcc); + pacc = xf86Entities[i]->access->fallback; + if (pacc->AccessEnable) + pacc->AccessEnable(pacc->arg); + xf86Entities[i]->entityInit(i,xf86Entities[i]->private); + if (pacc->AccessDisable) + pacc->AccessDisable(pacc->arg); + /* remove init resources after init is processed */ + pprev_next = &Acc; + res = Acc; + while (res) { + if (res->res_type & ResInit && (res->entityIndex == i)) { + (*pprev_next) = res->next; + xfree(res); + } else + pprev_next = &(res->next); + res = (*pprev_next); + } + } +} + +int +xf86AllocateEntity(void) +{ + xf86NumEntities++; + xf86Entities = xnfrealloc(xf86Entities, + sizeof(EntityPtr) * xf86NumEntities); + xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec)); + xf86Entities[xf86NumEntities - 1]->entityPrivates = + xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1); + return (xf86NumEntities - 1); +} + +static void +EntityEnter(void) +{ + int i; + xf86AccessPtr pacc; + + for (i = 0; i < xf86NumEntities; i++) + if (xf86Entities[i]->entityEnter) { + if (xf86Entities[i]->access->busAcc) + ((BusAccPtr)xf86Entities[i]->access->busAcc)->set_f + (xf86Entities[i]->access->busAcc); + pacc = xf86Entities[i]->access->fallback; + if (pacc->AccessEnable) + pacc->AccessEnable(pacc->arg); + xf86Entities[i]->entityEnter(i,xf86Entities[i]->private); + if (pacc->AccessDisable) + pacc->AccessDisable(pacc->arg); + } +} + +static void +EntityLeave(void) +{ + int i; + xf86AccessPtr pacc; + + for (i = 0; i < xf86NumEntities; i++) + if (xf86Entities[i]->entityLeave) { + if (xf86Entities[i]->access->busAcc) + ((BusAccPtr)xf86Entities[i]->access->busAcc)->set_f + (xf86Entities[i]->access->busAcc); + pacc = xf86Entities[i]->access->fallback; + if (pacc->AccessEnable) + pacc->AccessEnable(pacc->arg); + xf86Entities[i]->entityLeave(i,xf86Entities[i]->private); + if (pacc->AccessDisable) + pacc->AccessDisable(pacc->arg); + } +} + +_X_EXPORT Bool +xf86IsEntityPrimary(int entityIndex) +{ + EntityPtr pEnt = xf86Entities[entityIndex]; + + if (primaryBus.type != pEnt->busType) return FALSE; + + switch (pEnt->busType) { + case BUS_PCI: + return (pEnt->bus.id.pci == primaryBus.id.pci); + case BUS_ISA: + return TRUE; + case BUS_SBUS: + return (pEnt->sbusBusId.fbNum == primaryBus.id.sbus.fbNum); + default: + return FALSE; + } +} + +_X_EXPORT Bool +xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter, + EntityProc leave, pointer private) +{ + if (entityIndex >= xf86NumEntities) + return FALSE; + xf86Entities[entityIndex]->entityInit = init; + xf86Entities[entityIndex]->entityEnter = enter; + xf86Entities[entityIndex]->entityLeave = leave; + xf86Entities[entityIndex]->private = private; + return TRUE; +} + +Bool +xf86DriverHasEntities(DriverPtr drvp) +{ + int i; + for (i = 0; i < xf86NumEntities; i++) { + if (xf86Entities[i]->driver == drvp) + return TRUE; + } + return FALSE; +} + +_X_EXPORT void +xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex) +{ + if (entityIndex == -1) + return; + if (xf86Entities[entityIndex]->inUse && + !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) { + ErrorF("Requested Entity already in use!\n"); + return; + } + + pScrn->numEntities++; + pScrn->entityList = xnfrealloc(pScrn->entityList, + pScrn->numEntities * sizeof(int)); + pScrn->entityList[pScrn->numEntities - 1] = entityIndex; + xf86Entities[entityIndex]->access->next = pScrn->access; + pScrn->access = xf86Entities[entityIndex]->access; + xf86Entities[entityIndex]->inUse = TRUE; + pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList, + pScrn->numEntities * sizeof(int)); + pScrn->entityInstanceList[pScrn->numEntities - 1] = 0; + pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO; +} + +_X_EXPORT void +xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance) +{ + int i; + + if (entityIndex == -1 || entityIndex >= xf86NumEntities) + return; + + for (i = 0; i < pScrn->numEntities; i++) { + if (pScrn->entityList[i] == entityIndex) { + pScrn->entityInstanceList[i] = instance; + break; + } + } +} + +/* + * XXX This needs to be updated for the case where a single entity may have + * instances associated with more than one screen. + */ +_X_EXPORT ScrnInfoPtr +xf86FindScreenForEntity(int entityIndex) +{ + int i,j; + + if (entityIndex == -1) return NULL; + + if (xf86Screens) { + for (i = 0; i < xf86NumScreens; i++) { + for (j = 0; j < xf86Screens[i]->numEntities; j++) { + if ( xf86Screens[i]->entityList[j] == entityIndex ) + return (xf86Screens[i]); + } + } + } + return NULL; +} + +_X_EXPORT void +xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex) +{ + int i; + EntityAccessPtr *ptr = (EntityAccessPtr *)&pScrn->access; + EntityAccessPtr peacc; + + for (i = 0; i < pScrn->numEntities; i++) { + if (pScrn->entityList[i] == entityIndex) { + peacc = xf86Entities[pScrn->entityList[i]]->access; + (*ptr) = peacc->next; + /* disable entity: call disable func */ + if (peacc->pAccess && peacc->pAccess->AccessDisable) + peacc->pAccess->AccessDisable(peacc->pAccess->arg); + /* also disable fallback - just in case */ + if (peacc->fallback && peacc->fallback->AccessDisable) + peacc->fallback->AccessDisable(peacc->fallback->arg); + for (i++; i < pScrn->numEntities; i++) + pScrn->entityList[i-1] = pScrn->entityList[i]; + pScrn->numEntities--; + xf86Entities[entityIndex]->inUse = FALSE; + break; + } + ptr = &(xf86Entities[pScrn->entityList[i]]->access->next); + } +} + +/* + * xf86ClearEntitiesForScreen() - called when a screen is deleted + * to mark it's entities unused. Called by xf86DeleteScreen(). + */ +void +xf86ClearEntityListForScreen(int scrnIndex) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + EntityAccessPtr peacc; + int i, entityIndex; + + if (pScrn->entityList == NULL || pScrn->numEntities == 0) return; + + for (i = 0; i < pScrn->numEntities; i++) { + entityIndex = pScrn->entityList[i]; + xf86Entities[entityIndex]->inUse = FALSE; + /* disable resource: call the disable function */ + peacc = xf86Entities[entityIndex]->access; + if (peacc->pAccess && peacc->pAccess->AccessDisable) + peacc->pAccess->AccessDisable(peacc->pAccess->arg); + /* and the fallback function */ + if (peacc->fallback && peacc->fallback->AccessDisable) + peacc->fallback->AccessDisable(peacc->fallback->arg); + /* shared resources are only needed when entity is active: remove */ + xf86DeallocateResourcesForEntity(entityIndex, ResShared); + } + xfree(pScrn->entityList); + xfree(pScrn->entityInstanceList); + if (pScrn->CurrentAccess->pIoAccess == (EntityAccessPtr)pScrn->access) + pScrn->CurrentAccess->pIoAccess = NULL; + if (pScrn->CurrentAccess->pMemAccess == (EntityAccessPtr)pScrn->access) + pScrn->CurrentAccess->pMemAccess = NULL; + pScrn->entityList = NULL; + pScrn->entityInstanceList = NULL; +} + +_X_EXPORT void +xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type) +{ + resPtr *pprev_next = &Acc; + resPtr res = Acc; + + while (res) { + if (res->entityIndex == entityIndex && + (type & ResAccMask & res->res_type)) + { + (*pprev_next) = res->next; + xfree(res); + } else + pprev_next = &(res->next); + res = (*pprev_next); + } +} + +/* + * Add an extra device section (GDevPtr) to an entity. + */ + +void +xf86AddDevToEntity(int entityIndex, GDevPtr dev) +{ + EntityPtr pEnt; + + if (entityIndex >= xf86NumEntities) + return; + + pEnt = xf86Entities[entityIndex]; + pEnt->numInstances++; + pEnt->devices = xnfrealloc(pEnt->devices, + pEnt->numInstances * sizeof(GDevPtr)); + pEnt->devices[pEnt->numInstances - 1] = dev; + dev->claimed = TRUE; +} + +/* + * xf86GetEntityInfo() -- This function hands information from the + * EntityRec struct to the drivers. The EntityRec structure itself + * remains invisible to the driver. + */ +_X_EXPORT EntityInfoPtr +xf86GetEntityInfo(int entityIndex) +{ + EntityInfoPtr pEnt; + int i; + + if (entityIndex >= xf86NumEntities) + return NULL; + + pEnt = xnfcalloc(1,sizeof(EntityInfoRec)); + pEnt->index = entityIndex; + pEnt->location = xf86Entities[entityIndex]->bus; + pEnt->active = xf86Entities[entityIndex]->active; + pEnt->chipset = xf86Entities[entityIndex]->chipset; + pEnt->resources = xf86Entities[entityIndex]->resources; + pEnt->driver = xf86Entities[entityIndex]->driver; + if ( (xf86Entities[entityIndex]->devices) && + (xf86Entities[entityIndex]->devices[0]) ) { + for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++) + if (xf86Entities[entityIndex]->devices[i]->screen == 0) + break; + pEnt->device = xf86Entities[entityIndex]->devices[i]; + } else + pEnt->device = NULL; + + return pEnt; +} + +_X_EXPORT int +xf86GetNumEntityInstances(int entityIndex) +{ + if (entityIndex >= xf86NumEntities) + return -1; + + return xf86Entities[entityIndex]->numInstances; +} + +_X_EXPORT GDevPtr +xf86GetDevFromEntity(int entityIndex, int instance) +{ + int i; + + /* We might not use AddDevtoEntity */ + if ( (!xf86Entities[entityIndex]->devices) || + (!xf86Entities[entityIndex]->devices[0]) ) + return NULL; + + if (entityIndex >= xf86NumEntities || + instance >= xf86Entities[entityIndex]->numInstances) + return NULL; + + for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++) + if (xf86Entities[entityIndex]->devices[i]->screen == instance) + break; + return xf86Entities[entityIndex]->devices[i]; +} + +/* + * general generic disable function. + */ +static void +disableAccess(void) +{ + int i; + xf86AccessPtr pacc; + EntityAccessPtr peacc; + + /* call disable funcs and reset current access pointer */ + /* the entity specific access funcs are in an enabled */ + /* state - driver must restore their state explicitely */ + for (i = 0; i < xf86NumScreens; i++) { + peacc = xf86Screens[i]->CurrentAccess->pIoAccess; + while (peacc) { + if (peacc->pAccess && peacc->pAccess->AccessDisable) + peacc->pAccess->AccessDisable(peacc->pAccess->arg); + peacc = peacc->next; + } + xf86Screens[i]->CurrentAccess->pIoAccess = NULL; + peacc = xf86Screens[i]->CurrentAccess->pMemAccess; + while (peacc) { + if (peacc->pAccess && peacc->pAccess->AccessDisable) + peacc->pAccess->AccessDisable(peacc->pAccess->arg); + peacc = peacc->next; + } + xf86Screens[i]->CurrentAccess->pMemAccess = NULL; + } + /* then call the generic entity disable funcs */ + for (i = 0; i < xf86NumEntities; i++) { + pacc = xf86Entities[i]->access->fallback; + if (pacc->AccessDisable) + pacc->AccessDisable(pacc->arg); + } +} + +static void +clearAccess(void) +{ + int i; + + /* call disable funcs and reset current access pointer */ + /* the entity specific access funcs are in an enabled */ + /* state - driver must restore their state explicitely */ + for (i = 0; i < xf86NumScreens; i++) { + xf86Screens[i]->CurrentAccess->pIoAccess = NULL; + xf86Screens[i]->CurrentAccess->pMemAccess = NULL; + } + +} + +/* + * Generic interface to bus specific code - add other buses here + */ + +/* + * xf86AccessInit() - set up everything needed for access control + * called only once on first server generation. + */ +void +xf86AccessInit(void) +{ + initPciState(); + initPciBusState(); + DisablePciBusAccess(); + DisablePciAccess(); + + xf86ResAccessEnter = TRUE; +} + +/* + * xf86AccessEnter() -- gets called to save the text mode VGA IO + * resources when reentering the server after a VT switch. + */ +void +xf86AccessEnter(void) +{ + if (xf86ResAccessEnter) + return; + + /* + * on enter we simply disable routing of special resources + * to any bus and let the RAC code to "open" the right bridges. + */ + PciBusStateEnter(); + DisablePciBusAccess(); + PciStateEnter(); + disableAccess(); + EntityEnter(); + notifyStateChange(NOTIFY_ENTER); + xf86EnterServerState(SETUP); + xf86ResAccessEnter = TRUE; +} + +/* + * xf86AccessLeave() -- prepares access for and calls the + * entityLeave() functions. + * xf86AccessLeaveState() --- gets called to restore the + * access to the VGA IO resources when switching VT or on + * server exit. + * This was split to call xf86AccessLeaveState() from + * ddxGiveUp(). + */ +void +xf86AccessLeave(void) +{ + if (!xf86ResAccessEnter) + return; + notifyStateChange(NOTIFY_LEAVE); + disableAccess(); + DisablePciBusAccess(); + EntityLeave(); +} + +void +xf86AccessLeaveState(void) +{ + if (!xf86ResAccessEnter) + return; + xf86ResAccessEnter = FALSE; + PciStateLeave(); + PciBusStateLeave(); +} + +/* + * xf86AccessRestoreState() - Restore the access registers to the + * state before X was started. This is handy for framebuffers. + */ +static void +xf86AccessRestoreState(void) +{ + if (!xf86ResAccessEnter) + return; + PciStateLeave(); + PciBusStateLeave(); +} + +/* + * xf86EnableAccess() -- enable access to controlled resources. + * To reduce latency when switching access the ScrnInfoRec has + * a linked list of the EntityAccPtr of all screen entities. + */ +/* + * switching access needs to be done in te following oder: + * disable + * 1. disable old entity + * 2. reroute bus + * 3. enable new entity + * Otherwise resources needed for access control might be shadowed + * by other resources! + */ + +_X_EXPORT void +xf86EnableAccess(ScrnInfoPtr pScrn) +{ + register EntityAccessPtr peAcc = (EntityAccessPtr) pScrn->access; + register EntityAccessPtr pceAcc; + register xf86AccessPtr pAcc; + EntityAccessPtr tmp; + +#ifdef DEBUG + ErrorF("Enable access %i\n",pScrn->scrnIndex); +#endif + + /* Entity is not under access control or currently enabled */ + if (!pScrn->access) { + if (pScrn->busAccess) { + ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess); + } + return; + } + + switch (pScrn->resourceType) { + case IO: + pceAcc = pScrn->CurrentAccess->pIoAccess; + if (peAcc == pceAcc) { + return; + } + if (pScrn->CurrentAccess->pMemAccess == pceAcc) + pScrn->CurrentAccess->pMemAccess = NULL; + while (pceAcc) { + pAcc = pceAcc->pAccess; + if ( pAcc && pAcc->AccessDisable) + (*pAcc->AccessDisable)(pAcc->arg); + pceAcc = pceAcc->next; + } + if (pScrn->busAccess) + ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess); + while (peAcc) { + pAcc = peAcc->pAccess; + if (pAcc && pAcc->AccessEnable) + (*pAcc->AccessEnable)(pAcc->arg); + peAcc = peAcc->next; + } + pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access; + return; + + case MEM_IO: + pceAcc = pScrn->CurrentAccess->pIoAccess; + if (peAcc != pceAcc) { /* current Io != pAccess */ + tmp = pceAcc; + while (pceAcc) { + pAcc = pceAcc->pAccess; + if (pAcc && pAcc->AccessDisable) + (*pAcc->AccessDisable)(pAcc->arg); + pceAcc = pceAcc->next; + } + pceAcc = pScrn->CurrentAccess->pMemAccess; + if (peAcc != pceAcc /* current Mem != pAccess */ + && tmp !=pceAcc) { + while (pceAcc) { + pAcc = pceAcc->pAccess; + if (pAcc && pAcc->AccessDisable) + (*pAcc->AccessDisable)(pAcc->arg); + pceAcc = pceAcc->next; + } + } + } else { /* current Io == pAccess */ + pceAcc = pScrn->CurrentAccess->pMemAccess; + if (pceAcc == peAcc) { /* current Mem == pAccess */ + return; + } + while (pceAcc) { /* current Mem != pAccess */ + pAcc = pceAcc->pAccess; + if (pAcc && pAcc->AccessDisable) + (*pAcc->AccessDisable)(pAcc->arg); + pceAcc = pceAcc->next; + } + } + if (pScrn->busAccess) + ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess); + while (peAcc) { + pAcc = peAcc->pAccess; + if (pAcc && pAcc->AccessEnable) + (*pAcc->AccessEnable)(pAcc->arg); + peAcc = peAcc->next; + } + pScrn->CurrentAccess->pMemAccess = + pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access; + return; + + case MEM: + pceAcc = pScrn->CurrentAccess->pMemAccess; + if (peAcc == pceAcc) { + return; + } + if (pScrn->CurrentAccess->pIoAccess == pceAcc) + pScrn->CurrentAccess->pIoAccess = NULL; + while (pceAcc) { + pAcc = pceAcc->pAccess; + if ( pAcc && pAcc->AccessDisable) + (*pAcc->AccessDisable)(pAcc->arg); + pceAcc = pceAcc->next; + } + if (pScrn->busAccess) + ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess); + while (peAcc) { + pAcc = peAcc->pAccess; + if (pAcc && pAcc->AccessEnable) + (*pAcc->AccessEnable)(pAcc->arg); + peAcc = peAcc->next; + } + pScrn->CurrentAccess->pMemAccess = (EntityAccessPtr) pScrn->access; + return; + + case NONE: + if (pScrn->busAccess) { + ((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess); + } + return; + } +} + +_X_EXPORT void +xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn) +{ + EntityAccessPtr pceAcc2 = NULL; + register EntityAccessPtr pceAcc = NULL; + register xf86AccessPtr pAcc; + + + switch(pScrn->resourceType) { + case IO: + pceAcc = pScrn->CurrentAccess->pIoAccess; + break; + case MEM: + pceAcc = pScrn->CurrentAccess->pMemAccess; + break; + case MEM_IO: + pceAcc = pScrn->CurrentAccess->pMemAccess; + pceAcc2 = pScrn->CurrentAccess->pIoAccess; + break; + default: + break; + } + + while (pceAcc) { + pAcc = pceAcc->pAccess; + if ( pAcc) { + if (!Enable) { + if (pAcc->AccessDisable) + (*pAcc->AccessDisable)(pAcc->arg); + } else { + if (pAcc->AccessEnable) + (*pAcc->AccessEnable)(pAcc->arg); + } + } + pceAcc = pceAcc->next; + if (!pceAcc) { + pceAcc = pceAcc2; + pceAcc2 = NULL; + } + } +} + +_X_EXPORT void +xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs, + xf86SetAccessFuncPtr oldFuncs) +{ + AccessFuncPtr rac; + + if (!xf86Entities[pEnt->index]->rac) + xf86Entities[pEnt->index]->rac = xnfcalloc(1,sizeof(AccessFuncRec)); + + rac = xf86Entities[pEnt->index]->rac; + + if (funcs->mem == funcs->io_mem && funcs->mem && funcs->io) + xf86Entities[pEnt->index]->entityProp |= NO_SEPARATE_MEM_FROM_IO; + if (funcs->io == funcs->io_mem && funcs->mem && funcs->io) + xf86Entities[pEnt->index]->entityProp |= NO_SEPARATE_IO_FROM_MEM; + + rac->mem_new = funcs->mem; + rac->io_new = funcs->io; + rac->io_mem_new = funcs->io_mem; + + rac->old = oldFuncs; +} + +/* + * Conflict checking + */ + +static memType +getMask(memType val) +{ + memType mask = 0; + memType tmp = 0; + + mask=~mask; + tmp = ~((~tmp) >> 1); + + while (!(val & tmp)) { + mask = mask >> 1; + val = val << 1; + } + return mask; +} + +/* + * checkConflictBlock() -- check for conflicts of a block resource range. + * If conflict is found return end of conflicting range. Else return 0. + */ +static memType +checkConflictBlock(resRange *range, resPtr pRes) +{ + memType val,tmp,prev; + int i; + + switch (pRes->res_type & ResExtMask) { + case ResBlock: + if (range->rBegin < pRes->block_end && + range->rEnd > pRes->block_begin) { +#ifdef DEBUG + ErrorF("b-b conflict w: %lx %lx\n", + pRes->block_begin,pRes->block_end); +#endif + return pRes->block_end < range->rEnd ? + pRes->block_end : range->rEnd; + } + return 0; + case ResSparse: + if (pRes->sparse_base > range->rEnd) return 0; + + val = (~pRes->sparse_mask | pRes->sparse_base) & getMask(range->rEnd); +#ifdef DEBUG + ErrorF("base = 0x%lx, mask = 0x%lx, begin = 0x%lx, end = 0x%lx ," + "val = 0x%lx\n", + pRes->sparse_base, pRes->sparse_mask, range->rBegin, + range->rEnd, val); +#endif + i = sizeof(memType) * 8; + tmp = prev = pRes->sparse_base; + + while (i) { + tmp |= 1<< (--i) & val; + if (tmp > range->rEnd) + tmp = prev; + else + prev = tmp; + } + if (tmp >= range->rBegin) { +#ifdef DEBUG + ErrorF("conflict found at: 0x%lx\n",tmp); + ErrorF("b-d conflict w: %lx %lx\n", + pRes->sparse_base,pRes->sparse_mask); +#endif + return tmp; + } + else + return 0; + } + return 0; +} + +/* + * checkConflictSparse() -- check for conflicts of a sparse resource range. + * If conflict is found return base of conflicting region. Else return 0. + */ +#define mt_max ~(memType)0 +#define length sizeof(memType) * 8 +static memType +checkConflictSparse(resRange *range, resPtr pRes) +{ + memType val, tmp, prev; + int i; + + switch (pRes->res_type & ResExtMask) { + case ResSparse: + tmp = pRes->sparse_mask & range->rMask; + if ((tmp & pRes->sparse_base) == (tmp & range->rBase)) { +#ifdef DEBUG + ErrorF("s-b conflict w: %lx %lx\n", + pRes->sparse_base,pRes->sparse_mask); +#endif + return pRes->sparse_mask; + } + return 0; + + case ResBlock: + if (pRes->block_end < range->rBase) return 0; + + val = (~range->rMask | range->rBase) & getMask(pRes->block_end); + i = length; + tmp = prev = range->rBase; + + while (i) { +#ifdef DEBUG + ErrorF("tmp = 0x%lx\n",tmp); +#endif + tmp |= 1<< (--i) & val; + if (tmp > pRes->block_end) + tmp = prev; + else + prev = tmp; + } + if (tmp < pRes->block_begin) + return 0; + else { + /* + * now we subdivide the block region in sparse regions + * with base values = 2^n and find the smallest mask. + * This might be done in a simpler way.... + */ + memType mask, m_mask = 0, base = pRes->block_begin; + int i; + while (base < pRes->block_end) { + for (i = 1; i < length; i++) + if ( base != (base & (mt_max << i))) break; + mask = mt_max >> (length - i); + do mask >>= 1; + while ((mask + base + 1) > pRes->block_end); + /* m_mask and are _inverted_ sparse masks */ + m_mask = mask > m_mask ? mask : m_mask; + base = base + mask + 1; + } +#ifdef DEBUG + ErrorF("conflict found at: 0x%lx\n",tmp); + ErrorF("b-b conflict w: %lx %lx\n", + pRes->block_begin,pRes->block_end); +#endif + return ~m_mask; + } + } + return 0; +} +#undef mt_max +#undef length + +/* + * needCheck() -- this function decides whether to check for conflicts + * depending on the types of the resource ranges and their locations + */ +static Bool +needCheck(resPtr pRes, unsigned long type, int entityIndex, xf86State state) +{ + /* the same entity shouldn't conflict with itself */ + ScrnInfoPtr pScrn; + int i; + BusType loc = BUS_NONE; + BusType r_loc = BUS_NONE; + + /* Ignore overlapped ranges that have been nullified */ + if ((pRes->res_type & ResOverlap) && (pRes->block_begin > pRes->block_end)) + return FALSE; + + if ((pRes->res_type & ResTypeMask) != (type & ResTypeMask)) + return FALSE; + + /* + * Resources set by BIOS (ResBios) are allowed to conflict + * with resources marked (ResBios). + */ + if (pRes->res_type & type & ResBios) + return FALSE; + + /*If requested, skip over estimated resources */ + if (pRes->res_type & type & ResEstimated) + return FALSE; + + if (type & pRes->res_type & ResUnused) + return FALSE; + + if (state == OPERATING) { + if (type & ResDisableOpr || pRes->res_type & ResDisableOpr) + return FALSE; + if (type & pRes->res_type & ResUnusedOpr) return FALSE; + /* + * Maybe we should have ResUnused set The resUnusedOpr + * bit, too. This way we could avoid this confusion + */ + if ((type & ResUnusedOpr && pRes->res_type & ResUnused) || + (type & ResUnused && pRes->res_type & ResUnusedOpr)) + return FALSE; + } + + if (entityIndex > -1) + loc = xf86Entities[entityIndex]->busType; + if (pRes->entityIndex > -1) + r_loc = xf86Entities[pRes->entityIndex]->busType; + + switch (type & ResAccMask) { + case ResExclusive: + switch (pRes->res_type & ResAccMask) { + case ResExclusive: + break; + case ResShared: + /* ISA buses are only locally exclusive on a PCI system */ + if (loc == BUS_ISA && r_loc == BUS_PCI) + return FALSE; + break; + } + break; + case ResShared: + switch (pRes->res_type & ResAccMask) { + case ResExclusive: + /* ISA buses are only locally exclusive on a PCI system */ + if (loc == BUS_PCI && r_loc == BUS_ISA) + return FALSE; + break; + case ResShared: + return FALSE; + } + break; + case ResAny: + break; + } + + if (pRes->entityIndex == entityIndex) return FALSE; + + if (pRes->entityIndex > -1 && + (pScrn = xf86FindScreenForEntity(entityIndex))) { + for (i = 0; i < pScrn->numEntities; i++) + if (pScrn->entityList[i] == pRes->entityIndex) return FALSE; + } + return TRUE; +} + +/* + * checkConflict() - main conflict checking function which all other + * function call. + */ +static memType +checkConflict(resRange *rgp, resPtr pRes, int entityIndex, + xf86State state, Bool ignoreIdentical) +{ + memType ret; + + while(pRes) { + if (!needCheck(pRes,rgp->type, entityIndex ,state)) { + pRes = pRes->next; + continue; + } + switch (rgp->type & ResExtMask) { + case ResBlock: + if (rgp->rEnd < rgp->rBegin) { + xf86Msg(X_ERROR,"end of block range 0x%lx < begin 0x%lx\n", + rgp->rEnd,rgp->rBegin); + return 0; + } + if ((ret = checkConflictBlock(rgp, pRes))) { + if (!ignoreIdentical || (rgp->rBegin != pRes->block_begin) + || (rgp->rEnd != pRes->block_end)) + return ret; + } + break; + case ResSparse: + if ((rgp->rBase & rgp->rMask) != rgp->rBase) { + xf86Msg(X_ERROR,"sparse io range (base: 0x%lx mask: 0x%lx)" + "doesn't satisfy (base & mask = mask)\n", + rgp->rBase, rgp->rMask); + return 0; + } + if ((ret = checkConflictSparse(rgp, pRes))) { + if (!ignoreIdentical || (rgp->rBase != pRes->sparse_base) + || (rgp->rMask != pRes->sparse_mask)) + return ret; + } + break; + } + pRes = pRes->next; + } + return 0; +} + +/* + * ChkConflict() -- used within xxxBus ; find conflict with any location. + */ +memType +ChkConflict(resRange *rgp, resPtr res, xf86State state) +{ + return checkConflict(rgp, res, -2, state,FALSE); +} + +/* + * xf86ChkConflict() - This function is the low level interface to + * the resource broker that gets exported. Tests all resources ie. + * performs test with SETUP flag. + */ +_X_EXPORT memType +xf86ChkConflict(resRange *rgp, int entityIndex) +{ + return checkConflict(rgp, Acc, entityIndex, SETUP,FALSE); +} + +/* + * Resources List handling + */ + +_X_EXPORT resPtr +xf86JoinResLists(resPtr rlist1, resPtr rlist2) +{ + resPtr pRes; + + if (!rlist1) + return rlist2; + + if (!rlist2) + return rlist1; + + for (pRes = rlist1; pRes->next; pRes = pRes->next) + ; + pRes->next = rlist2; + return rlist1; +} + +_X_EXPORT resPtr +xf86AddResToList(resPtr rlist, resRange *range, int entityIndex) +{ + resPtr new; + + switch (range->type & ResExtMask) { + case ResBlock: + if (range->rEnd < range->rBegin) { + xf86Msg(X_ERROR,"end of block range 0x%lx < begin 0x%lx\n", + range->rEnd,range->rBegin); + return rlist; + } + break; + case ResSparse: + if ((range->rBase & range->rMask) != range->rBase) { + xf86Msg(X_ERROR,"sparse io range (base: 0x%lx mask: 0x%lx)" + "doesn't satisfy (base & mask = mask)\n", + range->rBase, range->rMask); + return rlist; + } + break; + } + + new = xnfalloc(sizeof(resRec)); + /* + * Only background resources may be registered with ResBios + * and ResEstimated set. Other resources only set it for + * testing. + */ + if (entityIndex != (-1)) + range->type &= ~(ResBios | ResEstimated); + new->val = *range; + new->entityIndex = entityIndex; + new->next = rlist; + return new; +} + +_X_EXPORT void +xf86FreeResList(resPtr rlist) +{ + resPtr pRes; + + if (!rlist) + return; + + for (pRes = rlist->next; pRes; rlist = pRes, pRes = pRes->next) + xfree(rlist); + xfree(rlist); +} + +_X_EXPORT resPtr +xf86DupResList(const resPtr rlist) +{ + resPtr pRes, ret, prev, new; + + if (!rlist) + return NULL; + + ret = xnfalloc(sizeof(resRec)); + *ret = *rlist; + prev = ret; + for (pRes = rlist->next; pRes; pRes = pRes->next) { + new = xnfalloc(sizeof(resRec)); + *new = *pRes; + prev->next = new; + prev = new; + } + return ret; +} + +_X_EXPORT void +xf86PrintResList(int verb, resPtr list) +{ + int i = 0; + const char *s, *r; + resPtr tmp = list; + unsigned long type; + + if (!list) + return; + + type = ResMem; + r = "M"; + while (1) { + while (list) { + if ((list->res_type & ResPhysMask) == type) { + switch (list->res_type & ResExtMask) { + case ResBlock: + xf86ErrorFVerb(verb, + "\t[%d] %d\t%ld\t0x%08lx - 0x%08lx (0x%lx)", + i, list->entityIndex, + (list->res_type & ResDomain) >> 24, + list->block_begin, list->block_end, + list->block_end - list->block_begin + 1); + break; + case ResSparse: + xf86ErrorFVerb(verb, "\t[%d] %d\t%ld\t0x%08lx - 0x%08lx ", + i, list->entityIndex, + (list->res_type & ResDomain) >> 24, + list->sparse_base,list->sparse_mask); + break; + default: + list = list->next; + continue; + } + xf86ErrorFVerb(verb, " %s", r); + switch (list->res_type & ResAccMask) { + case ResExclusive: + if (list->res_type & ResUnused) + s = "x"; + else + s = "X"; + break; + case ResShared: + if (list->res_type & ResUnused) + s = "s"; + else + s = "S"; + break; + default: + s = "?"; + } + xf86ErrorFVerb(verb, "%s", s); + switch (list->res_type & ResExtMask) { + case ResBlock: + s = "[B]"; + break; + case ResSparse: + s = "[S]"; + break; + default: + s = "[?]"; + } + xf86ErrorFVerb(verb, "%s", s); + if (list->res_type & ResEstimated) + xf86ErrorFVerb(verb, "E"); + if (list->res_type & ResOverlap) + xf86ErrorFVerb(verb, "O"); + if (list->res_type & ResInit) + xf86ErrorFVerb(verb, "t"); + if (list->res_type & ResBios) + xf86ErrorFVerb(verb, "(B)"); + if (list->res_type & ResBus) + xf86ErrorFVerb(verb, "(b)"); + if (list->res_type & ResOprMask) { + switch (list->res_type & ResOprMask) { + case ResUnusedOpr: + s = "(OprU)"; + break; + case ResDisableOpr: + s = "(OprD)"; + break; + default: + s = "(Opr?)"; + break; + } + xf86ErrorFVerb(verb, "%s", s); + } + xf86ErrorFVerb(verb, "\n"); + i++; + } + list = list->next; + } + if (type == ResIo) break; + type = ResIo; + r = "I"; + list = tmp; + } +} + +resPtr +xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex) +{ + while(pRange && pRange->type != ResEnd) { + list = xf86AddResToList(list,pRange,entityIndex); + pRange++; + } + return list; +} + +void +xf86ResourceBrokerInit(void) +{ + Acc = NULL; + + /* Get the ranges used exclusively by the system */ + Acc = xf86AccResFromOS(Acc); + xf86MsgVerb(X_INFO, 3, "System resource ranges:\n"); + xf86PrintResList(3, Acc); +} + +#define MEM_ALIGN (1024 * 1024) + +/* + * RemoveOverlaps() -- remove overlaps between resources of the + * same kind. + * Beware: This function doesn't check for access attributes. + * At resource broker initialization this is no problem as this + * only deals with exclusive resources. + */ +#if 0 +void +RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment, Bool useEstimated) +{ + resPtr pRes; + memType size, newsize, adjust; + + if (!target) + return; + + for (pRes = list; pRes; pRes = pRes->next) { + if (pRes != target + && ((pRes->res_type & ResTypeMask) == + (target->res_type & ResTypeMask)) + && pRes->block_begin <= target->block_end + && pRes->block_end >= target->block_begin) { + /* Possibly ignore estimated resources */ + if (!useEstimated && (pRes->res_type & ResEstimated)) continue; + /* + * Target should be a larger region than pRes. If pRes fully + * contains target, don't do anything unless target can overlap. + */ + if (pRes->block_begin <= target->block_begin && + pRes->block_end >= target->block_end) { + if (target->res_type & ResOverlap) { + /* Nullify range but keep its ResOverlap bit on */ + target->block_end = target->block_begin - 1; + return; + } + continue; + } + /* + * In cases where the target and pRes have the same starting + * address, reduce the size of the target (given it's an estimate). + */ + if (pRes->block_begin == target->block_begin) { + if (target->res_type & ResOverlap) + target->block_end = target->block_begin - 1; + else + target->block_end = pRes->block_end; + } + /* Otherwise, trim target to remove the overlap */ + else if (pRes->block_begin <= target->block_end) { + target->block_end = pRes->block_begin - 1; + } else if (!pow2Alignment && + pRes->block_end >= target->block_begin) { + target->block_begin = pRes->block_end + 1; + } + if (pow2Alignment) { + /* + * Align to a power of two. This requires finding the + * largest power of two that is smaller than the adjusted + * size. + */ + size = target->block_end - target->block_begin + 1; + newsize = 1UL << (sizeof(memType) * 8 - 1); + while (!(newsize & size)) + newsize >>= 1; + target->block_end = target->block_begin + newsize - 1; + } else if (target->block_end > MEM_ALIGN) { + /* Align the end to MEM_ALIGN */ + if ((adjust = (target->block_end + 1) % MEM_ALIGN)) + target->block_end -= adjust; + } + } + } +} +#else + +void +RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment, Bool useEstimated) +{ + resPtr pRes; + memType size, newsize, adjust; + + if (!target) + return; + + if (!(target->res_type & ResEstimated) /* Don't touch sure resources */ + && !(target->res_type & ResOverlap)) /* Unless they may overlap */ + return; + + for (pRes = list; pRes; pRes = pRes->next) { + if (pRes == target + || ((pRes->res_type & ResTypeMask) != + (target->res_type & ResTypeMask)) + || pRes->block_begin > target->block_end + || pRes->block_end < target->block_begin) + continue; + + if (pRes->block_begin <= target->block_begin) { + /* Possibly ignore estimated resources */ + if (!useEstimated && (pRes->res_type & ResEstimated)) + continue; + + /* Special cases */ + if (pRes->block_end >= target->block_end) { + /* + * If pRes fully contains target, don't do anything + * unless target can overlap. + */ + if (target->res_type & ResOverlap) { + /* Nullify range but keep its ResOverlap bit on */ + target->block_end = target->block_begin - 1; + return; + } else + continue; + } else { +#if 0 /* Don't trim start address - we trust what we got */ + /* + * If !pow2Alignment trim start address: !pow2Alingment + * is only set when estimated OS addresses are handled. + * In cases where the target and pRes have the same + * starting address, reduce the size of the target + * (given it's an estimate). + */ + if (!pow2Alignment) + target->block_begin = pRes->block_end + 1; + else +#endif + if (pRes->block_begin == target->block_begin) + target->block_end = pRes->block_end; + else + continue; + } + } else { + /* Trim target to remove the overlap */ + target->block_end = pRes->block_begin - 1; + } + if (pow2Alignment) { + /* + * Align to a power of two. This requires finding the + * largest power of two that is smaller than the adjusted + * size. + */ + size = target->block_end - target->block_begin + 1; + newsize = 1UL << (sizeof(memType) * 8 - 1); + while (!(newsize & size)) + newsize >>= 1; + target->block_end = target->block_begin + newsize - 1; + } else if (target->block_end > MEM_ALIGN) { + /* Align the end to MEM_ALIGN */ + if ((adjust = (target->block_end + 1) % MEM_ALIGN)) + target->block_end -= adjust; + } + } +} + +#endif + +/* + * Resource registrarion + */ + +static resList +xf86GetResourcesImplicitly(int entityIndex) +{ + if (entityIndex >= xf86NumEntities) return NULL; + + switch (xf86Entities[entityIndex]->bus.type) { + case BUS_ISA: + case BUS_NONE: + case BUS_SBUS: + return NULL; + case BUS_PCI: + return NULL; + case BUS_last: + return NULL; + } + return NULL; +} + +static void +convertRange2Host(int entityIndex, resRange *pRange) +{ + if (pRange->type & ResBus) { + switch (xf86Entities[entityIndex]->busType) { + case BUS_PCI: + pciConvertRange2Host(entityIndex,pRange); + break; + case BUS_ISA: + isaConvertRange2Host(pRange); + break; + default: + break; + } + + pRange->type &= ~ResBus; + } +} + +static void +xf86ConvertListToHost(int entityIndex, resPtr list) +{ + while (list) { + convertRange2Host(entityIndex, &list->val); + list = list->next; + } +} + +/* + * xf86RegisterResources() -- attempts to register listed resources. + * If list is NULL it tries to obtain resources implicitly. Function + * returns a resPtr listing all resources not successfully registered. + */ + +_X_EXPORT resPtr +xf86RegisterResources(int entityIndex, resList list, unsigned long access) +{ + resPtr res = NULL; + resRange range; + resList list_f = NULL; + + if (!list) { + list = xf86GetResourcesImplicitly(entityIndex); + /* these resources have to be in host address space already */ + if (!list) return NULL; + list_f = list; + } + + while(list->type != ResEnd) { + range = *list; + + convertRange2Host(entityIndex,&range); + + if ((access != ResNone) && (access & ResAccMask)) { + range.type = (range.type & ~ResAccMask) | (access & ResAccMask); + } + range.type &= ~ResEstimated; /* Not allowed for drivers */ +#if !((defined(__alpha__) || (defined(__ia64__))) && defined(linux)) + /* On Alpha Linux, do not check for conflicts, trust the kernel. */ + if (checkConflict(&range, Acc, entityIndex, SETUP,TRUE)) + res = xf86AddResToList(res,&range,entityIndex); + else +#endif + { + Acc = xf86AddResToList(Acc,&range,entityIndex); + } + list++; + } + if (list_f) + xfree(list_f); + +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3,"Resources after driver initialization\n"); + xf86PrintResList(3, Acc); + if (res) xf86MsgVerb(X_INFO, 3, + "Failed Resources after driver initialization " + "for Entity: %i\n",entityIndex); + xf86PrintResList(3, res); +#endif + return res; + +} + +static void +busTypeSpecific(EntityPtr pEnt, xf86AccessPtr *acc_mem, + xf86AccessPtr *acc_io, xf86AccessPtr *acc_mem_io) +{ + switch (pEnt->bus.type) { + case BUS_ISA: + case BUS_SBUS: + *acc_mem = *acc_io = *acc_mem_io = &AccessNULL; + break; + case BUS_PCI: { + struct pci_device *const dev = pEnt->bus.id.pci; + + if ((dev != NULL) && ((void *)dev->user_data != NULL)) { + pciAccPtr const paccp = (pciAccPtr) dev->user_data; + + *acc_io = & paccp->ioAccess; + *acc_mem = & paccp->memAccess; + *acc_mem_io = & paccp->io_memAccess; + } + else { + /* FIXME: This is an error path. We should probably have an + * FIXME: assertion here or something. + */ + *acc_io = NULL; + *acc_mem = NULL; + *acc_mem_io = NULL; + } + break; + } + default: + *acc_mem = *acc_io = *acc_mem_io = NULL; + break; + } + return; +} + +static void +setAccess(EntityPtr pEnt, xf86State state) +{ + + xf86AccessPtr acc_mem, acc_io, acc_mem_io; + xf86AccessPtr org_mem = NULL, org_io = NULL, org_mem_io = NULL; + int prop; + + busTypeSpecific(pEnt, &acc_mem, &acc_io, &acc_mem_io); + + /* The replacement function needs to handle _all_ shared resources */ + /* unless they are handeled locally and disabled otherwise */ + if (pEnt->rac) { + if (pEnt->rac->io_new) { + org_io = acc_io; + acc_io = pEnt->rac->io_new; + } + if (pEnt->rac->mem_new) { + org_mem = acc_mem; + acc_mem = pEnt->rac->mem_new; + } + if (pEnt->rac->io_mem_new) { + org_mem_io = acc_mem_io; + acc_mem_io = pEnt->rac->io_mem_new; + } + } + + if (state == OPERATING) { + prop = pEnt->entityProp; + switch(pEnt->entityProp & NEED_SHARED) { + case NEED_SHARED: + pEnt->access->rt = MEM_IO; + break; + case NEED_IO_SHARED: + pEnt->access->rt = IO; + break; + case NEED_MEM_SHARED: + pEnt->access->rt = MEM; + break; + default: + pEnt->access->rt = NONE; + } + } else { + prop = NEED_SHARED | NEED_MEM | NEED_IO; + pEnt->access->rt = MEM_IO; + } + + switch(pEnt->access->rt) { + case IO: + pEnt->access->pAccess = acc_io; + break; + case MEM: + pEnt->access->pAccess = acc_mem; + break; + case MEM_IO: + pEnt->access->pAccess = acc_mem_io; + break; + default: /* no conflicts at all */ + pEnt->access->pAccess = NULL; /* remove from RAC */ + break; + } + + if (org_io) { + /* does the driver want the old access func? */ + if (pEnt->rac->old) { + /* give it to the driver, leave state disabled */ + pEnt->rac->old->io = org_io; + } else if (org_io->AccessEnable) { + /* driver doesn't want it - enable generic access */ + org_io->AccessEnable(org_io->arg); + } + } + + if (org_mem_io) { + /* does the driver want the old access func? */ + if (pEnt->rac->old) { + /* give it to the driver, leave state disabled */ + pEnt->rac->old->io_mem = org_mem_io; + } else if (org_mem_io->AccessEnable) { + /* driver doesn't want it - enable generic access */ + org_mem_io->AccessEnable(org_mem_io->arg); + } + } + + if (org_mem) { + /* does the driver want the old access func? */ + if (pEnt->rac->old) { + /* give it to the driver, leave state disabled */ + pEnt->rac->old->mem = org_mem; + } else if (org_mem->AccessEnable) { + /* driver doesn't want it - enable generic access */ + org_mem->AccessEnable(org_mem->arg); + } + } + + if (!(prop & NEED_MEM_SHARED)){ + if (prop & NEED_MEM) { + if (acc_mem && acc_mem->AccessEnable) + acc_mem->AccessEnable(acc_mem->arg); + } else { + if (acc_mem && acc_mem->AccessDisable) + acc_mem->AccessDisable(acc_mem->arg); + } + } + + if (!(prop & NEED_IO_SHARED)) { + if (prop & NEED_IO) { + if (acc_io && acc_io->AccessEnable) + acc_io->AccessEnable(acc_io->arg); + } else { + if (acc_io && acc_io->AccessDisable) + acc_io->AccessDisable(acc_io->arg); + } + } + + /* disable shared resources */ + if (pEnt->access->pAccess + && pEnt->access->pAccess->AccessDisable) + pEnt->access->pAccess->AccessDisable(pEnt->access->pAccess->arg); + + /* + * If device is not under access control it is enabled. + * If it needs bus routing do it here as it isn't bus + * type specific. Any conflicts should be checked at this + * stage + */ + if (!pEnt->access->pAccess + && (pEnt->entityProp & (state == SETUP ? NEED_VGA_ROUTED_SETUP : + NEED_VGA_ROUTED))) + ((BusAccPtr)pEnt->busAcc)->set_f(pEnt->busAcc); +} + + +/* + * xf86EnterServerState() -- set state the server is in. + */ + +typedef enum { TRI_UNSET, TRI_TRUE, TRI_FALSE } TriState; + +static void +SetSIGIOForState(xf86State state) +{ + static int sigio_state; + static TriState sigio_blocked = TRI_UNSET; + + if ((state == SETUP) && (sigio_blocked != TRI_TRUE)) { + sigio_state = xf86BlockSIGIO(); + sigio_blocked = TRI_TRUE; + } else if ((state == OPERATING) && (sigio_blocked != TRI_UNSET)) { + xf86UnblockSIGIO(sigio_state); + sigio_blocked = TRI_FALSE; + } +} + +_X_EXPORT void +xf86EnterServerState(xf86State state) +{ + EntityPtr pEnt; + ScrnInfoPtr pScrn; + int i,j; + int needVGA = 0; + resType rt; + /* + * This is a good place to block SIGIO during SETUP state. + * SIGIO should be blocked in SETUP state otherwise (u)sleep() + * might get interrupted early. + * We take care not to call xf86BlockSIGIO() twice. + */ + SetSIGIOForState(state); +#ifdef DEBUG + if (state == SETUP) + ErrorF("Entering SETUP state\n"); + else + ErrorF("Entering OPERATING state\n"); +#endif + + /* When servicing a dumb framebuffer we don't need to do anything */ + if (doFramebufferMode) return; + + for (i=0; ientityList[pScrn->numEntities - 1]; + pScrn->access = xf86Entities[j]->access; + + for (j = 0; jnumEntities; j++) { + pEnt = xf86Entities[xf86Screens[i]->entityList[j]]; + if (pEnt->entityProp & (state == SETUP ? NEED_VGA_ROUTED_SETUP + : NEED_VGA_ROUTED)) + xf86Screens[i]->busAccess = pEnt->busAcc; + } + if (xf86Screens[i]->busAccess) + needVGA ++; + } + + /* + * if we just have one screen we don't have RAC. + * Therefore just enable the screen and return. + */ + if (!needRAC) { + xf86EnableAccess(xf86Screens[0]); + notifyStateChange(NOTIFY_ENABLE); + return; + } + + if (state == SETUP) + notifyStateChange(NOTIFY_SETUP_TRANSITION); + else + notifyStateChange(NOTIFY_OPERATING_TRANSITION); + + clearAccess(); + for (i=0; inumEntities; j++) { + pEnt = xf86Entities[xf86Screens[i]->entityList[j]]; + setAccess(pEnt,state); + + if (pEnt->access->rt != NONE) { + if (rt != NONE && rt != pEnt->access->rt) + rt = MEM_IO; + else + rt = pEnt->access->rt; + } + } + xf86Screens[i]->resourceType = rt; + if (rt == NONE) { + xf86Screens[i]->access = NULL; + if (needVGA < 2) + xf86Screens[i]->busAccess = NULL; + } + +#ifdef DEBUG + if (xf86Screens[i]->busAccess) + ErrorF("Screen %i setting vga route\n",i); +#endif + switch (rt) { + case MEM_IO: + xf86MsgVerb(X_INFO, 3, "Screen %i shares mem & io resources\n",i); + break; + case IO: + xf86MsgVerb(X_INFO, 3, "Screen %i shares io resources\n",i); + break; + case MEM: + xf86MsgVerb(X_INFO, 3, "Screen %i shares mem resources\n",i); + break; + default: + xf86MsgVerb(X_INFO, 3, "Entity %i shares no resources\n",i); + break; + } + } + if (state == SETUP) + notifyStateChange(NOTIFY_SETUP); + else + notifyStateChange(NOTIFY_OPERATING); +} + +/* + * xf86SetOperatingState() -- Set ResOperMask for resources listed. + */ +_X_EXPORT resPtr +xf86SetOperatingState(resList list, int entityIndex, int mask) +{ + resPtr acc; + resPtr r_fail = NULL; + resRange range; + + while (list->type != ResEnd) { + range = *list; + convertRange2Host(entityIndex,&range); + + acc = Acc; + while (acc) { +#define MASK (ResTypeMask | ResExtMask) + if ((acc->entityIndex == entityIndex) + && (acc->val.a == range.a) && (acc->val.b == range.b) + && ((acc->val.type & MASK) == (range.type & MASK))) + break; +#undef MASK + acc = acc->next; + } + if (acc) + acc->val.type = (acc->val.type & ~ResOprMask) + | (mask & ResOprMask); + else { + r_fail = xf86AddResToList(r_fail,&range,entityIndex); + } + list ++; + } + + return r_fail; +} + +/* + * Stage specific code + */ + /* + * ProcessEstimatedConflicts() -- Do something about driver-registered + * resources that conflict with estimated resources. For now, just register + * them with a logged warning. + */ +#ifdef REDUCER +static void +ProcessEstimatedConflicts(void) +{ + if (!AccReducers) + return; + + /* Temporary */ + xf86MsgVerb(X_WARNING, 3, + "Registering the following despite conflicts with estimated" + " resources:\n"); + xf86PrintResList(3, AccReducers); + Acc = xf86JoinResLists(Acc, AccReducers); + AccReducers = NULL; +} +#endif + +/* + * xf86ClaimFixedResources() -- This function gets called from the + * driver Probe() function to claim fixed resources. + */ +static void +resError(resList list) +{ + FatalError("A driver tried to allocate the %s %sresource at \n" + "0x%lx:0x%lx which conflicted with another resource. Send the\n" + "output of the server to %s. Please \n" + "specify your computer hardware as closely as possible.\n", + ResIsBlock(list)?"Block":"Sparse", + ResIsMem(list)?"Mem":"Io", + ResIsBlock(list)?list->rBegin:list->rBase, + ResIsBlock(list)?list->rEnd:list->rMask,BUILDERADDR); +} + +/* + * xf86ClaimFixedResources() is used to allocate non-relocatable resources. + * This should only be done by a driver's Probe() function. + */ +_X_EXPORT void +xf86ClaimFixedResources(resList list, int entityIndex) +{ + resPtr ptr = NULL; + resRange range; + + if (!list) return; + + while (list->type !=ResEnd) { + range = *list; + + convertRange2Host(entityIndex,&range); + + range.type &= ~ResEstimated; /* Not allowed for drivers */ + switch (range.type & ResAccMask) { + case ResExclusive: + if (!xf86ChkConflict(&range, entityIndex)) { + Acc = xf86AddResToList(Acc, &range, entityIndex); +#ifdef REDUCER + } else { + range.type |= ResEstimated; + if (!xf86ChkConflict(&range, entityIndex) && + !checkConflict(&range, AccReducers, entityIndex, + SETUP, FALSE)) { + range.type &= ~(ResEstimated | ResBios); + AccReducers = + xf86AddResToList(AccReducers, &range, entityIndex); +#endif + } else resError(&range); /* no return */ +#ifdef REDUCER + } +#endif + break; + case ResShared: + /* at this stage the resources are just added to the + * EntityRec. After the Probe() phase this list is checked by + * xf86PostProbe(). All resources which don't + * conflict with already allocated ones are allocated + * and removed from the EntityRec. Thus a non-empty resource + * list in the EntityRec indicates resource conflicts the + * driver should either handle or fail. + */ + if (xf86Entities[entityIndex]->active) + ptr = xf86AddResToList(ptr,&range,entityIndex); + break; + } + list++; + } + xf86Entities[entityIndex]->resources = + xf86JoinResLists(xf86Entities[entityIndex]->resources,ptr); + xf86MsgVerb(X_INFO, 3, + "resource ranges after xf86ClaimFixedResources() call:\n"); + xf86PrintResList(3,Acc); +#ifdef REDUCER + ProcessEstimatedConflicts(); +#endif +#ifdef DEBUG + if (ptr) { + xf86MsgVerb(X_INFO, 3, "to be registered later:\n"); + xf86PrintResList(3,ptr); + } +#endif +} + +static void +checkRoutingForScreens(xf86State state) +{ + resList list = resVgaUnusedExclusive; + resPtr pResVGA = NULL; + resPtr pResVGAHost; + pointer vga = NULL; + int i,j; + int entityIndex; + EntityPtr pEnt; + resPtr pAcc; + resRange range; + + /* + * find devices that need VGA routed: ie the ones that have + * registered VGA resources without ResUnused. ResUnused + * doesn't conflict with itself therefore use it here. + */ + while (list->type != ResEnd) { /* create resPtr from resList for VGA */ + range = *list; + range.type &= ~(ResBios | ResEstimated); /* if set remove them */ + pResVGA = xf86AddResToList(pResVGA, &range, -1); + list++; + } + + for (i = 0; i < xf86NumScreens; i++) { + for (j = 0; j < xf86Screens[i]->numEntities; j++) { + entityIndex = xf86Screens[i]->entityList[j]; + pEnt = xf86Entities[entityIndex]; + pAcc = Acc; + vga = NULL; + pResVGAHost = xf86DupResList(pResVGA); + xf86ConvertListToHost(entityIndex,pResVGAHost); + while (pAcc) { + if (pAcc->entityIndex == entityIndex) + if (checkConflict(&pAcc->val, pResVGAHost, + entityIndex, state, FALSE)) { + if (vga && vga != pEnt->busAcc) { + xf86Msg(X_ERROR, "Screen %i needs vga routed to" + "different buses - deleting\n",i); + xf86DeleteScreen(i--,0); + } +#ifdef DEBUG + { + resPtr rlist = xf86AddResToList(NULL,&pAcc->val, + pAcc->entityIndex); + xf86MsgVerb(X_INFO,3,"====== %s\n", + state == OPERATING ? "OPERATING" + : "SETUP"); + xf86MsgVerb(X_INFO,3,"%s Resource:\n", + (pAcc->val.type) & ResMem ? "Mem" :"Io"); + xf86PrintResList(3,rlist); + xf86FreeResList(rlist); + xf86MsgVerb(X_INFO,3,"Conflicts with:\n"); + xf86PrintResList(3,pResVGAHost); + xf86MsgVerb(X_INFO,3,"=====\n"); + } +#endif + vga = pEnt->busAcc; + pEnt->entityProp |= (state == SETUP + ? NEED_VGA_ROUTED_SETUP : NEED_VGA_ROUTED); + if (state == OPERATING) { + if (pAcc->val.type & ResMem) + pEnt->entityProp |= NEED_VGA_MEM; + else + pEnt->entityProp |= NEED_VGA_IO; + } + } + pAcc = pAcc->next; + } + if (vga) + xf86MsgVerb(X_INFO, 3,"Setting vga for screen %i.\n",i); + xf86FreeResList(pResVGAHost); + } + } + xf86FreeResList(pResVGA); +} + +/* + * xf86PostProbe() -- Allocate all non conflicting resources + * This function gets called by xf86Init(). + */ +void +xf86PostProbe(void) +{ + memType val; + int i,j; + resPtr resp, acc, tmp, resp_x, *pprev_next; + + if (fbSlotClaimed) { + if (pciSlotClaimed || isaSlotClaimed +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + || sbusSlotClaimed +#endif + ) { + FatalError("Cannot run in framebuffer mode. Please specify busIDs " + " for all framebuffer devices\n"); + return; + } else { + xf86Msg(X_INFO,"Running in FRAMEBUFFER Mode\n"); + xf86AccessRestoreState(); + notifyStateChange(NOTIFY_ENABLE); + doFramebufferMode = TRUE; + + return; + } + } + /* don't compare against ResInit - remove it from clone.*/ + acc = tmp = xf86DupResList(Acc); + pprev_next = &acc; + while (tmp) { + if (tmp->res_type & ResInit) { + (*pprev_next) = tmp->next; + xfree(tmp); + } else + pprev_next = &(tmp->next); + tmp = (*pprev_next); + } + + for (i=0; iresources; + xf86Entities[i]->resources = NULL; + resp_x = NULL; + while (resp) { + if (! (val = checkConflict(&resp->val,acc,i,SETUP,FALSE))) { + resp->res_type &= ~(ResBios); /* just used for chkConflict() */ + tmp = resp_x; + resp_x = resp; + resp = resp->next; + resp_x->next = tmp; +#ifdef REDUCER + } else { + resp->res_type |= ResEstimated; + if (!checkConflict(&resp->val, acc, i, SETUP, FALSE)) { + resp->res_type &= ~(ResEstimated | ResBios); + tmp = AccReducers; + AccReducers = resp; + resp = resp->next; + AccReducers->next = tmp; +#endif + } else { + xf86MsgVerb(X_INFO, 3, "Found conflict at: 0x%lx\n",val); + resp->res_type &= ~ResEstimated; + tmp = xf86Entities[i]->resources; + xf86Entities[i]->resources = resp; + resp = resp->next; + xf86Entities[i]->resources->next = tmp; + } +#ifdef REDUCER + } +#endif + } + xf86JoinResLists(Acc,resp_x); +#ifdef REDUCER + ProcessEstimatedConflicts(); +#endif + } + xf86FreeResList(acc); + + xf86MsgVerb(X_INFO, 3, "resource ranges after probing:\n"); + xf86PrintResList(3, Acc); + checkRoutingForScreens(SETUP); + + for (i = 0; i < xf86NumScreens; i++) { + for (j = 0; jnumEntities; j++) { + EntityPtr pEnt = xf86Entities[xf86Screens[i]->entityList[j]]; + if ((pEnt->entityProp & NEED_VGA_ROUTED_SETUP) && + ((xf86Screens[i]->busAccess = pEnt->busAcc))) + break; + } + } +} + +static void +checkRequiredResources(int entityIndex) +{ + resRange range; + resPtr pAcc = Acc; + const EntityPtr pEnt = xf86Entities[entityIndex]; + while (pAcc) { + if (pAcc->entityIndex == entityIndex) { + range = pAcc->val; + /* ResAny to find conflicts with anything. */ + range.type = (range.type & ~ResAccMask) | ResAny | ResBios; + if (checkConflict(&range,Acc,entityIndex,OPERATING,FALSE)) + switch (pAcc->res_type & ResPhysMask) { + case ResMem: + pEnt->entityProp |= NEED_MEM_SHARED; + break; + case ResIo: + pEnt->entityProp |= NEED_IO_SHARED; + break; + } + if (!(pAcc->res_type & ResOprMask)) { + switch (pAcc->res_type & ResPhysMask) { + case ResMem: + pEnt->entityProp |= NEED_MEM; + break; + case ResIo: + pEnt->entityProp |= NEED_IO; + break; + } + } + } + pAcc = pAcc->next; + } + + /* check if we can separately enable mem/io resources */ + /* XXX we still need to find out how to set this yet */ + if ( ((pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO) + && (pEnt->entityProp & NEED_MEM_SHARED)) + || ((pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM) + && (pEnt->entityProp & NEED_IO_SHARED)) ) + pEnt->entityProp |= NEED_SHARED; + /* + * After we have checked all resources of an entity agains any + * other resource we know if the entity need this resource type + * (ie. mem/io) at all. if not we can disable this type completely, + * so no need to share it either. + */ + if ((pEnt->entityProp & NEED_MEM_SHARED) + && (!(pEnt->entityProp & NEED_MEM)) + && (!(pEnt->entityProp & NO_SEPARATE_MEM_FROM_IO))) + pEnt->entityProp &= ~(unsigned long)NEED_MEM_SHARED; + + if ((pEnt->entityProp & NEED_IO_SHARED) + && (!(pEnt->entityProp & NEED_IO)) + && (!(pEnt->entityProp & NO_SEPARATE_IO_FROM_MEM))) + pEnt->entityProp &= ~(unsigned long)NEED_IO_SHARED; +} + +void +xf86PostPreInit() +{ + if (doFramebufferMode) return; + + if (xf86NumScreens > 1) + needRAC = TRUE; + + xf86MsgVerb(X_INFO, 3, "do I need RAC?"); + + if (needRAC) { + xf86ErrorFVerb(3, " Yes, I do.\n"); + } else { + xf86ErrorFVerb(3, " No, I don't.\n"); + } + + xf86MsgVerb(X_INFO, 3, "resource ranges after preInit:\n"); + xf86PrintResList(3, Acc); +} + +void +xf86PostScreenInit(void) +{ + int i,j; + ScreenPtr pScreen; + unsigned int flags; + int nummem = 0, numio = 0; + + if (doFramebufferMode) { + SetSIGIOForState(OPERATING); + return; + } + +#ifdef DEBUG + ErrorF("PostScreenInit generation: %i\n",serverGeneration); +#endif + if (serverGeneration == 1) { + checkRoutingForScreens(OPERATING); + for (i=0; ientityProp & NEED_MEM_SHARED) + nummem++; + if (xf86Entities[i]->entityProp & NEED_IO_SHARED) + numio++; + } + for (i = 0; i < xf86NumEntities; i++) { + if (nummem < 2) + xf86Entities[i]->entityProp &= ~NEED_MEM_SHARED; + if (numio < 2) + xf86Entities[i]->entityProp &= ~NEED_IO_SHARED; + } + } + + if (xf86Screens && needRAC) { + int needRACforVga = 0; + + for (i = 0; i < xf86NumScreens; i++) { + for (j = 0; j < xf86Screens[i]->numEntities; j++) { + if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp + & NEED_VGA_ROUTED) { + needRACforVga ++; + break; /* only count each screen once */ + } + } + } + + for (i = 0; i < xf86NumScreens; i++) { + Bool needRACforMem = FALSE, needRACforIo = FALSE; + + for (j = 0; j < xf86Screens[i]->numEntities; j++) { + if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp + & NEED_MEM_SHARED) + needRACforMem = TRUE; + if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp + & NEED_IO_SHARED) + needRACforIo = TRUE; + /* + * We may need RAC although we don't share any resources + * as we need to route VGA to the correct bus. This can + * only be done simultaniously for MEM and IO. + */ + if (needRACforVga > 1) { + if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp + & NEED_VGA_MEM) + needRACforMem = TRUE; + if (xf86Entities[xf86Screens[i]->entityList[j]]->entityProp + & NEED_VGA_IO) + needRACforIo = TRUE; + } + } + + pScreen = xf86Screens[i]->pScreen; + flags = 0; + if (needRACforMem) { + flags |= xf86Screens[i]->racMemFlags; + xf86ErrorFVerb(3, "Screen %d is using RAC for mem\n", i); + } + if (needRACforIo) { + flags |= xf86Screens[i]->racIoFlags; + xf86ErrorFVerb(3, "Screen %d is using RAC for io\n", i); + } + + xf86RACInit(pScreen,flags); + } + } + + xf86EnterServerState(OPERATING); + +} + +/* + * Sets + */ + + +static resPtr +decomposeSparse(resRange range) +{ + resRange new; + resPtr ret = NULL; + memType val = range.rBegin; + int i = 0; + + new.type = (range.type & ~ResExtMask) | ResSparse; + + while (1) { + if (val & 0x01) { + new.rBase = (val << i); + new.rMask = ~((1 << i) - 1); + ret = xf86AddResToList(ret,&new,-1); + val ++; + } + i++; + val >>= 1; + if ((((val + 1) << i) - 1) > range.rEnd) + break; + } + i--; + val <<= 1; + + while (1) { + if((((val + 1) << i) - 1)> range.rEnd) { + if (--i < 0) break; + val <<= 1; + } else { + new.rBase = (val << i); + new.rMask = ~((1 << i) - 1); + val++; + ret = xf86AddResToList(ret,&new,-1); + } + } + return ret; +} + +static Bool +x_isSubsetOf(resRange range, resPtr list1, resPtr list2) +{ + resRange range1, range2; + memType m1_A_m2; + Bool ret; + resPtr list; + + if (list1) { + list = list1; + if ((range.type & ResTypeMask) == (list->res_type & ResTypeMask)) { + switch (range.type & ResExtMask) { + case ResBlock: + if ((list->res_type & ResExtMask) == ResBlock) { + if (range.rBegin >= list->block_begin + && range.rEnd <= list->block_end) + return TRUE; + else if (range.rBegin < list->block_begin + && range.rEnd > list->block_end) { + RANGE(range1, range.rBegin, list->block_begin - 1, + range.type); + RANGE(range2, list->block_end + 1, range.rEnd, + range.type); + return (x_isSubsetOf(range1,list->next,list2) && + x_isSubsetOf(range2,list->next,list2)); + } + else if (range.rBegin >= list->block_begin + && range.rBegin <= list->block_end) { + RANGE(range1, list->block_end + 1, range.rEnd, + range.type); + return (x_isSubsetOf(range1,list->next,list2)); + } else if (range.rEnd >= list->block_begin + && range.rEnd <= list->block_end) { + RANGE(range1,range.rBegin, list->block_begin - 1, + range.type); + return (x_isSubsetOf(range1,list->next,list2)); + } + } + break; + case ResSparse: + if ((list->res_type & ResExtMask) == ResSparse) { + memType test; + int i; + + m1_A_m2 = range.rMask & list->sparse_mask; + if ((range.rBase ^ list->sparse_base) & m1_A_m2) + break; + /* + * We use the following system: + * let 0 ^= mask:1 base:0, 1 ^= mask:1 base:1, + * X mask:0 ; S: set TSS: test set for subset + * NTSS: new test set after test + * S: 1 0 1 0 X X 0 1 X + * TSS: 1 0 0 1 1 0 X X X + * T: 0 0 1 1 0 0 0 0 0 + * NTSS: 1 0 0/X 1/X 1 0 1 0 X + * R: 0 0 0 0 0 0 1 1 0 + * If R != 0 TSS and S are disjunct + * If R == 0 TSS is subset of S + * If R != 0 NTSS contains elements from TSS + * which are not also members of S. + * If a T is set one of the correspondig bits + * in NTSS must be set to the specified value + * all other are X + */ + test = list->sparse_mask & ~range.rMask; + if (test == 0) + return TRUE; + for (i = 0; i < sizeof(memType); i++) { + if ((test >> i) & 0x1) { + RANGE(range1, ((range.rBase & list->sparse_base) + | (range.rBase & ~list->sparse_mask) + | ((~list->sparse_base & list->sparse_mask) + & ~range.rMask)) & range1.rMask, + ((range.rMask | list->sparse_mask) & ~test) + | (1 << i), range.type); + return (x_isSubsetOf(range1,list->next,list2)); + } + } + } + break; + } + } + return (x_isSubsetOf(range,list->next,list2)); + } else if (list2) { + resPtr tmpList = NULL; + switch (range.type & ResExtMask) { + case ResBlock: + tmpList = decomposeSparse(range); + while (tmpList) { + if (!x_isSubsetOf(tmpList->val,list2,NULL)) { + xf86FreeResList(tmpList); + return FALSE; + } + tmpList = tmpList->next; + } + xf86FreeResList(tmpList); + return TRUE; + break; + case ResSparse: + while (list2) { + tmpList = xf86JoinResLists(tmpList,decomposeSparse(list2->val)); + list2 = list2->next; + } + ret = x_isSubsetOf(range,tmpList,NULL); + xf86FreeResList(tmpList); + return ret; + break; + } + } else + return FALSE; + + return FALSE; +} + +Bool +xf86IsSubsetOf(resRange range, resPtr list) +{ + resPtr dup = xf86DupResList(list); + resPtr r_sp = NULL, r = NULL, tmp = NULL; + Bool ret = FALSE; + + while (dup) { + tmp = dup; + dup = dup->next; + switch (tmp->res_type & ResExtMask) { + case ResBlock: + tmp->next = r; + r = tmp; + break; + case ResSparse: + tmp->next = r_sp; + r_sp = tmp; + break; + } + } + + switch (range.type & ResExtMask) { + case ResBlock: + ret = x_isSubsetOf(range,r,r_sp); + break; + case ResSparse: + ret = x_isSubsetOf(range,r_sp,r); + break; + } + xf86FreeResList(r); + xf86FreeResList(r_sp); + + return ret; +} + +static resPtr +findIntersect(resRange Range, resPtr list) +{ + resRange range; + resPtr new = NULL; + + while (list) { + if ((Range.type & ResTypeMask) == (list->res_type & ResTypeMask)) { + switch (Range.type & ResExtMask) { + case ResBlock: + switch (list->res_type & ResExtMask) { + case ResBlock: + if (Range.rBegin >= list->block_begin) + range.rBegin = Range.rBegin; + else + range.rBegin = list->block_begin; + if (Range.rEnd <= list->block_end) + range.rEnd = Range.rEnd; + else + range.rEnd = list->block_end; + if (range.rEnd > range.rBegin) { + range.type = Range.type; + new = xf86AddResToList(new,&range,-1); + } + break; + case ResSparse: + new = xf86JoinResLists(new,xf86FindIntersectOfLists(new,decomposeSparse(list->val))); + break; + } + break; + case ResSparse: + switch (list->res_type & ResExtMask) { + case ResSparse: + if (!((~(range.rBase ^ list->sparse_base) + & (range.rMask & list->sparse_mask)))) { + RANGE(range, (range.rBase & list->sparse_base) + | (~range.rMask & list->sparse_base) + | (~list->sparse_mask & range.rBase), + range.rMask | list->sparse_mask, + Range.type); + new = xf86AddResToList(new,&range,-1); + } + break; + case ResBlock: + new = xf86JoinResLists(new,xf86FindIntersectOfLists( + decomposeSparse(range),list)); + break; + } + } + } + list = list->next; + } + return new; +} + +resPtr +xf86FindIntersectOfLists(resPtr l1, resPtr l2) +{ + resPtr ret = NULL; + + while (l1) { + ret = xf86JoinResLists(ret,findIntersect(l1->val,l2)); + l1 = l1->next; + } + return ret; +} + +#if 0 /* Not used */ +static resPtr +xf86FindComplement(resRange Range) +{ + resRange range; + memType tmp; + resPtr new = NULL; + int i; + + switch (Range.type & ResExtMask) { + case ResBlock: + if (Range.rBegin > 0) { + RANGE(range, 0, Range.rBegin - 1, Range.type); + new = xf86AddResToList(new,&range,-1); + } + if (Range.rEnd < (memType)~0) { + RANGE(range,Range.rEnd + 1, (memType)~0, Range.type); + new = xf86AddResToList(new,&range,-1); + } + break; + case ResSparse: + tmp = Range.rMask; + for (i = 0; i < sizeof(memType); i++) { + if (tmp & 0x1) { + RANGE(range,(~Range.rMask & range.rMask),(1 << i), Range.type); + new = xf86AddResToList(new,&range,-1); + } + } + break; + default: + break; + } + return new; +} +#endif + +resPtr +xf86ExtractTypeFromList(resPtr list, unsigned long type) +{ + resPtr ret = NULL; + + while (list) { + if ((list->res_type & ResTypeMask) == type) + ret = xf86AddResToList(ret,&(list->val),list->entityIndex); + list = list->next; + } + return ret; +} + +/*------------------------------------------------------------*/ +static void CheckGenericGA(void); + +/* + * xf86FindPrimaryDevice() - Find the display device which + * was active when the server was started. + */ +void +xf86FindPrimaryDevice() +{ + /* if no VGA device is found check for primary PCI device */ + if (primaryBus.type == BUS_NONE && xorgHWAccess) + CheckGenericGA(); + if (primaryBus.type != BUS_NONE) { + char *bus; + char loc[16]; + + switch (primaryBus.type) { + case BUS_PCI: + bus = "PCI"; + snprintf(loc, sizeof(loc), " %2.2x@%2.2x:%2.2x:%1.1x", + primaryBus.id.pci->bus, + primaryBus.id.pci->domain, + primaryBus.id.pci->dev, + primaryBus.id.pci->func); + break; + case BUS_ISA: + bus = "ISA"; + loc[0] = '\0'; + break; + case BUS_SBUS: + bus = "SBUS"; + snprintf(loc, sizeof(loc), " %2.2x", primaryBus.id.sbus.fbNum); + break; + default: + bus = ""; + loc[0] = '\0'; + } + + xf86MsgVerb(X_INFO, 2, "Primary Device is: %s%s\n",bus,loc); + } +} + +#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__arm__) +#include "vgaHW.h" +#include "compiler.h" +#endif + +/* + * CheckGenericGA() - Check for presence of a VGA device. + */ +static void +CheckGenericGA() +{ +/* This needs to be changed for multiple domains */ +#if !defined(__sparc__) && !defined(__sparc) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__) + IOADDRESS GenericIOBase = VGAHW_GET_IOBASE(); + CARD8 CurrentValue, TestValue; + + /* VGA CRTC registers are not used here, so don't bother unlocking them */ + + /* VGA has one more read/write attribute register than EGA */ + (void) inb(GenericIOBase + VGA_IN_STAT_1_OFFSET); /* Reset flip-flop */ + outb(VGA_ATTR_INDEX, 0x14 | 0x20); + CurrentValue = inb(VGA_ATTR_DATA_R); + outb(VGA_ATTR_DATA_W, CurrentValue ^ 0x0F); + outb(VGA_ATTR_INDEX, 0x14 | 0x20); + TestValue = inb(VGA_ATTR_DATA_R); + outb(VGA_ATTR_DATA_W, CurrentValue); + + if ((CurrentValue ^ 0x0F) == TestValue) { + primaryBus.type = BUS_ISA; + } +#endif +} + +_X_EXPORT Bool +xf86NoSharedResources(int screenIndex,resType res) +{ + int j; + + if (screenIndex > xf86NumScreens) + return TRUE; + + for (j = 0; j < xf86Screens[screenIndex]->numEntities; j++) { + switch (res) { + case IO: + if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp + & NEED_IO_SHARED) + return FALSE; + break; + case MEM: + if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp + & NEED_MEM_SHARED) + return FALSE; + break; + case MEM_IO: + if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp + & NEED_SHARED) + return FALSE; + break; + case NONE: + break; + } + } + return TRUE; +} + +_X_EXPORT void +xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg) +{ + StateChangeNotificationPtr ptr = + (StateChangeNotificationPtr)xnfalloc(sizeof(StateChangeNotificationRec)); + + ptr->func = func; + ptr->arg = arg; + ptr->next = StateChangeNotificationList; + StateChangeNotificationList = ptr; +} + +_X_EXPORT Bool +xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func) +{ + StateChangeNotificationPtr *ptr = &StateChangeNotificationList; + StateChangeNotificationPtr tmp; + + while (*ptr) { + if ((*ptr)->func == func) { + tmp = (*ptr); + (*ptr) = (*ptr)->next; + xfree(tmp); + return TRUE; + } + ptr = &((*ptr)->next); + } + return FALSE; +} + +static void +notifyStateChange(xf86NotifyState state) +{ + StateChangeNotificationPtr ptr = StateChangeNotificationList; + while (ptr) { + ptr->func(state,ptr->arg); + ptr = ptr->next; + } +} + +/* Multihead accel sharing accessor functions and entity Private handling */ + +_X_EXPORT int +xf86GetLastScrnFlag(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + return(xf86Entities[entityIndex]->lastScrnFlag); + } else { + return -1; + } +} + +_X_EXPORT void +xf86SetLastScrnFlag(int entityIndex, int scrnIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->lastScrnFlag = scrnIndex; + } +} + +_X_EXPORT Bool +xf86IsEntityShared(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) { + return TRUE; + } + } + return FALSE; +} + +_X_EXPORT void +xf86SetEntityShared(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL; + } +} + +_X_EXPORT Bool +xf86IsEntitySharable(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) { + return TRUE; + } + } + return FALSE; +} + +_X_EXPORT void +xf86SetEntitySharable(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE; + } +} + +_X_EXPORT Bool +xf86IsPrimInitDone(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) { + return TRUE; + } + } + return FALSE; +} + +_X_EXPORT void +xf86SetPrimInitDone(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE; + } +} + +_X_EXPORT void +xf86ClearPrimInitDone(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE; + } +} + + +/* + * Allocate a private in the entities. + */ + +_X_EXPORT int +xf86AllocateEntityPrivateIndex(void) +{ + int idx, i; + EntityPtr pEnt; + DevUnion *nprivs; + + idx = xf86EntityPrivateCount++; + for (i = 0; i < xf86NumEntities; i++) { + pEnt = xf86Entities[i]; + nprivs = xnfrealloc(pEnt->entityPrivates, + xf86EntityPrivateCount * sizeof(DevUnion)); + /* Zero the new private */ + bzero(&nprivs[idx], sizeof(DevUnion)); + pEnt->entityPrivates = nprivs; + } + return idx; +} + +_X_EXPORT DevUnion * +xf86GetEntityPrivate(int entityIndex, int privIndex) +{ + if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount) + return NULL; + + return &(xf86Entities[entityIndex]->entityPrivates[privIndex]); +} + diff --git a/xorg-server/hw/xfree86/common/xf86Bus.h b/xorg-server/hw/xfree86/common/xf86Bus.h new file mode 100644 index 000000000..489ee3459 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Bus.h @@ -0,0 +1,147 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains definitions of the bus-related data structures/types. + * Everything contained here is private to xf86Bus.c. In particular the + * video drivers must not include this file. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef _XF86_BUS_H +#define _XF86_BUS_H + +#include "xf86pciBus.h" +#if defined(__sparc__) || defined(__sparc) +#include "xf86sbusBus.h" +#endif + +typedef struct racInfo { + xf86AccessPtr mem_new; + xf86AccessPtr io_new; + xf86AccessPtr io_mem_new; + xf86SetAccessFuncPtr old; +} AccessFuncRec, *AccessFuncPtr; + + +typedef struct { + DriverPtr driver; + int chipset; + int entityProp; + EntityProc entityInit; + EntityProc entityEnter; + EntityProc entityLeave; + pointer private; + resPtr resources; + Bool active; + Bool inUse; + BusRec bus; + EntityAccessPtr access; + AccessFuncPtr rac; + pointer busAcc; + int lastScrnFlag; + DevUnion * entityPrivates; + int numInstances; + GDevPtr * devices; + IOADDRESS domainIO; +} EntityRec, *EntityPtr; + +#define NO_SEPARATE_IO_FROM_MEM 0x0001 +#define NO_SEPARATE_MEM_FROM_IO 0x0002 +#define NEED_VGA_ROUTED 0x0004 +#define NEED_VGA_ROUTED_SETUP 0x0008 +#define NEED_MEM 0x0010 +#define NEED_IO 0x0020 +#define NEED_MEM_SHARED 0x0040 +#define NEED_IO_SHARED 0x0080 +#define ACCEL_IS_SHARABLE 0x0100 +#define IS_SHARED_ACCEL 0x0200 +#define SA_PRIM_INIT_DONE 0x0400 +#define NEED_VGA_MEM 0x1000 +#define NEED_VGA_IO 0x2000 + +#define NEED_SHARED (NEED_MEM_SHARED | NEED_IO_SHARED) + +#define busType bus.type +#define isaBusId bus.id.isa +#define sbusBusId bus.id.sbus + +struct x_BusAccRec; +typedef void (*BusAccProcPtr)(struct x_BusAccRec *ptr); + +typedef struct x_BusAccRec { + BusAccProcPtr set_f; + BusAccProcPtr enable_f; + BusAccProcPtr disable_f; + BusAccProcPtr save_f; + BusAccProcPtr restore_f; + struct x_BusAccRec *current; /* pointer to bridge open on this bus */ + struct x_BusAccRec *primary; /* pointer to the bus connecting to this */ + struct x_BusAccRec *next; /* this links the different buses together */ + BusType type; + BusType busdep_type; + /* Bus-specific fields */ + union { + struct { + int bus; + int primary_bus; + struct pci_device * dev; + pciBridgesSave save; + } pci; + } busdep; +} BusAccRec, *BusAccPtr; + +/* state change notification callback */ +typedef struct _stateChange { + xf86StateChangeNotificationCallbackFunc func; + pointer arg; + struct _stateChange *next; +} StateChangeNotificationRec, *StateChangeNotificationPtr; + + +extern EntityPtr *xf86Entities; +extern int xf86NumEntities; +extern xf86AccessRec AccessNULL; +extern BusRec primaryBus; +extern resPtr Acc; +extern resPtr ResRange; +extern BusAccPtr xf86BusAccInfo; + +int xf86AllocateEntity(void); +BusType StringToBusType(const char* busID, const char **retID); +memType ChkConflict(resRange *rgp, resPtr res, xf86State state); +Bool xf86IsSubsetOf(resRange range, resPtr list); +resPtr xf86ExtractTypeFromList(resPtr list, unsigned long type); +resPtr xf86FindIntersect(resRange Range, resPtr list); +void RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment, + Bool useEstimated); + +#endif /* _XF86_BUS_H */ diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c new file mode 100644 index 000000000..e91eadd19 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Config.c @@ -0,0 +1,2673 @@ +/* + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + */ + +/* + * Copyright 1992-2003 by The XFree86 Project, Inc. + * Copyright 1997 by Metro Link, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * + * Authors: + * Dirk Hohndel + * David Dawes + * Marc La France + * Egbert Eich + * ... and others + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifdef XF86DRI +#include +#include +#endif + +#include "xf86.h" +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "xf86Config.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "configProcs.h" +#include "globals.h" +#include "extension.h" +#include "Pci.h" + +#ifdef XINPUT +#include "xf86Xinput.h" +extern DeviceAssocRec mouse_assoc; +#endif + +#ifdef XKB +#undef XKB_IN_SERVER +#define XKB_IN_SERVER +#include +#endif + +#ifdef RENDER +#include "picture.h" +#endif + +#if (defined(__i386__)) && \ + (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || defined(linux) || \ + (defined(SVR4) && !defined(sun)) || defined(__GNU__)) +#define SUPPORT_PC98 +#endif + +/* + * These paths define the way the config file search is done. The escape + * sequences are documented in parser/scan.c. + */ +#ifndef ROOT_CONFIGPATH +#define ROOT_CONFIGPATH "%A," "%R," \ + "/etc/X11/%R," "%P/etc/X11/%R," \ + "%E," "%F," \ + "/etc/X11/%F," "%P/etc/X11/%F," \ + "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" +#endif +#ifndef USER_CONFIGPATH +#define USER_CONFIGPATH "/etc/X11/%S," "%P/etc/X11/%S," \ + "/etc/X11/%G," "%P/etc/X11/%G," \ + "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" +#endif +#ifndef PROJECTROOT +#define PROJECTROOT "/usr/X11R6" +#endif + +static char *fontPath = NULL; + +static ModuleDefault ModuleDefaults[] = { + {.name = "extmod", .toLoad = TRUE, .load_opt=NULL}, + {.name = "dbe", .toLoad = TRUE, .load_opt=NULL}, + {.name = "glx", .toLoad = TRUE, .load_opt=NULL}, + {.name = "freetype", .toLoad = TRUE, .load_opt=NULL}, +#ifdef XRECORD + {.name = "record", .toLoad = TRUE, .load_opt=NULL}, +#endif + {.name = "dri", .toLoad = TRUE, .load_opt=NULL}, +#ifdef DRI2 + {.name = "dri2", .toLoad = TRUE, .load_opt=NULL}, +#endif + {.name = NULL, .toLoad = FALSE, .load_opt=NULL} +}; + + +/* Forward declarations */ +static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, + int scrnum, MessageType from); +static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor); +static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, + Bool active); +static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, + MessageType from); +static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display); +static Bool addDefaultModes(MonPtr monitorp); +#ifdef XF86DRI +static void configDRI(XF86ConfDRIPtr drip); +#endif +static void configExtensions(XF86ConfExtensionsPtr conf_ext); + +/* + * xf86GetPathElem -- + * Extract a single element from the font path string starting at + * pnt. The font path element will be returned, and pnt will be + * updated to point to the start of the next element, or set to + * NULL if there are no more. + */ +static char * +xf86GetPathElem(char **pnt) +{ + char *p1; + + p1 = *pnt; + *pnt = index(*pnt, ','); + if (*pnt != NULL) { + **pnt = '\0'; + *pnt += 1; + } + return(p1); +} + +/* + * xf86ValidateFontPath -- + * Validates the user-specified font path. Each element that + * begins with a '/' is checked to make sure the directory exists. + * If the directory exists, the existence of a file named 'fonts.dir' + * is checked. If either check fails, an error is printed and the + * element is removed from the font path. + */ + +#define DIR_FILE "/fonts.dir" +static char * +xf86ValidateFontPath(char *path) +{ + char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem; + struct stat stat_buf; + int flag; + int dirlen; + + tmp_path = xcalloc(1,strlen(path)+1); + out_pnt = tmp_path; + path_elem = NULL; + next = path; + while (next != NULL) { + path_elem = xf86GetPathElem(&next); + if (*path_elem == '/') { + dir_elem = xnfcalloc(1, strlen(path_elem) + 1); + if ((p1 = strchr(path_elem, ':')) != 0) + dirlen = p1 - path_elem; + else + dirlen = strlen(path_elem); + strncpy(dir_elem, path_elem, dirlen); + dir_elem[dirlen] = '\0'; + flag = stat(dir_elem, &stat_buf); + if (flag == 0) + if (!S_ISDIR(stat_buf.st_mode)) + flag = -1; + if (flag != 0) { + xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem); + xf86ErrorF("\tEntry deleted from font path.\n"); + xfree(dir_elem); + continue; + } + else { + p1 = xnfalloc(strlen(dir_elem)+strlen(DIR_FILE)+1); + strcpy(p1, dir_elem); + strcat(p1, DIR_FILE); + flag = stat(p1, &stat_buf); + if (flag == 0) + if (!S_ISREG(stat_buf.st_mode)) + flag = -1; + xfree(p1); + if (flag != 0) { + xf86Msg(X_WARNING, + "`fonts.dir' not found (or not valid) in \"%s\".\n", + dir_elem); + xf86ErrorF("\tEntry deleted from font path.\n"); + xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem); + xfree(dir_elem); + continue; + } + } + xfree(dir_elem); + } + + /* + * Either an OK directory, or a font server name. So add it to + * the path. + */ + if (out_pnt != tmp_path) + *out_pnt++ = ','; + strcat(out_pnt, path_elem); + out_pnt += strlen(path_elem); + } + return(tmp_path); +} + + +/* + * use the datastructure that the parser provides and pick out the parts + * that we need at this point + */ +char ** +xf86ModulelistFromConfig(pointer **optlist) +{ + int count = 0, i = 0; + char **modulearray; + char *ignore[] = { "GLcore", "speedo", "bitmap", "drm", NULL }; + pointer *optarray; + XF86LoadPtr modp; + Bool found; + + /* + * make sure the config file has been parsed and that we have a + * ModulePath set; if no ModulePath was given, use the default + * ModulePath + */ + if (xf86configptr == NULL) { + xf86Msg(X_ERROR, "Cannot access global config data structure\n"); + return NULL; + } + + if (xf86configptr->conf_modules) { + /* Walk the disable list and let people know what we've parsed to + * not be loaded + */ + modp = xf86configptr->conf_modules->mod_disable_lst; + while (modp) { + xf86Msg(X_WARNING, "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n", modp->load_name); + modp = (XF86LoadPtr) modp->list.next; + } + /* + * Walk the default settings table. For each module listed to be + * loaded, make sure it's in the mod_load_lst. If it's not, make + * sure it's not in the mod_no_load_lst. If it's not disabled, + * append it to mod_load_lst + */ + for (i=0 ; ModuleDefaults[i].name != NULL ; i++) { + if (ModuleDefaults[i].toLoad == FALSE) { + xf86Msg(X_WARNING, "\"%s\" is not to be loaded by default. Skipping.\n", ModuleDefaults[i].name); + continue; + } + found = FALSE; + modp = xf86configptr->conf_modules->mod_load_lst; + while (modp) { + if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) { + xf86Msg(X_INFO, "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n", ModuleDefaults[i].name); + found = TRUE; + break; + } + modp = (XF86LoadPtr) modp->list.next; + } + if (found == FALSE) { + modp = xf86configptr->conf_modules->mod_disable_lst; + while (modp) { + if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) { + xf86Msg(X_INFO, "\"%s\" will be loaded even though the default is to disable it.\n", ModuleDefaults[i].name); + found = TRUE; + break; + } + modp = (XF86LoadPtr) modp->list.next; + } + } + if (found == FALSE) { + XF86ConfModulePtr ptr = xf86configptr->conf_modules; + ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt); + xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n", ModuleDefaults[i].name); + } + } + } else { + xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec)); + for (i=0 ; ModuleDefaults[i].name != NULL ; i++) { + if (ModuleDefaults[i].toLoad == TRUE) { + XF86ConfModulePtr ptr = xf86configptr->conf_modules; + ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt); + } + } + } + + /* + * Walk the list of modules in the "Module" section to determine how + * many we have. + */ + modp = xf86configptr->conf_modules->mod_load_lst; + while (modp) { + for (i = 0; ignore[i]; i++) { + if (strcmp(modp->load_name, ignore[i]) == 0) + modp->ignore = 1; + } + if (!modp->ignore) + count++; + modp = (XF86LoadPtr) modp->list.next; + } + + /* + * allocate the memory and walk the list again to fill in the pointers + */ + modulearray = xnfalloc((count + 1) * sizeof(char*)); + optarray = xnfalloc((count + 1) * sizeof(pointer)); + count = 0; + if (xf86configptr->conf_modules) { + modp = xf86configptr->conf_modules->mod_load_lst; + while (modp) { + if (!modp->ignore) { + modulearray[count] = modp->load_name; + optarray[count] = modp->load_opt; + count++; + } + modp = (XF86LoadPtr) modp->list.next; + } + } + modulearray[count] = NULL; + optarray[count] = NULL; + if (optlist) + *optlist = optarray; + else + xfree(optarray); + return modulearray; +} + + +char ** +xf86DriverlistFromConfig() +{ + int count = 0; + int j; + char **modulearray; + screenLayoutPtr slp; + + /* + * make sure the config file has been parsed and that we have a + * ModulePath set; if no ModulePath was given, use the default + * ModulePath + */ + if (xf86configptr == NULL) { + xf86Msg(X_ERROR, "Cannot access global config data structure\n"); + return NULL; + } + + /* + * Walk the list of driver lines in active "Device" sections to + * determine now many implicitly loaded modules there are. + * + */ + if (xf86ConfigLayout.screens) { + slp = xf86ConfigLayout.screens; + while ((slp++)->screen) { + count++; + } + } + + /* + * Handle the set of inactive "Device" sections. + */ + j = 0; + while (xf86ConfigLayout.inactives[j++].identifier) + count++; + + if (count == 0) + return NULL; + + /* + * allocate the memory and walk the list again to fill in the pointers + */ + modulearray = xnfalloc((count + 1) * sizeof(char*)); + count = 0; + slp = xf86ConfigLayout.screens; + while (slp->screen) { + modulearray[count] = slp->screen->device->driver; + count++; + slp++; + } + + j = 0; + + while (xf86ConfigLayout.inactives[j].identifier) + modulearray[count++] = xf86ConfigLayout.inactives[j++].driver; + + modulearray[count] = NULL; + + /* Remove duplicates */ + for (count = 0; modulearray[count] != NULL; count++) { + int i; + + for (i = 0; i < count; i++) + if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) { + modulearray[count] = ""; + break; + } + } + return modulearray; +} + +char ** +xf86InputDriverlistFromConfig() +{ + int count = 0; + char **modulearray; + IDevPtr* idp; + + /* + * make sure the config file has been parsed and that we have a + * ModulePath set; if no ModulePath was given, use the default + * ModulePath + */ + if (xf86configptr == NULL) { + xf86Msg(X_ERROR, "Cannot access global config data structure\n"); + return NULL; + } + + /* + * Walk the list of driver lines in active "InputDevice" sections to + * determine now many implicitly loaded modules there are. + */ + if (xf86ConfigLayout.inputs) { + idp = xf86ConfigLayout.inputs; + while (*idp) { + count++; + idp++; + } + } + + if (count == 0) + return NULL; + + /* + * allocate the memory and walk the list again to fill in the pointers + */ + modulearray = xnfalloc((count + 1) * sizeof(char*)); + count = 0; + idp = xf86ConfigLayout.inputs; + while (idp && *idp) { + modulearray[count] = (*idp)->driver; + count++; + idp++; + } + modulearray[count] = NULL; + + /* Remove duplicates */ + for (count = 0; modulearray[count] != NULL; count++) { + int i; + + for (i = 0; i < count; i++) + if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) { + modulearray[count] = ""; + break; + } + } + return modulearray; +} + +static void +fixup_video_driver_list(char **drivers) +{ + static const char *fallback[4] = { "vesa", "fbdev", "wsfb", NULL }; + char **end, **drv; + char *x; + char **ati, **atimisc; + int i; + + /* walk to the end of the list */ + for (end = drivers; *end && **end; end++) ; + end--; + + /* + * for each of the fallback drivers, if we find it in the list, + * swap it with the last available non-fallback driver. + */ + for (i = 0; fallback[i]; i++) { + for (drv = drivers; drv != end; drv++) { + if (strstr(*drv, fallback[i])) { + x = *drv; *drv = *end; *end = x; + end--; + break; + } + } + } + /* + * since the ati wrapper driver is gross and awful, sort ati before + * atimisc, which makes sure all the ati symbols are visible in xorgcfg. + */ + for (drv = drivers; drv != end; drv++) { + if (!strcmp(*drv, "atimisc")) { + atimisc = drv; + for (drv = atimisc; drv != end; drv++) { + if (!strcmp(*drv, "ati")) { + ati = drv; + x = *ati; *ati = *atimisc; *atimisc = x; + return; + } + } + /* if we get here, ati was already ahead of atimisc */ + return; + } + } +} + +static char ** +GenerateDriverlist(char * dirname) +{ + char **ret; + const char *subdirs[] = { dirname, NULL }; + static const char *patlist[] = {"(.*)_drv\\.so", "(.*)_drv\\.o", NULL}; + ret = LoaderListDirs(subdirs, patlist); + + /* fix up the probe order for video drivers */ + if (strstr(dirname, "drivers") && ret != NULL) + fixup_video_driver_list(ret); + + return ret; +} + +char ** +xf86DriverlistFromCompile(void) +{ + static char **driverlist = NULL; + + if (!driverlist) + driverlist = GenerateDriverlist("drivers"); + + return driverlist; +} + +/* + * xf86ConfigError -- + * Print a READABLE ErrorMessage!!! All information that is + * available is printed. + */ +static void +xf86ConfigError(char *msg, ...) +{ + va_list ap; + + ErrorF("\nConfig Error:\n"); + va_start(ap, msg); + VErrorF(msg, ap); + va_end(ap); + ErrorF("\n"); + return; +} + +static void +configFiles(XF86ConfFilesPtr fileconf) +{ + MessageType pathFrom = X_DEFAULT; + int countDirs; + char *temp_path; + char *log_buf; + + /* FontPath */ + /* Try XF86Config FontPath first */ + if (!xf86fpFlag) { + if (fileconf) { + if (fileconf->file_fontpath) { + char *f = xf86ValidateFontPath(fileconf->file_fontpath); + pathFrom = X_CONFIG; + if (*f) { + if (xf86Info.useDefaultFontPath) { + xf86Msg(X_DEFAULT, "Including the default font path %s.\n", defaultFontPath); + char *g = xnfalloc(strlen(defaultFontPath) + strlen(f) + 3); + strcpy(g, f); + strcat(g, ","); + defaultFontPath = strcat(g, defaultFontPath); + xfree(f); + } else { + defaultFontPath = f; + } + } else { + xf86Msg(X_WARNING, + "FontPath is completely invalid. Using compiled-in default.\n"); + fontPath = NULL; + pathFrom = X_DEFAULT; + } + } + } else { + xf86Msg(X_DEFAULT, + "No FontPath specified. Using compiled-in default.\n"); + pathFrom = X_DEFAULT; + } + } else { + /* Use fontpath specified with '-fp' */ + if (fontPath) + { + fontPath = NULL; + } + pathFrom = X_CMDLINE; + } + if (!fileconf) { + /* xf86ValidateFontPath will write into it's arg, but defaultFontPath + could be static, so we make a copy. */ + char *f = xnfalloc(strlen(defaultFontPath) + 1); + f[0] = '\0'; + strcpy (f, defaultFontPath); + defaultFontPath = xf86ValidateFontPath(f); + xfree(f); + } else { + if (fileconf) { + if (!fileconf->file_fontpath) { + /* xf86ValidateFontPath will write into it's arg, but defaultFontPath + could be static, so we make a copy. */ + char *f = xnfalloc(strlen(defaultFontPath) + 1); + f[0] = '\0'; + strcpy (f, defaultFontPath); + defaultFontPath = xf86ValidateFontPath(f); + xfree(f); + } + } + } + + /* If defaultFontPath is still empty, exit here */ + + if (! *defaultFontPath) + FatalError("No valid FontPath could be found."); + + /* make fontpath more readable in the logfiles */ + countDirs = 1; + temp_path = defaultFontPath; + while((temp_path = index(temp_path, ',')) != NULL) { + countDirs++; + temp_path++; + } + log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1); + if(!log_buf) /* fallback to old method */ + xf86Msg(pathFrom, "FontPath set to \"%s\"\n", defaultFontPath); + else { + char *start, *end; + int size; + temp_path = log_buf; + start = defaultFontPath; + while((end = index(start, ',')) != NULL) { + size = (end - start) + 1; + *(temp_path++) = '\t'; + strncpy(temp_path, start, size); + temp_path += size; + *(temp_path++) = '\n'; + start += size; + } + /* copy last entry */ + *(temp_path++) = '\t'; + strcpy(temp_path, start); + xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf); + xfree(log_buf); + } + + + if (fileconf && fileconf->file_inputdevs) { + xf86InputDeviceList = fileconf->file_inputdevs; + xf86Msg(X_CONFIG, "Input device list set to \"%s\"\n", + xf86InputDeviceList); + } + + + /* ModulePath */ + + if (fileconf) { + if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) { + xf86ModulePath = fileconf->file_modulepath; + xf86ModPathFrom = X_CONFIG; + } + } + + xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath); + +#if 0 + /* LogFile */ + /* + * XXX The problem with this is that the log file is already open. + * One option might be to copy the exiting contents to the new location. + * and re-open it. The down side is that the default location would + * already have been overwritten. Another option would be to start with + * unique temporary location, then copy it once the correct name is known. + * A problem with this is what happens if the server exits before that + * happens. + */ + if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) { + xf86LogFile = fileconf->file_logfile; + xf86LogFileFrom = X_CONFIG; + } +#endif + + return; +} + +typedef enum { + FLAG_NOTRAPSIGNALS, + FLAG_DONTVTSWITCH, + FLAG_DONTZAP, + FLAG_DONTZOOM, + FLAG_DISABLEVIDMODE, + FLAG_ALLOWNONLOCAL, + FLAG_DISABLEMODINDEV, + FLAG_MODINDEVALLOWNONLOCAL, + FLAG_ALLOWMOUSEOPENFAIL, + FLAG_VTSYSREQ, + FLAG_XKBDISABLE, + FLAG_PCIPROBE1, + FLAG_PCIPROBE2, + FLAG_PCIFORCECONFIG1, + FLAG_PCIFORCECONFIG2, + FLAG_PCIFORCENONE, + FLAG_PCIOSCONFIG, + FLAG_SAVER_BLANKTIME, + FLAG_DPMS_STANDBYTIME, + FLAG_DPMS_SUSPENDTIME, + FLAG_DPMS_OFFTIME, + FLAG_PIXMAP, + FLAG_PC98, + FLAG_ESTIMATE_SIZES_AGGRESSIVELY, + FLAG_NOPM, + FLAG_XINERAMA, + FLAG_ALLOW_DEACTIVATE_GRABS, + FLAG_ALLOW_CLOSEDOWN_GRABS, + FLAG_LOG, + FLAG_RENDER_COLORMAP_MODE, + FLAG_HANDLE_SPECIAL_KEYS, + FLAG_RANDR, + FLAG_AIGLX, + FLAG_IGNORE_ABI, + FLAG_ALLOW_EMPTY_INPUT, + FLAG_USE_DEFAULT_FONT_PATH, + FLAG_AUTO_ADD_DEVICES, + FLAG_AUTO_ENABLE_DEVICES, + FLAG_GLX_VISUALS, + FLAG_DRI2, +} FlagValues; + +static OptionInfoRec FlagOptions[] = { + { FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_DISABLEMODINDEV, "DisableModInDev", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_MODINDEVALLOWNONLOCAL, "AllowNonLocalModInDev", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_XKBDISABLE, "XkbDisable", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_PCIPROBE1, "PciProbe1" , OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_PCIPROBE2, "PciProbe2", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_PCIFORCECONFIG1, "PciForceConfig1", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_PCIFORCECONFIG2, "PciForceConfig2", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_PCIFORCENONE, "PciForceNone", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_PCIOSCONFIG, "PciOsConfig", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_SAVER_BLANKTIME, "BlankTime" , OPTV_INTEGER, + {0}, FALSE }, + { FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER, + {0}, FALSE }, + { FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER, + {0}, FALSE }, + { FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER, + {0}, FALSE }, + { FLAG_PIXMAP, "Pixmap", OPTV_INTEGER, + {0}, FALSE }, + { FLAG_PC98, "PC98", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_ESTIMATE_SIZES_AGGRESSIVELY,"EstimateSizesAggressively",OPTV_INTEGER, + {0}, FALSE }, + { FLAG_NOPM, "NoPM", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_ALLOW_DEACTIVATE_GRABS,"AllowDeactivateGrabs", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_ALLOW_CLOSEDOWN_GRABS, "AllowClosedownGrabs", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_LOG, "Log", OPTV_STRING, + {0}, FALSE }, + { FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING, + {0}, FALSE }, + { FLAG_HANDLE_SPECIAL_KEYS, "HandleSpecialKeys", OPTV_STRING, + {0}, FALSE }, + { FLAG_RANDR, "RandR", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_ALLOW_EMPTY_INPUT, "AllowEmptyInput", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN, + {0}, FALSE }, + { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN, + {0}, TRUE }, + { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN, + {0}, TRUE }, + { FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING, + {0}, FALSE }, + { FLAG_DRI2, "DRI2", OPTV_BOOLEAN, + {0}, FALSE }, + { -1, NULL, OPTV_NONE, + {0}, FALSE }, +}; + +#ifdef __i386__ +static Bool +detectPC98(void) +{ +#ifdef SUPPORT_PC98 + unsigned char buf[2]; + + if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2) + return FALSE; + if ((buf[0] == 0x98) && (buf[1] == 0x21)) + return TRUE; + else + return FALSE; +#else + return FALSE; +#endif +} +#endif /* __i386__ */ + +static Bool +configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) +{ + XF86OptionPtr optp, tmp; + int i; + Pix24Flags pix24 = Pix24DontCare; + Bool value; + MessageType from; + const char *s; + + /* + * Merge the ServerLayout and ServerFlags options. The former have + * precedence over the latter. + */ + optp = NULL; + if (flagsconf && flagsconf->flg_option_lst) + optp = xf86optionListDup(flagsconf->flg_option_lst); + if (layoutopts) { + tmp = xf86optionListDup(layoutopts); + if (optp) + optp = xf86optionListMerge(optp, tmp); + else + optp = tmp; + } + + xf86ProcessOptions(-1, optp, FlagOptions); + + xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals); + xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch); + xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap); + xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom); + + xf86GetOptValBool(FlagOptions, FLAG_ALLOW_DEACTIVATE_GRABS, + &(xf86Info.grabInfo.allowDeactivate)); + xf86GetOptValBool(FlagOptions, FLAG_ALLOW_CLOSEDOWN_GRABS, + &(xf86Info.grabInfo.allowClosedown)); + xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI); + if (xf86Info.ignoreABI) { + xf86Msg(X_CONFIG, "Ignoring ABI Version\n"); + } + + if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) { + xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES, + &xf86Info.autoAddDevices); + from = X_CONFIG; + } + else { + xf86Info.autoAddDevices = TRUE; + from = X_DEFAULT; + } + xf86Msg(from, "%sutomatically adding devices\n", + xf86Info.autoAddDevices ? "A" : "Not a"); + + if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ENABLE_DEVICES)) { + xf86GetOptValBool(FlagOptions, FLAG_AUTO_ENABLE_DEVICES, + &xf86Info.autoEnableDevices); + from = X_CONFIG; + } + else { + xf86Info.autoEnableDevices = TRUE; + from = X_DEFAULT; + } + xf86Msg(from, "%sutomatically enabling devices\n", + xf86Info.autoEnableDevices ? "A" : "Not a"); + + /* + * Set things up based on the config file information. Some of these + * settings may be overridden later when the command line options are + * checked. + */ +#ifdef XF86VIDMODE + if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value)) + xf86Info.vidModeEnabled = !value; + if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value)) + xf86Info.vidModeAllowNonLocal = value; +#endif + +#ifdef XF86MISC + if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEMODINDEV, &value)) + xf86Info.miscModInDevEnabled = !value; + if (xf86GetOptValBool(FlagOptions, FLAG_MODINDEVALLOWNONLOCAL, &value)) + xf86Info.miscModInDevAllowNonLocal = value; +#endif + + if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value)) + xf86Info.allowMouseOpenFail = value; + + if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) { +#ifdef USE_VT_SYSREQ + xf86Info.vtSysreq = value; + xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled"); +#else + if (value) + xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n"); +#endif + } + + if (xf86GetOptValBool(FlagOptions, FLAG_XKBDISABLE, &value)) { +#ifdef XKB + noXkbExtension = value; + xf86Msg(X_CONFIG, "Xkb %s\n", value ? "disabled" : "enabled"); +#else + if (!value) + xf86Msg(X_WARNING, "Xserver doesn't support XKB\n"); +#endif + } + + if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE1)) + xf86Info.pciFlags = PCIProbe1; + if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE2)) + xf86Info.pciFlags = PCIProbe2; + if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG1)) + xf86Info.pciFlags = PCIForceConfig1; + if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG2)) + xf86Info.pciFlags = PCIForceConfig2; + if (xf86IsOptionSet(FlagOptions, FLAG_PCIOSCONFIG)) + xf86Info.pciFlags = PCIOsConfig; + if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCENONE)) + xf86Info.pciFlags = PCIForceNone; + + xf86Info.pmFlag = TRUE; + if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value)) + xf86Info.pmFlag = !value; + { + if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) { + if (!xf86NameCmp(s,"flush")) { + xf86Msg(X_CONFIG, "Flushing logfile enabled\n"); + xf86Info.log = LogFlush; + LogSetParameter(XLOG_FLUSH, TRUE); + } else if (!xf86NameCmp(s,"sync")) { + xf86Msg(X_CONFIG, "Syncing logfile enabled\n"); + xf86Info.log = LogSync; + LogSetParameter(XLOG_FLUSH, TRUE); + LogSetParameter(XLOG_SYNC, TRUE); + } else { + xf86Msg(X_WARNING,"Unknown Log option\n"); + } + } + } + +#ifdef RENDER + { + if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){ + int policy = PictureParseCmapPolicy (s); + if (policy == PictureCmapPolicyInvalid) + xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s); + else + { + xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s); + PictureCmapPolicy = policy; + } + } + } +#endif + { + if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) { + if (!xf86NameCmp(s,"always")) { + xf86Msg(X_CONFIG, "Always handling special keys in DDX\n"); + xf86Info.ddxSpecialKeys = SKAlways; + } else if (!xf86NameCmp(s,"whenneeded")) { + xf86Msg(X_CONFIG, "Special keys handled in DDX only if needed\n"); + xf86Info.ddxSpecialKeys = SKWhenNeeded; + } else if (!xf86NameCmp(s,"never")) { + xf86Msg(X_CONFIG, "Never handling special keys in DDX\n"); + xf86Info.ddxSpecialKeys = SKNever; + } else { + xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n"); + } + } + } +#ifdef RANDR + xf86Info.disableRandR = FALSE; + xf86Info.randRFrom = X_DEFAULT; + if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) { + xf86Info.disableRandR = !value; + xf86Info.randRFrom = X_CONFIG; + } +#endif + i = -1; + xf86GetOptValInteger(FlagOptions, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, &i); + if (i >= 0) + xf86Info.estimateSizesAggressively = i; + else + xf86Info.estimateSizesAggressively = 0; + + xf86Info.aiglx = TRUE; + xf86Info.aiglxFrom = X_DEFAULT; + if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) { + xf86Info.aiglx = value; + xf86Info.aiglxFrom = X_CONFIG; + } + +#ifdef GLXEXT + xf86Info.glxVisuals = XF86_GlxVisualsTypical; + xf86Info.glxVisualsFrom = X_DEFAULT; + if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) { + if (!xf86NameCmp(s, "minimal")) { + xf86Info.glxVisuals = XF86_GlxVisualsMinimal; + } else if (!xf86NameCmp(s, "typical")) { + xf86Info.glxVisuals = XF86_GlxVisualsTypical; + } else if (!xf86NameCmp(s, "all")) { + xf86Info.glxVisuals = XF86_GlxVisualsAll; + } else { + xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n"); + } + } + + if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) { + xf86Info.aiglx = value; + xf86Info.aiglxFrom = X_CONFIG; + } +#endif + + /* AllowEmptyInput is automatically true if we're hotplugging */ + xf86Info.allowEmptyInput = (xf86Info.autoAddDevices && xf86Info.autoEnableDevices); + xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &xf86Info.allowEmptyInput); + + xf86Info.useDefaultFontPath = TRUE; + xf86Info.useDefaultFontPathFrom = X_DEFAULT; + if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) { + xf86Info.useDefaultFontPath = value; + xf86Info.useDefaultFontPathFrom = X_CONFIG; + } + +/* Make sure that timers don't overflow CARD32's after multiplying */ +#define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN) + + i = -1; + xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i); + if ((i >= 0) && (i < MAX_TIME_IN_MIN)) + ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN; + else if (i != -1) + xf86ConfigError("BlankTime value %d outside legal range of 0 - %d minutes", + i, MAX_TIME_IN_MIN); + +#ifdef DPMSExtension + i = -1; + xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i); + if ((i >= 0) && (i < MAX_TIME_IN_MIN)) + DPMSStandbyTime = defaultDPMSStandbyTime = i * MILLI_PER_MIN; + else if (i != -1) + xf86ConfigError("StandbyTime value %d outside legal range of 0 - %d minutes", + i, MAX_TIME_IN_MIN); + i = -1; + xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i); + if ((i >= 0) && (i < MAX_TIME_IN_MIN)) + DPMSSuspendTime = defaultDPMSSuspendTime = i * MILLI_PER_MIN; + else if (i != -1) + xf86ConfigError("SuspendTime value %d outside legal range of 0 - %d minutes", + i, MAX_TIME_IN_MIN); + i = -1; + xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i); + if ((i >= 0) && (i < MAX_TIME_IN_MIN)) + DPMSOffTime = defaultDPMSOffTime = i * MILLI_PER_MIN; + else if (i != -1) + xf86ConfigError("OffTime value %d outside legal range of 0 - %d minutes", + i, MAX_TIME_IN_MIN); +#endif + + i = -1; + xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i); + switch (i) { + case 24: + pix24 = Pix24Use24; + break; + case 32: + pix24 = Pix24Use32; + break; + case -1: + break; + default: + xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i); + return FALSE; + } + if (xf86Pix24 != Pix24DontCare) { + xf86Info.pixmap24 = xf86Pix24; + xf86Info.pix24From = X_CMDLINE; + } else if (pix24 != Pix24DontCare) { + xf86Info.pixmap24 = pix24; + xf86Info.pix24From = X_CONFIG; + } else { + xf86Info.pixmap24 = Pix24DontCare; + xf86Info.pix24From = X_DEFAULT; + } +#ifdef __i386__ + if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) { + xf86Info.pc98 = value; + if (value) { + xf86Msg(X_CONFIG, "Japanese PC98 architecture\n"); + } + } else + if (detectPC98()) { + xf86Info.pc98 = TRUE; + xf86Msg(X_PROBED, "Japanese PC98 architecture\n"); + } +#endif + +#ifdef PANORAMIX + from = X_DEFAULT; + if (!noPanoramiXExtension) + from = X_CMDLINE; + else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) { + noPanoramiXExtension = !value; + from = X_CONFIG; + } + if (!noPanoramiXExtension) + xf86Msg(from, "Xinerama: enabled\n"); +#endif + +#ifdef DRI2 + xf86Info.dri2 = FALSE; + xf86Info.dri2From = X_DEFAULT; + if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) { + xf86Info.dri2 = value; + xf86Info.dri2From = X_CONFIG; + } +#endif + + return TRUE; +} + +Bool xf86DRI2Enabled(void) +{ + return xf86Info.dri2; +} + +/* + * Locate the core input devices. These can be specified/located in + * the following ways, in order of priority: + * + * 1. The InputDevices named by the -pointer and -keyboard command line + * options. + * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by + * the active ServerLayout. + * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard". + * 4. The first InputDevices that use the 'mouse' and 'keyboard' or 'kbd' + * drivers. + * 5. Default devices with an empty (default) configuration. These defaults + * will reference the 'mouse' and 'keyboard' drivers. + */ + +static Bool +checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) +{ + IDevPtr corePointer = NULL, coreKeyboard = NULL; + Bool foundPointer = FALSE, foundKeyboard = FALSE; + const char *pointerMsg = NULL, *keyboardMsg = NULL; + IDevPtr *devs, /* iterator */ + indp; + IDevRec Pointer, Keyboard; + XF86ConfInputPtr confInput; + XF86ConfInputRec defPtr, defKbd; + int count = 0; + MessageType from = X_DEFAULT; + int found = 0; + + /* + * First check if a core pointer or core keyboard have been specified + * in the active ServerLayout. If more than one is specified for either, + * remove the core attribute from the later ones. + */ + for (devs = servlayoutp->inputs; devs && *devs; devs++) { + indp = *devs; + pointer opt1 = NULL, opt2 = NULL; + if (indp->commonOptions && + xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) { + opt1 = indp->commonOptions; + } + if (indp->extraOptions && + xf86CheckBoolOption(indp->extraOptions, "CorePointer", FALSE)) { + opt2 = indp->extraOptions; + } + if (opt1 || opt2) { + if (!corePointer) { + corePointer = indp; + } else { + if (opt1) + xf86ReplaceBoolOption(opt1, "CorePointer", FALSE); + if (opt2) + xf86ReplaceBoolOption(opt2, "CorePointer", FALSE); + xf86Msg(X_WARNING, "Duplicate core pointer devices. " + "Removing core pointer attribute from \"%s\"\n", + indp->identifier); + } + } + opt1 = opt2 = NULL; + if (indp->commonOptions && + xf86CheckBoolOption(indp->commonOptions, "CoreKeyboard", FALSE)) { + opt1 = indp->commonOptions; + } + if (indp->extraOptions && + xf86CheckBoolOption(indp->extraOptions, "CoreKeyboard", FALSE)) { + opt2 = indp->extraOptions; + } + if (opt1 || opt2) { + if (!coreKeyboard) { + coreKeyboard = indp; + } else { + if (opt1) + xf86ReplaceBoolOption(opt1, "CoreKeyboard", FALSE); + if (opt2) + xf86ReplaceBoolOption(opt2, "CoreKeyboard", FALSE); + xf86Msg(X_WARNING, "Duplicate core keyboard devices. " + "Removing core keyboard attribute from \"%s\"\n", + indp->identifier); + } + } + count++; + } + + confInput = NULL; + + /* 1. Check for the -pointer command line option. */ + if (xf86PointerName) { + confInput = xf86findInput(xf86PointerName, + xf86configptr->conf_input_lst); + if (!confInput) { + xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", + xf86PointerName); + return FALSE; + } + from = X_CMDLINE; + /* + * If one was already specified in the ServerLayout, it needs to be + * removed. + */ + if (corePointer) { + for (devs = servlayoutp->inputs; devs && *devs; devs++) + if (*devs == corePointer) + { + xfree(*devs); + *devs = (IDevPtr)0x1; /* ensure we dont skip next loop*/ + break; + } + for (; devs && *devs; devs++) + devs[0] = devs[1]; + count--; + } + corePointer = NULL; + foundPointer = TRUE; + } + + /* 2. ServerLayout-specified core pointer. */ + if (corePointer) { + foundPointer = TRUE; + from = X_CONFIG; + } + + /* 3. First core pointer device. */ + if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) { + XF86ConfInputPtr p; + + for (p = xf86configptr->conf_input_lst; p; p = p->list.next) { + if (p->inp_option_lst && + xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) { + confInput = p; + foundPointer = TRUE; + from = X_DEFAULT; + pointerMsg = "first core pointer device"; + break; + } + } + } + + /* 4. First pointer with 'mouse' as the driver. */ + if (!foundPointer && !xf86Info.allowEmptyInput) { + confInput = xf86findInput(CONF_IMPLICIT_POINTER, + xf86configptr->conf_input_lst); + if (!confInput) { + confInput = xf86findInputByDriver("mouse", + xf86configptr->conf_input_lst); + } + if (confInput) { + foundPointer = TRUE; + from = X_DEFAULT; + pointerMsg = "first mouse device"; + } + } + + /* 5. Built-in default. */ + if (!foundPointer && !xf86Info.allowEmptyInput) { + bzero(&defPtr, sizeof(defPtr)); + defPtr.inp_identifier = strdup(""); + defPtr.inp_driver = strdup("mouse"); + confInput = &defPtr; + foundPointer = TRUE; + from = X_DEFAULT; + pointerMsg = "default mouse configuration"; + } + + /* Add the core pointer device to the layout, and set it to Core. */ + if (foundPointer && confInput) { + foundPointer = configInput(&Pointer, confInput, from); + if (foundPointer) { + count++; + devs = xnfrealloc(servlayoutp->inputs, + (count + 1) * sizeof(IDevPtr)); + devs[count - 1] = xnfalloc(sizeof(IDevRec)); + *devs[count - 1] = Pointer; + devs[count - 1]->extraOptions = + xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL); + devs[count] = NULL; + servlayoutp->inputs = devs; + } + } + + if (!foundPointer) { + if (!xf86Info.allowEmptyInput) { + /* This shouldn't happen. */ + xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n"); + return FALSE; + } else { + xf86Msg(X_INFO, "Cannot locate a core pointer device.\n"); + } + } + + /* + * always synthesize a 'mouse' section configured to send core + * events, unless a 'void' section is found, in which case the user + * probably wants to run footless. + * + * If you're using an evdev keyboard and expect a default mouse + * section ... deal. + */ + for (devs = servlayoutp->inputs; devs && *devs; devs++) { + if (!strcmp((*devs)->driver, "void") || !strcmp((*devs)->driver, "mouse") || + !strcmp((*devs)->driver, "vmmouse") || !strcmp((*devs)->driver, "evdev")) { + found = 1; break; + } + } + if (!found && !xf86Info.allowEmptyInput) { + xf86Msg(X_INFO, "No default mouse found, adding one\n"); + bzero(&defPtr, sizeof(defPtr)); + defPtr.inp_identifier = strdup(""); + defPtr.inp_driver = strdup("mouse"); + confInput = &defPtr; + foundPointer = configInput(&Pointer, confInput, from); + if (foundPointer) { + count++; + devs = xnfrealloc(servlayoutp->inputs, + (count + 1) * sizeof(IDevPtr)); + devs[count - 1] = xnfalloc(sizeof(IDevRec)); + *devs[count - 1] = Pointer; + devs[count - 1]->extraOptions = + xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL); + devs[count] = NULL; + servlayoutp->inputs = devs; + } + } + + confInput = NULL; + + /* 1. Check for the -keyboard command line option. */ + if (xf86KeyboardName) { + confInput = xf86findInput(xf86KeyboardName, + xf86configptr->conf_input_lst); + if (!confInput) { + xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", + xf86KeyboardName); + return FALSE; + } + from = X_CMDLINE; + /* + * If one was already specified in the ServerLayout, it needs to be + * removed. + */ + if (coreKeyboard) { + for (devs = servlayoutp->inputs; devs && *devs; devs++) + if (*devs == coreKeyboard) + { + xfree(*devs); + *devs = (IDevPtr)0x1; /* ensure we dont skip next loop */ + break; + } + for (; devs && *devs; devs++) + devs[0] = devs[1]; + count--; + } + coreKeyboard = NULL; + foundKeyboard = TRUE; + } + + /* 2. ServerLayout-specified core keyboard. */ + if (coreKeyboard) { + foundKeyboard = TRUE; + from = X_CONFIG; + } + + /* 3. First core keyboard device. */ + if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) { + XF86ConfInputPtr p; + + for (p = xf86configptr->conf_input_lst; p; p = p->list.next) { + if (p->inp_option_lst && + xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) { + confInput = p; + foundKeyboard = TRUE; + from = X_DEFAULT; + keyboardMsg = "first core keyboard device"; + break; + } + } + } + + /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */ + if (!foundKeyboard && !xf86Info.allowEmptyInput) { + confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD, + xf86configptr->conf_input_lst); + if (!confInput) { + confInput = xf86findInputByDriver("kbd", + xf86configptr->conf_input_lst); + } + if (confInput) { + foundKeyboard = TRUE; + from = X_DEFAULT; + keyboardMsg = "first keyboard device"; + } + } + + /* 5. Built-in default. */ + if (!foundKeyboard && !xf86Info.allowEmptyInput) { + bzero(&defKbd, sizeof(defKbd)); + defKbd.inp_identifier = strdup(""); + defKbd.inp_driver = strdup("kbd"); + confInput = &defKbd; + foundKeyboard = TRUE; + keyboardMsg = "default keyboard configuration"; + from = X_DEFAULT; + } + + /* Add the core keyboard device to the layout, and set it to Core. */ + if (foundKeyboard && confInput) { + foundKeyboard = configInput(&Keyboard, confInput, from); + if (foundKeyboard) { + count++; + devs = xnfrealloc(servlayoutp->inputs, + (count + 1) * sizeof(IDevPtr)); + devs[count - 1] = xnfalloc(sizeof(IDevRec)); + *devs[count - 1] = Keyboard; + devs[count - 1]->extraOptions = + xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL); + devs[count] = NULL; + servlayoutp->inputs = devs; + } + } + + if (!foundKeyboard) { + if (!xf86Info.allowEmptyInput) { + /* This shouldn't happen. */ + xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n"); + return FALSE; + } else { + xf86Msg(X_INFO, "Cannot locate a core keyboard device.\n"); + } + } + + if (pointerMsg) { + if (implicitLayout) + xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n", + pointerMsg); + else + xf86Msg(X_DEFAULT, "The core pointer device wasn't specified " + "explicitly in the layout.\n" + "\tUsing the %s.\n", pointerMsg); + } + + if (keyboardMsg) { + if (implicitLayout) + xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n", + keyboardMsg); + else + xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified " + "explicitly in the layout.\n" + "\tUsing the %s.\n", keyboardMsg); + } + + if (xf86Info.allowEmptyInput && !(foundPointer && foundKeyboard)) { + xf86Msg(X_INFO, "The server relies on HAL to provide the list of " + "input devices.\n\tIf no devices become available, " + "reconfigure HAL or disable AllowEmptyInput.\n"); + } + + return TRUE; +} + +typedef enum { + LAYOUT_ISOLATEDEVICE, + LAYOUT_SINGLECARD +} LayoutValues; + +static OptionInfoRec LayoutOptions[] = { + { LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING, + {0}, FALSE }, + { LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN, + {0}, FALSE }, + { -1, NULL, OPTV_NONE, + {0}, FALSE }, +}; + +/* + * figure out which layout is active, which screens are used in that layout, + * which drivers and monitors are used in these screens + */ +static Bool +configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, + char *default_layout) +{ + XF86ConfAdjacencyPtr adjp; + XF86ConfInactivePtr idp; + XF86ConfInputrefPtr irp; + int count = 0; + int scrnum; + XF86ConfLayoutPtr l; + MessageType from; + screenLayoutPtr slp; + GDevPtr gdp; + IDevPtr* indp; + int i = 0, j; + + if (!servlayoutp) + return FALSE; + + /* + * which layout section is the active one? + * + * If there is a -layout command line option, use that one, otherwise + * pick the first one. + */ + from = X_DEFAULT; + if (xf86LayoutName != NULL) + from = X_CMDLINE; + else if (default_layout) { + xf86LayoutName = default_layout; + from = X_CONFIG; + } + if (xf86LayoutName != NULL) { + if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) { + xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n", + xf86LayoutName); + return FALSE; + } + conf_layout = l; + } + xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier); + adjp = conf_layout->lay_adjacency_lst; + + /* + * we know that each screen is referenced exactly once on the left side + * of a layout statement in the Layout section. So to allocate the right + * size for the array we do a quick walk of the list to figure out how + * many sections we have + */ + while (adjp) { + count++; + adjp = (XF86ConfAdjacencyPtr)adjp->list.next; + } +#ifdef DEBUG + ErrorF("Found %d screens in the layout section %s", + count, conf_layout->lay_identifier); +#endif + slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec)); + slp[count].screen = NULL; + /* + * now that we have storage, loop over the list again and fill in our + * data structure; at this point we do not fill in the adjacency + * information as it is not clear if we need it at all + */ + adjp = conf_layout->lay_adjacency_lst; + count = 0; + while (adjp) { + slp[count].screen = xnfcalloc(1, sizeof(confScreenRec)); + if (adjp->adj_scrnum < 0) + scrnum = count; + else + scrnum = adjp->adj_scrnum; + if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum, + X_CONFIG)) { + xfree(slp); + return FALSE; + } + slp[count].x = adjp->adj_x; + slp[count].y = adjp->adj_y; + slp[count].refname = adjp->adj_refscreen; + switch (adjp->adj_where) { + case CONF_ADJ_OBSOLETE: + slp[count].where = PosObsolete; + slp[count].topname = adjp->adj_top_str; + slp[count].bottomname = adjp->adj_bottom_str; + slp[count].leftname = adjp->adj_left_str; + slp[count].rightname = adjp->adj_right_str; + break; + case CONF_ADJ_ABSOLUTE: + slp[count].where = PosAbsolute; + break; + case CONF_ADJ_RIGHTOF: + slp[count].where = PosRightOf; + break; + case CONF_ADJ_LEFTOF: + slp[count].where = PosLeftOf; + break; + case CONF_ADJ_ABOVE: + slp[count].where = PosAbove; + break; + case CONF_ADJ_BELOW: + slp[count].where = PosBelow; + break; + case CONF_ADJ_RELATIVE: + slp[count].where = PosRelative; + break; + } + count++; + adjp = (XF86ConfAdjacencyPtr)adjp->list.next; + } + + /* XXX Need to tie down the upper left screen. */ + + /* Fill in the refscreen and top/bottom/left/right values */ + for (i = 0; i < count; i++) { + for (j = 0; j < count; j++) { + if (slp[i].refname && + strcmp(slp[i].refname, slp[j].screen->id) == 0) { + slp[i].refscreen = slp[j].screen; + } + if (slp[i].topname && + strcmp(slp[i].topname, slp[j].screen->id) == 0) { + slp[i].top = slp[j].screen; + } + if (slp[i].bottomname && + strcmp(slp[i].bottomname, slp[j].screen->id) == 0) { + slp[i].bottom = slp[j].screen; + } + if (slp[i].leftname && + strcmp(slp[i].leftname, slp[j].screen->id) == 0) { + slp[i].left = slp[j].screen; + } + if (slp[i].rightname && + strcmp(slp[i].rightname, slp[j].screen->id) == 0) { + slp[i].right = slp[j].screen; + } + } + if (slp[i].where != PosObsolete + && slp[i].where != PosAbsolute + && !slp[i].refscreen) { + xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n", + slp[i].refname); + slp[i].where = PosAbsolute; + slp[i].x = 0; + slp[i].y = 0; + } + } + +#ifdef LAYOUT_DEBUG + ErrorF("Layout \"%s\"\n", conf_layout->lay_identifier); + for (i = 0; i < count; i++) { + ErrorF("Screen: \"%s\" (%d):\n", slp[i].screen->id, + slp[i].screen->screennum); + switch (slp[i].where) { + case PosObsolete: + ErrorF("\tObsolete format: \"%s\" \"%s\" \"%s\" \"%s\"\n", + slp[i].top, slp[i].bottom, slp[i].left, slp[i].right); + break; + case PosAbsolute: + if (slp[i].x == -1) + if (slp[i].screen->screennum == 0) + ErrorF("\tImplicitly left-most\n"); + else + ErrorF("\tImplicitly right of screen %d\n", + slp[i].screen->screennum - 1); + else + ErrorF("\t%d %d\n", slp[i].x, slp[i].y); + break; + case PosRightOf: + ErrorF("\tRight of \"%s\"\n", slp[i].refscreen->id); + break; + case PosLeftOf: + ErrorF("\tLeft of \"%s\"\n", slp[i].refscreen->id); + break; + case PosAbove: + ErrorF("\tAbove \"%s\"\n", slp[i].refscreen->id); + break; + case PosBelow: + ErrorF("\tBelow \"%s\"\n", slp[i].refscreen->id); + break; + case PosRelative: + ErrorF("\t%d %d relative to \"%s\"\n", slp[i].x, slp[i].y, + slp[i].refscreen->id); + break; + } + } +#endif + /* + * Count the number of inactive devices. + */ + count = 0; + idp = conf_layout->lay_inactive_lst; + while (idp) { + count++; + idp = (XF86ConfInactivePtr)idp->list.next; + } +#ifdef DEBUG + ErrorF("Found %d inactive devices in the layout section %s", + count, conf_layout->lay_identifier); +#endif + gdp = xnfalloc((count + 1) * sizeof(GDevRec)); + gdp[count].identifier = NULL; + idp = conf_layout->lay_inactive_lst; + count = 0; + while (idp) { + if (!configDevice(&gdp[count], idp->inactive_device, FALSE)) { + xfree(gdp); + return FALSE; + } + count++; + idp = (XF86ConfInactivePtr)idp->list.next; + } + /* + * Count the number of input devices. + */ + count = 0; + irp = conf_layout->lay_input_lst; + while (irp) { + count++; + irp = (XF86ConfInputrefPtr)irp->list.next; + } +#ifdef DEBUG + ErrorF("Found %d input devices in the layout section %s", + count, conf_layout->lay_identifier); +#endif + indp = xnfcalloc((count + 1), sizeof(IDevPtr)); + indp[count] = NULL; + irp = conf_layout->lay_input_lst; + count = 0; + while (irp) { + indp[count] = xnfalloc(sizeof(IDevRec)); + if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) { + while(count--) + xfree(indp[count]); + xfree(indp); + return FALSE; + } + indp[count]->extraOptions = irp->iref_option_lst; + count++; + irp = (XF86ConfInputrefPtr)irp->list.next; + } + servlayoutp->id = conf_layout->lay_identifier; + servlayoutp->screens = slp; + servlayoutp->inactives = gdp; + servlayoutp->inputs = indp; + servlayoutp->options = conf_layout->lay_option_lst; + from = X_DEFAULT; + + return TRUE; +} + +/* + * No layout section, so find the first Screen section and set that up as + * the only active screen. + */ +static Bool +configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen) +{ + MessageType from; + XF86ConfScreenPtr s; + screenLayoutPtr slp; + IDevPtr *indp; + + if (!servlayoutp) + return FALSE; + + /* + * which screen section is the active one? + * + * If there is a -screen option, use that one, otherwise use the first + * one. + */ + + from = X_CONFIG; + if (xf86ScreenName != NULL) { + if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) { + xf86Msg(X_ERROR, "No Screen section called \"%s\"\n", + xf86ScreenName); + return FALSE; + } + conf_screen = s; + from = X_CMDLINE; + } + + /* We have exactly one screen */ + + slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec)); + slp[0].screen = xnfcalloc(1, sizeof(confScreenRec)); + slp[1].screen = NULL; + if (!configScreen(slp[0].screen, conf_screen, 0, from)) { + xfree(slp); + return FALSE; + } + servlayoutp->id = "(implicit)"; + servlayoutp->screens = slp; + servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec)); + servlayoutp->options = NULL; + /* Set up an empty input device list, then look for some core devices. */ + indp = xnfalloc(sizeof(IDevPtr)); + *indp = NULL; + servlayoutp->inputs = indp; + + return TRUE; +} + +static Bool +configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor) +{ + int count = 0; + XF86ConfVideoPortPtr conf_port; + + xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n", + conf_adaptor->va_identifier); + adaptor->identifier = conf_adaptor->va_identifier; + adaptor->options = conf_adaptor->va_option_lst; + if (conf_adaptor->va_busid || conf_adaptor->va_driver) { + xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n"); + return FALSE; + } + + /* + * figure out how many videoport subsections there are and fill them in + */ + conf_port = conf_adaptor->va_port_lst; + while(conf_port) { + count++; + conf_port = (XF86ConfVideoPortPtr)conf_port->list.next; + } + adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec)); + adaptor->numports = count; + count = 0; + conf_port = conf_adaptor->va_port_lst; + while(conf_port) { + adaptor->ports[count].identifier = conf_port->vp_identifier; + adaptor->ports[count].options = conf_port->vp_option_lst; + count++; + conf_port = (XF86ConfVideoPortPtr)conf_port->list.next; + } + + return TRUE; +} + +static Bool +configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, + MessageType from) +{ + int count = 0; + XF86ConfDisplayPtr dispptr; + XF86ConfAdaptorLinkPtr conf_adaptor; + Bool defaultMonitor = FALSE; + + if (!conf_screen) { + conf_screen = xnfcalloc(1, sizeof(XF86ConfScreenRec)); + conf_screen->scrn_identifier = "Default Screen Section"; + xf86Msg(X_DEFAULT, "No screen section available. Using defaults.\n"); + } + + xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier, + scrnum); + /* + * now we fill in the elements of the screen + */ + screenp->id = conf_screen->scrn_identifier; + screenp->screennum = scrnum; + screenp->defaultdepth = conf_screen->scrn_defaultdepth; + screenp->defaultbpp = conf_screen->scrn_defaultbpp; + screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp; + screenp->monitor = xnfcalloc(1, sizeof(MonRec)); + /* If no monitor is specified, create a default one. */ + if (!conf_screen->scrn_monitor) { + XF86ConfMonitorRec defMon; + + bzero(&defMon, sizeof(defMon)); + defMon.mon_identifier = ""; + /* + * TARGET_REFRESH_RATE may be defined to effectively limit the + * default resolution to the largest that has a "good" refresh + * rate. + */ +#ifdef TARGET_REFRESH_RATE + defMon.mon_option_lst = xf86ReplaceRealOption(defMon.mon_option_lst, + "TargetRefresh", + TARGET_REFRESH_RATE); +#endif + if (!configMonitor(screenp->monitor, &defMon)) + return FALSE; + defaultMonitor = TRUE; + } else { + if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor)) + return FALSE; + } + /* Configure the device. If there isn't one configured, attach to the + * first inactive one that we can configure. If there's none that work, + * set it to NULL so that the section can be autoconfigured later */ + screenp->device = xnfcalloc(1, sizeof(GDevRec)); + if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) { + conf_screen->scrn_device = xf86configptr->conf_device_lst; + xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n" + "\tUsing the first device section listed.\n", screenp->id); + } + if (configDevice(screenp->device,conf_screen->scrn_device, TRUE)) { + screenp->device->myScreenSection = screenp; + } else { + screenp->device = NULL; + } + screenp->options = conf_screen->scrn_option_lst; + + /* + * figure out how many display subsections there are and fill them in + */ + dispptr = conf_screen->scrn_display_lst; + while(dispptr) { + count++; + dispptr = (XF86ConfDisplayPtr)dispptr->list.next; + } + screenp->displays = xnfalloc((count) * sizeof(DispRec)); + screenp->numdisplays = count; + + /* Fill in the default Virtual size, if any */ + if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) { + for (count = 0, dispptr = conf_screen->scrn_display_lst; + dispptr; + dispptr = (XF86ConfDisplayPtr)dispptr->list.next, count++) { + screenp->displays[count].virtualX = conf_screen->scrn_virtualX; + screenp->displays[count].virtualY = conf_screen->scrn_virtualY; + } + } + + /* Now do the per-Display Virtual sizes */ + count = 0; + dispptr = conf_screen->scrn_display_lst; + while(dispptr) { + configDisplay(&(screenp->displays[count]),dispptr); + count++; + dispptr = (XF86ConfDisplayPtr)dispptr->list.next; + } + + /* + * figure out how many videoadaptor references there are and fill them in + */ + conf_adaptor = conf_screen->scrn_adaptor_lst; + while(conf_adaptor) { + count++; + conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next; + } + screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec)); + screenp->numxvadaptors = 0; + conf_adaptor = conf_screen->scrn_adaptor_lst; + while(conf_adaptor) { + if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]), + conf_adaptor->al_adaptor)) + screenp->numxvadaptors++; + conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next; + } + + if (defaultMonitor) { + xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n" + "\tUsing a default monitor configuration.\n", screenp->id); + } + return TRUE; +} + +typedef enum { + MON_REDUCEDBLANKING, + MON_MAX_PIX_CLOCK, +} MonitorValues; + +static OptionInfoRec MonitorOptions[] = { + { MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN, + {0}, FALSE }, + { MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ, + {0}, FALSE }, + { -1, NULL, OPTV_NONE, + {0}, FALSE }, +}; + +static Bool +configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor) +{ + int count; + DisplayModePtr mode,last = NULL; + XF86ConfModeLinePtr cmodep; + XF86ConfModesPtr modes; + XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst; + Gamma zeros = {0.0, 0.0, 0.0}; + float badgamma = 0.0; + + xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n", + conf_monitor->mon_identifier); + monitorp->id = conf_monitor->mon_identifier; + monitorp->vendor = conf_monitor->mon_vendor; + monitorp->model = conf_monitor->mon_modelname; + monitorp->Modes = NULL; + monitorp->Last = NULL; + monitorp->gamma = zeros; + monitorp->widthmm = conf_monitor->mon_width; + monitorp->heightmm = conf_monitor->mon_height; + monitorp->reducedblanking = FALSE; + monitorp->maxPixClock = 0; + monitorp->options = conf_monitor->mon_option_lst; + + /* + * fill in the monitor structure + */ + for( count = 0 ; + count < conf_monitor->mon_n_hsync && count < MAX_HSYNC; + count++) { + monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi; + monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo; + } + monitorp->nHsync = count; + for( count = 0 ; + count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH; + count++) { + monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi; + monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo; + } + monitorp->nVrefresh = count; + + /* + * first we collect the mode lines from the UseModes directive + */ + while(modeslnk) + { + modes = xf86findModes (modeslnk->ml_modes_str, + xf86configptr->conf_modes_lst); + modeslnk->ml_modes = modes; + + + /* now add the modes found in the modes + section to the list of modes for this + monitor unless it has been added before + because we are reusing the same section + for another screen */ + if (xf86itemNotSublist( + (GenericListPtr)conf_monitor->mon_modeline_lst, + (GenericListPtr)modes->mon_modeline_lst)) { + conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr) + xf86addListItem( + (GenericListPtr)conf_monitor->mon_modeline_lst, + (GenericListPtr)modes->mon_modeline_lst); + } + modeslnk = modeslnk->list.next; + } + + /* + * we need to hook in the mode lines now + * here both data structures use lists, only our internal one + * is double linked + */ + cmodep = conf_monitor->mon_modeline_lst; + while( cmodep ) { + mode = xnfcalloc(1, sizeof(DisplayModeRec)); + mode->type = 0; + mode->Clock = cmodep->ml_clock; + mode->HDisplay = cmodep->ml_hdisplay; + mode->HSyncStart = cmodep->ml_hsyncstart; + mode->HSyncEnd = cmodep->ml_hsyncend; + mode->HTotal = cmodep->ml_htotal; + mode->VDisplay = cmodep->ml_vdisplay; + mode->VSyncStart = cmodep->ml_vsyncstart; + mode->VSyncEnd = cmodep->ml_vsyncend; + mode->VTotal = cmodep->ml_vtotal; + mode->Flags = cmodep->ml_flags; + mode->HSkew = cmodep->ml_hskew; + mode->VScan = cmodep->ml_vscan; + mode->name = xnfstrdup(cmodep->ml_identifier); + if( last ) { + mode->prev = last; + last->next = mode; + } + else { + /* + * this is the first mode + */ + monitorp->Modes = mode; + mode->prev = NULL; + } + last = mode; + cmodep = (XF86ConfModeLinePtr)cmodep->list.next; + } + if(last){ + last->next = NULL; + } + monitorp->Last = last; + + /* add the (VESA) default modes */ + if (! addDefaultModes(monitorp) ) + return FALSE; + + if (conf_monitor->mon_gamma_red > GAMMA_ZERO) + monitorp->gamma.red = conf_monitor->mon_gamma_red; + if (conf_monitor->mon_gamma_green > GAMMA_ZERO) + monitorp->gamma.green = conf_monitor->mon_gamma_green; + if (conf_monitor->mon_gamma_blue > GAMMA_ZERO) + monitorp->gamma.blue = conf_monitor->mon_gamma_blue; + + /* Check that the gamma values are within range */ + if (monitorp->gamma.red > GAMMA_ZERO && + (monitorp->gamma.red < GAMMA_MIN || + monitorp->gamma.red > GAMMA_MAX)) { + badgamma = monitorp->gamma.red; + } else if (monitorp->gamma.green > GAMMA_ZERO && + (monitorp->gamma.green < GAMMA_MIN || + monitorp->gamma.green > GAMMA_MAX)) { + badgamma = monitorp->gamma.green; + } else if (monitorp->gamma.blue > GAMMA_ZERO && + (monitorp->gamma.blue < GAMMA_MIN || + monitorp->gamma.blue > GAMMA_MAX)) { + badgamma = monitorp->gamma.blue; + } + if (badgamma > GAMMA_ZERO) { + xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n", + badgamma, GAMMA_MIN, GAMMA_MAX); + return FALSE; + } + + xf86ProcessOptions(-1, monitorp->options, MonitorOptions); + xf86GetOptValBool(MonitorOptions, MON_REDUCEDBLANKING, + &monitorp->reducedblanking); + xf86GetOptValFreq(MonitorOptions, MON_MAX_PIX_CLOCK, OPTUNITS_KHZ, + &monitorp->maxPixClock); + return TRUE; +} + +static int +lookupVisual(const char *visname) +{ + int i; + + if (!visname || !*visname) + return -1; + + for (i = 0; i <= DirectColor; i++) { + if (!xf86nameCompare(visname, xf86VisualNames[i])) + break; + } + + if (i <= DirectColor) + return i; + + return -1; +} + + +static Bool +configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display) +{ + int count = 0; + XF86ModePtr modep; + + displayp->frameX0 = conf_display->disp_frameX0; + displayp->frameY0 = conf_display->disp_frameY0; + displayp->virtualX = conf_display->disp_virtualX; + displayp->virtualY = conf_display->disp_virtualY; + displayp->depth = conf_display->disp_depth; + displayp->fbbpp = conf_display->disp_bpp; + displayp->weight.red = conf_display->disp_weight.red; + displayp->weight.green = conf_display->disp_weight.green; + displayp->weight.blue = conf_display->disp_weight.blue; + displayp->blackColour.red = conf_display->disp_black.red; + displayp->blackColour.green = conf_display->disp_black.green; + displayp->blackColour.blue = conf_display->disp_black.blue; + displayp->whiteColour.red = conf_display->disp_white.red; + displayp->whiteColour.green = conf_display->disp_white.green; + displayp->whiteColour.blue = conf_display->disp_white.blue; + displayp->options = conf_display->disp_option_lst; + if (conf_display->disp_visual) { + displayp->defaultVisual = lookupVisual(conf_display->disp_visual); + if (displayp->defaultVisual == -1) { + xf86ConfigError("Invalid visual name: \"%s\"", + conf_display->disp_visual); + return FALSE; + } + } else { + displayp->defaultVisual = -1; + } + + /* + * now hook in the modes + */ + modep = conf_display->disp_mode_lst; + while(modep) { + count++; + modep = (XF86ModePtr)modep->list.next; + } + displayp->modes = xnfalloc((count+1) * sizeof(char*)); + modep = conf_display->disp_mode_lst; + count = 0; + while(modep) { + displayp->modes[count] = modep->mode_name; + count++; + modep = (XF86ModePtr)modep->list.next; + } + displayp->modes[count] = NULL; + + return TRUE; +} + +static Bool +configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active) +{ + int i; + + if (!conf_device) { + return FALSE; + } + + if (active) + xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n", + conf_device->dev_identifier); + else + xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n", + conf_device->dev_identifier); + + devicep->identifier = conf_device->dev_identifier; + devicep->vendor = conf_device->dev_vendor; + devicep->board = conf_device->dev_board; + devicep->chipset = conf_device->dev_chipset; + devicep->ramdac = conf_device->dev_ramdac; + devicep->driver = conf_device->dev_driver; + devicep->active = active; + devicep->videoRam = conf_device->dev_videoram; + devicep->BiosBase = conf_device->dev_bios_base; + devicep->MemBase = conf_device->dev_mem_base; + devicep->IOBase = conf_device->dev_io_base; + devicep->clockchip = conf_device->dev_clockchip; + devicep->busID = conf_device->dev_busid; + devicep->textClockFreq = conf_device->dev_textclockfreq; + devicep->chipID = conf_device->dev_chipid; + devicep->chipRev = conf_device->dev_chiprev; + devicep->options = conf_device->dev_option_lst; + devicep->irq = conf_device->dev_irq; + devicep->screen = conf_device->dev_screen; + + for (i = 0; i < MAXDACSPEEDS; i++) { + if (i < CONF_MAXDACSPEEDS) + devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i]; + else + devicep->dacSpeeds[i] = 0; + } + devicep->numclocks = conf_device->dev_clocks; + if (devicep->numclocks > MAXCLOCKS) + devicep->numclocks = MAXCLOCKS; + for (i = 0; i < devicep->numclocks; i++) { + devicep->clock[i] = conf_device->dev_clock[i]; + } + devicep->claimed = FALSE; + + return TRUE; +} + +#ifdef XF86DRI +static void +configDRI(XF86ConfDRIPtr drip) +{ + int count = 0; + XF86ConfBuffersPtr bufs; + int i; + struct group *grp; + + xf86ConfigDRI.group = -1; + xf86ConfigDRI.mode = 0; + xf86ConfigDRI.bufs_count = 0; + xf86ConfigDRI.bufs = NULL; + + if (drip) { + if (drip->dri_group_name) { + if ((grp = getgrnam(drip->dri_group_name))) + xf86ConfigDRI.group = grp->gr_gid; + } else { + if (drip->dri_group >= 0) + xf86ConfigDRI.group = drip->dri_group; + } + xf86ConfigDRI.mode = drip->dri_mode; + for (bufs = drip->dri_buffers_lst; bufs; bufs = bufs->list.next) + ++count; + + xf86ConfigDRI.bufs_count = count; + xf86ConfigDRI.bufs = xnfalloc(count * sizeof(*xf86ConfigDRI.bufs)); + + for (i = 0, bufs = drip->dri_buffers_lst; + i < count; + i++, bufs = bufs->list.next) { + + xf86ConfigDRI.bufs[i].count = bufs->buf_count; + xf86ConfigDRI.bufs[i].size = bufs->buf_size; + /* FIXME: Flags not implemented. These + could be used, for example, to specify a + contiguous block and/or write-combining + cache policy. */ + xf86ConfigDRI.bufs[i].flags = 0; + } + } +} +#endif + +static void +configExtensions(XF86ConfExtensionsPtr conf_ext) +{ + XF86OptionPtr o; + + if (conf_ext && conf_ext->ext_option_lst) { + for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) { + char *name = xf86OptionName(o); + char *val = xf86OptionValue(o); + char *n; + Bool enable = TRUE; + + /* Handle "No" */ + n = xf86NormalizeName(name); + if (strncmp(n, "no", 2) == 0) { + name += 2; + enable = FALSE; + } + + if (!val || + xf86NameCmp(val, "enable") == 0 || + xf86NameCmp(val, "enabled") == 0 || + xf86NameCmp(val, "on") == 0 || + xf86NameCmp(val, "1") == 0 || + xf86NameCmp(val, "yes") == 0 || + xf86NameCmp(val, "true") == 0) { + /* NOTHING NEEDED -- enabling is handled below */ + } else if (xf86NameCmp(val, "disable") == 0 || + xf86NameCmp(val, "disabled") == 0 || + xf86NameCmp(val, "off") == 0 || + xf86NameCmp(val, "0") == 0 || + xf86NameCmp(val, "no") == 0 || + xf86NameCmp(val, "false") == 0) { + enable = !enable; + } else { + xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val); + xfree(n); + continue; + } + + if (EnableDisableExtension(name, enable)) { + xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n", + name, enable ? "enabled" : "disabled"); + } else { + xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n", + name); + } + xfree(n); + } + } +} + +static Bool +configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from) +{ + xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier); + inputp->identifier = conf_input->inp_identifier; + inputp->driver = conf_input->inp_driver; + inputp->commonOptions = conf_input->inp_option_lst; + inputp->extraOptions = NULL; + + return TRUE; +} + +static Bool +modeIsPresent(DisplayModePtr mode, MonPtr monitorp) +{ + DisplayModePtr knownmodes = monitorp->Modes; + + /* all I can think of is a linear search... */ + while(knownmodes != NULL) + { + if(!strcmp(mode->name, knownmodes->name) && + !(knownmodes->type & M_T_DEFAULT)) + return TRUE; + knownmodes = knownmodes->next; + } + return FALSE; +} + +static Bool +addDefaultModes(MonPtr monitorp) +{ + DisplayModePtr mode; + DisplayModePtr last = monitorp->Last; + int i = 0; + + for (i = 0; i < xf86NumDefaultModes; i++) + { + mode = xf86DuplicateMode(&xf86DefaultModes[i]); + if (!modeIsPresent(mode, monitorp)) + { + monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode); + last = mode; + } else { + xfree(mode); + } + } + monitorp->Last = last; + + return TRUE; +} + +static void +checkInput(serverLayoutPtr layout, Bool implicit_layout) { + checkCoreInputDevices(layout, implicit_layout); + + /* AllowEmptyInput and the "kbd" and "mouse" drivers are mutually + * exclusive. Trawl the list for mouse/kbd devices and disable them. + */ + if (xf86Info.allowEmptyInput && layout->inputs) + { + IDevPtr *dev = layout->inputs; + BOOL warned = FALSE; + + while(*dev) + { + if (strcmp((*dev)->driver, "kbd") == 0 || + strcmp((*dev)->driver, "mouse") == 0) + { + IDevPtr *current; + if (!warned) + { + xf86Msg(X_WARNING, "AllowEmptyInput is on, devices using " + "drivers 'kbd' or 'mouse' will be disabled.\n"); + warned = TRUE; + } + + xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->identifier); + + current = dev; + xfree(*dev); + + do { + *current = *(current + 1); + current++; + } while(*current); + } else + dev++; + } + } +} + +/* + * load the config file and fill the global data structure + */ +ConfigStatus +xf86HandleConfigFile(Bool autoconfig) +{ + const char *filename; + char *searchpath; + MessageType from = X_DEFAULT; + char *scanptr; + Bool singlecard = 0; + Bool implicit_layout = FALSE; + + if (!autoconfig) { + if (getuid() == 0) + searchpath = ROOT_CONFIGPATH; + else + searchpath = USER_CONFIGPATH; + + if (xf86ConfigFile) + from = X_CMDLINE; + + filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT); + if (filename) { + xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename); + xf86ConfigFile = xnfstrdup(filename); + } else { + xf86Msg(X_ERROR, "Unable to locate/open config file"); + if (xf86ConfigFile) + xf86ErrorFVerb(0, ": \"%s\"", xf86ConfigFile); + xf86ErrorFVerb(0, "\n"); + return CONFIG_NOFILE; + } + } + + if ((xf86configptr = xf86readConfigFile ()) == NULL) { + xf86Msg(X_ERROR, "Problem parsing the config file\n"); + return CONFIG_PARSE_ERROR; + } + xf86closeConfigFile (); + + /* Initialise a few things. */ + + /* + * now we convert part of the information contained in the parser + * structures into our own structures. + * The important part here is to figure out which Screen Sections + * in the XF86Config file are active so that we can piece together + * the modes that we need later down the road. + * And while we are at it, we'll decode the rest of the stuff as well + */ + + /* First check if a layout section is present, and if it is valid. */ + + if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) { + if (xf86ScreenName == NULL) { + xf86Msg(X_DEFAULT, + "No Layout section. Using the first Screen section.\n"); + } + if (!configImpliedLayout(&xf86ConfigLayout, + xf86configptr->conf_screen_lst)) { + xf86Msg(X_ERROR, "Unable to determine the screen layout\n"); + return CONFIG_PARSE_ERROR; + } + implicit_layout = TRUE; + } else { + if (xf86configptr->conf_flags != NULL) { + char *dfltlayout = NULL; + pointer optlist = xf86configptr->conf_flags->flg_option_lst; + + if (optlist && xf86FindOption(optlist, "defaultserverlayout")) + dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL); + if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst, + dfltlayout)) { + xf86Msg(X_ERROR, "Unable to determine the screen layout\n"); + return CONFIG_PARSE_ERROR; + } + } else { + if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst, + NULL)) { + xf86Msg(X_ERROR, "Unable to determine the screen layout\n"); + return CONFIG_PARSE_ERROR; + } + } + } + + xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions); + + if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) { + ; /* IsolateDevice specified; overrides SingleCard */ + } else { + xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard); + if (singlecard) + scanptr = xf86ConfigLayout.screens->screen->device->busID; + } + if (scanptr) { + int bus, device, func; + if (strncmp(scanptr, "PCI:", 4) != 0) { + xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n" + "\tIgnoring IsolateDevice option.\n"); + } else if (sscanf(scanptr, "PCI:%d:%d:%d", &bus, &device, &func) == 3) { + xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus); + xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus); + xf86IsolateDevice.dev = device; + xf86IsolateDevice.func = func; + xf86Msg(X_INFO, + "Isolating PCI bus \"%d:%d:%d\"\n", bus, device, func); + } + } + + /* Now process everything else */ + if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){ + ErrorF ("Problem when converting the config data structures\n"); + return CONFIG_PARSE_ERROR; + } + + configFiles(xf86configptr->conf_files); + configExtensions(xf86configptr->conf_extensions); +#ifdef XF86DRI + configDRI(xf86configptr->conf_dri); +#endif + + checkInput(&xf86ConfigLayout, implicit_layout); + + /* + * Handle some command line options that can override some of the + * ServerFlags settings. + */ +#ifdef XF86VIDMODE + if (xf86VidModeDisabled) + xf86Info.vidModeEnabled = FALSE; + if (xf86VidModeAllowNonLocal) + xf86Info.vidModeAllowNonLocal = TRUE; +#endif + +#ifdef XF86MISC + if (xf86MiscModInDevDisabled) + xf86Info.miscModInDevEnabled = FALSE; + if (xf86MiscModInDevAllowNonLocal) + xf86Info.miscModInDevAllowNonLocal = TRUE; +#endif + + if (xf86AllowMouseOpenFail) + xf86Info.allowMouseOpenFail = TRUE; + + return CONFIG_OK; +} + +Bool +xf86PathIsSafe(const char *path) +{ + return (xf86pathIsSafe(path) != 0); +} diff --git a/xorg-server/hw/xfree86/common/xf86Config.h b/xorg-server/hw/xfree86/common/xf86Config.h new file mode 100644 index 000000000..a174e463b --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Config.h @@ -0,0 +1,74 @@ + +/* + * Copyright (c) 1997-2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef _xf86_config_h +#define _xf86_config_h + +#include "xf86Optrec.h" +#include "xf86Parser.h" +#include "xf86str.h" + +#ifdef HAVE_PARSER_DECLS +/* + * global structure that holds the result of parsing the config file + */ +extern XF86ConfigPtr xf86configptr; +#endif + +typedef enum _ConfigStatus { + CONFIG_OK = 0, + CONFIG_PARSE_ERROR, + CONFIG_NOFILE +} ConfigStatus; + +typedef struct _ModuleDefault { + char *name; + Bool toLoad; + XF86OptionPtr load_opt; +} ModuleDefault; + +/* + * prototypes + */ +char ** xf86ModulelistFromConfig(pointer **); +char ** xf86DriverlistFromConfig(void); +char ** xf86DriverlistFromCompile(void); +char ** xf86InputDriverlistFromConfig(void); +Bool xf86BuiltinInputDriver(const char *); +ConfigStatus xf86HandleConfigFile(Bool); + +Bool xf86AutoConfig(void); +GDevPtr autoConfigDevice(GDevPtr preconf_device); +char* chooseVideoDriver(void); +int xchomp(char *line); + +#endif /* _xf86_config_h */ diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c new file mode 100644 index 000000000..536f89700 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Configure.c @@ -0,0 +1,940 @@ +/* + * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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: Alan Hourihane, alanh@fairlite.demon.co.uk + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Pci.h" +#include "os.h" +#include "loaderProcs.h" +#include "xf86.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xf86Priv.h" +#define IN_XSERVER +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include "vbe.h" +#include "xf86DDC.h" +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) +#include "xf86Bus.h" +#include "xf86Sbus.h" +#endif +#include "globals.h" + +typedef struct _DevToConfig { + GDevRec GDev; + struct pci_device * pVideo; +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + sbusDevicePtr sVideo; +#endif + int iDriver; +} DevToConfigRec, *DevToConfigPtr; + +static DevToConfigPtr DevToConfig = NULL; +static int nDevToConfig = 0, CurrentDriver; + +_X_EXPORT xf86MonPtr ConfiguredMonitor; +Bool xf86DoConfigurePass1 = TRUE; +static Bool foundMouse = FALSE; + +#if defined(__SCO__) +static char *DFLT_MOUSE_PROTO = "OSMouse"; +#elif defined(__UNIXWARE__) +static char *DFLT_MOUSE_PROTO = "OSMouse"; +static char *DFLT_MOUSE_DEV = "/dev/mouse"; +#elif defined(QNX4) +static char *DFLT_MOUSE_PROTO = "OSMouse"; +static char *DFLT_MOUSE_DEV = "/dev/mouse"; +#elif defined(__QNXNTO__) +static char *DFLT_MOUSE_PROTO = "OSMouse"; +static char *DFLT_MOUSE_DEV = "/dev/devi/mouse0"; +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +static char *DFLT_MOUSE_DEV = "/dev/sysmouse"; +static char *DFLT_MOUSE_PROTO = "auto"; +#elif defined(linux) +static char DFLT_MOUSE_DEV[] = "/dev/input/mice"; +static char DFLT_MOUSE_PROTO[] = "auto"; +#else +static char *DFLT_MOUSE_DEV = "/dev/mouse"; +static char *DFLT_MOUSE_PROTO = "auto"; +#endif + +/* + * This is called by the driver, either through xf86Match???Instances() or + * directly. We allocate a GDevRec and fill it in as much as we can, letting + * the caller fill in the rest and/or change it as it sees fit. + */ +GDevPtr +xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset) +{ + int i, j; + struct pci_device * pVideo = NULL; + Bool isPrimary = FALSE; + + if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1) + return NULL; + + /* Check for duplicates */ + switch (bus) { + case BUS_PCI: + pVideo = (struct pci_device *) busData; + for (i = 0; i < nDevToConfig; i++) + if (DevToConfig[i].pVideo && + (DevToConfig[i].pVideo->domain == pVideo->domain) && + (DevToConfig[i].pVideo->bus == pVideo->bus) && + (DevToConfig[i].pVideo->dev == pVideo->dev) && + (DevToConfig[i].pVideo->func == pVideo->func)) + return NULL; + isPrimary = xf86IsPrimaryPci(pVideo); + break; + case BUS_ISA: + /* + * This needs to be revisited as it doesn't allow for non-PCI + * multihead. + */ + if (!xf86IsPrimaryIsa()) + return NULL; + isPrimary = TRUE; + for (i = 0; i < nDevToConfig; i++) + if (!DevToConfig[i].pVideo) + return NULL; + break; +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + case BUS_SBUS: + for (i = 0; i < nDevToConfig; i++) + if (DevToConfig[i].sVideo && + DevToConfig[i].sVideo->fbNum == ((sbusDevicePtr) busData)->fbNum) + return NULL; + break; +#endif + default: + return NULL; + } + + /* Allocate new structure occurrence */ + i = nDevToConfig++; + DevToConfig = + xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); +#if 1 /* Doesn't work when a driver detects more than one adapter */ + if ((i > 0) && isPrimary) { + memmove(DevToConfig + 1,DevToConfig, + (nDevToConfig - 1) * sizeof(DevToConfigRec)); + i = 0; + } +#endif + memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); + +# define NewDevice DevToConfig[i] + + NewDevice.GDev.chipID = NewDevice.GDev.chipRev = NewDevice.GDev.irq = -1; + + NewDevice.iDriver = CurrentDriver; + + /* Fill in what we know, converting the driver name to lower case */ + NewDevice.GDev.driver = xnfalloc(strlen(driver) + 1); + for (j = 0; (NewDevice.GDev.driver[j] = tolower(driver[j])); j++); + + switch (bus) { + case BUS_PCI: { + const char *VendorName; + const char *CardName; + char busnum[8]; + + NewDevice.pVideo = pVideo; + + VendorName = pci_device_get_vendor_name( pVideo ); + CardName = pci_device_get_device_name( pVideo ); + + if (!VendorName) { + VendorName = xnfalloc(15); + sprintf((char*)VendorName, "Unknown Vendor"); + } + + if (!CardName) { + CardName = xnfalloc(14); + sprintf((char*)CardName, "Unknown Board"); + } + + NewDevice.GDev.identifier = + xnfalloc(strlen(VendorName) + strlen(CardName) + 2); + sprintf(NewDevice.GDev.identifier, "%s %s", VendorName, CardName); + + NewDevice.GDev.vendor = (char *)VendorName; + NewDevice.GDev.board = (char *)CardName; + + NewDevice.GDev.busID = xnfalloc(16); + xf86FormatPciBusNumber(pVideo->bus, busnum); + sprintf(NewDevice.GDev.busID, "PCI:%s:%d:%d", + busnum, pVideo->dev, pVideo->func); + + NewDevice.GDev.chipID = pVideo->device_id; + NewDevice.GDev.chipRev = pVideo->revision; + + if (chipset < 0) + chipset = (pVideo->vendor_id << 16) | pVideo->device_id; + } + break; + case BUS_ISA: + NewDevice.GDev.identifier = "ISA Adapter"; + NewDevice.GDev.busID = "ISA"; + break; +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + case BUS_SBUS: { + char *promPath = NULL; + NewDevice.sVideo = (sbusDevicePtr) busData; + NewDevice.GDev.identifier = NewDevice.sVideo->descr; + if (sparcPromInit() >= 0) { + promPath = sparcPromNode2Pathname(&NewDevice.sVideo->node); + sparcPromClose(); + } + if (promPath) { + NewDevice.GDev.busID = xnfalloc(strlen(promPath) + 6); + sprintf(NewDevice.GDev.busID, "SBUS:%s", promPath); + xfree(promPath); + } else { + NewDevice.GDev.busID = xnfalloc(12); + sprintf(NewDevice.GDev.busID, "SBUS:fb%d", NewDevice.sVideo->fbNum); + } + } + break; +#endif + default: + break; + } + + /* Get driver's available options */ + if (xf86DriverList[CurrentDriver]->AvailableOptions) + NewDevice.GDev.options = (OptionInfoPtr) + (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset, + bus); + + return &NewDevice.GDev; + +# undef NewDevice +} + +/* + * Backwards compatibility + */ +_X_EXPORT GDevPtr +xf86AddDeviceToConfigure(const char *driver, struct pci_device * pVideo, + int chipset) +{ + return xf86AddBusDeviceToConfigure(driver, pVideo ? BUS_PCI : BUS_ISA, + pVideo, chipset); +} + +static XF86ConfInputPtr +configureInputSection (void) +{ + XF86ConfInputPtr mouse = NULL; + parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) + + ptr->inp_identifier = "Keyboard0"; + ptr->inp_driver = "kbd"; + ptr->list.next = NULL; + + /* Crude mechanism to auto-detect mouse (os dependent) */ + { + int fd; +#ifdef WSCONS_SUPPORT + fd = open("/dev/wsmouse", 0); + if (fd > 0) { + DFLT_MOUSE_DEV = "/dev/wsmouse"; + DFLT_MOUSE_PROTO = "wsmouse"; + close(fd); + } else { + ErrorF("cannot open /dev/wsmouse\n"); + } +#endif + +#ifndef __SCO__ + fd = open(DFLT_MOUSE_DEV, 0); + if (fd != -1) { + foundMouse = TRUE; + close(fd); + } +#else + foundMouse = TRUE; +#endif + } + + mouse = xf86confmalloc(sizeof(XF86ConfInputRec)); + memset((XF86ConfInputPtr)mouse,0,sizeof(XF86ConfInputRec)); + mouse->inp_identifier = "Mouse0"; + mouse->inp_driver = "mouse"; + mouse->inp_option_lst = + xf86addNewOption(mouse->inp_option_lst, xstrdup("Protocol"), + xstrdup(DFLT_MOUSE_PROTO)); +#ifndef __SCO__ + mouse->inp_option_lst = + xf86addNewOption(mouse->inp_option_lst, xstrdup("Device"), + xstrdup(DFLT_MOUSE_DEV)); +#endif + mouse->inp_option_lst = + xf86addNewOption(mouse->inp_option_lst, xstrdup("ZAxisMapping"), + xstrdup("4 5 6 7")); + ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse); + return ptr; +} + +static XF86ConfScreenPtr +configureScreenSection (int screennum) +{ + int i; + int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ }; + parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec) + + ptr->scrn_identifier = xf86confmalloc(18); + sprintf(ptr->scrn_identifier, "Screen%d", screennum); + ptr->scrn_monitor_str = xf86confmalloc(19); + sprintf(ptr->scrn_monitor_str, "Monitor%d", screennum); + ptr->scrn_device_str = xf86confmalloc(16); + sprintf(ptr->scrn_device_str, "Card%d", screennum); + + for (i=0; idisp_depth = depths[i]; + display->disp_black.red = display->disp_white.red = -1; + display->disp_black.green = display->disp_white.green = -1; + display->disp_black.blue = display->disp_white.blue = -1; + ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem( + (glp)ptr->scrn_display_lst, (glp)display); + } + + return ptr; +} + +static const char* +optionTypeToSting(OptionValueType type) +{ + switch (type) { + case OPTV_NONE: + return ""; + case OPTV_INTEGER: + return ""; + case OPTV_STRING: + return ""; + case OPTV_ANYSTR: + return "[]"; + case OPTV_REAL: + return ""; + case OPTV_BOOLEAN: + return "[]"; + case OPTV_FREQ: + return ""; + default: + return ""; + } +} + +static XF86ConfDevicePtr +configureDeviceSection (int screennum) +{ + char identifier[16]; + OptionInfoPtr p; + int i = 0; + parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec) + + /* Move device info to parser structure */ + sprintf(identifier, "Card%d", screennum); + ptr->dev_identifier = strdup(identifier); +/* ptr->dev_identifier = DevToConfig[screennum].GDev.identifier;*/ + ptr->dev_vendor = DevToConfig[screennum].GDev.vendor; + ptr->dev_board = DevToConfig[screennum].GDev.board; + ptr->dev_chipset = DevToConfig[screennum].GDev.chipset; + ptr->dev_busid = DevToConfig[screennum].GDev.busID; + ptr->dev_driver = DevToConfig[screennum].GDev.driver; + ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac; + for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++) + ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i]; + ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam; + ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq; + ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase; + ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase; + ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase; + ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip; + for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++) + ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i]; + ptr->dev_clocks = i; + ptr->dev_chipid = DevToConfig[screennum].GDev.chipID; + ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev; + ptr->dev_irq = DevToConfig[screennum].GDev.irq; + + /* Make sure older drivers don't segv */ + if (DevToConfig[screennum].GDev.options) { + /* Fill in the available driver options for people to use */ + const char *descrip = + " ### Available Driver options are:-\n" + " ### Values: : integer, : float, " + ": \"True\"/\"False\",\n" + " ### : \"String\", : \" Hz/kHz/MHz\"\n" + " ### [arg]: arg optional\n"; + ptr->dev_comment = xstrdup(descrip); + if (ptr->dev_comment) { + for (p = DevToConfig[screennum].GDev.options; + p->name != NULL; p++) { + char *p_e; + const char *prefix = " #Option "; + const char *middle = " \t# "; + const char *suffix = "\n"; + const char *opttype = optionTypeToSting(p->type); + char *optname; + int len = strlen(ptr->dev_comment) + strlen(prefix) + + strlen(middle) + strlen(suffix) + 1; + + optname = xalloc(strlen(p->name) + 2 + 1); + if (!optname) + break; + sprintf(optname, "\"%s\"", p->name); + + len += max(20, strlen(optname)); + len += strlen(opttype); + + ptr->dev_comment = xrealloc(ptr->dev_comment, len); + if (!ptr->dev_comment) + break; + p_e = ptr->dev_comment + strlen(ptr->dev_comment); + sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle, + opttype, suffix); + xfree(optname); + } + } + } + + return ptr; +} + +static XF86ConfLayoutPtr +configureLayoutSection (void) +{ + int scrnum = 0; + parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec) + + ptr->lay_identifier = "X.org Configured"; + + { + XF86ConfInputrefPtr iptr; + + iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec)); + iptr->list.next = NULL; + iptr->iref_option_lst = NULL; + iptr->iref_inputdev_str = "Mouse0"; + iptr->iref_option_lst = + xf86addNewOption (iptr->iref_option_lst, xstrdup("CorePointer"), NULL); + ptr->lay_input_lst = (XF86ConfInputrefPtr) + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + } + + { + XF86ConfInputrefPtr iptr; + + iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec)); + iptr->list.next = NULL; + iptr->iref_option_lst = NULL; + iptr->iref_inputdev_str = "Keyboard0"; + iptr->iref_option_lst = + xf86addNewOption (iptr->iref_option_lst, xstrdup("CoreKeyboard"), NULL); + ptr->lay_input_lst = (XF86ConfInputrefPtr) + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + } + + for (scrnum = 0; scrnum < nDevToConfig; scrnum++) { + XF86ConfAdjacencyPtr aptr; + + aptr = xf86confmalloc (sizeof (XF86ConfAdjacencyRec)); + aptr->list.next = NULL; + aptr->adj_x = 0; + aptr->adj_y = 0; + aptr->adj_scrnum = scrnum; + aptr->adj_screen_str = xnfalloc(18); + sprintf(aptr->adj_screen_str, "Screen%d", scrnum); + if (scrnum == 0) { + aptr->adj_where = CONF_ADJ_ABSOLUTE; + aptr->adj_refscreen = NULL; + } + else { + aptr->adj_where = CONF_ADJ_RIGHTOF; + aptr->adj_refscreen = xnfalloc(18); + sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1); + } + ptr->lay_adjacency_lst = + (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst, + (glp)aptr); + } + + return ptr; +} + +static XF86ConfFlagsPtr +configureFlagsSection (void) +{ + parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec) + + return ptr; +} + +static XF86ConfModulePtr +configureModuleSection (void) +{ + char **elist, **el; + /* Find the list of extension modules. */ + const char *esubdirs[] = { + "extensions", + NULL + }; + const char *fsubdirs[] = { + "fonts", + NULL + }; + parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec) + + elist = LoaderListDirs(esubdirs, NULL); + if (elist) { + for (el = elist; *el; el++) { + XF86LoadPtr module; + + module = xf86confmalloc(sizeof(XF86LoadRec)); + memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec)); + module->load_name = *el; + ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem( + (glp)ptr->mod_load_lst, (glp)module); + } + xfree(elist); + } + + /* Process list of font backends separately to include only required ones */ + elist = LoaderListDirs(fsubdirs, NULL); + if (elist) { + for (el = elist; *el; el++) { + XF86LoadPtr module; + + module = xf86confmalloc(sizeof(XF86LoadRec)); + memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec)); + module->load_name = *el; + + /* Add only those font backends which are referenced by fontpath */ + /* 'strstr(dFP,"/dir")' is meant as 'dFP =~ m(/dir\W)' */ + if (defaultFontPath && ( + (strcmp(*el, "freetype") == 0 && + strstr(defaultFontPath, "/TTF")) || + (strcmp(*el, "type1") == 0 && + strstr(defaultFontPath, "/Type1")))) + ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem( + (glp)ptr->mod_load_lst, (glp)module); + } + xfree(elist); + } + + return ptr; +} + +static XF86ConfFilesPtr +configureFilesSection (void) +{ + parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec) + + if (xf86ModulePath) + ptr->file_modulepath = strdup(xf86ModulePath); + if (defaultFontPath) + ptr->file_fontpath = strdup(defaultFontPath); + + return ptr; +} + +static XF86ConfMonitorPtr +configureMonitorSection (int screennum) +{ + parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) + + ptr->mon_identifier = xf86confmalloc(19); + sprintf(ptr->mon_identifier, "Monitor%d", screennum); + ptr->mon_vendor = strdup("Monitor Vendor"); + ptr->mon_modelname = strdup("Monitor Model"); + + return ptr; +} + +static XF86ConfMonitorPtr +configureDDCMonitorSection (int screennum) +{ + int i = 0; + int len, mon_width, mon_height; +#define displaySizeMaxLen 80 + char displaySize_string[displaySizeMaxLen]; + int displaySizeLen; + + parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) + + ptr->mon_identifier = xf86confmalloc(19); + sprintf(ptr->mon_identifier, "Monitor%d", screennum); + ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name); + ptr->mon_modelname = xf86confmalloc(12); + sprintf(ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id); + + /* features in centimetres, we want millimetres */ + mon_width = 10 * ConfiguredMonitor->features.hsize ; + mon_height = 10 * ConfiguredMonitor->features.vsize ; + +#ifdef CONFIGURE_DISPLAYSIZE + ptr->mon_width = mon_width; + ptr->mon_height = mon_height; +#else + if (mon_width && mon_height) { + /* when values available add DisplaySize option AS A COMMENT */ + + displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen, + "\t#DisplaySize\t%5d %5d\t# mm\n", + mon_width, mon_height); + + if (displaySizeLen>0 && displaySizeLenmon_comment) { + len = strlen(ptr->mon_comment); + } else { + len = 0; + } + if ((ptr->mon_comment = + xf86confrealloc(ptr->mon_comment, + len+strlen(displaySize_string)))) { + strcpy(ptr->mon_comment + len, displaySize_string); + } + } + } +#endif /* def CONFIGURE_DISPLAYSIZE */ + + for (i=0;i<4;i++) { + switch (ConfiguredMonitor->det_mon[i].type) { + case DS_NAME: + ptr->mon_modelname = xf86confrealloc(ptr->mon_modelname, + strlen((char*)(ConfiguredMonitor->det_mon[i].section.name)) + + 1); + strcpy(ptr->mon_modelname, + (char*)(ConfiguredMonitor->det_mon[i].section.name)); + break; + case DS_RANGES: + ptr->mon_hsync[ptr->mon_n_hsync].lo = + ConfiguredMonitor->det_mon[i].section.ranges.min_h; + ptr->mon_hsync[ptr->mon_n_hsync].hi = + ConfiguredMonitor->det_mon[i].section.ranges.max_h; + ptr->mon_n_vrefresh = 1; + ptr->mon_vrefresh[ptr->mon_n_hsync].lo = + ConfiguredMonitor->det_mon[i].section.ranges.min_v; + ptr->mon_vrefresh[ptr->mon_n_hsync].hi = + ConfiguredMonitor->det_mon[i].section.ranges.max_v; + ptr->mon_n_hsync++; + default: + break; + } + } + + if (ConfiguredMonitor->features.dpms) { + ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, xstrdup("DPMS"), NULL); + } + + return ptr; +} + +void +DoConfigure() +{ + int i,j, screennum = -1; + char *home = NULL; + char *filename = NULL; + XF86ConfigPtr xf86config = NULL; + char **vlist, **vl; + int *dev2screen; + + vlist = xf86DriverlistFromCompile(); + + if (!vlist) { + ErrorF("Missing output drivers. Configuration failed.\n"); + goto bail; + } + + ErrorF("List of video drivers:\n"); + for (vl = vlist; *vl; vl++) + ErrorF("\t%s\n", *vl); + + /* Load all the drivers that were found. */ + xf86LoadModules(vlist, NULL); + + xfree(vlist); + + for (i = 0; i < xf86NumDrivers; i++) { + xorgHWFlags flags; + if (!xf86DriverList[i]->driverFunc + || !xf86DriverList[i]->driverFunc(NULL, + GET_REQUIRED_HW_INTERFACES, + &flags) + || NEED_IO_ENABLED(flags)) { + xorgHWAccess = TRUE; + break; + } + } + /* Enable full I/O access */ + if (xorgHWAccess) { + if(!xf86EnableIO()) + /* oops, we have failed */ + xorgHWAccess = FALSE; + } + + /* Disable PCI devices */ + xf86ResourceBrokerInit(); + xf86AccessInit(); + xf86FindPrimaryDevice(); + + /* Create XF86Config file structure */ + xf86config = malloc(sizeof(XF86ConfigRec)); + memset ((XF86ConfigPtr)xf86config, 0, sizeof(XF86ConfigRec)); + xf86config->conf_device_lst = NULL; + xf86config->conf_screen_lst = NULL; + xf86config->conf_monitor_lst = NULL; + + /* Call all of the probe functions, reporting the results. */ + for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) { + xorgHWFlags flags; + Bool found_screen; + DriverRec * const drv = xf86DriverList[CurrentDriver]; + + if (!xorgHWAccess) { + if (!drv->driverFunc + || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags ) + || NEED_IO_ENABLED(flags)) + continue; + } + + found_screen = xf86CallDriverProbe( drv, TRUE ); + if ( found_screen && drv->Identify ) { + (*drv->Identify)(0); + } + } + + if (nDevToConfig <= 0) { + ErrorF("No devices to configure. Configuration failed.\n"); + goto bail; + } + + /* Add device, monitor and screen sections for detected devices */ + for (screennum = 0; screennum < nDevToConfig; screennum++) { + XF86ConfDevicePtr DevicePtr; + XF86ConfMonitorPtr MonitorPtr; + XF86ConfScreenPtr ScreenPtr; + + DevicePtr = configureDeviceSection(screennum); + xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem( + (glp)xf86config->conf_device_lst, (glp)DevicePtr); + MonitorPtr = configureMonitorSection(screennum); + xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem( + (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr); + ScreenPtr = configureScreenSection(screennum); + xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem( + (glp)xf86config->conf_screen_lst, (glp)ScreenPtr); + } + + xf86config->conf_files = configureFilesSection(); + xf86config->conf_modules = configureModuleSection(); + xf86config->conf_flags = configureFlagsSection(); + xf86config->conf_videoadaptor_lst = NULL; + xf86config->conf_modes_lst = NULL; + xf86config->conf_vendor_lst = NULL; + xf86config->conf_dri = NULL; + xf86config->conf_input_lst = configureInputSection(); + xf86config->conf_layout_lst = configureLayoutSection(); + + if (!(home = getenv("HOME"))) + home = "/"; + { +#if !defined(PATH_MAX) +#define PATH_MAX 1024 +#endif + const char* configfile = XF86CONFIGFILE".new"; + char homebuf[PATH_MAX]; + /* getenv might return R/O memory, as with OS/2 */ + strncpy(homebuf,home,PATH_MAX-1); + homebuf[PATH_MAX-1] = '\0'; + home = homebuf; + if (!(filename = + (char *)xalloc(strlen(home) + + strlen(configfile) + 3))) + + if (home[0] == '/' && home[1] == '\0') + home[0] = '\0'; +#ifndef QNX4 + sprintf(filename, "%s/%s", home,configfile); +#else + sprintf(filename, "//%d%s/%s", getnid(),home,configfile); +#endif + + } + + xf86writeConfigFile(filename, xf86config); + + xf86DoConfigurePass1 = FALSE; + /* Try to get DDC information filled in */ + xf86ConfigFile = filename; + if (xf86HandleConfigFile(FALSE) != CONFIG_OK) { + goto bail; + } + + xf86DoConfigurePass1 = FALSE; + + dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int)); + + { + Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool)); + for (screennum = 0; screennum < nDevToConfig; screennum++) { + int k,l,n,oldNumScreens; + + i = DevToConfig[screennum].iDriver; + + if (driverProbed[i]) continue; + driverProbed[i] = TRUE; + + oldNumScreens = xf86NumScreens; + + xf86CallDriverProbe( xf86DriverList[i], FALSE ); + + /* reorder */ + k = screennum > 0 ? screennum : 1; + for (l = oldNumScreens; l < xf86NumScreens; l++) { + /* is screen primary? */ + Bool primary = FALSE; + for (n = 0; nnumEntities; n++) { + if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) { + dev2screen[0] = l; + primary = TRUE; + break; + } + } + if (primary) continue; + /* not primary: assign it to next device of same driver */ + /* + * NOTE: we assume that devices in DevToConfig + * and xf86Screens[] have the same order except + * for the primary device which always comes first. + */ + for (; k < nDevToConfig; k++) { + if (DevToConfig[k].iDriver == i) { + dev2screen[k++] = l; + break; + } + } + } + } + xfree(driverProbed); + } + + + if (nDevToConfig != xf86NumScreens) { + ErrorF("Number of created screens does not match number of detected" + " devices.\n Configuration failed.\n"); + goto bail; + } + + xf86PostProbe(); + xf86EntityInit(); + + for (j = 0; j < xf86NumScreens; j++) { + xf86Screens[j]->scrnIndex = j; + } + + xf86freeMonitorList(xf86config->conf_monitor_lst); + xf86config->conf_monitor_lst = NULL; + xf86freeScreenList(xf86config->conf_screen_lst); + xf86config->conf_screen_lst = NULL; + for (j = 0; j < xf86NumScreens; j++) { + XF86ConfMonitorPtr MonitorPtr; + XF86ConfScreenPtr ScreenPtr; + + ConfiguredMonitor = NULL; + + xf86EnableAccess(xf86Screens[dev2screen[j]]); + if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]], + PROBE_DETECT) && + ConfiguredMonitor) { + MonitorPtr = configureDDCMonitorSection(j); + } else { + MonitorPtr = configureMonitorSection(j); + } + ScreenPtr = configureScreenSection(j); + xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem( + (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr); + xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem( + (glp)xf86config->conf_screen_lst, (glp)ScreenPtr); + } + + xf86writeConfigFile(filename, xf86config); + + ErrorF("\n"); + +#ifdef __SCO__ + ErrorF("\n"__XSERVERNAME__ + " is using the kernel event driver to access the mouse.\n" + "If you wish to use the internal "__XSERVERNAME__ + " mouse drivers, please\n" + "edit the file and correct the Device.\n"); +#else /* !__SCO__ */ + if (!foundMouse) { + ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n" + "Edit the file and correct the Device.\n"); + } else { + ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n" + "Please check your config if the mouse is still not\n" + "operational, as by default "__XSERVERNAME__ + " tries to autodetect\n" + "the protocol.\n",DFLT_MOUSE_DEV); + } +#endif /* !__SCO__ */ + + if (xf86NumScreens > 1) { + ErrorF("\n"__XSERVERNAME__ + " has configured a multihead system, please check your config.\n"); + } + + ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename); + ErrorF("To test the server, run 'X -config %s'\n\n", filename); + +bail: + OsCleanup(TRUE); + AbortDDX(); + fflush(stderr); + exit(0); +} diff --git a/xorg-server/hw/xfree86/common/xf86Cursor.c b/xorg-server/hw/xfree86/common/xf86Cursor.c new file mode 100644 index 000000000..3ea1b4d91 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Cursor.c @@ -0,0 +1,820 @@ +/* + * Copyright (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#define NEED_EVENTS +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include "input.h" +#include "cursor.h" +#include "mipointer.h" +#include "scrnintstr.h" +#include "globals.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSproc.h" + +#ifdef XINPUT +#include +#include "xf86Xinput.h" +#endif + +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +typedef struct _xf86EdgeRec { + short screen; + short start; + short end; + DDXPointRec offset; + struct _xf86EdgeRec *next; +} xf86EdgeRec, *xf86EdgePtr; + +typedef struct { + xf86EdgePtr left, right, up, down; +} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr; + +static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y); +static void xf86CrossScreen(ScreenPtr pScreen, Bool entering); +static void xf86WarpCursor(ScreenPtr pScreen, int x, int y); + +static void xf86PointerMoved(int scrnIndex, int x, int y); + +static miPointerScreenFuncRec xf86PointerScreenFuncs = { + xf86CursorOffScreen, + xf86CrossScreen, + xf86WarpCursor, + /* let miPointerInitialize take care of these */ + NULL, + NULL +}; + +static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS]; + +static Bool HardEdges; + +/* + * xf86InitViewport -- + * Initialize paning & zooming parameters, so that a driver must only + * check what resolutions are possible and whether the virtual area + * is valid if specified. + */ + +void +xf86InitViewport(ScrnInfoPtr pScr) +{ + + pScr->PointerMoved = xf86PointerMoved; + + /* + * Compute the initial Viewport if necessary + */ + if (pScr->display) { + if (pScr->display->frameX0 < 0) { + pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2; + pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2; + } else { + pScr->frameX0 = pScr->display->frameX0; + pScr->frameY0 = pScr->display->frameY0; + } + } + + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + + /* + * Now adjust the initial Viewport, so it lies within the virtual area + */ + if (pScr->frameX1 >= pScr->virtualX) + { + pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay; + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + } + + if (pScr->frameY1 >= pScr->virtualY) + { + pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + } +} + + +/* + * xf86SetViewport -- + * Scroll the visual part of the screen so the pointer is visible. + */ + +void +xf86SetViewport(ScreenPtr pScreen, int x, int y) +{ + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + + (*pScr->PointerMoved)(pScreen->myNum, x, y); +} + + +static void +xf86PointerMoved(int scrnIndex, int x, int y) +{ + Bool frameChanged = FALSE; + ScrnInfoPtr pScr = xf86Screens[scrnIndex]; + + /* + * check wether (x,y) belongs to the visual part of the screen + * if not, change the base of the displayed frame accoring + */ + if ( pScr->frameX0 > x) { + pScr->frameX0 = x; + pScr->frameX1 = x + pScr->currentMode->HDisplay - 1; + frameChanged = TRUE ; + } + + if ( pScr->frameX1 < x) { + pScr->frameX1 = x + 1; + pScr->frameX0 = x - pScr->currentMode->HDisplay + 1; + frameChanged = TRUE ; + } + + if ( pScr->frameY0 > y) { + pScr->frameY0 = y; + pScr->frameY1 = y + pScr->currentMode->VDisplay - 1; + frameChanged = TRUE; + } + + if ( pScr->frameY1 < y) { + pScr->frameY1 = y; + pScr->frameY0 = y - pScr->currentMode->VDisplay + 1; + frameChanged = TRUE; + } + + if (frameChanged && pScr->AdjustFrame != NULL) + pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0); +} + +/* + * xf86LockZoom -- + * Enable/disable ZoomViewport + */ + +void +xf86LockZoom(ScreenPtr pScreen, Bool lock) +{ + XF86SCRNINFO(pScreen)->zoomLocked = lock; +} + +/* + * xf86SwitchMode -- + * This is called by both keyboard processing and the VidMode extension to + * set a new mode. + */ + +Bool +xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode) +{ + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + ScreenPtr pCursorScreen; + Bool Switched; + int px, py; + + if (!pScr->vtSema || !mode || !pScr->SwitchMode) + return FALSE; + +#ifdef XFreeXDGA + if (DGAActive(pScr->scrnIndex)) + return FALSE; +#endif + + if (mode == pScr->currentMode) + return TRUE; + + if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY) + return FALSE; + + pCursorScreen = miPointerGetScreen(inputInfo.pointer); + if (pScreen == pCursorScreen) + miPointerGetPosition(inputInfo.pointer, &px, &py); + + xf86EnterServerState(SETUP); + Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0); + if (Switched) { + pScr->currentMode = mode; + + /* + * Adjust frame for new display size. + */ + if (pScreen == pCursorScreen) + pScr->frameX0 = px - (mode->HDisplay / 2) + 1; + else + pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2; + + if (pScr->frameX0 < 0) + pScr->frameX0 = 0; + + pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1; + if (pScr->frameX1 >= pScr->virtualX) { + pScr->frameX0 = pScr->virtualX - mode->HDisplay; + pScr->frameX1 = pScr->virtualX - 1; + } + + if (pScreen == pCursorScreen) + pScr->frameY0 = py - (mode->VDisplay / 2) + 1; + else + pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2; + + if (pScr->frameY0 < 0) + pScr->frameY0 = 0; + + pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1; + if (pScr->frameY1 >= pScr->virtualY) { + pScr->frameY0 = pScr->virtualY - mode->VDisplay; + pScr->frameY1 = pScr->virtualY - 1; + } + } + xf86EnterServerState(OPERATING); + + if (pScr->AdjustFrame) + (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0); + + if (pScreen == pCursorScreen) + xf86WarpCursor(pScreen, px, py); + + return Switched; +} + +/* + * xf86ZoomViewport -- + * Reinitialize the visual part of the screen for another mode. + */ + +void +xf86ZoomViewport(ScreenPtr pScreen, int zoom) +{ + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + DisplayModePtr mode; + + if (pScr->zoomLocked || !(mode = pScr->currentMode)) + return; + + do { + if (zoom > 0) + mode = mode->next; + else + mode = mode->prev; + } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF)); + + (void)xf86SwitchMode(pScreen, mode); +} + + +static xf86EdgePtr +FindEdge(xf86EdgePtr edge, int val) +{ + while(edge && (edge->end <= val)) + edge = edge->next; + + if(edge && (edge->start <= val)) + return edge; + + return NULL; +} + +/* + * xf86CursorOffScreen -- + * Check whether it is necessary to switch to another screen + */ + +static Bool +xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y) +{ + xf86EdgePtr edge; + int tmp; + + if(screenInfo.numScreens == 1) + return FALSE; + + if(*x < 0) { + tmp = *y; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].left)) + edge = FindEdge(edge, tmp); + + if(!edge) *x = 0; + else { + *x += edge->offset.x; + *y += edge->offset.y; + *pScreen = xf86Screens[edge->screen]->pScreen; + } + } + + if(*x >= (*pScreen)->width) { + tmp = *y; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].right)) + edge = FindEdge(edge, tmp); + + if(!edge) *x = (*pScreen)->width - 1; + else { + *x += edge->offset.x; + *y += edge->offset.y; + *pScreen = xf86Screens[edge->screen]->pScreen; + } + } + + if(*y < 0) { + tmp = *x; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].up)) + edge = FindEdge(edge, tmp); + + if(!edge) *y = 0; + else { + *x += edge->offset.x; + *y += edge->offset.y; + *pScreen = xf86Screens[edge->screen]->pScreen; + } + } + + if(*y >= (*pScreen)->height) { + tmp = *x; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].down)) + edge = FindEdge(edge, tmp); + + if(!edge) *y = (*pScreen)->height - 1; + else { + *x += edge->offset.x; + *y += edge->offset.y; + (*pScreen) = xf86Screens[edge->screen]->pScreen; + } + } + + +#if 0 + /* This presents problems for overlapping screens when + HardEdges is used. Have to think about the logic more */ + if((*x < 0) || (*x >= (*pScreen)->width) || + (*y < 0) || (*y >= (*pScreen)->height)) { + /* We may have crossed more than one screen */ + xf86CursorOffScreen(pScreen, x, y); + } +#endif + + return TRUE; +} + + + +/* + * xf86CrossScreen -- + * Switch to another screen + * + * Currently nothing special happens, but mi assumes the CrossScreen + * method exists. + */ + +static void +xf86CrossScreen (ScreenPtr pScreen, Bool entering) +{ +} + + +/* + * xf86WarpCursor -- + * Warp possible to another screen + */ + +/* ARGSUSED */ +static void +xf86WarpCursor (ScreenPtr pScreen, int x, int y) +{ + int sigstate; + sigstate = xf86BlockSIGIO (); + miPointerWarpCursor(pScreen,x,y); + + xf86Info.currentScreen = pScreen; + xf86UnblockSIGIO (sigstate); +} + + +_X_EXPORT void * +xf86GetPointerScreenFuncs(void) +{ + return (void *)&xf86PointerScreenFuncs; +} + + +static xf86EdgePtr +AddEdge( + xf86EdgePtr edge, + short min, + short max, + short dx, + short dy, + short screen +){ + xf86EdgePtr pEdge = edge, pPrev = NULL, pNew; + + while(1) { + while(pEdge && (min >= pEdge->end)) { + pPrev = pEdge; + pEdge = pEdge->next; + } + + if(!pEdge) { + if(!(pNew = xalloc(sizeof(xf86EdgeRec)))) + break; + + pNew->screen = screen; + pNew->start = min; + pNew->end = max; + pNew->offset.x = dx; + pNew->offset.y = dy; + pNew->next = NULL; + + if(pPrev) + pPrev->next = pNew; + else + edge = pNew; + + break; + } else if (min < pEdge->start) { + if(!(pNew = xalloc(sizeof(xf86EdgeRec)))) + break; + + pNew->screen = screen; + pNew->start = min; + pNew->offset.x = dx; + pNew->offset.y = dy; + pNew->next = pEdge; + + if(pPrev) pPrev->next = pNew; + else edge = pNew; + + if(max <= pEdge->start) { + pNew->end = max; + break; + } else { + pNew->end = pEdge->start; + min = pEdge->end; + } + } else + min = pEdge->end; + + pPrev = pEdge; + pEdge = pEdge->next; + + if(max <= min) break; + } + + return edge; +} + +static void +FillOutEdge(xf86EdgePtr pEdge, int limit) +{ + xf86EdgePtr pNext; + int diff; + + if(pEdge->start > 0) pEdge->start = 0; + + while((pNext = pEdge->next)) { + diff = pNext->start - pEdge->end; + if(diff > 0) { + pEdge->end += diff >> 1; + pNext->start -= diff - (diff >> 1); + } + pEdge = pNext; + } + + if(pEdge->end < limit) + pEdge->end = limit; +} + +/* + * xf86InitOrigins() can deal with a maximum of 32 screens + * on 32 bit architectures, 64 on 64 bit architectures. + */ + +void +xf86InitOrigins(void) +{ + unsigned long screensLeft, prevScreensLeft, mask; + screenLayoutPtr screen; + ScreenPtr pScreen; + int x1, x2, y1, y2, left, right, top, bottom; + int i, j, ref, minX, minY, min, max; + xf86ScreenLayoutPtr pLayout; + Bool OldStyleConfig = FALSE; + + /* need to have this set up with a config file option */ + HardEdges = FALSE; + + bzero(xf86ScreenLayout, MAXSCREENS * sizeof(xf86ScreenLayoutRec)); + + screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1; + + while(1) { + for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) { + if(!(mask & 1L)) continue; + + screen = &xf86ConfigLayout.screens[i]; + + if (screen->refscreen != NULL && + screen->refscreen->screennum >= xf86NumScreens) { + screensLeft &= ~(1 << i); + xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n", + screen->screen->id); + continue; + } + + switch(screen->where) { + case PosObsolete: + OldStyleConfig = TRUE; + pLayout = &xf86ScreenLayout[i]; + /* force edge lists */ + if(screen->left) { + ref = screen->left->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pLayout->left = AddEdge(pLayout->left, + 0, xf86Screens[i]->pScreen->height, + xf86Screens[ref]->pScreen->width, 0, ref); + } + if(screen->right) { + ref = screen->right->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pScreen = xf86Screens[i]->pScreen; + pLayout->right = AddEdge(pLayout->right, + 0, pScreen->height, -pScreen->width, 0, ref); + } + if(screen->top) { + ref = screen->top->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pLayout->up = AddEdge(pLayout->up, + 0, xf86Screens[i]->pScreen->width, + 0, xf86Screens[ref]->pScreen->height, ref); + } + if(screen->bottom) { + ref = screen->bottom->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pScreen = xf86Screens[i]->pScreen; + pLayout->down = AddEdge(pLayout->down, + 0, pScreen->width, 0, -pScreen->height, ref); + } + /* we could also try to place it based on those + relative locations if we wanted to */ + screen->x = screen->y = 0; + /* FALLTHROUGH */ + case PosAbsolute: + dixScreenOrigins[i].x = screen->x; + dixScreenOrigins[i].y = screen->y; + screensLeft &= ~(1 << i); + break; + case PosRelative: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x; + dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y; + screensLeft &= ~(1 << i); + break; + case PosRightOf: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + pScreen = xf86Screens[ref]->pScreen; + dixScreenOrigins[i].x = + dixScreenOrigins[ref].x + pScreen->width; + dixScreenOrigins[i].y = dixScreenOrigins[ref].y; + screensLeft &= ~(1 << i); + break; + case PosLeftOf: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + pScreen = xf86Screens[i]->pScreen; + dixScreenOrigins[i].x = + dixScreenOrigins[ref].x - pScreen->width; + dixScreenOrigins[i].y = dixScreenOrigins[ref].y; + screensLeft &= ~(1 << i); + break; + case PosBelow: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + pScreen = xf86Screens[ref]->pScreen; + dixScreenOrigins[i].x = dixScreenOrigins[ref].x; + dixScreenOrigins[i].y = + dixScreenOrigins[ref].y + pScreen->height; + screensLeft &= ~(1 << i); + break; + case PosAbove: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + pScreen = xf86Screens[i]->pScreen; + dixScreenOrigins[i].x = dixScreenOrigins[ref].x; + dixScreenOrigins[i].y = + dixScreenOrigins[ref].y - pScreen->height; + screensLeft &= ~(1 << i); + break; + default: + ErrorF("Illegal placement keyword in Layout!\n"); + break; + } + + } + + if(!screensLeft) break; + + if(screensLeft == prevScreensLeft) { + /* All the remaining screens are referencing each other. + Assign a value to one of them and go through again */ + i = 0; + while(!((1 << i) & screensLeft)){ i++; } + + ref = xf86ConfigLayout.screens[i].refscreen->screennum; + dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0; + screensLeft &= ~(1 << ref); + } + + prevScreensLeft = screensLeft; + } + + /* justify the topmost and leftmost to (0,0) */ + minX = dixScreenOrigins[0].x; + minY = dixScreenOrigins[0].y; + + for(i = 1; i < xf86NumScreens; i++) { + if(dixScreenOrigins[i].x < minX) + minX = dixScreenOrigins[i].x; + if(dixScreenOrigins[i].y < minY) + minY = dixScreenOrigins[i].y; + } + + if (minX || minY) { + for(i = 0; i < xf86NumScreens; i++) { + dixScreenOrigins[i].x -= minX; + dixScreenOrigins[i].y -= minY; + } + } + + + /* Create the edge lists */ + + if(!OldStyleConfig) { + for(i = 0; i < xf86NumScreens; i++) { + pLayout = &xf86ScreenLayout[i]; + + pScreen = xf86Screens[i]->pScreen; + + left = dixScreenOrigins[i].x; + right = left + pScreen->width; + top = dixScreenOrigins[i].y; + bottom = top + pScreen->height; + + for(j = 0; j < xf86NumScreens; j++) { + if(i == j) continue; + + x1 = dixScreenOrigins[j].x; + x2 = x1 + xf86Screens[j]->pScreen->width; + y1 = dixScreenOrigins[j].y; + y2 = y1 + xf86Screens[j]->pScreen->height; + + if((bottom > y1) && (top < y2)) { + min = y1 - top; + if(min < 0) min = 0; + max = pScreen->height - (bottom - y2); + if(max > pScreen->height) max = pScreen->height; + + if(((left - 1) >= x1) && ((left - 1) < x2)) + pLayout->left = AddEdge(pLayout->left, min, max, + dixScreenOrigins[i].x - dixScreenOrigins[j].x, + dixScreenOrigins[i].y - dixScreenOrigins[j].y, j); + + if((right >= x1) && (right < x2)) + pLayout->right = AddEdge(pLayout->right, min, max, + dixScreenOrigins[i].x - dixScreenOrigins[j].x, + dixScreenOrigins[i].y - dixScreenOrigins[j].y, j); + } + + + if((left < x2) && (right > x1)) { + min = x1 - left; + if(min < 0) min = 0; + max = pScreen->width - (right - x2); + if(max > pScreen->width) max = pScreen->width; + + if(((top - 1) >= y1) && ((top - 1) < y2)) + pLayout->up = AddEdge(pLayout->up, min, max, + dixScreenOrigins[i].x - dixScreenOrigins[j].x, + dixScreenOrigins[i].y - dixScreenOrigins[j].y, j); + + if((bottom >= y1) && (bottom < y2)) + pLayout->down = AddEdge(pLayout->down, min, max, + dixScreenOrigins[i].x - dixScreenOrigins[j].x, + dixScreenOrigins[i].y - dixScreenOrigins[j].y, j); + } + } + } + } + + if(!HardEdges && !OldStyleConfig) { + for(i = 0; i < xf86NumScreens; i++) { + pLayout = &xf86ScreenLayout[i]; + pScreen = xf86Screens[i]->pScreen; + if(pLayout->left) + FillOutEdge(pLayout->left, pScreen->height); + if(pLayout->right) + FillOutEdge(pLayout->right, pScreen->height); + if(pLayout->up) + FillOutEdge(pLayout->up, pScreen->width); + if(pLayout->down) + FillOutEdge(pLayout->down, pScreen->width); + } + } +} + +void +xf86ReconfigureLayout(void) +{ + int i; + + for (i = 0; i < MAXSCREENS; i++) { + xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i]; + /* we don't have to zero these, xf86InitOrigins() takes care of that */ + if (sl->left) xfree(sl->left); + if (sl->right) xfree(sl->right); + if (sl->up) xfree(sl->up); + if (sl->down) xfree(sl->down); + } + + xf86InitOrigins(); +} + + diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c new file mode 100644 index 000000000..0daf1de44 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86DGA.c @@ -0,0 +1,1296 @@ +/* + * Copyright (c) 1998-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + * + * Written by Mark Vojkovich + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86.h" +#include "xf86str.h" +#include "xf86Priv.h" +#include "dgaproc.h" +#include +#include "colormapst.h" +#include "pixmapstr.h" +#include "inputstr.h" +#include "globals.h" +#include "servermd.h" +#include "micmap.h" +#ifdef XKB +#include +#endif +#include "xf86Xinput.h" + +#include "mi.h" + +static DevPrivateKey DGAScreenKey = NULL; +static int mieq_installed = 0; + +static Bool DGACloseScreen(int i, ScreenPtr pScreen); +static void DGADestroyColormap(ColormapPtr pmap); +static void DGAInstallColormap(ColormapPtr pmap); +static void DGAUninstallColormap(ColormapPtr pmap); +static void DGAHandleEvent(int screen_num, xEvent *event, + DeviceIntPtr device, int nevents); + +static void +DGACopyModeInfo( + DGAModePtr mode, + XDGAModePtr xmode +); + +_X_EXPORT int *XDGAEventBase = NULL; + +#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey)) + + +typedef struct _FakedVisualList{ + Bool free; + VisualPtr pVisual; + struct _FakedVisualList *next; +} FakedVisualList; + + +typedef struct { + ScrnInfoPtr pScrn; + int numModes; + DGAModePtr modes; + CloseScreenProcPtr CloseScreen; + DestroyColormapProcPtr DestroyColormap; + InstallColormapProcPtr InstallColormap; + UninstallColormapProcPtr UninstallColormap; + DGADevicePtr current; + DGAFunctionPtr funcs; + int input; + ClientPtr client; + int pixmapMode; + FakedVisualList *fakedVisuals; + ColormapPtr dgaColormap; + ColormapPtr savedColormap; + Bool grabMouse; + Bool grabKeyboard; +} DGAScreenRec, *DGAScreenPtr; + +_X_EXPORT Bool +DGAInit( + ScreenPtr pScreen, + DGAFunctionPtr funcs, + DGAModePtr modes, + int num +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DGAScreenPtr pScreenPriv; + int i; + + if(!funcs || !funcs->SetMode || !funcs->OpenFramebuffer) + return FALSE; + + if(!modes || num <= 0) + return FALSE; + + DGAScreenKey = &DGAScreenKey; + + if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec)))) + return FALSE; + + pScreenPriv->pScrn = pScrn; + pScreenPriv->numModes = num; + pScreenPriv->modes = modes; + pScreenPriv->current = NULL; + + pScreenPriv->funcs = funcs; + pScreenPriv->input = 0; + pScreenPriv->client = NULL; + pScreenPriv->fakedVisuals = NULL; + pScreenPriv->dgaColormap = NULL; + pScreenPriv->savedColormap = NULL; + pScreenPriv->grabMouse = FALSE; + pScreenPriv->grabKeyboard = FALSE; + + for(i = 0; i < num; i++) + modes[i].num = i + 1; + +#ifdef PANORAMIX + if(!noPanoramiXExtension) + for(i = 0; i < num; i++) + modes[i].flags &= ~DGA_PIXMAP_AVAILABLE; +#endif + + dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv); + pScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = DGACloseScreen; + pScreenPriv->DestroyColormap = pScreen->DestroyColormap; + pScreen->DestroyColormap = DGADestroyColormap; + pScreenPriv->InstallColormap = pScreen->InstallColormap; + pScreen->InstallColormap = DGAInstallColormap; + pScreenPriv->UninstallColormap = pScreen->UninstallColormap; + pScreen->UninstallColormap = DGAUninstallColormap; + + + return TRUE; +} + +/* DGAReInitModes allows the driver to re-initialize + * the DGA mode list. + */ + +_X_EXPORT Bool +DGAReInitModes( + ScreenPtr pScreen, + DGAModePtr modes, + int num +){ + DGAScreenPtr pScreenPriv; + int i; + + /* No DGA? Ignore call (but don't make it look like it failed) */ + if(DGAScreenKey == NULL) + return TRUE; + + pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + /* Same as above */ + if(!pScreenPriv) + return TRUE; + + /* Can't do this while DGA is active */ + if(pScreenPriv->current) + return FALSE; + + /* Quick sanity check */ + if(!num) + modes = NULL; + else if(!modes) + num = 0; + + pScreenPriv->numModes = num; + pScreenPriv->modes = modes; + + /* This practically disables DGA. So be it. */ + if(!num) + return TRUE; + + for(i = 0; i < num; i++) + modes[i].num = i + 1; + +#ifdef PANORAMIX + if(!noPanoramiXExtension) + for(i = 0; i < num; i++) + modes[i].flags &= ~DGA_PIXMAP_AVAILABLE; +#endif + + return TRUE; +} + +static void +FreeMarkedVisuals(ScreenPtr pScreen) +{ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + FakedVisualList *prev, *curr, *tmp; + + if(!pScreenPriv->fakedVisuals) + return; + + prev = NULL; + curr = pScreenPriv->fakedVisuals; + + while(curr) { + if(curr->free) { + tmp = curr; + curr = curr->next; + if(prev) + prev->next = curr; + else + pScreenPriv->fakedVisuals = curr; + xfree(tmp->pVisual); + xfree(tmp); + } else { + prev = curr; + curr = curr->next; + } + } +} + +static Bool +DGACloseScreen(int i, ScreenPtr pScreen) +{ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + if (XDGAEventBase) { + mieqSetHandler(*XDGAEventBase + MotionNotify, NULL); + mieqSetHandler(*XDGAEventBase + ButtonPress, NULL); + mieqSetHandler(*XDGAEventBase + ButtonRelease, NULL); + mieqSetHandler(*XDGAEventBase + KeyPress, NULL); + mieqSetHandler(*XDGAEventBase + KeyRelease, NULL); + } + + FreeMarkedVisuals(pScreen); + + pScreen->CloseScreen = pScreenPriv->CloseScreen; + pScreen->DestroyColormap = pScreenPriv->DestroyColormap; + pScreen->InstallColormap = pScreenPriv->InstallColormap; + pScreen->UninstallColormap = pScreenPriv->UninstallColormap; + + /* DGAShutdown() should have ensured that no DGA + screen were active by here */ + + xfree(pScreenPriv); + + return((*pScreen->CloseScreen)(i, pScreen)); +} + + +static void +DGADestroyColormap(ColormapPtr pmap) +{ + ScreenPtr pScreen = pmap->pScreen; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + VisualPtr pVisual = pmap->pVisual; + + if(pScreenPriv->fakedVisuals) { + FakedVisualList *curr = pScreenPriv->fakedVisuals; + + while(curr) { + if(curr->pVisual == pVisual) { + /* We can't get rid of them yet since FreeColormap + still needs the pVisual during the cleanup */ + curr->free = TRUE; + break; + } + curr = curr->next; + } + } + + if(pScreenPriv->DestroyColormap) { + pScreen->DestroyColormap = pScreenPriv->DestroyColormap; + (*pScreen->DestroyColormap)(pmap); + pScreen->DestroyColormap = DGADestroyColormap; + } +} + + +static void +DGAInstallColormap(ColormapPtr pmap) +{ + ScreenPtr pScreen = pmap->pScreen; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + if(pScreenPriv->current && pScreenPriv->dgaColormap) { + if (pmap != pScreenPriv->dgaColormap) { + pScreenPriv->savedColormap = pmap; + pmap = pScreenPriv->dgaColormap; + } + } + + pScreen->InstallColormap = pScreenPriv->InstallColormap; + (*pScreen->InstallColormap)(pmap); + pScreen->InstallColormap = DGAInstallColormap; +} + +static void +DGAUninstallColormap(ColormapPtr pmap) +{ + ScreenPtr pScreen = pmap->pScreen; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + if(pScreenPriv->current && pScreenPriv->dgaColormap) { + if (pmap == pScreenPriv->dgaColormap) { + pScreenPriv->dgaColormap = NULL; + } + } + + pScreen->UninstallColormap = pScreenPriv->UninstallColormap; + (*pScreen->UninstallColormap)(pmap); + pScreen->UninstallColormap = DGAUninstallColormap; +} + +int +xf86SetDGAMode( + int index, + int num, + DGADevicePtr devRet +){ + ScreenPtr pScreen = screenInfo.screens[index]; + DGAScreenPtr pScreenPriv; + ScrnInfoPtr pScrn; + DGADevicePtr device; + PixmapPtr pPix = NULL; + DGAModePtr pMode = NULL; + + /* First check if DGAInit was successful on this screen */ + if (DGAScreenKey == NULL) + return BadValue; + pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + if (!pScreenPriv) + return BadValue; + pScrn = pScreenPriv->pScrn; + + if(!num) { + if(pScreenPriv->current) { + PixmapPtr oldPix = pScreenPriv->current->pPix; + if(oldPix) { + if(oldPix->drawable.id) + FreeResource(oldPix->drawable.id, RT_NONE); + else + (*pScreen->DestroyPixmap)(oldPix); + } + xfree(pScreenPriv->current); + pScreenPriv->current = NULL; + pScrn->vtSema = TRUE; + (*pScreenPriv->funcs->SetMode)(pScrn, NULL); + if(pScreenPriv->savedColormap) { + (*pScreen->InstallColormap)(pScreenPriv->savedColormap); + pScreenPriv->savedColormap = NULL; + } + pScreenPriv->dgaColormap = NULL; + (*pScrn->EnableDisableFBAccess)(index, TRUE); + + FreeMarkedVisuals(pScreen); + } + + pScreenPriv->grabMouse = FALSE; + pScreenPriv->grabKeyboard = FALSE; + + return Success; + } + + if(!pScrn->vtSema && !pScreenPriv->current) /* Really switched away */ + return BadAlloc; + + if((num > 0) && (num <= pScreenPriv->numModes)) + pMode = &(pScreenPriv->modes[num - 1]); + else + return BadValue; + + if(!(device = (DGADevicePtr)xalloc(sizeof(DGADeviceRec)))) + return BadAlloc; + + if(!pScreenPriv->current) { + Bool oldVTSema = pScrn->vtSema; + + pScrn->vtSema = FALSE; /* kludge until we rewrite VT switching */ + (*pScrn->EnableDisableFBAccess)(index, FALSE); + pScrn->vtSema = oldVTSema; + } + + if(!(*pScreenPriv->funcs->SetMode)(pScrn, pMode)) { + xfree(device); + return BadAlloc; + } + + pScrn->currentMode = pMode->mode; + + if(!pScreenPriv->current && !pScreenPriv->input) { + /* if it's multihead we need to warp the cursor off of + our screen so it doesn't get trapped */ + } + + pScrn->vtSema = FALSE; + + if(pScreenPriv->current) { + PixmapPtr oldPix = pScreenPriv->current->pPix; + if(oldPix) { + if(oldPix->drawable.id) + FreeResource(oldPix->drawable.id, RT_NONE); + else + (*pScreen->DestroyPixmap)(oldPix); + } + xfree(pScreenPriv->current); + pScreenPriv->current = NULL; + } + + if(pMode->flags & DGA_PIXMAP_AVAILABLE) { + if((pPix = (*pScreen->CreatePixmap)(pScreen, 0, 0, pMode->depth, 0))) { + (*pScreen->ModifyPixmapHeader)(pPix, + pMode->pixmapWidth, pMode->pixmapHeight, + pMode->depth, pMode->bitsPerPixel, + pMode->bytesPerScanline, + (pointer)(pMode->address)); + } + } + + devRet->mode = device->mode = pMode; + devRet->pPix = device->pPix = pPix; + pScreenPriv->current = device; + pScreenPriv->pixmapMode = FALSE; + pScreenPriv->grabMouse = TRUE; + pScreenPriv->grabKeyboard = TRUE; + + return Success; +} + + + +/*********** exported ones ***************/ + +_X_EXPORT void +DGASetInputMode(int index, Bool keyboard, Bool mouse) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + if (pScreenPriv) + { + pScreenPriv->grabMouse = mouse; + pScreenPriv->grabKeyboard = keyboard; + + if (!mieq_installed) { + mieqSetHandler(*XDGAEventBase + MotionNotify, DGAHandleEvent); + mieqSetHandler(*XDGAEventBase + ButtonPress, DGAHandleEvent); + mieqSetHandler(*XDGAEventBase + ButtonRelease, DGAHandleEvent); + mieqSetHandler(*XDGAEventBase + KeyPress, DGAHandleEvent); + mieqSetHandler(*XDGAEventBase + KeyRelease, DGAHandleEvent); + mieq_installed = 1; + } + } +} + +_X_EXPORT Bool +DGAChangePixmapMode(int index, int *x, int *y, int mode) +{ + DGAScreenPtr pScreenPriv; + DGADevicePtr pDev; + DGAModePtr pMode; + PixmapPtr pPix; + + if(DGAScreenKey == NULL) + return FALSE; + + pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + if(!pScreenPriv || !pScreenPriv->current || !pScreenPriv->current->pPix) + return FALSE; + + pDev = pScreenPriv->current; + pPix = pDev->pPix; + pMode = pDev->mode; + + if(mode) { + int shift = 2; + + if(*x > (pMode->pixmapWidth - pMode->viewportWidth)) + *x = pMode->pixmapWidth - pMode->viewportWidth; + if(*y > (pMode->pixmapHeight - pMode->viewportHeight)) + *y = pMode->pixmapHeight - pMode->viewportHeight; + + switch(xf86Screens[index]->bitsPerPixel) { + case 16: shift = 1; break; + case 32: shift = 0; break; + default: break; + } + + if(BITMAP_SCANLINE_PAD == 64) + shift++; + + *x = (*x >> shift) << shift; + + pPix->drawable.x = *x; + pPix->drawable.y = *y; + pPix->drawable.width = pMode->viewportWidth; + pPix->drawable.height = pMode->viewportHeight; + } else { + pPix->drawable.x = 0; + pPix->drawable.y = 0; + pPix->drawable.width = pMode->pixmapWidth; + pPix->drawable.height = pMode->pixmapHeight; + } + pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pScreenPriv->pixmapMode = mode; + + return TRUE; +} + +_X_EXPORT Bool +DGAAvailable(int index) +{ + if(DGAScreenKey == NULL) + return FALSE; + + if (!xf86NoSharedResources(((ScrnInfoPtr)dixLookupPrivate( + &screenInfo.screens[index]->devPrivates, + xf86ScreenKey))->scrnIndex, MEM)) + return FALSE; + + if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index])) + return TRUE; + + return FALSE; +} + +_X_EXPORT Bool +DGAActive(int index) +{ + DGAScreenPtr pScreenPriv; + + if(DGAScreenKey == NULL) + return FALSE; + + pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + if(pScreenPriv && pScreenPriv->current) + return TRUE; + + return FALSE; +} + + + +/* Called by the event code in case the server is abruptly terminated */ + +void +DGAShutdown() +{ + ScrnInfoPtr pScrn; + int i; + + if(DGAScreenKey == NULL) + return; + + for(i = 0; i < screenInfo.numScreens; i++) { + pScrn = xf86Screens[i]; + + (void)(*pScrn->SetDGAMode)(pScrn->scrnIndex, 0, NULL); + } +} + +/* Called by the extension to initialize a mode */ + +_X_EXPORT int +DGASetMode( + int index, + int num, + XDGAModePtr mode, + PixmapPtr *pPix +){ + ScrnInfoPtr pScrn = xf86Screens[index]; + DGADeviceRec device; + int ret; + + /* We rely on the extension to check that DGA is available */ + + ret = (*pScrn->SetDGAMode)(index, num, &device); + if((ret == Success) && num) { + DGACopyModeInfo(device.mode, mode); + *pPix = device.pPix; + } + + return ret; +} + +/* Called from the extension to let the DDX know which events are requested */ + +_X_EXPORT void +DGASelectInput( + int index, + ClientPtr client, + long mask +){ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is available */ + pScreenPriv->client = client; + pScreenPriv->input = mask; +} + +_X_EXPORT int +DGAGetViewportStatus(int index) +{ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is active */ + + if (!pScreenPriv->funcs->GetViewport) + return 0; + + return (*pScreenPriv->funcs->GetViewport)(pScreenPriv->pScrn); +} + +_X_EXPORT int +DGASetViewport( + int index, + int x, int y, + int mode +){ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + if (pScreenPriv->funcs->SetViewport) + (*pScreenPriv->funcs->SetViewport)(pScreenPriv->pScrn, x, y, mode); + return Success; +} + + +static int +BitsClear(CARD32 data) +{ + int bits = 0; + CARD32 mask; + + for(mask = 1; mask; mask <<= 1) { + if(!(data & mask)) bits++; + else break; + } + + return bits; +} + +_X_EXPORT int +DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + FakedVisualList *fvlp; + VisualPtr pVisual; + DGAModePtr pMode; + ColormapPtr pmap; + + if(!mode || (mode > pScreenPriv->numModes)) + return BadValue; + + if((alloc != AllocNone) && (alloc != AllocAll)) + return BadValue; + + pMode = &(pScreenPriv->modes[mode - 1]); + + if(!(pVisual = xalloc(sizeof(VisualRec)))) + return BadAlloc; + + pVisual->vid = FakeClientID(0); + pVisual->class = pMode->visualClass; + pVisual->nplanes = pMode->depth; + pVisual->ColormapEntries = 1 << pMode->depth; + pVisual->bitsPerRGBValue = (pMode->depth + 2) / 3; + + switch (pVisual->class) { + case PseudoColor: + case GrayScale: + case StaticGray: + pVisual->bitsPerRGBValue = 8; /* not quite */ + pVisual->redMask = 0; + pVisual->greenMask = 0; + pVisual->blueMask = 0; + pVisual->offsetRed = 0; + pVisual->offsetGreen = 0; + pVisual->offsetBlue = 0; + break; + case DirectColor: + case TrueColor: + pVisual->ColormapEntries = 1 << pVisual->bitsPerRGBValue; + /* fall through */ + case StaticColor: + pVisual->redMask = pMode->red_mask; + pVisual->greenMask = pMode->green_mask; + pVisual->blueMask = pMode->blue_mask; + pVisual->offsetRed = BitsClear(pVisual->redMask); + pVisual->offsetGreen = BitsClear(pVisual->greenMask); + pVisual->offsetBlue = BitsClear(pVisual->blueMask); + } + + if(!(fvlp = xalloc(sizeof(FakedVisualList)))) { + xfree(pVisual); + return BadAlloc; + } + + fvlp->free = FALSE; + fvlp->pVisual = pVisual; + fvlp->next = pScreenPriv->fakedVisuals; + pScreenPriv->fakedVisuals = fvlp; + + LEGAL_NEW_RESOURCE(id, client); + + return CreateColormap(id, pScreen, pVisual, &pmap, alloc, client->index); +} + +/* Called by the extension to install a colormap on DGA active screens */ + +_X_EXPORT void +DGAInstallCmap(ColormapPtr cmap) +{ + ScreenPtr pScreen = cmap->pScreen; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + /* We rely on the extension to check that DGA is active */ + + if(!pScreenPriv->dgaColormap) + pScreenPriv->savedColormap = miInstalledMaps[pScreen->myNum]; + + pScreenPriv->dgaColormap = cmap; + + (*pScreen->InstallColormap)(cmap); +} + +_X_EXPORT int +DGASync(int index) +{ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is active */ + + if (pScreenPriv->funcs->Sync) + (*pScreenPriv->funcs->Sync)(pScreenPriv->pScrn); + + return Success; +} + +_X_EXPORT int +DGAFillRect( + int index, + int x, int y, int w, int h, + unsigned long color +){ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is active */ + + if(pScreenPriv->funcs->FillRect && + (pScreenPriv->current->mode->flags & DGA_FILL_RECT)) { + + (*pScreenPriv->funcs->FillRect)(pScreenPriv->pScrn, x, y, w, h, color); + return Success; + } + return BadMatch; +} + +_X_EXPORT int +DGABlitRect( + int index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +){ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is active */ + + if(pScreenPriv->funcs->BlitRect && + (pScreenPriv->current->mode->flags & DGA_BLIT_RECT)) { + + (*pScreenPriv->funcs->BlitRect)(pScreenPriv->pScrn, + srcx, srcy, w, h, dstx, dsty); + return Success; + } + return BadMatch; +} + +_X_EXPORT int +DGABlitTransRect( + int index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +){ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is active */ + + if(pScreenPriv->funcs->BlitTransRect && + (pScreenPriv->current->mode->flags & DGA_BLIT_RECT_TRANS)) { + + (*pScreenPriv->funcs->BlitTransRect)(pScreenPriv->pScrn, + srcx, srcy, w, h, dstx, dsty, color); + return Success; + } + return BadMatch; +} + + +_X_EXPORT int +DGAGetModes(int index) +{ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + /* We rely on the extension to check that DGA is available */ + + return pScreenPriv->numModes; +} + + +_X_EXPORT int +DGAGetModeInfo( + int index, + XDGAModePtr mode, + int num +){ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + /* We rely on the extension to check that DGA is available */ + + if((num <= 0) || (num > pScreenPriv->numModes)) + return BadValue; + + DGACopyModeInfo(&(pScreenPriv->modes[num - 1]), mode); + + return Success; +} + + +static void +DGACopyModeInfo( + DGAModePtr mode, + XDGAModePtr xmode +){ + DisplayModePtr dmode = mode->mode; + + xmode->num = mode->num; + xmode->name = dmode->name; + xmode->VSync_num = (int)(dmode->VRefresh * 1000.0); + xmode->VSync_den = 1000; + xmode->flags = mode->flags; + xmode->imageWidth = mode->imageWidth; + xmode->imageHeight = mode->imageHeight; + xmode->pixmapWidth = mode->pixmapWidth; + xmode->pixmapHeight = mode->pixmapHeight; + xmode->bytesPerScanline = mode->bytesPerScanline; + xmode->byteOrder = mode->byteOrder; + xmode->depth = mode->depth; + xmode->bitsPerPixel = mode->bitsPerPixel; + xmode->red_mask = mode->red_mask; + xmode->green_mask = mode->green_mask; + xmode->blue_mask = mode->blue_mask; + xmode->visualClass = mode->visualClass; + xmode->viewportWidth = mode->viewportWidth; + xmode->viewportHeight = mode->viewportHeight; + xmode->xViewportStep = mode->xViewportStep; + xmode->yViewportStep = mode->yViewportStep; + xmode->maxViewportX = mode->maxViewportX; + xmode->maxViewportY = mode->maxViewportY; + xmode->viewportFlags = mode->viewportFlags; + xmode->reserved1 = mode->reserved1; + xmode->reserved2 = mode->reserved2; + xmode->offset = mode->offset; + + if(dmode->Flags & V_INTERLACE) xmode->flags |= DGA_INTERLACED; + if(dmode->Flags & V_DBLSCAN) xmode->flags |= DGA_DOUBLESCAN; +} + + +Bool +DGAVTSwitch(void) +{ + ScreenPtr pScreen; + int i; + + for(i = 0; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + + /* Alternatively, this could send events to DGA clients */ + + if(DGAScreenKey) { + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + if(pScreenPriv && pScreenPriv->current) + return FALSE; + } + } + + return TRUE; +} + +Bool +DGAStealKeyEvent(int index, int key_code, int is_down) +{ + DGAScreenPtr pScreenPriv; + dgaEvent de; + + if(DGAScreenKey == NULL) /* no DGA */ + return FALSE; + + pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */ + return FALSE; + + de.u.u.type = *XDGAEventBase + (is_down ? KeyPress : KeyRelease); + de.u.u.detail = key_code; + de.u.event.time = GetTimeInMillis(); + mieqEnqueue (inputInfo.keyboard, (xEvent *) &de); + + return TRUE; +} + +static int DGAMouseX, DGAMouseY; + +Bool +DGAStealMotionEvent(int index, int dx, int dy) +{ + DGAScreenPtr pScreenPriv; + dgaEvent de; + + if(DGAScreenKey == NULL) /* no DGA */ + return FALSE; + + pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */ + return FALSE; + + DGAMouseX += dx; + if (DGAMouseX < 0) + DGAMouseX = 0; + else if (DGAMouseX > screenInfo.screens[index]->width) + DGAMouseX = screenInfo.screens[index]->width; + DGAMouseY += dy; + if (DGAMouseY < 0) + DGAMouseY = 0; + else if (DGAMouseY > screenInfo.screens[index]->height) + DGAMouseY = screenInfo.screens[index]->height; + de.u.u.type = *XDGAEventBase + MotionNotify; + de.u.u.detail = 0; + de.u.event.time = GetTimeInMillis(); + de.u.event.dx = dx; + de.u.event.dy = dy; + de.u.event.pad1 = DGAMouseX; + de.u.event.pad2 = DGAMouseY; + mieqEnqueue (inputInfo.pointer, (xEvent *) &de); + return TRUE; +} + +Bool +DGAStealButtonEvent(int index, int button, int is_down) +{ + DGAScreenPtr pScreenPriv; + dgaEvent de; + + if (DGAScreenKey == NULL) + return FALSE; + + pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + if (!pScreenPriv || !pScreenPriv->grabMouse) + return FALSE; + + de.u.u.type = *XDGAEventBase + (is_down ? ButtonPress : ButtonRelease); + de.u.u.detail = button; + de.u.event.time = GetTimeInMillis(); + de.u.event.dx = 0; + de.u.event.dy = 0; + de.u.event.pad1 = DGAMouseX; + de.u.event.pad2 = DGAMouseY; + mieqEnqueue (inputInfo.pointer, (xEvent *) &de); + + return TRUE; +} + +/* We have the power to steal or modify events that are about to get queued */ + +Bool +DGAIsDgaEvent (xEvent *e) +{ + int coreEquiv; + if (DGAScreenKey == NULL || XDGAEventBase == 0) + return FALSE; + coreEquiv = e->u.u.type - *XDGAEventBase; + if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify) + return TRUE; + return FALSE; +} + +#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */ +static Mask filters[] = +{ + NoSuchEvent, /* 0 */ + NoSuchEvent, /* 1 */ + KeyPressMask, /* KeyPress */ + KeyReleaseMask, /* KeyRelease */ + ButtonPressMask, /* ButtonPress */ + ButtonReleaseMask, /* ButtonRelease */ + PointerMotionMask, /* MotionNotify (initial state) */ +}; + +static void +DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd) +{ + int key, bit; + register BYTE *kptr; + register int i; + register CARD8 modifiers; + register CARD16 mask; + int coreEquiv; + xEvent core; + KeyClassPtr keyc = keybd->key; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + coreEquiv = de->u.u.type - *XDGAEventBase; + + /* + * Fill in remaining event state + */ + de->u.event.dx = 0; + de->u.event.dy = 0; + de->u.event.screen = pScreen->myNum; + de->u.event.state = keyc->state | (inputInfo.pointer)->button->state; + + /* + * Keep the core state in sync by duplicating what + * CoreProcessKeyboardEvent does + */ + key = de->u.u.detail; + kptr = &keyc->down[key >> 3]; + bit = 1 << (key & 7); + modifiers = keyc->modifierMap[key]; + switch (coreEquiv) + { + case KeyPress: + inputInfo.pointer->valuator->motionHintWindow = NullWindow; + *kptr |= bit; + keyc->prev_state = keyc->state; +#ifdef XKB + if (noXkbExtension) +#endif + { + + for (i = 0, mask = 1; modifiers; i++, mask <<= 1) + { + if (mask & modifiers) + { + /* This key affects modifier "i" */ + keyc->modifierKeyCount[i]++; + keyc->state |= mask; + modifiers &= ~mask; + } + } + } + break; + case KeyRelease: + inputInfo.pointer->valuator->motionHintWindow = NullWindow; + *kptr &= ~bit; + keyc->prev_state = keyc->state; +#ifdef XKB + if (noXkbExtension) +#endif + { + for (i = 0, mask = 1; modifiers; i++, mask <<= 1) + { + if (mask & modifiers) { + /* This key affects modifier "i" */ + if (--keyc->modifierKeyCount[i] <= 0) { + keyc->state &= ~mask; + keyc->modifierKeyCount[i] = 0; + } + modifiers &= ~mask; + } + } + } + break; + } + /* + * Deliver the DGA event + */ + if (pScreenPriv->client) + { + /* If the DGA client has selected input, then deliver based on the usual filter */ + TryClientEvents (pScreenPriv->client, (xEvent *) de, 1, + filters[coreEquiv], pScreenPriv->input, 0); + } + else + { + /* If the keyboard is actively grabbed, deliver a grabbed core event */ + if (keybd->grab && !keybd->fromPassiveGrab) + { + core.u.u.type = coreEquiv; + core.u.u.detail = de->u.u.detail; + core.u.keyButtonPointer.time = de->u.event.time; + core.u.keyButtonPointer.eventX = de->u.event.dx; + core.u.keyButtonPointer.eventY = de->u.event.dy; + core.u.keyButtonPointer.rootX = de->u.event.dx; + core.u.keyButtonPointer.rootY = de->u.event.dy; + core.u.keyButtonPointer.state = de->u.event.state; + DeliverGrabbedEvent (&core, keybd, FALSE, 1); + } + } +} + +static void +DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse) +{ + ButtonClassPtr butc = mouse->button; + int coreEquiv; + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + xEvent core; + + coreEquiv = de->u.u.type - *XDGAEventBase; + /* + * Fill in remaining event state + */ + de->u.event.screen = pScreen->myNum; + de->u.event.state = butc->state | inputInfo.keyboard->key->state; + /* + * Keep the core state in sync by duplicating what + * CoreProcessPointerEvent does + */ + if (coreEquiv != MotionNotify) + { + register int key; + register BYTE *kptr; + int bit; + + key = de->u.u.detail; + kptr = &butc->down[key >> 3]; + bit = 1 << (key & 7); + switch (coreEquiv) + { + case ButtonPress: + mouse->valuator->motionHintWindow = NullWindow; + if (!(*kptr & bit)) + butc->buttonsDown++; + butc->motionMask = ButtonMotionMask; + *kptr |= bit; + if (key <= 5) + butc->state |= (Button1Mask >> 1) << key; + break; + case ButtonRelease: + mouse->valuator->motionHintWindow = NullWindow; + if (*kptr & bit) + --butc->buttonsDown; + if (!butc->buttonsDown) + butc->motionMask = 0; + *kptr &= ~bit; + if (key == 0) + return; + if (key <= 5) + butc->state &= ~((Button1Mask >> 1) << key); + break; + } + } + /* + * Deliver the DGA event + */ + if (pScreenPriv->client) + { + /* If the DGA client has selected input, then deliver based on the usual filter */ + TryClientEvents (pScreenPriv->client, (xEvent *) de, 1, + filters[coreEquiv], pScreenPriv->input, 0); + } + else + { + /* If the pointer is actively grabbed, deliver a grabbed core event */ + if (mouse->grab && !mouse->fromPassiveGrab) + { + core.u.u.type = coreEquiv; + core.u.u.detail = de->u.u.detail; + core.u.keyButtonPointer.time = de->u.event.time; + core.u.keyButtonPointer.eventX = de->u.event.dx; + core.u.keyButtonPointer.eventY = de->u.event.dy; + core.u.keyButtonPointer.rootX = de->u.event.dx; + core.u.keyButtonPointer.rootY = de->u.event.dy; + core.u.keyButtonPointer.state = de->u.event.state; + DeliverGrabbedEvent (&core, mouse, FALSE, 1); + } + } +} + +_X_EXPORT Bool +DGAOpenFramebuffer( + int index, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *flags +){ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is available */ + + return (*pScreenPriv->funcs->OpenFramebuffer)(pScreenPriv->pScrn, + name, mem, size, offset, flags); +} + +_X_EXPORT void +DGACloseFramebuffer(int index) +{ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + + /* We rely on the extension to check that DGA is available */ + if(pScreenPriv->funcs->CloseFramebuffer) + (*pScreenPriv->funcs->CloseFramebuffer)(pScreenPriv->pScrn); +} + +/* For DGA 1.0 backwards compatibility only */ + +_X_EXPORT int +DGAGetOldDGAMode(int index) +{ + DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); + ScrnInfoPtr pScrn = pScreenPriv->pScrn; + DGAModePtr mode; + int i, w, h, p; + + /* We rely on the extension to check that DGA is available */ + + w = pScrn->currentMode->HDisplay; + h = pScrn->currentMode->VDisplay; + p = ((pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) + 3) & ~3L; + + for(i = 0; i < pScreenPriv->numModes; i++) { + mode = &(pScreenPriv->modes[i]); + + if((mode->viewportWidth == w) && (mode->viewportHeight == h) && + (mode->bytesPerScanline == p) && + (mode->bitsPerPixel == pScrn->bitsPerPixel) && + (mode->depth == pScrn->depth)) { + + return mode->num; + } + } + + return 0; +} + +static void +DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents) +{ + dgaEvent *de = (dgaEvent *) event; + ScreenPtr pScreen = screenInfo.screens[screen_num]; + DGAScreenPtr pScreenPriv; + int coreEquiv; + + /* no DGA */ + if (DGAScreenKey == NULL || XDGAEventBase == 0) + return; + pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); + + /* DGA not initialized on this screen */ + if (!pScreenPriv) + return; + + coreEquiv = de->u.u.type - *XDGAEventBase; + /* Not a DGA event; shouldn't happen, but you never know. */ + if (coreEquiv < KeyPress || coreEquiv > MotionNotify) + return; + + switch (coreEquiv) { + case KeyPress: + case KeyRelease: + DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard); + break; + default: + DGAProcessPointerEvent (pScreen, de, inputInfo.pointer); + break; + } +} diff --git a/xorg-server/hw/xfree86/common/xf86DPMS.c b/xorg-server/hw/xfree86/common/xf86DPMS.c new file mode 100644 index 000000000..4fb901aae --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86DPMS.c @@ -0,0 +1,225 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the DPMS functions required by the extension. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "globals.h" +#include "xf86.h" +#include "xf86Priv.h" +#ifdef DPMSExtension +#define DPMS_SERVER +#include +#include "dpmsproc.h" +#endif + + +#ifdef DPMSExtension +static DevPrivateKey DPMSKey = NULL; +static Bool DPMSClose(int i, ScreenPtr pScreen); +static int DPMSCount = 0; +#endif + + +_X_EXPORT Bool +xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) +{ +#ifdef DPMSExtension + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DPMSPtr pDPMS; + pointer DPMSOpt; + MessageType enabled_from = X_INFO; + + DPMSKey = &DPMSKey; + + if (DPMSDisabledSwitch) + DPMSEnabled = FALSE; + if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey, + xcalloc(sizeof(DPMSRec), 1))) + return FALSE; + + pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey); + pScrn->DPMSSet = set; + pDPMS->Flags = flags; + DPMSOpt = xf86FindOption(pScrn->options, "dpms"); + if (DPMSOpt) { + if ((pDPMS->Enabled + = xf86SetBoolOption(pScrn->options, "dpms", FALSE)) + && !DPMSDisabledSwitch) + DPMSEnabled = TRUE; + enabled_from = X_CONFIG; + xf86MarkOptionUsed(DPMSOpt); + } else if (DPMSEnabledSwitch) { + if (!DPMSDisabledSwitch) + DPMSEnabled = TRUE; + pDPMS->Enabled = TRUE; + } + else { + pDPMS->Enabled = defaultDPMSEnabled; + } + if (pDPMS->Enabled) + xf86DrvMsg(pScreen->myNum, enabled_from, "DPMS enabled\n"); + pDPMS->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = DPMSClose; + DPMSCount++; + return TRUE; +#else + return FALSE; +#endif +} + + +#ifdef DPMSExtension + +static Bool +DPMSClose(int i, ScreenPtr pScreen) +{ + DPMSPtr pDPMS; + + /* This shouldn't happen */ + if (DPMSKey == NULL) + return FALSE; + + pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey); + + /* This shouldn't happen */ + if (!pDPMS) + return FALSE; + + pScreen->CloseScreen = pDPMS->CloseScreen; + + /* + * Turn on DPMS when shutting down. If this function can be used + * depends on the order the driver wraps things. If this is called + * after the driver has shut down everything the driver will have + * to deal with this internally. + */ + if (xf86Screens[i]->vtSema && xf86Screens[i]->DPMSSet) { + xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0); + } + + xfree((pointer)pDPMS); + dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL); + if (--DPMSCount == 0) + DPMSKey = NULL; + return pScreen->CloseScreen(i, pScreen); +} + + +/* + * DPMSSet -- + * Device dependent DPMS mode setting hook. This is called whenever + * the DPMS mode is to be changed. + */ +_X_EXPORT int +DPMSSet(ClientPtr client, int level) +{ + int rc, i; + DPMSPtr pDPMS; + ScrnInfoPtr pScrn; + + DPMSPowerLevel = level; + + if (DPMSKey == NULL) + return Success; + + if (level != DPMSModeOn) { + rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive); + if (rc != Success) + return rc; + } + + /* For each screen, set the DPMS level */ + for (i = 0; i < xf86NumScreens; i++) { + pScrn = xf86Screens[i]; + pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + DPMSKey); + if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) { + xf86EnableAccess(pScrn); + pScrn->DPMSSet(pScrn, level, 0); + } + } + return Success; +} + + +/* + * DPMSSupported -- + * Return TRUE if any screen supports DPMS. + */ +_X_EXPORT Bool +DPMSSupported(void) +{ + int i; + DPMSPtr pDPMS; + ScrnInfoPtr pScrn; + + if (DPMSKey == NULL) { + return FALSE; + } + + /* For each screen, check if DPMS is supported */ + for (i = 0; i < xf86NumScreens; i++) { + pScrn = xf86Screens[i]; + pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + DPMSKey); + if (pDPMS && pScrn->DPMSSet) + return TRUE; + } + return FALSE; +} + + +/* + * DPMSGet -- + * Device dependent DPMS mode getting hook. This returns the current + * DPMS mode, or -1 if DPMS is not supported. + * + * This should hook in to the appropriate driver-level function, which + * will be added to the ScrnInfoRec. + * + * NOTES: + * 1. the calling interface should be changed to specify which + * screen to check. + * 2. It isn't clear that this function is ever used or what it should + * return. + */ +_X_EXPORT int +DPMSGet(int *level) +{ + return DPMSPowerLevel; +} + +#endif /* DPMSExtension */ diff --git a/xorg-server/hw/xfree86/common/xf86Date.h b/xorg-server/hw/xfree86/common/xf86Date.h new file mode 100644 index 000000000..978c4fa15 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Date.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef XF86_DATE + +#define XF86_DATE "18 December 2003" + +#endif diff --git a/xorg-server/hw/xfree86/common/xf86Debug.c b/xorg-server/hw/xfree86/common/xf86Debug.c new file mode 100644 index 000000000..5b609652b --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Debug.c @@ -0,0 +1,77 @@ + +/* + * Copyright (c) 2000-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "compiler.h" + +CARD8 xf86PeekFb8(CARD8 *p) { return *p; } +CARD16 xf86PeekFb16(CARD16 *p) { return *p; } +CARD32 xf86PeekFb32(CARD32 *p) { return *p; } +void xf86PokeFb8(CARD8 *p, CARD8 v) { *p = v; } +void xf86PokeFb16(CARD16 *p, CARD16 v) { *p = v; } +void xf86PokeFb32(CARD16 *p, CARD32 v) { *p = v; } + +CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset) +{ + return MMIO_IN8(Base,Offset); +} + +CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset) +{ + return MMIO_IN16(Base,Offset); +} + +CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset) +{ + return MMIO_IN32(Base,Offset); +} + +void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v) +{ + MMIO_OUT8(Base,Offset,v); +} + +void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v) +{ + MMIO_OUT16(Base,Offset,v); +} + +void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v) +{ + MMIO_OUT32(Base,Offset,v); +} diff --git a/xorg-server/hw/xfree86/common/xf86DoProbe.c b/xorg-server/hw/xfree86/common/xf86DoProbe.c new file mode 100644 index 000000000..bba6ab7e8 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86DoProbe.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 1999-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * finish setting up the server + * Load the driver modules and call their probe functions. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "os.h" +#include "loaderProcs.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xf86.h" +#include "xf86Priv.h" + +void +DoProbe() +{ + int i; + Bool probeResult; + Bool ioEnableFailed = FALSE; + + /* Find the list of video driver modules. */ + char **list = xf86DriverlistFromCompile(); + char **l; + + if (list) { + ErrorF("List of video driver modules:\n"); + for (l = list; *l; l++) + ErrorF("\t%s\n", *l); + } else { + ErrorF("No video driver modules found\n"); + } + + /* Load all the drivers that were found. */ + xf86LoadModules(list, NULL); + + /* Disable PCI devices */ + xf86AccessInit(); + + /* Call all of the probe functions, reporting the results. */ + for (i = 0; i < xf86NumDrivers; i++) { + DriverRec * const drv = xf86DriverList[i]; + + if (!xorgHWAccess) { + xorgHWFlags flags; + if (!drv->driverFunc + || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags ) + || NEED_IO_ENABLED(flags)) { + if (ioEnableFailed) + continue; + if (!xf86EnableIO()) { + ioEnableFailed = TRUE; + continue; + } + xorgHWAccess = TRUE; + } + } + + + xf86MsgVerb(X_INFO, 3, "Probing in driver %s\n", drv->driverName); + + probeResult = xf86CallDriverProbe( drv, TRUE ); + if (!probeResult) { + xf86ErrorF("Probe in driver `%s' returns FALSE\n", + drv->driverName); + } else { + xf86ErrorF("Probe in driver `%s' returns TRUE\n", + drv->driverName); + + /* If we have a result, then call driver's Identify function */ + if (drv->Identify != NULL) { + const int verbose = xf86SetVerbosity(1); + (*drv->Identify)(0); + xf86SetVerbosity(verbose); + } + } + } + + OsCleanup(TRUE); + AbortDDX(); + fflush(stderr); + exit(0); +} diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c new file mode 100644 index 000000000..76c207a13 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Events.c @@ -0,0 +1,1018 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * 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 Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* [JCH-96/01/21] Extended std reverse map to four buttons. */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include "misc.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSlib.h" +#include "atKeynames.h" + + +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +#ifdef XINPUT +#include +#include +#else +#include "inputstr.h" +#endif +#include "xf86Xinput.h" + +#include "mi.h" +#include "mipointer.h" + +#ifdef XF86BIGFONT +#define _XF86BIGFONT_SERVER_ +#include +#endif + +#ifdef XKB +extern Bool noXkbExtension; +#endif + +#ifdef DPMSExtension +#define DPMS_SERVER +#include +#include "dpmsproc.h" +#endif + +#define XE_POINTER 1 +#define XE_KEYBOARD 2 + +#define EqEnqueue(pDev, ev) { \ + int __sigstate = xf86BlockSIGIO (); \ + mieqEnqueue (pDev, ev); \ + xf86UnblockSIGIO(__sigstate); \ +} + +/* + * The first of many hacks to get VT switching to work under + * Solaris 2.1 for x86. The basic problem is that Solaris is supposed + * to be SVR4. It is for the most part, except where the video interface + * is concerned. These hacks work around those problems. + * See the comments for Linux, and SCO. + * + * This is a toggling variable: + * FALSE = No VT switching keys have been pressed last time around + * TRUE = Possible VT switch Pending + * (DWH - 12/2/93) + * + * This has been generalised to work with Linux and *BSD+syscons (DHD) + */ + +_X_EXPORT Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for + *BSD and for avoiding VT + switches when using the DRI + automatic full screen mode.*/ + +extern fd_set EnabledDevices; + +#ifdef XF86PM +extern void (*xf86OSPMClose)(void); +#endif + +static void xf86VTSwitch(void); + +/* + * Allow arbitrary drivers or other XFree86 code to register with our main + * Wakeup handler. + */ +typedef struct x_IHRec { + int fd; + InputHandlerProc ihproc; + pointer data; + Bool enabled; + struct x_IHRec * next; +} IHRec, *IHPtr; + +static IHPtr InputHandlers = NULL; + + +Bool +LegalModifier(unsigned int key, DeviceIntPtr pDev) +{ + return TRUE; +} + +/* + * TimeSinceLastInputEvent -- + * Function used for screensaver purposes by the os module. Returns the + * time in milliseconds since there last was any input. + */ + +int +TimeSinceLastInputEvent() +{ + if (xf86Info.lastEventTime == 0) { + xf86Info.lastEventTime = GetTimeInMillis(); + } + return GetTimeInMillis() - xf86Info.lastEventTime; +} + + + +/* + * SetTimeSinceLastInputEvent -- + * Set the lastEventTime to now. + */ + +_X_EXPORT void +SetTimeSinceLastInputEvent() +{ + xf86Info.lastEventTime = GetTimeInMillis(); +} + + + +/* + * ProcessInputEvents -- + * Retrieve all waiting input events and pass them to DIX in their + * correct chronological order. Only reads from the system pointer + * and keyboard. + */ + +void +ProcessInputEvents () +{ + int x, y; +#ifdef INHERIT_LOCK_STATE + static int generation = 0; +#endif + + /* + * With INHERIT_LOCK_STATE defined, the initial state of CapsLock, NumLock + * and ScrollLock will be set to match that of the VT the server is + * running on. + */ +#ifdef INHERIT_LOCK_STATE + if (generation != serverGeneration) { + xEvent kevent; + DevicePtr pKeyboard = xf86Info.pKeyboard; + extern unsigned int xf86InitialCaps, xf86InitialNum, xf86InitialScroll; + + generation = serverGeneration; + kevent.u.keyButtonPointer.time = GetTimeInMillis(); + kevent.u.keyButtonPointer.rootX = 0; + kevent.u.keyButtonPointer.rootY = 0; + kevent.u.u.type = KeyPress; + + + if (xf86InitialCaps) { + kevent.u.u.detail = xf86InitialCaps; + (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1); + xf86InitialCaps = 0; + } + if (xf86InitialNum) { + kevent.u.u.detail = xf86InitialNum; + (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1); + xf86InitialNum = 0; + } + if (xf86InitialScroll) { + kevent.u.u.detail = xf86InitialScroll; + (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1); + xf86InitialScroll = 0; + } + } +#endif + + xf86Info.inputPending = FALSE; + + mieqProcessInputEvents(); + miPointerUpdateSprite(inputInfo.pointer); + + miPointerGetPosition(inputInfo.pointer, &x, &y); + xf86SetViewport(xf86Info.currentScreen, x, y); +} + +void +xf86GrabServerCallback(CallbackListPtr *callbacks, pointer data, pointer args) +{ + ServerGrabInfoRec *grab = (ServerGrabInfoRec*)args; + + xf86Info.grabInfo.server.client = grab->client; + xf86Info.grabInfo.server.grabstate = grab->grabstate; +} + +/* + * Handle keyboard events that cause some kind of "action" + * (i.e., server termination, video mode changes, VT switches, etc.) + */ +void +xf86ProcessActionEvent(ActionEvent action, void *arg) +{ +#ifdef DEBUG + ErrorF("ProcessActionEvent(%d,%x)\n", (int) action, arg); +#endif + switch (action) { + case ACTION_TERMINATE: + if (!xf86Info.dontZap) { +#ifdef XFreeXDGA + DGAShutdown(); +#endif + GiveUp(0); + } + break; + case ACTION_NEXT_MODE: + if (!xf86Info.dontZoom) + xf86ZoomViewport(xf86Info.currentScreen, 1); + break; + case ACTION_PREV_MODE: + if (!xf86Info.dontZoom) + xf86ZoomViewport(xf86Info.currentScreen, -1); + break; + case ACTION_DISABLEGRAB: + if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowDeactivate) { + if (inputInfo.pointer && inputInfo.pointer->grab != NULL && + inputInfo.pointer->DeactivateGrab) + inputInfo.pointer->DeactivateGrab(inputInfo.pointer); + if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL && + inputInfo.keyboard->DeactivateGrab) + inputInfo.keyboard->DeactivateGrab(inputInfo.keyboard); + } + break; + case ACTION_CLOSECLIENT: + if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowClosedown) { + ClientPtr pointer, keyboard, server; + + pointer = keyboard = server = NULL; + if (inputInfo.pointer && inputInfo.pointer->grab != NULL) + pointer = clients[CLIENT_ID(inputInfo.pointer->grab->resource)]; + if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL) { + keyboard = clients[CLIENT_ID(inputInfo.keyboard->grab->resource)]; + if (keyboard == pointer) + keyboard = NULL; + } + if ((xf86Info.grabInfo.server.grabstate == SERVER_GRABBED) && + (((server = xf86Info.grabInfo.server.client) == pointer) || + (server == keyboard))) + server = NULL; + + if (pointer) + CloseDownClient(pointer); + if (keyboard) + CloseDownClient(keyboard); + if (server) + CloseDownClient(server); + } + break; +#if !defined(__SOL8__) && !defined(sgi) && \ + (!defined(sun) || defined(__i386__)) && defined(VT_ACTIVATE) + case ACTION_SWITCHSCREEN: + if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) { + int vtno = *((int *) arg); +#if defined(__SCO__) || defined(__UNIXWARE__) + vtno--; +#endif +#if defined(QNX4) + xf86Info.vtRequestsPending = vtno; +#else + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); +#endif + } + break; + case ACTION_SWITCHSCREEN_NEXT: + if (VTSwitchEnabled && !xf86Info.dontVTSwitch) { +/* Shouldn't this be true for (sun) && (i386) && (SVR4) ? */ +#if defined(__SCO__) || defined(__UNIXWARE__) + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) +#else + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1) < 0) +#endif +#if defined (__SCO__) || (defined(sun) && defined (__i386__) && defined (SVR4)) || defined(__UNIXWARE__) + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0) +#else + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) < 0) +#endif + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + } + break; + case ACTION_SWITCHSCREEN_PREV: + if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno - 1) < 0) + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + } + break; +#endif + case ACTION_MESSAGE: + { + char *retstr, *message = (char *) arg; + ScrnInfoPtr pScr = XF86SCRNINFO(xf86Info.currentScreen); + +#ifdef DEBUG + ErrorF("ActionMessage: '%s'\n", message); +#endif + /* Okay the message made it to the ddx. The common layer */ + /* can check for relevant messages here and react to any */ + /* that have a global effect. For example: */ + /* */ + /* if (!strcmp(message, "foo") { */ + /* do_foo(); break */ + /* } */ + /* */ + /* otherwise fallback to sending a key event message to */ + /* the current screen's driver: */ + if (*pScr->HandleMessage != NULL) { + (void) (*pScr->HandleMessage)(pScr->scrnIndex, + "KeyEventMessage", message, &retstr); + } + } + break; + default: + break; + } +} + +#define ModifierIsSet(k) ((modifiers & (k)) == (k)) + +_X_EXPORT Bool +xf86CommonSpecialKey(int key, Bool down, int modifiers) +{ + if ((!ModifierIsSet(ShiftMask)) && + (((ModifierIsSet(ControlMask | AltMask)) || + (ModifierIsSet(ControlMask | AltLangMask))))) { + switch (key) { + + case KEY_BackSpace: + xf86ProcessActionEvent(ACTION_TERMINATE, NULL); + break; + + /* + * Check grabs + */ + case KEY_KP_Divide: + xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL); + break; + case KEY_KP_Multiply: + xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL); + break; + + /* + * The idea here is to pass the scancode down to a list of + * registered routines. There should be some standard conventions + * for processing certain keys. + */ + case KEY_KP_Minus: /* Keypad - */ + if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL); + if (!xf86Info.dontZoom) return TRUE; + break; + + case KEY_KP_Plus: /* Keypad + */ + if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL); + if (!xf86Info.dontZoom) return TRUE; + break; + } + } + return FALSE; +} + +/* + * xf86Wakeup -- + * Os wakeup handler. + */ + +/* ARGSUSED */ +void +xf86Wakeup(pointer blockData, int err, pointer pReadmask) +{ +#if !defined(__QNX__) + fd_set* LastSelectMask = (fd_set*)pReadmask; + fd_set devicesWithInput; + InputInfoPtr pInfo; + + if (err >= 0) { + + XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices); + if (XFD_ANYSET(&devicesWithInput)) { + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->read_input && pInfo->fd >= 0 && + (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) { + int sigstate = xf86BlockSIGIO(); + + pInfo->read_input(pInfo); + xf86UnblockSIGIO(sigstate); + /* + * Remove the descriptior from the set because more than one + * device may share the same file descriptor. + */ + FD_CLR(pInfo->fd, &devicesWithInput); + } + pInfo = pInfo->next; + } + } + } +#else /* __QNX__ */ + + InputInfoPtr pInfo; + + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->read_input && pInfo->fd >= 0) { + int sigstate = xf86BlockSIGIO(); + + pInfo->read_input(pInfo); + xf86UnblockSIGIO(sigstate); + /* + * Must break here because more than one device may share + * the same file descriptor. + */ + break; + } + pInfo = pInfo->next; + } + +#endif /* __QNX__ */ + + if (err >= 0) { /* we don't want the handlers called if select() */ + IHPtr ih; /* returned with an error condition, do we? */ + + for (ih = InputHandlers; ih; ih = ih->next) { + if (ih->enabled && ih->fd >= 0 && ih->ihproc && + (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) { + ih->ihproc(ih->fd, ih->data); + } + } + } + + if (xf86VTSwitchPending()) xf86VTSwitch(); + + if (xf86Info.inputPending) ProcessInputEvents(); +} + + +/* + * xf86SigioReadInput -- + * signal handler for the SIGIO signal. + */ +static void +xf86SigioReadInput(int fd, + void *closure) +{ + int errno_save = errno; + int sigstate = xf86BlockSIGIO(); + InputInfoPtr pInfo = (InputInfoPtr) closure; + + pInfo->read_input(pInfo); + + xf86UnblockSIGIO(sigstate); + errno = errno_save; +} + +/* + * xf86AddEnabledDevice -- + * + */ +_X_EXPORT void +xf86AddEnabledDevice(InputInfoPtr pInfo) +{ + if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) { + AddEnabledDevice(pInfo->fd); + } +} + +/* + * xf86RemoveEnabledDevice -- + * + */ +_X_EXPORT void +xf86RemoveEnabledDevice(InputInfoPtr pInfo) +{ + if (!xf86RemoveSIGIOHandler (pInfo->fd)) { + RemoveEnabledDevice(pInfo->fd); + } +} + +static int *xf86SignalIntercept = NULL; + +_X_EXPORT void +xf86InterceptSignals(int *signo) +{ + if ((xf86SignalIntercept = signo)) + *signo = -1; +} + +static void (*xf86SigIllHandler)(void) = NULL; + +_X_EXPORT void +xf86InterceptSigIll(void (*sigillhandler)(void)) +{ + xf86SigIllHandler = sigillhandler; +} + +/* + * xf86SigHandler -- + * Catch unexpected signals and exit or continue cleanly. + */ +void +xf86SigHandler(int signo) +{ + if ((signo == SIGILL) && xf86SigIllHandler) { + (*xf86SigIllHandler)(); + /* Re-arm handler just in case we unexpectedly return here */ + (void) signal(signo, xf86SigHandler); + return; + } + + if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) { + *xf86SignalIntercept = signo; + /* Re-arm handler just in case */ + (void) signal(signo, xf86SigHandler); + return; + } + + signal(signo,SIG_IGN); + xf86Info.caughtSignal = TRUE; +#ifdef XF86BIGFONT + XF86BigfontCleanup(); +#endif + + xorg_backtrace(); + + FatalError("Caught signal %d. Server aborting\n", signo); +} + +static void +xf86ReleaseKeys(DeviceIntPtr pDev) +{ + KeyClassPtr keyc = NULL; + KeySym *map = NULL; + xEvent ke; + int i = 0, j = 0, nevents = 0; + + if (!pDev || !pDev->key) + return; + + keyc = pDev->key; + map = keyc->curKeySyms.map; + + /* + * Hmm... here is the biggest hack of every time ! + * It may be possible that a switch-vt procedure has finished BEFORE + * you released all keys neccessary to do this. That peculiar behavior + * can fool the X-server pretty much, cause it assumes that some keys + * were not released. TWM may stuck alsmost completly.... + * OK, what we are doing here is after returning from the vt-switch + * exeplicitely unrelease all keyboard keys before the input-devices + * are reenabled. + */ + + for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map; + i < keyc->curKeySyms.maxKeyCode; + i++, map += keyc->curKeySyms.mapWidth) { + if (KeyPressed(i)) { + switch (*map) { + /* Don't release the lock keys */ + case XK_Caps_Lock: + case XK_Shift_Lock: + case XK_Num_Lock: + case XK_Scroll_Lock: + case XK_Kana_Lock: + break; + default: + if (pDev == inputInfo.keyboard) { + ke.u.keyButtonPointer.time = GetTimeInMillis(); + ke.u.keyButtonPointer.rootX = 0; + ke.u.keyButtonPointer.rootY = 0; + ke.u.u.type = KeyRelease; + ke.u.u.detail = i; + (*pDev->public.processInputProc) (&ke, pDev, 1); + } + else { + int sigstate = xf86BlockSIGIO (); + nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i); + for (j = 0; j < nevents; j++) + mieqEnqueue(pDev, xf86Events + j); + xf86UnblockSIGIO(sigstate); + } + break; + } + } + } +} + +/* + * xf86VTSwitch -- + * Handle requests for switching the vt. + */ +static void +xf86VTSwitch() +{ + int i, prevSIGIO; + InputInfoPtr pInfo; + IHPtr ih; + +#ifdef DEBUG + ErrorF("xf86VTSwitch()\n"); +#endif + +#ifdef XFreeXDGA + if(!DGAVTSwitch()) + return; +#endif + + /* + * Since all screens are currently all in the same state it is sufficient + * check the first. This might change in future. + */ + if (xf86Screens[0]->vtSema) { + +#ifdef DEBUG + ErrorF("xf86VTSwitch: Leaving, xf86Exiting is %s\n", + BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE)); +#endif +#ifdef DPMSExtension + if (DPMSPowerLevel != DPMSModeOn) + DPMSSet(serverClient, DPMSModeOn); +#endif + for (i = 0; i < xf86NumScreens; i++) { + if (!(dispatchException & DE_TERMINATE)) + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE); + } + + /* + * Keep the order: Disable Device > LeaveVT + * EnterVT > EnableDevice + */ + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->dev) + DisableDevice(pInfo->dev); + pInfo = pInfo->next; + } + xf86EnterServerState(SETUP); + for (i = 0; i < xf86NumScreens; i++) + xf86Screens[i]->LeaveVT(i, 0); + + for (ih = InputHandlers; ih; ih = ih->next) + xf86DisableInputHandler(ih); + xf86AccessLeave(); /* We need this here, otherwise */ + xf86AccessLeaveState(); /* console won't be restored */ + + if (!xf86VTSwitchAway()) { + /* + * switch failed + */ + +#ifdef DEBUG + ErrorF("xf86VTSwitch: Leave failed\n"); +#endif + prevSIGIO = xf86BlockSIGIO(); + xf86AccessEnter(); + xf86EnterServerState(SETUP); + for (i = 0; i < xf86NumScreens; i++) { + if (!xf86Screens[i]->EnterVT(i, 0)) + FatalError("EnterVT failed for screen %d\n", i); + } + xf86EnterServerState(OPERATING); + if (!(dispatchException & DE_TERMINATE)) { + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); + } + } + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); + + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->dev) { + xf86ReleaseKeys(pInfo->dev); + EnableDevice(pInfo->dev); + } + pInfo = pInfo->next; + } + /* XXX HACK */ + xf86ReleaseKeys(inputInfo.keyboard); + for (ih = InputHandlers; ih; ih = ih->next) + xf86EnableInputHandler(ih); + + xf86UnblockSIGIO(prevSIGIO); + + } else { +#ifdef XF86PM + if (xf86OSPMClose) + xf86OSPMClose(); + xf86OSPMClose = NULL; +#endif + + for (i = 0; i < xf86NumScreens; i++) { + /* + * zero all access functions to + * trap calls when switched away. + */ + xf86Screens[i]->vtSema = FALSE; + xf86Screens[i]->access = NULL; + xf86Screens[i]->busAccess = NULL; + } + if (xorgHWAccess) + xf86DisableIO(); + } + } else { + +#ifdef DEBUG + ErrorF("xf86VTSwitch: Entering\n"); +#endif + if (!xf86VTSwitchTo()) return; + + prevSIGIO = xf86BlockSIGIO(); +#ifdef XF86PM + xf86OSPMClose = xf86OSPMOpen(); +#endif + + if (xorgHWAccess) + xf86EnableIO(); + xf86AccessEnter(); + xf86EnterServerState(SETUP); + for (i = 0; i < xf86NumScreens; i++) { + xf86Screens[i]->vtSema = TRUE; + if (!xf86Screens[i]->EnterVT(i, 0)) + FatalError("EnterVT failed for screen %d\n", i); + } + xf86EnterServerState(OPERATING); + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE); + } + + /* Turn screen saver off when switching back */ + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); + + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->dev) { + xf86ReleaseKeys(pInfo->dev); + EnableDevice(pInfo->dev); + } + pInfo = pInfo->next; + } + /* XXX HACK */ + xf86ReleaseKeys(inputInfo.keyboard); + + for (ih = InputHandlers; ih; ih = ih->next) + xf86EnableInputHandler(ih); + + xf86UnblockSIGIO(prevSIGIO); + } +} + + +/* Input handler registration */ + +static pointer +addInputHandler(int fd, InputHandlerProc proc, pointer data) +{ + IHPtr ih; + + if (fd < 0 || !proc) + return NULL; + + ih = xcalloc(sizeof(*ih), 1); + if (!ih) + return NULL; + + ih->fd = fd; + ih->ihproc = proc; + ih->data = data; + ih->enabled = TRUE; + + ih->next = InputHandlers; + InputHandlers = ih; + + return ih; +} + +_X_EXPORT pointer +xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data) +{ + IHPtr ih = addInputHandler(fd, proc, data); + + if (ih) + AddEnabledDevice(fd); + return ih; +} + +_X_EXPORT pointer +xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data) +{ + IHPtr ih = addInputHandler(fd, proc, data); + + if (ih) + AddGeneralSocket(fd); + return ih; +} + +static void +removeInputHandler(IHPtr ih) +{ + IHPtr p; + + if (ih == InputHandlers) + InputHandlers = ih->next; + else { + p = InputHandlers; + while (p && p->next != ih) + p = p->next; + if (ih) + p->next = ih->next; + } + xfree(ih); +} + +_X_EXPORT int +xf86RemoveInputHandler(pointer handler) +{ + IHPtr ih; + int fd; + + if (!handler) + return -1; + + ih = handler; + fd = ih->fd; + + if (ih->fd >= 0) + RemoveEnabledDevice(ih->fd); + removeInputHandler(ih); + + return fd; +} + +_X_EXPORT int +xf86RemoveGeneralHandler(pointer handler) +{ + IHPtr ih; + int fd; + + if (!handler) + return -1; + + ih = handler; + fd = ih->fd; + + if (ih->fd >= 0) + RemoveGeneralSocket(ih->fd); + removeInputHandler(ih); + + return fd; +} + +_X_EXPORT void +xf86DisableInputHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = FALSE; + if (ih->fd >= 0) + RemoveEnabledDevice(ih->fd); +} + +_X_EXPORT void +xf86DisableGeneralHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = FALSE; + if (ih->fd >= 0) + RemoveGeneralSocket(ih->fd); +} + +_X_EXPORT void +xf86EnableInputHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = TRUE; + if (ih->fd >= 0) + AddEnabledDevice(ih->fd); +} + +_X_EXPORT void +xf86EnableGeneralHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = TRUE; + if (ih->fd >= 0) + AddGeneralSocket(ih->fd); +} + +/* + * As used currently by the DRI, the return value is ignored. + */ +_X_EXPORT Bool +xf86EnableVTSwitch(Bool new) +{ + static Bool def = TRUE; + Bool old; + + old = VTSwitchEnabled; + if (!new) { + /* Disable VT switching */ + def = VTSwitchEnabled; + VTSwitchEnabled = FALSE; + } else { + /* Restore VT switching to default */ + VTSwitchEnabled = def; + } + return old; +} + +void +xf86ReloadInputDevs(int sig) +{ + InputInfoPtr pInfo; + + signal(sig, (void(*)(int))xf86ReloadInputDevs); + + pInfo = xf86InputDevs; + while (pInfo) { + DisableDevice(pInfo->dev); + EnableDevice(pInfo->dev); + pInfo = pInfo->next; + } + + return; +} + +_X_EXPORT void +DDXRingBell(int volume, int pitch, int duration) { + xf86OSRingBell(volume, pitch, duration); +} diff --git a/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c new file mode 100644 index 000000000..f5babbc49 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Globals.c @@ -0,0 +1,209 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains all the XFree86 global variables. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "windowstr.h" +#include "propertyst.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Parser.h" +#include "xf86Xinput.h" +#include "xf86InPriv.h" + +/* Globals that video drivers may access */ + +/* Index into pScreen.devPrivates */ +DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKey; +/* Index of ScrnInfo in pScreen.devPrivates */ +_X_EXPORT DevPrivateKey xf86ScreenKey = &xf86ScreenKey; +_X_EXPORT DevPrivateKey xf86PixmapKey = &xf86PixmapKey; +_X_EXPORT ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */ +_X_EXPORT const unsigned char byte_reversed[256] = +{ + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +}; + +/* Globals that input drivers may access */ +InputInfoPtr xf86InputDevs = NULL; + + +/* Globals that video drivers may not access */ + +xf86InfoRec xf86Info = { + -1, /* consoleFd */ + -1, /* vtno */ + FALSE, /* vtSysreq */ + SKWhenNeeded, /* ddxSpecialKeys */ + NULL, /* pMouse */ +#ifdef XINPUT + NULL, /* mouseLocal */ +#endif + -1, /* lastEventTime */ + FALSE, /* vtRequestsPending */ + FALSE, /* inputPending */ + FALSE, /* dontVTSwitch */ + FALSE, /* dontZap */ + FALSE, /* dontZoom */ + FALSE, /* notrapSignals */ + FALSE, /* caughtSignal */ + FALSE, /* sharedMonitor */ + NULL, /* currentScreen */ +#ifdef CSRG_BASED + -1, /* screenFd */ + -1, /* consType */ +#endif + FALSE, /* allowMouseOpenFail */ + TRUE, /* vidModeEnabled */ + FALSE, /* vidModeAllowNonLocal */ + TRUE, /* miscModInDevEnabled */ + FALSE, /* miscModInDevAllowNonLocal */ + PCIOsConfig, /* pciFlags */ + Pix24DontCare, /* pixmap24 */ + X_DEFAULT, /* pix24From */ +#ifdef __i386__ + FALSE, /* pc98 */ +#endif + TRUE, /* pmFlag */ + LogNone, /* syncLog */ + 0, /* estimateSizesAggressively */ + FALSE, /* kbdCustomKeycodes */ + FALSE, /* disableRandR */ + X_DEFAULT /* randRFrom */ +}; +const char *xf86ConfigFile = NULL; +const char *xf86InputDeviceList = NULL; +const char *xf86ModulePath = DEFAULT_MODULE_PATH; +MessageType xf86ModPathFrom = X_DEFAULT; +const char *xf86LogFile = DEFAULT_LOGPREFIX; +MessageType xf86LogFileFrom = X_DEFAULT; +Bool xf86LogFileWasOpened = FALSE; +serverLayoutRec xf86ConfigLayout = {NULL, }; +_X_EXPORT confDRIRec xf86ConfigDRI = {0, }; +XF86ConfigPtr xf86configptr = NULL; +Bool xf86Resetting = FALSE; +Bool xf86Initialising = FALSE; +Bool xf86DoProbe = FALSE; +Bool xf86DoConfigure = FALSE; +Bool xf86DoModalias = FALSE; +DriverPtr *xf86DriverList = NULL; +int xf86NumDrivers = 0; +InputDriverPtr *xf86InputDriverList = NULL; +int xf86NumInputDrivers = 0; +int xf86NumScreens = 0; + +const char *xf86VisualNames[] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" +}; + +/* Parameters set only from the command line */ +char *xf86ServerName = "no-name"; +Bool xf86fpFlag = FALSE; +Bool xf86coFlag = FALSE; +Bool xf86sFlag = FALSE; +Bool xf86bsEnableFlag = FALSE; +Bool xf86bsDisableFlag = FALSE; +Bool xf86silkenMouseDisableFlag = FALSE; +#ifdef HAVE_ACPI +Bool xf86acpiDisableFlag = FALSE; +#endif +char *xf86LayoutName = NULL; +char *xf86ScreenName = NULL; +char *xf86PointerName = NULL; +char *xf86KeyboardName = NULL; +Bool xf86ProbeOnly = FALSE; +int xf86Verbose = DEFAULT_VERBOSE; +int xf86LogVerbose = DEFAULT_LOG_VERBOSE; +int xf86FbBpp = -1; +Pix24Flags xf86Pix24 = Pix24DontCare; +int xf86Depth = -1; +rgb xf86Weight = {0, 0, 0}; +Bool xf86FlipPixels = FALSE; +Gamma xf86Gamma = {0.0, 0.0, 0.0}; +Bool xf86ShowUnresolved = DEFAULT_UNRESOLVED; +Bool xf86BestRefresh = DEFAULT_BEST_REFRESH; +Bool xf86AllowMouseOpenFail = FALSE; +#ifdef XF86VIDMODE +Bool xf86VidModeDisabled = FALSE; +Bool xf86VidModeAllowNonLocal = FALSE; +#endif +#ifdef XF86MISC +Bool xf86MiscModInDevDisabled = FALSE; +Bool xf86MiscModInDevAllowNonLocal = FALSE; +#endif +RootWinPropPtr *xf86RegisteredPropertiesTable = NULL; +_X_EXPORT Bool xf86inSuspend = FALSE; +Bool xorgHWAccess = FALSE; + +struct pci_slot_match xf86IsolateDevice = { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0 +}; diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c new file mode 100644 index 000000000..282eb49f9 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -0,0 +1,2959 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * Authors: Dirk Hohndel + * David Dawes + * ... and others + * + * This file includes the helper functions that the server provides for + * different drivers. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "Pci.h" + +#include +#include "os.h" +#include "servermd.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "propertyst.h" +#include "gcstruct.h" +#include "loaderProcs.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "micmap.h" +#include "xf86PciInfo.h" +#include "xf86DDC.h" +#include "xf86Xinput.h" +#include "xf86InPriv.h" +#include "mivalidate.h" +#include "xf86RAC.h" +#include "xf86Bus.h" +#include "xf86Version.h" + +/* For xf86GetClocks */ +#if defined(CSRG_BASED) || defined(__GNU__) +#define HAS_SETPRIORITY +#include +#endif + +static int xf86ScrnInfoPrivateCount = 0; + + +/* Add a pointer to a new DriverRec to xf86DriverList */ + +_X_EXPORT void +xf86AddDriver(DriverPtr driver, pointer module, int flags) +{ + /* Don't add null entries */ + if (!driver) + return; + + if (xf86DriverList == NULL) + xf86NumDrivers = 0; + + xf86NumDrivers++; + xf86DriverList = xnfrealloc(xf86DriverList, + xf86NumDrivers * sizeof(DriverPtr)); + xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec)); + if (flags & HaveDriverFuncs) + *xf86DriverList[xf86NumDrivers - 1] = *driver; + else { + (void) memset( xf86DriverList[xf86NumDrivers - 1], 0, + sizeof( DriverRec ) ); + (void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver, + sizeof(DriverRec1)); + + } + xf86DriverList[xf86NumDrivers - 1]->module = module; + xf86DriverList[xf86NumDrivers - 1]->refCount = 0; +} + +_X_EXPORT void +xf86DeleteDriver(int drvIndex) +{ + if (xf86DriverList[drvIndex] + && (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) { + if (xf86DriverList[drvIndex]->module) + UnloadModule(xf86DriverList[drvIndex]->module); + xfree(xf86DriverList[drvIndex]); + xf86DriverList[drvIndex] = NULL; + } +} + +/* Add a pointer to a new InputDriverRec to xf86InputDriverList */ + +_X_EXPORT void +xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags) +{ + /* Don't add null entries */ + if (!driver) + return; + + if (xf86InputDriverList == NULL) + xf86NumInputDrivers = 0; + + xf86NumInputDrivers++; + xf86InputDriverList = xnfrealloc(xf86InputDriverList, + xf86NumInputDrivers * sizeof(InputDriverPtr)); + xf86InputDriverList[xf86NumInputDrivers - 1] = + xnfalloc(sizeof(InputDriverRec)); + *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver; + xf86InputDriverList[xf86NumInputDrivers - 1]->module = module; + xf86InputDriverList[xf86NumInputDrivers - 1]->refCount = 0; +} + +void +xf86DeleteInputDriver(int drvIndex) +{ + if (xf86InputDriverList[drvIndex] && xf86InputDriverList[drvIndex]->module) + UnloadModule(xf86InputDriverList[drvIndex]->module); + xfree(xf86InputDriverList[drvIndex]); + xf86InputDriverList[drvIndex] = NULL; +} + +InputDriverPtr +xf86LookupInputDriver(const char *name) +{ + int i; + + for (i = 0; i < xf86NumInputDrivers; i++) { + if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName && + xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0) + return xf86InputDriverList[i]; + } + return NULL; +} + +InputInfoPtr +xf86LookupInput(const char *name) +{ + InputInfoPtr p; + + for (p = xf86InputDevs; p != NULL; p = p->next) { + if (strcmp(name, p->name) == 0) + return p; + } + + return NULL; +} + +/* ABI stubs of despair */ +_X_EXPORT void +xf86AddModuleInfo(pointer info, pointer module) +{ +} + +_X_EXPORT void +xf86DeleteModuleInfo(int idx) +{ +} + +/* Allocate a new ScrnInfoRec in xf86Screens */ + +_X_EXPORT ScrnInfoPtr +xf86AllocateScreen(DriverPtr drv, int flags) +{ + int i; + + if (xf86Screens == NULL) + xf86NumScreens = 0; + + i = xf86NumScreens++; + xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr)); + xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); + xf86Screens[i]->scrnIndex = i; /* Changes when a screen is removed */ + xf86Screens[i]->origIndex = i; /* This never changes */ + xf86Screens[i]->privates = xnfcalloc(sizeof(DevUnion), + xf86ScrnInfoPrivateCount); + /* + * EnableDisableFBAccess now gets initialized in InitOutput() + * xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; + */ + + xf86Screens[i]->drv = drv; + drv->refCount++; + xf86Screens[i]->module = DuplicateModule(drv->module, NULL); + /* + * set the initial access state. This will be modified after PreInit. + * XXX Or should we do it some other place? + */ + xf86Screens[i]->CurrentAccess = &xf86CurrentAccess; + xf86Screens[i]->resourceType = MEM_IO; + +#ifdef DEBUG + /* OOps -- What's this ? */ + ErrorF("xf86AllocateScreen - xf86Screens[%d]->pScreen = %p\n", + i, xf86Screens[i]->pScreen ); + if ( NULL != xf86Screens[i]->pScreen ) { + ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n", + i, xf86Screens[i]->pScreen->CreateWindow ); + } +#endif + + xf86Screens[i]->DriverFunc = drv->driverFunc; + + return xf86Screens[i]; +} + + +/* + * Remove an entry from xf86Screens. Ideally it should free all allocated + * data. To do this properly may require a driver hook. + */ + +_X_EXPORT void +xf86DeleteScreen(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn; + int i; + + /* First check if the screen is valid */ + if (xf86NumScreens == 0 || xf86Screens == NULL) + return; + + if (scrnIndex > xf86NumScreens - 1) + return; + + if (!(pScrn = xf86Screens[scrnIndex])) + return; + + /* If a FreeScreen function is defined, call it here */ + if (pScrn->FreeScreen != NULL) + pScrn->FreeScreen(scrnIndex, 0); + + while (pScrn->modes) + xf86DeleteMode(&pScrn->modes, pScrn->modes); + + while (pScrn->modePool) + xf86DeleteMode(&pScrn->modePool, pScrn->modePool); + + xf86OptionListFree(pScrn->options); + + if (pScrn->module) + UnloadModule(pScrn->module); + + if (pScrn->drv) + pScrn->drv->refCount--; + + if (pScrn->privates) + xfree(pScrn->privates); + + xf86ClearEntityListForScreen(scrnIndex); + + xfree(pScrn); + + /* Move the other entries down, updating their scrnIndex fields */ + + xf86NumScreens--; + + for (i = scrnIndex; i < xf86NumScreens; i++) { + xf86Screens[i] = xf86Screens[i + 1]; + xf86Screens[i]->scrnIndex = i; + /* Also need to take care of the screen layout settings */ + } +} + +/* + * Allocate a private in ScrnInfoRec. + */ + +_X_EXPORT int +xf86AllocateScrnInfoPrivateIndex(void) +{ + int idx, i; + ScrnInfoPtr pScr; + DevUnion *nprivs; + + idx = xf86ScrnInfoPrivateCount++; + for (i = 0; i < xf86NumScreens; i++) { + pScr = xf86Screens[i]; + nprivs = xnfrealloc(pScr->privates, + xf86ScrnInfoPrivateCount * sizeof(DevUnion)); + /* Zero the new private */ + bzero(&nprivs[idx], sizeof(DevUnion)); + pScr->privates = nprivs; + } + return idx; +} + +/* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */ +_X_EXPORT InputInfoPtr +xf86AllocateInput(InputDriverPtr drv, int flags) +{ + InputInfoPtr new, *prev = NULL; + + if (!(new = xcalloc(sizeof(InputInfoRec), 1))) + return NULL; + + new->drv = drv; + drv->refCount++; + new->module = DuplicateModule(drv->module, NULL); + + for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next) + ; + + *prev = new; + new->next = NULL; + + return new; +} + + +/* + * Remove an entry from xf86InputDevs. Ideally it should free all allocated + * data. To do this properly may require a driver hook. + */ + +_X_EXPORT void +xf86DeleteInput(InputInfoPtr pInp, int flags) +{ + InputInfoPtr p; + + /* First check if the inputdev is valid. */ + if (pInp == NULL) + return; + +#if 0 + /* If a free function is defined, call it here. */ + if (pInp->free) + pInp->free(pInp, 0); +#endif + + if (pInp->module) + UnloadModule(pInp->module); + + if (pInp->drv) + pInp->drv->refCount--; + + /* This should *really* be handled in drv->UnInit(dev) call instead */ +#if 0 + if (pInp->private) + xfree(pInp->private); +#endif + + /* Remove the entry from the list. */ + if (pInp == xf86InputDevs) + xf86InputDevs = pInp->next; + else { + p = xf86InputDevs; + while (p && p->next != pInp) + p = p->next; + if (p) + p->next = pInp->next; + /* Else the entry wasn't in the xf86InputDevs list (ignore this). */ + } + xfree(pInp); +} + +_X_EXPORT Bool +xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad) +{ + int i; + + if (pScrn->numFormats >= MAXFORMATS) + return FALSE; + + if (bpp <= 0) { + if (depth == 1) + bpp = 1; + else if (depth <= 8) + bpp = 8; + else if (depth <= 16) + bpp = 16; + else if (depth <= 32) + bpp = 32; + else + return FALSE; + } + if (pad <= 0) + pad = BITMAP_SCANLINE_PAD; + + i = pScrn->numFormats++; + pScrn->formats[i].depth = depth; + pScrn->formats[i].bitsPerPixel = bpp; + pScrn->formats[i].scanlinePad = pad; + return TRUE; +} + +/* + * Set the depth we are using based on (in the following order of preference): + * - values given on the command line + * - values given in the config file + * - values provided by the driver + * - an overall default when nothing else is given + * + * Also find a Display subsection matching the depth/bpp found. + * + * Sets the following ScrnInfoRec fields: + * bitsPerPixel, pixmap24, depth, display, imageByteOrder, + * bitmapScanlinePad, bitmapScanlineUnit, bitmapBitOrder, numFormats, + * formats, fbFormat. + */ + +/* Can the screen handle 24 bpp pixmaps */ +#define DO_PIX24(f) ((f & Support24bppFb) || \ + ((f & Support32bppFb) && (f & SupportConvert24to32))) + +/* Can the screen handle 32 bpp pixmaps */ +#define DO_PIX32(f) ((f & Support32bppFb) || \ + ((f & Support24bppFb) && (f & SupportConvert32to24))) + +/* Does the screen prefer 32bpp fb for 24bpp pixmaps */ +#define CHOOSE32FOR24(f) ((f & Support32bppFb) && (f & SupportConvert24to32) \ + && (f & PreferConvert24to32)) + +/* Does the screen prefer 24bpp fb for 32bpp pixmaps */ +#define CHOOSE24FOR32(f) ((f & Support24bppFb) && (f & SupportConvert32to24) \ + && (f & PreferConvert32to24)) + +/* Can the screen handle 32bpp pixmaps for 24bpp fb */ +#define DO_PIX32FOR24(f) ((f & Support24bppFb) && (f & SupportConvert32to24)) + +/* Can the screen handle 24bpp pixmaps for 32bpp fb */ +#define DO_PIX24FOR32(f) ((f & Support32bppFb) && (f & SupportConvert24to32)) + +#ifndef GLOBAL_DEFAULT_DEPTH +#define GLOBAL_DEFAULT_DEPTH 24 +#endif + +#ifndef GLOBAL_DEFAULT_FBBPP +#define GLOBAL_DEFAULT_FBBPP 32 +#endif + +_X_EXPORT Bool +xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp, + int depth24flags) +{ + int i; + DispPtr disp; + Pix24Flags pix24 = xf86Info.pixmap24; + Bool nomatch = FALSE; + + scrp->bitsPerPixel = -1; + scrp->depth = -1; + scrp->pixmap24 = Pix24DontCare; + scrp->bitsPerPixelFrom = X_DEFAULT; + scrp->depthFrom = X_DEFAULT; + + if (xf86FbBpp > 0) { + scrp->bitsPerPixel = xf86FbBpp; + scrp->bitsPerPixelFrom = X_CMDLINE; + } + + if (xf86Depth > 0) { + scrp->depth = xf86Depth; + scrp->depthFrom = X_CMDLINE; + } + + if (xf86FbBpp < 0 && xf86Depth < 0) { + if (scrp->confScreen->defaultfbbpp > 0) { + scrp->bitsPerPixel = scrp->confScreen->defaultfbbpp; + scrp->bitsPerPixelFrom = X_CONFIG; + } + if (scrp->confScreen->defaultdepth > 0) { + scrp->depth = scrp->confScreen->defaultdepth; + scrp->depthFrom = X_CONFIG; + } + + if (scrp->confScreen->defaultfbbpp <= 0 && + scrp->confScreen->defaultdepth <= 0) { + /* + * Check for DefaultDepth and DefaultFbBpp options in the + * Device sections. + */ + int i; + GDevPtr device; + Bool found = FALSE; + + for (i = 0; i < scrp->numEntities; i++) { + device = xf86GetDevFromEntity(scrp->entityList[i], + scrp->entityInstanceList[i]); + if (device && device->options) { + if (xf86FindOption(device->options, "DefaultDepth")) { + scrp->depth = xf86SetIntOption(device->options, + "DefaultDepth", -1); + scrp->depthFrom = X_CONFIG; + found = TRUE; + } + if (xf86FindOption(device->options, "DefaultFbBpp")) { + scrp->bitsPerPixel = xf86SetIntOption(device->options, + "DefaultFbBpp", + -1); + scrp->bitsPerPixelFrom = X_CONFIG; + found = TRUE; + } + } + if (found) + break; + } + } + } + + /* If none of these is set, pick a default */ + if (scrp->bitsPerPixel < 0 && scrp->depth < 0) { + if (fbbpp > 0 || depth > 0) { + if (fbbpp > 0) + scrp->bitsPerPixel = fbbpp; + if (depth > 0) + scrp->depth = depth; + } else { + scrp->bitsPerPixel = GLOBAL_DEFAULT_FBBPP; + scrp->depth = GLOBAL_DEFAULT_DEPTH; + } + } + + /* If any are not given, determine a default for the others */ + + if (scrp->bitsPerPixel < 0) { + /* The depth must be set */ + if (scrp->depth > -1) { + if (scrp->depth == 1) + scrp->bitsPerPixel = 1; + else if (scrp->depth <= 4) + scrp->bitsPerPixel = 4; + else if (scrp->depth <= 8) + scrp->bitsPerPixel = 8; + else if (scrp->depth <= 16) + scrp->bitsPerPixel = 16; + else if (scrp->depth <= 24) { + /* + * Figure out if a choice is possible based on the depth24 + * and pix24 flags. + */ + /* Check pix24 first */ + if (pix24 != Pix24DontCare) { + if (pix24 == Pix24Use32) { + if (DO_PIX32(depth24flags)) { + if (CHOOSE24FOR32(depth24flags)) + scrp->bitsPerPixel = 24; + else + scrp->bitsPerPixel = 32; + } else { + nomatch = TRUE; + } + } else if (pix24 == Pix24Use24) { + if (DO_PIX24(depth24flags)) { + if (CHOOSE32FOR24(depth24flags)) + scrp->bitsPerPixel = 32; + else + scrp->bitsPerPixel = 24; + } else { + nomatch = TRUE; + } + } + } else { + if (DO_PIX32(depth24flags)) { + if (CHOOSE24FOR32(depth24flags)) + scrp->bitsPerPixel = 24; + else + scrp->bitsPerPixel = 32; + } else if (DO_PIX24(depth24flags)) { + if (CHOOSE32FOR24(depth24flags)) + scrp->bitsPerPixel = 32; + else + scrp->bitsPerPixel = 24; + } + } + } else if (scrp->depth <= 32) + scrp->bitsPerPixel = 32; + else { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Specified depth (%d) is greater than 32\n", + scrp->depth); + return FALSE; + } + } else { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "xf86SetDepthBpp: internal error: depth and fbbpp" + " are both not set\n"); + return FALSE; + } + if (scrp->bitsPerPixel < 0) { + if (nomatch) + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Driver can't support depth 24 pixmap format (%d)\n", + PIX24TOBPP(pix24)); + else if ((depth24flags & (Support24bppFb | Support32bppFb)) == + NoDepth24Support) + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Driver can't support depth 24\n"); + else + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Can't find fbbpp for depth 24\n"); + return FALSE; + } + scrp->bitsPerPixelFrom = X_PROBED; + } + + if (scrp->depth <= 0) { + /* bitsPerPixel is already set */ + switch (scrp->bitsPerPixel) { + case 32: + scrp->depth = 24; + break; + default: + /* 1, 4, 8, 16 and 24 */ + scrp->depth = scrp->bitsPerPixel; + break; + } + scrp->depthFrom = X_PROBED; + } + + /* Sanity checks */ + if (scrp->depth < 1 || scrp->depth > 32) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Specified depth (%d) is not in the range 1-32\n", + scrp->depth); + return FALSE; + } + switch (scrp->bitsPerPixel) { + case 1: + case 4: + case 8: + case 16: + case 24: + case 32: + break; + default: + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Specified fbbpp (%d) is not a permitted value\n", + scrp->bitsPerPixel); + return FALSE; + } + if (scrp->depth > scrp->bitsPerPixel) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Specified depth (%d) is greater than the fbbpp (%d)\n", + scrp->depth, scrp->bitsPerPixel); + return FALSE; + } + + /* set scrp->pixmap24 if the driver isn't flexible */ + if (scrp->bitsPerPixel == 24 && !DO_PIX32FOR24(depth24flags)) { + scrp->pixmap24 = Pix24Use24; + } + if (scrp->bitsPerPixel == 32 && !DO_PIX24FOR32(depth24flags)) { + scrp->pixmap24 = Pix24Use32; + } + + /* + * Find the Display subsection matching the depth/fbbpp and initialise + * scrp->display with it. + */ + for (i = 0, disp = scrp->confScreen->displays; + i < scrp->confScreen->numdisplays; i++, disp++) { + if ((disp->depth == scrp->depth && disp->fbbpp == scrp->bitsPerPixel) + || (disp->depth == scrp->depth && disp->fbbpp <= 0) + || (disp->fbbpp == scrp->bitsPerPixel && disp->depth <= 0)) { + scrp->display = disp; + break; + } + } + + /* + * If an exact match can't be found, see if there is one with no + * depth or fbbpp specified. + */ + if (i == scrp->confScreen->numdisplays) { + for (i = 0, disp = scrp->confScreen->displays; + i < scrp->confScreen->numdisplays; i++, disp++) { + if (disp->depth <= 0 && disp->fbbpp <= 0) { + scrp->display = disp; + break; + } + } + } + + /* + * If all else fails, create a default one. + */ + if (i == scrp->confScreen->numdisplays) { + scrp->confScreen->numdisplays++; + scrp->confScreen->displays = + xnfrealloc(scrp->confScreen->displays, + scrp->confScreen->numdisplays * sizeof(DispRec)); + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "Creating default Display subsection in Screen section\n" + "\t\"%s\" for depth/fbbpp %d/%d\n", + scrp->confScreen->id, scrp->depth, scrp->bitsPerPixel); + memset(&scrp->confScreen->displays[i], 0, sizeof(DispRec)); + scrp->confScreen->displays[i].blackColour.red = -1; + scrp->confScreen->displays[i].blackColour.green = -1; + scrp->confScreen->displays[i].blackColour.blue = -1; + scrp->confScreen->displays[i].whiteColour.red = -1; + scrp->confScreen->displays[i].whiteColour.green = -1; + scrp->confScreen->displays[i].whiteColour.blue = -1; + scrp->confScreen->displays[i].defaultVisual = -1; + scrp->confScreen->displays[i].modes = xnfalloc(sizeof(char *)); + scrp->confScreen->displays[i].modes[0] = NULL; + scrp->confScreen->displays[i].depth = depth; + scrp->confScreen->displays[i].fbbpp = fbbpp; + scrp->display = &scrp->confScreen->displays[i]; + } + + /* + * Setup defaults for the display-wide attributes the framebuffer will + * need. These defaults should eventually be set globally, and not + * dependent on the screens. + */ + scrp->imageByteOrder = IMAGE_BYTE_ORDER; + scrp->bitmapScanlinePad = BITMAP_SCANLINE_PAD; + if (scrp->depth < 8) { + /* Planar modes need these settings */ + scrp->bitmapScanlineUnit = 8; + scrp->bitmapBitOrder = MSBFirst; + } else { + scrp->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; + scrp->bitmapBitOrder = BITMAP_BIT_ORDER; + } + + /* + * If an unusual depth is required, add it to scrp->formats. The formats + * for the common depths are handled globally in InitOutput + */ + switch (scrp->depth) { + case 1: + case 4: + case 8: + case 15: + case 16: + case 24: + /* Common depths. Nothing to do for them */ + break; + default: + if (!xf86AddPixFormat(scrp, scrp->depth, 0, 0)) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Can't add pixmap format for depth %d\n", scrp->depth); + return FALSE; + } + } + + /* Initialise the framebuffer format for this screen */ + scrp->fbFormat.depth = scrp->depth; + scrp->fbFormat.bitsPerPixel = scrp->bitsPerPixel; + scrp->fbFormat.scanlinePad = BITMAP_SCANLINE_PAD; + + return TRUE; +} + +/* + * Print out the selected depth and bpp. + */ +_X_EXPORT void +xf86PrintDepthBpp(ScrnInfoPtr scrp) +{ + xf86DrvMsg(scrp->scrnIndex, scrp->depthFrom, "Depth %d, ", scrp->depth); + xf86Msg(scrp->bitsPerPixelFrom, "framebuffer bpp %d\n", scrp->bitsPerPixel); +} + +/* + * xf86SetWeight sets scrp->weight, scrp->mask, scrp->offset, and for depths + * greater than MAX_PSEUDO_DEPTH also scrp->rgbBits. + */ +_X_EXPORT Bool +xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask) +{ + MessageType weightFrom = X_DEFAULT; + + scrp->weight.red = 0; + scrp->weight.green = 0; + scrp->weight.blue = 0; + + if (xf86Weight.red > 0 && xf86Weight.green > 0 && xf86Weight.blue > 0) { + scrp->weight = xf86Weight; + weightFrom = X_CMDLINE; + } else if (scrp->display->weight.red > 0 && scrp->display->weight.green > 0 + && scrp->display->weight.blue > 0) { + scrp->weight = scrp->display->weight; + weightFrom = X_CONFIG; + } else if (weight.red > 0 && weight.green > 0 && weight.blue > 0) { + scrp->weight = weight; + } else { + switch (scrp->depth) { + case 1: + case 4: + case 8: + scrp->weight.red = scrp->weight.green = + scrp->weight.blue = scrp->rgbBits; + break; + case 15: + scrp->weight.red = scrp->weight.green = scrp->weight.blue = 5; + break; + case 16: + scrp->weight.red = scrp->weight.blue = 5; + scrp->weight.green = 6; + break; + case 24: + scrp->weight.red = scrp->weight.green = scrp->weight.blue = 8; + break; + case 30: + scrp->weight.red = scrp->weight.green = scrp->weight.blue = 10; + break; + } + } + + if (scrp->weight.red) + xf86DrvMsg(scrp->scrnIndex, weightFrom, "RGB weight %d%d%d\n", + (int)scrp->weight.red, (int)scrp->weight.green, + (int)scrp->weight.blue); + + if (scrp->depth > MAX_PSEUDO_DEPTH && + (scrp->depth != scrp->weight.red + scrp->weight.green + + scrp->weight.blue)) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Weight given (%d%d%d) is inconsistent with the " + "depth (%d)\n", + (int)scrp->weight.red, (int)scrp->weight.green, + (int)scrp->weight.blue, scrp->depth); + return FALSE; + } + if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->weight.red) { + /* + * XXX Does this even mean anything for TrueColor visuals? + * If not, we shouldn't even be setting it here. However, this + * matches the behaviour of 3.x versions of XFree86. + */ + scrp->rgbBits = scrp->weight.red; + if (scrp->weight.green > scrp->rgbBits) + scrp->rgbBits = scrp->weight.green; + if (scrp->weight.blue > scrp->rgbBits) + scrp->rgbBits = scrp->weight.blue; + } + + /* Set the mask and offsets */ + if (mask.red == 0 || mask.green == 0 || mask.blue == 0) { + /* Default to a setting common to PC hardware */ + scrp->offset.red = scrp->weight.green + scrp->weight.blue; + scrp->offset.green = scrp->weight.blue; + scrp->offset.blue = 0; + scrp->mask.red = ((1 << scrp->weight.red) - 1) << scrp->offset.red; + scrp->mask.green = ((1 << scrp->weight.green) - 1) + << scrp->offset.green; + scrp->mask.blue = (1 << scrp->weight.blue) - 1; + } else { + /* Initialise to the values passed */ + scrp->mask.red = mask.red; + scrp->mask.green = mask.green; + scrp->mask.blue = mask.blue; + scrp->offset.red = ffs(mask.red); + scrp->offset.green = ffs(mask.green); + scrp->offset.blue = ffs(mask.blue); + } + return TRUE; +} + +_X_EXPORT Bool +xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual) +{ + MessageType visualFrom = X_DEFAULT; + + if (defaultColorVisualClass >= 0) { + scrp->defaultVisual = defaultColorVisualClass; + visualFrom = X_CMDLINE; + } else if (scrp->display->defaultVisual >= 0) { + scrp->defaultVisual = scrp->display->defaultVisual; + visualFrom = X_CONFIG; + } else if (visual >= 0) { + scrp->defaultVisual = visual; + } else { + if (scrp->depth == 1) + scrp->defaultVisual = StaticGray; + else if (scrp->depth == 4) + scrp->defaultVisual = StaticColor; + else if (scrp->depth <= MAX_PSEUDO_DEPTH) + scrp->defaultVisual = PseudoColor; + else + scrp->defaultVisual = TrueColor; + } + switch (scrp->defaultVisual) { + case StaticGray: + case GrayScale: + case StaticColor: + case PseudoColor: + case TrueColor: + case DirectColor: + xf86DrvMsg(scrp->scrnIndex, visualFrom, "Default visual is %s\n", + xf86VisualNames[scrp->defaultVisual]); + return TRUE; + default: + + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Invalid default visual class (%d)\n", scrp->defaultVisual); + return FALSE; + } +} + +#define TEST_GAMMA(g) \ + (g).red > GAMMA_ZERO || (g).green > GAMMA_ZERO || (g).blue > GAMMA_ZERO + +#define SET_GAMMA(g) \ + (g) > GAMMA_ZERO ? (g) : 1.0 + +_X_EXPORT Bool +xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma) +{ + MessageType from = X_DEFAULT; +#if 0 + xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC); +#endif + if (TEST_GAMMA(xf86Gamma)) { + from = X_CMDLINE; + scrp->gamma.red = SET_GAMMA(xf86Gamma.red); + scrp->gamma.green = SET_GAMMA(xf86Gamma.green); + scrp->gamma.blue = SET_GAMMA(xf86Gamma.blue); + } else if (TEST_GAMMA(scrp->monitor->gamma)) { + from = X_CONFIG; + scrp->gamma.red = SET_GAMMA(scrp->monitor->gamma.red); + scrp->gamma.green = SET_GAMMA(scrp->monitor->gamma.green); + scrp->gamma.blue = SET_GAMMA(scrp->monitor->gamma.blue); +#if 0 + } else if ( DDC && DDC->features.gamma > GAMMA_ZERO ) { + from = X_PROBED; + scrp->gamma.red = SET_GAMMA(DDC->features.gamma); + scrp->gamma.green = SET_GAMMA(DDC->features.gamma); + scrp->gamma.blue = SET_GAMMA(DDC->features.gamma); + /* EDID structure version 2 gives optional seperate red, green & blue gamma values + * in bytes 0x57-0x59 */ +#endif + } else if (TEST_GAMMA(gamma)) { + scrp->gamma.red = SET_GAMMA(gamma.red); + scrp->gamma.green = SET_GAMMA(gamma.green); + scrp->gamma.blue = SET_GAMMA(gamma.blue); + } else { + scrp->gamma.red = 1.0; + scrp->gamma.green = 1.0; + scrp->gamma.blue = 1.0; + } + xf86DrvMsg(scrp->scrnIndex, from, + "Using gamma correction (%.1f, %.1f, %.1f)\n", + scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue); + + return TRUE; +} + +#undef TEST_GAMMA +#undef SET_GAMMA + + +/* + * Set the DPI from the command line option. XXX should allow it to be + * calculated from the widthmm/heightmm values. + */ + +#undef MMPERINCH +#define MMPERINCH 25.4 + +_X_EXPORT void +xf86SetDpi(ScrnInfoPtr pScrn, int x, int y) +{ + MessageType from = X_DEFAULT; + xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC); + int ddcWidthmm, ddcHeightmm; + int widthErr, heightErr; + + /* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */ + pScrn->widthmm = pScrn->monitor->widthmm; + pScrn->heightmm = pScrn->monitor->heightmm; + + if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0) ) { + /* DDC gives display size in mm for individual modes, + * but cm for monitor + */ + ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */ + ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */ + } else { + ddcWidthmm = ddcHeightmm = 0; + } + + if (monitorResolution > 0) { + pScrn->xDpi = monitorResolution; + pScrn->yDpi = monitorResolution; + from = X_CMDLINE; + } else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) { + from = X_CONFIG; + if (pScrn->widthmm > 0) { + pScrn->xDpi = + (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm); + } + if (pScrn->heightmm > 0) { + pScrn->yDpi = + (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm); + } + if (pScrn->xDpi > 0 && pScrn->yDpi <= 0) + pScrn->yDpi = pScrn->xDpi; + if (pScrn->yDpi > 0 && pScrn->xDpi <= 0) + pScrn->xDpi = pScrn->yDpi; + xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n", + pScrn->widthmm, pScrn->heightmm); + + /* Warn if config and probe disagree about display size */ + if ( ddcWidthmm && ddcHeightmm ) { + if (pScrn->widthmm > 0) { + widthErr = abs(ddcWidthmm - pScrn->widthmm); + } else { + widthErr = 0; + } + if (pScrn->heightmm > 0) { + heightErr = abs(ddcHeightmm - pScrn->heightmm); + } else { + heightErr = 0; + } + if (widthErr>10 || heightErr>10) { + /* Should include config file name for monitor here */ + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n", + ddcWidthmm,ddcHeightmm, pScrn->widthmm,pScrn->heightmm); + } + } + } else if ( ddcWidthmm && ddcHeightmm ) { + from = X_PROBED; + xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n", + ddcWidthmm, ddcHeightmm ); + pScrn->widthmm = ddcWidthmm; + pScrn->heightmm = ddcHeightmm; + if (pScrn->widthmm > 0) { + pScrn->xDpi = + (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm); + } + if (pScrn->heightmm > 0) { + pScrn->yDpi = + (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm); + } + if (pScrn->xDpi > 0 && pScrn->yDpi <= 0) + pScrn->yDpi = pScrn->xDpi; + if (pScrn->yDpi > 0 && pScrn->xDpi <= 0) + pScrn->xDpi = pScrn->yDpi; + } else { + if (x > 0) + pScrn->xDpi = x; + else + pScrn->xDpi = DEFAULT_DPI; + if (y > 0) + pScrn->yDpi = y; + else + pScrn->yDpi = DEFAULT_DPI; + } + xf86DrvMsg(pScrn->scrnIndex, from, "DPI set to (%d, %d)\n", + pScrn->xDpi, pScrn->yDpi); +} + +#undef MMPERINCH + + +_X_EXPORT void +xf86SetBlackWhitePixels(ScreenPtr pScreen) +{ + if (xf86FlipPixels) { + pScreen->whitePixel = 0; + pScreen->blackPixel = 1; + } else { + pScreen->whitePixel = 1; + pScreen->blackPixel = 0; + } +} + +/* + * xf86SetRootClip -- + * Enable or disable rendering to the screen by + * setting the root clip list and revalidating + * all of the windows + */ + +static void +xf86SetRootClip (ScreenPtr pScreen, Bool enable) +{ + WindowPtr pWin = WindowTable[pScreen->myNum]; + WindowPtr pChild; + Bool WasViewable = (Bool)(pWin->viewable); + Bool anyMarked = FALSE; +#ifdef DO_SAVE_UNDERS + Bool dosave = FALSE; +#endif + WindowPtr pLayerWin; + BoxRec box; + + if (WasViewable) + { + for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) + { + (void) (*pScreen->MarkOverlappedWindows)(pChild, + pChild, + &pLayerWin); + } + (*pScreen->MarkWindow) (pWin); + anyMarked = TRUE; + if (pWin->valdata) + { + if (HasBorder (pWin)) + { + RegionPtr borderVisible; + + borderVisible = REGION_CREATE(pScreen, NullBox, 1); + REGION_SUBTRACT(pScreen, borderVisible, + &pWin->borderClip, &pWin->winSize); + pWin->valdata->before.borderVisible = borderVisible; + } + pWin->valdata->before.resized = TRUE; + } + } + + /* + * Use REGION_BREAK to avoid optimizations in ValidateTree + * that assume the root borderClip can't change well, normally + * it doesn't...) + */ + if (enable) + { + box.x1 = 0; + box.y1 = 0; + box.x2 = pScreen->width; + box.y2 = pScreen->height; + REGION_INIT (pScreen, &pWin->winSize, &box, 1); + REGION_INIT (pScreen, &pWin->borderSize, &box, 1); + if (WasViewable) + REGION_RESET(pScreen, &pWin->borderClip, &box); + pWin->drawable.width = pScreen->width; + pWin->drawable.height = pScreen->height; + REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); + } + else + { + REGION_EMPTY(pScreen, &pWin->borderClip); + REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); + } + + ResizeChildrenWinSize (pWin, 0, 0, 0, 0); + + if (WasViewable) + { + if (pWin->firstChild) + { + anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild, + pWin->firstChild, + (WindowPtr *)NULL); + } + else + { + (*pScreen->MarkWindow) (pWin); + anyMarked = TRUE; + } + +#ifdef DO_SAVE_UNDERS + if (DO_SAVE_UNDERS(pWin)) + { + dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); + } +#endif /* DO_SAVE_UNDERS */ + + if (anyMarked) + (*pScreen->ValidateTree)(pWin, NullWindow, VTOther); + } + + if (WasViewable) + { + if (anyMarked) + (*pScreen->HandleExposures)(pWin); +#ifdef DO_SAVE_UNDERS + if (dosave) + (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); +#endif /* DO_SAVE_UNDERS */ + if (anyMarked && pScreen->PostValidateTree) + (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther); + } + if (pWin->realized) + WindowsRestructured (); + FlushAllOutput (); +} + +/* + * Function to enable/disable access to the frame buffer + * + * This is used when VT switching and when entering/leaving DGA direct mode. + * + * This has been rewritten again to eliminate the saved pixmap. The + * devPrivate field in the screen pixmap is set to NULL to catch code + * accidentally referencing the frame buffer while the X server is not + * supposed to touch it. + * + * Here, we exchange the pixmap private data, rather than the pixmaps + * themselves to avoid having to find and change any references to the screen + * pixmap such as GC's, window privates etc. This also means that this code + * does not need to know exactly how the pixmap pixels are accessed. Further, + * this exchange is >not< done through the screen's ModifyPixmapHeader() + * vector. This means the called frame buffer code layers can determine + * whether they are switched in or out by keeping track of the root pixmap's + * private data, and therefore don't need to access pScrnInfo->vtSema. + */ +_X_EXPORT void +xf86EnableDisableFBAccess(int scrnIndex, Bool enable) +{ + ScrnInfoPtr pScrnInfo = xf86Screens[scrnIndex]; + ScreenPtr pScreen = pScrnInfo->pScreen; + PixmapPtr pspix; + + pspix = (*pScreen->GetScreenPixmap) (pScreen); + if (enable) + { + /* + * Restore the screen pixmap devPrivate field + */ + pspix->devPrivate = pScrnInfo->pixmapPrivate; + /* + * Restore all of the clip lists on the screen + */ + if (!xf86Resetting) + xf86SetRootClip (pScreen, TRUE); + + } + else + { + /* + * Empty all of the clip lists on the screen + */ + xf86SetRootClip (pScreen, FALSE); + /* + * save the screen pixmap devPrivate field and + * replace it with NULL so accidental references + * to the frame buffer are caught + */ + pScrnInfo->pixmapPrivate = pspix->devPrivate; + pspix->devPrivate.ptr = NULL; + } +} + +/* Print driver messages in the standard format */ + +#undef PREFIX_SIZE +#define PREFIX_SIZE 14 + +_X_EXPORT void +xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format, + va_list args) +{ + char *tmpFormat; + + /* Prefix the scrnIndex name to the format string. */ + if (scrnIndex >= 0 && scrnIndex < xf86NumScreens && + xf86Screens[scrnIndex]->name) { + tmpFormat = xalloc(strlen(format) + + strlen(xf86Screens[scrnIndex]->name) + + PREFIX_SIZE + 1); + if (!tmpFormat) + return; + + snprintf(tmpFormat, PREFIX_SIZE + 1, "%s(%d): ", + xf86Screens[scrnIndex]->name, scrnIndex); + + strcat(tmpFormat, format); + LogVMessageVerb(type, verb, tmpFormat, args); + xfree(tmpFormat); + } else + LogVMessageVerb(type, verb, format, args); +} +#undef PREFIX_SIZE + +/* Print driver messages, with verbose level specified directly */ +_X_EXPORT void +xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format, + ...) +{ + va_list ap; + + va_start(ap, format); + xf86VDrvMsgVerb(scrnIndex, type, verb, format, ap); + va_end(ap); +} + +/* Print driver messages, with verbose level of 1 (default) */ +_X_EXPORT void +xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + xf86VDrvMsgVerb(scrnIndex, type, 1, format, ap); + va_end(ap); +} + +/* Print non-driver messages with verbose level specified directly */ +_X_EXPORT void +xf86MsgVerb(MessageType type, int verb, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + xf86VDrvMsgVerb(-1, type, verb, format, ap); + va_end(ap); +} + +/* Print non-driver messages with verbose level of 1 (default) */ +_X_EXPORT void +xf86Msg(MessageType type, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + xf86VDrvMsgVerb(-1, type, 1, format, ap); + va_end(ap); +} + +/* Just like ErrorF, but with the verbose level checked */ +_X_EXPORT void +xf86ErrorFVerb(int verb, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + if (xf86Verbose >= verb || xf86LogVerbose >= verb) + LogVWrite(verb, format, ap); + va_end(ap); +} + +/* Like xf86ErrorFVerb, but with an implied verbose level of 1 */ +_X_EXPORT void +xf86ErrorF(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + if (xf86Verbose >= 1 || xf86LogVerbose >= 1) + LogVWrite(1, format, ap); + va_end(ap); +} + + +void +xf86LogInit() +{ + char *lf = NULL; + +#define LOGSUFFIX ".log" +#define LOGOLDSUFFIX ".old" + + /* Get the log file name */ + if (xf86LogFileFrom == X_DEFAULT) { + /* Append the display number and ".log" */ + lf = malloc(strlen(xf86LogFile) + strlen("%s") + + strlen(LOGSUFFIX) + 1); + if (!lf) + FatalError("Cannot allocate space for the log file name\n"); + sprintf(lf, "%s%%s" LOGSUFFIX, xf86LogFile); + xf86LogFile = lf; + } + + xf86LogFile = LogInit(xf86LogFile, LOGOLDSUFFIX); + xf86LogFileWasOpened = TRUE; + + xf86SetVerbosity(xf86Verbose); + xf86SetLogVerbosity(xf86LogVerbose); + +#undef LOGSUFFIX +#undef LOGOLDSUFFIX + + free(lf); +} + +void +xf86CloseLog() +{ + LogClose(); +} + + +/* + * Drivers can use these for using their own SymTabRecs. + */ + +_X_EXPORT const char * +xf86TokenToString(SymTabPtr table, int token) +{ + int i; + + for (i = 0; table[i].token >= 0 && table[i].token != token; i++) + ; + + if (table[i].token < 0) + return NULL; + else + return(table[i].name); +} + +_X_EXPORT int +xf86StringToToken(SymTabPtr table, const char *string) +{ + int i; + + if (string == NULL) + return -1; + + for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++) + ; + + return(table[i].token); +} + +/* + * helper to display the clocks found on a card + */ +_X_EXPORT void +xf86ShowClocks(ScrnInfoPtr scrp, MessageType from) +{ + int j; + + xf86DrvMsg(scrp->scrnIndex, from, "Pixel clocks available:"); + for (j=0; j < scrp->numClocks; j++) { + if ((j % 4) == 0) { + xf86ErrorF("\n"); + xf86DrvMsg(scrp->scrnIndex, from, "pixel clocks:"); + } + xf86ErrorF(" %7.3f", (double)scrp->clock[j] / 1000.0); + } + xf86ErrorF("\n"); +} + + +/* + * This prints out the driver identify message, including the names of + * the supported chipsets. + * + * XXX This makes assumptions about the line width, etc. Maybe we could + * use a more general "pretty print" function for messages. + */ +_X_EXPORT void +xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips) +{ + int len, i; + + len = 6 + strlen(drvname) + 2 + strlen(drvmsg) + 2; + xf86Msg(X_INFO, "%s: %s:", drvname, drvmsg); + for (i = 0; chips[i].name != NULL; i++) { + if (i != 0) { + xf86ErrorF(","); + len++; + } + if (len + 2 + strlen(chips[i].name) < 78) { + xf86ErrorF(" "); + len++; + } else { + xf86ErrorF("\n\t"); + len = 8; + } + xf86ErrorF("%s", chips[i].name); + len += strlen(chips[i].name); + } + xf86ErrorF("\n"); +} + + +_X_EXPORT int +xf86MatchDevice(const char *drivername, GDevPtr **sectlist) +{ + GDevPtr gdp, *pgdp = NULL; + confScreenPtr screensecptr; + int i,j; + + if (sectlist) + *sectlist = NULL; + + if (xf86DoModalias) return 0; + + if (xf86DoProbe) return 1; + + if (xf86DoConfigure && xf86DoConfigurePass1) return 1; + + /* + * This is a very important function that matches the device sections + * as they show up in the config file with the drivers that the server + * loads at run time. + * + * ChipProbe can call + * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist) + * with its driver name. The function allocates an array of GDevPtr and + * returns this via sectlist and returns the number of elements in + * this list as return value. 0 means none found, -1 means fatal error. + * + * It can figure out which of the Device sections to use for which card + * (using things like the Card statement, etc). For single headed servers + * there will of course be just one such Device section. + */ + i = 0; + + /* + * first we need to loop over all the Screens sections to get to all + * 'active' device sections + */ + for (j=0; xf86ConfigLayout.screens[j].screen != NULL; j++) { + screensecptr = xf86ConfigLayout.screens[j].screen; + if ((screensecptr->device->driver != NULL) + && (xf86NameCmp( screensecptr->device->driver,drivername) == 0) + && (! screensecptr->device->claimed)) { + /* + * we have a matching driver that wasn't claimed, yet + */ + pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp[i++] = screensecptr->device; + } + } + + /* Then handle the inactive devices */ + j = 0; + while (xf86ConfigLayout.inactives[j].identifier) { + gdp = &xf86ConfigLayout.inactives[j]; + if (gdp->driver && !gdp->claimed && + !xf86NameCmp(gdp->driver,drivername)) { + /* we have a matching driver that wasn't claimed yet */ + pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp[i++] = gdp; + } + j++; + } + + /* + * make the array NULL terminated and return its address + */ + if (i) + pgdp[i] = NULL; + + if (sectlist) + *sectlist = pgdp; + else + xfree(pgdp); + return i; +} + +struct Inst { + struct pci_device * pci; + GDevPtr dev; + Bool foundHW; /* PCIid in list of supported chipsets */ + Bool claimed; /* BusID matches with a device section */ + int chip; + int screen; +}; + + +/** + * Find set of unclaimed devices matching a given vendor ID. + * + * Used by drivers to find as yet unclaimed devices matching the specified + * vendor ID. + * + * \param driverName Name of the driver. This is used to find Device + * sections in the config file. + * \param vendorID PCI vendor ID of associated devices. If zero, then + * the true vendor ID must be encoded in the \c PCIid + * fields of the \c PCIchipsets entries. + * \param chipsets Symbol table used to associate chipset names with + * PCI IDs. + * \param devList List of Device sections parsed from the config file. + * \param numDevs Number of entries in \c devList. + * \param drvp Pointer the driver's control structure. + * \param foundEntities Returned list of entity indicies associated with the + * driver. + * + * \returns + * The number of elements in returned in \c foundEntities on success or zero + * on failure. + * + * \todo + * This function does a bit more than short description says. Fill in some + * more of the details of its operation. + * + * \todo + * The \c driverName parameter is redundant. It is the same as + * \c DriverRec::driverName. In a future version of this function, remove + * that parameter. + */ +_X_EXPORT int +xf86MatchPciInstances(const char *driverName, int vendorID, + SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, + int **foundEntities) +{ + int i,j; + struct pci_device * pPci; + struct pci_device_iterator *iter; + struct Inst *instances = NULL; + int numClaimedInstances = 0; + int allocatedInstances = 0; + int numFound = 0; + SymTabRec *c; + PciChipsets *id; + int *retEntities = NULL; + + *foundEntities = NULL; + + + /* Each PCI device will contribute at least one entry. Each device + * section can contribute at most one entry. The sum of the two is + * guaranteed to be larger than the maximum possible number of entries. + * Do this calculation and memory allocation once now to eliminate the + * need for realloc calls inside the loop. + */ + if ( !xf86DoProbe && !(xf86DoConfigure && xf86DoConfigurePass1) ) { + unsigned max_entries = numDevs; + + iter = pci_slot_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + max_entries++; + } + + pci_iterator_destroy(iter); + instances = xnfalloc(max_entries * sizeof(struct Inst)); + } + + iter = pci_slot_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + unsigned device_class = pPci->device_class; + Bool foundVendor = FALSE; + + + /* Convert the pre-PCI 2.0 device class for a VGA adapter to the + * 2.0 version of the same class. + */ + if ( device_class == 0x00000101 ) { + device_class = 0x00030000; + } + + + /* Find PCI devices that match the given vendor ID. The vendor ID is + * either specified explicitly as a parameter to the function or + * implicitly encoded in the high bits of id->PCIid. + * + * The first device with a matching vendor is recorded, even if the + * device ID doesn't match. This is done because the Device section + * in the xorg.conf file can over-ride the device ID. A matching PCI + * ID might not be found now, but after the device ID over-ride is + * applied there /might/ be a match. + */ + for (id = PCIchipsets; id->PCIid != -1; id++) { + const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16) + | vendorID; + const unsigned device_id = (id->PCIid & 0x0000FFFF); + const unsigned match_class = 0x00030000 | id->PCIid; + + if ((vendor_id == pPci->vendor_id) + || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) { + if (!foundVendor && (instances != NULL)) { + ++allocatedInstances; + instances[allocatedInstances - 1].pci = pPci; + instances[allocatedInstances - 1].dev = NULL; + instances[allocatedInstances - 1].claimed = FALSE; + instances[allocatedInstances - 1].foundHW = FALSE; + instances[allocatedInstances - 1].screen = 0; + } + + foundVendor = TRUE; + + if ( (device_id == pPci->device_id) + || ((vendorID == PCI_VENDOR_GENERIC) + && (match_class == device_class)) ) { + if ( instances != NULL ) { + instances[allocatedInstances - 1].foundHW = TRUE; + instances[allocatedInstances - 1].chip = id->numChipset; + } + + + if ( xf86DoConfigure && xf86DoConfigurePass1 ) { + if (xf86CheckPciSlot(pPci)) { + GDevPtr pGDev = + xf86AddDeviceToConfigure(drvp->driverName, + pPci, -1); + if (pGDev) { + /* After configure pass 1, chipID and chipRev + * are treated as over-rides, so clobber them + * here. + */ + pGDev->chipID = -1; + pGDev->chipRev = -1; + } + + numFound++; + } + } + else { + numFound++; + } + + break; + } + } + } + } + + pci_iterator_destroy(iter); + + + /* In "probe only" or "configure" mode (signaled by instances being NULL), + * our work is done. Return the number of detected devices. + */ + if ( instances == NULL ) { + return numFound; + } + + + /* + * This may be debatable, but if no PCI devices with a matching vendor + * type is found, return zero now. It is probably not desirable to + * allow the config file to override this. + */ + if (allocatedInstances <= 0) { + xfree(instances); + return 0; + } + + +#ifdef DEBUG + ErrorF("%s instances found: %d\n", driverName, allocatedInstances); +#endif + + /* + * Check for devices that need duplicated instances. This is required + * when there is more than one screen per entity. + * + * XXX This currently doesn't work for cases where the BusID isn't + * specified explicitly in the config file. + */ + + for (j = 0; j < numDevs; j++) { + if (devList[j]->screen > 0 && devList[j]->busID + && *devList[j]->busID) { + for (i = 0; i < allocatedInstances; i++) { + pPci = instances[i].pci; + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, + pPci->func)) { + allocatedInstances++; + instances[allocatedInstances - 1] = instances[i]; + instances[allocatedInstances - 1].screen = + devList[j]->screen; + numFound++; + break; + } + } + } + } + + for (i = 0; i < allocatedInstances; i++) { + GDevPtr dev = NULL; + GDevPtr devBus = NULL; + + pPci = instances[i].pci; + for (j = 0; j < numDevs; j++) { + if (devList[j]->busID && *devList[j]->busID) { + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, + pPci->func) && + devList[j]->screen == instances[i].screen) { + + if (devBus) + xf86MsgVerb(X_WARNING,0, + "%s: More than one matching Device section for " + "instances\n\t(BusID: %s) found: %s\n", + driverName, devList[j]->busID, + devList[j]->identifier); + else + devBus = devList[j]; + } + } else { + /* + * if device section without BusID is found + * only assign to it to the primary device. + */ + if (xf86IsPrimaryPci(pPci)) { + xf86Msg(X_PROBED, "Assigning device section with no busID" + " to primary device\n"); + if (dev || devBus) + xf86MsgVerb(X_WARNING, 0, + "%s: More than one matching Device section " + "found: %s\n", driverName, devList[j]->identifier); + else + dev = devList[j]; + } + } + } + if (devBus) dev = devBus; /* busID preferred */ + if (!dev) { + if ( xf86CheckPciSlot( pPci ) ) { + xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " + "for instance (BusID PCI:%u@%u:%u:%u) found\n", + driverName, pPci->domain, pPci->bus, pPci->dev, + pPci->func); + } + } else { + numClaimedInstances++; + instances[i].claimed = TRUE; + instances[i].dev = dev; + } + } +#ifdef DEBUG + ErrorF("%s instances found: %d\n", driverName, numClaimedInstances); +#endif + /* + * Now check that a chipset or chipID override in the device section + * is valid. Chipset has precedence over chipID. + * If chipset is not valid ignore BusSlot completely. + */ + for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { + MessageType from = X_PROBED; + + if (!instances[i].claimed) { + continue; + } + if (instances[i].dev->chipset) { + for (c = chipsets; c->token >= 0; c++) { + if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0) + break; + } + if (c->token == -1) { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " + "section \"%s\" isn't valid for this driver\n", + driverName, instances[i].dev->chipset, + instances[i].dev->identifier); + } else { + instances[i].chip = c->token; + + for (id = PCIchipsets; id->numChipset >= 0; id++) { + if (id->numChipset == instances[i].chip) + break; + } + if(id->numChipset >=0){ + xf86Msg(X_CONFIG,"Chipset override: %s\n", + instances[i].dev->chipset); + from = X_CONFIG; + } else { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " + "section \"%s\" isn't a valid PCI chipset\n", + driverName, instances[i].dev->chipset, + instances[i].dev->identifier); + } + } + } else if (instances[i].dev->chipID > 0) { + for (id = PCIchipsets; id->numChipset >= 0; id++) { + if (id->PCIid == instances[i].dev->chipID) + break; + } + if (id->numChipset == -1) { + instances[i].claimed = FALSE; + numClaimedInstances--; + xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device " + "section \"%s\" isn't valid for this driver\n", + driverName, instances[i].dev->chipID, + instances[i].dev->identifier); + } else { + instances[i].chip = id->numChipset; + + xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n", + instances[i].dev->chipID); + from = X_CONFIG; + } + } else if (!instances[i].foundHW) { + /* + * This means that there was no override and the PCI chipType + * doesn't match one that is supported + */ + instances[i].claimed = FALSE; + numClaimedInstances--; + } + if (instances[i].claimed == TRUE){ + for (c = chipsets; c->token >= 0; c++) { + if (c->token == instances[i].chip) + break; + } + xf86Msg(from,"Chipset %s found\n", + c->name); + } + } + + /* + * Of the claimed instances, check that another driver hasn't already + * claimed its slot. + */ + numFound = 0; + for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { + + if (!instances[i].claimed) + continue; + pPci = instances[i].pci; + + + /* + * Allow the same entity to be used more than once for devices with + * multiple screens per entity. This assumes implicitly that there + * will be a screen == 0 instance. + * + * XXX Need to make sure that two different drivers don't claim + * the same screen > 0 instance. + */ + if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci )) + continue; + +#ifdef DEBUG + ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n", + driverName, pPci->bus, pPci->dev, pPci->func); +#endif + + /* Allocate an entry in the lists to be returned */ + numFound++; + retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); + retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp, + instances[i].chip, + instances[i].dev, + instances[i].dev->active); + if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) { + for (j = 0; j < xf86NumEntities; j++) { + EntityPtr pEnt = xf86Entities[j]; + if (pEnt->bus.type != BUS_PCI) + continue; + if (pEnt->bus.id.pci == pPci) { + retEntities[numFound - 1] = j; + xf86AddDevToEntity(j, instances[i].dev); + break; + } + } + } + } + xfree(instances); + if (numFound > 0) { + *foundEntities = retEntities; + } + + return numFound; +} + +_X_EXPORT int +xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets, + IsaChipsets *ISAchipsets, DriverPtr drvp, + FindIsaDevProc FindIsaDevice, GDevPtr *devList, + int numDevs, int **foundEntities) +{ + SymTabRec *c; + IsaChipsets *Chips; + int i; + int numFound = 0; + int foundChip = -1; + int *retEntities = NULL; + + *foundEntities = NULL; + +#if defined(__sparc__) || defined(__powerpc__) + FindIsaDevice = NULL; /* Temporary */ +#endif + + if (xf86DoProbe || (xf86DoConfigure && xf86DoConfigurePass1)) { + if (FindIsaDevice && + ((foundChip = (*FindIsaDevice)(NULL)) != -1)) { + xf86AddDeviceToConfigure(drvp->driverName, NULL, foundChip); + return 1; + } + return 0; + } + + for (i = 0; i < numDevs; i++) { + MessageType from = X_CONFIG; + GDevPtr dev = NULL; + GDevPtr devBus = NULL; + + if (devList[i]->busID && *devList[i]->busID) { + if (xf86ParseIsaBusString(devList[i]->busID)) { + if (devBus) xf86MsgVerb(X_WARNING,0, + "%s: More than one matching Device " + "section for ISA-Bus found: %s\n", + driverName,devList[i]->identifier); + else devBus = devList[i]; + } + } else { + if (xf86IsPrimaryIsa()) { + if (dev) xf86MsgVerb(X_WARNING,0, + "%s: More than one matching " + "Device section found: %s\n", + driverName,devList[i]->identifier); + else dev = devList[i]; + } + } + if (devBus) dev = devBus; + if (dev) { + if (dev->chipset) { + for (c = chipsets; c->token >= 0; c++) { + if (xf86NameCmp(c->name, dev->chipset) == 0) + break; + } + if (c->token == -1) { + xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device " + "section \"%s\" isn't valid for this driver\n", + driverName, dev->chipset, + dev->identifier); + } else + foundChip = c->token; + } else { + if (FindIsaDevice) foundChip = (*FindIsaDevice)(dev); + /* Probe it */ + from = X_PROBED; + } + } + + /* Check if the chip type is listed in the chipset table - for sanity*/ + + if (foundChip >= 0){ + for (Chips = ISAchipsets; Chips->numChipset >= 0; Chips++) { + if (Chips->numChipset == foundChip) + break; + } + if (Chips->numChipset == -1){ + foundChip = -1; + xf86MsgVerb(X_WARNING,0, + "%s: Driver detected unknown ISA-Bus Chipset\n", + driverName); + } + } + if (foundChip != -1) { + numFound++; + retEntities = xnfrealloc(retEntities,numFound * sizeof(int)); + retEntities[numFound - 1] = + xf86ClaimIsaSlot(drvp,foundChip,dev, dev->active ? TRUE : FALSE); + for (c = chipsets; c->token >= 0; c++) { + if (c->token == foundChip) + break; + } + xf86Msg(from, "Chipset %s found\n", c->name); + } + } + *foundEntities = retEntities; + + return numFound; +} + +/* + * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ... + */ +_X_EXPORT void +xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int), + void (*ProtectRegs)(ScrnInfoPtr, Bool), + void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg, + int maskval, int knownclkindex, int knownclkvalue) +{ + register int status = vertsyncreg; + unsigned long i, cnt, rcnt, sync; + + /* First save registers that get written on */ + (*ClockFunc)(pScrn, CLK_REG_SAVE); + + xf86SetPriority(TRUE); + + if (num > MAXCLOCKS) + num = MAXCLOCKS; + + for (i = 0; i < num; i++) + { + if (ProtectRegs) + (*ProtectRegs)(pScrn, TRUE); + if (!(*ClockFunc)(pScrn, i)) + { + pScrn->clock[i] = -1; + continue; + } + if (ProtectRegs) + (*ProtectRegs)(pScrn, FALSE); + if (BlankScreen) + (*BlankScreen)(pScrn, FALSE); + + usleep(50000); /* let VCO stabilise */ + + cnt = 0; + sync = 200000; + + /* XXX How critical is this? */ + if (!xf86DisableInterrupts()) + { + (*ClockFunc)(pScrn, CLK_REG_RESTORE); + ErrorF("Failed to disable interrupts during clock probe. If\n"); + ErrorF("your OS does not support disabling interrupts, then you\n"); + FatalError("must specify a Clocks line in the XF86Config file.\n"); + } + while ((inb(status) & maskval) == 0x00) + if (sync-- == 0) goto finish; + /* Something appears to be happening, so reset sync count */ + sync = 200000; + while ((inb(status) & maskval) == maskval) + if (sync-- == 0) goto finish; + /* Something appears to be happening, so reset sync count */ + sync = 200000; + while ((inb(status) & maskval) == 0x00) + if (sync-- == 0) goto finish; + + for (rcnt = 0; rcnt < 5; rcnt++) + { + while (!(inb(status) & maskval)) + cnt++; + while ((inb(status) & maskval)) + cnt++; + } + +finish: + xf86EnableInterrupts(); + + pScrn->clock[i] = cnt ? cnt : -1; + if (BlankScreen) + (*BlankScreen)(pScrn, TRUE); + } + + xf86SetPriority(FALSE); + + for (i = 0; i < num; i++) + { + if (i != knownclkindex) + { + if (pScrn->clock[i] == -1) + { + pScrn->clock[i] = 0; + } + else + { + pScrn->clock[i] = (int)(0.5 + + (((float)knownclkvalue) * pScrn->clock[knownclkindex]) / + (pScrn->clock[i])); + /* Round to nearest 10KHz */ + pScrn->clock[i] += 5; + pScrn->clock[i] /= 10; + pScrn->clock[i] *= 10; + } + } + } + + pScrn->clock[knownclkindex] = knownclkvalue; + pScrn->numClocks = num; + + /* Restore registers that were written on */ + (*ClockFunc)(pScrn, CLK_REG_RESTORE); +} + +_X_EXPORT void +xf86SetPriority(Bool up) +{ + static int saved_nice; + + if (up) { +#ifdef HAS_SETPRIORITY + saved_nice = getpriority(PRIO_PROCESS, 0); + setpriority(PRIO_PROCESS, 0, -20); +#endif +#if defined(SYSV) || defined(SVR4) || defined(linux) + saved_nice = nice(0); + nice(-20 - saved_nice); +#endif + } else { +#ifdef HAS_SETPRIORITY + setpriority(PRIO_PROCESS, 0, saved_nice); +#endif +#if defined(SYSV) || defined(SVR4) || defined(linux) + nice(20 + saved_nice); +#endif + } +} + +_X_EXPORT const char * +xf86GetVisualName(int visual) +{ + if (visual < 0 || visual > DirectColor) + return NULL; + + return xf86VisualNames[visual]; +} + + +_X_EXPORT int +xf86GetVerbosity() +{ + return max(xf86Verbose, xf86LogVerbose); +} + +_X_EXPORT Pix24Flags +xf86GetPix24() +{ + return xf86Info.pixmap24; +} + + +_X_EXPORT int +xf86GetDepth() +{ + return xf86Depth; +} + + +_X_EXPORT rgb +xf86GetWeight() +{ + return xf86Weight; +} + + +_X_EXPORT Gamma +xf86GetGamma() +{ + return xf86Gamma; +} + + +_X_EXPORT Bool +xf86GetFlipPixels() +{ + return xf86FlipPixels; +} + + +_X_EXPORT const char * +xf86GetServerName() +{ + return xf86ServerName; +} + + +_X_EXPORT Bool +xf86ServerIsExiting() +{ + return (dispatchException & DE_TERMINATE) == DE_TERMINATE; +} + + +_X_EXPORT Bool +xf86ServerIsResetting() +{ + return xf86Resetting; +} + + +Bool +xf86ServerIsInitialising() +{ + return xf86Initialising; +} + + +_X_EXPORT Bool +xf86ServerIsOnlyDetecting(void) +{ + return xf86DoProbe || xf86DoConfigure; +} + + +_X_EXPORT Bool +xf86ServerIsOnlyProbing(void) +{ + return xf86ProbeOnly; +} + + +_X_EXPORT Bool +xf86CaughtSignal() +{ + return xf86Info.caughtSignal; +} + + +_X_EXPORT Bool +xf86GetVidModeAllowNonLocal() +{ + return xf86Info.vidModeAllowNonLocal; +} + + +_X_EXPORT Bool +xf86GetVidModeEnabled() +{ + return xf86Info.vidModeEnabled; +} + +_X_EXPORT Bool +xf86GetModInDevAllowNonLocal() +{ + return xf86Info.miscModInDevAllowNonLocal; +} + + +_X_EXPORT Bool +xf86GetModInDevEnabled() +{ + return xf86Info.miscModInDevEnabled; +} + + +_X_EXPORT Bool +xf86GetAllowMouseOpenFail() +{ + return xf86Info.allowMouseOpenFail; +} + + +_X_EXPORT Bool +xf86IsPc98() +{ +#ifdef __i386__ + return xf86Info.pc98; +#else + return FALSE; +#endif +} + +_X_EXPORT void +xf86DisableRandR() +{ + xf86Info.disableRandR = TRUE; + xf86Info.randRFrom = X_PROBED; +} + +_X_EXPORT CARD32 +xf86GetVersion() +{ + return XF86_VERSION_CURRENT; +} + +_X_EXPORT CARD32 +xf86GetModuleVersion(pointer module) +{ + return (CARD32)LoaderGetModuleVersion(module); +} + +_X_EXPORT pointer +xf86LoadDrvSubModule(DriverPtr drv, const char *name) +{ + pointer ret; + int errmaj = 0, errmin = 0; + + ret = LoadSubModule(drv->module, name, NULL, NULL, NULL, NULL, + &errmaj, &errmin); + if (!ret) + LoaderErrorMsg(NULL, name, errmaj, errmin); + return ret; +} + +_X_EXPORT pointer +xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name) +{ + pointer ret; + int errmaj = 0, errmin = 0; + + ret = LoadSubModule(pScrn->module, name, NULL, NULL, NULL, NULL, + &errmaj, &errmin); + if (!ret) + LoaderErrorMsg(pScrn->name, name, errmaj, errmin); + return ret; +} + +/* + * xf86LoadOneModule loads a single module. + */ +_X_EXPORT pointer +xf86LoadOneModule(char *name, pointer opt) +{ + int errmaj, errmin; + char *Name; + pointer mod; + + if (!name) + return NULL; + + /* Normalise the module name */ + Name = xf86NormalizeName(name); + + /* Skip empty names */ + if (Name == NULL) + return NULL; + if (*Name == '\0') { + xfree(Name); + return NULL; + } + + mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin); + if (!mod) + LoaderErrorMsg(NULL, Name, errmaj, errmin); + xfree(Name); + return mod; +} + +_X_EXPORT void +xf86UnloadSubModule(pointer mod) +{ + /* + * This is disabled for now. The loader isn't smart enough yet to undo + * relocations. + */ +#if 0 + UnloadSubModule(mod); +#endif +} + +_X_EXPORT Bool +xf86LoaderCheckSymbol(const char *name) +{ + return LoaderSymbol(name) != NULL; +} + +/* These two are just ABI stubs, they don't do anything in dlloader world */ +_X_EXPORT void +xf86LoaderReqSymLists(const char **list0, ...) +{ +} + +_X_EXPORT void +xf86LoaderReqSymbols(const char *sym0, ...) +{ +} + +_X_EXPORT void +xf86LoaderRefSymLists(const char **list0, ...) +{ +} + +_X_EXPORT void +xf86LoaderRefSymbols(const char *sym0, ...) +{ +} + + +typedef enum { + OPTION_BACKING_STORE +} BSOpts; + +static const OptionInfoRec BSOptions[] = { + { OPTION_BACKING_STORE, "BackingStore", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +_X_EXPORT void +xf86SetBackingStore(ScreenPtr pScreen) +{ + Bool useBS = FALSE; + MessageType from = X_DEFAULT; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + OptionInfoPtr options; + + options = xnfalloc(sizeof(BSOptions)); + (void)memcpy(options, BSOptions, sizeof(BSOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + /* check for commandline option here */ + if (xf86bsEnableFlag) { + from = X_CMDLINE; + useBS = TRUE; + } else if (xf86bsDisableFlag) { + from = X_CMDLINE; + useBS = FALSE; + } else { + if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS)) + from = X_CONFIG; + } + xfree(options); + pScreen->backingStoreSupport = useBS ? Always : NotUseful; + if (serverGeneration == 1) + xf86DrvMsg(pScreen->myNum, from, "Backing store %s\n", + useBS ? "enabled" : "disabled"); +} + + +typedef enum { + OPTION_SILKEN_MOUSE +} SMOpts; + +static const OptionInfoRec SMOptions[] = { + { OPTION_SILKEN_MOUSE, "SilkenMouse", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +_X_EXPORT void +xf86SetSilkenMouse (ScreenPtr pScreen) +{ + Bool useSM = TRUE; + MessageType from = X_DEFAULT; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + OptionInfoPtr options; + + options = xnfalloc(sizeof(SMOptions)); + (void)memcpy(options, SMOptions, sizeof(SMOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + /* check for commandline option here */ + /* disable if screen shares resources */ + if (((pScrn->racMemFlags & RAC_CURSOR) && + !xf86NoSharedResources(pScrn->scrnIndex,MEM)) || + ((pScrn->racIoFlags & RAC_CURSOR) && + !xf86NoSharedResources(pScrn->scrnIndex,IO))) { + useSM = FALSE; + from = X_PROBED; + } else if (xf86silkenMouseDisableFlag) { + from = X_CMDLINE; + useSM = FALSE; + } else { + if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM)) + from = X_CONFIG; + } + xfree(options); + /* + * XXX quick hack to report correctly for OSs that can't do SilkenMouse + * yet. Should handle this differently so that alternate async methods + * work correctly with this too. + */ + pScrn->silkenMouse = useSM && xf86SIGIOSupported(); + if (serverGeneration == 1) + xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n", + pScrn->silkenMouse ? "enabled" : "disabled"); +} + +/* Wrote this function for the PM2 Xv driver, preliminary. */ + +_X_EXPORT pointer +xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name, + char **adaptor_name, pointer *adaptor_options) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + confXvAdaptorPtr adaptor; + int i; + + if (adaptor_index >= pScrn->confScreen->numxvadaptors) { + if (adaptor_name) *adaptor_name = NULL; + if (adaptor_options) *adaptor_options = NULL; + return NULL; + } + + adaptor = &pScrn->confScreen->xvadaptors[adaptor_index]; + if (adaptor_name) *adaptor_name = adaptor->identifier; + if (adaptor_options) *adaptor_options = adaptor->options; + + for (i = 0; i < adaptor->numports; i++) + if (!xf86NameCmp(adaptor->ports[i].identifier, port_name)) + return adaptor->ports[i].options; + + return NULL; +} + +/* Rather than duplicate loader's get OS function, just include it directly */ +#define LoaderGetOS xf86GetOS +#include "loader/os.c" + +/* new RAC */ +/* + * xf86ConfigIsa/PciEntity() -- These helper functions assign an + * active entity to a screen, registers its fixed resources, assign + * special enter/leave functions and their private scratch area to + * this entity, take the dog for a walk... + */ +_X_EXPORT ScrnInfoPtr +xf86ConfigIsaEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, + IsaChipsets *i_chip, resList res, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + IsaChipsets *i_id; + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; + + if (!(pEnt->location.type == BUS_ISA)) { + xfree(pEnt); + return pScrn; + } + + if (!pEnt->active) { + xf86ConfigIsaEntityInactive(pEnt, i_chip, res, init, enter, + leave, private); + xfree(pEnt); + return pScrn; + } + + if (!pScrn) + pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); + xf86AddEntityToScreen(pScrn,entityIndex); + + if (i_chip) { + for (i_id = i_chip; i_id->numChipset != -1; i_id++) { + if (pEnt->chipset == i_id->numChipset) break; + } + xf86ClaimFixedResources(i_id->resList,entityIndex); + } + xfree(pEnt); + xf86ClaimFixedResources(res,entityIndex); + xf86SetEntityFuncs(entityIndex,init,enter,leave,private); + + return pScrn; +} + +_X_EXPORT ScrnInfoPtr +xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, + PciChipsets *p_chip, resList res, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + PciChipsets *p_id; + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; + + if (!(pEnt->location.type == BUS_PCI) + || !xf86GetPciInfoForEntity(entityIndex)) { + xfree(pEnt); + return pScrn; + } + if (!pEnt->active) { + xf86ConfigPciEntityInactive(pEnt, p_chip, res, init, enter, + leave, private); + xfree(pEnt); + return pScrn; + } + + if (!pScrn) + pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); + if (xf86IsEntitySharable(entityIndex)) { + xf86SetEntityShared(entityIndex); + } + xf86AddEntityToScreen(pScrn,entityIndex); + if (xf86IsEntityShared(entityIndex)) { + return pScrn; + } + if (p_chip) { + for (p_id = p_chip; p_id->numChipset != -1; p_id++) { + if (pEnt->chipset == p_id->numChipset) break; + } + xf86ClaimFixedResources(p_id->resList,entityIndex); + } + xfree(pEnt); + + xf86ClaimFixedResources(res,entityIndex); + xf86SetEntityFuncs(entityIndex,init,enter,leave,private); + + return pScrn; +} + +_X_EXPORT ScrnInfoPtr +xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, + EntityProc init, EntityProc enter, EntityProc leave, + pointer private) +{ + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; + + if (!(pEnt->location.type == BUS_NONE)) { + xfree(pEnt); + return pScrn; + } + + if (!pEnt->active) { + xf86ConfigFbEntityInactive(pEnt, init, enter, leave, private); + xfree(pEnt); + return pScrn; + } + + if (!pScrn) + pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); + xf86AddEntityToScreen(pScrn,entityIndex); + + xf86SetEntityFuncs(entityIndex,init,enter,leave,private); + + return pScrn; +} + +/* + * + * OBSOLETE ! xf86ConfigActiveIsaEntity() and xf86ConfigActivePciEntity() + * are obsolete functions. They the are likely to be removed + * Don't use! + */ +_X_EXPORT Bool +xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex, + IsaChipsets *i_chip, resList res, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + IsaChipsets *i_id; + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return FALSE; + + if (!pEnt->active || !(pEnt->location.type == BUS_ISA)) { + xfree(pEnt); + return FALSE; + } + + xf86AddEntityToScreen(pScrn,entityIndex); + + if (i_chip) { + for (i_id = i_chip; i_id->numChipset != -1; i_id++) { + if (pEnt->chipset == i_id->numChipset) break; + } + xf86ClaimFixedResources(i_id->resList,entityIndex); + } + xfree(pEnt); + xf86ClaimFixedResources(res,entityIndex); + if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private)) + return FALSE; + + return TRUE; +} + +_X_EXPORT Bool +xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex, + PciChipsets *p_chip, resList res, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + PciChipsets *p_id; + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return FALSE; + + if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) { + xfree(pEnt); + return FALSE; + } + xf86AddEntityToScreen(pScrn,entityIndex); + + if (p_chip) { + for (p_id = p_chip; p_id->numChipset != -1; p_id++) { + if (pEnt->chipset == p_id->numChipset) break; + } + xf86ClaimFixedResources(p_id->resList,entityIndex); + } + xfree(pEnt); + + xf86ClaimFixedResources(res,entityIndex); + if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private)) + return FALSE; + + return TRUE; +} + +/* + * xf86ConfigPci/IsaEntityInactive() -- These functions can be used + * to configure an inactive entity as well as to reconfigure an + * previously active entity inactive. If the entity has been + * assigned to a screen before it will be removed. If p_pci(p_isa) is + * non-NULL all static resources listed there will be registered. + */ +_X_EXPORT void +xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip, + resList res, EntityProc init, EntityProc enter, + EntityProc leave, pointer private) +{ + PciChipsets *p_id; + ScrnInfoPtr pScrn; + + if ((pScrn = xf86FindScreenForEntity(pEnt->index))) + xf86RemoveEntityFromScreen(pScrn,pEnt->index); + else if (p_chip) { + for (p_id = p_chip; p_id->numChipset != -1; p_id++) { + if (pEnt->chipset == p_id->numChipset) break; + } + xf86ClaimFixedResources(p_id->resList,pEnt->index); + } + xf86ClaimFixedResources(res,pEnt->index); + /* shared resources are only needed when entity is active: remove */ + xf86DeallocateResourcesForEntity(pEnt->index, ResShared); + xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); +} + +_X_EXPORT void +xf86ConfigIsaEntityInactive(EntityInfoPtr pEnt, IsaChipsets *i_chip, + resList res, EntityProc init, EntityProc enter, + EntityProc leave, pointer private) +{ + IsaChipsets *i_id; + ScrnInfoPtr pScrn; + + if ((pScrn = xf86FindScreenForEntity(pEnt->index))) + xf86RemoveEntityFromScreen(pScrn,pEnt->index); + else if (i_chip) { + for (i_id = i_chip; i_id->numChipset != -1; i_id++) { + if (pEnt->chipset == i_id->numChipset) break; + } + xf86ClaimFixedResources(i_id->resList,pEnt->index); + } + xf86ClaimFixedResources(res,pEnt->index); + /* shared resources are only needed when entity is active: remove */ + xf86DeallocateResourcesForEntity(pEnt->index, ResShared); + xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); +} + +void +xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + ScrnInfoPtr pScrn; + + if ((pScrn = xf86FindScreenForEntity(pEnt->index))) + xf86RemoveEntityFromScreen(pScrn,pEnt->index); + xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); +} + +_X_EXPORT Bool +xf86IsScreenPrimary(int scrnIndex) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + int i; + + for (i=0 ; i < pScrn->numEntities; i++) { + if (xf86IsEntityPrimary(i)) + return TRUE; + } + return FALSE; +} + +_X_EXPORT int +xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, + int format, unsigned long len, pointer value ) +{ + RootWinPropPtr pNewProp = NULL, pRegProp; + int i; + Bool existing = FALSE; + +#ifdef DEBUG + ErrorF("xf86RegisterRootWindowProperty(%d, %ld, %ld, %d, %ld, %p)\n", + ScrnIndex, property, type, format, len, value); +#endif + + if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) { + return(BadMatch); + } + + if (xf86RegisteredPropertiesTable && + xf86RegisteredPropertiesTable[ScrnIndex]) { + for (pNewProp = xf86RegisteredPropertiesTable[ScrnIndex]; + pNewProp; pNewProp = pNewProp->next) { + if (strcmp(pNewProp->name, NameForAtom(property)) == 0) + break; + } + } + + if (!pNewProp) { + if ((pNewProp = (RootWinPropPtr)xalloc(sizeof(RootWinProp))) == NULL) { + return(BadAlloc); + } + /* + * We will put this property at the end of the list so that + * the changes are made in the order they were requested. + */ + pNewProp->next = NULL; + } else { + if (pNewProp->name) + xfree(pNewProp->name); + existing = TRUE; + } + + pNewProp->name = xnfstrdup(NameForAtom(property)); + pNewProp->type = type; + pNewProp->format = format; + pNewProp->size = len; + pNewProp->data = value; + +#ifdef DEBUG + ErrorF("new property filled\n"); +#endif + + if (NULL==xf86RegisteredPropertiesTable) { +#ifdef DEBUG + ErrorF("creating xf86RegisteredPropertiesTable[] size %d\n", + xf86NumScreens); +#endif + if ( NULL==(xf86RegisteredPropertiesTable=(RootWinPropPtr*)xnfcalloc(sizeof(RootWinProp),xf86NumScreens) )) { + return(BadAlloc); + } + for (i=0; inext != NULL) { +#ifdef DEBUG + ErrorF("- next %p\n", (void *)pRegProp); +#endif + pRegProp = pRegProp->next; + } + pRegProp->next = pNewProp; + } + } +#ifdef DEBUG + ErrorF("xf86RegisterRootWindowProperty succeeded\n"); +#endif + return(Success); +} + +_X_EXPORT Bool +xf86IsUnblank(int mode) +{ + switch(mode) { + case SCREEN_SAVER_OFF: + case SCREEN_SAVER_FORCER: + return TRUE; + case SCREEN_SAVER_ON: + case SCREEN_SAVER_CYCLE: + return FALSE; + default: + xf86MsgVerb(X_WARNING, 0, "Unexpected save screen mode: %d\n", mode); + return TRUE; + } +} + +_X_EXPORT void +xf86MotionHistoryAllocate(LocalDevicePtr local) +{ + AllocateMotionHistory(local->dev); +} + +_X_EXPORT int +xf86GetMotionEvents(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start, + unsigned long stop, ScreenPtr pScreen) +{ + return GetMotionHistory(pDev, buff, start, stop, pScreen); +} + +_X_EXPORT void +xf86getsecs(long * secs, long * usecs) +{ + struct timeval tv; + + X_GETTIMEOFDAY(&tv); + if (secs) + *secs = tv.tv_sec; + if (usecs) + *usecs= tv.tv_usec; + + return; +} diff --git a/xorg-server/hw/xfree86/common/xf86InPriv.h b/xorg-server/hw/xfree86/common/xf86InPriv.h new file mode 100644 index 000000000..62e4820cb --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86InPriv.h @@ -0,0 +1,46 @@ + +/* + * Copyright (c) 1999 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef _xf86InPriv_h +#define _xf86InPriv_h + +/* xf86Globals.c */ +extern InputDriverPtr *xf86InputDriverList; +extern int xf86NumInputDrivers; + +/* xf86Xinput.c */ +void xf86ActivateDevice(InputInfoPtr pInfo); + +/* xf86Helper.c */ +InputDriverPtr xf86LookupInputDriver(const char *name); + +#endif /* _xf86InPriv_h */ diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c new file mode 100644 index 000000000..fc50cafc7 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Init.c @@ -0,0 +1,2095 @@ +/* + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + */ +/* + * Copyright (c) 1992-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include + +#undef HAS_UTSNAME +#if !defined(WIN32) +#define HAS_UTSNAME 1 +#include +#endif + +#define NEED_EVENTS +#include +#include +#include +#include +#include "input.h" +#include "servermd.h" +#include "windowstr.h" +#include "scrnintstr.h" +#include "site.h" +#include "mi.h" + +#include "compiler.h" + +#include "loaderProcs.h" +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +#define XF86_OS_PRIVS +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xorgVersion.h" +#include "xf86Date.h" +#include "xf86Build.h" +#include "mipointer.h" +#ifdef XINPUT +#include +#include +#else +#include "inputstr.h" +#endif +#include "xf86DDC.h" +#include "xf86Xinput.h" +#include "xf86InPriv.h" +#ifdef RENDER +#include "picturestr.h" +#endif + +#include "globals.h" + +#ifdef DPMSExtension +#define DPMS_SERVER +#include +#include "dpmsproc.h" +#endif + +#include +#include "Pci.h" +#include "xf86Bus.h" + +/* forward declarations */ + +static void xf86PrintBanner(void); +static void xf86PrintMarkers(void); +static void xf86PrintDefaultModulePath(void); +static void xf86PrintDefaultLibraryPath(void); + +static Bool probe_devices_from_device_sections(DriverPtr drvp); +static Bool add_matching_devices_to_configure_list(DriverPtr drvp); +static Bool check_for_matching_devices(DriverPtr drvp); + +#ifdef XF86PM +void (*xf86OSPMClose)(void) = NULL; +#endif + +/* Common pixmap formats */ + +static PixmapFormatRec formats[MAXFORMATS] = { + { 1, 1, BITMAP_SCANLINE_PAD }, + { 4, 8, BITMAP_SCANLINE_PAD }, + { 8, 8, BITMAP_SCANLINE_PAD }, + { 15, 16, BITMAP_SCANLINE_PAD }, + { 16, 16, BITMAP_SCANLINE_PAD }, + { 24, 32, BITMAP_SCANLINE_PAD }, +#ifdef RENDER + { 32, 32, BITMAP_SCANLINE_PAD }, +#endif +}; +#ifdef RENDER +static int numFormats = 7; +#else +static int numFormats = 6; +#endif +static Bool formatsDone = FALSE; + +#ifndef OSNAME +#define OSNAME " unknown" +#endif +#ifndef OSVENDOR +#define OSVENDOR "" +#endif +#ifndef PRE_RELEASE +#define PRE_RELEASE XORG_VERSION_SNAP +#endif + +static void +xf86PrintBanner() +{ +#if PRE_RELEASE + ErrorF("\n" + "This is a pre-release version of the X server from " XVENDORNAME ".\n" + "It is not supported in any way.\n" + "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n" + "Select the \"xorg\" product for bugs you find in this release.\n" + "Before reporting bugs in pre-release versions please check the\n" + "latest version in the X.Org Foundation git repository.\n" + "See http://wiki.x.org/wiki/GitPage for git access instructions.\n"); +#endif + ErrorF("\nX.Org X Server %d.%d.%d", + XORG_VERSION_MAJOR, + XORG_VERSION_MINOR, + XORG_VERSION_PATCH); +#if XORG_VERSION_SNAP > 0 + ErrorF(".%d", XORG_VERSION_SNAP); +#endif + +#if XORG_VERSION_SNAP >= 900 + /* When the minor number is 99, that signifies that the we are making + * a release candidate for a major version. (X.0.0) + * When the patch number is 99, that signifies that the we are making + * a release candidate for a minor version. (X.Y.0) + * When the patch number is < 99, then we are making a release + * candidate for the next point release. (X.Y.Z) + */ +#if XORG_VERSION_MINOR >= 99 + ErrorF(" (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1, XORG_VERSION_SNAP - 900); +#elif XORG_VERSION_PATCH == 99 + ErrorF(" (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR + 1, + XORG_VERSION_SNAP - 900); +#else + ErrorF(" (%d.%d.%d RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, + XORG_VERSION_PATCH + 1, XORG_VERSION_SNAP - 900); +#endif +#endif + +#ifdef XORG_CUSTOM_VERSION + ErrorF(" (%s)", XORG_CUSTOM_VERSION); +#endif +#ifndef XORG_DATE +#define XORG_DATE XF86_DATE +#endif + ErrorF("\nRelease Date: %s\n", XORG_DATE); + ErrorF("X Protocol Version %d, Revision %d\n", + X_PROTOCOL, X_PROTOCOL_REVISION); + ErrorF("Build Operating System: %s %s\n", OSNAME, OSVENDOR); +#ifdef HAS_UTSNAME + { + struct utsname name; + + /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX, + and Irix) and Single Unix Spec 3 just say that non-negative is success. + All agree that failure is represented by a negative number. + */ + if (uname(&name) >= 0) { + ErrorF("Current Operating System: %s %s %s %s %s\n", + name.sysname, name.nodename, name.release, name.version, name.machine); + } + } +#endif +#if defined(BUILD_DATE) && (BUILD_DATE > 19000000) + { + struct tm t; + char buf[100]; + + bzero(&t, sizeof(t)); + bzero(buf, sizeof(buf)); + t.tm_mday = BUILD_DATE % 100; + t.tm_mon = (BUILD_DATE / 100) % 100 - 1; + t.tm_year = BUILD_DATE / 10000 - 1900; +#if defined(BUILD_TIME) + t.tm_sec = BUILD_TIME % 100; + t.tm_min = (BUILD_TIME / 100) % 100; + t.tm_hour = (BUILD_TIME / 10000) % 100; + if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t)) + ErrorF("Build Date: %s\n", buf); +#else + if (strftime(buf, sizeof(buf), "%d %B %Y", &t)) + ErrorF("Build Date: %s\n", buf); +#endif + } +#endif +#if defined(CLOG_DATE) && (CLOG_DATE > 19000000) + { + struct tm t; + char buf[100]; + + bzero(&t, sizeof(t)); + bzero(buf, sizeof(buf)); + t.tm_mday = CLOG_DATE % 100; + t.tm_mon = (CLOG_DATE / 100) % 100 - 1; + t.tm_year = CLOG_DATE / 10000 - 1900; + if (strftime(buf, sizeof(buf), "%d %B %Y", &t)) + ErrorF("Changelog Date: %s\n", buf); + } +#endif +#if defined(BUILDERSTRING) + ErrorF("%s \n",BUILDERSTRING); +#endif + ErrorF("\tBefore reporting problems, check "__VENDORDWEBSUPPORT__"\n" + "\tto make sure that you have the latest version.\n"); +} + +static void +xf86PrintMarkers() +{ + LogPrintMarkers(); +} + +static void +DoModalias() +{ + int i = -1; + char **vlist; + + /* Get all the drivers */ + vlist = xf86DriverlistFromCompile(); + if (!vlist) { + ErrorF("Missing output drivers. PCI Access dump failed.\n"); + goto bail; + } + + /* Load all the drivers that were found. */ + xf86LoadModules(vlist, NULL); + + xfree(vlist); + + /* Iterate through each driver */ + for (i = 0; i < xf86NumDrivers; i++) { + struct pci_id_match *match; + + /* Iterate through each pci id match data, dumping it to the screen */ + for (match = (struct pci_id_match *) xf86DriverList[i]->supported_devices ; + match && !(!match->vendor_id && !match->device_id) ; match++) { + /* Prefix */ + ErrorF("alias pci:"); + + /* Vendor */ + if (match->vendor_id == ~0) + ErrorF("v*"); + else + ErrorF("v%08X", match->vendor_id); + + /* Device */ + if (match->device_id == ~0) + ErrorF("d*"); + else + ErrorF("d%08X", match->device_id); + + /* Subvendor */ + if (match->subvendor_id == ~0) + ErrorF("sv*"); + else + ErrorF("sv%08X", match->subvendor_id); + + /* Subdevice */ + if (match->subdevice_id == ~0) + ErrorF("sd*"); + else + ErrorF("sd%08X", match->subdevice_id); + + /* Class */ + if ((match->device_class_mask >> 16 & 0xFF) == 0xFF) + ErrorF("bc%02X", match->device_class >> 16 & 0xFF); + else + ErrorF("bc*"); + if ((match->device_class_mask >> 8 & 0xFF) == 0xFF) + ErrorF("sc%02X", match->device_class >> 8 & 0xFF); + else + ErrorF("sc*"); + if ((match->device_class_mask & 0xFF) == 0xFF) + ErrorF("i%02X*", match->device_class & 0xFF); + else + ErrorF("i*"); + + /* Suffix (driver) */ + ErrorF(" %s\n", xf86DriverList[i]->driverName); + } + } + +bail: + OsCleanup(TRUE); + AbortDDX(); + fflush(stderr); + exit(0); +} + +static Bool +xf86CreateRootWindow(WindowPtr pWin) +{ + int ret = TRUE; + int err = Success; + ScreenPtr pScreen = pWin->drawable.pScreen; + RootWinPropPtr pProp; + CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr) + dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey); + +#ifdef DEBUG + ErrorF("xf86CreateRootWindow(%p)\n", pWin); +#endif + + if ( pScreen->CreateWindow != xf86CreateRootWindow ) { + /* Can't find hook we are hung on */ + xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */, + "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n", + (void *)xf86CreateRootWindow, + (void *)pScreen->CreateWindow ); + } + + /* Unhook this function ... */ + pScreen->CreateWindow = CreateWindow; + dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL); + + /* ... and call the previous CreateWindow fuction, if any */ + if (NULL!=pScreen->CreateWindow) { + ret = (*pScreen->CreateWindow)(pWin); + } + + /* Now do our stuff */ + if (xf86RegisteredPropertiesTable != NULL) { + if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) { + for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum]; + pProp != NULL && err==Success; + pProp = pProp->next ) + { + Atom prop; + + prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE); + err = dixChangeWindowProperty(serverClient, pWin, + prop, pProp->type, + pProp->format, PropModeReplace, + pProp->size, pProp->data, + FALSE); + } + + /* Look at err */ + ret &= (err==Success); + + } else { + xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with " + "non-root window %p (parent %p)\n", + (void *)pWin, (void *)pWin->parent); + ret = FALSE; + } + } + +#ifdef DEBUG + ErrorF("xf86CreateRootWindow() returns %d\n", ret); +#endif + return (ret); +} + + +static void +PostConfigInit(void) +{ + /* + * Install signal handler for unexpected signals + */ + xf86Info.caughtSignal=FALSE; + if (!xf86Info.notrapSignals) { + signal(SIGSEGV,xf86SigHandler); + signal(SIGILL,xf86SigHandler); +#ifdef SIGEMT + signal(SIGEMT,xf86SigHandler); +#endif + signal(SIGFPE,xf86SigHandler); +#ifdef SIGBUS + signal(SIGBUS,xf86SigHandler); +#endif +#ifdef SIGSYS + signal(SIGSYS,xf86SigHandler); +#endif +#ifdef SIGXCPU + signal(SIGXCPU,xf86SigHandler); +#endif +#ifdef SIGXFSZ + signal(SIGXFSZ,xf86SigHandler); +#endif + } + +#ifdef XF86PM + xf86OSPMClose = xf86OSPMOpen(); +#endif + + /* Do this after XF86Config is read (it's normally in OsInit()) */ + OsInitColors(); +} + + +#define END_OF_MATCHES(m) \ + (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0)) + +Bool +probe_devices_from_device_sections(DriverPtr drvp) +{ + int i, j; + struct pci_device * pPci; + Bool foundScreen = FALSE; + const struct pci_id_match * const devices = drvp->supported_devices; + GDevPtr *devList; + const unsigned numDevs = xf86MatchDevice(drvp->driverName, & devList); + + + for ( i = 0 ; i < numDevs ; i++ ) { + struct pci_device_iterator *iter; + unsigned device_id; + + + /* Find the pciVideoRec associated with this device section. + */ + iter = pci_id_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + if (devList[i]->busID && *devList[i]->busID) { + if (xf86ComparePciBusString(devList[i]->busID, + ((pPci->domain << 8) + | pPci->bus), + pPci->dev, + pPci->func)) { + break; + } + } + else if (xf86IsPrimaryPci(pPci)) { + break; + } + } + + pci_iterator_destroy(iter); + + if (pPci == NULL) { + continue; + } + + device_id = (devList[i]->chipID > 0) + ? devList[i]->chipID : pPci->device_id; + + + /* Once the pciVideoRec is found, determine if the device is supported + * by the driver. If it is, probe it! + */ + for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) { + if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id ) + && PCI_ID_COMPARE( devices[j].device_id, device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + int entry; + + /* Allow the same entity to be used more than once for + * devices with multiple screens per entity. This assumes + * implicitly that there will be a screen == 0 instance. + * + * FIXME Need to make sure that two different drivers don't + * FIXME claim the same screen > 0 instance. + */ + if ( (devList[i]->screen == 0) && !xf86CheckPciSlot( pPci ) ) + continue; + +#ifdef DEBUG + ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n", + drvp->driverName, pPci->bus, pPci->dev, pPci->func); +#endif + + /* Allocate an entry in the lists to be returned */ + entry = xf86ClaimPciSlot(pPci, drvp, device_id, + devList[i], devList[i]->active); + + if ((entry == -1) && (devList[i]->screen > 0)) { + unsigned k; + + for ( k = 0; k < xf86NumEntities; k++ ) { + EntityPtr pEnt = xf86Entities[k]; + if (pEnt->busType != BUS_PCI) + continue; + + if (pEnt->bus.id.pci == pPci) { + entry = k; + xf86AddDevToEntity(k, devList[i]); + break; + } + } + } + + if (entry != -1) { + if ((*drvp->PciProbe)(drvp, entry, pPci, + devices[j].match_data)) { + foundScreen = TRUE; + } + } + + break; + } + } + } + + + return foundScreen; +} + + +Bool +add_matching_devices_to_configure_list(DriverPtr drvp) +{ + const struct pci_id_match * const devices = drvp->supported_devices; + int j; + struct pci_device *pPci; + struct pci_device_iterator *iter; + int numFound = 0; + + + iter = pci_id_match_iterator_create(NULL); + while ((pPci = pci_device_next(iter)) != NULL) { + /* Determine if this device is supported by the driver. If it is, + * add it to the list of devices to configure. + */ + for (j = 0 ; ! END_OF_MATCHES(devices[j]) ; j++) { + if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id ) + && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + if (xf86CheckPciSlot(pPci)) { + GDevPtr pGDev = + xf86AddDeviceToConfigure(drvp->driverName, pPci, -1); + if (pGDev != NULL) { + /* After configure pass 1, chipID and chipRev are + * treated as over-rides, so clobber them here. + */ + pGDev->chipID = -1; + pGDev->chipRev = -1; + } + + numFound++; + } + + break; + } + } + } + + pci_iterator_destroy(iter); + + + return (numFound != 0); +} + + +Bool +check_for_matching_devices(DriverPtr drvp) +{ + const struct pci_id_match * const devices = drvp->supported_devices; + int j; + + + for (j = 0; ! END_OF_MATCHES(devices[j]); j++) { + struct pci_device_iterator *iter; + struct pci_device *dev; + + iter = pci_id_match_iterator_create(& devices[j]); + dev = pci_device_next(iter); + pci_iterator_destroy(iter); + + if (dev != NULL) { + return TRUE; + } + } + + + return FALSE; +} + + +/** + * Call the driver's correct probe function. + * + * If the driver implements the \c DriverRec::PciProbe entry-point and an + * appropriate PCI device (with matching Device section in the xorg.conf file) + * is found, it is called. If \c DriverRec::PciProbe or no devices can be + * successfully probed with it (e.g., only non-PCI devices are available), + * the driver's \c DriverRec::Probe function is called. + * + * \param drv Driver to probe + * + * \return + * If a device can be successfully probed by the driver, \c TRUE is + * returned. Otherwise, \c FALSE is returned. + */ +Bool +xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) +{ + Bool foundScreen = FALSE; + + if ( drv->PciProbe != NULL ) { + if ( xf86DoProbe ) { + assert( detect_only ); + foundScreen = check_for_matching_devices( drv ); + } + else if ( xf86DoConfigure && xf86DoConfigurePass1 ) { + assert( detect_only ); + foundScreen = add_matching_devices_to_configure_list( drv ); + } + else { + assert( ! detect_only ); + foundScreen = probe_devices_from_device_sections( drv ); + } + } + + if ( ! foundScreen && (drv->Probe != NULL) ) { + xf86Msg( X_WARNING, "Falling back to old probe method for %s\n", + drv->driverName ); + foundScreen = (*drv->Probe)( drv, (detect_only) ? PROBE_DETECT + : PROBE_DEFAULT ); + } + + return foundScreen; +} + +/* + * InitOutput -- + * Initialize screenInfo for all actually accessible framebuffers. + * That includes vt-manager setup, querying all possible devices and + * collecting the pixmap formats. + */ +void +InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) +{ + int i, j, k, scr_index; + char **modulelist; + pointer *optionlist; + screenLayoutPtr layout; + Pix24Flags screenpix24, pix24; + MessageType pix24From = X_DEFAULT; + Bool pix24Fail = FALSE; + Bool autoconfig = FALSE; + + xf86Initialising = TRUE; + + if (serverGeneration == 1) { + + pScreenInfo->numScreens = 0; + + if ((xf86ServerName = strrchr(argv[0], '/')) != 0) + xf86ServerName++; + else + xf86ServerName = argv[0]; + + if (!xf86DoModalias) { + xf86PrintBanner(); + xf86PrintMarkers(); + if (xf86LogFile) { + time_t t; + const char *ct; + t = time(NULL); + ct = ctime(&t); + xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s", + xf86LogFile, ct); + } + } + + /* Read and parse the config file */ + if (!xf86DoProbe && !xf86DoConfigure && !xf86DoModalias) { + switch (xf86HandleConfigFile(FALSE)) { + case CONFIG_OK: + break; + case CONFIG_PARSE_ERROR: + xf86Msg(X_ERROR, "Error parsing the config file\n"); + return; + case CONFIG_NOFILE: + autoconfig = TRUE; + break; + } + } + + if (!autoconfig) + PostConfigInit(); + + /* Initialise the loader */ + LoaderInit(); + + /* Tell the loader the default module search path */ + LoaderSetPath(xf86ModulePath); + + if (xf86Info.ignoreABI) { + LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); + } + + xf86OpenConsole(); + + /* Do a general bus probe. This will be a PCI probe for x86 platforms */ + xf86BusProbe(); + + if (xf86DoProbe) + DoProbe(); + + if (xf86DoConfigure) + DoConfigure(); + + /* Do the PCI Access dump */ + if (xf86DoModalias) + DoModalias(); + + if (autoconfig) { + if (!xf86AutoConfig()) { + xf86Msg(X_ERROR, "Auto configuration failed\n"); + return; + } + PostConfigInit(); + } + + /* Initialise the resource broker */ + xf86ResourceBrokerInit(); + + /* Load all modules specified explicitly in the config file */ + if ((modulelist = xf86ModulelistFromConfig(&optionlist))) { + xf86LoadModules(modulelist, optionlist); + xfree(modulelist); + xfree(optionlist); + } + + /* Load all driver modules specified in the config file */ + /* If there aren't any specified in the config file, autoconfig them */ + /* FIXME: Does not handle multiple active screen sections, but I'm not + * sure if we really want to handle that case*/ + GDevPtr configured_device = xf86ConfigLayout.screens->screen->device; + if ((!configured_device) || (!configured_device->driver)) { + if (!autoConfigDevice(configured_device)) { + xf86Msg(X_ERROR, "Automatic driver configuration failed\n"); + return ; + } + } + if ((modulelist = xf86DriverlistFromConfig())) { + xf86LoadModules(modulelist, NULL); + xfree(modulelist); + } + + /* Load all input driver modules specified in the config file. */ + if ((modulelist = xf86InputDriverlistFromConfig())) { + xf86LoadModules(modulelist, NULL); + xfree(modulelist); + } + + /* + * It is expected that xf86AddDriver()/xf86AddInputDriver will be + * called for each driver as it is loaded. Those functions save the + * module pointers for drivers. + * XXX Nothing keeps track of them for other modules. + */ + /* XXX What do we do if not all of these could be loaded? */ + + /* + * At this point, xf86DriverList[] is all filled in with entries for + * each of the drivers to try and xf86NumDrivers has the number of + * drivers. If there are none, return now. + */ + + if (xf86NumDrivers == 0) { + xf86Msg(X_ERROR, "No drivers available.\n"); + return; + } + + /* + * Call each of the Identify functions and call the driverFunc to check + * if HW access is required. The Identify functions print out some + * identifying information, and anything else that might be + * needed at this early stage. + */ + + for (i = 0; i < xf86NumDrivers; i++) { + xorgHWFlags flags; + /* The Identify function is mandatory, but if it isn't there continue */ + if (xf86DriverList[i]->Identify != NULL) + xf86DriverList[i]->Identify(0); + else { + xf86Msg(X_WARNING, "Driver `%s' has no Identify function\n", + xf86DriverList[i]->driverName ? xf86DriverList[i]->driverName + : "noname"); + } + if (!xorgHWAccess + && (!xf86DriverList[i]->driverFunc + || !xf86DriverList[i]->driverFunc(NULL, + GET_REQUIRED_HW_INTERFACES, + &flags) + || NEED_IO_ENABLED(flags))) + xorgHWAccess = TRUE; + } + + /* Enable full I/O access */ + if (xorgHWAccess) { + if(!xf86EnableIO()) + /* oops, we have failed */ + xorgHWAccess = FALSE; + } + + /* + * Locate bus slot that had register IO enabled at server startup + */ + + xf86AccessInit(); + xf86FindPrimaryDevice(); + + /* + * Now call each of the Probe functions. Each successful probe will + * result in an extra entry added to the xf86Screens[] list for each + * instance of the hardware found. + */ + + for (i = 0; i < xf86NumDrivers; i++) { + xorgHWFlags flags; + if (!xorgHWAccess) { + if (!xf86DriverList[i]->driverFunc + || !xf86DriverList[i]->driverFunc(NULL, + GET_REQUIRED_HW_INTERFACES, + &flags) + || NEED_IO_ENABLED(flags)) + continue; + } + + xf86CallDriverProbe( xf86DriverList[i], FALSE ); + } + + /* + * If nothing was detected, return now. + */ + + if (xf86NumScreens == 0) { + xf86Msg(X_ERROR, "No devices detected.\n"); + return; + } + + /* + * Match up the screens found by the probes against those specified + * in the config file. Remove the ones that won't be used. Sort + * them in the order specified. + */ + + /* + * What is the best way to do this? + * + * For now, go through the screens allocated by the probes, and + * look for screen config entry which refers to the same device + * section as picked out by the probe. + * + */ + + for (i = 0; i < xf86NumScreens; i++) { + for (layout = xf86ConfigLayout.screens; layout->screen != NULL; + layout++) { + Bool found = FALSE; + for (j = 0; j < xf86Screens[i]->numEntities; j++) { + + GDevPtr dev = + xf86GetDevFromEntity(xf86Screens[i]->entityList[j], + xf86Screens[i]->entityInstanceList[j]); + + if (dev == layout->screen->device) { + /* A match has been found */ + xf86Screens[i]->confScreen = layout->screen; + found = TRUE; + break; + } + } + if (found) break; + } + if (layout->screen == NULL) { + /* No match found */ + xf86Msg(X_ERROR, + "Screen %d deleted because of no matching config section.\n", i); + xf86DeleteScreen(i--, 0); + } + } + + /* + * If no screens left, return now. + */ + + if (xf86NumScreens == 0) { + xf86Msg(X_ERROR, + "Device(s) detected, but none match those in the config file.\n"); + return; + } + + xf86PostProbe(); + xf86EntityInit(); + + /* + * Sort the drivers to match the requested ording. Using a slow + * bubble sort. + */ + for (j = 0; j < xf86NumScreens - 1; j++) { + for (i = 0; i < xf86NumScreens - j - 1; i++) { + if (xf86Screens[i + 1]->confScreen->screennum < + xf86Screens[i]->confScreen->screennum) { + ScrnInfoPtr tmpScrn = xf86Screens[i + 1]; + xf86Screens[i + 1] = xf86Screens[i]; + xf86Screens[i] = tmpScrn; + } + } + } + /* Fix up the indexes */ + for (i = 0; i < xf86NumScreens; i++) { + xf86Screens[i]->scrnIndex = i; + } + + /* + * Call the driver's PreInit()'s to complete initialisation for the first + * generation. + */ + + for (i = 0; i < xf86NumScreens; i++) { + xf86EnableAccess(xf86Screens[i]); + if (xf86Screens[i]->PreInit && + xf86Screens[i]->PreInit(xf86Screens[i], 0)) + xf86Screens[i]->configured = TRUE; + } + for (i = 0; i < xf86NumScreens; i++) + if (!xf86Screens[i]->configured) + xf86DeleteScreen(i--, 0); + + /* + * If no screens left, return now. + */ + + if (xf86NumScreens == 0) { + xf86Msg(X_ERROR, + "Screen(s) found, but none have a usable configuration.\n"); + return; + } + + /* This could be moved into a separate function */ + + /* + * Check that all screens have initialised the mandatory function + * entry points. Delete those which have not. + */ + +#define WARN_SCREEN(func) \ + xf86Msg(X_ERROR, "Driver `%s' has no %s function, deleting.\n", \ + xf86Screens[i]->name, (warned++, func)) + + for (i = 0; i < xf86NumScreens; i++) { + int warned = 0; + if (xf86Screens[i]->name == NULL) { + xf86Screens[i]->name = xnfalloc(strlen("screen") + 1 + 1); + if (i < 10) + sprintf(xf86Screens[i]->name, "screen%c", i + '0'); + else + sprintf(xf86Screens[i]->name, "screen%c", i - 10 + 'A'); + xf86MsgVerb(X_WARNING, 0, + "Screen driver %d has no name set, using `%s'.\n", + i, xf86Screens[i]->name); + } + if (xf86Screens[i]->ScreenInit == NULL) + WARN_SCREEN("ScreenInit"); + if (xf86Screens[i]->EnterVT == NULL) + WARN_SCREEN("EnterVT"); + if (xf86Screens[i]->LeaveVT == NULL) + WARN_SCREEN("LeaveVT"); + if (warned) + xf86DeleteScreen(i--, 0); + } + + /* + * If no screens left, return now. + */ + + if (xf86NumScreens == 0) { + xf86Msg(X_ERROR, "Screen(s) found, but drivers were unusable.\n"); + return; + } + + /* XXX Should this be before or after loading dependent modules? */ + if (xf86ProbeOnly) + { + OsCleanup(TRUE); + AbortDDX(); + fflush(stderr); + exit(0); + } + + /* Remove (unload) drivers that are not required */ + for (i = 0; i < xf86NumDrivers; i++) + if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0) + xf86DeleteDriver(i); + + /* + * At this stage we know how many screens there are. + */ + + for (i = 0; i < xf86NumScreens; i++) + xf86InitViewport(xf86Screens[i]); + + /* + * Collect all pixmap formats and check for conflicts at the display + * level. Should we die here? Or just delete the offending screens? + * Also, should this be done for -probeonly? + */ + screenpix24 = Pix24DontCare; + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->imageByteOrder != + xf86Screens[0]->imageByteOrder) + FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); + if (xf86Screens[i]->bitmapScanlinePad != + xf86Screens[0]->bitmapScanlinePad) + FatalError("Inconsistent display bitmapScanlinePad. Exiting\n"); + if (xf86Screens[i]->bitmapScanlineUnit != + xf86Screens[0]->bitmapScanlineUnit) + FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n"); + if (xf86Screens[i]->bitmapBitOrder != + xf86Screens[0]->bitmapBitOrder) + FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); + + /* Determine the depth 24 pixmap format the screens would like */ + if (xf86Screens[i]->pixmap24 != Pix24DontCare) { + if (screenpix24 == Pix24DontCare) + screenpix24 = xf86Screens[i]->pixmap24; + else if (screenpix24 != xf86Screens[i]->pixmap24) + FatalError("Inconsistent depth 24 pixmap format. Exiting\n"); + } + } + /* check if screenpix24 is consistent with the config/cmdline */ + if (xf86Info.pixmap24 != Pix24DontCare) { + pix24 = xf86Info.pixmap24; + pix24From = xf86Info.pix24From; + if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24) + pix24Fail = TRUE; + } else if (screenpix24 != Pix24DontCare) { + pix24 = screenpix24; + pix24From = X_PROBED; + } else + pix24 = Pix24Use32; + + if (pix24Fail) + FatalError("Screen(s) can't use the required depth 24 pixmap format" + " (%d). Exiting\n", PIX24TOBPP(pix24)); + + /* Initialise the depth 24 format */ + for (j = 0; j < numFormats && formats[j].depth != 24; j++) + ; + formats[j].bitsPerPixel = PIX24TOBPP(pix24); + + /* Collect additional formats */ + for (i = 0; i < xf86NumScreens; i++) { + for (j = 0; j < xf86Screens[i]->numFormats; j++) { + for (k = 0; ; k++) { + if (k >= numFormats) { + if (k >= MAXFORMATS) + FatalError("Too many pixmap formats! Exiting\n"); + formats[k] = xf86Screens[i]->formats[j]; + numFormats++; + break; + } + if (formats[k].depth == xf86Screens[i]->formats[j].depth) { + if ((formats[k].bitsPerPixel == + xf86Screens[i]->formats[j].bitsPerPixel) && + (formats[k].scanlinePad == + xf86Screens[i]->formats[j].scanlinePad)) + break; + FatalError("Inconsistent pixmap format for depth %d." + " Exiting\n", formats[k].depth); + } + } + } + } + formatsDone = TRUE; + + if (xf86Info.vtno >= 0 ) { +#define VT_ATOM_NAME "XFree86_VT" + Atom VTAtom=-1; + CARD32 *VT = NULL; + int ret; + + /* This memory needs to stay available until the screen has been + initialized, and we can create the property for real. + */ + if ( (VT = xalloc(sizeof(CARD32)))==NULL ) { + FatalError("Unable to make VT property - out of memory. Exiting...\n"); + } + *VT = xf86Info.vtno; + + VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE); + + for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) { + ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex, + VTAtom, XA_INTEGER, 32, + 1, VT ); + if (ret != Success) + xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING, + "Failed to register VT property\n"); + } + } + + /* If a screen uses depth 24, show what the pixmap format is */ + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->depth == 24) { + xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n", + PIX24TOBPP(pix24)); + break; + } + } + +#ifdef XKB + xf86InitXkb(); +#endif + /* set up the proper access funcs */ + xf86PostPreInit(); + + AddCallback(&ServerGrabCallback, xf86GrabServerCallback, NULL); + + } else { + /* + * serverGeneration != 1; some OSs have to do things here, too. + */ + xf86OpenConsole(); + +#ifdef XF86PM + /* + should we reopen it here? We need to deal with an already opened + device. We could leave this to the OS layer. For now we simply + close it here + */ + if (xf86OSPMClose) + xf86OSPMClose(); + if ((xf86OSPMClose = xf86OSPMOpen()) != NULL) + xf86MsgVerb(X_INFO, 3, "APM registered successfully\n"); +#endif + + /* Make sure full I/O access is enabled */ + if (xorgHWAccess) + xf86EnableIO(); + } + +#if 0 + /* + * Install signal handler for unexpected signals + */ + xf86Info.caughtSignal=FALSE; + if (!xf86Info.notrapSignals) + { + signal(SIGSEGV,xf86SigHandler); + signal(SIGILL,xf86SigHandler); +#ifdef SIGEMT + signal(SIGEMT,xf86SigHandler); +#endif + signal(SIGFPE,xf86SigHandler); +#ifdef SIGBUS + signal(SIGBUS,xf86SigHandler); +#endif +#ifdef SIGSYS + signal(SIGSYS,xf86SigHandler); +#endif +#ifdef SIGXCPU + signal(SIGXCPU,xf86SigHandler); +#endif +#ifdef SIGXFSZ + signal(SIGXFSZ,xf86SigHandler); +#endif + } +#endif + + /* + * Use the previously collected parts to setup pScreenInfo + */ + + pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder; + pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad; + pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit; + pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder; + pScreenInfo->numPixmapFormats = numFormats; + for (i = 0; i < numFormats; i++) + pScreenInfo->formats[i] = formats[i]; + + /* Make sure the server's VT is active */ + + if (serverGeneration != 1) { + xf86Resetting = TRUE; + /* All screens are in the same state, so just check the first */ + if (!xf86Screens[0]->vtSema) { +#ifdef HAS_USL_VTS + ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ); +#endif + xf86AccessEnter(); + xf86EnterServerState(SETUP); + } + } +#ifdef SCO325 + else { + /* + * Under SCO we must ack that we got the console at startup, + * I think this is the safest way to assure it. + */ + static int once = 1; + if (once) { + once = 0; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + xf86Msg(X_WARNING, "VT_ACKACQ failed"); + } + } +#endif /* SCO325 */ + + for (i = 0; i < xf86NumScreens; i++) { + xf86EnableAccess(xf86Screens[i]); + /* + * Almost everything uses these defaults, and many of those that + * don't, will wrap them. + */ + xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; + xf86Screens[i]->SetDGAMode = xf86SetDGAMode; + xf86Screens[i]->DPMSSet = NULL; + xf86Screens[i]->LoadPalette = NULL; + xf86Screens[i]->SetOverscan = NULL; + xf86Screens[i]->DriverFunc = NULL; + xf86Screens[i]->pScreen = NULL; + scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv); + if (scr_index == i) { + /* + * Hook in our ScrnInfoRec, and initialise some other pScreen + * fields. + */ + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86ScreenKey, xf86Screens[i]); + xf86Screens[i]->pScreen = screenInfo.screens[scr_index]; + /* The driver should set this, but make sure it is set anyway */ + xf86Screens[i]->vtSema = TRUE; + } else { + /* This shouldn't normally happen */ + FatalError("AddScreen/ScreenInit failed for driver %d\n", i); + } + +#ifdef DEBUG + ErrorF("InitOutput - xf86Screens[%d]->pScreen = %p\n", + i, xf86Screens[i]->pScreen ); + ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n", + i, xf86Screens[i]->pScreen->CreateWindow ); +#endif + + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86CreateRootWindowKey, + xf86Screens[i]->pScreen->CreateWindow); + xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow; + +#ifdef RENDER + if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown) + { + xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC); + PictureSetSubpixelOrder (xf86Screens[i]->pScreen, + DDC ? + (DDC->features.input_type ? + SubPixelHorizontalRGB : SubPixelNone) : + SubPixelUnknown); + } +#endif +#ifdef RANDR + if (!xf86Info.disableRandR) + xf86RandRInit (screenInfo.screens[scr_index]); + xf86Msg(xf86Info.randRFrom, "RandR %s\n", + xf86Info.disableRandR ? "disabled" : "enabled"); +#endif + } + + xf86PostScreenInit(); + + xf86InitOrigins(); + + xf86Resetting = FALSE; + xf86Initialising = FALSE; + + RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup, + NULL); +} + +/* + * InitInput -- + * Initialize all supported input devices. + */ + +void +InitInput(argc, argv) + int argc; + char **argv; +{ + IDevPtr* pDev; + InputDriverPtr pDrv; + InputInfoPtr pInfo; + + xf86Info.vtRequestsPending = FALSE; + xf86Info.inputPending = FALSE; + + /* Call the PreInit function for each input device instance. */ + for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { + /* Replace obsolete keyboard driver with kbd */ + if (!xf86NameCmp((*pDev)->driver, "keyboard")) { + strcpy((*pDev)->driver, "kbd"); + } + + if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) { + xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver); + /* XXX For now, just continue. */ + continue; + } + if (!pDrv->PreInit) { + xf86MsgVerb(X_WARNING, 0, + "Input driver `%s' has no PreInit function (ignoring)\n", + pDrv->driverName); + continue; + } + pInfo = pDrv->PreInit(pDrv, *pDev, 0); + if (!pInfo) { + xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", + (*pDev)->identifier); + continue; + } else if (!(pInfo->flags & XI86_CONFIGURED)) { + xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n", + (*pDev)->identifier); + xf86DeleteInput(pInfo, 0); + continue; + } + } + + /* Initialise all input devices. */ + pInfo = xf86InputDevs; + while (pInfo) { + xf86Msg(X_INFO, "evaluating device (%s)\n", pInfo->name); + xf86ActivateDevice(pInfo); + pInfo = pInfo->next; + } + + mieqInit(); +} + +#ifndef SET_STDERR_NONBLOCKING +#define SET_STDERR_NONBLOCKING 1 +#endif + +/* + * OsVendorInit -- + * OS/Vendor-specific initialisations. Called from OsInit(), which + * is called by dix before establishing the well known sockets. + */ + +void +OsVendorInit() +{ + static Bool beenHere = FALSE; + +#ifdef SIGCHLD + signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */ +#endif + OsDelayInitColors = TRUE; +#ifndef BUILTIN_FONTS + loadableFonts = TRUE; +#endif + + if (!beenHere) + xf86LogInit(); + +#if SET_STDERR_NONBLOCKING + /* Set stderr to non-blocking. */ +#ifndef O_NONBLOCK +#if defined(FNDELAY) +#define O_NONBLOCK FNDELAY +#elif defined(O_NDELAY) +#define O_NONBLOCK O_NDELAY +#endif +#endif + +#ifdef O_NONBLOCK + if (!beenHere) { + if (geteuid() == 0 && getuid() != geteuid()) + { + int status; + + status = fcntl(fileno(stderr), F_GETFL, 0); + if (status != -1) { + fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK); + } + } + } +#endif +#endif + + beenHere = TRUE; +} + +/* + * ddxGiveUp -- + * Device dependent cleanup. Called by by dix before normal server death. + * For SYSV386 we must switch the terminal back to normal mode. No error- + * checking here, since there should be restored as much as possible. + */ + +void +ddxGiveUp() +{ + int i; + +#ifdef XF86PM + if (xf86OSPMClose) + xf86OSPMClose(); + xf86OSPMClose = NULL; +#endif + + xf86AccessLeaveState(); + + for (i = 0; i < xf86NumScreens; i++) { + /* + * zero all access functions to + * trap calls when switched away. + */ + xf86Screens[i]->vtSema = FALSE; + xf86Screens[i]->access = NULL; + xf86Screens[i]->busAccess = NULL; + } + +#ifdef USE_XF86_SERVERLOCK + xf86UnlockServer(); +#endif +#ifdef XFreeXDGA + DGAShutdown(); +#endif + + xf86CloseConsole(); + + xf86CloseLog(); + + /* If an unexpected signal was caught, dump a core for debugging */ + if (xf86Info.caughtSignal) + abort(); +} + + + +/* + * AbortDDX -- + * DDX - specific abort routine. Called by AbortServer(). The attempt is + * made to restore all original setting of the displays. Also all devices + * are closed. + */ + +void +AbortDDX() +{ + int i; + + /* + * try to restore the original video state + */ +#ifdef DPMSExtension /* Turn screens back on */ + if (DPMSPowerLevel != DPMSModeOn) + DPMSSet(serverClient, DPMSModeOn); +#endif + if (xf86Screens) { + if (xf86Screens[0]->vtSema) + xf86EnterServerState(SETUP); + for (i = 0; i < xf86NumScreens; i++) + if (xf86Screens[i]->vtSema) { + /* + * if we are aborting before ScreenInit() has finished + * we might not have been wrapped yet. Therefore enable + * screen explicitely. + */ + xf86EnableAccess(xf86Screens[i]); + (xf86Screens[i]->LeaveVT)(i, 0); + } + } + + xf86AccessLeave(); + + /* + * This is needed for an abnormal server exit, since the normal exit stuff + * MUST also be performed (i.e. the vt must be left in a defined state) + */ + ddxGiveUp(); +} + +void +OsVendorFatalError() +{ +#ifdef VENDORSUPPORT + ErrorF("\nPlease refer to your Operating System Vendor support pages\n" + "at %s for support on this crash.\n",VENDORSUPPORT); +#else + ErrorF("\nPlease consult the "XVENDORNAME" support \n" + "\t at "__VENDORDWEBSUPPORT__"\n for help. \n"); +#endif + if (xf86LogFile && xf86LogFileWasOpened) + ErrorF("Please also check the log file at \"%s\" for additional " + "information.\n", xf86LogFile); + ErrorF("\n"); +} + +int +xf86SetVerbosity(int verb) +{ + int save = xf86Verbose; + + xf86Verbose = verb; + LogSetParameter(XLOG_VERBOSITY, verb); + return save; +} + +int +xf86SetLogVerbosity(int verb) +{ + int save = xf86LogVerbose; + + xf86LogVerbose = verb; + LogSetParameter(XLOG_FILE_VERBOSITY, verb); + return save; +} + +/* + * ddxProcessArgument -- + * Process device-dependent command line args. Returns 0 if argument is + * not device dependent, otherwise Count of number of elements of argv + * that are part of a device dependent commandline option. + * + */ + + + +/* ARGSUSED */ +int +ddxProcessArgument(int argc, char **argv, int i) +{ + /* + * Note: can't use xalloc/xfree here because OsInit() hasn't been called + * yet. Use malloc/free instead. + */ + +#define CHECK_FOR_REQUIRED_ARGUMENT() \ + if (((i + 1) >= argc) || (!argv[i + 1])) { \ + ErrorF("Required argument to %s not specified\n", argv[i]); \ + UseMsg(); \ + FatalError("Required argument to %s not specified\n", argv[i]); \ + } + + /* First the options that are only allowed for root */ + if (getuid() == 0 || geteuid() != 0) + { + if (!strcmp(argv[i], "-modulepath")) + { + char *mp; + CHECK_FOR_REQUIRED_ARGUMENT(); + mp = malloc(strlen(argv[i + 1]) + 1); + if (!mp) + FatalError("Can't allocate memory for ModulePath\n"); + strcpy(mp, argv[i + 1]); + xf86ModulePath = mp; + xf86ModPathFrom = X_CMDLINE; + return 2; + } + else if (!strcmp(argv[i], "-logfile")) + { + char *lf; + CHECK_FOR_REQUIRED_ARGUMENT(); + lf = malloc(strlen(argv[i + 1]) + 1); + if (!lf) + FatalError("Can't allocate memory for LogFile\n"); + strcpy(lf, argv[i + 1]); + xf86LogFile = lf; + xf86LogFileFrom = X_CMDLINE; + return 2; + } + } else if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) { + FatalError("The '%s' option can only be used by root.\n", argv[i]); + } + if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) { + FatalError("\nInvalid argument for %s\n" + "\tFor non-root users, the file specified with %s must be\n" + "\ta relative path and must not contain any \"..\" elements.\n" + "\tUsing default "__XCONFIGFILE__" search path.\n\n", + argv[i], argv[i]); + } + xf86ConfigFile = argv[i + 1]; + return 2; + } + if (!strcmp(argv[i],"-showunresolved")) + { + xf86ShowUnresolved = TRUE; + return 1; + } + if (!strcmp(argv[i],"-probeonly")) + { + xf86ProbeOnly = TRUE; + return 1; + } + if (!strcmp(argv[i],"-flipPixels")) + { + xf86FlipPixels = TRUE; + return 1; + } +#ifdef XF86VIDMODE + if (!strcmp(argv[i],"-disableVidMode")) + { + xf86VidModeDisabled = TRUE; + return 1; + } + if (!strcmp(argv[i],"-allowNonLocalXvidtune")) + { + xf86VidModeAllowNonLocal = TRUE; + return 1; + } +#endif +#ifdef XF86MISC + if (!strcmp(argv[i],"-disableModInDev")) + { + xf86MiscModInDevDisabled = TRUE; + return 1; + } + if (!strcmp(argv[i],"-allowNonLocalModInDev")) + { + xf86MiscModInDevAllowNonLocal = TRUE; + return 1; + } +#endif + if (!strcmp(argv[i],"-allowMouseOpenFail")) + { + xf86AllowMouseOpenFail = TRUE; + return 1; + } + if (!strcmp(argv[i],"-bestRefresh")) + { + xf86BestRefresh = TRUE; + return 1; + } + if (!strcmp(argv[i],"-ignoreABI")) + { + LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); + return 1; + } + if (!strcmp(argv[i],"-verbose")) + { + if (++i < argc && argv[i]) + { + char *end; + long val; + val = strtol(argv[i], &end, 0); + if (*end == '\0') + { + xf86SetVerbosity(val); + return 2; + } + } + xf86SetVerbosity(++xf86Verbose); + return 1; + } + if (!strcmp(argv[i],"-logverbose")) + { + if (++i < argc && argv[i]) + { + char *end; + long val; + val = strtol(argv[i], &end, 0); + if (*end == '\0') + { + xf86SetLogVerbosity(val); + return 2; + } + } + xf86SetLogVerbosity(++xf86LogVerbose); + return 1; + } + if (!strcmp(argv[i],"-quiet")) + { + xf86SetVerbosity(0); + return 1; + } + if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version")) + { + xf86PrintBanner(); + exit(0); + } + if (!strcmp(argv[i],"-showDefaultModulePath")) + { + xf86PrintDefaultModulePath(); + exit(0); + } + if (!strcmp(argv[i],"-showDefaultLibPath")) + { + xf86PrintDefaultLibraryPath(); + exit(0); + } + /* Notice the -fp flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-fp")) + { + xf86fpFlag = TRUE; + return 0; + } + /* Notice the -co flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-co")) + { + xf86coFlag = TRUE; + return 0; + } + /* Notice the -bs flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-bs")) + { + xf86bsDisableFlag = TRUE; + return 0; + } + /* Notice the +bs flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "+bs")) + { + xf86bsEnableFlag = TRUE; + return 0; + } + /* Notice the -s flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-s")) + { + xf86sFlag = TRUE; + return 0; + } + if (!strcmp(argv[i], "-pixmap24")) + { + xf86Pix24 = Pix24Use24; + return 1; + } + if (!strcmp(argv[i], "-pixmap32")) + { + xf86Pix24 = Pix24Use32; + return 1; + } + if (!strcmp(argv[i], "-fbbpp")) + { + int bpp; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%d", &bpp) == 1) + { + xf86FbBpp = bpp; + return 2; + } + else + { + ErrorF("Invalid fbbpp\n"); + return 0; + } + } + if (!strcmp(argv[i], "-depth")) + { + int depth; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%d", &depth) == 1) + { + xf86Depth = depth; + return 2; + } + else + { + ErrorF("Invalid depth\n"); + return 0; + } + } + if (!strcmp(argv[i], "-weight")) + { + int red, green, blue; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3) + { + xf86Weight.red = red; + xf86Weight.green = green; + xf86Weight.blue = blue; + return 2; + } + else + { + ErrorF("Invalid weighting\n"); + return 0; + } + } + if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") || + !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma")) + { + double gamma; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%lf", &gamma) == 1) { + if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) { + ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f" + " is valid\n", GAMMA_MIN, GAMMA_MAX); + return 0; + } + if (!strcmp(argv[i-1], "-gamma")) + xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma; + else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma; + else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma; + else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma; + return 2; + } + } + if (!strcmp(argv[i], "-layout")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86LayoutName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-screen")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86ScreenName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-pointer")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86PointerName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-keyboard")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86KeyboardName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-nosilk")) + { + xf86silkenMouseDisableFlag = TRUE; + return 1; + } +#ifdef HAVE_ACPI + if (!strcmp(argv[i], "-noacpi")) + { + xf86acpiDisableFlag = TRUE; + return 1; + } +#endif + if (!strcmp(argv[i], "-probe")) + { + xf86DoProbe = TRUE; + return 1; + } + if (!strcmp(argv[i], "-configure")) + { + if (getuid() != 0 && geteuid() == 0) { + ErrorF("The '-configure' option can only be used by root.\n"); + exit(1); + } + xf86DoConfigure = TRUE; + xf86AllowMouseOpenFail = TRUE; + return 1; + } + if (!strcmp(argv[i], "-modalias")) + { + xf86DoModalias = TRUE; + xf86AllowMouseOpenFail = TRUE; + return 1; + } + if (!strcmp(argv[i], "-isolateDevice")) + { + int bus, device, func; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (strncmp(argv[++i], "PCI:", 4)) { + FatalError("Bus types other than PCI not yet isolable\n"); + } + if (sscanf(argv[i], "PCI:%d:%d:%d", &bus, &device, &func) == 3) { + xf86IsolateDevice.domain = PCI_DOM_FROM_BUS(bus); + xf86IsolateDevice.bus = PCI_BUS_NO_DOMAIN(bus); + xf86IsolateDevice.dev = device; + xf86IsolateDevice.func = func; + return 2; + } else { + FatalError("Invalid isolated device specification\n"); + } + } + /* OS-specific processing */ + return xf86ProcessArgument(argc, argv, i); +} + +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + +/* + * ddxUseMsg -- + * Print out correct use of device dependent commandline options. + * Maybe the user now knows what really to do ... + */ + +void +ddxUseMsg() +{ + ErrorF("\n"); + ErrorF("\n"); + ErrorF("Device Dependent Usage\n"); + if (getuid() == 0 || geteuid() != 0) + { + ErrorF("-modulepath paths specify the module search path\n"); + ErrorF("-logfile file specify a log file name\n"); + ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n"); + } + ErrorF("-modalias output a modalias-style filter for each driver installed\n"); + ErrorF("-config file specify a configuration file, relative to the\n"); + ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n"); + ErrorF("-probeonly probe for devices, then exit\n"); + ErrorF("-verbose [n] verbose startup messages\n"); + ErrorF("-logverbose [n] verbose log messages\n"); + ErrorF("-quiet minimal startup messages\n"); + ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n"); + ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n"); + ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n"); + ErrorF("-depth n set colour depth. Default: 8\n"); + ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n"); + ErrorF("-rgamma f set gamma value for red phase\n"); + ErrorF("-ggamma f set gamma value for green phase\n"); + ErrorF("-bgamma f set gamma value for blue phase\n"); + ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n"); + ErrorF("-layout name specify the ServerLayout section name\n"); + ErrorF("-screen name specify the Screen section name\n"); + ErrorF("-keyboard name specify the core keyboard InputDevice name\n"); + ErrorF("-pointer name specify the core pointer InputDevice name\n"); + ErrorF("-nosilk disable Silken Mouse\n"); + ErrorF("-flipPixels swap default black/white Pixel values\n"); +#ifdef XF86VIDMODE + ErrorF("-disableVidMode disable mode adjustments with xvidtune\n"); + ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n"); +#endif +#ifdef XF86MISC + ErrorF("-disableModInDev disable dynamic modification of input device settings\n"); + ErrorF("-allowNonLocalModInDev allow changes to keyboard and mouse settings\n"); + ErrorF(" from non-local clients\n"); + ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n"); +#endif + ErrorF("-bestRefresh choose modes with the best refresh rate\n"); + ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); + ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); + ErrorF("-version show the server version\n"); + ErrorF("-showDefaultModulePath show the server default module path\n"); + ErrorF("-showDefaultLibPath show the server default library path\n"); + /* OS-specific usage */ + xf86UseMsg(); + ErrorF("\n"); +} + +static void +xf86PrintDefaultModulePath(void) +{ + ErrorF("%s\n", DEFAULT_MODULE_PATH); +} + +static void +xf86PrintDefaultLibraryPath(void) +{ + ErrorF("%s\n", DEFAULT_LIBRARY_PATH); +} + +/* + * xf86LoadModules iterates over a list that is being passed in. + */ +Bool +xf86LoadModules(char **list, pointer *optlist) +{ + int errmaj, errmin; + pointer opt; + int i; + char *name; + Bool failed = FALSE; + + if (!list) + return TRUE; + + for (i = 0; list[i] != NULL; i++) { + + /* Normalise the module name */ + name = xf86NormalizeName(list[i]); + + /* Skip empty names */ + if (name == NULL || *name == '\0') + continue; + + /* Replace obsolete keyboard driver with kbd */ + if (!xf86NameCmp(name, "keyboard")) { + strcpy(name, "kbd"); + } + + if (optlist) + opt = optlist[i]; + else + opt = NULL; + + if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) { + LoaderErrorMsg(NULL, name, errmaj, errmin); + failed = TRUE; + } + xfree(name); + } + return !failed; +} + +/* Pixmap format stuff */ + +_X_EXPORT PixmapFormatPtr +xf86GetPixFormat(ScrnInfoPtr pScrn, int depth) +{ + int i; + static PixmapFormatRec format; /* XXX not reentrant */ + + /* + * When the formats[] list initialisation isn't complete, check the + * depth 24 pixmap config/cmdline options and screen-specified formats. + */ + + if (!formatsDone) { + if (depth == 24) { + Pix24Flags pix24 = Pix24DontCare; + + format.depth = 24; + format.scanlinePad = BITMAP_SCANLINE_PAD; + if (xf86Info.pixmap24 != Pix24DontCare) + pix24 = xf86Info.pixmap24; + else if (pScrn->pixmap24 != Pix24DontCare) + pix24 = pScrn->pixmap24; + if (pix24 == Pix24Use24) + format.bitsPerPixel = 24; + else + format.bitsPerPixel = 32; + return &format; + } + } + + for (i = 0; i < numFormats; i++) + if (formats[i].depth == depth) + break; + if (i != numFormats) + return &formats[i]; + else if (!formatsDone) { + /* Check for screen-specified formats */ + for (i = 0; i < pScrn->numFormats; i++) + if (pScrn->formats[i].depth == depth) + break; + if (i != pScrn->numFormats) + return &pScrn->formats[i]; + } + return NULL; +} + +_X_EXPORT int +xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth) +{ + PixmapFormatPtr format; + + + format = xf86GetPixFormat(pScrn, depth); + if (format) + return format->bitsPerPixel; + else + return 0; +} + diff --git a/xorg-server/hw/xfree86/common/xf86MiscExt.c b/xorg-server/hw/xfree86/common/xf86MiscExt.c new file mode 100644 index 000000000..40c196a3e --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86MiscExt.c @@ -0,0 +1,561 @@ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the Pointer/Keyboard functions needed by the + * XFree86-Misc extension. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +#ifdef XF86MISC +#define _XF86MISC_SERVER_ +#include +#include "xf86miscproc.h" +#endif + +#define XF86_OS_PRIVS +#include "xf86_OSlib.h" + +#ifdef XINPUT +#include +#include +#include "xf86Xinput.h" +#else +#include "inputstr.h" +#endif + +#include "xf86OSmouse.h" + +#ifdef DEBUG +# define DEBUG_P(x) ErrorF(x"\n"); +#else +# define DEBUG_P(x) /**/ +#endif + +#ifdef XF86MISC + +typedef struct { + int type; + int baudrate; + int samplerate; + int resolution; + int buttons; + Bool em3buttons; + int em3timeout; + Bool chordmiddle; + int flags; + char* device; + pointer private; +} mseParamsRec, *mseParamsPtr; + +typedef struct { + int type; + int rate; + int delay; + int serverNumLock; /* obsolete */ + pointer private; +} kbdParamsRec, *kbdParamsPtr; + +/* + Sigh... + + The extension should probably be changed to use protocol + names instead of ID numbers +*/ +static struct mouse_map { + int mtype; + MouseProtocolID proto; +} m_map[] = +{ + { MTYPE_MICROSOFT, PROT_MS }, + { MTYPE_MOUSESYS, PROT_MSC }, + { MTYPE_MMSERIES, PROT_MM }, + { MTYPE_LOGITECH, PROT_LOGI }, + { MTYPE_LOGIMAN, PROT_LOGIMAN }, + { MTYPE_MMHIT, PROT_MMHIT }, + { MTYPE_GLIDEPOINT, PROT_GLIDE }, + { MTYPE_IMSERIAL, PROT_IMSERIAL }, + { MTYPE_THINKING, PROT_THINKING }, + { MTYPE_ACECAD, PROT_ACECAD }, + { MTYPE_PS_2, PROT_PS2 }, + { MTYPE_IMPS2, PROT_IMPS2 }, + { MTYPE_EXPPS2, PROT_EXPPS2 }, + { MTYPE_THINKINGPS2, PROT_THINKPS2 }, + { MTYPE_MMANPLUSPS2, PROT_MMPS2 }, + { MTYPE_GLIDEPOINTPS2, PROT_GLIDEPS2 }, + { MTYPE_NETPS2, PROT_NETPS2 }, + { MTYPE_NETSCROLLPS2, PROT_NETSCPS2 }, + { MTYPE_BUSMOUSE, PROT_BM }, + { MTYPE_AUTOMOUSE, PROT_AUTO }, + { MTYPE_SYSMOUSE, PROT_SYSMOUSE }, + { MTYPE_UNKNOWN, PROT_UNKNOWN } +}; + +static int +MapMseProtoToMisc(MouseProtocolID proto) +{ + int i; + + for (i = 0; m_map[i].proto != PROT_UNKNOWN; i++) + if (proto == m_map[i].proto) + return m_map[i].mtype; + + return MTYPE_UNKNOWN; +} + +static MouseProtocolID +MapMseMiscToProto(int proto) +{ + int i; + + for (i = 0; m_map[i].mtype != MTYPE_UNKNOWN; i++) + if (proto == m_map[i].mtype) + return m_map[i].proto; + + return PROT_UNKNOWN; +} + +_X_EXPORT Bool +MiscExtGetMouseSettings(pointer *mouse, char **devname) +{ + mseParamsPtr mseptr; + + mseptr = MiscExtCreateStruct(MISC_POINTER); + if (!mseptr) + return FALSE; + + { + InputInfoPtr pInfo = mseptr->private; + MouseDevPtr pMse; + + *devname = xf86FindOptionValue(pInfo->options, "Device"); + pMse = pInfo->private; + + mseptr->type = MapMseProtoToMisc(pMse->protocolID); + mseptr->baudrate = pMse->baudRate; + mseptr->samplerate = pMse->sampleRate; + mseptr->resolution = pMse->resolution; + mseptr->buttons = pMse->buttons; + mseptr->em3buttons = pMse->emulate3Buttons; + mseptr->em3timeout = pMse->emulate3Timeout; + mseptr->chordmiddle = pMse->chordMiddle; + mseptr->flags = pMse->mouseFlags; + } + *mouse = mseptr; + return TRUE; +} + +_X_EXPORT int +MiscExtGetMouseValue(pointer mouse, MiscExtMseValType valtype) +{ + mseParamsPtr mse = mouse; + + switch (valtype) { + case MISC_MSE_PROTO: return mse->type; + case MISC_MSE_BAUDRATE: return mse->baudrate; + case MISC_MSE_SAMPLERATE: return mse->samplerate; + case MISC_MSE_RESOLUTION: return mse->resolution; + case MISC_MSE_BUTTONS: return mse->buttons; + case MISC_MSE_EM3BUTTONS: return mse->em3buttons; + case MISC_MSE_EM3TIMEOUT: return mse->em3timeout; + case MISC_MSE_CHORDMIDDLE: return mse->chordmiddle; + case MISC_MSE_FLAGS: return mse->flags; + } + return 0; +} + +_X_EXPORT Bool +MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value) +{ + mseParamsPtr mse = mouse; + + switch (valtype) { + case MISC_MSE_PROTO: + mse->type = value; + return TRUE; + case MISC_MSE_BAUDRATE: + mse->baudrate = value; + return TRUE; + case MISC_MSE_SAMPLERATE: + mse->samplerate = value; + return TRUE; + case MISC_MSE_RESOLUTION: + mse->resolution = value; + return TRUE; + case MISC_MSE_BUTTONS: + mse->buttons = value; + return TRUE; + case MISC_MSE_EM3BUTTONS: + mse->em3buttons = value; + return TRUE; + case MISC_MSE_EM3TIMEOUT: + mse->em3timeout = value; + return TRUE; + case MISC_MSE_CHORDMIDDLE: + mse->chordmiddle = value; + return TRUE; + case MISC_MSE_FLAGS: + mse->flags = value; + return TRUE; + } + return FALSE; +} + +_X_EXPORT Bool +MiscExtSetMouseDevice(pointer mouse, char* device) +{ + mseParamsPtr mse = mouse; + mse->device = device; + + return TRUE; +} + +_X_EXPORT Bool +MiscExtGetKbdSettings(pointer *kbd) +{ + return FALSE; +} + +_X_EXPORT int +MiscExtGetKbdValue(pointer keyboard, MiscExtKbdValType valtype) +{ + return 0; +} + +_X_EXPORT Bool +MiscExtSetKbdValue(pointer keyboard, MiscExtKbdValType valtype, int value) +{ + return FALSE; +} + +static void +MiscExtClientStateCallback(CallbackListPtr *callbacks, + pointer data, pointer args) +{ + NewClientInfoRec *clientinfo = (NewClientInfoRec*)args; + + if (clientinfo->client == xf86Info.grabInfo.override && + clientinfo->client->clientState == ClientStateGone) { + xf86Info.grabInfo.override = NULL; + xf86Info.grabInfo.disabled = 0; + DeleteCallback(&ClientStateCallback, MiscExtClientStateCallback, NULL); + } +} + +#define MiscExtGrabStateSuccess 0 /* No errors */ +#define MiscExtGrabStateLocked 1 /* A client already requested that + * grabs cannot be removed/killed */ +#define MiscExtGrabStateAlready 2 /* Request for enabling/disabling + * grab removeal/kill already done */ +_X_EXPORT int +MiscExtSetGrabKeysState(ClientPtr client, int state) +{ + if (xf86Info.grabInfo.override == NULL || + xf86Info.grabInfo.override == client) { + if (state == 0 && xf86Info.grabInfo.disabled == 0) { + xf86Info.grabInfo.disabled = 1; + AddCallback(&ClientStateCallback, + MiscExtClientStateCallback, NULL); + xf86Info.grabInfo.override = client; + } + else if (state == 1 && xf86Info.grabInfo.disabled == 1) { + xf86Info.grabInfo.disabled = 0; + DeleteCallback(&ClientStateCallback, + MiscExtClientStateCallback, NULL); + xf86Info.grabInfo.override = NULL; + } + else + return MiscExtGrabStateAlready; + + return MiscExtGrabStateSuccess; + } + + return MiscExtGrabStateLocked; +} + +_X_EXPORT pointer +MiscExtCreateStruct(MiscExtStructType mse_or_kbd) +{ + switch (mse_or_kbd) { + case MISC_POINTER: + { + mseParamsPtr mseptr; + InputInfoPtr pInfo = xf86InputDevs; + + while (pInfo) { + if (pInfo->dev == inputInfo.pointer) + break; + pInfo = pInfo->next; + } + if (!pInfo) + return NULL; + + mseptr = xcalloc(sizeof(mseParamsRec),1); + if (mseptr) + mseptr->private = pInfo; + return mseptr; + } + case MISC_KEYBOARD: + return xcalloc(sizeof(kbdParamsRec),1); + } + return 0; +} + +_X_EXPORT void +MiscExtDestroyStruct(pointer structure, MiscExtStructType mse_or_kbd) +{ + switch (mse_or_kbd) { + case MISC_POINTER: + case MISC_KEYBOARD: + xfree(structure); + } +} + +static Bool +MiscExtAuthorizeDevice(InputInfoPtr pInfo, char *device) +{ + Bool authorized = FALSE; + char *elem; + struct stat dev, dev_list; + const char *olddev = xf86FindOptionValue(pInfo->options, "Device"); + + if (stat(device,&dev)) + return FALSE; + + if (!S_ISCHR(dev.st_mode)) + return FALSE; + + if (!stat(olddev,&dev_list)) { + if (dev_list.st_dev == dev.st_dev + && dev_list.st_ino == dev.st_ino) { + authorized = TRUE; + } + } + + if (!authorized) { + char *path; + + if (!xf86InputDeviceList + || (path = strdup(xf86InputDeviceList)) == NULL) + return FALSE; + + elem = strtok(path,","); + + while (elem) { + + if (!stat(elem,&dev_list)) { + if (dev_list.st_dev == dev.st_dev + && dev_list.st_ino == dev.st_ino) { + authorized = TRUE; + break; + + } + } + elem = strtok(NULL,","); + } + xfree(path); + } +#if 0 + ErrorF("AUTHORIZED: %s\n",authorized?"Yes":"No"); +#endif + return (authorized); +} + +_X_EXPORT MiscExtReturn +MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd) +{ + if (mse_or_kbd == MISC_POINTER) { + Bool protoChanged = FALSE; + int oldflags; + Bool reopen = FALSE; + MouseProtocolID newProtocol; + mseParamsPtr mse = structure; + InputInfoPtr pInfo; + MouseDevPtr pMse; + pointer xf86MouseProtocolIDToName + = LoaderSymbol("xf86MouseProtocolIDToName"); + if (!xf86MouseProtocolIDToName) + return MISC_RET_NOMODULE; + if (mse->type < MTYPE_MICROSOFT + || (mse->type > MTYPE_EXPPS2 + && (mse->type != MTYPE_OSMOUSE))) + return MISC_RET_BADMSEPROTO; +#ifdef OSMOUSE_ONLY + if (mse->type != MTYPE_OSMOUSE) + return MISC_RET_BADMSEPROTO; +#else + if (mse->type == MTYPE_OSMOUSE) + return MISC_RET_BADMSEPROTO; +#endif /* OSMOUSE_ONLY */ + + if (mse->em3timeout < 0) + return MISC_RET_BADVAL; + + if (mse->type == MTYPE_LOGIMAN + && !(mse->baudrate == 0 + || mse->baudrate == 1200 + || mse->baudrate == 9600)) + return MISC_RET_BADBAUDRATE; + if (mse->type == MTYPE_LOGIMAN && mse->samplerate) + return MISC_RET_BADCOMBO; + + if (mse->flags & MF_REOPEN) { + reopen = TRUE; + mse->flags &= ~MF_REOPEN; + } + if (mse->type != MTYPE_OSMOUSE + && mse->type != MTYPE_PS_2 + && mse->type != MTYPE_BUSMOUSE + && mse->type != MTYPE_IMPS2 + && mse->type != MTYPE_THINKINGPS2 + && mse->type != MTYPE_MMANPLUSPS2 + && mse->type != MTYPE_GLIDEPOINTPS2 + && mse->type != MTYPE_NETPS2 + && mse->type != MTYPE_NETSCROLLPS2 + && mse->type != MTYPE_SYSMOUSE) + { + if (mse->baudrate % 1200 != 0 + || (mse->baudrate != 0 && mse->baudrate < 1200) + || mse->baudrate > 9600) + return MISC_RET_BADBAUDRATE; + } + if ((mse->flags & (MF_CLEAR_DTR|MF_CLEAR_RTS)) + && (mse->type != MTYPE_MOUSESYS)) + return MISC_RET_BADFLAGS; + + if (mse->type != MTYPE_OSMOUSE + && mse->type != MTYPE_BUSMOUSE) + { + if (mse->samplerate < 0) + return MISC_RET_BADVAL; + } + + if (mse->resolution < 0) + return MISC_RET_BADVAL; + if (mse->chordmiddle) + { + if (mse->em3buttons || !(mse->type == MTYPE_MICROSOFT + || mse->type == MTYPE_LOGIMAN) ) + return MISC_RET_BADCOMBO; + } + + /* XXX - This still needs work */ + + pInfo = mse->private; + pMse = pInfo->private; + oldflags = pMse->mouseFlags; + + newProtocol = MapMseMiscToProto(mse->type); + protoChanged = pMse->protocolID != newProtocol; + if (protoChanged + || pMse->baudRate != mse->baudrate + || pMse->sampleRate != mse->samplerate + || pMse->resolution != mse->resolution + || pMse->mouseFlags != mse->flags) + reopen = TRUE; + + if (mse->device) + reopen = TRUE; + + if (reopen) + (pMse->device->deviceProc)(pMse->device, DEVICE_CLOSE); + + pMse->protocolID = newProtocol; + pMse->baudRate = mse->baudrate; + pMse->sampleRate = mse->samplerate; + pMse->resolution = mse->resolution; + pMse->buttons = mse->buttons; + pMse->emulate3Buttons = mse->em3buttons; + pMse->emulate3Timeout = mse->em3timeout; + pMse->chordMiddle = mse->chordmiddle; + pMse->mouseFlags = mse->flags; + + pMse->protocol = ((const char *(*)(MouseProtocolID)) + xf86MouseProtocolIDToName)(pMse->protocolID); + + if (mse->device) { + if (MiscExtAuthorizeDevice(pInfo, mse->device)) { + xf86ReplaceStrOption(pInfo->options, "Device", mse->device); + } else { + return MISC_RET_BADVAL; + } + } + + if (reopen) { + /* Only if protocol is changed explicitely disable auto detect */ + if (protoChanged) + pMse->autoProbe = FALSE; + (pMse->device->deviceProc)(pMse->device, DEVICE_ON); + } + /* Set pInfo->options too */ + + if ((oldflags & MF_CLEAR_DTR) != (pMse->mouseFlags & MF_CLEAR_DTR)) + xf86ReplaceBoolOption(pInfo->options, "ClearDTR", + pMse->mouseFlags | MF_CLEAR_DTR); + if ((oldflags & MF_CLEAR_RTS) != (pMse->mouseFlags & MF_CLEAR_RTS)) + xf86ReplaceBoolOption(pInfo->options, "ClearRTS", + pMse->mouseFlags | MF_CLEAR_RTS); + } + return MISC_RET_BADVAL; +} + +_X_EXPORT Bool +MiscExtGetFilePaths(const char **configfile, const char **modulepath, + const char **logfile) +{ + *configfile = xf86ConfigFile; + *modulepath = xf86ModulePath; + *logfile = xf86LogFile; + + return TRUE; +} + +_X_EXPORT int +MiscExtPassMessage(int scrnIndex, const char *msgtype, const char *msgval, + char **retstr) +{ + ScrnInfoPtr pScr = xf86Screens[scrnIndex]; + + /* should check this in the protocol, but xf86NumScreens isn't exported */ + if (scrnIndex >= xf86NumScreens) + return BadValue; + + if (*pScr->HandleMessage == NULL) + return BadImplementation; + return (*pScr->HandleMessage)(scrnIndex, msgtype, msgval, retstr); +} + +#endif /* XF86MISC */ + diff --git a/xorg-server/hw/xfree86/common/xf86Mode.c b/xorg-server/hw/xfree86/common/xf86Mode.c new file mode 100644 index 000000000..c1b0a5fc9 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Mode.c @@ -0,0 +1,2022 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * Authors: Dirk Hohndel + * David Dawes + * Marc La France + * ... and others + * + * This file includes helper functions for mode related things. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "servermd.h" +#include "mibank.h" +#include "globals.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "edid.h" + +static void +printModeRejectMessage(int index, DisplayModePtr p, int status) +{ + char *type; + + if (p->type & M_T_BUILTIN) + type = "built-in "; + else if (p->type & M_T_DEFAULT) + type = "default "; + else if (p->type & M_T_DRIVER) + type = "driver "; + else + type = ""; + + xf86DrvMsg(index, X_INFO, "Not using %smode \"%s\" (%s)\n", type, p->name, + xf86ModeStatusToString(status)); +} + +/* + * xf86GetNearestClock -- + * Find closest clock to given frequency (in kHz). This assumes the + * number of clocks is greater than zero. + */ +_X_EXPORT int +xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2, + int DivFactor, int MulFactor, int *divider) +{ + int nearestClock = 0, nearestDiv = 1; + int minimumGap = abs(freq - scrp->clock[0]); + int i, j, k, gap; + + if (allowDiv2) + k = 2; + else + k = 1; + + /* Must set this here in case the best match is scrp->clock[0] */ + if (divider != NULL) + *divider = 0; + + for (i = 0; i < scrp->numClocks; i++) { + for (j = 1; j <= k; j++) { + gap = abs((freq * j) - ((scrp->clock[i] * DivFactor) / MulFactor)); + if ((gap < minimumGap) || + ((gap == minimumGap) && (j < nearestDiv))) { + minimumGap = gap; + nearestClock = i; + nearestDiv = j; + if (divider != NULL) + *divider = (j - 1) * V_CLKDIV2; + } + } + } + return nearestClock; +} + +/* + * xf86ModeStatusToString + * + * Convert a ModeStatus value to a printable message + */ + +_X_EXPORT const char * +xf86ModeStatusToString(ModeStatus status) +{ + switch (status) { + case MODE_OK: + return "Mode OK"; + case MODE_HSYNC: + return "hsync out of range"; + case MODE_VSYNC: + return "vrefresh out of range"; + case MODE_H_ILLEGAL: + return "illegal horizontal timings"; + case MODE_V_ILLEGAL: + return "illegal vertical timings"; + case MODE_BAD_WIDTH: + return "width requires unsupported line pitch"; + case MODE_NOMODE: + return "no mode of this name"; + case MODE_NO_INTERLACE: + return "interlace mode not supported"; + case MODE_NO_DBLESCAN: + return "doublescan mode not supported"; + case MODE_NO_VSCAN: + return "multiscan mode not supported"; + case MODE_MEM: + return "insufficient memory for mode"; + case MODE_VIRTUAL_X: + return "width too large for virtual size"; + case MODE_VIRTUAL_Y: + return "height too large for virtual size"; + case MODE_MEM_VIRT: + return "insufficient memory given virtual size"; + case MODE_NOCLOCK: + return "no clock available for mode"; + case MODE_CLOCK_HIGH: + return "mode clock too high"; + case MODE_CLOCK_LOW: + return "mode clock too low"; + case MODE_CLOCK_RANGE: + return "bad mode clock/interlace/doublescan"; + case MODE_BAD_HVALUE: + return "horizontal timing out of range"; + case MODE_BAD_VVALUE: + return "vertical timing out of range"; + case MODE_BAD_VSCAN: + return "VScan value out of range"; + case MODE_HSYNC_NARROW: + return "horizontal sync too narrow"; + case MODE_HSYNC_WIDE: + return "horizontal sync too wide"; + case MODE_HBLANK_NARROW: + return "horizontal blanking too narrow"; + case MODE_HBLANK_WIDE: + return "horizontal blanking too wide"; + case MODE_VSYNC_NARROW: + return "vertical sync too narrow"; + case MODE_VSYNC_WIDE: + return "vertical sync too wide"; + case MODE_VBLANK_NARROW: + return "vertical blanking too narrow"; + case MODE_VBLANK_WIDE: + return "vertical blanking too wide"; + case MODE_PANEL: + return "exceeds panel dimensions"; + case MODE_INTERLACE_WIDTH: + return "width too large for interlaced mode"; + case MODE_ONE_WIDTH: + return "all modes must have the same width"; + case MODE_ONE_HEIGHT: + return "all modes must have the same height"; + case MODE_ONE_SIZE: + return "all modes must have the same resolution"; + case MODE_NO_REDUCED: + return "monitor doesn't support reduced blanking"; + case MODE_BANDWIDTH: + return "mode requires too much memory bandwidth"; + case MODE_BAD: + return "unknown reason"; + case MODE_ERROR: + return "internal error"; + default: + return "unknown"; + } +} + +/* + * xf86ShowClockRanges() -- Print the clock ranges allowed + * and the clock values scaled by ClockMulFactor and ClockDivFactor + */ +_X_EXPORT void +xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges) +{ + ClockRangePtr cp; + int MulFactor = 1; + int DivFactor = 1; + int i, j; + int scaledClock; + + for (cp = clockRanges; cp != NULL; cp = cp->next) { + DivFactor = max(1, cp->ClockDivFactor); + MulFactor = max(1, cp->ClockMulFactor); + if (scrp->progClock) { + if (cp->minClock) { + if (cp->maxClock) { + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "Clock range: %6.2f to %6.2f MHz\n", + (double)cp->minClock / 1000.0, + (double)cp->maxClock / 1000.0); + } else { + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "Minimum clock: %6.2f MHz\n", + (double)cp->minClock / 1000.0); + } + } else { + if (cp->maxClock) { + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "Maximum clock: %6.2f MHz\n", + (double)cp->maxClock / 1000.0); + } + } + } else if (DivFactor > 1 || MulFactor > 1) { + j = 0; + for (i = 0; i < scrp->numClocks; i++) { + scaledClock = (scrp->clock[i] * DivFactor) / MulFactor; + if (scaledClock >= cp->minClock && scaledClock <= cp->maxClock) { + if ((j % 8) == 0) { + if (j > 0) + xf86ErrorF("\n"); + xf86DrvMsg(scrp->scrnIndex, X_INFO, "scaled clocks:"); + } + xf86ErrorF(" %6.2f", (double)scaledClock / 1000.0); + j++; + } + } + xf86ErrorF("\n"); + } + } +} + + +/* + * xf86FindClockRangeForMode() [... like the name says ...] + */ +static ClockRangePtr +xf86FindClockRangeForMode(ClockRangePtr clockRanges, DisplayModePtr p) +{ + ClockRangePtr cp; + + for (cp = clockRanges; ; cp = cp->next) + if (!cp || + ((p->Clock >= cp->minClock) && + (p->Clock <= cp->maxClock) && + (cp->interlaceAllowed || !(p->Flags & V_INTERLACE)) && + (cp->doubleScanAllowed || + ((p->VScan <= 1) && !(p->Flags & V_DBLSCAN))))) + return cp; +} + + +/* + * xf86HandleBuiltinMode() - handles built-in modes + */ +static ModeStatus +xf86HandleBuiltinMode(ScrnInfoPtr scrp, + DisplayModePtr p, + DisplayModePtr modep, + ClockRangePtr clockRanges, + Bool allowDiv2) +{ + ClockRangePtr cp; + int extraFlags = 0; + int MulFactor = 1; + int DivFactor = 1; + int clockIndex; + + /* Reject previously rejected modes */ + if (p->status != MODE_OK) + return p->status; + + /* Reject previously considered modes */ + if (p->prev) + return MODE_NOMODE; + + if ((p->type & M_T_CLOCK_C) == M_T_CLOCK_C) { + /* Check clock is in range */ + cp = xf86FindClockRangeForMode(clockRanges, p); + if (cp == NULL){ + modep->type = p->type; + p->status = MODE_CLOCK_RANGE; + return MODE_CLOCK_RANGE; + } + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + if (!scrp->progClock) { + clockIndex = xf86GetNearestClock(scrp, p->Clock, allowDiv2, + cp->ClockDivFactor, + cp->ClockMulFactor, &extraFlags); + modep->Clock = (scrp->clock[clockIndex] * DivFactor) + / MulFactor; + modep->ClockIndex = clockIndex; + modep->SynthClock = scrp->clock[clockIndex]; + if (extraFlags & V_CLKDIV2) { + modep->Clock /= 2; + modep->SynthClock /= 2; + } + } else { + modep->Clock = p->Clock; + modep->ClockIndex = -1; + modep->SynthClock = (modep->Clock * MulFactor) + / DivFactor; + } + modep->PrivFlags = cp->PrivFlags; + } else { + if(!scrp->progClock) { + modep->Clock = p->Clock; + modep->ClockIndex = p->ClockIndex; + modep->SynthClock = p->SynthClock; + } else { + modep->Clock = p->Clock; + modep->ClockIndex = -1; + modep->SynthClock = p->SynthClock; + } + modep->PrivFlags = p->PrivFlags; + } + modep->type = p->type; + modep->HDisplay = p->HDisplay; + modep->HSyncStart = p->HSyncStart; + modep->HSyncEnd = p->HSyncEnd; + modep->HTotal = p->HTotal; + modep->HSkew = p->HSkew; + modep->VDisplay = p->VDisplay; + modep->VSyncStart = p->VSyncStart; + modep->VSyncEnd = p->VSyncEnd; + modep->VTotal = p->VTotal; + modep->VScan = p->VScan; + modep->Flags = p->Flags | extraFlags; + modep->CrtcHDisplay = p->CrtcHDisplay; + modep->CrtcHBlankStart = p->CrtcHBlankStart; + modep->CrtcHSyncStart = p->CrtcHSyncStart; + modep->CrtcHSyncEnd = p->CrtcHSyncEnd; + modep->CrtcHBlankEnd = p->CrtcHBlankEnd; + modep->CrtcHTotal = p->CrtcHTotal; + modep->CrtcHSkew = p->CrtcHSkew; + modep->CrtcVDisplay = p->CrtcVDisplay; + modep->CrtcVBlankStart = p->CrtcVBlankStart; + modep->CrtcVSyncStart = p->CrtcVSyncStart; + modep->CrtcVSyncEnd = p->CrtcVSyncEnd; + modep->CrtcVBlankEnd = p->CrtcVBlankEnd; + modep->CrtcVTotal = p->CrtcVTotal; + modep->CrtcHAdjusted = p->CrtcHAdjusted; + modep->CrtcVAdjusted = p->CrtcVAdjusted; + modep->HSync = p->HSync; + modep->VRefresh = p->VRefresh; + modep->Private = p->Private; + modep->PrivSize = p->PrivSize; + + p->prev = modep; + + return MODE_OK; +} + +/* + * xf86LookupMode + * + * This function returns a mode from the given list which matches the + * given name. When multiple modes with the same name are available, + * the method of picking the matching mode is determined by the + * strategy selected. + * + * This function takes the following parameters: + * scrp ScrnInfoPtr + * modep pointer to the returned mode, which must have the name + * field filled in. + * clockRanges a list of clock ranges. This is optional when all the + * modes are built-in modes. + * strategy how to decide which mode to use from multiple modes with + * the same name + * + * In addition, the following fields from the ScrnInfoRec are used: + * modePool the list of monitor modes compatible with the driver + * clocks a list of discrete clocks + * numClocks number of discrete clocks + * progClock clock is programmable + * + * If a mode was found, its values are filled in to the area pointed to + * by modep, If a mode was not found the return value indicates the + * reason. + */ + +_X_EXPORT ModeStatus +xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, + ClockRangePtr clockRanges, LookupModeFlags strategy) +{ + DisplayModePtr p, bestMode = NULL; + ClockRangePtr cp; + int i, k, gap, minimumGap = CLOCK_TOLERANCE + 1; + double refresh, bestRefresh = 0.0; + Bool found = FALSE; + int extraFlags = 0; + int clockIndex = -1; + int MulFactor = 1; + int DivFactor = 1; + int ModePrivFlags = 0; + ModeStatus status = MODE_NOMODE; + Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0; + int n; + const int types[] = { + M_T_BUILTIN | M_T_PREFERRED, + M_T_BUILTIN, + M_T_USERDEF | M_T_PREFERRED, + M_T_USERDEF, + M_T_DRIVER | M_T_PREFERRED, + M_T_DRIVER, + 0 + }; + const int ntypes = sizeof(types) / sizeof(int); + + strategy &= ~(LOOKUP_CLKDIV2 | LOOKUP_OPTIONAL_TOLERANCES); + + /* Some sanity checking */ + if (scrp == NULL || scrp->modePool == NULL || + (!scrp->progClock && scrp->numClocks == 0)) { + ErrorF("xf86LookupMode: called with invalid scrnInfoRec\n"); + return MODE_ERROR; + } + if (modep == NULL || modep->name == NULL) { + ErrorF("xf86LookupMode: called with invalid modep\n"); + return MODE_ERROR; + } + for (cp = clockRanges; cp != NULL; cp = cp->next) { + /* DivFactor and MulFactor must be > 0 */ + cp->ClockDivFactor = max(1, cp->ClockDivFactor); + cp->ClockMulFactor = max(1, cp->ClockMulFactor); + } + + /* Scan the mode pool for matching names */ + for (n = 0; n < ntypes; n++) { + int type = types[n]; + for (p = scrp->modePool; p != NULL; p = p->next) { + + /* scan through the modes in the sort order above */ + if ((p->type & type) != type) + continue; + + if (strcmp(p->name, modep->name) == 0) { + + /* Skip over previously rejected modes */ + if (p->status != MODE_OK) { + if (!found) + status = p->status; + continue; + } + + /* Skip over previously considered modes */ + if (p->prev) + continue; + + if (p->type & M_T_BUILTIN) { + return xf86HandleBuiltinMode(scrp, p,modep, clockRanges, + allowDiv2); + } + + /* Check clock is in range */ + cp = xf86FindClockRangeForMode(clockRanges, p); + if (cp == NULL) { + /* + * XXX Could do more here to provide a more detailed + * reason for not finding a mode. + */ + p->status = MODE_CLOCK_RANGE; + if (!found) + status = MODE_CLOCK_RANGE; + continue; + } + + /* + * If programmable clock and strategy is not + * LOOKUP_BEST_REFRESH, the required mode has been found, + * otherwise record the refresh and continue looking. + */ + if (scrp->progClock) { + found = TRUE; + if (strategy != LOOKUP_BEST_REFRESH) { + bestMode = p; + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + ModePrivFlags = cp->PrivFlags; + break; + } + refresh = xf86ModeVRefresh(p); + if (p->Flags & V_INTERLACE) + refresh /= INTERLACE_REFRESH_WEIGHT; + if (refresh > bestRefresh) { + bestMode = p; + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + ModePrivFlags = cp->PrivFlags; + bestRefresh = refresh; + } + continue; + } + + /* + * Clock is in range, so if it is not a programmable clock, find + * a matching clock. + */ + + i = xf86GetNearestClock(scrp, p->Clock, allowDiv2, + cp->ClockDivFactor, cp->ClockMulFactor, &k); + /* + * If the clock is too far from the requested clock, this + * mode is no good. + */ + if (k & V_CLKDIV2) + gap = abs((p->Clock * 2) - + ((scrp->clock[i] * cp->ClockDivFactor) / + cp->ClockMulFactor)); + else + gap = abs(p->Clock - + ((scrp->clock[i] * cp->ClockDivFactor) / + cp->ClockMulFactor)); + if (gap > minimumGap) { + p->status = MODE_NOCLOCK; + if (!found) + status = MODE_NOCLOCK; + continue; + } + found = TRUE; + + if (strategy == LOOKUP_BEST_REFRESH) { + refresh = xf86ModeVRefresh(p); + if (p->Flags & V_INTERLACE) + refresh /= INTERLACE_REFRESH_WEIGHT; + if (refresh > bestRefresh) { + bestMode = p; + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + ModePrivFlags = cp->PrivFlags; + extraFlags = k; + clockIndex = i; + bestRefresh = refresh; + } + continue; + } + if (strategy == LOOKUP_CLOSEST_CLOCK) { + if (gap < minimumGap) { + bestMode = p; + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + ModePrivFlags = cp->PrivFlags; + extraFlags = k; + clockIndex = i; + minimumGap = gap; + } + continue; + } + /* + * If strategy is neither LOOKUP_BEST_REFRESH or + * LOOKUP_CLOSEST_CLOCK the required mode has been found. + */ + bestMode = p; + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + ModePrivFlags = cp->PrivFlags; + extraFlags = k; + clockIndex = i; + break; + } + } + if (found) break; + } + if (!found || bestMode == NULL) + return status; + + /* Fill in the mode parameters */ + if (scrp->progClock) { + modep->Clock = bestMode->Clock; + modep->ClockIndex = -1; + modep->SynthClock = (modep->Clock * MulFactor) / DivFactor; + } else { + modep->Clock = (scrp->clock[clockIndex] * DivFactor) / + MulFactor; + modep->ClockIndex = clockIndex; + modep->SynthClock = scrp->clock[clockIndex]; + if (extraFlags & V_CLKDIV2) { + modep->Clock /= 2; + modep->SynthClock /= 2; + } + } + modep->type = bestMode->type; + modep->PrivFlags = ModePrivFlags; + modep->HDisplay = bestMode->HDisplay; + modep->HSyncStart = bestMode->HSyncStart; + modep->HSyncEnd = bestMode->HSyncEnd; + modep->HTotal = bestMode->HTotal; + modep->HSkew = bestMode->HSkew; + modep->VDisplay = bestMode->VDisplay; + modep->VSyncStart = bestMode->VSyncStart; + modep->VSyncEnd = bestMode->VSyncEnd; + modep->VTotal = bestMode->VTotal; + modep->VScan = bestMode->VScan; + modep->Flags = bestMode->Flags | extraFlags; + modep->CrtcHDisplay = bestMode->CrtcHDisplay; + modep->CrtcHBlankStart = bestMode->CrtcHBlankStart; + modep->CrtcHSyncStart = bestMode->CrtcHSyncStart; + modep->CrtcHSyncEnd = bestMode->CrtcHSyncEnd; + modep->CrtcHBlankEnd = bestMode->CrtcHBlankEnd; + modep->CrtcHTotal = bestMode->CrtcHTotal; + modep->CrtcHSkew = bestMode->CrtcHSkew; + modep->CrtcVDisplay = bestMode->CrtcVDisplay; + modep->CrtcVBlankStart = bestMode->CrtcVBlankStart; + modep->CrtcVSyncStart = bestMode->CrtcVSyncStart; + modep->CrtcVSyncEnd = bestMode->CrtcVSyncEnd; + modep->CrtcVBlankEnd = bestMode->CrtcVBlankEnd; + modep->CrtcVTotal = bestMode->CrtcVTotal; + modep->CrtcHAdjusted = bestMode->CrtcHAdjusted; + modep->CrtcVAdjusted = bestMode->CrtcVAdjusted; + modep->HSync = bestMode->HSync; + modep->VRefresh = bestMode->VRefresh; + modep->Private = bestMode->Private; + modep->PrivSize = bestMode->PrivSize; + + bestMode->prev = modep; + + return MODE_OK; +} + +/* + * xf86CheckModeForMonitor + * + * This function takes a mode and monitor description, and determines + * if the mode is valid for the monitor. + */ +_X_EXPORT ModeStatus +xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor) +{ + int i; + + /* Sanity checks */ + if (mode == NULL || monitor == NULL) { + ErrorF("xf86CheckModeForMonitor: called with invalid parameters\n"); + return MODE_ERROR; + } + +#ifdef DEBUG + ErrorF("xf86CheckModeForMonitor(%p %s, %p %s)\n", + mode, mode->name, monitor, monitor->id); +#endif + + /* Some basic mode validity checks */ + if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart || + mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal) + return MODE_H_ILLEGAL; + + if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart || + mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal) + return MODE_V_ILLEGAL; + + if (monitor->nHsync > 0) { + /* Check hsync against the allowed ranges */ + float hsync = xf86ModeHSync(mode); + for (i = 0; i < monitor->nHsync; i++) + if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) && + (hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE))) + break; + + /* Now see whether we ran out of sync ranges without finding a match */ + if (i == monitor->nHsync) + return MODE_HSYNC; + } + + if (monitor->nVrefresh > 0) { + /* Check vrefresh against the allowed ranges */ + float vrefrsh = xf86ModeVRefresh(mode); + for (i = 0; i < monitor->nVrefresh; i++) + if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) && + (vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE))) + break; + + /* Now see whether we ran out of refresh ranges without finding a match */ + if (i == monitor->nVrefresh) + return MODE_VSYNC; + } + + /* Force interlaced modes to have an odd VTotal */ + if (mode->Flags & V_INTERLACE) + mode->CrtcVTotal = mode->VTotal |= 1; + + /* + * This code stops cvt -r modes, and only cvt -r modes, from hitting 15y+ + * old CRTs which might, when there is a lot of solar flare activity and + * when the celestial bodies are unfavourably aligned, implode trying to + * sync to it. It's called "Protecting the user from doing anything stupid". + * -- libv + */ + + /* Is the horizontal blanking a bit lowish? */ + if (((mode->HDisplay * 5 / 4) & ~0x07) > mode->HTotal) { + /* is this a cvt -r mode, and only a cvt -r mode? */ + if (((mode->HTotal - mode->HDisplay) == 160) && + ((mode->HSyncEnd - mode->HDisplay) == 80) && + ((mode->HSyncEnd - mode->HSyncStart) == 32) && + ((mode->VSyncStart - mode->VDisplay) == 3)) { + if (!monitor->reducedblanking && !(mode->type & M_T_DRIVER)) + return MODE_NO_REDUCED; + } + } + + if ((monitor->maxPixClock) && (mode->Clock > monitor->maxPixClock)) + return MODE_CLOCK_HIGH; + + return MODE_OK; +} + +/* + * xf86CheckModeSize + * + * An internal routine to check if a mode fits in video memory. This tries to + * avoid overflows that would otherwise occur when video memory size is greater + * than 256MB. + */ +static Bool +xf86CheckModeSize(ScrnInfoPtr scrp, int w, int x, int y) +{ + int bpp = scrp->fbFormat.bitsPerPixel, + pad = scrp->fbFormat.scanlinePad; + int lineWidth, lastWidth; + + if (scrp->depth == 4) + pad *= 4; /* 4 planes */ + + /* Sanity check */ + if ((w < 0) || (x < 0) || (y <= 0)) + return FALSE; + + lineWidth = (((w * bpp) + pad - 1) / pad) * pad; + lastWidth = x * bpp; + + /* + * At this point, we need to compare + * + * (lineWidth * (y - 1)) + lastWidth + * + * against + * + * scrp->videoRam * (1024 * 8) + * + * These are bit quantities. To avoid overflows, do the comparison in + * terms of BITMAP_SCANLINE_PAD units. This assumes BITMAP_SCANLINE_PAD + * is a power of 2. We currently use 32, which limits us to a video + * memory size of 8GB. + */ + + lineWidth = (lineWidth + (BITMAP_SCANLINE_PAD - 1)) / BITMAP_SCANLINE_PAD; + lastWidth = (lastWidth + (BITMAP_SCANLINE_PAD - 1)) / BITMAP_SCANLINE_PAD; + + if ((lineWidth * (y - 1) + lastWidth) > + (scrp->videoRam * ((1024 * 8) / BITMAP_SCANLINE_PAD))) + return FALSE; + + return TRUE; +} + +/* + * xf86InitialCheckModeForDriver + * + * This function checks if a mode satisfies a driver's initial requirements: + * - mode size fits within the available pixel area (memory) + * - width lies within the range of supported line pitches + * - mode size fits within virtual size (if fixed) + * - horizontal timings are in range + * + * This function takes the following parameters: + * scrp ScrnInfoPtr + * mode mode to check + * maxPitch (optional) maximum line pitch + * virtualX (optional) virtual width requested + * virtualY (optional) virtual height requested + * + * In addition, the following fields from the ScrnInfoRec are used: + * monitor pointer to structure for monitor section + * fbFormat pixel format for the framebuffer + * videoRam video memory size (in kB) + * maxHValue maximum horizontal timing value + * maxVValue maximum vertical timing value + */ + +_X_EXPORT ModeStatus +xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, + ClockRangePtr clockRanges, + LookupModeFlags strategy, + int maxPitch, int virtualX, int virtualY) +{ + ClockRangePtr cp; + ModeStatus status; + Bool allowDiv2 = (strategy & LOOKUP_CLKDIV2) != 0; + int i, needDiv2; + + /* Sanity checks */ + if (!scrp || !mode || !clockRanges) { + ErrorF("xf86InitialCheckModeForDriver: " + "called with invalid parameters\n"); + return MODE_ERROR; + } + +#ifdef DEBUG + ErrorF("xf86InitialCheckModeForDriver(%p, %p %s, %p, 0x%x, %d, %d, %d)\n", + scrp, mode, mode->name , clockRanges, strategy, maxPitch, virtualX, virtualY); +#endif + + /* Some basic mode validity checks */ + if (0 >= mode->HDisplay || mode->HDisplay > mode->HSyncStart || + mode->HSyncStart >= mode->HSyncEnd || mode->HSyncEnd >= mode->HTotal) + return MODE_H_ILLEGAL; + + if (0 >= mode->VDisplay || mode->VDisplay > mode->VSyncStart || + mode->VSyncStart >= mode->VSyncEnd || mode->VSyncEnd >= mode->VTotal) + return MODE_V_ILLEGAL; + + if (!xf86CheckModeSize(scrp, mode->HDisplay, mode->HDisplay, + mode->VDisplay)) + return MODE_MEM; + + if (maxPitch > 0 && mode->HDisplay > maxPitch) + return MODE_BAD_WIDTH; + + if (virtualX > 0 && mode->HDisplay > virtualX) + return MODE_VIRTUAL_X; + + if (virtualY > 0 && mode->VDisplay > virtualY) + return MODE_VIRTUAL_Y; + + if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue) + return MODE_BAD_HVALUE; + + if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue) + return MODE_BAD_VVALUE; + + /* + * The use of the DisplayModeRec's Crtc* and SynthClock elements below is + * provisional, in that they are later reused by the driver at mode-set + * time. Here, they are temporarily enlisted to contain the mode timings + * as seen by the CRT or panel (rather than the CRTC). The driver's + * ValidMode() is allowed to modify these so it can deal with such things + * as mode stretching and/or centering. The driver should >NOT< modify the + * user-supplied values as these are reported back when mode validation is + * said and done. + */ + /* + * NOTE: We (ab)use the mode->Crtc* values here to store timing + * information for the calculation of Hsync and Vrefresh. Before + * these values are calculated the driver is given the opportunity + * to either set these HSync and VRefresh itself or modify the timing + * values. + * The difference to the final calculation is small but imortand: + * here we pass the flag INTERLACE_HALVE_V regardless if the driver + * sets it or not. This way our calculation of VRefresh has the same + * effect as if we do if (flags & V_INTERLACE) refresh *= 2.0 + * This dual use of the mode->Crtc* values will certainly create + * confusion and is bad software design. However since it's part of + * the driver API it's hard to change. + */ + + if (scrp->ValidMode) { + + xf86SetModeCrtc(mode, INTERLACE_HALVE_V); + + cp = xf86FindClockRangeForMode(clockRanges, mode); + if (!cp) + return MODE_CLOCK_RANGE; + + if (cp->ClockMulFactor < 1) + cp->ClockMulFactor = 1; + if (cp->ClockDivFactor < 1) + cp->ClockDivFactor = 1; + + /* + * XXX The effect of clock dividers and multipliers on the monitor's + * pixel clock needs to be verified. + */ + if (scrp->progClock) { + mode->SynthClock = mode->Clock; + } else { + i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2, + cp->ClockDivFactor, cp->ClockMulFactor, + &needDiv2); + mode->SynthClock = (scrp->clock[i] * cp->ClockDivFactor) / + cp->ClockMulFactor; + if (needDiv2 & V_CLKDIV2) + mode->SynthClock /= 2; + } + + status = (*scrp->ValidMode)(scrp->scrnIndex, mode, FALSE, + MODECHECK_INITIAL); + if (status != MODE_OK) + return status; + + if (mode->HSync <= 0.0) + mode->HSync = (float)mode->SynthClock / (float)mode->CrtcHTotal; + if (mode->VRefresh <= 0.0) + mode->VRefresh = (mode->SynthClock * 1000.0) + / (mode->CrtcHTotal * mode->CrtcVTotal); + } + + mode->HSync = xf86ModeHSync(mode); + mode->VRefresh = xf86ModeVRefresh(mode); + + /* Assume it is OK */ + return MODE_OK; +} + +/* + * xf86CheckModeForDriver + * + * This function is for checking modes while the server is running (for + * use mainly by the VidMode extension). + * + * This function checks if a mode satisfies a driver's requirements: + * - width lies within the line pitch + * - mode size fits within virtual size + * - horizontal/vertical timings are in range + * + * This function takes the following parameters: + * scrp ScrnInfoPtr + * mode mode to check + * flags not (currently) used + * + * In addition, the following fields from the ScrnInfoRec are used: + * maxHValue maximum horizontal timing value + * maxVValue maximum vertical timing value + * virtualX virtual width + * virtualY virtual height + * clockRanges allowable clock ranges + */ + +_X_EXPORT ModeStatus +xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, int flags) +{ + ClockRangesPtr cp; + int i, k, gap, minimumGap = CLOCK_TOLERANCE + 1; + int extraFlags = 0; + int clockIndex = -1; + int MulFactor = 1; + int DivFactor = 1; + int ModePrivFlags = 0; + Bool allowDiv2; + ModeStatus status = MODE_NOMODE; + + /* Some sanity checking */ + if (scrp == NULL || (!scrp->progClock && scrp->numClocks == 0)) { + ErrorF("xf86CheckModeForDriver: called with invalid scrnInfoRec\n"); + return MODE_ERROR; + } + if (mode == NULL) { + ErrorF("xf86CheckModeForDriver: called with invalid modep\n"); + return MODE_ERROR; + } + + /* Check the mode size */ + if (mode->HDisplay > scrp->virtualX) + return MODE_VIRTUAL_X; + + if (mode->VDisplay > scrp->virtualY) + return MODE_VIRTUAL_Y; + + if (scrp->maxHValue > 0 && mode->HTotal > scrp->maxHValue) + return MODE_BAD_HVALUE; + + if (scrp->maxVValue > 0 && mode->VTotal > scrp->maxVValue) + return MODE_BAD_VVALUE; + + for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) { + /* DivFactor and MulFactor must be > 0 */ + cp->ClockDivFactor = max(1, cp->ClockDivFactor); + cp->ClockMulFactor = max(1, cp->ClockMulFactor); + } + + if (scrp->progClock) { + /* Check clock is in range */ + for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) { + if ((cp->minClock <= mode->Clock) && + (cp->maxClock >= mode->Clock) && + (cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) && + (cp->doubleScanAllowed || + ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1)))) + break; + } + if (cp == NULL) { + return MODE_CLOCK_RANGE; + } + /* + * If programmable clock the required mode has been found + */ + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + ModePrivFlags = cp->PrivFlags; + } else { + status = MODE_CLOCK_RANGE; + /* Check clock is in range */ + for (cp = scrp->clockRanges; cp != NULL; cp = cp->next) { + if ((cp->minClock <= mode->Clock) && + (cp->maxClock >= mode->Clock) && + (cp->interlaceAllowed || !(mode->Flags & V_INTERLACE)) && + (cp->doubleScanAllowed || + ((!(mode->Flags & V_DBLSCAN)) && (mode->VScan <= 1)))) { + + /* + * Clock is in range, so if it is not a programmable clock, + * find a matching clock. + */ + + allowDiv2 = (cp->strategy & LOOKUP_CLKDIV2) != 0; + i = xf86GetNearestClock(scrp, mode->Clock, allowDiv2, + cp->ClockDivFactor, cp->ClockMulFactor, &k); + /* + * If the clock is too far from the requested clock, this + * mode is no good. + */ + if (k & V_CLKDIV2) + gap = abs((mode->Clock * 2) - + ((scrp->clock[i] * cp->ClockDivFactor) / + cp->ClockMulFactor)); + else + gap = abs(mode->Clock - + ((scrp->clock[i] * cp->ClockDivFactor) / + cp->ClockMulFactor)); + if (gap > minimumGap) { + status = MODE_NOCLOCK; + continue; + } + + DivFactor = cp->ClockDivFactor; + MulFactor = cp->ClockMulFactor; + ModePrivFlags = cp->PrivFlags; + extraFlags = k; + clockIndex = i; + break; + } + } + if (cp == NULL) + return status; + } + + /* Fill in the mode parameters */ + if (scrp->progClock) { + mode->ClockIndex = -1; + mode->SynthClock = (mode->Clock * MulFactor) / DivFactor; + } else { + mode->Clock = (scrp->clock[clockIndex] * DivFactor) / MulFactor; + mode->ClockIndex = clockIndex; + mode->SynthClock = scrp->clock[clockIndex]; + if (extraFlags & V_CLKDIV2) { + mode->Clock /= 2; + mode->SynthClock /= 2; + } + } + mode->PrivFlags = ModePrivFlags; + + return MODE_OK; +} + +static int +inferVirtualSize(ScrnInfoPtr scrp, DisplayModePtr modes, int *vx, int *vy) +{ + float aspect = 0.0; + MonPtr mon = scrp->monitor; + xf86MonPtr DDC; + int x = 0, y = 0; + DisplayModePtr mode; + + if (!mon) return 0; + DDC = mon->DDC; + + if (DDC && DDC->ver.revision >= 4) { + /* For 1.4, we might actually get native pixel format. How novel. */ + if (PREFERRED_TIMING_MODE(DDC->features.msc)) { + for (mode = modes; mode; mode = mode->next) { + if (mode->type & (M_T_DRIVER | M_T_PREFERRED)) { + x = mode->HDisplay; + y = mode->VDisplay; + goto found; + } + } + } + /* + * Even if we don't, we might get aspect ratio from extra CVT info + * or from the monitor size fields. TODO. + */ + } + + /* + * Technically this triggers if either is zero. That wasn't legal + * before EDID 1.4, but right now we'll get that wrong. TODO. + */ + if (!aspect) { + if (!mon->widthmm || !mon->heightmm) + aspect = 4.0/3.0; + else + aspect = (float)mon->widthmm / (float)mon->heightmm; + } + + /* find the largest M_T_DRIVER mode with that aspect ratio */ + for (mode = modes; mode; mode = mode->next) { + float mode_aspect, metaspect; + if (!(mode->type & (M_T_DRIVER|M_T_USERDEF))) + continue; + mode_aspect = (float)mode->HDisplay / (float)mode->VDisplay; + metaspect = aspect / mode_aspect; + /* 5% slop or so, since we only get size in centimeters */ + if (fabs(1.0 - metaspect) < 0.05) { + if ((mode->HDisplay > x) && (mode->VDisplay > y)) { + x = mode->HDisplay; + y = mode->VDisplay; + } + } + } + + if (!x || !y) { + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Unable to estimate virtual size\n"); + return 0; + } + +found: + *vx = x; + *vy = y; + + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "Estimated virtual size for aspect ratio %.4f is %dx%d\n", + aspect, *vx, *vy); + + return 1; +} + +/* + * xf86ValidateModes + * + * This function takes a set of mode names, modes and limiting conditions, + * and selects a set of modes and parameters based on those conditions. + * + * This function takes the following parameters: + * scrp ScrnInfoPtr + * availModes the list of modes available for the monitor + * modeNames (optional) list of mode names that the screen is requesting + * clockRanges a list of clock ranges + * linePitches (optional) a list of line pitches + * minPitch (optional) minimum line pitch (in pixels) + * maxPitch (optional) maximum line pitch (in pixels) + * pitchInc (mandatory) pitch increment (in bits) + * minHeight (optional) minimum virtual height (in pixels) + * maxHeight (optional) maximum virtual height (in pixels) + * virtualX (optional) virtual width requested (in pixels) + * virtualY (optional) virtual height requested (in pixels) + * apertureSize size of video aperture (in bytes) + * strategy how to decide which mode to use from multiple modes with + * the same name + * + * In addition, the following fields from the ScrnInfoRec are used: + * clocks a list of discrete clocks + * numClocks number of discrete clocks + * progClock clock is programmable + * monitor pointer to structure for monitor section + * fbFormat format of the framebuffer + * videoRam video memory size + * maxHValue maximum horizontal timing value + * maxVValue maximum vertical timing value + * xInc horizontal timing increment (defaults to 8 pixels) + * + * The function fills in the following ScrnInfoRec fields: + * modePool A subset of the modes available to the monitor which + * are compatible with the driver. + * modes one mode entry for each of the requested modes, with the + * status field filled in to indicate if the mode has been + * accepted or not. + * virtualX the resulting virtual width + * virtualY the resulting virtual height + * displayWidth the resulting line pitch + * + * The function's return value is the number of matching modes found, or -1 + * if an unrecoverable error was encountered. + */ + +_X_EXPORT int +xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, + char **modeNames, ClockRangePtr clockRanges, + int *linePitches, int minPitch, int maxPitch, int pitchInc, + int minHeight, int maxHeight, int virtualX, int virtualY, + int apertureSize, LookupModeFlags strategy) +{ + DisplayModePtr p, q, r, new, last, *endp; + int i, numModes = 0; + ModeStatus status; + int linePitch = -1, virtX = 0, virtY = 0; + int newLinePitch, newVirtX, newVirtY; + int modeSize; /* in pixels */ + Bool validateAllDefaultModes = FALSE; + Bool userModes = FALSE; + int saveType; + PixmapFormatRec *BankFormat; + ClockRangePtr cp; + ClockRangesPtr storeClockRanges; + double targetRefresh = 0.0; + int numTimings = 0; + range hsync[MAX_HSYNC]; + range vrefresh[MAX_VREFRESH]; + Bool inferred_virtual = FALSE; + +#ifdef DEBUG + ErrorF("xf86ValidateModes(%p, %p, %p, %p,\n\t\t %p, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x)\n", + scrp, availModes, modeNames, clockRanges, + linePitches, minPitch, maxPitch, pitchInc, + minHeight, maxHeight, virtualX, virtualY, + apertureSize, strategy + ); +#endif + + /* Some sanity checking */ + if (scrp == NULL || scrp->name == NULL || !scrp->monitor || + (!scrp->progClock && scrp->numClocks == 0)) { + ErrorF("xf86ValidateModes: called with invalid scrnInfoRec\n"); + return -1; + } + if (linePitches != NULL && linePitches[0] <= 0) { + ErrorF("xf86ValidateModes: called with invalid linePitches\n"); + return -1; + } + if (pitchInc <= 0) { + ErrorF("xf86ValidateModes: called with invalid pitchInc\n"); + return -1; + } + if ((virtualX > 0) != (virtualY > 0)) { + ErrorF("xf86ValidateModes: called with invalid virtual resolution\n"); + return -1; + } + + /* + * If requested by the driver, allow missing hsync and/or vrefresh ranges + * in the monitor section. + */ + if (strategy & LOOKUP_OPTIONAL_TOLERANCES) { + strategy &= ~LOOKUP_OPTIONAL_TOLERANCES; + } else { + const char *type = ""; + + if (scrp->monitor->nHsync <= 0) { + if (numTimings > 0) { + scrp->monitor->nHsync = numTimings; + for (i = 0; i < numTimings; i++) { + scrp->monitor->hsync[i].lo = hsync[i].lo; + scrp->monitor->hsync[i].hi = hsync[i].hi; + } + } else { + scrp->monitor->hsync[0].lo = 31.5; + scrp->monitor->hsync[0].hi = 37.9; + scrp->monitor->nHsync = 1; + } + type = "default "; + } + for (i = 0; i < scrp->monitor->nHsync; i++) { + if (scrp->monitor->hsync[i].lo == scrp->monitor->hsync[i].hi) + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "%s: Using %shsync value of %.2f kHz\n", + scrp->monitor->id, type, + scrp->monitor->hsync[i].lo); + else + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "%s: Using %shsync range of %.2f-%.2f kHz\n", + scrp->monitor->id, type, + scrp->monitor->hsync[i].lo, + scrp->monitor->hsync[i].hi); + } + + type = ""; + if (scrp->monitor->nVrefresh <= 0) { + if (numTimings > 0) { + scrp->monitor->nVrefresh = numTimings; + for (i = 0; i < numTimings; i++) { + scrp->monitor->vrefresh[i].lo = vrefresh[i].lo; + scrp->monitor->vrefresh[i].hi = vrefresh[i].hi; + } + } else { + scrp->monitor->vrefresh[0].lo = 50; + scrp->monitor->vrefresh[0].hi = 70; + scrp->monitor->nVrefresh = 1; + } + type = "default "; + } + for (i = 0; i < scrp->monitor->nVrefresh; i++) { + if (scrp->monitor->vrefresh[i].lo == scrp->monitor->vrefresh[i].hi) + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "%s: Using %svrefresh value of %.2f Hz\n", + scrp->monitor->id, type, + scrp->monitor->vrefresh[i].lo); + else + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "%s: Using %svrefresh range of %.2f-%.2f Hz\n", + scrp->monitor->id, type, + scrp->monitor->vrefresh[i].lo, + scrp->monitor->vrefresh[i].hi); + } + if (scrp->monitor->maxPixClock) { + xf86DrvMsg(scrp->scrnIndex, X_INFO, + "%s: Using maximum pixel clock of %.2f MHz\n", + scrp->monitor->id, + (float)scrp->monitor->maxPixClock / 1000.0); + } + } + + /* + * Store the clockRanges for later use by the VidMode extension. Must + * also store the strategy, since ClockDiv2 flag is stored there. + */ + storeClockRanges = scrp->clockRanges; + while (storeClockRanges != NULL) { + storeClockRanges = storeClockRanges->next; + } + for (cp = clockRanges; cp != NULL; cp = cp->next, + storeClockRanges = storeClockRanges->next) { + storeClockRanges = xnfalloc(sizeof(ClockRanges)); + if (scrp->clockRanges == NULL) + scrp->clockRanges = storeClockRanges; + memcpy(storeClockRanges, cp, sizeof(ClockRange)); + storeClockRanges->strategy = strategy; + } + + /* Determine which pixmap format to pass to miScanLineWidth() */ + if (scrp->depth > 4) + BankFormat = &scrp->fbFormat; + else + BankFormat = xf86GetPixFormat(scrp, 1); /* >not< scrp->depth! */ + + if (scrp->xInc <= 0) + scrp->xInc = 8; /* Suitable for VGA and others */ + +#define _VIRTUALX(x) ((((x) + scrp->xInc - 1) / scrp->xInc) * scrp->xInc) + + /* + * Determine maxPitch if it wasn't given explicitly. Note linePitches + * always takes precedence if is non-NULL. In that case the minPitch and + * maxPitch values passed are ignored. + */ + if (linePitches) { + minPitch = maxPitch = linePitches[0]; + for (i = 1; linePitches[i] > 0; i++) { + if (linePitches[i] > maxPitch) + maxPitch = linePitches[i]; + if (linePitches[i] < minPitch) + minPitch = linePitches[i]; + } + } + + /* Initial check of virtual size against other constraints */ + scrp->virtualFrom = X_PROBED; + /* + * Initialise virtX and virtY if the values are fixed. + */ + if (virtualY > 0) { + if (maxHeight > 0 && virtualY > maxHeight) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Virtual height (%d) is too large for the hardware " + "(max %d)\n", virtualY, maxHeight); + return -1; + } + + if (minHeight > 0 && virtualY < minHeight) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Virtual height (%d) is too small for the hardware " + "(min %d)\n", virtualY, minHeight); + return -1; + } + + virtualX = _VIRTUALX(virtualX); + if (linePitches != NULL) { + for (i = 0; linePitches[i] != 0; i++) { + if ((linePitches[i] >= virtualX) && + (linePitches[i] == + miScanLineWidth(virtualX, virtualY, linePitches[i], + apertureSize, BankFormat, pitchInc))) { + linePitch = linePitches[i]; + break; + } + } + } else { + linePitch = miScanLineWidth(virtualX, virtualY, minPitch, + apertureSize, BankFormat, pitchInc); + } + + if ((linePitch < minPitch) || (linePitch > maxPitch)) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Virtual width (%d) is too large for the hardware " + "(max %d)\n", virtualX, maxPitch); + return -1; + } + + if (!xf86CheckModeSize(scrp, linePitch, virtualX, virtualY)) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Virtual size (%dx%d) (pitch %d) exceeds video memory\n", + virtualX, virtualY, linePitch); + return -1; + } + + virtX = virtualX; + virtY = virtualY; + scrp->virtualFrom = X_CONFIG; + } else if (!modeNames || !*modeNames) { + /* No virtual size given in the config, try to infer */ + /* XXX this doesn't take m{in,ax}Pitch into account; oh well */ + inferred_virtual = inferVirtualSize(scrp, availModes, &virtX, &virtY); + if (inferred_virtual) + linePitch = miScanLineWidth(virtX, virtY, minPitch, apertureSize, + BankFormat, pitchInc); + } + + /* Print clock ranges and scaled clocks */ + xf86ShowClockRanges(scrp, clockRanges); + + /* + * If scrp->modePool hasn't been setup yet, set it up now. This allows the + * modes that the driver definitely can't use to be weeded out early. Note + * that a modePool mode's prev field is used to hold a pointer to the + * member of the scrp->modes list for which a match was considered. + */ + if (scrp->modePool == NULL) { + q = NULL; + for (p = availModes; p != NULL; p = p->next) { + status = xf86InitialCheckModeForDriver(scrp, p, clockRanges, + strategy, maxPitch, + virtX, virtY); + + if (status == MODE_OK) { + status = xf86CheckModeForMonitor(p, scrp->monitor); + } + + if (status == MODE_OK) { + new = xnfalloc(sizeof(DisplayModeRec)); + *new = *p; + new->next = NULL; + if (!q) { + scrp->modePool = new; + } else { + q->next = new; + } + new->prev = NULL; + q = new; + q->name = xnfstrdup(p->name); + q->status = MODE_OK; + } else { + printModeRejectMessage(scrp->scrnIndex, p, status); + } + } + + if (scrp->modePool == NULL) { + xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode pool is empty\n"); + return 0; + } + } else { + for (p = scrp->modePool; p != NULL; p = p->next) { + p->prev = NULL; + p->status = MODE_OK; + } + } + + /* + * Go through the mode pool and see if any modes match the target + * refresh rate, (if specified). If no modes match, abandon the target. + */ + targetRefresh = xf86SetRealOption(scrp->options, + "TargetRefresh", 0.0); + if (targetRefresh > 0.0) { + for (p = scrp->modePool; p != NULL; p = p->next) { + if (xf86ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE)) + break; + } + if (!p) + targetRefresh = 0.0; + } + + if (targetRefresh > 0.0) { + xf86DrvMsg(scrp->scrnIndex, X_CONFIG, + "Target refresh rate is %.1f Hz\n", targetRefresh); + } + + /* + * Allocate one entry in scrp->modes for each named mode. + */ + while (scrp->modes) + xf86DeleteMode(&scrp->modes, scrp->modes); + endp = &scrp->modes; + last = NULL; + if (modeNames != NULL) { + for (i = 0; modeNames[i] != NULL; i++) { + userModes = TRUE; + new = xnfcalloc(1, sizeof(DisplayModeRec)); + new->prev = last; + new->type = M_T_USERDEF; + new->name = xnfalloc(strlen(modeNames[i]) + 1); + strcpy(new->name, modeNames[i]); + if (new->prev) + new->prev->next = new; + *endp = last = new; + endp = &new->next; + } + } + + /* Lookup each mode */ +#ifdef RANDR + if (!xf86Info.disableRandR +#ifdef PANORAMIX + && noPanoramiXExtension +#endif + ) + validateAllDefaultModes = TRUE; +#endif + + for (p = scrp->modes; ; p = p->next) { + Bool repeat; + + /* + * If the supplied mode names don't produce a valid mode, scan through + * unconsidered modePool members until one survives validation. This + * is done in decreasing order by mode pixel area. + */ + + if (p == NULL) { + if ((numModes > 0) && !validateAllDefaultModes) + break; + + validateAllDefaultModes = TRUE; + r = NULL; + modeSize = 0; + for (q = scrp->modePool; q != NULL; q = q->next) { + if ((q->prev == NULL) && (q->status == MODE_OK)) { + /* + * Deal with the case where this mode wasn't considered + * because of a builtin mode of the same name. + */ + for (p = scrp->modes; p != NULL; p = p->next) { + if ((p->status != MODE_OK) && + !strcmp(p->name, q->name)) + break; + } + + if (p != NULL) + q->prev = p; + else { + /* + * A quick check to not allow default modes with + * horizontal timing parameters that CRTs may have + * problems with. + */ + if (!scrp->monitor->reducedblanking && + (q->type & M_T_DEFAULT) && + ((double)q->HTotal / (double)q->HDisplay) < 1.15) + continue; + + /* + * If there is a target refresh rate, skip modes that + * don't match up. + */ + if (xf86ModeVRefresh(q) < + (1.0 - SYNC_TOLERANCE) * targetRefresh) + continue; + + if (modeSize < (q->HDisplay * q->VDisplay)) { + r = q; + modeSize = q->HDisplay * q->VDisplay; + } + } + } + } + + if (r == NULL) + break; + + p = xnfcalloc(1, sizeof(DisplayModeRec)); + p->prev = last; + p->name = xnfalloc(strlen(r->name) + 1); + if (!userModes) + p->type = M_T_USERDEF; + strcpy(p->name, r->name); + if (p->prev) + p->prev->next = p; + *endp = last = p; + endp = &p->next; + } + + repeat = FALSE; + lookupNext: + if (repeat && ((status = p->status) != MODE_OK)) + printModeRejectMessage(scrp->scrnIndex, p, status); + saveType = p->type; + status = xf86LookupMode(scrp, p, clockRanges, strategy); + if (repeat && status == MODE_NOMODE) + continue; + if (status != MODE_OK) + printModeRejectMessage(scrp->scrnIndex, p, status); + if (status == MODE_ERROR) { + ErrorF("xf86ValidateModes: " + "unexpected result from xf86LookupMode()\n"); + return -1; + } + if (status != MODE_OK) { + if (p->status == MODE_OK) + p->status = status; + continue; + } + p->type |= saveType; + repeat = TRUE; + + newLinePitch = linePitch; + newVirtX = virtX; + newVirtY = virtY; + + /* + * Don't let non-user defined modes increase the virtual size + */ + if (!(p->type & M_T_USERDEF) && (numModes > 0)) { + if (p->HDisplay > virtX) { + p->status = MODE_VIRTUAL_X; + goto lookupNext; + } + if (p->VDisplay > virtY) { + p->status = MODE_VIRTUAL_Y; + goto lookupNext; + } + } + /* + * Adjust virtual width and height if the mode is too large for the + * current values and if they are not fixed. + */ + if (virtualX <= 0 && p->HDisplay > newVirtX) + newVirtX = _VIRTUALX(p->HDisplay); + if (virtualY <= 0 && p->VDisplay > newVirtY) { + if (maxHeight > 0 && p->VDisplay > maxHeight) { + p->status = MODE_VIRTUAL_Y; /* ? */ + goto lookupNext; + } + newVirtY = p->VDisplay; + } + + /* + * If virtual resolution is to be increased, revalidate it. + */ + if ((virtX != newVirtX) || (virtY != newVirtY)) { + if (linePitches != NULL) { + newLinePitch = -1; + for (i = 0; linePitches[i] != 0; i++) { + if ((linePitches[i] >= newVirtX) && + (linePitches[i] >= linePitch) && + (linePitches[i] == + miScanLineWidth(newVirtX, newVirtY, linePitches[i], + apertureSize, BankFormat, pitchInc))) { + newLinePitch = linePitches[i]; + break; + } + } + } else { + if (linePitch < minPitch) + linePitch = minPitch; + newLinePitch = miScanLineWidth(newVirtX, newVirtY, linePitch, + apertureSize, BankFormat, + pitchInc); + } + if ((newLinePitch < minPitch) || (newLinePitch > maxPitch)) { + p->status = MODE_BAD_WIDTH; + goto lookupNext; + } + + /* + * Check that the pixel area required by the new virtual height + * and line pitch isn't too large. + */ + if (!xf86CheckModeSize(scrp, newLinePitch, newVirtX, newVirtY)) { + p->status = MODE_MEM_VIRT; + goto lookupNext; + } + } + + if (scrp->ValidMode) { + /* + * Give the driver a final say, passing it the proposed virtual + * geometry. + */ + scrp->virtualX = newVirtX; + scrp->virtualY = newVirtY; + scrp->displayWidth = newLinePitch; + p->status = (scrp->ValidMode)(scrp->scrnIndex, p, FALSE, + MODECHECK_FINAL); + + if (p->status != MODE_OK) { + goto lookupNext; + } + } + + /* Mode has passed all the tests */ + virtX = newVirtX; + virtY = newVirtY; + linePitch = newLinePitch; + p->status = MODE_OK; + numModes++; + } + +#undef _VIRTUALX + + /* + * If we estimated the virtual size above, we may have filtered away all + * the modes that maximally match that size; scan again to find out and + * fix up if so. + */ + if (inferred_virtual) { + int vx = 0, vy = 0; + for (p = scrp->modes; p; p = p->next) { + if (p->HDisplay > vx && p->VDisplay > vy) { + vx = p->HDisplay; + vy = p->VDisplay; + } + } + if (vx < virtX || vy < virtY) { + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Shrinking virtual size estimate from %dx%d to %dx%d\n", + virtX, virtY, vx, vy); + virtX = vx; + virtY = vy; + linePitch = miScanLineWidth(vx, vy, minPitch, apertureSize, + BankFormat, pitchInc); + } + } + + /* Update the ScrnInfoRec parameters */ + + scrp->virtualX = virtX; + scrp->virtualY = virtY; + scrp->displayWidth = linePitch; + + if (numModes <= 0) + return 0; + + /* Make the mode list into a circular list by joining up the ends */ + p = scrp->modes; + while (p->next != NULL) + p = p->next; + /* p is now the last mode on the list */ + p->next = scrp->modes; + scrp->modes->prev = p; + + if (minHeight > 0 && virtY < minHeight) { + xf86DrvMsg(scrp->scrnIndex, X_ERROR, + "Virtual height (%d) is too small for the hardware " + "(min %d)\n", virtY, minHeight); + return -1; + } + + return numModes; +} + +/* + * xf86DeleteMode + * + * This function removes a mode from a list of modes. + * + * There are different types of mode lists: + * + * - singly linked linear lists, ending in NULL + * - doubly linked linear lists, starting and ending in NULL + * - doubly linked circular lists + * + */ + +_X_EXPORT void +xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode) +{ + /* Catch the easy/insane cases */ + if (modeList == NULL || *modeList == NULL || mode == NULL) + return; + + /* If the mode is at the start of the list, move the start of the list */ + if (*modeList == mode) + *modeList = mode->next; + + /* If mode is the only one on the list, set the list to NULL */ + if ((mode == mode->prev) && (mode == mode->next)) { + *modeList = NULL; + } else { + if ((mode->prev != NULL) && (mode->prev->next == mode)) + mode->prev->next = mode->next; + if ((mode->next != NULL) && (mode->next->prev == mode)) + mode->next->prev = mode->prev; + } + + xfree(mode->name); + xfree(mode); +} + +/* + * xf86PruneDriverModes + * + * Remove modes from the driver's mode list which have been marked as + * invalid. + */ + +_X_EXPORT void +xf86PruneDriverModes(ScrnInfoPtr scrp) +{ + DisplayModePtr first, p, n; + + p = scrp->modes; + if (p == NULL) + return; + + do { + if (!(first = scrp->modes)) + return; + n = p->next; + if (p->status != MODE_OK) { + xf86DeleteMode(&(scrp->modes), p); + } + p = n; + } while (p != NULL && p != first); + + /* modePool is no longer needed, turf it */ + while (scrp->modePool) { + /* + * A modePool mode's prev field is used to hold a pointer to the + * member of the scrp->modes list for which a match was considered. + * Clear that pointer first, otherwise xf86DeleteMode might get + * confused + */ + scrp->modePool->prev = NULL; + xf86DeleteMode(&scrp->modePool, scrp->modePool); + } +} + + +/* + * xf86SetCrtcForModes + * + * Goes through the screen's mode list, and initialises the Crtc + * parameters for each mode. The initialisation includes adjustments + * for interlaced and double scan modes. + */ +_X_EXPORT void +xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags) +{ + DisplayModePtr p; + + /* + * Store adjustFlags for use with the VidMode extension. There is an + * implicit assumption here that SetCrtcForModes is called once. + */ + scrp->adjustFlags = adjustFlags; + + p = scrp->modes; + if (p == NULL) + return; + + do { + xf86SetModeCrtc(p, adjustFlags); +#ifdef DEBUG + ErrorF("%sMode %s: %d (%d) %d %d (%d) %d %d (%d) %d %d (%d) %d\n", + (p->type & M_T_DEFAULT) ? "Default " : "", + p->name, p->CrtcHDisplay, p->CrtcHBlankStart, + p->CrtcHSyncStart, p->CrtcHSyncEnd, p->CrtcHBlankEnd, + p->CrtcHTotal, p->CrtcVDisplay, p->CrtcVBlankStart, + p->CrtcVSyncStart, p->CrtcVSyncEnd, p->CrtcVBlankEnd, + p->CrtcVTotal); +#endif + p = p->next; + } while (p != NULL && p != scrp->modes); +} + + +#if 0 +static void +add(char **p, char *new) +{ + *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2); + strcat(*p, " "); + strcat(*p, new); +} + +_X_EXPORT void +xf86PrintModeline(int scrnIndex,DisplayModePtr mode) +{ + char tmp[256]; + char *flags = xnfcalloc(1, 1); + + if (mode->HSkew) { + snprintf(tmp, 256, "hskew %i", mode->HSkew); + add(&flags, tmp); + } + if (mode->VScan) { + snprintf(tmp, 256, "vscan %i", mode->VScan); + add(&flags, tmp); + } + if (mode->Flags & V_INTERLACE) add(&flags, "interlace"); + if (mode->Flags & V_CSYNC) add(&flags, "composite"); + if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan"); + if (mode->Flags & V_BCAST) add(&flags, "bcast"); + if (mode->Flags & V_PHSYNC) add(&flags, "+hsync"); + if (mode->Flags & V_NHSYNC) add(&flags, "-hsync"); + if (mode->Flags & V_PVSYNC) add(&flags, "+vsync"); + if (mode->Flags & V_NVSYNC) add(&flags, "-vsync"); + if (mode->Flags & V_PCSYNC) add(&flags, "+csync"); + if (mode->Flags & V_NCSYNC) add(&flags, "-csync"); +#if 0 + if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2"); +#endif + xf86DrvMsgVerb(scrnIndex, X_INFO, 3, + "Modeline \"%s\" %6.2f %i %i %i %i %i %i %i %i%s\n", + mode->name, mode->Clock/1000., mode->HDisplay, + mode->HSyncStart, mode->HSyncEnd, mode->HTotal, + mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, + mode->VTotal, flags); + xfree(flags); +} +#endif + +_X_EXPORT void +xf86PrintModes(ScrnInfoPtr scrp) +{ + DisplayModePtr p; + float hsync, refresh = 0; + char *desc, *desc2, *prefix, *uprefix; + + if (scrp == NULL) + return; + + xf86DrvMsg(scrp->scrnIndex, scrp->virtualFrom, "Virtual size is %dx%d " + "(pitch %d)\n", scrp->virtualX, scrp->virtualY, + scrp->displayWidth); + + p = scrp->modes; + if (p == NULL) + return; + + do { + desc = desc2 = ""; + hsync = xf86ModeHSync(p); + refresh = xf86ModeVRefresh(p); + if (p->Flags & V_INTERLACE) { + desc = " (I)"; + } + if (p->Flags & V_DBLSCAN) { + desc = " (D)"; + } + if (p->VScan > 1) { + desc2 = " (VScan)"; + } + if (p->type & M_T_BUILTIN) + prefix = "Built-in mode"; + else if (p->type & M_T_DEFAULT) + prefix = "Default mode"; + else if (p->type & M_T_DRIVER) + prefix = "Driver mode"; + else + prefix = "Mode"; + if (p->type & M_T_USERDEF) + uprefix = "*"; + else + uprefix = " "; + if (hsync == 0 || refresh == 0) { + if (p->name) + xf86DrvMsg(scrp->scrnIndex, X_CONFIG, + "%s%s \"%s\"\n", uprefix, prefix, p->name); + else + xf86DrvMsg(scrp->scrnIndex, X_PROBED, + "%s%s %dx%d (unnamed)\n", + uprefix, prefix, p->HDisplay, p->VDisplay); + } else if (p->Clock == p->SynthClock) { + xf86DrvMsg(scrp->scrnIndex, X_CONFIG, + "%s%s \"%s\": %.1f MHz, %.1f kHz, %.1f Hz%s%s\n", + uprefix, prefix, p->name, p->Clock / 1000.0, + hsync, refresh, desc, desc2); + } else { + xf86DrvMsg(scrp->scrnIndex, X_CONFIG, + "%s%s \"%s\": %.1f MHz (scaled from %.1f MHz), " + "%.1f kHz, %.1f Hz%s%s\n", + uprefix, prefix, p->name, p->Clock / 1000.0, + p->SynthClock / 1000.0, hsync, refresh, desc, desc2); + } + if (hsync != 0 && refresh != 0) + xf86PrintModeline(scrp->scrnIndex,p); + p = p->next; + } while (p != NULL && p != scrp->modes); +} + +#if 0 +/** + * Adds the new mode into the mode list, and returns the new list + * + * \param modes doubly-linked mode list. + */ +_X_EXPORT DisplayModePtr +xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new) +{ + if (modes == NULL) + return new; + + if (new) { + DisplayModePtr mode = modes; + + while (mode->next) + mode = mode->next; + + mode->next = new; + new->prev = mode; + } + + return modes; +} +#endif diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h new file mode 100644 index 000000000..5ce6e8a26 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Module.h @@ -0,0 +1,225 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the parts of the loader interface that are visible + * to modules. This is the only loader-related header that modules should + * include. + * + * It should include a bare minimum of other headers. + * + * Longer term, the module/loader code should probably live directly under + * Xserver/. + * + * XXX This file arguably belongs in xfree86/loader/. + */ + +#ifndef _XF86MODULE_H +#define _XF86MODULE_H + +#include "misc.h" +#include "xf86Version.h" +#ifndef NULL +#define NULL ((void *)0) +#endif + +typedef enum { + LD_RESOLV_IFDONE = 0, /* only check if no more + delays pending */ + LD_RESOLV_NOW = 1, /* finish one delay step */ + LD_RESOLV_FORCE = 2 /* force checking... */ +} LoaderResolveOptions; + +#define DEFAULT_LIST ((char *)-1) + +/* This indicates a special module that doesn't have the usual entry point */ +#define EXTERN_MODULE ((pointer)-1) + +/* Built-in ABI classes. These definitions must not be changed. */ +#define ABI_CLASS_NONE NULL +#define ABI_CLASS_ANSIC "X.Org ANSI C Emulation" +#define ABI_CLASS_VIDEODRV "X.Org Video Driver" +#define ABI_CLASS_XINPUT "X.Org XInput driver" +#define ABI_CLASS_EXTENSION "X.Org Server Extension" +#define ABI_CLASS_FONT "X.Org Font Renderer" + +#define ABI_MINOR_MASK 0x0000FFFF +#define ABI_MAJOR_MASK 0xFFFF0000 +#define GET_ABI_MINOR(v) ((v) & ABI_MINOR_MASK) +#define GET_ABI_MAJOR(v) (((v) & ABI_MAJOR_MASK) >> 16) +#define SET_ABI_VERSION(maj, min) \ + ((((maj) << 16) & ABI_MAJOR_MASK) | ((min) & ABI_MINOR_MASK)) + +/* + * ABI versions. Each version has a major and minor revision. Modules + * using lower minor revisions must work with servers of a higher minor + * revision. There is no compatibility between different major revisions. + * Whenever the ABI_ANSIC_VERSION is changed, the others must also be + * changed. The minor revision mask is 0x0000FFFF and the major revision + * mask is 0xFFFF0000. + */ +#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(4, 1) +#define ABI_XINPUT_VERSION SET_ABI_VERSION(2, 1) +#define ABI_EXTENSION_VERSION SET_ABI_VERSION(1, 1) +#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) + +#define MODINFOSTRING1 0xef23fdc5 +#define MODINFOSTRING2 0x10dc023a + +#ifndef MODULEVENDORSTRING +#define MODULEVENDORSTRING "X.Org Foundation" +#endif + +/* Error return codes for errmaj. New codes must only be added at the end. */ +typedef enum { + LDR_NOERROR = 0, + LDR_NOMEM, /* memory allocation failed */ + LDR_NOENT, /* Module file does not exist */ + LDR_NOSUBENT, /* pre-requsite file to be sub-loaded does not exist */ + LDR_NOSPACE, /* internal module array full */ + LDR_NOMODOPEN, /* module file could not be opened (check errmin) */ + LDR_UNKTYPE, /* file is not a recognized module type */ + LDR_NOLOAD, /* type specific loader failed */ + LDR_ONCEONLY, /* Module should only be loaded once (not an error) */ + LDR_NOPORTOPEN, /* could not open port (check errmin) */ + LDR_NOHARDWARE, /* could not query/initialize the hardware device */ + LDR_MISMATCH, /* the module didn't match the spec'd requirments */ + LDR_BADUSAGE, /* LoadModule is called with bad arguments */ + LDR_INVALID, /* The module doesn't have a valid ModuleData object */ + LDR_BADOS, /* The module doesn't support the OS */ + LDR_MODSPECIFIC /* A module-specific error in the SetupProc */ +} LoaderErrorCode; + +/* + * Some common module classes. The moduleclass can be used to identify + * that modules loaded are of the correct type. This is a finer + * classification than the ABI classes even though the default set of + * classes have the same names. For example, not all modules that require + * the video driver ABI are themselves video drivers. + */ +#define MOD_CLASS_NONE NULL +#define MOD_CLASS_VIDEODRV "X.Org Video Driver" +#define MOD_CLASS_XINPUT "X.Org XInput Driver" +#define MOD_CLASS_FONT "X.Org Font Renderer" +#define MOD_CLASS_EXTENSION "X.Org Server Extension" + +/* This structure is expected to be returned by the initfunc */ +typedef struct { + const char * modname; /* name of module, e.g. "foo" */ + const char * vendor; /* vendor specific string */ + CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */ + CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */ + CARD32 xf86version; /* contains XF86_VERSION_CURRENT */ + CARD8 majorversion; /* module-specific major version */ + CARD8 minorversion; /* module-specific minor version */ + CARD16 patchlevel; /* module-specific patch level */ + const char * abiclass; /* ABI class that the module uses */ + CARD32 abiversion; /* ABI version */ + const char * moduleclass; /* module class description */ + CARD32 checksum[4]; /* contains a digital signature of the */ + /* version info structure */ +} XF86ModuleVersionInfo; + +/* + * This structure can be used to callers of LoadModule and LoadSubModule to + * specify version and/or ABI requirements. + */ +typedef struct { + CARD8 majorversion; /* module-specific major version */ + CARD8 minorversion; /* moudle-specific minor version */ + CARD16 patchlevel; /* module-specific patch level */ + const char * abiclass; /* ABI class that the module uses */ + CARD32 abiversion; /* ABI version */ + const char * moduleclass; /* module class */ +} XF86ModReqInfo; + +/* values to indicate unspecified fields in XF86ModReqInfo. */ +#define MAJOR_UNSPEC 0xFF +#define MINOR_UNSPEC 0xFF +#define PATCH_UNSPEC 0xFFFF +#define ABI_VERS_UNSPEC 0xFFFFFFFF + +#define MODULE_VERSION_NUMERIC(maj, min, patch) \ + ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF)) +#define GET_MODULE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF) +#define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF) +#define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF) + +#define INITARGS void + +typedef void (*InitExtension)(INITARGS); + +typedef struct { + InitExtension initFunc; + const char * name; + Bool *disablePtr; + InitExtension setupFunc; + const char ** initDependencies; +} ExtensionModule; + +extern ExtensionModule *ExtensionModuleList; + +/* Prototypes for Loader functions that are exported to modules */ +#ifndef IN_LOADER +/* Prototypes with opaque pointers for use by modules */ +pointer LoadSubModule(pointer, const char *, const char **, + const char **, pointer, const XF86ModReqInfo *, + int *, int *); +pointer LoadSubModuleLocal(pointer, const char *, const char **, + const char **, pointer, const XF86ModReqInfo *, + int *, int *); +void UnloadSubModule(pointer); +void LoadFont(pointer); +void UnloadModule (pointer); +#endif +pointer LoaderSymbol(const char *); +pointer LoaderSymbolLocal(pointer module, const char *); +char **LoaderListDirs(const char **, const char **); +void LoaderFreeDirList(char **); +void LoaderErrorMsg(const char *, const char *, int, int); +void LoadExtension(ExtensionModule *, Bool); +void LoaderRefSymLists(const char **, ...); +void LoaderRefSymbols(const char *, ...); +void LoaderReqSymLists(const char **, ...); +void LoaderReqSymbols(const char *, ...); +int LoaderCheckUnresolved(int); +void LoaderGetOS(const char **name, int *major, int *minor, int *teeny); +int LoaderGetABIVersion(const char *abiclass); + +typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *); +typedef void (*ModuleTearDownProc)(pointer); +#define MODULESETUPPROTO(func) pointer func(pointer, pointer, int*, int*) +#define MODULETEARDOWNPROTO(func) void func(pointer) + +typedef struct { + XF86ModuleVersionInfo * vers; + ModuleSetupProc setup; + ModuleTearDownProc teardown; +} XF86ModuleData; + +#endif /* _XF86STR_H */ diff --git a/xorg-server/hw/xfree86/common/xf86Opt.h b/xorg-server/hw/xfree86/common/xf86Opt.h new file mode 100644 index 000000000..dbb98da03 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Opt.h @@ -0,0 +1,113 @@ + +/* + * Copyright (c) 1998-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Option handling things that ModuleSetup procs can use */ + +#ifndef _XF86_OPT_H_ +#define _XF86_OPT_H_ + +typedef struct { + double freq; + int units; +} OptFrequency; + +typedef union { + unsigned long num; + char * str; + double realnum; + Bool bool; + OptFrequency freq; +} ValueUnion; + +typedef enum { + OPTV_NONE = 0, + OPTV_INTEGER, + OPTV_STRING, /* a non-empty string */ + OPTV_ANYSTR, /* Any string, including an empty one */ + OPTV_REAL, + OPTV_BOOLEAN, + OPTV_FREQ +} OptionValueType; + +typedef enum { + OPTUNITS_HZ = 1, + OPTUNITS_KHZ, + OPTUNITS_MHZ +} OptFreqUnits; + +typedef struct { + int token; + const char* name; + OptionValueType type; + ValueUnion value; + Bool found; +} OptionInfoRec, *OptionInfoPtr; + +int xf86SetIntOption(pointer optlist, const char *name, int deflt); +double xf86SetRealOption(pointer optlist, const char *name, double deflt); +char *xf86SetStrOption(pointer optlist, const char *name, char *deflt); +int xf86SetBoolOption(pointer list, const char *name, int deflt ); +int xf86CheckIntOption(pointer optlist, const char *name, int deflt); +double xf86CheckRealOption(pointer optlist, const char *name, double deflt); +char *xf86CheckStrOption(pointer optlist, const char *name, char *deflt); +int xf86CheckBoolOption(pointer list, const char *name, int deflt ); +pointer xf86AddNewOption(pointer head, const char *name, const char *val ); +pointer xf86NewOption(char *name, char *value ); +pointer xf86NextOption(pointer list ); +pointer xf86OptionListCreate(const char **options, int count, int used); +pointer xf86OptionListMerge(pointer head, pointer tail); +void xf86OptionListFree(pointer opt); +char *xf86OptionName(pointer opt); +char *xf86OptionValue(pointer opt); +void xf86OptionListReport(pointer parm); +pointer xf86FindOption(pointer options, const char *name); +char *xf86FindOptionValue(pointer options, const char *name); +void xf86MarkOptionUsed(pointer option); +void xf86MarkOptionUsedByName(pointer options, const char *name); +Bool xf86CheckIfOptionUsed(pointer option); +Bool xf86CheckIfOptionUsedByName(pointer options, const char *name); +void xf86ShowUnusedOptions(int scrnIndex, pointer options); +void xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo); +OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table, int token); +const char *xf86TokenToOptName(const OptionInfoRec *table, int token); +Bool xf86IsOptionSet(const OptionInfoRec *table, int token); +char *xf86GetOptValString(const OptionInfoRec *table, int token); +Bool xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value); +Bool xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value); +Bool xf86GetOptValReal(const OptionInfoRec *table, int token, double *value); +Bool xf86GetOptValFreq(const OptionInfoRec *table, int token, + OptFreqUnits expectedUnits, double *value); +Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value); +Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def); +int xf86NameCmp(const char *s1, const char *s2); +char *xf86NormalizeName(const char *s); +pointer xf86ReplaceIntOption(pointer optlist, const char *name, const int val); +pointer xf86ReplaceRealOption(pointer optlist, const char *name, const double val); +pointer xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val); +pointer xf86ReplaceStrOption(pointer optlist, const char *name, const char* val); +#endif diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c new file mode 100644 index 000000000..50a7d9cb9 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Option.c @@ -0,0 +1,883 @@ +/* + * Copyright (c) 1998-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * Author: David Dawes + * + * This file includes public option handling functions. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include "os.h" +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86Optrec.h" + +static Bool ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p, + Bool markUsed); + +/* + * xf86CollectOptions collects the options from each of the config file + * sections used by the screen and puts the combined list in pScrn->options. + * This function requires that the following have been initialised: + * + * pScrn->confScreen + * pScrn->Entities[i]->device + * pScrn->display + * pScrn->monitor + * + * The extraOpts parameter may optionally contain a list of additional options + * to include. + * + * The order of precedence for options is: + * + * extraOpts, display, confScreen, monitor, device + */ + +_X_EXPORT void +xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts) +{ + XF86OptionPtr tmp; + XF86OptionPtr extras = (XF86OptionPtr)extraOpts; + GDevPtr device; + + int i; + + pScrn->options = NULL; + + for (i=pScrn->numEntities - 1; i >= 0; i--) { + device = xf86GetDevFromEntity(pScrn->entityList[i], + pScrn->entityInstanceList[i]); + if (device && device->options) { + tmp = xf86optionListDup(device->options); + if (pScrn->options) + xf86optionListMerge(pScrn->options,tmp); + else + pScrn->options = tmp; + } + } + if (pScrn->monitor->options) { + tmp = xf86optionListDup(pScrn->monitor->options); + if (pScrn->options) + pScrn->options = xf86optionListMerge(pScrn->options, tmp); + else + pScrn->options = tmp; + } + if (pScrn->confScreen->options) { + tmp = xf86optionListDup(pScrn->confScreen->options); + if (pScrn->options) + pScrn->options = xf86optionListMerge(pScrn->options, tmp); + else + pScrn->options = tmp; + } + if (pScrn->display->options) { + tmp = xf86optionListDup(pScrn->display->options); + if (pScrn->options) + pScrn->options = xf86optionListMerge(pScrn->options, tmp); + else + pScrn->options = tmp; + } + if (extras) { + tmp = xf86optionListDup(extras); + if (pScrn->options) + pScrn->options = xf86optionListMerge(pScrn->options, tmp); + else + pScrn->options = tmp; + } +} + +/* + * xf86CollectInputOptions collects the options for an InputDevice. + * This function requires that the following has been initialised: + * + * pInfo->conf_idev + * + * The extraOpts parameter may optionally contain a list of additional options + * to include. + * + * The order of precedence for options is: + * + * extraOpts, pInfo->conf_idev->extraOptions, + * pInfo->conf_idev->commonOptions, defaultOpts + */ + +_X_EXPORT void +xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts, + pointer extraOpts) +{ + XF86OptionPtr tmp; + XF86OptionPtr extras = (XF86OptionPtr)extraOpts; + + pInfo->options = NULL; + if (defaultOpts) { + pInfo->options = xf86OptionListCreate(defaultOpts, -1, 0); + } + if (pInfo->conf_idev && pInfo->conf_idev->commonOptions) { + tmp = xf86optionListDup(pInfo->conf_idev->commonOptions); + if (pInfo->options) + pInfo->options = xf86optionListMerge(pInfo->options, tmp); + else + pInfo->options = tmp; + } + if (pInfo->conf_idev && pInfo->conf_idev->extraOptions) { + tmp = xf86optionListDup(pInfo->conf_idev->extraOptions); + if (pInfo->options) + pInfo->options = xf86optionListMerge(pInfo->options, tmp); + else + pInfo->options = tmp; + } + if (extras) { + tmp = xf86optionListDup(extras); + if (pInfo->options) + pInfo->options = xf86optionListMerge(pInfo->options, tmp); + else + pInfo->options = tmp; + } +} + +/* Created for new XInput stuff -- essentially extensions to the parser */ + +static int +LookupIntOption(pointer optlist, const char *name, int deflt, Bool markUsed) +{ + OptionInfoRec o; + + o.name = name; + o.type = OPTV_INTEGER; + if (ParseOptionValue(-1, optlist, &o, markUsed)) + deflt = o.value.num; + return deflt; +} + + +static double +LookupRealOption(pointer optlist, const char *name, double deflt, + Bool markUsed) +{ + OptionInfoRec o; + + o.name = name; + o.type = OPTV_REAL; + if (ParseOptionValue(-1, optlist, &o, markUsed)) + deflt = o.value.realnum; + return deflt; +} + + +static char * +LookupStrOption(pointer optlist, const char *name, char *deflt, Bool markUsed) +{ + OptionInfoRec o; + + o.name = name; + o.type = OPTV_STRING; + if (ParseOptionValue(-1, optlist, &o, markUsed)) + deflt = o.value.str; + if (deflt) + return xstrdup(deflt); + else + return NULL; +} + + +static int +LookupBoolOption(pointer optlist, const char *name, int deflt, Bool markUsed) +{ + OptionInfoRec o; + + o.name = name; + o.type = OPTV_BOOLEAN; + if (ParseOptionValue(-1, optlist, &o, markUsed)) + deflt = o.value.bool; + return deflt; +} + +/* These xf86Set* functions are intended for use by non-screen specific code */ + +_X_EXPORT int +xf86SetIntOption(pointer optlist, const char *name, int deflt) +{ + return LookupIntOption(optlist, name, deflt, TRUE); +} + + +_X_EXPORT double +xf86SetRealOption(pointer optlist, const char *name, double deflt) +{ + return LookupRealOption(optlist, name, deflt, TRUE); +} + + +_X_EXPORT char * +xf86SetStrOption(pointer optlist, const char *name, char *deflt) +{ + return LookupStrOption(optlist, name, deflt, TRUE); +} + + +_X_EXPORT int +xf86SetBoolOption(pointer optlist, const char *name, int deflt) +{ + return LookupBoolOption(optlist, name, deflt, TRUE); +} + +/* + * These are like the Set*Option functions, but they don't mark the options + * as used. + */ +_X_EXPORT int +xf86CheckIntOption(pointer optlist, const char *name, int deflt) +{ + return LookupIntOption(optlist, name, deflt, FALSE); +} + + +_X_EXPORT double +xf86CheckRealOption(pointer optlist, const char *name, double deflt) +{ + return LookupRealOption(optlist, name, deflt, FALSE); +} + + +_X_EXPORT char * +xf86CheckStrOption(pointer optlist, const char *name, char *deflt) +{ + return LookupStrOption(optlist, name, deflt, FALSE); +} + + +_X_EXPORT int +xf86CheckBoolOption(pointer optlist, const char *name, int deflt) +{ + return LookupBoolOption(optlist, name, deflt, FALSE); +} + +/* + * addNewOption() has the required property of replacing the option value + * if the option is already present. + */ +_X_EXPORT pointer +xf86ReplaceIntOption(pointer optlist, const char *name, const int val) +{ + char tmp[16]; + sprintf(tmp,"%i",val); + return xf86AddNewOption(optlist,name,tmp); +} + +_X_EXPORT pointer +xf86ReplaceRealOption(pointer optlist, const char *name, const double val) +{ + char tmp[32]; + snprintf(tmp,32,"%f",val); + return xf86AddNewOption(optlist,name,tmp); +} + +_X_EXPORT pointer +xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val) +{ + return xf86AddNewOption(optlist,name,val?"True":"False"); +} + +_X_EXPORT pointer +xf86ReplaceStrOption(pointer optlist, const char *name, const char* val) +{ + return xf86AddNewOption(optlist,name,val); +} + +_X_EXPORT pointer +xf86AddNewOption(pointer head, const char *name, const char *val) +{ + /* XXX These should actually be allocated in the parser library. */ + char *tmp = strdup(val); + char *tmp_name = strdup(name); + + return xf86addNewOption(head, tmp_name, tmp); +} + + +_X_EXPORT pointer +xf86NewOption(char *name, char *value) +{ + return xf86newOption(name, value); +} + + +_X_EXPORT pointer +xf86NextOption(pointer list) +{ + return xf86nextOption(list); +} + +_X_EXPORT pointer +xf86OptionListCreate(const char **options, int count, int used) +{ + return xf86optionListCreate(options, count, used); +} + +_X_EXPORT pointer +xf86OptionListMerge(pointer head, pointer tail) +{ + return xf86optionListMerge(head, tail); +} + +_X_EXPORT void +xf86OptionListFree(pointer opt) +{ + xf86optionListFree(opt); +} + +_X_EXPORT char * +xf86OptionName(pointer opt) +{ + return xf86optionName(opt); +} + +_X_EXPORT char * +xf86OptionValue(pointer opt) +{ + return xf86optionValue(opt); +} + +_X_EXPORT void +xf86OptionListReport(pointer parm) +{ + XF86OptionPtr opts = parm; + + while(opts) { + if (xf86optionValue(opts)) + xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n", + xf86optionName(opts), xf86optionValue(opts)); + else + xf86ErrorFVerb( 5, "\tOption \"%s\"\n", xf86optionName(opts)); + opts = xf86nextOption(opts); + } +} + +/* End of XInput-caused section */ + +_X_EXPORT pointer +xf86FindOption(pointer options, const char *name) +{ + return xf86findOption(options, name); +} + + +_X_EXPORT char * +xf86FindOptionValue(pointer options, const char *name) +{ + return xf86findOptionValue(options, name); +} + + +_X_EXPORT void +xf86MarkOptionUsed(pointer option) +{ + if (option != NULL) + ((XF86OptionPtr)option)->opt_used = TRUE; +} + + +_X_EXPORT void +xf86MarkOptionUsedByName(pointer options, const char *name) +{ + XF86OptionPtr opt; + + opt = xf86findOption(options, name); + if (opt != NULL) + opt->opt_used = TRUE; +} + +_X_EXPORT Bool +xf86CheckIfOptionUsed(pointer option) +{ + if (option != NULL) + return ((XF86OptionPtr)option)->opt_used; + else + return FALSE; +} + +_X_EXPORT Bool +xf86CheckIfOptionUsedByName(pointer options, const char *name) +{ + XF86OptionPtr opt; + + opt = xf86findOption(options, name); + if (opt != NULL) + return opt->opt_used; + else + return FALSE; +} + +_X_EXPORT void +xf86ShowUnusedOptions(int scrnIndex, pointer options) +{ + XF86OptionPtr opt = options; + + while (opt) { + if (opt->opt_name && !opt->opt_used) { + xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n", + opt->opt_name); + } + opt = opt->list.next; + } +} + + +static Bool +GetBoolValue(OptionInfoPtr p, const char *s) +{ + if (*s == '\0') { + p->value.bool = TRUE; + } else { + if (xf86NameCmp(s, "1") == 0) + p->value.bool = TRUE; + else if (xf86NameCmp(s, "on") == 0) + p->value.bool = TRUE; + else if (xf86NameCmp(s, "true") == 0) + p->value.bool = TRUE; + else if (xf86NameCmp(s, "yes") == 0) + p->value.bool = TRUE; + else if (xf86NameCmp(s, "0") == 0) + p->value.bool = FALSE; + else if (xf86NameCmp(s, "off") == 0) + p->value.bool = FALSE; + else if (xf86NameCmp(s, "false") == 0) + p->value.bool = FALSE; + else if (xf86NameCmp(s, "no") == 0) + p->value.bool = FALSE; + else + return FALSE; + } + return TRUE; +} + +static Bool +ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p, + Bool markUsed) +{ + char *s, *end; + Bool wasUsed = FALSE; + + if ((s = xf86findOptionValue(options, p->name)) != NULL) { + if (markUsed) { + wasUsed = xf86CheckIfOptionUsedByName(options, p->name); + xf86MarkOptionUsedByName(options, p->name); + } + switch (p->type) { + case OPTV_INTEGER: + if (*s == '\0') { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires an integer value\n", + p->name); + p->found = FALSE; + } else { + p->value.num = strtoul(s, &end, 0); + if (*end == '\0') { + p->found = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires an integer value\n", + p->name); + p->found = FALSE; + } + } + break; + case OPTV_STRING: + if (*s == '\0') { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires an string value\n", + p->name); + p->found = FALSE; + } else { + p->value.str = s; + p->found = TRUE; + } + break; + case OPTV_ANYSTR: + p->value.str = s; + p->found = TRUE; + break; + case OPTV_REAL: + if (*s == '\0') { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires a floating point value\n", + p->name); + p->found = FALSE; + } else { + p->value.realnum = strtod(s, &end); + if (*end == '\0') { + p->found = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires a floating point value\n", + p->name); + p->found = FALSE; + } + } + break; + case OPTV_BOOLEAN: + if (GetBoolValue(p, s)) { + p->found = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires a boolean value\n", p->name); + p->found = FALSE; + } + break; + case OPTV_FREQ: + if (*s == '\0') { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires a frequency value\n", + p->name); + p->found = FALSE; + } else { + double freq = strtod(s, &end); + int units = 0; + + if (end != s) { + p->found = TRUE; + if (!xf86NameCmp(end, "Hz")) + units = 1; + else if (!xf86NameCmp(end, "kHz") || + !xf86NameCmp(end, "k")) + units = 1000; + else if (!xf86NameCmp(end, "MHz") || + !xf86NameCmp(end, "M")) + units = 1000000; + else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires a frequency value\n", + p->name); + p->found = FALSE; + } + if (p->found) + freq *= (double)units; + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires a frequency value\n", + p->name); + p->found = FALSE; + } + if (p->found) { + p->value.freq.freq = freq; + p->value.freq.units = units; + } + } + break; + case OPTV_NONE: + /* Should never get here */ + p->found = FALSE; + break; + } + if (p->found && markUsed) { + int verb = 2; + if (wasUsed) + verb = 4; + xf86DrvMsgVerb(scrnIndex, X_CONFIG, verb, "Option \"%s\"", p->name); + if (!(p->type == OPTV_BOOLEAN && *s == 0)) { + xf86ErrorFVerb(verb, " \"%s\"", s); + } + xf86ErrorFVerb(verb, "\n"); + } + } else if (p->type == OPTV_BOOLEAN) { + /* Look for matches with options with or without a "No" prefix. */ + char *n, *newn; + OptionInfoRec opt; + + n = xf86NormalizeName(p->name); + if (!n) { + p->found = FALSE; + return FALSE; + } + if (strncmp(n, "no", 2) == 0) { + newn = n + 2; + } else { + xfree(n); + n = xalloc(strlen(p->name) + 2 + 1); + if (!n) { + p->found = FALSE; + return FALSE; + } + strcpy(n, "No"); + strcat(n, p->name); + newn = n; + } + if ((s = xf86findOptionValue(options, newn)) != NULL) { + if (markUsed) + xf86MarkOptionUsedByName(options, newn); + if (GetBoolValue(&opt, s)) { + p->value.bool = !opt.value.bool; + p->found = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Option \"%s\" requires a boolean value\n", newn); + p->found = FALSE; + } + } else { + p->found = FALSE; + } + if (p->found && markUsed) { + xf86DrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn); + if (*s != 0) { + xf86ErrorFVerb(2, " \"%s\"", s); + } + xf86ErrorFVerb(2, "\n"); + } + xfree(n); + } else { + p->found = FALSE; + } + return p->found; +} + + +_X_EXPORT void +xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo) +{ + OptionInfoPtr p; + + for (p = optinfo; p->name != NULL; p++) { + ParseOptionValue(scrnIndex, options, p, TRUE); + } +} + + +_X_EXPORT OptionInfoPtr +xf86TokenToOptinfo(const OptionInfoRec *table, int token) +{ + const OptionInfoRec *p, *match = NULL, *set = NULL; + + if (!table) { + ErrorF("xf86TokenToOptinfo: table is NULL\n"); + return NULL; + } + + for (p = table; p->token >= 0; p++) { + if (p->token == token) { + match = p; + if (p->found) + set = p; + } + } + + if (set) + return (OptionInfoPtr)set; + else if (match) + return (OptionInfoPtr)match; + else + return NULL; +} + + +_X_EXPORT const char * +xf86TokenToOptName(const OptionInfoRec *table, int token) +{ + const OptionInfoRec *p; + + p = xf86TokenToOptinfo(table, token); + return p->name; +} + + +_X_EXPORT Bool +xf86IsOptionSet(const OptionInfoRec *table, int token) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + return (p && p->found); +} + + +_X_EXPORT char * +xf86GetOptValString(const OptionInfoRec *table, int token) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + if (p && p->found) + return p->value.str; + else + return NULL; +} + + +_X_EXPORT Bool +xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + if (p && p->found) { + *value = p->value.num; + return TRUE; + } else + return FALSE; +} + + +_X_EXPORT Bool +xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + if (p && p->found) { + *value = p->value.num; + return TRUE; + } else + return FALSE; +} + + +_X_EXPORT Bool +xf86GetOptValReal(const OptionInfoRec *table, int token, double *value) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + if (p && p->found) { + *value = p->value.realnum; + return TRUE; + } else + return FALSE; +} + + +_X_EXPORT Bool +xf86GetOptValFreq(const OptionInfoRec *table, int token, + OptFreqUnits expectedUnits, double *value) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + if (p && p->found) { + if (p->value.freq.units > 0) { + /* Units give, so the scaling is known. */ + switch (expectedUnits) { + case OPTUNITS_HZ: + *value = p->value.freq.freq; + break; + case OPTUNITS_KHZ: + *value = p->value.freq.freq / 1000.0; + break; + case OPTUNITS_MHZ: + *value = p->value.freq.freq / 1000000.0; + break; + } + } else { + /* No units given, so try to guess the scaling. */ + switch (expectedUnits) { + case OPTUNITS_HZ: + *value = p->value.freq.freq; + break; + case OPTUNITS_KHZ: + if (p->value.freq.freq > 1000.0) + *value = p->value.freq.freq / 1000.0; + else + *value = p->value.freq.freq; + break; + case OPTUNITS_MHZ: + if (p->value.freq.freq > 1000000.0) + *value = p->value.freq.freq / 1000000.0; + else if (p->value.freq.freq > 1000.0) + *value = p->value.freq.freq / 1000.0; + else + *value = p->value.freq.freq; + } + } + return TRUE; + } else + return FALSE; +} + + +_X_EXPORT Bool +xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + if (p && p->found) { + *value = p->value.bool; + return TRUE; + } else + return FALSE; +} + + +_X_EXPORT Bool +xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def) +{ + OptionInfoPtr p; + + p = xf86TokenToOptinfo(table, token); + if (p && p->found) { + return p->value.bool; + } else + return def; +} + + +_X_EXPORT int +xf86NameCmp(const char *s1, const char *s2) +{ + return xf86nameCompare(s1, s2); +} + +char * +xf86NormalizeName(const char *s) +{ + char *ret, *q; + const char *p; + + if (s == NULL) + return NULL; + + ret = xalloc(strlen(s) + 1); + for (p = s, q = ret; *p != 0; p++) { + switch (*p) { + case '_': + case ' ': + case '\t': + continue; + default: + if (isupper(*p)) + *q++ = tolower(*p); + else + *q++ = *p; + } + } + *q = '\0'; + return ret; +} diff --git a/xorg-server/hw/xfree86/common/xf86PM.c b/xorg-server/hw/xfree86/common/xf86PM.c new file mode 100644 index 000000000..7c8320dee --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86PM.c @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2000-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Xinput.h" + +int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num) = NULL; +pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event) = NULL; + +static Bool suspended = FALSE; + +static int +eventName(pmEvent event, char **str) +{ + switch(event) { + case XF86_APM_SYS_STANDBY: *str="System Standby Request"; return 0; + case XF86_APM_SYS_SUSPEND: *str="System Suspend Request"; return 0; + case XF86_APM_CRITICAL_SUSPEND: *str="Critical Suspend"; return 0; + case XF86_APM_USER_STANDBY: *str="User System Standby Request"; return 0; + case XF86_APM_USER_SUSPEND: *str="User System Suspend Request"; return 0; + case XF86_APM_STANDBY_RESUME: *str="System Standby Resume"; return 0; + case XF86_APM_NORMAL_RESUME: *str="Normal Resume System"; return 0; + case XF86_APM_CRITICAL_RESUME: *str="Critical Resume System"; return 0; + case XF86_APM_LOW_BATTERY: *str="Battery Low"; return 3; + case XF86_APM_POWER_STATUS_CHANGE: *str="Power Status Change";return 3; + case XF86_APM_UPDATE_TIME: *str="Update Time";return 3; + case XF86_APM_CAPABILITY_CHANGED: *str="Capability Changed"; return 3; + case XF86_APM_STANDBY_FAILED: *str="Standby Request Failed"; return 0; + case XF86_APM_SUSPEND_FAILED: *str="Suspend Request Failed"; return 0; + default: *str="Unknown Event"; return 0; + } +} + +static void +suspend (pmEvent event, Bool undo) +{ + int i; + InputInfoPtr pInfo; + + xf86inSuspend = TRUE; + + for (i = 0; i < xf86NumScreens; i++) { + xf86EnableAccess(xf86Screens[i]); + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE); + } + pInfo = xf86InputDevs; + while (pInfo) { + DisableDevice(pInfo->dev); + pInfo = pInfo->next; + } + xf86EnterServerState(SETUP); + for (i = 0; i < xf86NumScreens; i++) { + xf86EnableAccess(xf86Screens[i]); + if (xf86Screens[i]->PMEvent) + xf86Screens[i]->PMEvent(i,event,undo); + else { + xf86Screens[i]->LeaveVT(i, 0); + xf86Screens[i]->vtSema = FALSE; + } + } + xf86AccessLeave(); + xf86AccessLeaveState(); +} + +static void +resume(pmEvent event, Bool undo) +{ + int i; + InputInfoPtr pInfo; + + xf86AccessEnter(); + xf86EnterServerState(SETUP); + for (i = 0; i < xf86NumScreens; i++) { + xf86EnableAccess(xf86Screens[i]); + if (xf86Screens[i]->PMEvent) + xf86Screens[i]->PMEvent(i,event,undo); + else { + xf86Screens[i]->vtSema = TRUE; + xf86Screens[i]->EnterVT(i, 0); + } + } + xf86EnterServerState(OPERATING); + for (i = 0; i < xf86NumScreens; i++) { + xf86EnableAccess(xf86Screens[i]); + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); + } + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); + pInfo = xf86InputDevs; + while (pInfo) { + EnableDevice(pInfo->dev); + pInfo = pInfo->next; + } + xf86inSuspend = FALSE; +} + +static void +DoApmEvent(pmEvent event, Bool undo) +{ + /* + * we leave that as a global function for now. I don't know if + * this might cause problems in the future. It is a global server + * variable therefore it needs to be in a server info structure + */ + int i, setup = 0; + + switch(event) { +#if 0 + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: +#endif + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: /*do we want to delay a critical suspend?*/ + case XF86_APM_USER_SUSPEND: + /* should we do this ? */ + if (!undo && !suspended) { + suspend(event,undo); + suspended = TRUE; + } else if (undo && suspended) { + resume(event,undo); + suspended = FALSE; + } + break; +#if 0 + case XF86_APM_STANDBY_RESUME: +#endif + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + if (suspended) { + resume(event,undo); + suspended = FALSE; + } + break; + default: + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->PMEvent) { + if (!setup) xf86EnterServerState(SETUP); + setup = 1; + xf86EnableAccess(xf86Screens[i]); + xf86Screens[i]->PMEvent(i,event,undo); + } + } + if (setup) xf86EnterServerState(OPERATING); + break; + } +} + +#define MAX_NO_EVENTS 8 + +void +xf86HandlePMEvents(int fd, pointer data) +{ + pmEvent events[MAX_NO_EVENTS]; + int i,n; + Bool wait = FALSE; + + if (!xf86PMGetEventFromOs) + return; + + if ((n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS))) { + do { + for (i = 0; i < n; i++) { + char *str = NULL; + int verb = eventName(events[i],&str); + + xf86MsgVerb(X_INFO,verb,"PM Event received: %s\n",str); + DoApmEvent(events[i],FALSE); + switch (xf86PMConfirmEventToOs(fd,events[i])) { + case PM_WAIT: + wait = TRUE; + break; + case PM_CONTINUE: + wait = FALSE; + break; + case PM_FAILED: + DoApmEvent(events[i],TRUE); + wait = FALSE; + break; + default: + break; + } + } + if (wait) + n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS); + else + break; + } while (1); + } +} diff --git a/xorg-server/hw/xfree86/common/xf86PciInfo.h b/xorg-server/hw/xfree86/common/xf86PciInfo.h new file mode 100644 index 000000000..356c7db4d --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86PciInfo.h @@ -0,0 +1,731 @@ + +/* + * Copyright (c) 1995-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains macros for the PCI Vendor and Device IDs for video + * cards plus a few other things that are needed in drivers or elsewhere. + * This information is used in several ways: + * 1. It is used by drivers and/or other code. + * 2. It is used by the pciid2c.pl script to determine what vendor data to + * include in the pcidata module that the X server loads. + * 3. A side-effect of 2. affects how config-generation works for + * otherwise "unknown" cards. + * + * Don't add entries here for vendors that don't make video cards, + * or for non-video devices unless they're needed by a driver or elsewhere. + * A comprehensive set of PCI vendor, device and subsystem data is + * auto-generated from the ../etc/pci.ids file using the pciids2c.pl script, + * and is used in scanpci utility. Don't modify the pci.ids file. If + * new/corrected entries are required, add them to ../etc/extrapci.ids. + */ + +#ifndef _XF86_PCIINFO_H +#define _XF86_PCIINFO_H + +/* PCI Pseudo Vendor */ +#define PCI_VENDOR_GENERIC 0x00FF + +#define PCI_VENDOR_REAL3D 0x003D +#define PCI_VENDOR_COMPAQ 0x0E11 +#define PCI_VENDOR_ATI 0x1002 +#define PCI_VENDOR_AVANCE 0x1005 +#define PCI_VENDOR_TSENG 0x100C +#define PCI_VENDOR_NS 0x100B +#define PCI_VENDOR_WEITEK 0x100E +#define PCI_VENDOR_VIDEOLOGIC 0x1010 +#define PCI_VENDOR_DIGITAL 0x1011 +#define PCI_VENDOR_CIRRUS 0x1013 +#define PCI_VENDOR_AMD 0x1022 +#define PCI_VENDOR_TRIDENT 0x1023 +#define PCI_VENDOR_ALI 0x1025 +#define PCI_VENDOR_DELL 0x1028 +#define PCI_VENDOR_MATROX 0x102B +#define PCI_VENDOR_CHIPSTECH 0x102C +#define PCI_VENDOR_MIRO 0x1031 +#define PCI_VENDOR_NEC 0x1033 +#define PCI_VENDOR_SIS 0x1039 +#define PCI_VENDOR_HP 0x103C +#define PCI_VENDOR_SGS 0x104A +#define PCI_VENDOR_TI 0x104C +#define PCI_VENDOR_SONY 0x104D +#define PCI_VENDOR_OAK 0x104E +#define PCI_VENDOR_MOTOROLA 0x1057 +#define PCI_VENDOR_NUMNINE 0x105D +#define PCI_VENDOR_CYRIX 0x1078 +#define PCI_VENDOR_SUN 0x108E +#define PCI_VENDOR_DIAMOND 0x1092 +#define PCI_VENDOR_BROOKTREE 0x109E +#define PCI_VENDOR_NEOMAGIC 0x10C8 +#define PCI_VENDOR_NVIDIA 0x10DE +#define PCI_VENDOR_IMS 0x10E0 +#define PCI_VENDOR_INTEGRAPHICS 0x10EA +#define PCI_VENDOR_ALLIANCE 0x1142 +#define PCI_VENDOR_RENDITION 0x1163 +#define PCI_VENDOR_3DFX 0x121A +#define PCI_VENDOR_SMI 0x126F +#define PCI_VENDOR_TRITECH 0x1292 +#define PCI_VENDOR_NVIDIA_SGS 0x12D2 +#define PCI_VENDOR_VMWARE 0x15AD +#define PCI_VENDOR_AST 0x1A03 +#define PCI_VENDOR_3DLABS 0x3D3D +#define PCI_VENDOR_AVANCE_2 0x4005 +#define PCI_VENDOR_HERCULES 0x4843 +#define PCI_VENDOR_S3 0x5333 +#define PCI_VENDOR_INTEL 0x8086 +#define PCI_VENDOR_ARK 0xEDD8 + + +/* Generic */ +#define PCI_CHIP_VGA 0x0000 +#define PCI_CHIP_8514 0x0001 + +/* Real 3D */ +#define PCI_CHIP_I740_PCI 0x00D1 + +/* Compaq */ +#define PCI_CHIP_QV1280 0x3033 + +/* ATI */ +#define PCI_CHIP_RV380_3150 0x3150 +#define PCI_CHIP_RV380_3151 0x3151 +#define PCI_CHIP_RV380_3152 0x3152 +#define PCI_CHIP_RV380_3153 0x3153 +#define PCI_CHIP_RV380_3154 0x3154 +#define PCI_CHIP_RV380_3156 0x3156 +#define PCI_CHIP_RV380_3E50 0x3E50 +#define PCI_CHIP_RV380_3E51 0x3E51 +#define PCI_CHIP_RV380_3E52 0x3E52 +#define PCI_CHIP_RV380_3E53 0x3E53 +#define PCI_CHIP_RV380_3E54 0x3E54 +#define PCI_CHIP_RV380_3E56 0x3E56 +#define PCI_CHIP_RS100_4136 0x4136 +#define PCI_CHIP_RS200_4137 0x4137 +#define PCI_CHIP_R300_AD 0x4144 +#define PCI_CHIP_R300_AE 0x4145 +#define PCI_CHIP_R300_AF 0x4146 +#define PCI_CHIP_R300_AG 0x4147 +#define PCI_CHIP_R350_AH 0x4148 +#define PCI_CHIP_R350_AI 0x4149 +#define PCI_CHIP_R350_AJ 0x414A +#define PCI_CHIP_R350_AK 0x414B +#define PCI_CHIP_RV350_AP 0x4150 +#define PCI_CHIP_RV350_AQ 0x4151 +#define PCI_CHIP_RV360_AR 0x4152 +#define PCI_CHIP_RV350_AS 0x4153 +#define PCI_CHIP_RV350_AT 0x4154 +#define PCI_CHIP_RV350_4155 0x4155 +#define PCI_CHIP_RV350_AV 0x4156 +#define PCI_CHIP_MACH32 0x4158 +#define PCI_CHIP_RS250_4237 0x4237 +#define PCI_CHIP_R200_BB 0x4242 +#define PCI_CHIP_R200_BC 0x4243 +#define PCI_CHIP_RS100_4336 0x4336 +#define PCI_CHIP_RS200_4337 0x4337 +#define PCI_CHIP_MACH64CT 0x4354 +#define PCI_CHIP_MACH64CX 0x4358 +#define PCI_CHIP_RS250_4437 0x4437 +#define PCI_CHIP_MACH64ET 0x4554 +#define PCI_CHIP_MACH64GB 0x4742 +#define PCI_CHIP_MACH64GD 0x4744 +#define PCI_CHIP_MACH64GI 0x4749 +#define PCI_CHIP_MACH64GL 0x474C +#define PCI_CHIP_MACH64GM 0x474D +#define PCI_CHIP_MACH64GN 0x474E +#define PCI_CHIP_MACH64GO 0x474F +#define PCI_CHIP_MACH64GP 0x4750 +#define PCI_CHIP_MACH64GQ 0x4751 +#define PCI_CHIP_MACH64GR 0x4752 +#define PCI_CHIP_MACH64GS 0x4753 +#define PCI_CHIP_MACH64GT 0x4754 +#define PCI_CHIP_MACH64GU 0x4755 +#define PCI_CHIP_MACH64GV 0x4756 +#define PCI_CHIP_MACH64GW 0x4757 +#define PCI_CHIP_MACH64GX 0x4758 +#define PCI_CHIP_MACH64GY 0x4759 +#define PCI_CHIP_MACH64GZ 0x475A +#define PCI_CHIP_RV250_Id 0x4964 +#define PCI_CHIP_RV250_Ie 0x4965 +#define PCI_CHIP_RV250_If 0x4966 +#define PCI_CHIP_RV250_Ig 0x4967 +#define PCI_CHIP_R420_JH 0x4A48 +#define PCI_CHIP_R420_JI 0x4A49 +#define PCI_CHIP_R420_JJ 0x4A4A +#define PCI_CHIP_R420_JK 0x4A4B +#define PCI_CHIP_R420_JL 0x4A4C +#define PCI_CHIP_R420_JM 0x4A4D +#define PCI_CHIP_R420_JN 0x4A4E +#define PCI_CHIP_R420_4A4F 0x4A4F +#define PCI_CHIP_R420_JP 0x4A50 +#define PCI_CHIP_R420_4A54 0x4A54 +#define PCI_CHIP_R481_4B49 0x4B49 +#define PCI_CHIP_R481_4B4A 0x4B4A +#define PCI_CHIP_R481_4B4B 0x4B4B +#define PCI_CHIP_R481_4B4C 0x4B4C +#define PCI_CHIP_MACH64LB 0x4C42 +#define PCI_CHIP_MACH64LD 0x4C44 +#define PCI_CHIP_RAGE128LE 0x4C45 +#define PCI_CHIP_RAGE128LF 0x4C46 +#define PCI_CHIP_MACH64LG 0x4C47 +#define PCI_CHIP_MACH64LI 0x4C49 +#define PCI_CHIP_MACH64LM 0x4C4D +#define PCI_CHIP_MACH64LN 0x4C4E +#define PCI_CHIP_MACH64LP 0x4C50 +#define PCI_CHIP_MACH64LQ 0x4C51 +#define PCI_CHIP_MACH64LR 0x4C52 +#define PCI_CHIP_MACH64LS 0x4C53 +#define PCI_CHIP_RADEON_LW 0x4C57 +#define PCI_CHIP_RADEON_LX 0x4C58 +#define PCI_CHIP_RADEON_LY 0x4C59 +#define PCI_CHIP_RADEON_LZ 0x4C5A +#define PCI_CHIP_RV250_Ld 0x4C64 +#define PCI_CHIP_RV250_Le 0x4C65 +#define PCI_CHIP_RV250_Lf 0x4C66 +#define PCI_CHIP_RV250_Lg 0x4C67 +#define PCI_CHIP_RV250_Ln 0x4C6E +#define PCI_CHIP_RAGE128MF 0x4D46 +#define PCI_CHIP_RAGE128ML 0x4D4C +#define PCI_CHIP_R300_ND 0x4E44 +#define PCI_CHIP_R300_NE 0x4E45 +#define PCI_CHIP_R300_NF 0x4E46 +#define PCI_CHIP_R300_NG 0x4E47 +#define PCI_CHIP_R350_NH 0x4E48 +#define PCI_CHIP_R350_NI 0x4E49 +#define PCI_CHIP_R360_NJ 0x4E4A +#define PCI_CHIP_R350_NK 0x4E4B +#define PCI_CHIP_RV350_NP 0x4E50 +#define PCI_CHIP_RV350_NQ 0x4E51 +#define PCI_CHIP_RV350_NR 0x4E52 +#define PCI_CHIP_RV350_NS 0x4E53 +#define PCI_CHIP_RV350_NT 0x4E54 +#define PCI_CHIP_RV350_NV 0x4E56 +#define PCI_CHIP_RAGE128PA 0x5041 +#define PCI_CHIP_RAGE128PB 0x5042 +#define PCI_CHIP_RAGE128PC 0x5043 +#define PCI_CHIP_RAGE128PD 0x5044 +#define PCI_CHIP_RAGE128PE 0x5045 +#define PCI_CHIP_RAGE128PF 0x5046 +#define PCI_CHIP_RAGE128PG 0x5047 +#define PCI_CHIP_RAGE128PH 0x5048 +#define PCI_CHIP_RAGE128PI 0x5049 +#define PCI_CHIP_RAGE128PJ 0x504A +#define PCI_CHIP_RAGE128PK 0x504B +#define PCI_CHIP_RAGE128PL 0x504C +#define PCI_CHIP_RAGE128PM 0x504D +#define PCI_CHIP_RAGE128PN 0x504E +#define PCI_CHIP_RAGE128PO 0x504F +#define PCI_CHIP_RAGE128PP 0x5050 +#define PCI_CHIP_RAGE128PQ 0x5051 +#define PCI_CHIP_RAGE128PR 0x5052 +#define PCI_CHIP_RAGE128PS 0x5053 +#define PCI_CHIP_RAGE128PT 0x5054 +#define PCI_CHIP_RAGE128PU 0x5055 +#define PCI_CHIP_RAGE128PV 0x5056 +#define PCI_CHIP_RAGE128PW 0x5057 +#define PCI_CHIP_RAGE128PX 0x5058 +#define PCI_CHIP_RADEON_QD 0x5144 +#define PCI_CHIP_RADEON_QE 0x5145 +#define PCI_CHIP_RADEON_QF 0x5146 +#define PCI_CHIP_RADEON_QG 0x5147 +#define PCI_CHIP_R200_QH 0x5148 +#define PCI_CHIP_R200_QI 0x5149 +#define PCI_CHIP_R200_QJ 0x514A +#define PCI_CHIP_R200_QK 0x514B +#define PCI_CHIP_R200_QL 0x514C +#define PCI_CHIP_R200_QM 0x514D +#define PCI_CHIP_R200_QN 0x514E +#define PCI_CHIP_R200_QO 0x514F +#define PCI_CHIP_RV200_QW 0x5157 +#define PCI_CHIP_RV200_QX 0x5158 +#define PCI_CHIP_RV100_QY 0x5159 +#define PCI_CHIP_RV100_QZ 0x515A +#define PCI_CHIP_RN50_515E 0x515E +#define PCI_CHIP_RAGE128RE 0x5245 +#define PCI_CHIP_RAGE128RF 0x5246 +#define PCI_CHIP_RAGE128RG 0x5247 +#define PCI_CHIP_RAGE128RK 0x524B +#define PCI_CHIP_RAGE128RL 0x524C +#define PCI_CHIP_RAGE128SE 0x5345 +#define PCI_CHIP_RAGE128SF 0x5346 +#define PCI_CHIP_RAGE128SG 0x5347 +#define PCI_CHIP_RAGE128SH 0x5348 +#define PCI_CHIP_RAGE128SK 0x534B +#define PCI_CHIP_RAGE128SL 0x534C +#define PCI_CHIP_RAGE128SM 0x534D +#define PCI_CHIP_RAGE128SN 0x534E +#define PCI_CHIP_RAGE128TF 0x5446 +#define PCI_CHIP_RAGE128TL 0x544C +#define PCI_CHIP_RAGE128TR 0x5452 +#define PCI_CHIP_RAGE128TS 0x5453 +#define PCI_CHIP_RAGE128TT 0x5454 +#define PCI_CHIP_RAGE128TU 0x5455 +#define PCI_CHIP_RV370_5460 0x5460 +#define PCI_CHIP_RV370_5461 0x5461 +#define PCI_CHIP_RV370_5462 0x5462 +#define PCI_CHIP_RV370_5463 0x5463 +#define PCI_CHIP_RV370_5464 0x5464 +#define PCI_CHIP_RV370_5465 0x5465 +#define PCI_CHIP_RV370_5466 0x5466 +#define PCI_CHIP_RV370_5467 0x5467 +#define PCI_CHIP_R423_UH 0x5548 +#define PCI_CHIP_R423_UI 0x5549 +#define PCI_CHIP_R423_UJ 0x554A +#define PCI_CHIP_R423_UK 0x554B +#define PCI_CHIP_R430_554C 0x554C +#define PCI_CHIP_R430_554D 0x554D +#define PCI_CHIP_R430_554E 0x554E +#define PCI_CHIP_R430_554F 0x554F +#define PCI_CHIP_R423_5550 0x5550 +#define PCI_CHIP_R423_UQ 0x5551 +#define PCI_CHIP_R423_UR 0x5552 +#define PCI_CHIP_R423_UT 0x5554 +#define PCI_CHIP_RV410_564A 0x564A +#define PCI_CHIP_RV410_564B 0x564B +#define PCI_CHIP_RV410_564F 0x564F +#define PCI_CHIP_RV410_5652 0x5652 +#define PCI_CHIP_RV410_5653 0x5653 +#define PCI_CHIP_MACH64VT 0x5654 +#define PCI_CHIP_MACH64VU 0x5655 +#define PCI_CHIP_MACH64VV 0x5656 +#define PCI_CHIP_RS300_5834 0x5834 +#define PCI_CHIP_RS300_5835 0x5835 +#define PCI_CHIP_RS300_5836 0x5836 +#define PCI_CHIP_RS300_5837 0x5837 +#define PCI_CHIP_RS480_5954 0x5954 +#define PCI_CHIP_RS480_5955 0x5955 +#define PCI_CHIP_RV280_5960 0x5960 +#define PCI_CHIP_RV280_5961 0x5961 +#define PCI_CHIP_RV280_5962 0x5962 +#define PCI_CHIP_RV280_5964 0x5964 +#define PCI_CHIP_RV280_5965 0x5965 +#define PCI_CHIP_RN50_5969 0x5969 +#define PCI_CHIP_RS482_5974 0x5974 +#define PCI_CHIP_RS482_5975 0x5975 +#define PCI_CHIP_RS400_5A41 0x5A41 +#define PCI_CHIP_RS400_5A42 0x5A42 +#define PCI_CHIP_RC410_5A61 0x5A61 +#define PCI_CHIP_RC410_5A62 0x5A62 +#define PCI_CHIP_RV370_5B60 0x5B60 +#define PCI_CHIP_RV370_5B61 0x5B61 +#define PCI_CHIP_RV370_5B62 0x5B62 +#define PCI_CHIP_RV370_5B63 0x5B63 +#define PCI_CHIP_RV370_5B64 0x5B64 +#define PCI_CHIP_RV370_5B65 0x5B65 +#define PCI_CHIP_RV370_5B66 0x5B66 +#define PCI_CHIP_RV370_5B67 0x5B67 +#define PCI_CHIP_RV280_5C61 0x5C61 +#define PCI_CHIP_RV280_5C63 0x5C63 +#define PCI_CHIP_R430_5D48 0x5D48 +#define PCI_CHIP_R430_5D49 0x5D49 +#define PCI_CHIP_R430_5D4A 0x5D4A +#define PCI_CHIP_R480_5D4C 0x5D4C +#define PCI_CHIP_R480_5D4D 0x5D4D +#define PCI_CHIP_R480_5D4E 0x5D4E +#define PCI_CHIP_R480_5D4F 0x5D4F +#define PCI_CHIP_R480_5D50 0x5D50 +#define PCI_CHIP_R480_5D52 0x5D52 +#define PCI_CHIP_R423_5D57 0x5D57 +#define PCI_CHIP_RV410_5E48 0x5E48 +#define PCI_CHIP_RV410_5E4A 0x5E4A +#define PCI_CHIP_RV410_5E4B 0x5E4B +#define PCI_CHIP_RV410_5E4C 0x5E4C +#define PCI_CHIP_RV410_5E4D 0x5E4D +#define PCI_CHIP_RV410_5E4F 0x5E4F +#define PCI_CHIP_RS350_7834 0x7834 +#define PCI_CHIP_RS350_7835 0x7835 + +/* ASPEED Technology (AST) */ +#define PCI_CHIP_AST2000 0x2000 + +/* Avance Logic */ +#define PCI_CHIP_ALG2064 0x2064 +#define PCI_CHIP_ALG2301 0x2301 +#define PCI_CHIP_ALG2501 0x2501 + +/* Tseng */ +#define PCI_CHIP_ET4000_W32P_A 0x3202 +#define PCI_CHIP_ET4000_W32P_B 0x3205 +#define PCI_CHIP_ET4000_W32P_D 0x3206 +#define PCI_CHIP_ET4000_W32P_C 0x3207 +#define PCI_CHIP_ET6000 0x3208 +#define PCI_CHIP_ET6300 0x4702 + +/* Weitek */ +#define PCI_CHIP_P9000 0x9001 +#define PCI_CHIP_P9100 0x9100 + +/* Digital */ +#define PCI_CHIP_DC21050 0x0001 +#define PCI_CHIP_DEC21030 0x0004 +#define PCI_CHIP_TGA2 0x000D + +/* Cirrus Logic */ +#define PCI_CHIP_GD7548 0x0038 +#define PCI_CHIP_GD7555 0x0040 +#define PCI_CHIP_GD5430 0x00A0 +#define PCI_CHIP_GD5434_4 0x00A4 +#define PCI_CHIP_GD5434_8 0x00A8 +#define PCI_CHIP_GD5436 0x00AC +#define PCI_CHIP_GD5446 0x00B8 +#define PCI_CHIP_GD5480 0x00BC +#define PCI_CHIP_GD5462 0x00D0 +#define PCI_CHIP_GD5464 0x00D4 +#define PCI_CHIP_GD5464BD 0x00D5 +#define PCI_CHIP_GD5465 0x00D6 +#define PCI_CHIP_6729 0x1100 +#define PCI_CHIP_6832 0x1110 +#define PCI_CHIP_GD7542 0x1200 +#define PCI_CHIP_GD7543 0x1202 +#define PCI_CHIP_GD7541 0x1204 + +/* AMD */ +#define PCI_CHIP_AMD761 0x700E + +/* Trident */ +#define PCI_CHIP_2100 0x2100 +#define PCI_CHIP_8400 0x8400 +#define PCI_CHIP_8420 0x8420 +#define PCI_CHIP_8500 0x8500 +#define PCI_CHIP_8520 0x8520 +#define PCI_CHIP_8600 0x8600 +#define PCI_CHIP_8620 0x8620 +#define PCI_CHIP_8820 0x8820 +#define PCI_CHIP_9320 0x9320 +#define PCI_CHIP_9388 0x9388 +#define PCI_CHIP_9397 0x9397 +#define PCI_CHIP_939A 0x939A +#define PCI_CHIP_9420 0x9420 +#define PCI_CHIP_9440 0x9440 +#define PCI_CHIP_9520 0x9520 +#define PCI_CHIP_9525 0x9525 +#define PCI_CHIP_9540 0x9540 +#define PCI_CHIP_9660 0x9660 +#define PCI_CHIP_9750 0x9750 +#define PCI_CHIP_9850 0x9850 +#define PCI_CHIP_9880 0x9880 +#define PCI_CHIP_9910 0x9910 + +/* ALI */ +#define PCI_CHIP_M1435 0x1435 + +/* Matrox */ +#define PCI_CHIP_MGA2085 0x0518 +#define PCI_CHIP_MGA2064 0x0519 +#define PCI_CHIP_MGA1064 0x051A +#define PCI_CHIP_MGA2164 0x051B +#define PCI_CHIP_MGA2164_AGP 0x051F +#define PCI_CHIP_MGAG200_PCI 0x0520 +#define PCI_CHIP_MGAG200 0x0521 +#define PCI_CHIP_MGAG400 0x0525 +#define PCI_CHIP_MGAG550 0x2527 +#define PCI_CHIP_IMPRESSION 0x0D10 +#define PCI_CHIP_MGAG100_PCI 0x1000 +#define PCI_CHIP_MGAG100 0x1001 + +#define PCI_CARD_G400_TH 0x2179 +#define PCI_CARD_MILL_G200_SD 0xFF00 +#define PCI_CARD_PROD_G100_SD 0xFF01 +#define PCI_CARD_MYST_G200_SD 0xFF02 +#define PCI_CARD_MILL_G200_SG 0xFF03 +#define PCI_CARD_MARV_G200_SD 0xFF04 + +/* Chips & Tech */ +#define PCI_CHIP_65545 0x00D8 +#define PCI_CHIP_65548 0x00DC +#define PCI_CHIP_65550 0x00E0 +#define PCI_CHIP_65554 0x00E4 +#define PCI_CHIP_65555 0x00E5 +#define PCI_CHIP_68554 0x00F4 +#define PCI_CHIP_69000 0x00C0 +#define PCI_CHIP_69030 0x0C30 + +/* Miro */ +#define PCI_CHIP_ZR36050 0x5601 + +/* NEC */ +#define PCI_CHIP_POWER_VR 0x0046 + +/* SiS */ +#define PCI_CHIP_SG86C201 0x0001 +#define PCI_CHIP_SG86C202 0x0002 +#define PCI_CHIP_SG85C503 0x0008 +#define PCI_CHIP_SIS5597 0x0200 +/* Agregado por Carlos Duclos & Manuel Jander */ +#define PCI_CHIP_SIS82C204 0x0204 +#define PCI_CHIP_SG86C205 0x0205 +#define PCI_CHIP_SG86C215 0x0215 +#define PCI_CHIP_SG86C225 0x0225 +#define PCI_CHIP_85C501 0x0406 +#define PCI_CHIP_85C496 0x0496 +#define PCI_CHIP_85C601 0x0601 +#define PCI_CHIP_85C5107 0x5107 +#define PCI_CHIP_85C5511 0x5511 +#define PCI_CHIP_85C5513 0x5513 +#define PCI_CHIP_SIS5571 0x5571 +#define PCI_CHIP_SIS5597_2 0x5597 +#define PCI_CHIP_SIS530 0x6306 +#define PCI_CHIP_SIS6326 0x6326 +#define PCI_CHIP_SIS7001 0x7001 +#define PCI_CHIP_SIS300 0x0300 +#define PCI_CHIP_SIS315H 0x0310 +#define PCI_CHIP_SIS315PRO 0x0325 +#define PCI_CHIP_SIS330 0x0330 +#define PCI_CHIP_SIS630 0x6300 +#define PCI_CHIP_SIS540 0x5300 +#define PCI_CHIP_SIS550 0x5315 +#define PCI_CHIP_SIS650 0x6325 +#define PCI_CHIP_SIS730 0x7300 + +/* Hewlett-Packard */ +#define PCI_CHIP_ELROY 0x1054 +#define PCI_CHIP_ZX1_SBA 0x1229 +#define PCI_CHIP_ZX1_IOC 0x122A +#define PCI_CHIP_ZX1_LBA 0x122E /* a.k.a. Mercury */ +#define PCI_CHIP_ZX1_AGP8 0x12B4 /* a.k.a. QuickSilver */ +#define PCI_CHIP_ZX2_LBA 0x12EE +#define PCI_CHIP_ZX2_SBA 0x4030 +#define PCI_CHIP_ZX2_IOC 0x4031 +#define PCI_CHIP_ZX2_PCIE 0x4037 + +/* SGS */ +#define PCI_CHIP_STG2000 0x0008 +#define PCI_CHIP_STG1764 0x0009 +#define PCI_CHIP_KYROII 0x0010 + +/* Texas Instruments */ +#define PCI_CHIP_TI_PERMEDIA 0x3D04 +#define PCI_CHIP_TI_PERMEDIA2 0x3D07 + +/* Oak */ +#define PCI_CHIP_OTI107 0x0107 + +/* Number Nine */ +#define PCI_CHIP_I128 0x2309 +#define PCI_CHIP_I128_2 0x2339 +#define PCI_CHIP_I128_T2R 0x493D +#define PCI_CHIP_I128_T2R4 0x5348 + +/* Sun */ +#define PCI_CHIP_EBUS 0x1000 +#define PCI_CHIP_HAPPY_MEAL 0x1001 +#define PCI_CHIP_SIMBA 0x5000 +#define PCI_CHIP_PSYCHO 0x8000 +#define PCI_CHIP_SCHIZO 0x8001 +#define PCI_CHIP_SABRE 0xA000 +#define PCI_CHIP_HUMMINGBIRD 0xA001 + +/* BrookTree */ +#define PCI_CHIP_BT848 0x0350 +#define PCI_CHIP_BT849 0x0351 + +/* NVIDIA */ +#define PCI_CHIP_NV1 0x0008 +#define PCI_CHIP_DAC64 0x0009 +#define PCI_CHIP_TNT 0x0020 +#define PCI_CHIP_TNT2 0x0028 +#define PCI_CHIP_UTNT2 0x0029 +#define PCI_CHIP_VTNT2 0x002C +#define PCI_CHIP_UVTNT2 0x002D +#define PCI_CHIP_ITNT2 0x00A0 +#define PCI_CHIP_GEFORCE_256 0x0100 +#define PCI_CHIP_GEFORCE_DDR 0x0101 +#define PCI_CHIP_QUADRO 0x0103 +#define PCI_CHIP_GEFORCE2_MX 0x0110 +#define PCI_CHIP_GEFORCE2_MX_100 0x0111 +#define PCI_CHIP_GEFORCE2_GO 0x0112 +#define PCI_CHIP_QUADRO2_MXR 0x0113 +#define PCI_CHIP_GEFORCE2_GTS 0x0150 +#define PCI_CHIP_GEFORCE2_TI 0x0151 +#define PCI_CHIP_GEFORCE2_ULTRA 0x0152 +#define PCI_CHIP_QUADRO2_PRO 0x0153 +#define PCI_CHIP_GEFORCE4_MX_460 0x0170 +#define PCI_CHIP_GEFORCE4_MX_440 0x0171 +#define PCI_CHIP_GEFORCE4_MX_420 0x0172 +#define PCI_CHIP_GEFORCE4_440_GO 0x0174 +#define PCI_CHIP_GEFORCE4_420_GO 0x0175 +#define PCI_CHIP_GEFORCE4_420_GO_M32 0x0176 +#define PCI_CHIP_QUADRO4_500XGL 0x0178 +#define PCI_CHIP_GEFORCE4_440_GO_M64 0x0179 +#define PCI_CHIP_QUADRO4_200 0x017A +#define PCI_CHIP_QUADRO4_550XGL 0x017B +#define PCI_CHIP_QUADRO4_500_GOGL 0x017C +#define PCI_CHIP_IGEFORCE2 0x01A0 +#define PCI_CHIP_GEFORCE3 0x0200 +#define PCI_CHIP_GEFORCE3_TI_200 0x0201 +#define PCI_CHIP_GEFORCE3_TI_500 0x0202 +#define PCI_CHIP_QUADRO_DCC 0x0203 +#define PCI_CHIP_GEFORCE4_TI_4600 0x0250 +#define PCI_CHIP_GEFORCE4_TI_4400 0x0251 +#define PCI_CHIP_GEFORCE4_TI_4200 0x0253 +#define PCI_CHIP_QUADRO4_900XGL 0x0258 +#define PCI_CHIP_QUADRO4_750XGL 0x0259 +#define PCI_CHIP_QUADRO4_700XGL 0x025B + +/* NVIDIA & SGS */ +#define PCI_CHIP_RIVA128 0x0018 + +/* IMS */ +#define PCI_CHIP_IMSTT128 0x9128 +#define PCI_CHIP_IMSTT3D 0x9135 + +/* Alliance Semiconductor */ +#define PCI_CHIP_AP6410 0x3210 +#define PCI_CHIP_AP6422 0x6422 +#define PCI_CHIP_AT24 0x6424 +#define PCI_CHIP_AT3D 0x643D + +/* 3dfx Interactive */ +#define PCI_CHIP_VOODOO_GRAPHICS 0x0001 +#define PCI_CHIP_VOODOO2 0x0002 +#define PCI_CHIP_BANSHEE 0x0003 +#define PCI_CHIP_VOODOO3 0x0005 +#define PCI_CHIP_VOODOO5 0x0009 + +#define PCI_CARD_VOODOO3_2000 0x0036 +#define PCI_CARD_VOODOO3_3000 0x003A + +/* Rendition */ +#define PCI_CHIP_V1000 0x0001 +#define PCI_CHIP_V2x00 0x2000 + +/* 3Dlabs */ +#define PCI_CHIP_300SX 0x0001 +#define PCI_CHIP_500TX 0x0002 +#define PCI_CHIP_DELTA 0x0003 +#define PCI_CHIP_PERMEDIA 0x0004 +#define PCI_CHIP_MX 0x0006 +#define PCI_CHIP_PERMEDIA2 0x0007 +#define PCI_CHIP_GAMMA 0x0008 +#define PCI_CHIP_PERMEDIA2V 0x0009 +#define PCI_CHIP_PERMEDIA3 0x000A +#define PCI_CHIP_PERMEDIA4 0x000C +#define PCI_CHIP_R4 0x000D +#define PCI_CHIP_GAMMA2 0x000E +#define PCI_CHIP_R4ALT 0x0011 + +/* S3 */ +#define PCI_CHIP_PLATO 0x0551 +#define PCI_CHIP_VIRGE 0x5631 +#define PCI_CHIP_TRIO 0x8811 +#define PCI_CHIP_AURORA64VP 0x8812 +#define PCI_CHIP_TRIO64UVP 0x8814 +#define PCI_CHIP_VIRGE_VX 0x883D +#define PCI_CHIP_868 0x8880 +#define PCI_CHIP_928 0x88B0 +#define PCI_CHIP_864_0 0x88C0 +#define PCI_CHIP_864_1 0x88C1 +#define PCI_CHIP_964_0 0x88D0 +#define PCI_CHIP_964_1 0x88D1 +#define PCI_CHIP_968 0x88F0 +#define PCI_CHIP_TRIO64V2_DXGX 0x8901 +#define PCI_CHIP_PLATO_PX 0x8902 +#define PCI_CHIP_Trio3D 0x8904 +#define PCI_CHIP_VIRGE_DXGX 0x8A01 +#define PCI_CHIP_VIRGE_GX2 0x8A10 +#define PCI_CHIP_Trio3D_2X 0x8A13 +#define PCI_CHIP_SAVAGE3D 0x8A20 +#define PCI_CHIP_SAVAGE3D_MV 0x8A21 +#define PCI_CHIP_SAVAGE4 0x8A22 +#define PCI_CHIP_PROSAVAGE_PM 0x8A25 +#define PCI_CHIP_PROSAVAGE_KM 0x8A26 +#define PCI_CHIP_VIRGE_MX 0x8C01 +#define PCI_CHIP_VIRGE_MXPLUS 0x8C02 +#define PCI_CHIP_VIRGE_MXP 0x8C03 +#define PCI_CHIP_SAVAGE_MX_MV 0x8C10 +#define PCI_CHIP_SAVAGE_MX 0x8C11 +#define PCI_CHIP_SAVAGE_IX_MV 0x8C12 +#define PCI_CHIP_SAVAGE_IX 0x8C13 +#define PCI_CHIP_SUPSAV_MX128 0x8C22 +#define PCI_CHIP_SUPSAV_MX64 0x8C24 +#define PCI_CHIP_SUPSAV_MX64C 0x8C26 +#define PCI_CHIP_SUPSAV_IX128SDR 0x8C2A +#define PCI_CHIP_SUPSAV_IX128DDR 0x8C2B +#define PCI_CHIP_SUPSAV_IX64SDR 0x8C2C +#define PCI_CHIP_SUPSAV_IX64DDR 0x8C2D +#define PCI_CHIP_SUPSAV_IXCSDR 0x8C2E +#define PCI_CHIP_SUPSAV_IXCDDR 0x8C2F +#define PCI_CHIP_S3TWISTER_P 0x8D01 +#define PCI_CHIP_S3TWISTER_K 0x8D02 +#define PCI_CHIP_PROSAVAGE_DDR 0x8D03 +#define PCI_CHIP_PROSAVAGE_DDRK 0x8D04 +#define PCI_CHIP_SAVAGE2000 0x9102 + +/* ARK Logic */ +#define PCI_CHIP_1000PV 0xA091 +#define PCI_CHIP_2000PV 0xA099 +#define PCI_CHIP_2000MT 0xA0A1 +#define PCI_CHIP_2000MI 0xA0A9 + +/* Tritech Microelectronics */ +#define PCI_CHIP_TR25202 0xFC02 + +/* Neomagic */ +#define PCI_CHIP_NM2070 0x0001 +#define PCI_CHIP_NM2090 0x0002 +#define PCI_CHIP_NM2093 0x0003 +#define PCI_CHIP_NM2097 0x0083 +#define PCI_CHIP_NM2160 0x0004 +#define PCI_CHIP_NM2200 0x0005 +#define PCI_CHIP_NM2230 0x0025 +#define PCI_CHIP_NM2360 0x0006 +#define PCI_CHIP_NM2380 0x0016 + +/* Intel */ +#define PCI_CHIP_I815_BRIDGE 0x1130 +#define PCI_CHIP_I815 0x1132 +#define PCI_CHIP_82801_P2P 0x244E +#define PCI_CHIP_845_G_BRIDGE 0x2560 +#define PCI_CHIP_845_G 0x2562 +#define PCI_CHIP_I830_M_BRIDGE 0x3575 +#define PCI_CHIP_I830_M 0x3577 +#define PCI_CHIP_I810_BRIDGE 0x7120 +#define PCI_CHIP_I810 0x7121 +#define PCI_CHIP_I810_DC100_BRIDGE 0x7122 +#define PCI_CHIP_I810_DC100 0x7123 +#define PCI_CHIP_I810_E_BRIDGE 0x7124 +#define PCI_CHIP_I810_E 0x7125 +#define PCI_CHIP_I740_AGP 0x7800 +#define PCI_CHIP_460GX_PXB 0x84CB +#define PCI_CHIP_460GX_SAC 0x84E0 +#define PCI_CHIP_460GX_GXB_2 0x84E2 /* PCI function 2 */ +#define PCI_CHIP_460GX_WXB 0x84E6 +#define PCI_CHIP_460GX_GXB_1 0x84EA /* PCI function 1 */ + +/* Silicon Motion Inc. */ +#define PCI_CHIP_SMI910 0x0910 +#define PCI_CHIP_SMI810 0x0810 +#define PCI_CHIP_SMI820 0x0820 +#define PCI_CHIP_SMI710 0x0710 +#define PCI_CHIP_SMI712 0x0712 +#define PCI_CHIP_SMI720 0x0720 +#define PCI_CHIP_SMI731 0x0730 + +/* VMware */ +#define PCI_CHIP_VMWARE0405 0x0405 +#define PCI_CHIP_VMWARE0710 0x0710 + +#endif /* _XF86_PCIINFO_H */ diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h new file mode 100644 index 000000000..c0d240dd5 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Priv.h @@ -0,0 +1,200 @@ +/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains declarations for private XFree86 functions and variables, + * and definitions of private macros. + * + * "private" means not available to video drivers. + */ + +#ifndef _XF86PRIV_H +#define _XF86PRIV_H + +#include + +#include "xf86Privstr.h" +#include "propertyst.h" + +/* + * Parameters set ONLY from the command line options + * The global state of these things is held in xf86InfoRec (when appropriate). + */ +extern const char *xf86ConfigFile; +extern Bool xf86AllowMouseOpenFail; +#ifdef XF86VIDMODE +extern Bool xf86VidModeDisabled; +extern Bool xf86VidModeAllowNonLocal; +#endif +#ifdef XF86MISC +extern Bool xf86MiscModInDevDisabled; +extern Bool xf86MiscModInDevAllowNonLocal; +#endif +extern Bool xf86fpFlag; +extern Bool xf86coFlag; +extern Bool xf86sFlag; +extern Bool xf86bsEnableFlag; +extern Bool xf86bsDisableFlag; +extern Bool xf86silkenMouseDisableFlag; +extern Bool xf86acpiDisableFlag; +extern char *xf86LayoutName; +extern char *xf86ScreenName; +extern char *xf86PointerName; +extern char *xf86KeyboardName; +#ifdef KEEPBPP +extern int xf86Bpp; +#endif +extern int xf86FbBpp; +extern int xf86Depth; +extern Pix24Flags xf86Pix24; +extern rgb xf86Weight; +extern Bool xf86FlipPixels; +extern Bool xf86BestRefresh; +extern Gamma xf86Gamma; +extern char *xf86ServerName; +extern Bool xf86ShowUnresolved; +extern struct pci_slot_match xf86IsolateDevice; + +/* Other parameters */ + +extern xf86InfoRec xf86Info; +extern const char *xf86InputDeviceList; +extern const char *xf86ModulePath; +extern MessageType xf86ModPathFrom; +extern const char *xf86LogFile; +extern MessageType xf86LogFileFrom; +extern Bool xf86LogFileWasOpened; +extern serverLayoutRec xf86ConfigLayout; +extern Pix24Flags xf86ConfigPix24; + +extern unsigned short xf86MouseCflags[]; +extern Bool xf86SupportedMouseTypes[]; +extern int xf86NumMouseTypes; + +extern DriverPtr *xf86DriverList; +extern int xf86NumDrivers; +extern Bool xf86Resetting; +extern Bool xf86Initialising; +extern int xf86NumScreens; +extern xf86CurrentAccessRec xf86CurrentAccess; +extern const char *xf86VisualNames[]; +extern int xf86Verbose; /* verbosity level */ +extern int xf86LogVerbose; /* log file verbosity level */ +extern Bool xf86ProbeOnly; +extern Bool xf86DoProbe; +extern Bool xorgHWAccess; + +extern RootWinPropPtr *xf86RegisteredPropertiesTable; + +#ifndef DEFAULT_VERBOSE +#define DEFAULT_VERBOSE 0 +#endif +#ifndef DEFAULT_LOG_VERBOSE +#define DEFAULT_LOG_VERBOSE 3 +#endif +#ifndef DEFAULT_DPI +#define DEFAULT_DPI 96 +#endif + +#define DEFAULT_UNRESOLVED TRUE +#define DEFAULT_BEST_REFRESH FALSE + +/* Function Prototypes */ +#ifndef _NO_XF86_PROTOTYPES + +/* xf86Bus.c */ + +void xf86BusProbe(void); +void xf86ChangeBusIndex(int oldIndex, int newIndex); +void xf86AccessInit(void); +void xf86AccessEnter(void); +void xf86AccessLeave(void); +void xf86EntityInit(void); +void xf86EntityEnter(void); +void xf86EntityLeave(void); +void xf86AccessLeaveState(void); + +void xf86FindPrimaryDevice(void); +/* new RAC */ +void xf86ResourceBrokerInit(void); +void xf86PostProbe(void); +void xf86ClearEntityListForScreen(int scrnIndex); +void xf86AddDevToEntity(int entityIndex, GDevPtr dev); +extern void xf86PostPreInit(void); +extern void xf86PostScreenInit(void); + +/* xf86Config.c */ + +Bool xf86PathIsSafe(const char *path); + +/* xf86DefaultModes */ + +extern const DisplayModeRec xf86DefaultModes[]; +extern const int xf86NumDefaultModes; + +/* xf86DoProbe.c */ +void DoProbe(void); +void DoConfigure(void); + +/* xf86Events.c */ + +void xf86PostKbdEvent(unsigned key); +void xf86PostMseEvent(DeviceIntPtr device, int buttons, int dx, int dy); +void xf86Wakeup(pointer blockData, int err, pointer pReadmask); +void xf86SigHandler(int signo); +void xf86HandlePMEvents(int fd, pointer data); +extern int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num); +extern pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event); +void xf86GrabServerCallback(CallbackListPtr *, pointer, pointer); + +/* xf86Helper.c */ +void xf86LogInit(void); +void xf86CloseLog(void); + +/* xf86Init.c */ +Bool xf86LoadModules(char **list, pointer *optlist); +int xf86SetVerbosity(int verb); +int xf86SetLogVerbosity(int verb); +Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only ); + +/* xf86Lock.c */ + +#ifdef USE_XF86_SERVERLOCK +void xf86UnlockServer(void); +#endif + +/* xf86XKB.c */ + +void xf86InitXkb(void); + +/* xf86Xinput.c */ +extern xEvent *xf86Events; + +#endif /* _NO_XF86_PROTOTYPES */ + + +#endif /* _XF86PRIV_H */ diff --git a/xorg-server/hw/xfree86/common/xf86Privstr.h b/xorg-server/hw/xfree86/common/xf86Privstr.h new file mode 100644 index 000000000..8cab56ec8 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Privstr.h @@ -0,0 +1,209 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains definitions of the private XFree86 data structures/types. + * None of the data structures here should be used by video drivers. + */ + +#ifndef _XF86PRIVSTR_H +#define _XF86PRIVSTR_H + +#include "xf86Pci.h" +#include "xf86str.h" + +/* PCI probe flags */ + +typedef enum { + PCIProbe1 = 0, + PCIProbe2, + PCIForceConfig1, + PCIForceConfig2, + PCIForceNone, + PCIOsConfig +} PciProbeType; + +typedef enum { + LogNone, + LogFlush, + LogSync +} Log; + +typedef enum { + SKNever, + SKWhenNeeded, + SKAlways +} SpecialKeysInDDX; + +typedef enum { + XF86_GlxVisualsMinimal, + XF86_GlxVisualsTypical, + XF86_GlxVisualsAll, +} XF86_GlxVisuals; + +/* + * xf86InfoRec contains global parameters which the video drivers never + * need to access. Global parameters which the video drivers do need + * should be individual globals. + */ + +typedef struct { + int consoleFd; + int vtno; + Bool vtSysreq; + SpecialKeysInDDX ddxSpecialKeys; + + /* mouse part */ + DeviceIntPtr pMouse; +#ifdef XINPUT + pointer mouseLocal; +#endif + + /* event handler part */ + int lastEventTime; + Bool vtRequestsPending; + Bool inputPending; + Bool dontVTSwitch; + Bool dontZap; + Bool dontZoom; + Bool notrapSignals; /* don't exit cleanly - die at fault */ + Bool caughtSignal; + + /* graphics part */ + Bool sharedMonitor; + ScreenPtr currentScreen; +#if defined(CSRG_BASED) || defined(__FreeBSD_kernel__) + int screenFd; /* fd for memory mapped access to + * vga card */ + int consType; /* Which console driver? */ +#endif + + /* Other things */ + Bool allowMouseOpenFail; + Bool vidModeEnabled; /* VidMode extension enabled */ + Bool vidModeAllowNonLocal; /* allow non-local VidMode + * connections */ + Bool miscModInDevEnabled; /* Allow input devices to be + * changed */ + Bool miscModInDevAllowNonLocal; + PciProbeType pciFlags; + Pix24Flags pixmap24; + MessageType pix24From; +#ifdef __i386__ + Bool pc98; +#endif + Bool pmFlag; + Log log; + int estimateSizesAggressively; + Bool kbdCustomKeycodes; + Bool disableRandR; + MessageType randRFrom; + Bool aiglx; + MessageType aiglxFrom; + XF86_GlxVisuals glxVisuals; + MessageType glxVisualsFrom; + + Bool useDefaultFontPath; + MessageType useDefaultFontPathFrom; + Bool ignoreABI; + struct { + Bool disabled; /* enable/disable deactivating + * grabs or closing the + * connection to the grabbing + * client */ + ClientPtr override; /* client that disabled + * grab deactivation. + */ + Bool allowDeactivate; + Bool allowClosedown; + ServerGrabInfoRec server; + } grabInfo; + + Bool allowEmptyInput; /* Allow the server to start with no input + * devices. */ + Bool autoAddDevices; /* Whether to succeed NIDR, or ignore. */ + Bool autoEnableDevices; /* Whether to enable, or let the client + * control. */ + + Bool dri2; + MessageType dri2From; +} xf86InfoRec, *xf86InfoPtr; + +#ifdef DPMSExtension +/* Private info for DPMS */ +typedef struct { + CloseScreenProcPtr CloseScreen; + Bool Enabled; + int Flags; +} DPMSRec, *DPMSPtr; +#endif + +#ifdef XF86VIDMODE +/* Private info for Video Mode Extentsion */ +typedef struct { + DisplayModePtr First; + DisplayModePtr Next; + int Flags; + CloseScreenProcPtr CloseScreen; +} VidModeRec, *VidModePtr; +#endif + +/* Information for root window properties. */ +typedef struct _RootWinProp { + struct _RootWinProp * next; + char * name; + Atom type; + short format; + long size; + pointer data; +} RootWinProp, *RootWinPropPtr; + +/* private resource types */ +#define ResNoAvoid ResBios + +/* ISC's cc can't handle ~ of UL constants, so explicitly type cast them. */ +#define XLED1 ((unsigned long) 0x00000001) +#define XLED2 ((unsigned long) 0x00000002) +#define XLED3 ((unsigned long) 0x00000004) +#define XLED4 ((unsigned long) 0x00000008) +#define XCAPS ((unsigned long) 0x20000000) +#define XNUM ((unsigned long) 0x40000000) +#define XSCR ((unsigned long) 0x80000000) +#define XCOMP ((unsigned long) 0x00008000) + +/* BSD console driver types (consType) */ +#if defined(CSRG_BASED) || defined(__FreeBSD_kernel__) +#define PCCONS 0 +#define CODRV011 1 +#define CODRV01X 2 +#define SYSCONS 8 +#define PCVT 16 +#define WSCONS 32 +#endif + +#endif /* _XF86PRIVSTR_H */ diff --git a/xorg-server/hw/xfree86/common/xf86RandR.c b/xorg-server/hw/xfree86/common/xf86RandR.c new file mode 100644 index 000000000..a55b93d4c --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86RandR.c @@ -0,0 +1,457 @@ +/* + * + * Copyright © 2002 Keith Packard, member of The XFree86 Project, 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 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_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "mibank.h" +#include "globals.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86DDC.h" +#include "mipointer.h" +#include + +typedef struct _xf86RandRInfo { + CreateScreenResourcesProcPtr CreateScreenResources; + CloseScreenProcPtr CloseScreen; + int virtualX; + int virtualY; + int mmWidth; + int mmHeight; + Rotation rotation; +} XF86RandRInfoRec, *XF86RandRInfoPtr; + +static DevPrivateKey xf86RandRKey = NULL; + +#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey)) + +static int +xf86RandRModeRefresh (DisplayModePtr mode) +{ + if (mode->VRefresh) + return (int) (mode->VRefresh + 0.5); + else if (mode->Clock == 0) + return 0; + else + return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5); +} + +static Bool +xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations) +{ + RRScreenSizePtr pSize; + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + DisplayModePtr mode; + int refresh0 = 60; + xorgRRModeMM RRModeMM; + + *rotations = RR_Rotate_0; + + for (mode = scrp->modes; ; mode = mode->next) + { + int refresh = xf86RandRModeRefresh (mode); + + if (mode == scrp->modes) + refresh0 = refresh; + + RRModeMM.mode = mode; + RRModeMM.virtX = randrp->virtualX; + RRModeMM.virtY = randrp->virtualY; + RRModeMM.mmWidth = randrp->mmWidth; + RRModeMM.mmHeight = randrp->mmHeight; + + if(scrp->DriverFunc) { + (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM); + } + + pSize = RRRegisterSize (pScreen, + mode->HDisplay, mode->VDisplay, + RRModeMM.mmWidth, RRModeMM.mmHeight); + if (!pSize) + return FALSE; + RRRegisterRate (pScreen, pSize, refresh); + if (mode == scrp->currentMode && + mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY) + RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize); + if (mode->next == scrp->modes) + break; + } + if (scrp->currentMode->HDisplay != randrp->virtualX || + scrp->currentMode->VDisplay != randrp->virtualY) + { + mode = scrp->modes; + + RRModeMM.mode = NULL; + RRModeMM.virtX = randrp->virtualX; + RRModeMM.virtY = randrp->virtualY; + RRModeMM.mmWidth = randrp->mmWidth; + RRModeMM.mmHeight = randrp->mmHeight; + + if(scrp->DriverFunc) { + (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM); + } + + pSize = RRRegisterSize (pScreen, + randrp->virtualX, randrp->virtualY, + RRModeMM.mmWidth, RRModeMM.mmHeight); + if (!pSize) + return FALSE; + RRRegisterRate (pScreen, pSize, refresh0); + if (scrp->virtualX == randrp->virtualX && + scrp->virtualY == randrp->virtualY) + { + RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize); + } + } + + /* If there is driver support for randr, let it set our supported rotations */ + if(scrp->DriverFunc) { + xorgRRRotation RRRotation; + + RRRotation.RRRotations = *rotations; + if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation)) + return TRUE; + *rotations = RRRotation.RRRotations; + } + + return TRUE; +} + +static Bool +xf86RandRSetMode (ScreenPtr pScreen, + DisplayModePtr mode, + Bool useVirtual, + int mmWidth, + int mmHeight) +{ + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + int oldWidth = pScreen->width; + int oldHeight = pScreen->height; + int oldmmWidth = pScreen->mmWidth; + int oldmmHeight = pScreen->mmHeight; + int oldVirtualX = scrp->virtualX; + int oldVirtualY = scrp->virtualY; + WindowPtr pRoot = WindowTable[pScreen->myNum]; + Bool ret = TRUE; + + if (pRoot) + (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); + if (useVirtual) + { + scrp->virtualX = randrp->virtualX; + scrp->virtualY = randrp->virtualY; + } + else + { + scrp->virtualX = mode->HDisplay; + scrp->virtualY = mode->VDisplay; + } + + /* + * The DIX forgets the physical dimensions we passed into RRRegisterSize, so + * reconstruct them if possible. + */ + if(scrp->DriverFunc) { + xorgRRModeMM RRModeMM; + + RRModeMM.mode = mode; + RRModeMM.virtX = scrp->virtualX; + RRModeMM.virtY = scrp->virtualY; + RRModeMM.mmWidth = mmWidth; + RRModeMM.mmHeight = mmHeight; + + (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM); + + mmWidth = RRModeMM.mmWidth; + mmHeight = RRModeMM.mmHeight; + } + if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) + { + /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ + pScreen->width = scrp->virtualY; + pScreen->height = scrp->virtualX; + pScreen->mmWidth = mmHeight; + pScreen->mmHeight = mmWidth; + } + else + { + pScreen->width = scrp->virtualX; + pScreen->height = scrp->virtualY; + pScreen->mmWidth = mmWidth; + pScreen->mmHeight = mmHeight; + } + if (!xf86SwitchMode (pScreen, mode)) + { + pScreen->width = oldWidth; + pScreen->height = oldHeight; + pScreen->mmWidth = oldmmWidth; + pScreen->mmHeight = oldmmHeight; + scrp->virtualX = oldVirtualX; + scrp->virtualY = oldVirtualY; + ret = FALSE; + } + /* + * Make sure the layout is correct + */ + xf86ReconfigureLayout(); + + /* + * Make sure the whole screen is visible + */ + xf86SetViewport (pScreen, pScreen->width, pScreen->height); + xf86SetViewport (pScreen, 0, 0); + if (pRoot) + (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); + return ret; +} + +static Bool +xf86RandRSetConfig (ScreenPtr pScreen, + Rotation rotation, + int rate, + RRScreenSizePtr pSize) +{ + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + DisplayModePtr mode; + int px, py; + Bool useVirtual = FALSE; + Rotation oldRotation = randrp->rotation; + + miPointerPosition (&px, &py); + for (mode = scrp->modes; ; mode = mode->next) + { + if (mode->HDisplay == pSize->width && + mode->VDisplay == pSize->height && + (rate == 0 || xf86RandRModeRefresh (mode) == rate)) + break; + if (mode->next == scrp->modes) + { + if (pSize->width == randrp->virtualX && + pSize->height == randrp->virtualY) + { + mode = scrp->modes; + useVirtual = TRUE; + break; + } + return FALSE; + } + } + + if (randrp->rotation != rotation) { + + /* Have the driver do its thing. */ + if (scrp->DriverFunc) { + xorgRRRotation RRRotation; + RRRotation.RRConfig.rotation = rotation; + RRRotation.RRConfig.rate = rate; + RRRotation.RRConfig.width = pSize->width; + RRRotation.RRConfig.height = pSize->height; + + /* + * Currently we need to rely on HW support for rotation. + */ + if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation)) + return FALSE; + } else + return FALSE; + + randrp->rotation = rotation; + } + + if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) { + if(randrp->rotation != oldRotation) { + /* Have the driver undo its thing. */ + if (scrp->DriverFunc) { + xorgRRRotation RRRotation; + RRRotation.RRConfig.rotation = oldRotation; + RRRotation.RRConfig.rate = xf86RandRModeRefresh (scrp->currentMode); + RRRotation.RRConfig.width = scrp->virtualX; + RRRotation.RRConfig.height = scrp->virtualY; + (*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation); + } + + randrp->rotation = oldRotation; + } + return FALSE; + } + /* + * Move the cursor back where it belongs; SwitchMode repositions it + */ + if (pScreen == miPointerCurrentScreen ()) + { + px = (px >= pScreen->width ? (pScreen->width - 1) : px); + py = (py >= pScreen->height ? (pScreen->height - 1) : py); + + xf86SetViewport(pScreen, px, py); + + (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); + } + + return TRUE; +} + +/* + * Wait until the screen is initialized before whacking the + * sizes around; otherwise the screen pixmap will be allocated + * at the current mode size rather than the maximum size + */ +static Bool +xf86RandRCreateScreenResources (ScreenPtr pScreen) +{ + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); +#if 0 + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + DisplayModePtr mode; +#endif + + pScreen->CreateScreenResources = randrp->CreateScreenResources; + if (!(*pScreen->CreateScreenResources) (pScreen)) + return FALSE; + +#if 0 + mode = scrp->currentMode; + if (mode) + xf86RandRSetMode (pScreen, mode, TRUE); +#endif + + return TRUE; +} + +/* + * Reset size back to original + */ +static Bool +xf86RandRCloseScreen (int index, ScreenPtr pScreen) +{ + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + + scrp->virtualX = pScreen->width = randrp->virtualX; + scrp->virtualY = pScreen->height = randrp->virtualY; + scrp->currentMode = scrp->modes; + pScreen->CloseScreen = randrp->CloseScreen; + xfree (randrp); + dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL); + return (*pScreen->CloseScreen) (index, pScreen); +} + +_X_EXPORT Rotation +xf86GetRotation(ScreenPtr pScreen) +{ + if (xf86RandRKey == NULL) + return RR_Rotate_0; + + return XF86RANDRINFO(pScreen)->rotation; +} + +/* Function to change RandR's idea of the virtual screen size */ +_X_EXPORT Bool +xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen, + int newvirtX, int newvirtY, int newmmWidth, int newmmHeight, + Bool resetMode) +{ + XF86RandRInfoPtr randrp; + + if (xf86RandRKey == NULL) + return FALSE; + + randrp = XF86RANDRINFO(pScreen); + if (randrp == NULL) + return FALSE; + + if (newvirtX > 0) + randrp->virtualX = newvirtX; + + if (newvirtY > 0) + randrp->virtualY = newvirtY; + + if (newmmWidth > 0) + randrp->mmWidth = newmmWidth; + + if (newmmHeight > 0) + randrp->mmHeight = newmmHeight; + + /* This is only for during server start */ + if (resetMode) { + return (xf86RandRSetMode(pScreen, + XF86SCRNINFO(pScreen)->currentMode, + TRUE, + pScreen->mmWidth, pScreen->mmHeight)); + } + + return TRUE; +} + +Bool +xf86RandRInit (ScreenPtr pScreen) +{ + rrScrPrivPtr rp; + XF86RandRInfoPtr randrp; + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + +#ifdef PANORAMIX + /* XXX disable RandR when using Xinerama */ + if (!noPanoramiXExtension) + return TRUE; +#endif + + xf86RandRKey = &xf86RandRKey; + + randrp = xalloc (sizeof (XF86RandRInfoRec)); + if (!randrp) + return FALSE; + + if (!RRScreenInit (pScreen)) + { + xfree (randrp); + return FALSE; + } + rp = rrGetScrPriv(pScreen); + rp->rrGetInfo = xf86RandRGetInfo; + rp->rrSetConfig = xf86RandRSetConfig; + + randrp->virtualX = scrp->virtualX; + randrp->virtualY = scrp->virtualY; + randrp->mmWidth = pScreen->mmWidth; + randrp->mmHeight = pScreen->mmHeight; + + randrp->CreateScreenResources = pScreen->CreateScreenResources; + pScreen->CreateScreenResources = xf86RandRCreateScreenResources; + + randrp->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = xf86RandRCloseScreen; + + randrp->rotation = RR_Rotate_0; + + dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp); + return TRUE; +} + + diff --git a/xorg-server/hw/xfree86/common/xf86Resources.h b/xorg-server/hw/xfree86/common/xf86Resources.h new file mode 100644 index 000000000..15bd32c69 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Resources.h @@ -0,0 +1,137 @@ + +/* + * Copyright (c) 1999-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86_RESOURCES_H + +#define _XF86_RESOURCES_H + +#include "xf86str.h" + +#define _END {ResEnd,0,0} + +#define _VGA_EXCLUSIVE \ + {ResExcMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\ + {ResExcMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\ + {ResExcMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\ + {ResExcIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\ + {ResExcIoBlock | ResBios | ResBus, 0x03C0, 0x03DF} + +#define _VGA_SHARED \ + {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\ + {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\ + {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\ + {ResShrIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\ + {ResShrIoBlock | ResBios | ResBus, 0x03C0, 0x03DF} + +#define _VGA_SHARED_MEM \ + {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\ + {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\ + {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF} + +#define _VGA_SHARED_IO \ + {ResShrIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\ + {ResShrIoBlock | ResBios | ResBus, 0x03C0, 0x03DF} + +/* + * Exclusive unused VGA: resources unneeded but cannot be disabled. + * Like old Millennium. + */ +#define _VGA_EXCLUSIVE_UNUSED \ + {ResExcUusdMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\ + {ResExcUusdMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\ + {ResExcUusdMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\ + {ResExcUusdIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\ + {ResExcUusdIoBlock | ResBios | ResBus, 0x03C0, 0x03DF} + +/* + * Shared unused VGA: resources unneeded but cannot be disabled + * independently. This is used to determine if a device needs RAC. + */ +#define _VGA_SHARED_UNUSED \ + {ResShrUusdMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\ + {ResShrUusdMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\ + {ResShrUusdMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\ + {ResShrUusdIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\ + {ResShrUusdIoBlock | ResBios | ResBus, 0x03C0, 0x03DF} + +/* + * Sparse versions of the above for those adapters that respond to all ISA + * aliases of VGA ports. + */ +#define _VGA_EXCLUSIVE_SPARSE \ + {ResExcMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\ + {ResExcMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\ + {ResExcMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\ + {ResExcIoSparse | ResBios | ResBus, 0x03B0, 0x03F8},\ + {ResExcIoSparse | ResBios | ResBus, 0x03B8, 0x03FC},\ + {ResExcIoSparse | ResBios | ResBus, 0x03C0, 0x03E0} + +#define _VGA_SHARED_SPARSE \ + {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\ + {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\ + {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\ + {ResShrIoSparse | ResBios | ResBus, 0x03B0, 0x03F8},\ + {ResShrIoSparse | ResBios | ResBus, 0x03B8, 0x03FC},\ + {ResShrIoSparse | ResBios | ResBus, 0x03C0, 0x03E0} + +#define _8514_EXCLUSIVE \ + {ResExcIoSparse | ResBios | ResBus, 0x02E8, 0x03F8} + +#define _8514_SHARED \ + {ResShrIoSparse | ResBios | ResBus, 0x02E8, 0x03F8} + +/* Predefined resources */ +extern resRange resVgaExclusive[]; +extern resRange resVgaShared[]; +extern resRange resVgaIoShared[]; +extern resRange resVgaMemShared[]; +extern resRange resVgaUnusedExclusive[]; +extern resRange resVgaUnusedShared[]; +extern resRange resVgaSparseExclusive[]; +extern resRange resVgaSparseShared[]; +extern resRange res8514Exclusive[]; +extern resRange res8514Shared[]; + +/* Less misleading aliases for xf86SetOperatingState() */ +#define resVgaMem resVgaMemShared +#define resVgaIo resVgaIoShared +#define resVga resVgaShared + +/* Old style names */ +#define RES_EXCLUSIVE_VGA resVgaExclusive +#define RES_SHARED_VGA resVgaShared +#define RES_EXCLUSIVE_8514 res8514Exclusive +#define RES_SHARED_8514 res8514Shared + +#define _PCI_AVOID_PC_STYLE \ + {ResExcIoSparse | ResBus, 0x0100, 0x0300},\ + {ResExcIoSparse | ResBus, 0x0200, 0x0200},\ + {ResExcMemBlock | ResBus, 0xA0000,0xFFFFF} + +#define RES_UNDEFINED NULL +#endif diff --git a/xorg-server/hw/xfree86/common/xf86Version.h b/xorg-server/hw/xfree86/common/xf86Version.h new file mode 100644 index 000000000..b93ac7d23 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Version.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef XF86_VERSION_CURRENT + +#define XF86_VERSION_MAJOR 4 +#define XF86_VERSION_MINOR 3 +#define XF86_VERSION_PATCH 99 +#define XF86_VERSION_SNAP 902 + +/* This has five arguments for compatibilty reasons */ +#define XF86_VERSION_NUMERIC(major,minor,patch,snap,dummy) \ + (((major) * 10000000) + ((minor) * 100000) + ((patch) * 1000) + snap) + +#define XF86_GET_MAJOR_VERSION(vers) ((vers) / 10000000) +#define XF86_GET_MINOR_VERSION(vers) (((vers) % 10000000) / 100000) +#define XF86_GET_PATCH_VERSION(vers) (((vers) % 100000) / 1000) +#define XF86_GET_SNAP_VERSION(vers) ((vers) % 1000) + +/* Define these for compatibility. They'll be removed at some point. */ +#define XF86_VERSION_SUBMINOR XF86_VERSION_PATCH +#define XF86_VERSION_BETA 0 +#define XF86_VERSION_ALPHA XF86_VERSION_SNAP + +#define XF86_VERSION_CURRENT \ + XF86_VERSION_NUMERIC(XF86_VERSION_MAJOR, \ + XF86_VERSION_MINOR, \ + XF86_VERSION_PATCH, \ + XF86_VERSION_SNAP, \ + 0) + +#endif diff --git a/xorg-server/hw/xfree86/common/xf86Versions.c b/xorg-server/hw/xfree86/common/xf86Versions.c new file mode 100644 index 000000000..97a35590e --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Versions.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86.h" +#include "xf86OSmouse.h" + +static CARD32 registeredVersions[NUM_BUILTIN_IFS]; + +_X_EXPORT CARD32 +xf86GetBuiltinInterfaceVersion(BuiltinInterface iface, int flags) +{ + if (iface < 0 || iface >= NUM_BUILTIN_IFS) { + xf86Msg(X_ERROR, "xf86GetBuiltinInterfaceVersion: Unexpected interface" + "query: %d\n", iface); + return 0; + } + + if (registeredVersions[iface]) + return registeredVersions[iface]; + + /* Most built-in interfaces are handled this way. */ + switch (iface) { + case BUILTIN_IF_OSMOUSE: + return OS_MOUSE_VERSION_CURRENT; + default: + xf86Msg(X_ERROR, "xf86GetBuiltinInterfaceVersion: internal error: " + "interface %d not handled\n", iface); + return 0; + } +} + +_X_EXPORT Bool +xf86RegisterBuiltinInterfaceVersion(BuiltinInterface iface, CARD32 version, + int flags) +{ + if (iface < 0 || iface >= NUM_BUILTIN_IFS) { + xf86Msg(X_ERROR, "xf86RegisterBuiltinInterfaceVersion: " + "unexpected interface number: %d\n", iface); + return FALSE; + } + if (version == 0) { + xf86Msg(X_ERROR, "xf86RegisterBuiltinInterfaceVersion: " + "versions must be greater than zero\n"); + return FALSE; + } + registeredVersions[iface] = version; + return TRUE; +} + diff --git a/xorg-server/hw/xfree86/common/xf86VidMode.c b/xorg-server/hw/xfree86/common/xf86VidMode.c new file mode 100644 index 000000000..9260bb57b --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86VidMode.c @@ -0,0 +1,672 @@ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the VidMode functions required by the extension. + * These have been added to avoid the need for the higher level extension + * code to access the private XFree86 data structures directly. Wherever + * possible this code uses the functions in xf86Mode.c to do the work, + * so that two version of code that do similar things don't have to be + * maintained. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +#ifdef XF86VIDMODE +#include "vidmodeproc.h" +#include "xf86cmap.h" + +static DevPrivateKey VidModeKey = NULL; +static int VidModeCount = 0; +static Bool VidModeClose(int i, ScreenPtr pScreen); + +#define VMPTR(p) ((VidModePtr)dixLookupPrivate(&(p)->devPrivates, VidModeKey)) + +#endif + +#ifdef DEBUG +# define DEBUG_P(x) ErrorF(x"\n"); +#else +# define DEBUG_P(x) /**/ +#endif + +_X_EXPORT Bool +VidModeExtensionInit(ScreenPtr pScreen) +{ +#ifdef XF86VIDMODE + VidModePtr pVidMode; + + if (!xf86GetVidModeEnabled()) { + DEBUG_P("!xf86GetVidModeEnabled()"); + return FALSE; + } + + VidModeKey = &VidModeKey; + + if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey, + xcalloc(sizeof(VidModeRec), 1))) { + DEBUG_P("xcalloc failed"); + return FALSE; + } + + pVidMode = VMPTR(pScreen); + pVidMode->Flags = 0; + pVidMode->Next = NULL; + pVidMode->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = VidModeClose; + VidModeCount++; + return TRUE; +#else + DEBUG_P("no vidmode extension"); + return FALSE; +#endif +} + + +#ifdef XF86VIDMODE + +static Bool +VidModeClose(int i, ScreenPtr pScreen) +{ + VidModePtr pVidMode = VMPTR(pScreen); + + /* This shouldn't happen */ + if (!pVidMode) + return FALSE; + + pScreen->CloseScreen = pVidMode->CloseScreen; + + if (--VidModeCount == 0) { + xfree(dixLookupPrivate(&pScreen->devPrivates, VidModeKey)); + dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL); + VidModeKey = NULL; + } + return pScreen->CloseScreen(i, pScreen); +} + +Bool +VidModeAvailable(int scrnIndex) +{ + ScrnInfoPtr pScrn; + VidModePtr pVidMode; + + if (VidModeKey == NULL) { + DEBUG_P("VidModeKey == NULL"); + return FALSE; + } + + pScrn = xf86Screens[scrnIndex]; + if (pScrn == NULL) { + DEBUG_P("pScrn == NULL"); + return FALSE; + } + + pVidMode = VMPTR(pScrn->pScreen); + if (pVidMode) + return TRUE; + else { + DEBUG_P("pVidMode == NULL"); + return FALSE; + } +} + +_X_EXPORT Bool +VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + + if (pScrn->currentMode) { + *mode = (pointer)(pScrn->currentMode); + *dotClock = pScrn->currentMode->Clock; + + return TRUE; + } + return FALSE; +} + +_X_EXPORT int +VidModeGetDotClock(int scrnIndex, int Clock) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return 0; + + pScrn = xf86Screens[scrnIndex]; + if ((pScrn->progClock) || (Clock >= MAXCLOCKS)) + return Clock; + else + return pScrn->clock[Clock]; +} + +_X_EXPORT int +VidModeGetNumOfClocks(int scrnIndex, Bool *progClock) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return 0; + + pScrn = xf86Screens[scrnIndex]; + if (pScrn->progClock){ + *progClock = TRUE; + return 0; + } else { + *progClock = FALSE; + return pScrn->numClocks; + } +} + +_X_EXPORT Bool +VidModeGetClocks(int scrnIndex, int *Clocks) +{ + ScrnInfoPtr pScrn; + int i; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + + if (pScrn->progClock) + return FALSE; + + for (i = 0; i < pScrn->numClocks; i++) + *Clocks++ = pScrn->clock[i]; + + return TRUE; +} + + +_X_EXPORT Bool +VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock) +{ + ScrnInfoPtr pScrn; + VidModePtr pVidMode; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + pVidMode = VMPTR(pScrn->pScreen); + pVidMode->First = pScrn->modes; + pVidMode->Next = pVidMode->First->next; + + if (pVidMode->First->status == MODE_OK) { + *mode = (pointer)(pVidMode->First); + *dotClock = VidModeGetDotClock(scrnIndex, pVidMode->First->Clock); + return TRUE; + } + + return VidModeGetNextModeline(scrnIndex, mode, dotClock); +} + +_X_EXPORT Bool +VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock) +{ + ScrnInfoPtr pScrn; + VidModePtr pVidMode; + DisplayModePtr p; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + pVidMode = VMPTR(pScrn->pScreen); + + for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) { + if (p->status == MODE_OK) { + pVidMode->Next = p->next; + *mode = (pointer)p; + *dotClock = VidModeGetDotClock(scrnIndex, p->Clock); + return TRUE; + } + } + + return FALSE; +} + +_X_EXPORT Bool +VidModeDeleteModeline(int scrnIndex, pointer mode) +{ + ScrnInfoPtr pScrn; + + if ((mode == NULL) || (!VidModeAvailable(scrnIndex))) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + xf86DeleteMode(&(pScrn->modes), (DisplayModePtr)mode); + return TRUE; +} + +_X_EXPORT Bool +VidModeZoomViewport(int scrnIndex, int zoom) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + xf86ZoomViewport(pScrn->pScreen, zoom); + return TRUE; +} + +_X_EXPORT Bool +VidModeSetViewPort(int scrnIndex, int x, int y) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + pScrn->frameX0 = min( max(x, 0), + pScrn->virtualX - pScrn->currentMode->HDisplay ); + pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay - 1; + pScrn->frameY0 = min( max(y, 0), + pScrn->virtualY - pScrn->currentMode->VDisplay ); + pScrn->frameY1 = pScrn->frameY0 + pScrn->currentMode->VDisplay - 1; + if (pScrn->AdjustFrame != NULL) + (pScrn->AdjustFrame)(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + +_X_EXPORT Bool +VidModeGetViewPort(int scrnIndex, int *x, int *y) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + *x = pScrn->frameX0; + *y = pScrn->frameY0; + return TRUE; +} + +_X_EXPORT Bool +VidModeSwitchMode(int scrnIndex, pointer mode) +{ + ScrnInfoPtr pScrn; + DisplayModePtr pTmpMode; + Bool retval; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + /* save in case we fail */ + pTmpMode = pScrn->currentMode; + /* Force a mode switch */ + pScrn->currentMode = NULL; + retval = xf86SwitchMode(pScrn->pScreen, mode); + /* we failed: restore it */ + if (retval == FALSE) + pScrn->currentMode = pTmpMode; + return retval; +} + +_X_EXPORT Bool +VidModeLockZoom(int scrnIndex, Bool lock) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + + if (xf86Info.dontZoom) + return FALSE; + + xf86LockZoom(pScrn->pScreen, lock); + return TRUE; +} + +_X_EXPORT Bool +VidModeGetMonitor(int scrnIndex, pointer *monitor) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + *monitor = (pointer)(pScrn->monitor); + + return TRUE; +} + +_X_EXPORT ModeStatus +VidModeCheckModeForMonitor(int scrnIndex, pointer mode) +{ + ScrnInfoPtr pScrn; + + if ((mode == NULL) || (!VidModeAvailable(scrnIndex))) + return MODE_ERROR; + + pScrn = xf86Screens[scrnIndex]; + + return xf86CheckModeForMonitor((DisplayModePtr)mode, pScrn->monitor); +} + +_X_EXPORT ModeStatus +VidModeCheckModeForDriver(int scrnIndex, pointer mode) +{ + ScrnInfoPtr pScrn; + + if ((mode == NULL) || (!VidModeAvailable(scrnIndex))) + return MODE_ERROR; + + pScrn = xf86Screens[scrnIndex]; + + return xf86CheckModeForDriver(pScrn, (DisplayModePtr)mode, 0); +} + +_X_EXPORT void +VidModeSetCrtcForMode(int scrnIndex, pointer mode) +{ + ScrnInfoPtr pScrn; + DisplayModePtr ScreenModes; + + if ((mode == NULL) || (!VidModeAvailable(scrnIndex))) + return; + + /* Ugly hack so that the xf86Mode.c function can be used without change */ + pScrn = xf86Screens[scrnIndex]; + ScreenModes = pScrn->modes; + pScrn->modes = (DisplayModePtr)mode; + + xf86SetCrtcForModes(pScrn, pScrn->adjustFlags); + pScrn->modes = ScreenModes; + return; +} + +_X_EXPORT Bool +VidModeAddModeline(int scrnIndex, pointer mode) +{ + ScrnInfoPtr pScrn; + + if ((mode == NULL) || (!VidModeAvailable(scrnIndex))) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + + ((DisplayModePtr)mode)->name = strdup(""); /* freed by deletemode */ + ((DisplayModePtr)mode)->status = MODE_OK; + ((DisplayModePtr)mode)->next = pScrn->modes->next; + ((DisplayModePtr)mode)->prev = pScrn->modes; + pScrn->modes->next = (DisplayModePtr)mode; + if( ((DisplayModePtr)mode)->next != NULL ) + ((DisplayModePtr)mode)->next->prev = (DisplayModePtr)mode; + + return TRUE; +} + +_X_EXPORT int +VidModeGetNumOfModes(int scrnIndex) +{ + pointer mode = NULL; + int dotClock= 0, nummodes = 0; + + if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock)) + return nummodes; + + do { + nummodes++; + if (!VidModeGetNextModeline(scrnIndex, &mode, &dotClock)) + return nummodes; + } while (TRUE); +} + +_X_EXPORT Bool +VidModeSetGamma(int scrnIndex, float red, float green, float blue) +{ + ScrnInfoPtr pScrn; + Gamma gamma; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + gamma.red = red; + gamma.green = green; + gamma.blue = blue; + if (xf86ChangeGamma(pScrn->pScreen, gamma) != Success) + return FALSE; + else + return TRUE; +} + +_X_EXPORT Bool +VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + *red = pScrn->gamma.red; + *green = pScrn->gamma.green; + *blue = pScrn->gamma.blue; + return TRUE; +} + +_X_EXPORT Bool +VidModeSetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + xf86ChangeGammaRamp(pScrn->pScreen, size, r, g, b); + return TRUE; +} + +_X_EXPORT Bool +VidModeGetGammaRamp(int scrnIndex, int size, CARD16 *r, CARD16 *g, CARD16 *b) +{ + ScrnInfoPtr pScrn; + + if (!VidModeAvailable(scrnIndex)) + return FALSE; + + pScrn = xf86Screens[scrnIndex]; + xf86GetGammaRamp(pScrn->pScreen, size, r, g, b); + return TRUE; +} + +_X_EXPORT int +VidModeGetGammaRampSize(int scrnIndex) +{ + if (!VidModeAvailable(scrnIndex)) + return 0; + + return xf86GetGammaRampSize(xf86Screens[scrnIndex]->pScreen); +} + +_X_EXPORT pointer +VidModeCreateMode(void) +{ + DisplayModePtr mode; + + mode = xalloc(sizeof(DisplayModeRec)); + if (mode != NULL) { + mode->name = ""; + mode->VScan = 1; /* divides refresh rate. default = 1 */ + mode->Private = NULL; + mode->next = mode; + mode->prev = mode; + } + return mode; +} + +_X_EXPORT void +VidModeCopyMode(pointer modefrom, pointer modeto) +{ + memcpy(modeto, modefrom, sizeof(DisplayModeRec)); +} + + +_X_EXPORT int +VidModeGetModeValue(pointer mode, int valtyp) +{ + int ret = 0; + + switch (valtyp) { + case VIDMODE_H_DISPLAY: + ret = ((DisplayModePtr) mode)->HDisplay; + break; + case VIDMODE_H_SYNCSTART: + ret = ((DisplayModePtr)mode)->HSyncStart; + break; + case VIDMODE_H_SYNCEND: + ret = ((DisplayModePtr)mode)->HSyncEnd; + break; + case VIDMODE_H_TOTAL: + ret = ((DisplayModePtr)mode)->HTotal; + break; + case VIDMODE_H_SKEW: + ret = ((DisplayModePtr)mode)->HSkew; + break; + case VIDMODE_V_DISPLAY: + ret = ((DisplayModePtr)mode)->VDisplay; + break; + case VIDMODE_V_SYNCSTART: + ret = ((DisplayModePtr)mode)->VSyncStart; + break; + case VIDMODE_V_SYNCEND: + ret = ((DisplayModePtr)mode)->VSyncEnd; + break; + case VIDMODE_V_TOTAL: + ret = ((DisplayModePtr)mode)->VTotal; + break; + case VIDMODE_FLAGS: + ret = ((DisplayModePtr)mode)->Flags; + break; + case VIDMODE_CLOCK: + ret = ((DisplayModePtr)mode)->Clock; + break; + } + return ret; +} + +_X_EXPORT void +VidModeSetModeValue(pointer mode, int valtyp, int val) +{ + switch (valtyp) { + case VIDMODE_H_DISPLAY: + ((DisplayModePtr)mode)->HDisplay = val; + break; + case VIDMODE_H_SYNCSTART: + ((DisplayModePtr)mode)->HSyncStart = val; + break; + case VIDMODE_H_SYNCEND: + ((DisplayModePtr)mode)->HSyncEnd = val; + break; + case VIDMODE_H_TOTAL: + ((DisplayModePtr)mode)->HTotal = val; + break; + case VIDMODE_H_SKEW: + ((DisplayModePtr)mode)->HSkew = val; + break; + case VIDMODE_V_DISPLAY: + ((DisplayModePtr)mode)->VDisplay = val; + break; + case VIDMODE_V_SYNCSTART: + ((DisplayModePtr)mode)->VSyncStart = val; + break; + case VIDMODE_V_SYNCEND: + ((DisplayModePtr)mode)->VSyncEnd = val; + break; + case VIDMODE_V_TOTAL: + ((DisplayModePtr)mode)->VTotal = val; + break; + case VIDMODE_FLAGS: + ((DisplayModePtr)mode)->Flags = val; + break; + case VIDMODE_CLOCK: + ((DisplayModePtr)mode)->Clock = val; + break; + } + return; +} + +_X_EXPORT vidMonitorValue +VidModeGetMonitorValue(pointer monitor, int valtyp, int indx) +{ + vidMonitorValue ret; + + switch (valtyp) { + case VIDMODE_MON_VENDOR: + ret.ptr = (((MonPtr)monitor)->vendor); + break; + case VIDMODE_MON_MODEL: + ret.ptr = (((MonPtr)monitor)->model); + break; + case VIDMODE_MON_NHSYNC: + ret.i = ((MonPtr)monitor)->nHsync; + break; + case VIDMODE_MON_NVREFRESH: + ret.i = ((MonPtr)monitor)->nVrefresh; + break; + case VIDMODE_MON_HSYNC_LO: + ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].lo); + break; + case VIDMODE_MON_HSYNC_HI: + ret.f = (100.0 * ((MonPtr)monitor)->hsync[indx].hi); + break; + case VIDMODE_MON_VREFRESH_LO: + ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].lo); + break; + case VIDMODE_MON_VREFRESH_HI: + ret.f = (100.0 * ((MonPtr)monitor)->vrefresh[indx].hi); + break; + } + return ret; +} + + +#endif /* XF86VIDMODE */ diff --git a/xorg-server/hw/xfree86/common/xf86XKB.c b/xorg-server/hw/xfree86/common/xf86XKB.c new file mode 100644 index 000000000..11694544a --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86XKB.c @@ -0,0 +1,80 @@ +/************************************************************ +Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting +documentation, and that the name of Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ +/* + * Copyright (c) 1994-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#define NEED_EVENTS 1 +#include +#include +#include +#include "inputstr.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSlib.h" + +#include + +void +xf86InitXkb(void) +{ +} diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c new file mode 100644 index 000000000..710e787fd --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Xinput.c @@ -0,0 +1,865 @@ +/* + * Copyright 1995-1999 by Frederic Lepied, France. + * + * 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 Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 2000-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#ifdef XINPUT +#include +#include +#endif +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Xinput.h" +#ifdef XINPUT +#include "XIstubs.h" +#include "xf86Optrec.h" +#endif +#include "mipointer.h" +#include "xf86InPriv.h" + +#ifdef DPMSExtension +#define DPMS_SERVER +#include +#include "dpmsproc.h" +#endif + +#include "exevents.h" /* AddInputDevice */ +#include "exglobals.h" + +#define EXTENSION_PROC_ARGS void * +#include "extnsionst.h" + +#include "windowstr.h" /* screenIsSaved */ + +#include + +#include + +#include "mi.h" + +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +xEvent *xf86Events = NULL; + +static Bool +xf86SendDragEvents(DeviceIntPtr device) +{ + LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate; + + if (device->button && device->button->buttonsDown > 0) + return (local->flags & XI86_SEND_DRAG_EVENTS); + else + return (TRUE); +} + +/*********************************************************************** + * + * xf86ProcessCommonOptions -- + * + * Process global options. + * + *********************************************************************** + */ +_X_EXPORT void +xf86ProcessCommonOptions(LocalDevicePtr local, + pointer list) +{ + if (!xf86SetBoolOption(list, "AlwaysCore", 1) || + !xf86SetBoolOption(list, "SendCoreEvents", 1) || + !xf86SetBoolOption(list, "CorePointer", 1) || + !xf86SetBoolOption(list, "CoreKeyboard", 1)) { + xf86Msg(X_CONFIG, "%s: doesn't report core events\n", local->name); + } else { + local->flags |= XI86_ALWAYS_CORE; + xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name); + } + + if (xf86SetBoolOption(list, "SendDragEvents", 1)) { + local->flags |= XI86_SEND_DRAG_EVENTS; + } else { + xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name); + } + + /* Backwards compatibility. */ + local->history_size = GetMotionHistorySize(); + /* Preallocate xEvent store */ + if (!xf86Events) + xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); + if (!xf86Events) + FatalError("Couldn't allocate event store\n"); +} + +/*********************************************************************** + * + * xf86ActivateDevice -- + * + * Initialize an input device. + * + *********************************************************************** + */ +_X_EXPORT void +xf86ActivateDevice(LocalDevicePtr local) +{ + DeviceIntPtr dev; + + if (local->flags & XI86_CONFIGURED) { + dev = AddInputDevice(local->device_control, TRUE); + + if (dev == NULL) + FatalError("Too many input devices"); + + local->atom = MakeAtom(local->type_name, + strlen(local->type_name), + TRUE); + AssignTypeAndName(dev, local->atom, local->name); + dev->public.devicePrivate = (pointer) local; + local->dev = dev; + + dev->coreEvents = local->flags & XI86_ALWAYS_CORE; + RegisterOtherDevice(dev); + +#ifdef XKB + if (!noXkbExtension) + XkbSetExtension(dev, ProcessKeyboardEvent); +#endif + + if (serverGeneration == 1) + xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n", + local->name, local->type_name); + } +} + + +#ifdef XINPUT +/*********************************************************************** + * + * Caller: ProcXOpenDevice + * + * This is the implementation-dependent routine to open an input device. + * Some implementations open all input devices when the server is first + * initialized, and never close them. Other implementations open only + * the X pointer and keyboard devices during server initialization, + * and only open other input devices when some client makes an + * XOpenDevice request. This entry point is for the latter type of + * implementation. + * + * If the physical device is not already open, do it here. In this case, + * you need to keep track of the fact that one or more clients has the + * device open, and physically close it when the last client that has + * it open does an XCloseDevice. + * + * The default implementation is to do nothing (assume all input devices + * are opened during X server initialization and kept open). + * + *********************************************************************** + */ + +void +OpenInputDevice(DeviceIntPtr dev, + ClientPtr client, + int *status) +{ + if (!dev->inited) + ActivateDevice(dev); + + *status = Success; +} + +void +CloseInputDevice(DeviceIntPtr dev, + ClientPtr client) +{ +} + +/**************************************************************************** + * + * Caller: ProcXSetDeviceMode + * + * Change the mode of an extension device. + * This function is used to change the mode of a device from reporting + * relative motion to reporting absolute positional information, and + * vice versa. + * The default implementation below is that no such devices are supported. + * + *********************************************************************** + */ + +int +SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode) +{ + LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; + + if (local->switch_mode) { + return (*local->switch_mode)(client, dev, mode); + } + else + return BadMatch; +} + + +/*********************************************************************** + * + * Caller: ProcXSetDeviceValuators + * + * Set the value of valuators on an extension input device. + * This function is used to set the initial value of valuators on + * those input devices that are capable of reporting either relative + * motion or an absolute position, and allow an initial position to be set. + * The default implementation below is that no such devices are supported. + * + *********************************************************************** + */ + +int +SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators, + int first_valuator, int num_valuators) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + + if (local->set_device_valuators) + return (*local->set_device_valuators)(local, valuators, first_valuator, + num_valuators); + + return BadMatch; +} + + +/*********************************************************************** + * + * Caller: ProcXChangeDeviceControl + * + * Change the specified device controls on an extension input device. + * + *********************************************************************** + */ + +int +ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control) +{ + LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; + + if (!local->control_proc) { + switch (control->control) { + case DEVICE_CORE: + case DEVICE_RESOLUTION: + case DEVICE_ABS_CALIB: + case DEVICE_ABS_AREA: + case DEVICE_ENABLE: + return Success; + default: + return BadMatch; + } + } + else { + return (*local->control_proc)(local, control); + } +} + +void +AddOtherInputDevices() +{ +} +#endif + +int +NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev) +{ + IDevRec *idev = NULL; + InputDriverPtr drv = NULL; + InputInfoPtr pInfo = NULL; + InputOption *option = NULL; + DeviceIntPtr dev = NULL; + int rval = Success; + int is_auto = 0; + + idev = xcalloc(sizeof(*idev), 1); + if (!idev) + return BadAlloc; + + for (option = options; option; option = option->next) { + if (strcasecmp(option->key, "driver") == 0) { + if (idev->driver) { + rval = BadRequest; + goto unwind; + } + /* Memory leak for every attached device if we don't + * test if the module is already loaded first */ + drv = xf86LookupInputDriver(option->value); + if (!drv) + if (xf86LoadOneModule(option->value, NULL)) + drv = xf86LookupInputDriver(option->value); + if (!drv) { + xf86Msg(X_ERROR, "No input driver matching `%s'\n", + option->value); + rval = BadName; + goto unwind; + } + idev->driver = xstrdup(option->value); + if (!idev->driver) { + rval = BadAlloc; + goto unwind; + } + } + + if (strcasecmp(option->key, "name") == 0 || + strcasecmp(option->key, "identifier") == 0) { + if (idev->identifier) { + rval = BadRequest; + goto unwind; + } + idev->identifier = xstrdup(option->value); + if (!idev->identifier) { + rval = BadAlloc; + goto unwind; + } + } + + /* Right now, the only automatic config we know of is HAL. */ + if (strcmp(option->key, "_source") == 0 && + strcmp(option->value, "server/hal") == 0) { + if (!xf86Info.autoAddDevices) { + rval = BadMatch; + goto unwind; + } + + is_auto = 1; + } + } + if (!idev->driver || !idev->identifier) { + xf86Msg(X_ERROR, "No input driver/identifier specified (ignoring)\n"); + rval = BadRequest; + goto unwind; + } + + if (!drv->PreInit) { + xf86Msg(X_ERROR, + "Input driver `%s' has no PreInit function (ignoring)\n", + drv->driverName); + rval = BadImplementation; + goto unwind; + } + + for (option = options; option; option = option->next) { + /* Steal option key/value strings from the provided list. + * We need those strings, the InputOption list doesn't. */ + idev->commonOptions = xf86addNewOption(idev->commonOptions, + option->key, option->value); + option->key = NULL; + option->value = NULL; + } + + pInfo = drv->PreInit(drv, idev, 0); + + if (!pInfo) { + xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier); + rval = BadMatch; + goto unwind; + } + else if (!(pInfo->flags & XI86_CONFIGURED)) { + xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n", + idev->identifier); + rval = BadMatch; + goto unwind; + } + + xf86ActivateDevice(pInfo); + + dev = pInfo->dev; + ActivateDevice(dev); + /* Enable it if it's properly initialised, we're currently in the VT, and + * either it's a manual request, or we're automatically enabling devices. */ + if (dev->inited && dev->startup && xf86Screens[0]->vtSema && + (!is_auto || xf86Info.autoEnableDevices)) + EnableDevice(dev); + + *pdev = dev; + return Success; + +unwind: + if(pInfo) { + if(drv->UnInit) + drv->UnInit(drv, pInfo, 0); + else + xf86DeleteInput(pInfo, 0); + } + if(idev->driver) + xfree(idev->driver); + if(idev->identifier) + xfree(idev->identifier); + xf86optionListFree(idev->commonOptions); + xfree(idev); + return rval; +} + +void +DeleteInputDeviceRequest(DeviceIntPtr pDev) +{ + LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate; + InputDriverPtr drv; + IDevRec *idev; + BOOL found; + IDevPtr *it; + + if (pInfo) /* need to get these before RemoveDevice */ + { + drv = pInfo->drv; + idev = pInfo->conf_idev; + } + RemoveDevice(pDev); + + if (!pInfo) /* VCP and VCK */ + return; + + if(drv->UnInit) + drv->UnInit(drv, pInfo, 0); + else + xf86DeleteInput(pInfo, 0); + + /* devices added through HAL aren't in the config layout */ + it = xf86ConfigLayout.inputs; + while(*it && *it != idev) + it++; + + if (!(*it)) /* end of list, not in the layout */ + { + xfree(idev->driver); + xfree(idev->identifier); + xf86optionListFree(idev->commonOptions); + xfree(idev); + } +} + +/* + * convenient functions to post events + */ + +#define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */ + +_X_EXPORT void +xf86PostMotionEvent(DeviceIntPtr device, + int is_absolute, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int i = 0; + static int valuators[MAX_VALUATORS]; + + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } + + va_start(var, num_valuators); + for (i = 0; i < num_valuators; i++) + valuators[i] = va_arg(var, int); + va_end(var); + + xf86PostMotionEventP(device, is_absolute, first_valuator, num_valuators, valuators); +} + +_X_EXPORT void +xf86PostMotionEventP(DeviceIntPtr device, + int is_absolute, + int first_valuator, + int num_valuators, + int *valuators) +{ + int i = 0, nevents = 0; + int dx, dy; + Bool drag = xf86SendDragEvents(device); + xEvent *xE = NULL; + int index; + int flags = 0; + + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } + + if (is_absolute) + flags = POINTER_ABSOLUTE; + else + flags = POINTER_RELATIVE | POINTER_ACCELERATE; + +#if XFreeXDGA + if (first_valuator == 0 && num_valuators >= 2) { + if (miPointerGetScreen(inputInfo.pointer)) { + index = miPointerGetScreen(inputInfo.pointer)->myNum; + if (is_absolute) { + dx = valuators[0] - device->valuator->lastx; + dy = valuators[1] - device->valuator->lasty; + } + else { + dx = valuators[0]; + dy = valuators[1]; + } + if (DGAStealMotionEvent(index, dx, dy)) + return; + } + } +#endif + + if (!xf86Events) + FatalError("Didn't allocate event store\n"); + + nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0, + flags, first_valuator, num_valuators, + valuators); + + for (i = 0; i < nevents; i++) { + xE = xf86Events + i; + /* Don't post core motion events for devices not registered to send + * drag events. */ + if (xE->u.u.type != MotionNotify || drag) { + mieqEnqueue(device, xf86Events + i); + } + } +} + +_X_EXPORT void +xf86PostProximityEvent(DeviceIntPtr device, + int is_in, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int i, nevents; + int valuators[MAX_VALUATORS]; + + + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } + + va_start(var, num_valuators); + for (i = 0; i < num_valuators; i++) + valuators[i] = va_arg(var, int); + va_end(var); + + if (!xf86Events) + FatalError("Didn't allocate event store\n"); + + nevents = GetProximityEvents(xf86Events, device, + is_in ? ProximityIn : ProximityOut, + first_valuator, num_valuators, valuators); + for (i = 0; i < nevents; i++) + mieqEnqueue(device, xf86Events + i); + +} + +_X_EXPORT void +xf86PostButtonEvent(DeviceIntPtr device, + int is_absolute, + int button, + int is_down, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int valuators[MAX_VALUATORS]; + int i = 0, nevents = 0; + int index; + +#if XFreeXDGA + if (miPointerGetScreen(inputInfo.pointer)) { + index = miPointerGetScreen(inputInfo.pointer)->myNum; + if (DGAStealButtonEvent(index, button, is_down)) + return; + } +#endif + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } + + va_start(var, num_valuators); + for (i = 0; i < num_valuators; i++) + valuators[i] = va_arg(var, int); + va_end(var); + + if (!xf86Events) + FatalError("Didn't allocate event store\n"); + + nevents = GetPointerEvents(xf86Events, device, + is_down ? ButtonPress : ButtonRelease, button, + is_absolute ? POINTER_ABSOLUTE : + POINTER_RELATIVE, + first_valuator, num_valuators, valuators); + + for (i = 0; i < nevents; i++) + mieqEnqueue(device, xf86Events + i); +} + +_X_EXPORT void +xf86PostKeyEvent(DeviceIntPtr device, + unsigned int key_code, + int is_down, + int is_absolute, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int i = 0, nevents = 0; + static int valuators[MAX_VALUATORS]; + + /* instil confidence in the user */ + DebugF("this function has never been tested properly. if things go quite " + "badly south after this message, then xf86PostKeyEvent is " + "broken.\n"); + + if (num_valuators > MAX_VALUATORS) { + xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d" + " is greater than MAX_VALUATORS\n", num_valuators); + return; + } + + if (!xf86Events) + FatalError("Didn't allocate event store\n"); + + if (is_absolute) { + va_start(var, num_valuators); + for (i = 0; i < num_valuators; i++) + valuators[i] = va_arg(var, int); + va_end(var); + + nevents = GetKeyboardValuatorEvents(xf86Events, device, + is_down ? KeyPress : KeyRelease, + key_code, first_valuator, + num_valuators, valuators); + } + else { + nevents = GetKeyboardEvents(xf86Events, device, + is_down ? KeyPress : KeyRelease, + key_code); + } + + for (i = 0; i < nevents; i++) + mieqEnqueue(device, xf86Events + i); +} + +_X_EXPORT void +xf86PostKeyboardEvent(DeviceIntPtr device, + unsigned int key_code, + int is_down) +{ + int nevents = 0, i = 0; + int index; + +#if XFreeXDGA + if (miPointerGetScreen(inputInfo.pointer)) { + index = miPointerGetScreen(inputInfo.pointer)->myNum; + if (DGAStealKeyEvent(index, key_code, is_down)) + return; + } +#endif + + if (!xf86Events) + FatalError("Didn't allocate event store\n"); + + nevents = GetKeyboardEvents(xf86Events, device, + is_down ? KeyPress : KeyRelease, key_code); + + for (i = 0; i < nevents; i++) + mieqEnqueue(device, xf86Events + i); +} + +_X_EXPORT LocalDevicePtr +xf86FirstLocalDevice() +{ + return xf86InputDevs; +} + +/* + * Cx - raw data from touch screen + * Sxhigh - scaled highest dimension + * (remember, this is of rows - 1 because of 0 origin) + * Sxlow - scaled lowest dimension + * Rxhigh - highest raw value from touch screen calibration + * Rxlow - lowest raw value from touch screen calibration + * + * This function is the same for X or Y coordinates. + * You may have to reverse the high and low values to compensate for + * different orgins on the touch screen vs X. + */ + +_X_EXPORT int +xf86ScaleAxis(int Cx, + int Sxhigh, + int Sxlow, + int Rxhigh, + int Rxlow ) +{ + int X; + int dSx = Sxhigh - Sxlow; + int dRx = Rxhigh - Rxlow; + + dSx = Sxhigh - Sxlow; + if (dRx) { + X = ((dSx * (Cx - Rxlow)) / dRx) + Sxlow; + } + else { + X = 0; + ErrorF ("Divide by Zero in xf86ScaleAxis"); + } + + if (X > Sxlow) + X = Sxlow; + if (X < Sxhigh) + X = Sxhigh; + + return (X); +} + +/* + * This function checks the given screen against the current screen and + * makes changes if appropriate. It should be called from an XInput driver's + * ReadInput function before any events are posted, if the device is screen + * specific like a touch screen. + */ +_X_EXPORT void +xf86XInputSetScreen(LocalDevicePtr local, + int screen_number, + int x, + int y) +{ + if (miPointerGetScreen(local->dev) != + screenInfo.screens[screen_number]) { + miPointerSetScreen(local->dev, screen_number, x, y); + } +} + + +_X_EXPORT void +xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval, + int resolution, int min_res, int max_res) +{ + if (!dev || !dev->valuator) + return; + + InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution, min_res, + max_res); +} + +/* + * Set the valuator values to be in synch with dix/event.c + * DefineInitialRootWindow(). + */ +_X_EXPORT void +xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum) +{ + if (axnum == 0) { + dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2; + dev->valuator->lastx = dev->valuator->axisVal[0]; + } + else if (axnum == 1) { + dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; + dev->valuator->lasty = dev->valuator->axisVal[1]; + } +} + + +/** + * Deactivate a device. Call this function from the driver if you receive a + * read error or something else that spoils your day. + * Device will be moved to the off_devices list, but it will still be there + * until you really clean up after it. + * Notifies the client about an inactive device. + * + * @param panic True if device is unrecoverable and needs to be removed. + */ +_X_EXPORT void +xf86DisableDevice(DeviceIntPtr dev, Bool panic) +{ + devicePresenceNotify ev; + DeviceIntRec dummyDev; + + if(!panic) + { + DisableDevice(dev); + } else + { + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = DeviceUnrecoverable; + ev.deviceid = dev->id; + dummyDev.id = 0; + SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, + (xEvent *) &ev, 1); + + DeleteInputDeviceRequest(dev); + } +} + +/** + * Reactivate a device. Call this function from the driver if you just found + * out that the read error wasn't quite that bad after all. + * Device will be re-activated, and an event sent to the client. + */ +_X_EXPORT void +xf86EnableDevice(DeviceIntPtr dev) +{ + EnableDevice(dev); +} + +/* end of xf86Xinput.c */ diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.h b/xorg-server/hw/xfree86/common/xf86Xinput.h new file mode 100644 index 000000000..d88bbbeee --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86Xinput.h @@ -0,0 +1,215 @@ +/* + * Copyright 1995-1999 by Frederic Lepied, France. + * + * 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 Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * Copyright (c) 2000-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +#ifndef _xf86Xinput_h +#define _xf86Xinput_h + +#ifndef NEED_EVENTS +#define NEED_EVENTS +#endif +#include "xf86str.h" +#include "inputstr.h" +#ifdef XINPUT +#include +#include +#include "XIstubs.h" +#endif + +/* Input device flags */ +#define XI86_OPEN_ON_INIT 0x01 /* open the device at startup time */ +#define XI86_CONFIGURED 0x02 /* the device has been configured */ +#define XI86_ALWAYS_CORE 0x04 /* device always controls the pointer */ +/* the device sends Xinput and core pointer events */ +#define XI86_SEND_CORE_EVENTS XI86_ALWAYS_CORE +/* if the device is the core pointer or is sending core events, and + * SEND_DRAG_EVENTS is false, and a buttons is done, then no motion events + * (mouse drag action) are sent. This is mainly to allow a touch screen to be + * used with netscape and other browsers which do strange things if the mouse + * moves between button down and button up. With a touch screen, this motion + * is common due to the user's finger moving slightly. + */ +#define XI86_SEND_DRAG_EVENTS 0x08 +#define XI86_CORE_POINTER 0x10 /* device is the core pointer */ +#define XI86_CORE_KEYBOARD 0x20 /* device is the core keyboard */ +#define XI86_POINTER_CAPABLE 0x40 /* capable of being a core pointer */ +#define XI86_KEYBOARD_CAPABLE 0x80 /* capable of being a core keyboard */ + +#define XI_PRIVATE(dev) \ + (((LocalDevicePtr)((dev)->public.devicePrivate))->private) + +/* Stupid API backwards-compatibility. */ +#define TS_Raw 60 +#define TS_Scaled 61 + +#ifdef XINPUT +/* This holds the input driver entry and module information. */ +typedef struct _InputDriverRec { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + struct _LocalDeviceRec *(*PreInit)(struct _InputDriverRec *drv, + IDevPtr dev, int flags); + void (*UnInit)(struct _InputDriverRec *drv, + struct _LocalDeviceRec *pInfo, + int flags); + pointer module; + int refCount; +} InputDriverRec, *InputDriverPtr; +#endif + +/* This is to input devices what the ScrnInfoRec is to screens. */ + +typedef struct _LocalDeviceRec { + struct _LocalDeviceRec *next; + char * name; + int flags; + + Bool (*device_control)(DeviceIntPtr device, int what); + void (*read_input)(struct _LocalDeviceRec *local); + int (*control_proc)(struct _LocalDeviceRec *local, + xDeviceCtl *control); + void (*close_proc)(struct _LocalDeviceRec *local); + int (*switch_mode)(ClientPtr client, DeviceIntPtr dev, + int mode); + Bool (*conversion_proc)(struct _LocalDeviceRec *local, + int first, int num, int v0, + int v1, int v2, int v3, int v4, + int v5, int *x, int *y); + Bool (*reverse_conversion_proc)( + struct _LocalDeviceRec *local, + int x, int y, int *valuators); + int (*set_device_valuators) + (struct _LocalDeviceRec *local, + int *valuators, int first_valuator, + int num_valuators); + + int fd; + Atom atom; + DeviceIntPtr dev; + pointer private; + int private_flags; + unsigned int first; + unsigned int last; + int old_x; + int old_y; + char * type_name; + IntegerFeedbackPtr always_core_feedback; + IDevPtr conf_idev; + InputDriverPtr drv; + pointer module; + pointer options; + unsigned int history_size; +} LocalDeviceRec, *LocalDevicePtr, InputInfoRec, *InputInfoPtr; + +typedef struct _DeviceAssocRec +{ + char * config_section_name; + LocalDevicePtr (*device_allocate)(void); +} DeviceAssocRec, *DeviceAssocPtr; + +/* xf86Globals.c */ +extern InputInfoPtr xf86InputDevs; + +/* xf86Xinput.c */ +void InitExtInput(void); +void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute, + int first_valuator, int num_valuators, ...); +void xf86PostMotionEventP(DeviceIntPtr device, int is_absolute, + int first_valuator, int num_valuators, int *valuators); +void xf86PostProximityEvent(DeviceIntPtr device, int is_in, + int first_valuator, int num_valuators, ...); +void xf86PostButtonEvent(DeviceIntPtr device, int is_absolute, int button, + int is_down, int first_valuator, int num_valuators, + ...); +void xf86PostKeyEvent(DeviceIntPtr device, unsigned int key_code, int is_down, + int is_absolute, int first_valuator, int num_valuators, + ...); +void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code, + int is_down); +void xf86XinputFinalizeInit(DeviceIntPtr dev); +void xf86ActivateDevice(LocalDevicePtr local); +Bool xf86CheckButton(int button, int down); +void xf86SwitchCoreDevice(LocalDevicePtr device, DeviceIntPtr core); +LocalDevicePtr xf86FirstLocalDevice(void); +int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow); +void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y); +void xf86ProcessCommonOptions(InputInfoPtr pInfo, pointer options); +void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, + int maxval, int resolution, int min_res, + int max_res); +void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum); +void xf86AddEnabledDevice(InputInfoPtr pInfo); +void xf86RemoveEnabledDevice(InputInfoPtr pInfo); +void xf86DisableDevice(DeviceIntPtr dev, Bool panic); +void xf86EnableDevice(DeviceIntPtr dev); + +/* xf86Helper.c */ +void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags); +void xf86DeleteInputDriver(int drvIndex); +InputInfoPtr xf86AllocateInput(InputDriverPtr drv, int flags); +InputDriverPtr xf86LookupInputDriver(const char *name); +InputInfoPtr xf86LookupInput(const char *name); +void xf86DeleteInput(InputInfoPtr pInp, int flags); +void xf86MotionHistoryAllocate(LocalDevicePtr local); +int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff, + unsigned long start, unsigned long stop, + ScreenPtr pScreen); + +/* xf86Option.c */ +void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts, + pointer extraOpts); + + +/* Legacy hatred */ +#define SendCoreEvents 59 +#define DontSendCoreEvents 60 + +#endif /* _xf86Xinput_h */ diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c new file mode 100644 index 000000000..764647ee4 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86cmap.c @@ -0,0 +1,1111 @@ +/* + * Copyright (c) 1998-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__) \ + || (defined(sun) && defined(__SVR4)) +#include +#else +#define _XOPEN_SOURCE /* to get prototype for pow on some systems */ +#include +#undef _XOPEN_SOURCE +#endif + +#include +#include "misc.h" +#include +#include "colormapst.h" +#include "scrnintstr.h" + +#include "resource.h" + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86str.h" +#include "micmap.h" + +#ifdef XFreeXDGA +#define _XF86DGA_SERVER_ +#include +#include "dgaproc.h" +#endif + +#include "xf86cmap.h" + +#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \ + ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field) +#define SCREEN_EPILOGUE(pScreen, field, wrapper)\ + ((pScreen)->field = wrapper) + +#define LOAD_PALETTE(pmap, index) \ + ((pmap == miInstalledMaps[index]) && \ + ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \ + xf86Screens[index]->vtSema || pScreenPriv->isDGAmode)) + + +typedef struct _CMapLink { + ColormapPtr cmap; + struct _CMapLink *next; +} CMapLink, *CMapLinkPtr; + +typedef struct { + ScrnInfoPtr pScrn; + CloseScreenProcPtr CloseScreen; + CreateColormapProcPtr CreateColormap; + DestroyColormapProcPtr DestroyColormap; + InstallColormapProcPtr InstallColormap; + StoreColorsProcPtr StoreColors; + Bool (*EnterVT)(int, int); + Bool (*SwitchMode)(int, DisplayModePtr, int); + int (*SetDGAMode)(int, int, DGADevicePtr); + int maxColors; + int sigRGBbits; + int gammaElements; + LOCO *gamma; + int *PreAllocIndices; + CMapLinkPtr maps; + unsigned int flags; + Bool isDGAmode; +} CMapScreenRec, *CMapScreenPtr; + +typedef struct { + int numColors; + LOCO *colors; + Bool recalculate; + int overscan; +} CMapColormapRec, *CMapColormapPtr; + +static DevPrivateKey CMapScreenKey = NULL; +static DevPrivateKey CMapColormapKey = &CMapColormapKey; + +static void CMapInstallColormap(ColormapPtr); +static void CMapStoreColors(ColormapPtr, int, xColorItem *); +static Bool CMapCloseScreen (int, ScreenPtr); +static Bool CMapCreateColormap (ColormapPtr); +static void CMapDestroyColormap (ColormapPtr); + +static Bool CMapEnterVT(int, int); +static Bool CMapSwitchMode(int, DisplayModePtr, int); +static int CMapSetDGAMode(int, int, DGADevicePtr); +static int CMapChangeGamma(int, Gamma); + +static void ComputeGamma(CMapScreenPtr); +static Bool CMapAllocateColormapPrivate(ColormapPtr); +static void CMapRefreshColors(ColormapPtr, int, int*); +static void CMapSetOverscan(ColormapPtr, int, int *); +static void CMapReinstallMap(ColormapPtr); +static void CMapUnwrapScreen(ScreenPtr pScreen); + + + +_X_EXPORT Bool xf86HandleColormaps( + ScreenPtr pScreen, + int maxColors, + int sigRGBbits, + xf86LoadPaletteProc *loadPalette, + xf86SetOverscanProc *setOverscan, + unsigned int flags +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ColormapPtr pDefMap = NULL; + CMapScreenPtr pScreenPriv; + LOCO *gamma; + int *indices; + int elements; + + if(!maxColors || !sigRGBbits || !loadPalette) + return FALSE; + + CMapScreenKey = &CMapScreenKey; + + elements = 1 << sigRGBbits; + + if(!(gamma = xalloc(elements * sizeof(LOCO)))) + return FALSE; + + if(!(indices = xalloc(maxColors * sizeof(int)))) { + xfree(gamma); + return FALSE; + } + + if(!(pScreenPriv = xalloc(sizeof(CMapScreenRec)))) { + xfree(gamma); + xfree(indices); + return FALSE; + } + + dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv); + + pScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreenPriv->CreateColormap = pScreen->CreateColormap; + pScreenPriv->DestroyColormap = pScreen->DestroyColormap; + pScreenPriv->InstallColormap = pScreen->InstallColormap; + pScreenPriv->StoreColors = pScreen->StoreColors; + pScreen->CloseScreen = CMapCloseScreen; + pScreen->CreateColormap = CMapCreateColormap; + pScreen->DestroyColormap = CMapDestroyColormap; + pScreen->InstallColormap = CMapInstallColormap; + pScreen->StoreColors = CMapStoreColors; + + pScreenPriv->pScrn = pScrn; + pScrn->LoadPalette = loadPalette; + pScrn->SetOverscan = setOverscan; + pScreenPriv->maxColors = maxColors; + pScreenPriv->sigRGBbits = sigRGBbits; + pScreenPriv->gammaElements = elements; + pScreenPriv->gamma = gamma; + pScreenPriv->PreAllocIndices = indices; + pScreenPriv->maps = NULL; + pScreenPriv->flags = flags; + pScreenPriv->isDGAmode = FALSE; + + pScreenPriv->EnterVT = pScrn->EnterVT; + pScreenPriv->SwitchMode = pScrn->SwitchMode; + pScreenPriv->SetDGAMode = pScrn->SetDGAMode; + + if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) { + pScrn->EnterVT = CMapEnterVT; + if ((flags & CMAP_RELOAD_ON_MODE_SWITCH) && pScrn->SwitchMode) + pScrn->SwitchMode = CMapSwitchMode; + } +#ifdef XFreeXDGA + pScrn->SetDGAMode = CMapSetDGAMode; +#endif + pScrn->ChangeGamma = CMapChangeGamma; + + ComputeGamma(pScreenPriv); + + /* get the default map */ + + pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP); + + if(!CMapAllocateColormapPrivate(pDefMap)) { + CMapUnwrapScreen(pScreen); + return FALSE; + } + + /* Force the initial map to be loaded */ + miInstalledMaps[pScreen->myNum] = NULL; + CMapInstallColormap(pDefMap); + return TRUE; +} + + +/**** Screen functions ****/ + + +static Bool +CMapCloseScreen (int i, ScreenPtr pScreen) +{ + CMapUnwrapScreen(pScreen); + + return (*pScreen->CloseScreen) (i, pScreen); +} + +static Bool +CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv) +{ + if (pVisual->nplanes > 16) + return TRUE; + return ((1 << pVisual->nplanes) > pScreenPriv->maxColors); +} + +static Bool +CMapAllocateColormapPrivate(ColormapPtr pmap) +{ + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv; + CMapLinkPtr pLink; + int numColors; + LOCO *colors; + + if (CMapColormapUseMax(pmap->pVisual, pScreenPriv)) + numColors = pmap->pVisual->ColormapEntries; + else + numColors = 1 << pmap->pVisual->nplanes; + + if(!(colors = xalloc(numColors * sizeof(LOCO)))) + return FALSE; + + if(!(pColPriv = xalloc(sizeof(CMapColormapRec)))) { + xfree(colors); + return FALSE; + } + + dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv); + + pColPriv->numColors = numColors; + pColPriv->colors = colors; + pColPriv->recalculate = TRUE; + pColPriv->overscan = -1; + + /* add map to list */ + pLink = xalloc(sizeof(CMapLink)); + if(pLink) { + pLink->cmap = pmap; + pLink->next = pScreenPriv->maps; + pScreenPriv->maps = pLink; + } + + return TRUE; +} + +static Bool +CMapCreateColormap (ColormapPtr pmap) +{ + ScreenPtr pScreen = pmap->pScreen; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + Bool ret = FALSE; + + pScreen->CreateColormap = pScreenPriv->CreateColormap; + if((*pScreen->CreateColormap)(pmap)) { + if(CMapAllocateColormapPrivate(pmap)) + ret = TRUE; + } + pScreen->CreateColormap = CMapCreateColormap; + + return ret; +} + +static void +CMapDestroyColormap (ColormapPtr cmap) +{ + ScreenPtr pScreen = cmap->pScreen; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &cmap->devPrivates, CMapColormapKey); + CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps; + + if(pColPriv) { + if(pColPriv->colors) xfree(pColPriv->colors); + xfree(pColPriv); + } + + /* remove map from list */ + while(pLink) { + if(pLink->cmap == cmap) { + if(prevLink) + prevLink->next = pLink->next; + else + pScreenPriv->maps = pLink->next; + xfree(pLink); + break; + } + prevLink = pLink; + pLink = pLink->next; + } + + if(pScreenPriv->DestroyColormap) { + pScreen->DestroyColormap = pScreenPriv->DestroyColormap; + (*pScreen->DestroyColormap)(cmap); + pScreen->DestroyColormap = CMapDestroyColormap; + } +} + + + +static void +CMapStoreColors( + ColormapPtr pmap, + int ndef, + xColorItem *pdefs +){ + ScreenPtr pScreen = pmap->pScreen; + VisualPtr pVisual = pmap->pVisual; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + int *indices = pScreenPriv->PreAllocIndices; + int num = ndef; + + /* At the moment this isn't necessary since there's nobody below us */ + pScreen->StoreColors = pScreenPriv->StoreColors; + (*pScreen->StoreColors)(pmap, ndef, pdefs); + pScreen->StoreColors = CMapStoreColors; + + /* should never get here for these */ + if( (pVisual->class == TrueColor) || + (pVisual->class == StaticColor) || + (pVisual->class == StaticGray)) + return; + + if(pVisual->class == DirectColor) { + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); + int i; + + if (CMapColormapUseMax(pVisual, pScreenPriv)) { + int index; + + num = 0; + while(ndef--) { + if(pdefs[ndef].flags & DoRed) { + index = (pdefs[ndef].pixel & pVisual->redMask) >> + pVisual->offsetRed; + i = num; + while(i--) + if(indices[i] == index) break; + if(i == -1) + indices[num++] = index; + } + if(pdefs[ndef].flags & DoGreen) { + index = (pdefs[ndef].pixel & pVisual->greenMask) >> + pVisual->offsetGreen; + i = num; + while(i--) + if(indices[i] == index) break; + if(i == -1) + indices[num++] = index; + } + if(pdefs[ndef].flags & DoBlue) { + index = (pdefs[ndef].pixel & pVisual->blueMask) >> + pVisual->offsetBlue; + i = num; + while(i--) + if(indices[i] == index) break; + if(i == -1) + indices[num++] = index; + } + } + + } else { + /* not really as overkill as it seems */ + num = pColPriv->numColors; + for(i = 0; i < pColPriv->numColors; i++) + indices[i] = i; + } + } else { + while(ndef--) + indices[ndef] = pdefs[ndef].pixel; + } + + CMapRefreshColors(pmap, num, indices); +} + + +static void +CMapInstallColormap(ColormapPtr pmap) +{ + ScreenPtr pScreen = pmap->pScreen; + int index = pScreen->myNum; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + + if (pmap == miInstalledMaps[index]) + return; + + pScreen->InstallColormap = pScreenPriv->InstallColormap; + (*pScreen->InstallColormap)(pmap); + pScreen->InstallColormap = CMapInstallColormap; + + /* Important. We let the lower layers, namely DGA, + overwrite the choice of Colormap to install */ + if (miInstalledMaps[index]) + pmap = miInstalledMaps[index]; + + if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && + (pmap->pVisual->class == TrueColor) && + CMapColormapUseMax(pmap->pVisual, pScreenPriv)) + return; + + if(LOAD_PALETTE(pmap, index)) + CMapReinstallMap(pmap); +} + + +/**** ScrnInfoRec functions ****/ + +static Bool +CMapEnterVT(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + + if((*pScreenPriv->EnterVT)(index, flags)) { + if(miInstalledMaps[index]) + CMapReinstallMap(miInstalledMaps[index]); + return TRUE; + } + return FALSE; +} + + +static Bool +CMapSwitchMode(int index, DisplayModePtr mode, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + + if((*pScreenPriv->SwitchMode)(index, mode, flags)) { + if(miInstalledMaps[index]) + CMapReinstallMap(miInstalledMaps[index]); + return TRUE; + } + return FALSE; +} + +#ifdef XFreeXDGA +static int +CMapSetDGAMode(int index, int num, DGADevicePtr dev) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + int ret; + + ret = (*pScreenPriv->SetDGAMode)(index, num, dev); + + pScreenPriv->isDGAmode = DGAActive(index); + + if(!pScreenPriv->isDGAmode && miInstalledMaps[index] + && xf86Screens[pScreen->myNum]->vtSema) + CMapReinstallMap(miInstalledMaps[index]); + + return ret; +} +#endif + + +/**** Utilities ****/ + +static void +CMapReinstallMap(ColormapPtr pmap) +{ + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr cmapPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); + ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; + int i = cmapPriv->numColors; + int *indices = pScreenPriv->PreAllocIndices; + + while(i--) + indices[i] = i; + + if(cmapPriv->recalculate) + CMapRefreshColors(pmap, cmapPriv->numColors, indices); + else { + (*pScrn->LoadPalette)(pScrn, cmapPriv->numColors, + indices, cmapPriv->colors, pmap->pVisual); + if (pScrn->SetOverscan) { +#ifdef DEBUGOVERSCAN + ErrorF("SetOverscan() called from CMapReinstallMap\n"); +#endif + pScrn->SetOverscan(pScrn, cmapPriv->overscan); + } + } + + cmapPriv->recalculate = FALSE; +} + + +static void +CMapRefreshColors(ColormapPtr pmap, int defs, int* indices) +{ + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); + VisualPtr pVisual = pmap->pVisual; + ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; + int numColors, i; + LOCO *gamma, *colors; + EntryPtr entry; + int reds, greens, blues, maxValue, index, shift; + + numColors = pColPriv->numColors; + shift = 16 - pScreenPriv->sigRGBbits; + maxValue = (1 << pScreenPriv->sigRGBbits) - 1; + gamma = pScreenPriv->gamma; + colors = pColPriv->colors; + + reds = pVisual->redMask >> pVisual->offsetRed; + greens = pVisual->greenMask >> pVisual->offsetGreen; + blues = pVisual->blueMask >> pVisual->offsetBlue; + + switch(pVisual->class) { + case StaticGray: + for(i = 0; i <= numColors - 1; i++) { + index = i * maxValue / numColors; + colors[i].red = gamma[index].red; + colors[i].green = gamma[index].green; + colors[i].blue = gamma[index].blue; + } + break; + case TrueColor: + if (CMapColormapUseMax(pVisual, pScreenPriv)) { + for(i = 0; i <= reds; i++) + colors[i].red = gamma[i * maxValue / reds].red; + for(i = 0; i <= greens; i++) + colors[i].green = gamma[i * maxValue / greens].green; + for(i = 0; i <= blues; i++) + colors[i].blue = gamma[i * maxValue / blues].blue; + break; + } + for(i = 0; i < numColors; i++) { + colors[i].red = gamma[((i >> pVisual->offsetRed) & reds) * + maxValue / reds].red; + colors[i].green = gamma[((i >> pVisual->offsetGreen) & greens) * + maxValue / greens].green; + colors[i].blue = gamma[((i >> pVisual->offsetBlue) & blues) * + maxValue / blues].blue; + } + break; + case StaticColor: + case PseudoColor: + case GrayScale: + for(i = 0; i < defs; i++) { + index = indices[i]; + entry = (EntryPtr)&pmap->red[index]; + + if(entry->fShared) { + colors[index].red = + gamma[entry->co.shco.red->color >> shift].red; + colors[index].green = + gamma[entry->co.shco.green->color >> shift].green; + colors[index].blue = + gamma[entry->co.shco.blue->color >> shift].blue; + } else { + colors[index].red = + gamma[entry->co.local.red >> shift].red; + colors[index].green = + gamma[entry->co.local.green >> shift].green; + colors[index].blue = + gamma[entry->co.local.blue >> shift].blue; + } + } + break; + case DirectColor: + if (CMapColormapUseMax(pVisual, pScreenPriv)) { + for(i = 0; i < defs; i++) { + index = indices[i]; + if(index <= reds) + colors[index].red = + gamma[pmap->red[index].co.local.red >> shift].red; + if(index <= greens) + colors[index].green = + gamma[pmap->green[index].co.local.green >> shift].green; + if(index <= blues) + colors[index].blue = + gamma[pmap->blue[index].co.local.blue >> shift].blue; + + } + break; + } + for(i = 0; i < defs; i++) { + index = indices[i]; + + colors[index].red = gamma[pmap->red[ + (index >> pVisual->offsetRed) & reds + ].co.local.red >> shift].red; + colors[index].green = gamma[pmap->green[ + (index >> pVisual->offsetGreen) & greens + ].co.local.green >> shift].green; + colors[index].blue = gamma[pmap->blue[ + (index >> pVisual->offsetBlue) & blues + ].co.local.blue >> shift].blue; + } + break; + } + + + if(LOAD_PALETTE(pmap, pmap->pScreen->myNum)) + (*pScrn->LoadPalette)(pScreenPriv->pScrn, defs, indices, + colors, pmap->pVisual); + + if (pScrn->SetOverscan) + CMapSetOverscan(pmap, defs, indices); + +} + +static Bool +CMapCompareColors(LOCO *color1, LOCO *color2) +{ + /* return TRUE if the color1 is "closer" to black than color2 */ +#ifdef DEBUGOVERSCAN + ErrorF("#%02x%02x%02x vs #%02x%02x%02x (%d vs %d)\n", + color1->red, color1->green, color1->blue, + color2->red, color2->green, color2->blue, + color1->red + color1->green + color1->blue, + color2->red + color2->green + color2->blue); +#endif + return (color1->red + color1->green + color1->blue < + color2->red + color2->green + color2->blue); +} + +static void +CMapSetOverscan(ColormapPtr pmap, int defs, int *indices) +{ + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); + ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; + VisualPtr pVisual = pmap->pVisual; + int i; + LOCO *colors; + int index; + Bool newOverscan = FALSE; + int overscan, tmpOverscan; + + colors = pColPriv->colors; + overscan = pColPriv->overscan; + + /* + * Search for a new overscan index in the following cases: + * + * - The index hasn't yet been initialised.  In this case search + * for an index that is black or a close match to black. + * + * - The colour of the old index is changed. In this case search + * all indices for a black or close match to black. + * + * - The colour of the old index wasn't black. In this case only + * search the indices that were changed for a better match to black. + */ + + switch (pVisual->class) { + case StaticGray: + case TrueColor: + /* Should only come here once. Initialise the overscan index to 0 */ + overscan = 0; + newOverscan = TRUE; + break; + case StaticColor: + /* + * Only come here once, but search for the overscan in the same way + * as for the other cases. + */ + case DirectColor: + case PseudoColor: + case GrayScale: + if (overscan < 0 || overscan > pScreenPriv->maxColors - 1) { + /* Uninitialised */ + newOverscan = TRUE; + } else { + /* Check if the overscan was changed */ + for (i = 0; i < defs; i++) { + index = indices[i]; + if (index == overscan) { + newOverscan = TRUE; + break; + } + } + } + if (newOverscan) { + /* The overscan is either uninitialised or it has been changed */ + + if (overscan < 0 || overscan > pScreenPriv->maxColors - 1) + tmpOverscan = pScreenPriv->maxColors - 1; + else + tmpOverscan = overscan; + + /* search all entries for a close match to black */ + for (i = pScreenPriv->maxColors - 1; i >= 0; i--) { + if (colors[i].red == 0 && colors[i].green == 0 && + colors[i].blue == 0) { + overscan = i; +#ifdef DEBUGOVERSCAN + ErrorF("Black found at index 0x%02x\n", i); +#endif + break; + } else { +#ifdef DEBUGOVERSCAN + ErrorF("0x%02x: ", i); +#endif + if (CMapCompareColors(&colors[i], &colors[tmpOverscan])) { + tmpOverscan = i; +#ifdef DEBUGOVERSCAN + ErrorF("possible \"Black\" at index 0x%02x\n", i); +#endif + } + } + } + if (i < 0) + overscan = tmpOverscan; + } else { + /* Check of the old overscan wasn't black */ + if (colors[overscan].red != 0 || colors[overscan].green != 0 || + colors[overscan].blue != 0) { + int oldOverscan = tmpOverscan = overscan; + /* See of there is now a better match */ + for (i = 0; i < defs; i++) { + index = indices[i]; + if (colors[index].red == 0 && colors[index].green == 0 && + colors[index].blue == 0) { + overscan = index; +#ifdef DEBUGOVERSCAN + ErrorF("Black found at index 0x%02x\n", index); +#endif + break; + } else { +#ifdef DEBUGOVERSCAN + ErrorF("0x%02x: ", index); +#endif + if (CMapCompareColors(&colors[index], + &colors[tmpOverscan])) { + tmpOverscan = index; +#ifdef DEBUGOVERSCAN + ErrorF("possible \"Black\" at index 0x%02x\n", + index); +#endif + } + } + } + if (i == defs) + overscan = tmpOverscan; + if (overscan != oldOverscan) + newOverscan = TRUE; + } + } + break; + } + if (newOverscan) { + pColPriv->overscan = overscan; + if (LOAD_PALETTE(pmap, pmap->pScreen->myNum)) { +#ifdef DEBUGOVERSCAN + ErrorF("SetOverscan() called from CmapSetOverscan\n"); +#endif + pScrn->SetOverscan(pScreenPriv->pScrn, overscan); + } + } +} + +static void +CMapUnwrapScreen(ScreenPtr pScreen) +{ + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + pScreen->CloseScreen = pScreenPriv->CloseScreen; + pScreen->CreateColormap = pScreenPriv->CreateColormap; + pScreen->DestroyColormap = pScreenPriv->DestroyColormap; + pScreen->InstallColormap = pScreenPriv->InstallColormap; + pScreen->StoreColors = pScreenPriv->StoreColors; + + pScrn->EnterVT = pScreenPriv->EnterVT; + pScrn->SwitchMode = pScreenPriv->SwitchMode; + pScrn->SetDGAMode = pScreenPriv->SetDGAMode; + + xfree(pScreenPriv->gamma); + xfree(pScreenPriv->PreAllocIndices); + xfree(pScreenPriv); +} + + +static void +ComputeGamma(CMapScreenPtr priv) +{ + int elements = priv->gammaElements - 1; + double RedGamma, GreenGamma, BlueGamma; + int i; + +#ifndef DONT_CHECK_GAMMA + /* This check is to catch drivers that are not initialising pScrn->gamma */ + if (priv->pScrn->gamma.red < GAMMA_MIN || + priv->pScrn->gamma.red > GAMMA_MAX || + priv->pScrn->gamma.green < GAMMA_MIN || + priv->pScrn->gamma.green > GAMMA_MAX || + priv->pScrn->gamma.blue < GAMMA_MIN || + priv->pScrn->gamma.blue > GAMMA_MAX) { + + xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0, + "The %s driver didn't call xf86SetGamma() to initialise\n" + "\tthe gamma values.\n", priv->pScrn->driverName); + xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0, + "PLEASE FIX THE `%s' DRIVER!\n", priv->pScrn->driverName); + priv->pScrn->gamma.red = 1.0; + priv->pScrn->gamma.green = 1.0; + priv->pScrn->gamma.blue = 1.0; + } +#endif + + RedGamma = 1.0 / (double)priv->pScrn->gamma.red; + GreenGamma = 1.0 / (double)priv->pScrn->gamma.green; + BlueGamma = 1.0 / (double)priv->pScrn->gamma.blue; + + for(i = 0; i <= elements; i++) { + if(RedGamma == 1.0) + priv->gamma[i].red = i; + else + priv->gamma[i].red = (CARD16)(pow((double)i/(double)elements, + RedGamma) * (double)elements + 0.5); + + if(GreenGamma == 1.0) + priv->gamma[i].green = i; + else + priv->gamma[i].green = (CARD16)(pow((double)i/(double)elements, + GreenGamma) * (double)elements + 0.5); + + if(BlueGamma == 1.0) + priv->gamma[i].blue = i; + else + priv->gamma[i].blue = (CARD16)(pow((double)i/(double)elements, + BlueGamma) * (double)elements + 0.5); + } +} + + +int +CMapChangeGamma( + int index, + Gamma gamma +){ + ScrnInfoPtr pScrn = xf86Screens[index]; + ScreenPtr pScreen = pScrn->pScreen; + CMapColormapPtr pColPriv; + CMapScreenPtr pScreenPriv; + CMapLinkPtr pLink; + + /* Is this sufficient checking ? */ + if(CMapScreenKey == NULL) + return BadImplementation; + + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); + if(!pScreenPriv) + return BadImplementation; + + if (gamma.red < GAMMA_MIN || gamma.red > GAMMA_MAX || + gamma.green < GAMMA_MIN || gamma.green > GAMMA_MAX || + gamma.blue < GAMMA_MIN || gamma.blue > GAMMA_MAX) + return BadValue; + + pScrn->gamma.red = gamma.red; + pScrn->gamma.green = gamma.green; + pScrn->gamma.blue = gamma.blue; + + ComputeGamma(pScreenPriv); + + /* mark all colormaps on this screen */ + pLink = pScreenPriv->maps; + while(pLink) { + pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates, + CMapColormapKey); + pColPriv->recalculate = TRUE; + pLink = pLink->next; + } + + if(miInstalledMaps[pScreen->myNum] && + ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || + pScrn->vtSema || pScreenPriv->isDGAmode)) { + ColormapPtr pMap = miInstalledMaps[pScreen->myNum]; + + if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && + (pMap->pVisual->class == TrueColor) && + CMapColormapUseMax(pMap->pVisual, pScreenPriv)) { + + /* if the current map doesn't have a palette look + for another map to change the gamma on. */ + + pLink = pScreenPriv->maps; + while(pLink) { + if(pLink->cmap->pVisual->class == PseudoColor) + break; + pLink = pLink->next; + } + + if(pLink) { + /* need to trick CMapRefreshColors() into thinking + this is the currently installed map */ + miInstalledMaps[pScreen->myNum] = pLink->cmap; + CMapReinstallMap(pLink->cmap); + miInstalledMaps[pScreen->myNum] = pMap; + } + } else + CMapReinstallMap(pMap); + } + + return Success; +} + + +static void +ComputeGammaRamp ( + CMapScreenPtr priv, + unsigned short *red, + unsigned short *green, + unsigned short *blue +){ + int elements = priv->gammaElements; + LOCO *entry = priv->gamma; + int shift = 16 - priv->sigRGBbits; + + while(elements--) { + entry->red = *(red++) >> shift; + entry->green = *(green++) >> shift; + entry->blue = *(blue++) >> shift; + entry++; + } +} + +_X_EXPORT int +xf86ChangeGammaRamp( + ScreenPtr pScreen, + int size, + unsigned short *red, + unsigned short *green, + unsigned short *blue +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + CMapColormapPtr pColPriv; + CMapScreenPtr pScreenPriv; + CMapLinkPtr pLink; + + if(CMapScreenKey == NULL) + return BadImplementation; + + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); + if(!pScreenPriv) + return BadImplementation; + + if(pScreenPriv->gammaElements != size) + return BadValue; + + ComputeGammaRamp(pScreenPriv, red, green, blue); + + /* mark all colormaps on this screen */ + pLink = pScreenPriv->maps; + while(pLink) { + pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates, + CMapColormapKey); + pColPriv->recalculate = TRUE; + pLink = pLink->next; + } + + if(miInstalledMaps[pScreen->myNum] && + ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || + pScrn->vtSema || pScreenPriv->isDGAmode)) { + ColormapPtr pMap = miInstalledMaps[pScreen->myNum]; + + if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && + (pMap->pVisual->class == TrueColor) && + CMapColormapUseMax(pMap->pVisual, pScreenPriv)) { + + /* if the current map doesn't have a palette look + for another map to change the gamma on. */ + + pLink = pScreenPriv->maps; + while(pLink) { + if(pLink->cmap->pVisual->class == PseudoColor) + break; + pLink = pLink->next; + } + + if(pLink) { + /* need to trick CMapRefreshColors() into thinking + this is the currently installed map */ + miInstalledMaps[pScreen->myNum] = pLink->cmap; + CMapReinstallMap(pLink->cmap); + miInstalledMaps[pScreen->myNum] = pMap; + } + } else + CMapReinstallMap(pMap); + } + + return Success; +} + +_X_EXPORT int +xf86GetGammaRampSize(ScreenPtr pScreen) +{ + CMapScreenPtr pScreenPriv; + + if(CMapScreenKey == NULL) return 0; + + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); + if(!pScreenPriv) return 0; + + return pScreenPriv->gammaElements; +} + +_X_EXPORT int +xf86GetGammaRamp( + ScreenPtr pScreen, + int size, + unsigned short *red, + unsigned short *green, + unsigned short *blue +){ + CMapScreenPtr pScreenPriv; + LOCO *entry; + int shift, sigbits; + + if(CMapScreenKey == NULL) + return BadImplementation; + + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); + if(!pScreenPriv) + return BadImplementation; + + if(size > pScreenPriv->gammaElements) + return BadValue; + + entry = pScreenPriv->gamma; + sigbits = pScreenPriv->sigRGBbits; + + while(size--) { + *red = entry->red << (16 - sigbits); + *green = entry->green << (16 - sigbits); + *blue = entry->blue << (16 - sigbits); + shift = sigbits; + while(shift < 16) { + *red |= *red >> shift; + *green |= *green >> shift; + *blue |= *blue >> shift; + shift += sigbits; + } + red++; green++; blue++; + entry++; + } + + return Success; +} + +int +xf86ChangeGamma( + ScreenPtr pScreen, + Gamma gamma +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if(pScrn->ChangeGamma) + return (*pScrn->ChangeGamma)(pScreen->myNum, gamma); + + return Success; /* Success? */ +} diff --git a/xorg-server/hw/xfree86/common/xf86cmap.h b/xorg-server/hw/xfree86/common/xf86cmap.h new file mode 100644 index 000000000..b98bd3bfd --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86cmap.h @@ -0,0 +1,75 @@ + +/* + * Copyright (c) 1998-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86CMAP_H +#define _XF86CMAP_H + +#include "xf86str.h" +#include "colormapst.h" + +#define CMAP_PALETTED_TRUECOLOR 0x0000001 +#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002 +#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004 + +Bool xf86HandleColormaps( + ScreenPtr pScreen, + int maxCol, + int sigRGBbits, + xf86LoadPaletteProc *loadPalette, + xf86SetOverscanProc *setOverscan, + unsigned int flags +); + +int +xf86ChangeGamma( + ScreenPtr pScreen, + Gamma newGamma +); + +int +xf86ChangeGammaRamp( + ScreenPtr pScreen, + int size, + unsigned short *red, + unsigned short *green, + unsigned short *blue +); + +int xf86GetGammaRampSize(ScreenPtr pScreen); + +int +xf86GetGammaRamp( + ScreenPtr pScreen, + int size, + unsigned short *red, + unsigned short *green, + unsigned short *blue +); + +#endif /* _XF86CMAP_H */ + diff --git a/xorg-server/hw/xfree86/common/xf86fbBus.c b/xorg-server/hw/xfree86/common/xf86fbBus.c new file mode 100644 index 000000000..102f6b1b2 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86fbBus.c @@ -0,0 +1,96 @@ + +/* + * Copyright (c) 2000-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the interfaces to the bus-specific code + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Resources.h" + +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#define NEED_OS_RAC_PROTOS +#include "xf86_OSproc.h" + +#include "xf86RAC.h" + +Bool fbSlotClaimed = FALSE; + +_X_EXPORT int +xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active) +{ + EntityPtr p; + int num; + + num = xf86AllocateEntity(); + p = xf86Entities[num]; + p->driver = drvp; + p->chipset = 0; + p->busType = BUS_NONE; + p->active = active; + p->inUse = FALSE; + xf86AddDevToEntity(num, dev); + p->access = xnfcalloc(1,sizeof(EntityAccessRec)); + p->access->fallback = &AccessNULL; + p->access->pAccess = &AccessNULL; + p->busAcc = NULL; + + fbSlotClaimed = TRUE; + return num; +} + +/* + * Get the list of FB "slots" claimed by a screen + */ +int +xf86GetFbInfoForScreen(int scrnIndex) +{ + int num = 0; + int i; + EntityPtr p; + + for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) { + p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]]; + if (p->busType == BUS_NONE) { + num++; + } + } + return num; +} diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c new file mode 100644 index 000000000..9fd2e6c70 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86fbman.c @@ -0,0 +1,1450 @@ + +/* + * Copyright (c) 1998-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" + +#include +#include "scrnintstr.h" +#include "regionstr.h" +#include "xf86fbman.h" + +/* +#define DEBUG +*/ + +static DevPrivateKey xf86FBManagerKey = NULL; + +_X_EXPORT Bool xf86RegisterOffscreenManager( + ScreenPtr pScreen, + FBManagerFuncsPtr funcs +){ + + xf86FBManagerKey = &xf86FBManagerKey; + dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs); + + return TRUE; +} + + +_X_EXPORT Bool +xf86FBManagerRunning(ScreenPtr pScreen) +{ + if(xf86FBManagerKey == NULL) + return FALSE; + if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey)) + return FALSE; + + return TRUE; +} + +_X_EXPORT Bool +xf86RegisterFreeBoxCallback( + ScreenPtr pScreen, + FreeBoxCallbackProcPtr FreeBoxCallback, + pointer devPriv +){ + FBManagerFuncsPtr funcs; + + if(xf86FBManagerKey == NULL) + return FALSE; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) + return FALSE; + + return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv); +} + + +_X_EXPORT FBAreaPtr +xf86AllocateOffscreenArea( + ScreenPtr pScreen, + int w, int h, + int gran, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData +){ + FBManagerFuncsPtr funcs; + + if(xf86FBManagerKey == NULL) + return NULL; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) + return NULL; + + return (*funcs->AllocateOffscreenArea)( + pScreen, w, h, gran, moveCB, removeCB, privData); +} + + +_X_EXPORT FBLinearPtr +xf86AllocateOffscreenLinear( + ScreenPtr pScreen, + int length, + int gran, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData +){ + FBManagerFuncsPtr funcs; + + if(xf86FBManagerKey == NULL) + return NULL; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) + return NULL; + + return (*funcs->AllocateOffscreenLinear)( + pScreen, length, gran, moveCB, removeCB, privData); +} + + +_X_EXPORT void +xf86FreeOffscreenArea(FBAreaPtr area) +{ + FBManagerFuncsPtr funcs; + + if(!area) return; + + if(xf86FBManagerKey == NULL) + return; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &area->pScreen->devPrivates, xf86FBManagerKey))) + return; + + (*funcs->FreeOffscreenArea)(area); + + return; +} + + +_X_EXPORT void +xf86FreeOffscreenLinear(FBLinearPtr linear) +{ + FBManagerFuncsPtr funcs; + + if(!linear) return; + + if(xf86FBManagerKey == NULL) + return; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &linear->pScreen->devPrivates, xf86FBManagerKey))) + return; + + (*funcs->FreeOffscreenLinear)(linear); + + return; +} + + +_X_EXPORT Bool +xf86ResizeOffscreenArea( + FBAreaPtr resize, + int w, int h +){ + FBManagerFuncsPtr funcs; + + if(!resize) return FALSE; + + if(xf86FBManagerKey == NULL) + return FALSE; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &resize->pScreen->devPrivates, xf86FBManagerKey))) + return FALSE; + + return (*funcs->ResizeOffscreenArea)(resize, w, h); +} + +_X_EXPORT Bool +xf86ResizeOffscreenLinear( + FBLinearPtr resize, + int size +){ + FBManagerFuncsPtr funcs; + + if(!resize) return FALSE; + + if(xf86FBManagerKey == NULL) + return FALSE; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &resize->pScreen->devPrivates, xf86FBManagerKey))) + return FALSE; + + return (*funcs->ResizeOffscreenLinear)(resize, size); +} + + +_X_EXPORT Bool +xf86QueryLargestOffscreenArea( + ScreenPtr pScreen, + int *w, int *h, + int gran, + int preferences, + int severity +){ + FBManagerFuncsPtr funcs; + + *w = 0; + *h = 0; + + if(xf86FBManagerKey == NULL) + return FALSE; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) + return FALSE; + + return (*funcs->QueryLargestOffscreenArea)( + pScreen, w, h, gran, preferences, severity); +} + +_X_EXPORT Bool +xf86QueryLargestOffscreenLinear( + ScreenPtr pScreen, + int *size, + int gran, + int severity +){ + FBManagerFuncsPtr funcs; + + *size = 0; + + if(xf86FBManagerKey == NULL) + return FALSE; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) + return FALSE; + + return (*funcs->QueryLargestOffscreenLinear)( + pScreen, size, gran, severity); +} + + +_X_EXPORT Bool +xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen) +{ + FBManagerFuncsPtr funcs; + + if(xf86FBManagerKey == NULL) + return FALSE; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) + return FALSE; + + return (*funcs->PurgeOffscreenAreas)(pScreen); +} + +/************************************************************\ + + Below is a specific implementation of an offscreen manager. + +\************************************************************/ + +static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKey; + +typedef struct _FBLink { + FBArea area; + struct _FBLink *next; +} FBLink, *FBLinkPtr; + +typedef struct _FBLinearLink { + FBLinear linear; + int free; /* need to add free here as FBLinear is publicly accessible */ + FBAreaPtr area; /* only used if allocation came from XY area */ + struct _FBLinearLink *next; +} FBLinearLink, *FBLinearLinkPtr; + + +typedef struct { + ScreenPtr pScreen; + RegionPtr InitialBoxes; + RegionPtr FreeBoxes; + FBLinkPtr UsedAreas; + int NumUsedAreas; + FBLinearLinkPtr LinearAreas; + CloseScreenProcPtr CloseScreen; + int NumCallbacks; + FreeBoxCallbackProcPtr *FreeBoxesUpdateCallback; + DevUnion *devPrivates; +} FBManager, *FBManagerPtr; + + +static void +SendCallFreeBoxCallbacks(FBManagerPtr offman) +{ + int i = offman->NumCallbacks; + + while(i--) { + (*offman->FreeBoxesUpdateCallback[i])( + offman->pScreen, offman->FreeBoxes, offman->devPrivates[i].ptr); + } +} + +static Bool +localRegisterFreeBoxCallback( + ScreenPtr pScreen, + FreeBoxCallbackProcPtr FreeBoxCallback, + pointer devPriv +){ + FBManagerPtr offman; + FreeBoxCallbackProcPtr *newCallbacks; + DevUnion *newPrivates; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback, + sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1)); + + newPrivates = xrealloc(offman->devPrivates, + sizeof(DevUnion) * (offman->NumCallbacks + 1)); + + if(!newCallbacks || !newPrivates) + return FALSE; + + offman->FreeBoxesUpdateCallback = newCallbacks; + offman->devPrivates = newPrivates; + + offman->FreeBoxesUpdateCallback[offman->NumCallbacks] = FreeBoxCallback; + offman->devPrivates[offman->NumCallbacks].ptr = devPriv; + offman->NumCallbacks++; + + SendCallFreeBoxCallbacks(offman); + + return TRUE; +} + + +static FBAreaPtr +AllocateArea( + FBManagerPtr offman, + int w, int h, + int granularity, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData +){ + ScreenPtr pScreen = offman->pScreen; + FBLinkPtr link = NULL; + FBAreaPtr area = NULL; + RegionRec NewReg; + int i, x = 0, num; + BoxPtr boxp; + + if(granularity <= 1) granularity = 0; + + boxp = REGION_RECTS(offman->FreeBoxes); + num = REGION_NUM_RECTS(offman->FreeBoxes); + + /* look through the free boxes */ + for(i = 0; i < num; i++, boxp++) { + x = boxp->x1; + if (granularity > 1) + x = ((x + granularity - 1) / granularity) * granularity; + + if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) + continue; + + link = xalloc(sizeof(FBLink)); + if(!link) return NULL; + + area = &(link->area); + link->next = offman->UsedAreas; + offman->UsedAreas = link; + offman->NumUsedAreas++; + break; + } + + /* try to boot a removeable one out if we are not expendable ourselves */ + if(!area && !removeCB) { + link = offman->UsedAreas; + + while(link) { + if(!link->area.RemoveAreaCallback) { + link = link->next; + continue; + } + + boxp = &(link->area.box); + x = boxp->x1; + if (granularity > 1) + x = ((x + granularity - 1) / granularity) * granularity; + + if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) { + link = link->next; + continue; + } + + /* bye, bye */ + (*link->area.RemoveAreaCallback)(&link->area); + REGION_INIT(pScreen, &NewReg, &(link->area.box), 1); + REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg); + REGION_UNINIT(pScreen, &NewReg); + + area = &(link->area); + break; + } + } + + if(area) { + area->pScreen = pScreen; + area->granularity = granularity; + area->box.x1 = x; + area->box.x2 = x + w; + area->box.y1 = boxp->y1; + area->box.y2 = boxp->y1 + h; + area->MoveAreaCallback = moveCB; + area->RemoveAreaCallback = removeCB; + area->devPrivate.ptr = privData; + + REGION_INIT(pScreen, &NewReg, &(area->box), 1); + REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg); + REGION_UNINIT(pScreen, &NewReg); + } + + return area; +} + +static FBAreaPtr +localAllocateOffscreenArea( + ScreenPtr pScreen, + int w, int h, + int gran, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData +){ + FBManagerPtr offman; + FBAreaPtr area = NULL; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData))) + SendCallFreeBoxCallbacks(offman); + + return area; +} + + +static void +localFreeOffscreenArea(FBAreaPtr area) +{ + FBManagerPtr offman; + FBLinkPtr pLink, pLinkPrev = NULL; + RegionRec FreedRegion; + ScreenPtr pScreen; + + pScreen = area->pScreen; + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + pLink = offman->UsedAreas; + if(!pLink) return; + + while(&(pLink->area) != area) { + pLinkPrev = pLink; + pLink = pLink->next; + if(!pLink) return; + } + + /* put the area back into the pool */ + REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1); + REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedRegion); + REGION_UNINIT(pScreen, &FreedRegion); + + if(pLinkPrev) + pLinkPrev->next = pLink->next; + else offman->UsedAreas = pLink->next; + + xfree(pLink); + offman->NumUsedAreas--; + + SendCallFreeBoxCallbacks(offman); +} + + + +static Bool +localResizeOffscreenArea( + FBAreaPtr resize, + int w, int h +){ + FBManagerPtr offman; + ScreenPtr pScreen; + BoxRec OrigArea; + RegionRec FreedReg; + FBAreaPtr area = NULL; + FBLinkPtr pLink, newLink, pLinkPrev = NULL; + + pScreen = resize->pScreen; + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + /* find this link */ + if(!(pLink = offman->UsedAreas)) + return FALSE; + + while(&(pLink->area) != resize) { + pLinkPrev = pLink; + pLink = pLink->next; + if(!pLink) return FALSE; + } + + OrigArea.x1 = resize->box.x1; + OrigArea.x2 = resize->box.x2; + OrigArea.y1 = resize->box.y1; + OrigArea.y2 = resize->box.y2; + + /* if it's smaller, this is easy */ + + if((w <= (resize->box.x2 - resize->box.x1)) && + (h <= (resize->box.y2 - resize->box.y1))) { + RegionRec NewReg; + + resize->box.x2 = resize->box.x1 + w; + resize->box.y2 = resize->box.y1 + h; + + if((resize->box.y2 == OrigArea.y2) && + (resize->box.x2 == OrigArea.x2)) + return TRUE; + + REGION_INIT(pScreen, &FreedReg, &OrigArea, 1); + REGION_INIT(pScreen, &NewReg, &(resize->box), 1); + REGION_SUBTRACT(pScreen, &FreedReg, &FreedReg, &NewReg); + REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg); + REGION_UNINIT(pScreen, &FreedReg); + REGION_UNINIT(pScreen, &NewReg); + + SendCallFreeBoxCallbacks(offman); + + return TRUE; + } + + + /* otherwise we remove the old region */ + + REGION_INIT(pScreen, &FreedReg, &OrigArea, 1); + REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg); + + /* remove the old link */ + if(pLinkPrev) + pLinkPrev->next = pLink->next; + else offman->UsedAreas = pLink->next; + + /* and try to add a new one */ + + if((area = AllocateArea(offman, w, h, resize->granularity, + resize->MoveAreaCallback, resize->RemoveAreaCallback, + resize->devPrivate.ptr))) { + + /* copy data over to our link and replace the new with old */ + memcpy(resize, area, sizeof(FBArea)); + + pLinkPrev = NULL; + newLink = offman->UsedAreas; + + while(&(newLink->area) != area) { + pLinkPrev = newLink; + newLink = newLink->next; + } + + if(pLinkPrev) + pLinkPrev->next = newLink->next; + else offman->UsedAreas = newLink->next; + + pLink->next = offman->UsedAreas; + offman->UsedAreas = pLink; + + xfree(newLink); + + /* AllocateArea added one but we really only exchanged one */ + offman->NumUsedAreas--; + } else { + /* reinstate the old region */ + REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg); + REGION_UNINIT(pScreen, &FreedReg); + + pLink->next = offman->UsedAreas; + offman->UsedAreas = pLink; + return FALSE; + } + + + REGION_UNINIT(pScreen, &FreedReg); + + SendCallFreeBoxCallbacks(offman); + + return TRUE; +} + +static Bool +localQueryLargestOffscreenArea( + ScreenPtr pScreen, + int *width, int *height, + int granularity, + int preferences, + int severity +){ + FBManagerPtr offman; + RegionPtr newRegion = NULL; + BoxPtr pbox; + int nbox; + int x, w, h, area, oldArea; + + *width = *height = oldArea = 0; + + if(granularity <= 1) granularity = 0; + + if((preferences < 0) || (preferences > 3)) + return FALSE; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + if(severity < 0) severity = 0; + if(severity > 2) severity = 2; + + switch(severity) { + case 2: + if(offman->NumUsedAreas) { + FBLinkPtr pLink; + RegionRec tmpRegion; + newRegion = REGION_CREATE(pScreen, NULL, 1); + REGION_COPY(pScreen, newRegion, offman->InitialBoxes); + pLink = offman->UsedAreas; + + while(pLink) { + if(!pLink->area.RemoveAreaCallback) { + REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1); + REGION_SUBTRACT(pScreen, newRegion, newRegion, &tmpRegion); + REGION_UNINIT(pScreen, &tmpRegion); + } + pLink = pLink->next; + } + + nbox = REGION_NUM_RECTS(newRegion); + pbox = REGION_RECTS(newRegion); + break; + } + case 1: + if(offman->NumUsedAreas) { + FBLinkPtr pLink; + RegionRec tmpRegion; + newRegion = REGION_CREATE(pScreen, NULL, 1); + REGION_COPY(pScreen, newRegion, offman->FreeBoxes); + pLink = offman->UsedAreas; + + while(pLink) { + if(pLink->area.RemoveAreaCallback) { + REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1); + REGION_APPEND(pScreen, newRegion, &tmpRegion); + REGION_UNINIT(pScreen, &tmpRegion); + } + pLink = pLink->next; + } + + nbox = REGION_NUM_RECTS(newRegion); + pbox = REGION_RECTS(newRegion); + break; + } + default: + nbox = REGION_NUM_RECTS(offman->FreeBoxes); + pbox = REGION_RECTS(offman->FreeBoxes); + break; + } + + while(nbox--) { + x = pbox->x1; + if (granularity > 1) + x = ((x + granularity - 1) / granularity) * granularity; + + w = pbox->x2 - x; + h = pbox->y2 - pbox->y1; + area = w * h; + + if(w > 0) { + Bool gotIt = FALSE; + switch(preferences) { + case FAVOR_AREA_THEN_WIDTH: + if((area > oldArea) || ((area == oldArea) && (w > *width))) + gotIt = TRUE; + break; + case FAVOR_AREA_THEN_HEIGHT: + if((area > oldArea) || ((area == oldArea) && (h > *height))) + gotIt = TRUE; + break; + case FAVOR_WIDTH_THEN_AREA: + if((w > *width) || ((w == *width) && (area > oldArea))) + gotIt = TRUE; + break; + case FAVOR_HEIGHT_THEN_AREA: + if((h > *height) || ((h == *height) && (area > oldArea))) + gotIt = TRUE; + break; + } + if(gotIt) { + *width = w; + *height = h; + oldArea = area; + } + } + pbox++; + } + + if(newRegion) + REGION_DESTROY(pScreen, newRegion); + + return TRUE; +} + +static Bool +localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen) +{ + FBManagerPtr offman; + FBLinkPtr pLink, tmp, pPrev = NULL; + RegionRec FreedRegion; + Bool anyUsed = FALSE; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + pLink = offman->UsedAreas; + if(!pLink) return TRUE; + + while(pLink) { + if(pLink->area.RemoveAreaCallback) { + (*pLink->area.RemoveAreaCallback)(&pLink->area); + + REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1); + REGION_APPEND(pScreen, offman->FreeBoxes, &FreedRegion); + REGION_UNINIT(pScreen, &FreedRegion); + + if(pPrev) + pPrev->next = pLink->next; + else offman->UsedAreas = pLink->next; + + tmp = pLink; + pLink = pLink->next; + xfree(tmp); + offman->NumUsedAreas--; + anyUsed = TRUE; + } else { + pPrev = pLink; + pLink = pLink->next; + } + } + + if(anyUsed) { + REGION_VALIDATE(pScreen, offman->FreeBoxes, &anyUsed); + SendCallFreeBoxCallbacks(offman); + } + + return TRUE; +} + +static void +LinearMoveCBWrapper(FBAreaPtr from, FBAreaPtr to) +{ + /* this will never get called */ +} + +static void +LinearRemoveCBWrapper(FBAreaPtr area) +{ + FBManagerPtr offman; + FBLinearLinkPtr pLink, pLinkPrev = NULL; + ScreenPtr pScreen = area->pScreen; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + pLink = offman->LinearAreas; + if(!pLink) return; + + while(pLink->area != area) { + pLinkPrev = pLink; + pLink = pLink->next; + if(!pLink) return; + } + + /* give the user the callback it is expecting */ + (*pLink->linear.RemoveLinearCallback)(&(pLink->linear)); + + if(pLinkPrev) + pLinkPrev->next = pLink->next; + else offman->LinearAreas = pLink->next; + + xfree(pLink); +} + +#ifdef DEBUG +static void +Dump(FBLinearLinkPtr pLink) +{ + if (!pLink) ErrorF("MMmm, PLINK IS NULL!\n"); + + while (pLink) { + ErrorF(" Offset:%08x, Size:%08x, %s,%s\n", + pLink->linear.offset, + pLink->linear.size, + pLink->free ? "Free" : "Used", + pLink->area ? "Area" : "Linear"); + + pLink = pLink->next; + } +} +#endif + +static FBLinearPtr +AllocateLinear( + FBManagerPtr offman, + int size, + int granularity, + pointer privData +){ + ScreenPtr pScreen = offman->pScreen; + FBLinearLinkPtr linear = NULL; + FBLinearLinkPtr newlink = NULL; + int offset, end; + + if(size <= 0) return NULL; + + if (!offman->LinearAreas) return NULL; + + linear = offman->LinearAreas; + while (linear) { + /* Make sure we get a free area that's not an XY fallback case */ + if (!linear->area && linear->free) { + offset = linear->linear.offset; + if (granularity > 1) + offset = ((offset + granularity - 1) / granularity) * granularity; + end = offset+size; + if (end <= (linear->linear.offset + linear->linear.size)) + break; + } + linear = linear->next; + } + if (!linear) + return NULL; + + /* break left */ + if (offset > linear->linear.offset) { + newlink = xalloc(sizeof(FBLinearLink)); + if (!newlink) + return NULL; + newlink->area = NULL; + newlink->linear.offset = offset; + newlink->linear.size = linear->linear.size - (offset - linear->linear.offset); + newlink->free = 1; + newlink->next = linear->next; + linear->linear.size -= newlink->linear.size; + linear->next = newlink; + linear = newlink; + } + + /* break right */ + if (size < linear->linear.size) { + newlink = xalloc(sizeof(FBLinearLink)); + if (!newlink) + return NULL; + newlink->area = NULL; + newlink->linear.offset = offset + size; + newlink->linear.size = linear->linear.size - size; + newlink->free = 1; + newlink->next = linear->next; + linear->linear.size = size; + linear->next = newlink; + } + + /* p = middle block */ + linear->linear.granularity = granularity; + linear->free = 0; + linear->linear.pScreen = pScreen; + linear->linear.MoveLinearCallback = NULL; + linear->linear.RemoveLinearCallback = NULL; + linear->linear.devPrivate.ptr = NULL; + +#ifdef DEBUG + Dump(offman->LinearAreas); +#endif + + return &(linear->linear); +} + +static FBLinearPtr +localAllocateOffscreenLinear( + ScreenPtr pScreen, + int length, + int gran, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData +){ + FBManagerPtr offman; + FBLinearLinkPtr link; + FBAreaPtr area; + FBLinearPtr linear = NULL; + BoxPtr extents; + int w, h, pitch; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + + /* Try to allocate from linear memory first...... */ +#ifdef DEBUG + ErrorF("ALLOCATING LINEAR\n"); +#endif + if ((linear = AllocateLinear(offman, length, gran, privData))) + return linear; + +#ifdef DEBUG + ErrorF("NOPE, ALLOCATING AREA\n"); +#endif + + if(!(link = xalloc(sizeof(FBLinearLink)))) + return NULL; + + /* No linear available, so try and pinch some from the XY areas */ + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + pitch = extents->x2 - extents->x1; + + if (gran > 1) { + if (gran > pitch) { + /* we can't match the specified alignment with XY allocations */ + xfree(link); + return NULL; + } + + if (pitch % gran) { + /* pitch and granularity aren't a perfect match, let's allocate + * a bit more so we can align later on + */ + length += gran - 1; + } + } + + if(length < pitch) { /* special case */ + w = length; + h = 1; + } else { + w = pitch; + h = (length + pitch - 1) / pitch; + } + + if((area = localAllocateOffscreenArea(pScreen, w, h, gran, + moveCB ? LinearMoveCBWrapper : NULL, + removeCB ? LinearRemoveCBWrapper : NULL, + privData))) + { + link->area = area; + link->free = 0; + link->next = offman->LinearAreas; + offman->LinearAreas = link; + linear = &(link->linear); + linear->pScreen = pScreen; + linear->size = h * w; + linear->offset = (pitch * area->box.y1) + area->box.x1; + if (gran > 1) + linear->offset = ((linear->offset + gran - 1) / gran) * gran; + linear->granularity = gran; + linear->MoveLinearCallback = moveCB; + linear->RemoveLinearCallback = removeCB; + linear->devPrivate.ptr = privData; + } else + xfree(link); + +#ifdef DEBUG + Dump(offman->LinearAreas); +#endif + + return linear; +} + + +static void +localFreeOffscreenLinear(FBLinearPtr linear) +{ + FBManagerPtr offman; + FBLinearLinkPtr pLink, pLinkPrev = NULL; + ScreenPtr pScreen = linear->pScreen; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + pLink = offman->LinearAreas; + if(!pLink) return; + + while(&(pLink->linear) != linear) { + pLinkPrev = pLink; + pLink = pLink->next; + if(!pLink) return; + } + + if(pLink->area) { /* really an XY area */ +#ifdef DEBUG + ErrorF("FREEING AREA\n"); +#endif + localFreeOffscreenArea(pLink->area); + if(pLinkPrev) + pLinkPrev->next = pLink->next; + else offman->LinearAreas = pLink->next; + xfree(pLink); +#ifdef DEBUG + Dump(offman->LinearAreas); +#endif + return; + } + + pLink->free = 1; + + if (pLink->next && pLink->next->free) { + FBLinearLinkPtr p = pLink->next; + pLink->linear.size += p->linear.size; + pLink->next = p->next; + free(p); + } + + if(pLinkPrev) { + if (pLinkPrev->next && pLinkPrev->next->free && !pLinkPrev->area) { + FBLinearLinkPtr p = pLinkPrev->next; + pLinkPrev->linear.size += p->linear.size; + pLinkPrev->next = p->next; + free(p); + } + } + +#ifdef DEBUG + ErrorF("FREEING LINEAR\n"); + Dump(offman->LinearAreas); +#endif +} + + +static Bool +localResizeOffscreenLinear(FBLinearPtr resize, int length) +{ + FBManagerPtr offman; + FBLinearLinkPtr pLink; + ScreenPtr pScreen = resize->pScreen; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + pLink = offman->LinearAreas; + if(!pLink) return FALSE; + + while(&(pLink->linear) != resize) { + pLink = pLink->next; + if(!pLink) return FALSE; + } + + /* This could actually be alot smarter and try to move allocations + from XY to linear when available. For now if it was XY, we keep + it XY */ + + if(pLink->area) { /* really an XY area */ + BoxPtr extents; + int pitch, w, h; + + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + pitch = extents->x2 - extents->x1; + + if(length < pitch) { /* special case */ + w = length; + h = 1; + } else { + w = pitch; + h = (length + pitch - 1) / pitch; + } + + if(localResizeOffscreenArea(pLink->area, w, h)) { + resize->size = h * w; + resize->offset = (pitch * pLink->area->box.y1) + pLink->area->box.x1; + return TRUE; + } + } else { + /* TODO!!!! resize the linear area */ + } + + return FALSE; +} + + +static Bool +localQueryLargestOffscreenLinear( + ScreenPtr pScreen, + int *size, + int gran, + int priority +) +{ + FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + FBLinearLinkPtr pLink; + FBLinearLinkPtr pLinkRet; + + *size = 0; + + pLink = offman->LinearAreas; + + if (pLink && !pLink->area) { + pLinkRet = pLink; + while (pLink) { + if (pLink->free) { + if (pLink->linear.size > pLinkRet->linear.size) + pLinkRet = pLink; + } + pLink = pLink->next; + } + + if (pLinkRet->free) { + *size = pLinkRet->linear.size; + return TRUE; + } + } else { + int w, h; + + if(localQueryLargestOffscreenArea(pScreen, &w, &h, gran, + FAVOR_WIDTH_THEN_AREA, priority)) + { + FBManagerPtr offman; + BoxPtr extents; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + if((extents->x2 - extents->x1) == w) + *size = w * h; + return TRUE; + } + } + + return FALSE; +} + + + +static FBManagerFuncs xf86FBManFuncs = { + localAllocateOffscreenArea, + localFreeOffscreenArea, + localResizeOffscreenArea, + localQueryLargestOffscreenArea, + localRegisterFreeBoxCallback, + localAllocateOffscreenLinear, + localFreeOffscreenLinear, + localResizeOffscreenLinear, + localQueryLargestOffscreenLinear, + localPurgeUnlockedOffscreenAreas + }; + + +static Bool +xf86FBCloseScreen (int i, ScreenPtr pScreen) +{ + FBLinkPtr pLink, tmp; + FBLinearLinkPtr pLinearLink, tmp2; + FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + + pScreen->CloseScreen = offman->CloseScreen; + + pLink = offman->UsedAreas; + while(pLink) { + tmp = pLink; + pLink = pLink->next; + xfree(tmp); + } + + pLinearLink = offman->LinearAreas; + while(pLinearLink) { + tmp2 = pLinearLink; + pLinearLink = pLinearLink->next; + xfree(tmp2); + } + + REGION_DESTROY(pScreen, offman->InitialBoxes); + REGION_DESTROY(pScreen, offman->FreeBoxes); + + xfree(offman->FreeBoxesUpdateCallback); + xfree(offman->devPrivates); + xfree(offman); + dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL); + + return (*pScreen->CloseScreen) (i, pScreen); +} + +_X_EXPORT Bool +xf86InitFBManager( + ScreenPtr pScreen, + BoxPtr FullBox +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RegionRec ScreenRegion; + RegionRec FullRegion; + BoxRec ScreenBox; + Bool ret; + + ScreenBox.x1 = 0; + ScreenBox.y1 = 0; + ScreenBox.x2 = pScrn->virtualX; + ScreenBox.y2 = pScrn->virtualY; + + if((FullBox->x1 > ScreenBox.x1) || (FullBox->y1 > ScreenBox.y1) || + (FullBox->x2 < ScreenBox.x2) || (FullBox->y2 < ScreenBox.y2)) { + return FALSE; + } + + if (FullBox->y2 < FullBox->y1) return FALSE; + if (FullBox->x2 < FullBox->x1) return FALSE; + + REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1); + REGION_INIT(pScreen, &FullRegion, FullBox, 1); + + REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion); + + ret = xf86InitFBManagerRegion(pScreen, &FullRegion); + + REGION_UNINIT(pScreen, &ScreenRegion); + REGION_UNINIT(pScreen, &FullRegion); + + return ret; +} + +_X_EXPORT Bool +xf86InitFBManagerArea( + ScreenPtr pScreen, + int PixelArea, + int Verbosity +) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xRectangle Rect[3]; + RegionPtr pRegion, pScreenRegion; + int nRect; + Bool ret = FALSE; + + if (PixelArea < (pScrn->displayWidth * pScrn->virtualY)) + return FALSE; + + Rect[0].x = Rect[0].y = 0; + Rect[0].width = pScrn->displayWidth; + Rect[0].height = PixelArea / pScrn->displayWidth; + nRect = 1; + + /* Add a possible partial scanline */ + if ((Rect[1].height = Rect[1].width = PixelArea % pScrn->displayWidth)) { + Rect[1].x = 0; + Rect[1].y = Rect[0].height; + Rect[1].height = 1; + nRect++; + } + + /* Factor out virtual resolution */ + pRegion = RECTS_TO_REGION(pScreen, nRect, Rect, 0); + if (pRegion) { + if (!REGION_NAR(pRegion)) { + Rect[2].x = Rect[2].y = 0; + Rect[2].width = pScrn->virtualX; + Rect[2].height = pScrn->virtualY; + + pScreenRegion = RECTS_TO_REGION(pScreen, 1, &Rect[2], 0); + if (pScreenRegion) { + if (!REGION_NAR(pScreenRegion)) { + REGION_SUBTRACT(pScreen, pRegion, pRegion, pScreenRegion); + + ret = xf86InitFBManagerRegion(pScreen, pRegion); + + if (ret && xf86GetVerbosity() >= Verbosity) { + int scrnIndex = pScrn->scrnIndex; + + xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity, + "Largest offscreen areas (with overlaps):\n"); + + if (Rect[2].width < Rect[0].width) { + xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity, + "\t%d x %d rectangle at %d,0\n", + Rect[0].width - Rect[2].width, + Rect[0].height, + Rect[2].width); + } + if (Rect[2].width < Rect[1].width) { + xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity, + "\t%d x %d rectangle at %d,0\n", + Rect[1].width - Rect[2].width, + Rect[0].height + Rect[1].height, + Rect[2].width); + } + if (Rect[2].height < Rect[0].height) { + xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity, + "\t%d x %d rectangle at 0,%d\n", + Rect[0].width, + Rect[0].height - Rect[2].height, + Rect[2].height); + } + if (Rect[1].height) { + xf86DrvMsgVerb(scrnIndex, X_INFO, Verbosity, + "\t%d x %d rectangle at 0,%d\n", + Rect[1].width, + Rect[0].height - Rect[2].height + + Rect[1].height, + Rect[2].height); + } + } + } + + REGION_DESTROY(pScreen, pScreenRegion); + } + } + + REGION_DESTROY(pScreen, pRegion); + } + + return ret; +} + +_X_EXPORT Bool +xf86InitFBManagerRegion( + ScreenPtr pScreen, + RegionPtr FullRegion +){ + FBManagerPtr offman; + + if(REGION_NIL(FullRegion)) + return FALSE; + + if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs)) + return FALSE; + + offman = xalloc(sizeof(FBManager)); + if(!offman) return FALSE; + + dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman); + + offman->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = xf86FBCloseScreen; + + offman->InitialBoxes = REGION_CREATE(pScreen, NULL, 1); + offman->FreeBoxes = REGION_CREATE(pScreen, NULL, 1); + + REGION_COPY(pScreen, offman->InitialBoxes, FullRegion); + REGION_COPY(pScreen, offman->FreeBoxes, FullRegion); + + offman->pScreen = pScreen; + offman->UsedAreas = NULL; + offman->LinearAreas = NULL; + offman->NumUsedAreas = 0; + offman->NumCallbacks = 0; + offman->FreeBoxesUpdateCallback = NULL; + offman->devPrivates = NULL; + + return TRUE; +} + +_X_EXPORT Bool +xf86InitFBManagerLinear( + ScreenPtr pScreen, + int offset, + int size +){ + FBManagerPtr offman; + FBLinearLinkPtr link; + FBLinearPtr linear; + + if (size <= 0) + return FALSE; + + /* we expect people to have called the Area setup first for pixmap cache */ + if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey)) + return FALSE; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + offman->LinearAreas = xalloc(sizeof(FBLinearLink)); + if (!offman->LinearAreas) + return FALSE; + + link = offman->LinearAreas; + link->area = NULL; + link->next = NULL; + link->free = 1; + linear = &(link->linear); + linear->pScreen = pScreen; + linear->size = size; + linear->offset = offset; + linear->granularity = 0; + linear->MoveLinearCallback = NULL; + linear->RemoveLinearCallback = NULL; + linear->devPrivate.ptr = NULL; + + return TRUE; +} + + +/* This is an implementation specific function and should + disappear after the next release. People should use the + real linear functions instead */ + +_X_EXPORT FBAreaPtr +xf86AllocateLinearOffscreenArea ( + ScreenPtr pScreen, + int length, + int gran, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData +){ + FBManagerFuncsPtr funcs; + FBManagerPtr offman; + BoxPtr extents; + int w, h; + + if(xf86FBManagerKey == NULL) + return NULL; + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) + return NULL; + + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + w = extents->x2 - extents->x1; + + if (gran > 1) { + if (gran > w) + return NULL; + + if (w % gran) + length += gran - 1; + } + + if(length <= w) { /* special case */ + h = 1; + w = length; + } else { + h = (length + w - 1) / w; + } + + return (*funcs->AllocateOffscreenArea)( + pScreen, w, h, gran, moveCB, removeCB, privData); +} diff --git a/xorg-server/hw/xfree86/common/xf86fbman.h b/xorg-server/hw/xfree86/common/xf86fbman.h new file mode 100644 index 000000000..4f2eac5e6 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86fbman.h @@ -0,0 +1,226 @@ + +/* + * Copyright (c) 1998-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86FBMAN_H +#define _XF86FBMAN_H + + +#include "scrnintstr.h" +#include "regionstr.h" + + +#define FAVOR_AREA_THEN_WIDTH 0 +#define FAVOR_AREA_THEN_HEIGHT 1 +#define FAVOR_WIDTH_THEN_AREA 2 +#define FAVOR_HEIGHT_THEN_AREA 3 + +#define PRIORITY_LOW 0 +#define PRIORITY_NORMAL 1 +#define PRIORITY_EXTREME 2 + + +typedef struct _FBArea { + ScreenPtr pScreen; + BoxRec box; + int granularity; + void (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*); + void (*RemoveAreaCallback)(struct _FBArea*); + DevUnion devPrivate; +} FBArea, *FBAreaPtr; + +typedef struct _FBLinear { + ScreenPtr pScreen; + int size; + int offset; + int granularity; + void (*MoveLinearCallback)(struct _FBLinear*, struct _FBLinear*); + void (*RemoveLinearCallback)(struct _FBLinear*); + DevUnion devPrivate; +} FBLinear, *FBLinearPtr; + +typedef void (*FreeBoxCallbackProcPtr)(ScreenPtr, RegionPtr, pointer); +typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr, FBAreaPtr); +typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr); + +typedef void (*MoveLinearCallbackProcPtr)(FBLinearPtr, FBLinearPtr); +typedef void (*RemoveLinearCallbackProcPtr)(FBLinearPtr); + + +typedef struct { + FBAreaPtr (*AllocateOffscreenArea)( + ScreenPtr pScreen, + int w, int h, + int granularity, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData); + void (*FreeOffscreenArea)(FBAreaPtr area); + Bool (*ResizeOffscreenArea)(FBAreaPtr area, int w, int h); + Bool (*QueryLargestOffscreenArea)( + ScreenPtr pScreen, + int *width, int *height, + int granularity, + int preferences, + int priority); + Bool (*RegisterFreeBoxCallback)( + ScreenPtr pScreen, + FreeBoxCallbackProcPtr FreeBoxCallback, + pointer devPriv); +/* linear functions */ + FBLinearPtr (*AllocateOffscreenLinear)( + ScreenPtr pScreen, + int size, + int granularity, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData); + void (*FreeOffscreenLinear)(FBLinearPtr area); + Bool (*ResizeOffscreenLinear)(FBLinearPtr area, int size); + Bool (*QueryLargestOffscreenLinear)( + ScreenPtr pScreen, + int *size, + int granularity, + int priority); + Bool (*PurgeOffscreenAreas) (ScreenPtr); +} FBManagerFuncs, *FBManagerFuncsPtr; + + +Bool xf86RegisterOffscreenManager( + ScreenPtr pScreen, + FBManagerFuncsPtr funcs +); + +Bool +xf86InitFBManagerRegion( + ScreenPtr pScreen, + RegionPtr ScreenRegion +); + +Bool +xf86InitFBManagerArea( + ScreenPtr pScreen, + int PixalArea, + int Verbosity +); + +Bool +xf86InitFBManager( + ScreenPtr pScreen, + BoxPtr FullBox +); + +Bool +xf86InitFBManagerLinear( + ScreenPtr pScreen, + int offset, + int size +); + +Bool +xf86FBManagerRunning( + ScreenPtr pScreen +); + +FBAreaPtr +xf86AllocateOffscreenArea ( + ScreenPtr pScreen, + int w, int h, + int granularity, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData +); + +FBAreaPtr +xf86AllocateLinearOffscreenArea ( + ScreenPtr pScreen, + int length, + int granularity, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData +); + +FBLinearPtr +xf86AllocateOffscreenLinear ( + ScreenPtr pScreen, + int length, + int granularity, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData +); + +void xf86FreeOffscreenArea(FBAreaPtr area); +void xf86FreeOffscreenLinear(FBLinearPtr area); + +Bool +xf86ResizeOffscreenArea( + FBAreaPtr resize, + int w, int h +); + +Bool +xf86ResizeOffscreenLinear( + FBLinearPtr resize, + int size +); + + +Bool +xf86RegisterFreeBoxCallback( + ScreenPtr pScreen, + FreeBoxCallbackProcPtr FreeBoxCallback, + pointer devPriv +); + +Bool +xf86PurgeUnlockedOffscreenAreas( + ScreenPtr pScreen +); + + +Bool +xf86QueryLargestOffscreenArea( + ScreenPtr pScreen, + int *width, int *height, + int granularity, + int preferences, + int priority +); + +Bool +xf86QueryLargestOffscreenLinear( + ScreenPtr pScreen, + int *size, + int granularity, + int priority +); + + +#endif /* _XF86FBMAN_H */ diff --git a/xorg-server/hw/xfree86/common/xf86isaBus.c b/xorg-server/hw/xfree86/common/xf86isaBus.c new file mode 100644 index 000000000..3abad38ef --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86isaBus.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 1997-2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* + * This file contains the interfaces to the bus-specific code + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Resources.h" + +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#define NEED_OS_RAC_PROTOS +#include "xf86_OSproc.h" + +#include "xf86RAC.h" + +Bool isaSlotClaimed = FALSE; + +/* + * If the slot requested is already in use, return FALSE. + * Otherwise, claim the slot for the screen requesting it. + */ + +_X_EXPORT int +xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active) +{ + EntityPtr p; + BusAccPtr pbap = xf86BusAccInfo; + int num; + + num = xf86AllocateEntity(); + p = xf86Entities[num]; + p->driver = drvp; + p->chipset = chipset; + p->busType = BUS_ISA; + p->active = active; + p->inUse = FALSE; + xf86AddDevToEntity(num, dev); + p->access = xnfcalloc(1,sizeof(EntityAccessRec)); + p->access->fallback = &AccessNULL; + p->access->pAccess = &AccessNULL; + p->busAcc = NULL; + while (pbap) { + if (pbap->type == BUS_ISA) + p->busAcc = pbap; + pbap = pbap->next; + } + isaSlotClaimed = TRUE; + return num; +} + +/* + * Get the list of ISA "slots" claimed by a screen + * + * Note: The ISA implementation here assumes that only one ISA "slot" type + * can be claimed by any one screen. That means a return value other than + * 0 or 1 isn't useful. + */ +int +xf86GetIsaInfoForScreen(int scrnIndex) +{ + int num = 0; + int i; + EntityPtr p; + + for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) { + p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]]; + if (p->busType == BUS_ISA) { + num++; + } + } + return num; +} + +/* + * Parse a BUS ID string, and return True if it is a ISA bus id. + */ + +_X_EXPORT Bool +xf86ParseIsaBusString(const char *busID) +{ + /* + * The format assumed to be "isa" or "isa:" + */ + return (StringToBusType(busID,NULL) == BUS_ISA); +} + + +/* + * xf86IsPrimaryIsa() -- return TRUE if primary device + * is ISA. + */ + +_X_EXPORT Bool +xf86IsPrimaryIsa(void) +{ + return ( primaryBus.type == BUS_ISA ); +} + +void +isaConvertRange2Host(resRange *pRange) +{ + return; +} diff --git a/xorg-server/hw/xfree86/common/xf86noBus.c b/xorg-server/hw/xfree86/common/xf86noBus.c new file mode 100644 index 000000000..0e3e3cc6b --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86noBus.c @@ -0,0 +1,74 @@ + +/* + * Copyright (c) 2000-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the interfaces to the bus-specific code + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Resources.h" + +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#define NEED_OS_RAC_PROTOS +#include "xf86_OSproc.h" + +#include "xf86RAC.h" + +_X_EXPORT int +xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active) +{ + EntityPtr p; + int num; + + num = xf86AllocateEntity(); + p = xf86Entities[num]; + p->driver = drvp; + p->chipset = 0; + p->busType = BUS_NONE; + p->active = active; + p->inUse = FALSE; + xf86AddDevToEntity(num, dev); + p->access = xnfcalloc(1,sizeof(EntityAccessRec)); + p->access->fallback = &AccessNULL; + p->access->pAccess = &AccessNULL; + p->busAcc = NULL; + + return num; +} diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c new file mode 100644 index 000000000..d5ae75b3a --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86pciBus.c @@ -0,0 +1,962 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the interfaces to the bus-specific code + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include "os.h" +#include "Pci.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Resources.h" + +/* Bus-specific headers */ +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#define NEED_OS_RAC_PROTOS +#include "xf86_OSproc.h" + +#include "xf86RAC.h" + +/* Bus-specific globals */ +Bool pciSlotClaimed = FALSE; +static struct pci_device ** xf86PciVideoInfo = NULL; /* PCI probe for video hw */ + + +/* PCI classes that get included in xf86PciVideoInfo */ +#define PCIINFOCLASSES(c) \ + ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \ + || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) ) + +/* + * PCI classes that have messages printed always. The others are only + * have a message printed when the vendor/dev IDs are recognised. + */ +#define PCIALWAYSPRINTCLASSES(c) \ + ( (((c) & 0x00ffff00) \ + == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \ + || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) ) + +#define IS_VGA(c) \ + (((c) & 0x00ffff00) \ + == ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8))) + +/* + * PCI classes for which potentially destructive checking of the map sizes + * may be done. Any classes where this may be unsafe should be omitted + * from this list. + */ +#define PCINONSYSTEMCLASSES(c) PCIALWAYSPRINTCLASSES(c) + +/* + * PCI classes that use RAC + */ +#define PCISHAREDIOCLASSES(c) \ + ( (((c) & 0x00ffff00) \ + == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \ + || IS_VGA(c) ) + + +_X_EXPORT void +xf86FormatPciBusNumber(int busnum, char *buffer) +{ + /* 'buffer' should be at least 8 characters long */ + if (busnum < 256) + sprintf(buffer, "%d", busnum); + else + sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8); +} + +/* + * IO enable/disable related routines for PCI + */ +#define pArg ((pciArg*)arg) +#define SETBITS PCI_CMD_IO_ENABLE +static void +pciIoAccessEnable(void* arg) +{ +#if 0 +#ifdef DEBUG + ErrorF("pciIoAccessEnable: 0x%05lx\n", *(PCITAG *)arg); +#endif + pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE; + pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG); +#endif +} + +static void +pciIoAccessDisable(void* arg) +{ +#if 0 +#ifdef DEBUG + ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg); +#endif + pArg->ctrl &= ~SETBITS; + pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG); +#endif +} + +#undef SETBITS +#define SETBITS (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE) +static void +pciIo_MemAccessEnable(void* arg) +{ +#if 0 +#ifdef DEBUG + ErrorF("pciIo_MemAccessEnable: 0x%05lx\n", *(PCITAG *)arg); +#endif + pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE; + pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG); +#endif +} + +static void +pciIo_MemAccessDisable(void* arg) +{ +#if 0 +#ifdef DEBUG + ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg); +#endif + pArg->ctrl &= ~SETBITS; + pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG); +#endif +} + +#undef SETBITS +#define SETBITS (PCI_CMD_MEM_ENABLE) +static void +pciMemAccessEnable(void* arg) +{ +#if 0 +#ifdef DEBUG + ErrorF("pciMemAccessEnable: 0x%05lx\n", *(PCITAG *)arg); +#endif + pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE; + pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG); +#endif +} + +static void +pciMemAccessDisable(void* arg) +{ +#if 0 +#ifdef DEBUG + ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg); +#endif + pArg->ctrl &= ~SETBITS; + pci_device_cfg_write_u32(pArg->dev, pArg->ctrl, PCI_CMD_STAT_REG); +#endif +} +#undef SETBITS +#undef pArg + + +/* move to OS layer */ +#define MASKBITS (PCI_PCI_BRIDGE_VGA_EN | PCI_PCI_BRIDGE_MASTER_ABORT_EN) +static void +pciBusAccessEnable(BusAccPtr ptr) +{ +#if 0 + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t ctrl; + +#ifdef DEBUG + ErrorF("pciBusAccessEnable: bus=%d\n", ptr->busdep.pci.bus); +#endif + pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); + if ((ctrl & MASKBITS) != PCI_PCI_BRIDGE_VGA_EN) { + ctrl = (ctrl | PCI_PCI_BRIDGE_VGA_EN) & + ~(PCI_PCI_BRIDGE_MASTER_ABORT_EN | PCI_PCI_BRIDGE_SECONDARY_RESET); + pci_device_cfg_write_u16(dev, ctrl, PCI_PCI_BRIDGE_CONTROL_REG); + } +#endif +} + +/* move to OS layer */ +static void +pciBusAccessDisable(BusAccPtr ptr) +{ +#if 0 + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t ctrl; + +#ifdef DEBUG + ErrorF("pciBusAccessDisable: bus=%d\n", ptr->busdep.pci.bus); +#endif + pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); + if (ctrl & MASKBITS) { + ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET); + pci_device_cfg_write_u16(dev, ctrl, PCI_PCI_BRIDGE_CONTROL_REG); + } +#endif +} +#undef MASKBITS + +static void +pciSetBusAccess(BusAccPtr ptr) +{ +#if 0 +#ifdef DEBUG + ErrorF("pciSetBusAccess: route VGA to bus %d\n", ptr->busdep.pci.bus); +#endif + + if (!ptr->primary && !ptr->current) + return; + + if (ptr->current && ptr->current->disable_f) + (*ptr->current->disable_f)(ptr->current); + ptr->current = NULL; + + /* walk down */ + while (ptr->primary) { /* No enable for root bus */ + if (ptr != ptr->primary->current) { + if (ptr->primary->current && ptr->primary->current->disable_f) + (*ptr->primary->current->disable_f)(ptr->primary->current); + if (ptr->enable_f) + (*ptr->enable_f)(ptr); + ptr->primary->current = ptr; + } + ptr = ptr->primary; + } +#endif +} + +/* move to OS layer */ +static void +savePciState( struct pci_device * dev, pciSavePtr ptr ) +{ +#if 0 + int i; + + pci_device_cfg_read_u32( dev, & ptr->command, PCI_CMD_STAT_REG ); + + for ( i = 0; i < 6; i++ ) { + pci_device_cfg_read_u32( dev, & ptr->base[i], + PCI_CMD_BASE_REG + (i * 4) ); + } + + pci_device_cfg_read_u32( dev, & ptr->biosBase, PCI_CMD_BIOS_REG ); +#endif +} + +/* move to OS layer */ +#if 0 +static void +restorePciState( struct pci_device * dev, pciSavePtr ptr) +{ + int i; + + /* disable card before setting anything */ + pci_device_cfg_write_bits(dev, PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE, 0, + PCI_CMD_STAT_REG); + + pci_device_cfg_write_u32(dev, ptr->biosBase, PCI_CMD_BIOS_REG); + + for ( i = 0; i < 6; i++ ) { + pci_device_cfg_write_u32(dev, ptr->base[i], + PCI_CMD_BASE_REG + (i * 4)); + } + + pci_device_cfg_write_u32(dev, ptr->command, PCI_CMD_STAT_REG); +} +#endif + +/* move to OS layer */ +static void +savePciBusState(BusAccPtr ptr) +{ +#if 0 + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t temp; + + pci_device_cfg_read_u16( dev, & temp, PCI_PCI_BRIDGE_CONTROL_REG ); + ptr->busdep.pci.save.control = temp & ~PCI_PCI_BRIDGE_SECONDARY_RESET; + + /* Allow master aborts to complete normally on non-root buses */ + if ( ptr->busdep.pci.save.control & PCI_PCI_BRIDGE_MASTER_ABORT_EN ) { + temp = ptr->busdep.pci.save.control & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN; + pci_device_cfg_read_u16( dev, & temp, PCI_PCI_BRIDGE_CONTROL_REG ); + } +#endif +} + +/* move to OS layer */ +#define MASKBITS (PCI_PCI_BRIDGE_VGA_EN | PCI_PCI_BRIDGE_MASTER_ABORT_EN) +static void +restorePciBusState(BusAccPtr ptr) +{ +#if 0 + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t ctrl; + + /* Only restore the bits we've changed (and don't cause resets) */ + pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); + + if ((ctrl ^ ptr->busdep.pci.save.control) & MASKBITS) { + ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET); + ctrl |= ptr->busdep.pci.save.control & MASKBITS; + pci_device_cfg_write_u16(dev, ctrl, PCI_PCI_BRIDGE_CONTROL_REG); + } +#endif +} +#undef MASKBITS + + +/* + * xf86Bus.c interface + */ + +void +xf86PciProbe(void) +{ + int i = 0, k; + int num = 0; + struct pci_device *info; + struct pci_device_iterator *iter; + + + if (!xf86scanpci()) { + xf86PciVideoInfo = NULL; + return; + } + + iter = pci_slot_match_iterator_create(& xf86IsolateDevice); + while ((info = pci_device_next(iter)) != NULL) { + if (PCIINFOCLASSES(info->device_class)) { + num++; + xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, + (sizeof(struct pci_device *) + * (num + 1))); + xf86PciVideoInfo[num] = NULL; + xf86PciVideoInfo[num - 1] = info; + + pci_device_probe(info); + info->user_data = 0; + } + } + + + /* If we haven't found a primary device try a different heuristic */ + if (primaryBus.type == BUS_NONE && num) { + for (i = 0; i < num; i++) { + uint16_t command; + + info = xf86PciVideoInfo[i]; + pci_device_cfg_read_u16(info, & command, 4); + + if ((command & PCI_CMD_MEM_ENABLE) + && ((num == 1) || IS_VGA(info->device_class))) { + if (primaryBus.type == BUS_NONE) { + primaryBus.type = BUS_PCI; + primaryBus.id.pci = info; + } else { + xf86Msg(X_NOTICE, + "More than one possible primary device found\n"); + primaryBus.type ^= (BusType)(-1); + } + } + } + } + + /* Print a summary of the video devices found */ + for (k = 0; k < num; k++) { + const char *vendorname = NULL, *chipname = NULL; + const char *prim = " "; + Bool memdone = FALSE, iodone = FALSE; + + + info = xf86PciVideoInfo[k]; + + vendorname = pci_device_get_vendor_name( info ); + chipname = pci_device_get_device_name( info ); + + if ((!vendorname || !chipname) && + !PCIALWAYSPRINTCLASSES(info->device_class)) + continue; + + if (xf86IsPrimaryPci(info)) + prim = "*"; + + xf86Msg( X_PROBED, "PCI:%s(%u@%u:%u:%u) ", prim, info->domain, + info->bus, info->dev, info->func ); + + if (vendorname) + xf86ErrorF("%s ", vendorname); + else + xf86ErrorF("unknown vendor (0x%04x) ", info->vendor_id); + + if (chipname) + xf86ErrorF("%s ", chipname); + else + xf86ErrorF("unknown chipset (0x%04x) ", info->device_id); + + xf86ErrorF("rev %d", info->revision); + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && ! r->is_IO ) { + if (!memdone) { + xf86ErrorF(", Mem @ "); + memdone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); + } + } + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && r->is_IO ) { + if (!iodone) { + xf86ErrorF(", I/O @ "); + iodone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); + } + } + + if ( info->rom_size ) { + xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", info->rom_size); + } + + xf86ErrorF("\n"); + } +} + +void +initPciState(void) +{ + unsigned i; + pciAccPtr pcaccp; + + if (xf86PciVideoInfo == NULL) { + return; + } + + for (i = 0 ; xf86PciVideoInfo[i] != NULL ; i++) { + struct pci_device * const pvp = xf86PciVideoInfo[i]; + + if (pvp->user_data == 0) { + pcaccp = xnfalloc( sizeof( pciAccRec ) ); + pvp->user_data = (intptr_t) pcaccp; + + pcaccp->arg.dev = pvp; + pcaccp->ioAccess.AccessDisable = pciIoAccessDisable; + pcaccp->ioAccess.AccessEnable = pciIoAccessEnable; + pcaccp->ioAccess.arg = &pcaccp->arg; + pcaccp->io_memAccess.AccessDisable = pciIo_MemAccessDisable; + pcaccp->io_memAccess.AccessEnable = pciIo_MemAccessEnable; + pcaccp->io_memAccess.arg = &pcaccp->arg; + pcaccp->memAccess.AccessDisable = pciMemAccessDisable; + pcaccp->memAccess.AccessEnable = pciMemAccessEnable; + pcaccp->memAccess.arg = &pcaccp->arg; + + pcaccp->ctrl = PCISHAREDIOCLASSES(pvp->device_class); + + savePciState(pvp, &pcaccp->save); + pcaccp->arg.ctrl = pcaccp->save.command; + } + } +} + +/* + * initPciBusState() - fill out the BusAccRec for a PCI bus. + * Theory: each bus is associated with one bridge connecting it + * to its parent bus. The address of a bridge is therefore stored + * in the BusAccRec of the bus it connects to. Each bus can + * have several bridges connecting secondary buses to it. Only one + * of these bridges can be open. Therefore the status of a bridge + * associated with a bus is stored in the BusAccRec of the parent + * the bridge connects to. The first member of the structure is + * a pointer to a function that open access to this bus. This function + * receives a pointer to the structure itself as argument. This + * design should be common to BusAccRecs of any type of buses we + * support. The remeinder of the structure is bus type specific. + * In this case it contains a pointer to the structure of the + * parent bus. Thus enabling access to a specific bus is simple: + * 1. Close any bridge going to secondary buses. + * 2. Climb down the ladder and enable any bridge on buses + * on the path from the CPU to this bus. + */ + +void +initPciBusState(void) +{ + static const struct pci_id_match bridge_match = { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + (PCI_CLASS_BRIDGE << 16), 0x0000ff0000, 0 + }; + struct pci_device *dev; + struct pci_device_iterator *iter; + BusAccPtr pbap, pbap_tmp; + + iter = pci_id_match_iterator_create(& bridge_match); + while((dev = pci_device_next(iter)) != NULL) { + const uint8_t subclass = (dev->device_class >> 8) & 0x0ff; + int primary; + int secondary; + int subordinate; + + + pci_device_get_bridge_buses(dev, &primary, &secondary, &subordinate); + + pbap = xnfcalloc(1,sizeof(BusAccRec)); + pbap->busdep.pci.bus = secondary; + pbap->busdep.pci.primary_bus = primary; + pbap->busdep_type = BUS_PCI; + pbap->busdep.pci.dev = dev; + + pbap->set_f = pciSetBusAccess; + + switch (subclass) { + case PCI_SUBCLASS_BRIDGE_HOST: + pbap->type = BUS_PCI; + break; + case PCI_SUBCLASS_BRIDGE_PCI: + case PCI_SUBCLASS_BRIDGE_CARDBUS: + pbap->type = BUS_PCI; + pbap->save_f = savePciBusState; + pbap->restore_f = restorePciBusState; + pbap->enable_f = pciBusAccessEnable; + pbap->disable_f = pciBusAccessDisable; + savePciBusState(pbap); + break; + case PCI_SUBCLASS_BRIDGE_ISA: + case PCI_SUBCLASS_BRIDGE_EISA: + case PCI_SUBCLASS_BRIDGE_MC: + pbap->type = BUS_ISA; + break; + } + pbap->next = xf86BusAccInfo; + xf86BusAccInfo = pbap; + } + + pci_iterator_destroy(iter); + + for (pbap = xf86BusAccInfo; pbap; pbap = pbap->next) { + pbap->primary = NULL; + + if (pbap->busdep_type == BUS_PCI + && pbap->busdep.pci.primary_bus > -1) { + pbap_tmp = xf86BusAccInfo; + while (pbap_tmp) { + if (pbap_tmp->busdep_type == BUS_PCI && + pbap_tmp->busdep.pci.bus == pbap->busdep.pci.primary_bus) { + /* Don't create loops */ + if (pbap == pbap_tmp) + break; + pbap->primary = pbap_tmp; + break; + } + pbap_tmp = pbap_tmp->next; + } + } + } +} + +void +PciStateEnter(void) +{ +#if 0 + unsigned i; + + if (xf86PciVideoInfo == NULL) + return; + + for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) { + pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data; + + if ( (paccp != NULL) && paccp->ctrl ) { + savePciState(paccp->arg.dev, &paccp->save); + restorePciState(paccp->arg.dev, &paccp->restore); + paccp->arg.ctrl = paccp->restore.command; + } + } +#endif +} + +void +PciBusStateEnter(void) +{ +#if 0 + BusAccPtr pbap = xf86BusAccInfo; + + while (pbap) { + if (pbap->save_f) + pbap->save_f(pbap); + pbap = pbap->next; + } +#endif +} + +void +PciStateLeave(void) +{ +#if 0 + unsigned i; + + if (xf86PciVideoInfo == NULL) + return; + + for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) { + pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data; + + if ( (paccp != NULL) && paccp->ctrl ) { + savePciState(paccp->arg.dev, &paccp->restore); + restorePciState(paccp->arg.dev, &paccp->save); + } + } +#endif +} + +void +PciBusStateLeave(void) +{ +#if 0 + BusAccPtr pbap = xf86BusAccInfo; + + while (pbap) { + if (pbap->restore_f) + pbap->restore_f(pbap); + pbap = pbap->next; + } +#endif +} + +void +DisablePciAccess(void) +{ +#if 0 + unsigned i; + + if (xf86PciVideoInfo == NULL) + return; + + for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) { + pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data; + + if ( (paccp != NULL) && paccp->ctrl ) { + pciIo_MemAccessDisable(paccp->io_memAccess.arg); + } + } +#endif +} + +void +DisablePciBusAccess(void) +{ +#if 0 + BusAccPtr pbap = xf86BusAccInfo; + + while (pbap) { + if (pbap->disable_f) + pbap->disable_f(pbap); + if (pbap->primary) + pbap->primary->current = NULL; + pbap = pbap->next; + } +#endif +} + +/* + * If the slot requested is already in use, return -1. + * Otherwise, claim the slot for the screen requesting it. + */ + +_X_EXPORT int +xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active) +{ + EntityPtr p = NULL; + pciAccPtr paccp = (pciAccPtr) d->user_data; + BusAccPtr pbap = xf86BusAccInfo; + const unsigned bus = PCI_MAKE_BUS(d->domain, d->bus); + + int num; + + if (xf86CheckPciSlot(d)) { + num = xf86AllocateEntity(); + p = xf86Entities[num]; + p->driver = drvp; + p->chipset = chipset; + p->bus.type = BUS_PCI; + p->bus.id.pci = d; + p->active = active; + p->inUse = FALSE; + if (dev) + xf86AddDevToEntity(num, dev); + /* Here we initialize the access structure */ + p->access = xnfcalloc(1,sizeof(EntityAccessRec)); + if (paccp != NULL) { + p->access->fallback = & paccp->io_memAccess; + p->access->pAccess = & paccp->io_memAccess; + paccp->ctrl = TRUE; /* mark control if not already */ + } + else { + p->access->fallback = &AccessNULL; + p->access->pAccess = &AccessNULL; + } + + p->busAcc = NULL; + while (pbap) { + if (pbap->type == BUS_PCI && pbap->busdep.pci.bus == bus) + p->busAcc = pbap; + pbap = pbap->next; + } + + pciSlotClaimed = TRUE; + + if (active) { + /* Map in this domain's I/O space */ + p->domainIO = xf86MapLegacyIO(d); + } + + return num; + } else + return -1; +} + +/* + * Parse a BUS ID string, and return the PCI bus parameters if it was + * in the correct format for a PCI bus id. + */ + +_X_EXPORT Bool +xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func) +{ + /* + * The format is assumed to be "bus[@domain]:device[:func]", where domain, + * bus, device and func are decimal integers. domain and func may be + * omitted and assumed to be zero, although doing this isn't encouraged. + */ + + char *p, *s, *d; + const char *id; + int i; + + if (StringToBusType(busID, &id) != BUS_PCI) + return FALSE; + + s = xstrdup(id); + p = strtok(s, ":"); + if (p == NULL || *p == 0) { + xfree(s); + return FALSE; + } + d = strpbrk(p, "@"); + if (d != NULL) { + *(d++) = 0; + for (i = 0; d[i] != 0; i++) { + if (!isdigit(d[i])) { + xfree(s); + return FALSE; + } + } + } + for (i = 0; p[i] != 0; i++) { + if (!isdigit(p[i])) { + xfree(s); + return FALSE; + } + } + *bus = atoi(p); + if (d != NULL && *d != 0) + *bus += atoi(d) << 8; + p = strtok(NULL, ":"); + if (p == NULL || *p == 0) { + xfree(s); + return FALSE; + } + for (i = 0; p[i] != 0; i++) { + if (!isdigit(p[i])) { + xfree(s); + return FALSE; + } + } + *device = atoi(p); + *func = 0; + p = strtok(NULL, ":"); + if (p == NULL || *p == 0) { + xfree(s); + return TRUE; + } + for (i = 0; p[i] != 0; i++) { + if (!isdigit(p[i])) { + xfree(s); + return FALSE; + } + } + *func = atoi(p); + xfree(s); + return TRUE; +} + +/* + * Compare a BUS ID string with a PCI bus id. Return TRUE if they match. + */ + +_X_EXPORT Bool +xf86ComparePciBusString(const char *busID, int bus, int device, int func) +{ + int ibus, idevice, ifunc; + + if (xf86ParsePciBusString(busID, &ibus, &idevice, &ifunc)) { + return bus == ibus && device == idevice && func == ifunc; + } else { + return FALSE; + } +} + +/* + * xf86IsPrimaryPci() -- return TRUE if primary device + * is PCI and bus, dev and func numbers match. + */ + +_X_EXPORT Bool +xf86IsPrimaryPci(struct pci_device *pPci) +{ + return ((primaryBus.type == BUS_PCI) && (pPci == primaryBus.id.pci)); +} + +/* + * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity. + */ +_X_EXPORT struct pci_device * +xf86GetPciInfoForEntity(int entityIndex) +{ + EntityPtr p; + + if (entityIndex >= xf86NumEntities) + return NULL; + + p = xf86Entities[entityIndex]; + return (p->bus.type == BUS_PCI) ? p->bus.id.pci : NULL; +} + +/* + * xf86CheckPciMemBase() checks that the memory base value matches one of the + * PCI base address register values for the given PCI device. + */ +_X_EXPORT Bool +xf86CheckPciMemBase( struct pci_device * pPci, memType base ) +{ + int i; + + for (i = 0; i < 6; i++) + if (base == pPci->regions[i].base_addr) + return TRUE; + return FALSE; +} + +/* + * Check if the slot requested is free. If it is already in use, return FALSE. + */ + +_X_EXPORT Bool +xf86CheckPciSlot(const struct pci_device *d) +{ + int i; + + for (i = 0; i < xf86NumEntities; i++) { + const EntityPtr p = xf86Entities[i]; + + if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) { + return FALSE; + } + } + return TRUE; +} + + +void +pciConvertRange2Host(int entityIndex, resRange *pRange) +{ + struct pci_device *const pvp = xf86GetPciInfoForEntity(entityIndex); + const PCITAG tag = PCI_MAKE_TAG(PCI_MAKE_BUS(pvp->domain, pvp->bus), + pvp->dev, pvp->func); + + if (pvp == NULL) { + return; + } + + if (!(pRange->type & ResBus)) + return; + + switch(pRange->type & ResPhysMask) { + case ResMem: + switch(pRange->type & ResExtMask) { + case ResBlock: + pRange->rBegin = pciBusAddrToHostAddr(tag,PCI_MEM, pRange->rBegin); + pRange->rEnd = pciBusAddrToHostAddr(tag,PCI_MEM, pRange->rEnd); + break; + case ResSparse: + pRange->rBase = pciBusAddrToHostAddr(tag,PCI_MEM_SPARSE_BASE, + pRange->rBegin); + pRange->rMask = pciBusAddrToHostAddr(tag,PCI_MEM_SPARSE_MASK, + pRange->rEnd); + break; + } + break; + case ResIo: + switch(pRange->type & ResExtMask) { + case ResBlock: + pRange->rBegin = pciBusAddrToHostAddr(tag,PCI_IO, pRange->rBegin); + pRange->rEnd = pciBusAddrToHostAddr(tag,PCI_IO, pRange->rEnd); + break; + case ResSparse: + pRange->rBase = pciBusAddrToHostAddr(tag,PCI_IO_SPARSE_BASE + , pRange->rBegin); + pRange->rMask = pciBusAddrToHostAddr(tag,PCI_IO_SPARSE_MASK + , pRange->rEnd); + break; + } + break; + } + + /* Set domain number */ + pRange->type &= ~(ResDomain | ResBus); + pRange->type |= pvp->domain << 24; +} diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.h b/xorg-server/hw/xfree86/common/xf86pciBus.h new file mode 100644 index 000000000..7d08502fc --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86pciBus.h @@ -0,0 +1,75 @@ + +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef _XF86_PCI_BUS_H +#define _XF86_PCI_BUS_H + +#define PCITAG_SPECIAL pciTag(0xFF,0xFF,0xFF) + +typedef struct { + CARD32 command; + CARD32 base[6]; + CARD32 biosBase; +} pciSave, *pciSavePtr; + +typedef struct { + struct pci_device * dev; + CARD32 ctrl; +} pciArg; + +typedef struct { + pciArg arg; + xf86AccessRec ioAccess; + xf86AccessRec io_memAccess; + xf86AccessRec memAccess; + pciSave save; + pciSave restore; + Bool ctrl; +} pciAccRec, *pciAccPtr; + +typedef union { + CARD16 control; +} pciBridgesSave, *pciBridgesSavePtr; + +void xf86PciProbe(void); +void initPciState(void); +void initPciBusState(void); +void DisablePciAccess(void); +void DisablePciBusAccess(void); +void PciStateEnter(void); +void PciBusStateEnter(void); +void PciStateLeave(void); +void PciBusStateLeave(void); +void pciConvertRange2Host(int entityIndex, resRange *pRange); +void isaConvertRange2Host(resRange *pRange); + +#endif /* _XF86_PCI_BUS_H */ diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c new file mode 100644 index 000000000..63d1cb31c --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86sbusBus.c @@ -0,0 +1,703 @@ +/* + * SBUS bus-specific code. + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * 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 + * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86Resources.h" +#include "xf86cmap.h" + +#include "xf86Bus.h" + +#include "xf86sbusBus.h" +#include "xf86Sbus.h" + +Bool sbusSlotClaimed = FALSE; + +static int xf86nSbusInfo; + +static void +CheckSbusDevice(const char *device, int fbNum) +{ + int fd, i; + struct fbgattr fbattr; + sbusDevicePtr psdp; + + fd = open(device, O_RDONLY, 0); + if (fd < 0) + return; + memset(&fbattr, 0, sizeof(fbattr)); + if (ioctl(fd, FBIOGATTR, &fbattr) < 0) { + if (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0) { + close(fd); + return; + } + } + close(fd); + for (i = 0; sbusDeviceTable[i].devId; i++) + if (sbusDeviceTable[i].fbType == fbattr.fbtype.fb_type) + break; + if (! sbusDeviceTable[i].devId) + return; + xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (++xf86nSbusInfo + 1)); + xf86SbusInfo[xf86nSbusInfo] = NULL; + xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof (sbusDevice), 1); + psdp->devId = sbusDeviceTable[i].devId; + psdp->fbNum = fbNum; + psdp->device = xnfstrdup(device); + psdp->width = fbattr.fbtype.fb_width; + psdp->height = fbattr.fbtype.fb_height; + psdp->fd = -1; +} + +void +xf86SbusProbe(void) +{ + int i, useProm = 0; + char fbDevName[32]; + sbusDevicePtr psdp, *psdpp; + + xf86SbusInfo = xalloc(sizeof(psdp)); + *xf86SbusInfo = NULL; + for (i = 0; i < 32; i++) { + sprintf(fbDevName, "/dev/fb%d", i); + CheckSbusDevice(fbDevName, i); + } + if (sparcPromInit() >= 0) { + useProm = 1; + sparcPromAssignNodes(); + } + for (psdpp = xf86SbusInfo; (psdp = *psdpp); psdpp++) { + for (i = 0; sbusDeviceTable[i].devId; i++) + if (sbusDeviceTable[i].devId == psdp->devId) + psdp->descr = sbusDeviceTable[i].descr; + /* + * If we can use PROM information and found the PROM node for this + * device, we can tell more about the card. + */ + if (useProm && psdp->node.node) { + char *prop, *promPath; + int len, chiprev, vmsize; + + switch (psdp->devId) { + case SBUS_DEVICE_MGX: + prop = sparcPromGetProperty(&psdp->node, "fb_size", &len); + if (prop && len == 4 && *(int *)prop == 0x400000) + psdp->descr = "Quantum 3D MGXplus with 4M VRAM"; + break; + case SBUS_DEVICE_CG6: + chiprev = 0; + vmsize = 0; + prop = sparcPromGetProperty(&psdp->node, "chiprev", &len); + if (prop && len == 4) + chiprev = *(int *)prop; + prop = sparcPromGetProperty(&psdp->node, "vmsize", &len); + if (prop && len == 4) + vmsize = *(int *)prop; + switch (chiprev) { + case 1: + case 2: + case 3: + case 4: + psdp->descr = "Sun Double width GX"; break; + case 5: + case 6: + case 7: + case 8: + case 9: + psdp->descr = "Sun Single width GX"; break; + case 11: + switch (vmsize) { + case 2: + psdp->descr = "Sun Turbo GX with 1M VSIMM"; break; + case 4: + psdp->descr = "Sun Turbo GX Plus"; break; + default: + psdp->descr = "Sun Turbo GX"; break; + } + } + break; + case SBUS_DEVICE_CG14: + prop = sparcPromGetProperty(&psdp->node, "reg", &len); + vmsize = 0; + if (prop && !(len % 12) && len > 0) + vmsize = *(int *)(prop + len - 4); + switch (vmsize) { + case 0x400000: + psdp->descr = "Sun SX with 4M VSIMM"; break; + case 0x800000: + psdp->descr = "Sun SX with 8M VSIMM"; break; + } + break; + case SBUS_DEVICE_LEO: + prop = sparcPromGetProperty(&psdp->node, "model", &len); + if (prop && len > 0 && !strstr(prop, "501-2503")) + psdp->descr = "Sun Turbo ZX"; + break; + case SBUS_DEVICE_TCX: + if (sparcPromGetBool(&psdp->node, "tcx-8-bit")) + psdp->descr = "Sun TCX (8bit)"; + else + psdp->descr = "Sun TCX (S24)"; + break; + case SBUS_DEVICE_FFB: + prop = sparcPromGetProperty(&psdp->node, "name", &len); + chiprev = 0; + prop = sparcPromGetProperty(&psdp->node, "board_type", &len); + if (prop && len == 4) + chiprev = *(int *)prop; + if (strstr (prop, "afb")) { + if (chiprev == 3) + psdp->descr = "Sun|Elite3D-M6 Horizontal"; + } else { + switch (chiprev) { + case 0x08: + psdp->descr = "Sun FFB 67MHz Creator"; break; + case 0x0b: + psdp->descr = "Sun FFB 67MHz Creator 3D"; break; + case 0x1b: + psdp->descr = "Sun FFB 75MHz Creator 3D"; break; + case 0x20: + case 0x28: + psdp->descr = "Sun FFB2 Vertical Creator"; break; + case 0x23: + case 0x2b: + psdp->descr = "Sun FFB2 Vertical Creator 3D"; break; + case 0x30: + psdp->descr = "Sun FFB2+ Vertical Creator"; break; + case 0x33: + psdp->descr = "Sun FFB2+ Vertical Creator 3D"; break; + case 0x40: + case 0x48: + psdp->descr = "Sun FFB2 Horizontal Creator"; break; + case 0x43: + case 0x4b: + psdp->descr = "Sun FFB2 Horizontal Creator 3D"; break; + } + } + break; + } + + xf86Msg(X_PROBED, "SBUS:(0x%08x) %s", psdp->node.node, psdp->descr); + promPath = sparcPromNode2Pathname (&psdp->node); + if (promPath) { + xf86ErrorF(" at %s", promPath); + xfree(promPath); + } + } else + xf86Msg(X_PROBED, "SBUS: %s", psdp->descr); + xf86ErrorF("\n"); + } + if (useProm) + sparcPromClose(); +} + +/* + * Parse a BUS ID string, and return the SBUS bus parameters if it was + * in the correct format for a SBUS bus id. + */ + +Bool +xf86ParseSbusBusString(const char *busID, int *fbNum) +{ + /* + * The format is assumed to be one of: + * "fbN", e.g. "fb1", which means the device corresponding to /dev/fbN + * "nameN", e.g. "cgsix0", which means Nth instance of card NAME + * "/prompath", e.g. "/sbus@0,10001000/cgsix@3,0" which is PROM pathname + * to the device. + */ + + const char *id; + int i, len; + + if (StringToBusType(busID, &id) != BUS_SBUS) + return FALSE; + + if (*id != '/') { + if (!strncmp (id, "fb", 2)) { + if (!isdigit(id[2])) + return FALSE; + *fbNum = atoi(id + 2); + return TRUE; + } else { + sbusDevicePtr *psdpp; + int devId; + + for (i = 0, len = 0; sbusDeviceTable[i].devId; i++) { + len = strlen(sbusDeviceTable[i].promName); + if (!strncmp (sbusDeviceTable[i].promName, id, len) + && isdigit(id[len])) + break; + } + devId = sbusDeviceTable[i].devId; + if (!devId) return FALSE; + i = atoi(id + len); + for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) { + if ((*psdpp)->devId != devId) + continue; + if (!i) { + *fbNum = (*psdpp)->fbNum; + return TRUE; + } + i--; + } + } + return FALSE; + } + + if (sparcPromInit() >= 0) { + i = sparcPromPathname2Node(id); + sparcPromClose(); + if (i) { + sbusDevicePtr *psdpp; + for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) { + if ((*psdpp)->node.node == i) { + *fbNum = (*psdpp)->fbNum; + return TRUE; + } + } + } + } + return FALSE; +} + +/* + * Compare a BUS ID string with a SBUS bus id. Return TRUE if they match. + */ + +Bool +xf86CompareSbusBusString(const char *busID, int fbNum) +{ + int iFbNum; + + if (xf86ParseSbusBusString(busID, &iFbNum)) { + return fbNum == iFbNum; + } else { + return FALSE; + } +} + +/* + * Check if the slot requested is free. If it is already in use, return FALSE. + */ + +Bool +xf86CheckSbusSlot(int fbNum) +{ + int i; + EntityPtr p; + + for (i = 0; i < xf86NumEntities; i++) { + p = xf86Entities[i]; + /* Check if this SBUS slot is taken */ + if (p->busType == BUS_SBUS && p->sbusBusId.fbNum == fbNum) + return FALSE; + } + + return TRUE; +} + +/* + * If the slot requested is already in use, return -1. + * Otherwise, claim the slot for the screen requesting it. + */ + +int +xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp, + GDevPtr dev, Bool active) +{ + EntityPtr p = NULL; + + int num; + + if (xf86CheckSbusSlot(psdp->fbNum)) { + num = xf86AllocateEntity(); + p = xf86Entities[num]; + p->driver = drvp; + p->chipset = -1; + p->busType = BUS_SBUS; + xf86AddDevToEntity(num, dev); + p->sbusBusId.fbNum = psdp->fbNum; + p->active = active; + p->inUse = FALSE; + /* Here we initialize the access structure */ + p->access = xnfcalloc(1,sizeof(EntityAccessRec)); + p->access->fallback = &AccessNULL; + p->access->pAccess = &AccessNULL; + sbusSlotClaimed = TRUE; + return num; + } else + return -1; +} + +_X_EXPORT int +xf86MatchSbusInstances(const char *driverName, int sbusDevId, + GDevPtr *devList, int numDevs, DriverPtr drvp, + int **foundEntities) +{ + int i,j; + sbusDevicePtr psdp, *psdpp; + int numClaimedInstances = 0; + int allocatedInstances = 0; + int numFound = 0; + GDevPtr devBus = NULL; + GDevPtr dev = NULL; + int *retEntities = NULL; + int useProm = 0; + + struct Inst { + sbusDevicePtr sbus; + GDevPtr dev; + Bool claimed; /* BusID matches with a device section */ + } *instances = NULL; + + *foundEntities = NULL; + for (psdpp = xf86SbusInfo, psdp = *psdpp; psdp; psdp = *++psdpp) { + if (psdp->devId != sbusDevId) + continue; + if (psdp->fd == -2) + continue; + ++allocatedInstances; + instances = xnfrealloc(instances, + allocatedInstances * sizeof(struct Inst)); + instances[allocatedInstances - 1].sbus = psdp; + instances[allocatedInstances - 1].dev = NULL; + instances[allocatedInstances - 1].claimed = FALSE; + numFound++; + } + + /* + * This may be debatable, but if no SBUS devices with a matching vendor + * type is found, return zero now. It is probably not desirable to + * allow the config file to override this. + */ + if (allocatedInstances <= 0) { + xfree(instances); + return 0; + } + + if (xf86DoProbe) { + xfree(instances); + return numFound; + } + + if (sparcPromInit() >= 0) + useProm = 1; + + if (xf86DoConfigure && xf86DoConfigurePass1) { + GDevPtr pGDev; + int actualcards = 0; + for (i = 0; i < allocatedInstances; i++) { + actualcards++; + pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS, + instances[i].sbus, -1); + if (pGDev) { + /* + * XF86Match???Instances() treat chipID and chipRev as + * overrides, so clobber them here. + */ + pGDev->chipID = pGDev->chipRev = -1; + } + } + xfree(instances); + if (useProm) + sparcPromClose(); + return actualcards; + } + +#ifdef DEBUG + ErrorF("%s instances found: %d\n", driverName, allocatedInstances); +#endif + + for (i = 0; i < allocatedInstances; i++) { + char *promPath = NULL; + + psdp = instances[i].sbus; + devBus = NULL; + dev = NULL; + if (useProm && psdp->node.node) + promPath = sparcPromNode2Pathname(&psdp->node); + + for (j = 0; j < numDevs; j++) { + if (devList[j]->busID && *devList[j]->busID) { + if (xf86CompareSbusBusString(devList[j]->busID, psdp->fbNum)) { + if (devBus) + xf86MsgVerb(X_WARNING,0, + "%s: More than one matching Device section for " + "instance (BusID: %s) found: %s\n", + driverName,devList[j]->identifier, + devList[j]->busID); + else + devBus = devList[j]; + } + } else { + if (!dev && !devBus) { + if (promPath) + xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:%s\n", + promPath); + else + xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:fb%d\n", + psdp->fbNum); + dev = devList[j]; + } else + xf86MsgVerb(X_WARNING, 0, + "%s: More than one matching Device section " + "found: %s\n", driverName, devList[j]->identifier); + } + } + if (devBus) dev = devBus; /* busID preferred */ + if (!dev && psdp->fd != -2) { + if (promPath) { + xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " + "for instance (BusID SBUS:%s) found\n", + driverName, promPath); + } else + xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " + "for instance (BusID SBUS:fb%d) found\n", + driverName, psdp->fbNum); + } else if (dev) { + numClaimedInstances++; + instances[i].claimed = TRUE; + instances[i].dev = dev; + } + if (promPath) + xfree(promPath); + } + +#ifdef DEBUG + ErrorF("%s instances found: %d\n", driverName, numClaimedInstances); +#endif + + /* + * Of the claimed instances, check that another driver hasn't already + * claimed its slot. + */ + numFound = 0; + for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) { + if (!instances[i].claimed) + continue; + psdp = instances[i].sbus; + if (!xf86CheckSbusSlot(psdp->fbNum)) + continue; + +#ifdef DEBUG + ErrorF("%s: card at fb%d %08x is claimed by a Device section\n", + driverName, psdp->fbNum, psdp->node.node); +#endif + + /* Allocate an entry in the lists to be returned */ + numFound++; + retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); + retEntities[numFound - 1] + = xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,instances[i].dev->active ? + TRUE : FALSE); + } + xfree(instances); + if (numFound > 0) { + *foundEntities = retEntities; + } + + if (useProm) + sparcPromClose(); + + return numFound; +} + +/* + * xf86GetSbusInfoForEntity() -- Get the sbusDevicePtr of entity. + */ +_X_EXPORT sbusDevicePtr +xf86GetSbusInfoForEntity(int entityIndex) +{ + sbusDevicePtr *psdpp; + EntityPtr p = xf86Entities[entityIndex]; + + if (entityIndex >= xf86NumEntities + || p->busType != BUS_SBUS) return NULL; + + for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) { + if (p->sbusBusId.fbNum == (*psdpp)->fbNum) + return (*psdpp); + } + return NULL; +} + +_X_EXPORT int +xf86GetEntityForSbusInfo(sbusDevicePtr psdp) +{ + int i; + + for (i = 0; i < xf86NumEntities; i++) { + EntityPtr p = xf86Entities[i]; + if (p->busType != BUS_SBUS) continue; + + if (p->sbusBusId.fbNum == psdp->fbNum) + return i; + } + return -1; +} + +_X_EXPORT void +xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp) +{ + DisplayModePtr mode; + + mode = xnfcalloc(sizeof(DisplayModeRec), 1); + mode->name = "current"; + mode->next = mode; + mode->prev = mode; + mode->type = M_T_BUILTIN; + mode->Clock = 100000000; + mode->HDisplay = psdp->width; + mode->HSyncStart = psdp->width; + mode->HSyncEnd = psdp->width; + mode->HTotal = psdp->width; + mode->VDisplay = psdp->height; + mode->VSyncStart = psdp->height; + mode->VSyncEnd = psdp->height; + mode->VTotal = psdp->height; + mode->SynthClock = mode->Clock; + mode->CrtcHDisplay = mode->HDisplay; + mode->CrtcHSyncStart = mode->HSyncStart; + mode->CrtcHSyncEnd = mode->HSyncEnd; + mode->CrtcHTotal = mode->HTotal; + mode->CrtcVDisplay = mode->VDisplay; + mode->CrtcVSyncStart = mode->VSyncStart; + mode->CrtcVSyncEnd = mode->VSyncEnd; + mode->CrtcVTotal = mode->VTotal; + mode->CrtcHAdjusted = FALSE; + mode->CrtcVAdjusted = FALSE; + pScrn->modes = mode; + pScrn->virtualX = psdp->width; + pScrn->virtualY = psdp->height; +} + +static DevPrivateKey sbusPaletteKey = &sbusPaletteKey; +typedef struct _sbusCmap { + sbusDevicePtr psdp; + CloseScreenProcPtr CloseScreen; + Bool origCmapValid; + unsigned char origRed[16]; + unsigned char origGreen[16]; + unsigned char origBlue[16]; +} sbusCmapRec, *sbusCmapPtr; + +#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey)) + +static void +xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual) +{ + int i, index; + sbusCmapPtr cmap; + struct fbcmap fbcmap; + unsigned char *data = xalloc(numColors*3); + + cmap = SBUSCMAPPTR(pScrn->pScreen); + if (!cmap) return; + fbcmap.count = 0; + fbcmap.index = indices[0]; + fbcmap.red = data; + fbcmap.green = data + numColors; + fbcmap.blue = fbcmap.green + numColors; + for (i = 0; i < numColors; i++) { + index = indices[i]; + if (fbcmap.count && index != fbcmap.index + fbcmap.count) { + ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap); + fbcmap.count = 0; + fbcmap.index = index; + } + fbcmap.red[fbcmap.count] = colors[index].red; + fbcmap.green[fbcmap.count] = colors[index].green; + fbcmap.blue[fbcmap.count++] = colors[index].blue; + } + ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap); + xfree(data); +} + +static Bool +xf86SbusCmapCloseScreen(int i, ScreenPtr pScreen) +{ + sbusCmapPtr cmap; + struct fbcmap fbcmap; + + cmap = SBUSCMAPPTR(pScreen); + if (cmap->origCmapValid) { + fbcmap.index = 0; + fbcmap.count = 16; + fbcmap.red = cmap->origRed; + fbcmap.green = cmap->origGreen; + fbcmap.blue = cmap->origBlue; + ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap); + } + pScreen->CloseScreen = cmap->CloseScreen; + xfree (cmap); + return (*pScreen->CloseScreen) (i, pScreen); +} + +_X_EXPORT Bool +xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp) +{ + sbusCmapPtr cmap; + struct fbcmap fbcmap; + unsigned char data[2]; + + cmap = xnfcalloc(1, sizeof(sbusCmapRec)); + dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap); + cmap->psdp = psdp; + fbcmap.index = 0; + fbcmap.count = 16; + fbcmap.red = cmap->origRed; + fbcmap.green = cmap->origGreen; + fbcmap.blue = cmap->origBlue; + if (ioctl (psdp->fd, FBIOGETCMAP, &fbcmap) >= 0) + cmap->origCmapValid = TRUE; + fbcmap.index = 0; + fbcmap.count = 2; + fbcmap.red = data; + fbcmap.green = data; + fbcmap.blue = data; + if (pScreen->whitePixel == 0) { + data[0] = 255; + data[1] = 0; + } else { + data[0] = 0; + data[1] = 255; + } + ioctl (psdp->fd, FBIOPUTCMAP, &fbcmap); + cmap->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = xf86SbusCmapCloseScreen; + return xf86HandleColormaps(pScreen, 256, 8, + xf86SbusCmapLoadPalette, NULL, 0); +} diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.h b/xorg-server/hw/xfree86/common/xf86sbusBus.h new file mode 100644 index 000000000..8576409d4 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86sbusBus.h @@ -0,0 +1,97 @@ +/* + * SBUS bus-specific declarations + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * 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 + * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _XF86_SBUSBUS_H +#define _XF86_SBUSBUS_H + +#include "xf86str.h" + +#define SBUS_DEVICE_BW2 0x0001 +#define SBUS_DEVICE_CG2 0x0002 +#define SBUS_DEVICE_CG3 0x0003 +#define SBUS_DEVICE_CG4 0x0004 +#define SBUS_DEVICE_CG6 0x0005 +#define SBUS_DEVICE_CG8 0x0006 +#define SBUS_DEVICE_CG12 0x0007 +#define SBUS_DEVICE_CG14 0x0008 +#define SBUS_DEVICE_LEO 0x0009 +#define SBUS_DEVICE_TCX 0x000a +#define SBUS_DEVICE_FFB 0x000b +#define SBUS_DEVICE_GT 0x000c +#define SBUS_DEVICE_MGX 0x000d + +typedef struct sbus_prom_node { + int node; + /* Because of misdesigned openpromio */ + int cookie[2]; +} sbusPromNode, *sbusPromNodePtr; + +typedef struct sbus_device { + int devId; + int fbNum; + int fd; + int width, height; + sbusPromNode node; + char *descr; + char *device; +} sbusDevice, *sbusDevicePtr; + +extern struct sbus_devtable { + int devId; + int fbType; + char *promName; + char *descr; +} sbusDeviceTable[]; + +void xf86SbusProbe(void); +extern sbusDevicePtr *xf86SbusInfo; + +int xf86MatchSbusInstances(const char *driverName, int sbusDevId, + GDevPtr *devList, int numDevs, DriverPtr drvp, + int **foundEntities); +sbusDevicePtr xf86GetSbusInfoForEntity(int entityIndex); +int xf86GetEntityForSbusInfo(sbusDevicePtr psdp); +void xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp); +pointer xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, + unsigned long size); +void xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size); +void xf86SbusHideOsHwCursor(sbusDevicePtr psdp); +void xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg, int fg); +Bool xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp); + +extern int promRootNode; + +int promGetSibling(int node); +int promGetChild(int node); +char * promGetProperty(const char *prop, int *lenp); +int promGetBool(const char *prop); + +int sparcPromInit(void); +void sparcPromClose(void); +char * sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp); +int sparcPromGetBool(sbusPromNodePtr pnode, const char *prop); +void sparcPromAssignNodes(void); +char * sparcPromNode2Pathname(sbusPromNodePtr pnode); +int sparcPromPathname2Node(const char *pathName); + +#endif /* _XF86_SBUSBUS_H */ diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h new file mode 100644 index 000000000..fc94284cb --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86str.h @@ -0,0 +1,1162 @@ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains definitions of the public XFree86 data structures/types. + * Any data structures that video drivers need to access should go here. + */ + +#ifndef _XF86STR_H +#define _XF86STR_H + +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "colormapst.h" +#include "xf86Module.h" +#include "xf86Opt.h" +#include "xf86Pci.h" + +#include + +/** + * Integer type that is of the size of the addressable memory (machine size). + * On most platforms \c uintptr_t will suffice. However, on some mixed + * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this + * must be 64-bits. + */ +#include +#if defined(__powerpc__) +typedef uint64_t memType; +#else +typedef uintptr_t memType; +#endif + + +/* Video mode flags */ + +typedef enum { + V_PHSYNC = 0x0001, + V_NHSYNC = 0x0002, + V_PVSYNC = 0x0004, + V_NVSYNC = 0x0008, + V_INTERLACE = 0x0010, + V_DBLSCAN = 0x0020, + V_CSYNC = 0x0040, + V_PCSYNC = 0x0080, + V_NCSYNC = 0x0100, + V_HSKEW = 0x0200, /* hskew provided */ + V_BCAST = 0x0400, + V_PIXMUX = 0x1000, + V_DBLCLK = 0x2000, + V_CLKDIV2 = 0x4000 +} ModeFlags; + +typedef enum { + INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */ +} CrtcAdjustFlags; + +/* Flags passed to ChipValidMode() */ +typedef enum { + MODECHECK_INITIAL = 0, + MODECHECK_FINAL = 1 +} ModeCheckFlags; + +/* These are possible return values for xf86CheckMode() and ValidMode() */ +typedef enum { + MODE_OK = 0, /* Mode OK */ + MODE_HSYNC, /* hsync out of range */ + MODE_VSYNC, /* vsync out of range */ + MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_BAD_WIDTH, /* requires an unsupported linepitch */ + MODE_NOMODE, /* no mode with a maching name */ + MODE_NO_INTERLACE, /* interlaced mode not supported */ + MODE_NO_DBLESCAN, /* doublescan mode not supported */ + MODE_NO_VSCAN, /* multiscan mode not supported */ + MODE_MEM, /* insufficient video memory */ + MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ + MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ + MODE_MEM_VIRT, /* insufficient video memory given virtual size */ + MODE_NOCLOCK, /* no fixed clock available */ + MODE_CLOCK_HIGH, /* clock required is too high */ + MODE_CLOCK_LOW, /* clock required is too low */ + MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ + MODE_BAD_HVALUE, /* horizontal timing was out of range */ + MODE_BAD_VVALUE, /* vertical timing was out of range */ + MODE_BAD_VSCAN, /* VScan value out of range */ + MODE_HSYNC_NARROW, /* horizontal sync too narrow */ + MODE_HSYNC_WIDE, /* horizontal sync too wide */ + MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ + MODE_HBLANK_WIDE, /* horizontal blanking too wide */ + MODE_VSYNC_NARROW, /* vertical sync too narrow */ + MODE_VSYNC_WIDE, /* vertical sync too wide */ + MODE_VBLANK_NARROW, /* vertical blanking too narrow */ + MODE_VBLANK_WIDE, /* vertical blanking too wide */ + MODE_PANEL, /* exceeds panel dimensions */ + MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ + MODE_ONE_WIDTH, /* only one width is supported */ + MODE_ONE_HEIGHT, /* only one height is supported */ + MODE_ONE_SIZE, /* only one resolution is supported */ + MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ + MODE_BANDWIDTH, /* mode requires too much memory bandwidth */ + MODE_BAD = -2, /* unspecified reason */ + MODE_ERROR = -1 /* error condition */ +} ModeStatus; + +/* + * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN. + * Preferred will bubble a mode to the top within a set. + */ +# define M_T_BUILTIN 0x01 /* built-in mode */ +# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */ +# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */ +# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C) + /* built-in mode - configure CRTC and clock */ +# define M_T_PREFERRED 0x08 /* preferred mode within a set */ +# define M_T_DEFAULT 0x10 /* (VESA) default modes */ +# define M_T_USERDEF 0x20 /* One of the modes from the config file */ +# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */ +# define M_T_USERPREF 0x80 /* mode preferred by the user config */ + +/* Video mode */ +typedef struct _DisplayModeRec { + struct _DisplayModeRec * prev; + struct _DisplayModeRec * next; + char * name; /* identifier for the mode */ + ModeStatus status; + int type; + + /* These are the values that the user sees/provides */ + int Clock; /* pixel clock freq (kHz) */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int HSkew; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int VScan; + int Flags; + + /* These are the values the hardware uses */ + int ClockIndex; + int SynthClock; /* Actual clock freq to + * be programmed (kHz) */ + int CrtcHDisplay; + int CrtcHBlankStart; + int CrtcHSyncStart; + int CrtcHSyncEnd; + int CrtcHBlankEnd; + int CrtcHTotal; + int CrtcHSkew; + int CrtcVDisplay; + int CrtcVBlankStart; + int CrtcVSyncStart; + int CrtcVSyncEnd; + int CrtcVBlankEnd; + int CrtcVTotal; + Bool CrtcHAdjusted; + Bool CrtcVAdjusted; + int PrivSize; + INT32 * Private; + int PrivFlags; + + float HSync, VRefresh; +} DisplayModeRec, *DisplayModePtr; + +/* The monitor description */ + +#define MAX_HSYNC 8 +#define MAX_VREFRESH 8 + +typedef struct { float hi, lo; } range; + +typedef struct { CARD32 red, green, blue; } rgb; + +typedef struct { float red, green, blue; } Gamma; + +/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */ +#define GAMMA_MAX 10.0 +#define GAMMA_MIN (1.0 / GAMMA_MAX) +#define GAMMA_ZERO (GAMMA_MIN / 100.0) + +typedef struct { + char * id; + char * vendor; + char * model; + int nHsync; + range hsync[MAX_HSYNC]; + int nVrefresh; + range vrefresh[MAX_VREFRESH]; + DisplayModePtr Modes; /* Start of the monitor's mode list */ + DisplayModePtr Last; /* End of the monitor's mode list */ + Gamma gamma; /* Gamma of the monitor */ + int widthmm; + int heightmm; + pointer options; + pointer DDC; + Bool reducedblanking; /* Allow CVT reduced blanking modes? */ + int maxPixClock; /* in kHz, like mode->Clock */ +} MonRec, *MonPtr; + +/* the list of clock ranges */ +typedef struct x_ClockRange { + struct x_ClockRange *next; + int minClock; /* (kHz) */ + int maxClock; /* (kHz) */ + int clockIndex; /* -1 for programmable clocks */ + Bool interlaceAllowed; + Bool doubleScanAllowed; + int ClockMulFactor; + int ClockDivFactor; + int PrivFlags; +} ClockRange, *ClockRangePtr; + +/* Need to store the strategy with clockRange for VidMode extension */ +typedef struct x_ClockRanges { + struct x_ClockRanges *next; + int minClock; + int maxClock; + int clockIndex; /* -1 for programmable clocks */ + Bool interlaceAllowed; + Bool doubleScanAllowed; + int ClockMulFactor; + int ClockDivFactor; + int PrivFlags; + int strategy; +} ClockRanges, *ClockRangesPtr; + +/* + * The driverFunc. xorgDriverFuncOp specifies the action driver should + * perform. If requested option is not supported function should return + * FALSE. pointer can be used to pass arguments to the function or + * to return data to the caller. + */ +typedef struct _ScrnInfoRec *ScrnInfoPtr; + +/* do not change order */ +typedef enum { + RR_GET_INFO, + RR_SET_CONFIG, + RR_GET_MODE_MM, + GET_REQUIRED_HW_INTERFACES = 10 +} xorgDriverFuncOp; + +typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp, + pointer); + +/* RR_GET_INFO, RR_SET_CONFIG */ +typedef struct { + int rotation; + int rate; + int width; + int height; +} xorgRRConfig; + +typedef union { + short RRRotations; + xorgRRConfig RRConfig; +} xorgRRRotation, *xorgRRRotationPtr; + +/* RR_GET_MODE_MM */ +typedef struct { + DisplayModePtr mode; + int virtX; + int virtY; + int mmWidth; + int mmHeight; +} xorgRRModeMM, *xorgRRModeMMPtr; + +/* GET_REQUIRED_HW_INTERFACES */ +#define HW_IO 1 +#define HW_MMIO 2 +#define NEED_IO_ENABLED(x) (x & HW_IO) + +typedef CARD32 xorgHWFlags; + +/* + * The driver list struct. This contains the information required for each + * driver before a ScrnInfoRec has been allocated. + */ +struct _DriverRec; + +typedef struct { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + Bool (*Probe)(struct _DriverRec *drv, int flags); + const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); + pointer module; + int refCount; +} DriverRec1; + +struct _SymTabRec; +struct _PciChipsets; + +typedef struct _DriverRec { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + Bool (*Probe)(struct _DriverRec *drv, int flags); + const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); + pointer module; + int refCount; + xorgDriverFuncProc *driverFunc; + + const struct pci_id_match * supported_devices; + Bool (*PciProbe)( struct _DriverRec * drv, int entity_num, + struct pci_device * dev, intptr_t match_data ); +} DriverRec, *DriverPtr; + +/* + * AddDriver flags + */ +#define HaveDriverFuncs 1 + + +/* + * The optional module list struct. This allows modules exporting helping + * functions to configuration tools, the Xserver, or any other + * application/module interested in such information. + */ +_X_DEPRECATED typedef struct _ModuleInfoRec { + int moduleVersion; + char * moduleName; + pointer module; + int refCount; + const OptionInfoRec * (*AvailableOptions)(void *unused); + pointer unused[8]; /* leave some space for more fields */ +} ModuleInfoRec, *ModuleInfoPtr; + +/* + * These are the private bus types. New types can be added here. Types + * required for the public interface should be added to xf86str.h, with + * function prototypes added to xf86.h. + */ + +/* Tolerate prior #include */ +#if defined(linux) && defined(_INPUT_H) +#undef BUS_NONE +#undef BUS_ISA +#undef BUS_PCI +#undef BUS_SBUS +#undef BUS_last +#endif + +typedef enum { + BUS_NONE, + BUS_ISA, + BUS_PCI, + BUS_SBUS, + BUS_last /* Keep last */ +} BusType; + +struct pci_device; + +typedef struct { + unsigned int dummy; +} IsaBusId; + +typedef struct { + int fbNum; +} SbusBusId; + +typedef struct _bus { + BusType type; + union { + IsaBusId isa; + struct pci_device *pci; + SbusBusId sbus; + } id; +} BusRec, *BusPtr; + +#define MAXCLOCKS 128 +typedef enum { + DAC_BPP8 = 0, + DAC_BPP16, + DAC_BPP24, + DAC_BPP32, + MAXDACSPEEDS +} DacSpeedIndex; + +typedef struct { + char * identifier; + char * vendor; + char * board; + char * chipset; + char * ramdac; + char * driver; + struct _confscreenrec * myScreenSection; + Bool claimed; + int dacSpeeds[MAXDACSPEEDS]; + int numclocks; + int clock[MAXCLOCKS]; + char * clockchip; + char * busID; + Bool active; + Bool inUse; + int videoRam; + int textClockFreq; + unsigned long BiosBase; /* Base address of video BIOS */ + unsigned long MemBase; /* Frame buffer base address */ + unsigned long IOBase; + int chipID; + int chipRev; + pointer options; + int irq; + int screen; /* For multi-CRTC cards */ +} GDevRec, *GDevPtr; + +typedef int (*FindIsaDevProc)(GDevPtr dev); + +typedef struct { + char * identifier; + char * driver; + pointer commonOptions; + pointer extraOptions; +} IDevRec, *IDevPtr; + +typedef struct { + int frameX0; + int frameY0; + int virtualX; + int virtualY; + int depth; + int fbbpp; + rgb weight; + rgb blackColour; + rgb whiteColour; + int defaultVisual; + char ** modes; + pointer options; +} DispRec, *DispPtr; + +typedef struct _confxvportrec { + char * identifier; + pointer options; +} confXvPortRec, *confXvPortPtr; + +typedef struct _confxvadaptrec { + char * identifier; + int numports; + confXvPortPtr ports; + pointer options; +} confXvAdaptorRec, *confXvAdaptorPtr; + +typedef struct _confscreenrec { + char * id; + int screennum; + int defaultdepth; + int defaultbpp; + int defaultfbbpp; + MonPtr monitor; + GDevPtr device; + int numdisplays; + DispPtr displays; + int numxvadaptors; + confXvAdaptorPtr xvadaptors; + pointer options; +} confScreenRec, *confScreenPtr; + +typedef enum { + PosObsolete = -1, + PosAbsolute = 0, + PosRightOf, + PosLeftOf, + PosAbove, + PosBelow, + PosRelative +} PositionType; + +typedef struct _screenlayoutrec { + confScreenPtr screen; + char * topname; + confScreenPtr top; + char * bottomname; + confScreenPtr bottom; + char * leftname; + confScreenPtr left; + char * rightname; + confScreenPtr right; + PositionType where; + int x; + int y; + char * refname; + confScreenPtr refscreen; +} screenLayoutRec, *screenLayoutPtr; + +typedef struct _serverlayoutrec { + char * id; + screenLayoutPtr screens; + GDevPtr inactives; + IDevPtr* inputs; /* NULL terminated */ + pointer options; +} serverLayoutRec, *serverLayoutPtr; + +typedef struct _confdribufferrec { + int count; + int size; + enum { + XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */ + } flags; +} confDRIBufferRec, *confDRIBufferPtr; + +typedef struct _confdrirec { + int group; + int mode; + int bufs_count; + confDRIBufferRec *bufs; +} confDRIRec, *confDRIPtr; + +/* These values should be adjusted when new fields are added to ScrnInfoRec */ +#define NUM_RESERVED_INTS 16 +#define NUM_RESERVED_POINTERS 15 +#define NUM_RESERVED_FUNCS 11 + +typedef pointer (*funcPointer)(void); + +/* flags for depth 24 pixmap options */ +typedef enum { + Pix24DontCare = 0, + Pix24Use24, + Pix24Use32 +} Pix24Flags; + +/* Power management events: so far we only support APM */ + +typedef enum { + XF86_APM_UNKNOWN = -1, + XF86_APM_SYS_STANDBY, + XF86_APM_SYS_SUSPEND, + XF86_APM_CRITICAL_SUSPEND, + XF86_APM_USER_STANDBY, + XF86_APM_USER_SUSPEND, + XF86_APM_STANDBY_RESUME, + XF86_APM_NORMAL_RESUME, + XF86_APM_CRITICAL_RESUME, + XF86_APM_LOW_BATTERY, + XF86_APM_POWER_STATUS_CHANGE, + XF86_APM_UPDATE_TIME, + XF86_APM_CAPABILITY_CHANGED, + XF86_APM_STANDBY_FAILED, + XF86_APM_SUSPEND_FAILED +} pmEvent; + +typedef enum { + PM_WAIT, + PM_CONTINUE, + PM_FAILED, + PM_NONE +} pmWait; + +/* + * The IO access enabler struct. This contains the address for + * the IOEnable/IODisable funcs for their specific bus along + * with a pointer to data needed by them + */ +typedef struct _AccessRec { + void (*AccessDisable)(void *arg); + void (*AccessEnable)(void *arg); + void *arg; +} xf86AccessRec, *xf86AccessPtr; + +typedef struct { + xf86AccessPtr mem; + xf86AccessPtr io; + xf86AccessPtr io_mem; +} xf86SetAccessFuncRec, *xf86SetAccessFuncPtr; + +/* bus-access-related types */ +typedef enum { + NONE, + IO, + MEM_IO, + MEM +} resType; + +typedef struct _EntityAccessRec { + xf86AccessPtr fallback; + xf86AccessPtr pAccess; + resType rt; + pointer busAcc; + struct _EntityAccessRec *next; +} EntityAccessRec, *EntityAccessPtr; + +typedef struct _CurrAccRec { + EntityAccessPtr pMemAccess; + EntityAccessPtr pIoAccess; +} xf86CurrentAccessRec, *xf86CurrentAccessPtr; + +/* new RAC */ + +/* Resource Type values */ +#define ResNone ((unsigned long)(-1)) + +#define ResMem 0x0001 +#define ResIo 0x0002 +#define ResIrq 0x0003 +#define ResDma 0x0004 +#define ResPciCfg 0x000e /* PCI Configuration space */ +#define ResPhysMask 0x000F + +#define ResExclusive 0x0010 +#define ResShared 0x0020 +#define ResAny 0x0040 +#define ResAccMask 0x0070 +#define ResUnused 0x0080 + +#define ResUnusedOpr 0x0100 +#define ResDisableOpr 0x0200 +#define ResOprMask 0x0300 + +#define ResBlock 0x0400 +#define ResSparse 0x0800 +#define ResExtMask 0x0C00 + +#define ResEstimated 0x001000 +#define ResInit 0x002000 +#define ResBios 0x004000 +#define ResMiscMask 0x00F000 + +#define ResBus 0x010000 +#define ResOverlap 0x020000 + +#if defined(__alpha__) && defined(linux) +# define ResDomain 0x1ff000000ul +#else +# define ResDomain 0xff000000ul +#endif +#define ResTypeMask (ResPhysMask | ResDomain) /* For conflict check */ + +#define ResEnd ResNone + +#define ResExcMemBlock (ResMem | ResExclusive | ResBlock) +#define ResExcIoBlock (ResIo | ResExclusive | ResBlock) +#define ResShrMemBlock (ResMem | ResShared | ResBlock) +#define ResShrIoBlock (ResIo | ResShared | ResBlock) +#define ResExcUusdMemBlock (ResMem | ResExclusive | ResUnused | ResBlock) +#define ResExcUusdIoBlock (ResIo | ResExclusive | ResUnused | ResBlock) +#define ResShrUusdMemBlock (ResMem | ResShared | ResUnused | ResBlock) +#define ResShrUusdIoBlock (ResIo | ResShared | ResUnused | ResBlock) +#define ResExcUusdMemSparse (ResMem | ResExclusive | ResUnused | ResSparse) +#define ResExcUusdIoSparse (ResIo | ResExclusive | ResUnused | ResSparse) +#define ResShrUusdMemSparse (ResMem | ResShared | ResUnused | ResSparse) +#define ResShrUusdIoSparse (ResIo | ResShared | ResUnused | ResSparse) + +#define ResExcMemSparse (ResMem | ResExclusive | ResSparse) +#define ResExcIoSparse (ResIo | ResExclusive | ResSparse) +#define ResShrMemSparse (ResMem | ResShared | ResSparse) +#define ResShrIoSparse (ResIo | ResShared | ResSparse) +#define ResUusdMemSparse (ResMem | ResUnused | ResSparse) +#define ResUusdIoSparse (ResIo | ResUnused | ResSparse) + +#define ResIsMem(r) (((r)->type & ResPhysMask) == ResMem) +#define ResIsIo(r) (((r)->type & ResPhysMask) == ResIo) +#define ResIsExclusive(r) (((r)->type & ResAccMask) == ResExclusive) +#define ResIsShared(r) (((r)->type & ResAccMask) == ResShared) +#define ResIsUnused(r) (((r)->type & ResAccMask) == ResUnused) +#define ResIsBlock(r) (((r)->type & ResExtMask) == ResBlock) +#define ResIsSparse(r) (((r)->type & ResExtMask) == ResSparse) +#define ResIsEstimated(r) (((r)->type & ResMiscMask) == ResEstimated) +#define ResCanOverlap(r) (ResIsEstimated(r) || ((r)->type & ResOverlap)) + +typedef struct { + unsigned long type; /* shared, exclusive, unused etc. */ + memType a; + memType b; +} resRange, *resList; + +#define RANGE_TYPE(type, domain) \ + (((unsigned long)(domain) << 24) | ((type) & ~ResBus)) +#define RANGE(r,u,v,t) {\ + (r).a = (u);\ + (r).b = (v);\ + (r).type = (t);\ + } + +#define rBase a +#define rMask b +#define rBegin a +#define rEnd b + +/* resource record */ +typedef struct _resRec *resPtr; +typedef struct _resRec { + resRange val; + int entityIndex; /* who owns the resource */ + resPtr next; +} resRec; + +#define sparse_base val.rBase +#define sparse_mask val.rMask +#define block_begin val.rBegin +#define block_end val.rEnd +#define res_type val.type + +typedef struct { + int numChipset; + resRange *resList; +} IsaChipsets; + +typedef struct _PciChipsets { + /** + * Key used to match this device with its name in an array of + * \c SymTabRec. + */ + int numChipset; + + /** + * This value is quirky. Depending on the driver, it can take on one of + * three meanings. In drivers that have exactly one vendor ID (e.g., + * radeon, mga, i810) the low 16-bits are the device ID. + * + * In drivers that can have multiple vendor IDs (e.g., the glint driver + * can have either 3dlabs' ID or TI's ID, the i740 driver can have either + * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and + * the high 16-bits are the vendor ID. + * + * In drivers that don't have a specific vendor (e.g., vga) contains the + * device ID for either the generic VGA or generic 8514 devices. This + * turns out to be the same as the subclass and programming interface + * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or + * 0x000101) and for 8514 is 0x030001). + */ + int PCIid; + + /** + * Resources associated with this type of device. + */ + resRange *resList; +} PciChipsets; + +/* Entity properties */ +typedef void (*EntityProc)(int entityIndex,pointer private); + +typedef struct _entityInfo { + int index; + BusRec location; + int chipset; + Bool active; + resPtr resources; + GDevPtr device; + DriverPtr driver; +} EntityInfoRec, *EntityInfoPtr; + +/* server states */ + +typedef enum { + SETUP, + OPERATING +} xf86State; + +typedef enum { + NOTIFY_SETUP_TRANSITION, + NOTIFY_SETUP, + NOTIFY_OPERATING, + NOTIFY_OPERATING_TRANSITION, + NOTIFY_ENABLE, + NOTIFY_ENTER, + NOTIFY_LEAVE +} xf86NotifyState; + +typedef void (*xf86StateChangeNotificationCallbackFunc)(xf86NotifyState state,pointer); + +/* DGA */ + +typedef struct { + int num; /* A unique identifier for the mode (num > 0) */ + DisplayModePtr mode; + int flags; /* DGA_CONCURRENT_ACCESS, etc... */ + int imageWidth; /* linear accessible portion (pixels) */ + int imageHeight; + int pixmapWidth; /* Xlib accessible portion (pixels) */ + int pixmapHeight; /* both fields ignored if no concurrent access */ + int bytesPerScanline; + int byteOrder; /* MSBFirst, LSBFirst */ + int depth; + int bitsPerPixel; + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + short visualClass; + int viewportWidth; + int viewportHeight; + int xViewportStep; /* viewport position granularity */ + int yViewportStep; + int maxViewportX; /* max viewport origin */ + int maxViewportY; + int viewportFlags; /* types of page flipping possible */ + int offset; /* offset into physical memory */ + unsigned char *address; /* server's mapped framebuffer */ + int reserved1; + int reserved2; +} DGAModeRec, *DGAModePtr; + +typedef struct { + DGAModePtr mode; + PixmapPtr pPix; +} DGADeviceRec, *DGADevicePtr; + +/* + * Flags for driver Probe() functions. + */ +#define PROBE_DEFAULT 0x00 +#define PROBE_DETECT 0x01 +#define PROBE_TRYHARD 0x02 + +/* + * Driver entry point types + */ + +typedef Bool xf86ProbeProc (DriverPtr, int); +typedef Bool xf86PreInitProc (ScrnInfoPtr, int); +typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**); +typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int); +typedef void xf86AdjustFrameProc (int, int, int, int); +typedef Bool xf86EnterVTProc (int, int); +typedef void xf86LeaveVTProc (int, int); +typedef void xf86FreeScreenProc (int, int); +typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int); +typedef void xf86EnableDisableFBAccessProc(int, Bool); +typedef int xf86SetDGAModeProc (int, int, DGADevicePtr); +typedef int xf86ChangeGammaProc (int, Gamma); +typedef void xf86PointerMovedProc (int, int, int); +typedef Bool xf86PMEventProc (int, pmEvent, Bool); +typedef int xf86HandleMessageProc (int, const char*, const char*, char**); +typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int); +typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr); +typedef void xf86SetOverscanProc (ScrnInfoPtr, int); + + +/* + * ScrnInfoRec + * + * There is one of these for each screen, and it holds all the screen-specific + * information. + * + * Note: the size and layout must be kept the same across versions. New + * fields are to be added in place of the "reserved*" fields. No fields + * are to be dependent on compile-time defines. + */ + + +typedef struct _ScrnInfoRec { + int driverVersion; + char * driverName; /* canonical name used in */ + /* the config file */ + ScreenPtr pScreen; /* Pointer to the ScreenRec */ + int scrnIndex; /* Number of this screen */ + Bool configured; /* Is this screen valid */ + int origIndex; /* initial number assigned to + * this screen before + * finalising the number of + * available screens */ + + /* Display-wide screenInfo values needed by this screen */ + int imageByteOrder; + int bitmapScanlineUnit; + int bitmapScanlinePad; + int bitmapBitOrder; + int numFormats; + PixmapFormatRec formats[MAXFORMATS]; + PixmapFormatRec fbFormat; + + int bitsPerPixel; /* fb bpp */ + Pix24Flags pixmap24; /* pixmap pref for depth 24 */ + int depth; /* depth of default visual */ + MessageType depthFrom; /* set from config? */ + MessageType bitsPerPixelFrom; /* set from config? */ + rgb weight; /* r/g/b weights */ + rgb mask; /* rgb masks */ + rgb offset; /* rgb offsets */ + int rgbBits; /* Number of bits in r/g/b */ + Gamma gamma; /* Gamma of the monitor */ + int defaultVisual; /* default visual class */ + int maxHValue; /* max horizontal timing */ + int maxVValue; /* max vertical timing value */ + int virtualX; /* Virtual width */ + int virtualY; /* Virtual height */ + int xInc; /* Horizontal timing increment */ + MessageType virtualFrom; /* set from config? */ + int displayWidth; /* memory pitch */ + int frameX0; /* viewport position */ + int frameY0; + int frameX1; + int frameY1; + int zoomLocked; /* Disallow mode changes */ + DisplayModePtr modePool; /* list of compatible modes */ + DisplayModePtr modes; /* list of actual modes */ + DisplayModePtr currentMode; /* current mode + * This was previously + * overloaded with the modes + * field, which is a pointer + * into a circular list */ + confScreenPtr confScreen; /* Screen config info */ + MonPtr monitor; /* Monitor information */ + DispPtr display; /* Display information */ + int * entityList; /* List of device entities */ + int numEntities; + int widthmm; /* physical display dimensions + * in mm */ + int heightmm; + int xDpi; /* width DPI */ + int yDpi; /* height DPI */ + char * name; /* Name to prefix messages */ + pointer driverPrivate; /* Driver private area */ + DevUnion * privates; /* Other privates can hook in + * here */ + DriverPtr drv; /* xf86DriverList[] entry */ + pointer module; /* Pointer to module head */ + int colorKey; + int overlayFlags; + + /* Some of these may be moved out of here into the driver private area */ + + char * chipset; /* chipset name */ + char * ramdac; /* ramdac name */ + char * clockchip; /* clock name */ + Bool progClock; /* clock is programmable */ + int numClocks; /* number of clocks */ + int clock[MAXCLOCKS]; /* list of clock frequencies */ + int videoRam; /* amount of video ram (kb) */ + unsigned long biosBase; /* Base address of video BIOS */ + unsigned long memPhysBase; /* Physical address of FB */ + unsigned long fbOffset; /* Offset of FB in the above */ + IOADDRESS domainIOBase; /* Domain I/O base address */ + int memClk; /* memory clock */ + int textClockFreq; /* clock of text mode */ + Bool flipPixels; /* swap default black/white */ + pointer options; + + int chipID; + int chipRev; + int racMemFlags; + int racIoFlags; + pointer access; + xf86CurrentAccessPtr CurrentAccess; + resType resourceType; + pointer busAccess; + + /* Allow screens to be enabled/disabled individually */ + Bool vtSema; + DevUnion pixmapPrivate; /* saved devPrivate from pixmap */ + + /* hw cursor moves at SIGIO time */ + Bool silkenMouse; + + /* Storage for clockRanges and adjustFlags for use with the VidMode ext */ + ClockRangesPtr clockRanges; + int adjustFlags; + + /* + * These can be used when the minor ABI version is incremented. + * The NUM_* parameters must be reduced appropriately to keep the + * structure size and alignment unchanged. + */ + int reservedInt[NUM_RESERVED_INTS]; + + int * entityInstanceList; + pointer reservedPtr[NUM_RESERVED_POINTERS]; + + /* + * Driver entry points. + * + */ + + xf86ProbeProc *Probe; + xf86PreInitProc *PreInit; + xf86ScreenInitProc *ScreenInit; + xf86SwitchModeProc *SwitchMode; + xf86AdjustFrameProc *AdjustFrame; + xf86EnterVTProc *EnterVT; + xf86LeaveVTProc *LeaveVT; + xf86FreeScreenProc *FreeScreen; + xf86ValidModeProc *ValidMode; + xf86EnableDisableFBAccessProc *EnableDisableFBAccess; + xf86SetDGAModeProc *SetDGAMode; + xf86ChangeGammaProc *ChangeGamma; + xf86PointerMovedProc *PointerMoved; + xf86PMEventProc *PMEvent; + xf86HandleMessageProc *HandleMessage; + xf86DPMSSetProc *DPMSSet; + xf86LoadPaletteProc *LoadPalette; + xf86SetOverscanProc *SetOverscan; + xorgDriverFuncProc *DriverFunc; + + /* + * This can be used when the minor ABI version is incremented. + * The NUM_* parameter must be reduced appropriately to keep the + * structure size and alignment unchanged. + */ + funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; + +} ScrnInfoRec; + + +typedef struct { + Bool (*OpenFramebuffer)( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *extra + ); + void (*CloseFramebuffer)(ScrnInfoPtr pScrn); + Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode); + void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags); + int (*GetViewport)(ScrnInfoPtr pScrn); + void (*Sync)(ScrnInfoPtr); + void (*FillRect)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color + ); + void (*BlitRect)( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty + ); + void (*BlitTransRect)( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color + ); +} DGAFunctionRec, *DGAFunctionPtr; + +typedef struct _SymTabRec { + int token; /* id of the token */ + const char * name; /* token name */ +} SymTabRec, *SymTabPtr; + +/* flags for xf86LookupMode */ +typedef enum { + LOOKUP_DEFAULT = 0, /* Use default mode lookup method */ + LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */ + LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */ + LOOKUP_LIST_ORDER, /* Pick first useful mode in list */ + LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */ + LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */ +} LookupModeFlags; + +#define NoDepth24Support 0x00 +#define Support24bppFb 0x01 /* 24bpp framebuffer supported */ +#define Support32bppFb 0x02 /* 32bpp framebuffer supported */ +#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */ +#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */ +#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */ +#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */ + + +/* For DPMS */ +typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int); + +/* Input handler proc */ +typedef void (*InputHandlerProc)(int fd, pointer data); + +/* These are used by xf86GetClocks */ +#define CLK_REG_SAVE -1 +#define CLK_REG_RESTORE -2 + +/* xf86Debug.c */ +#ifdef BUILDDEBUG +typedef struct { + long sec; + long usec; +} xf86TsRec, *xf86TsPtr; +#endif + +/* + * misc constants + */ +#define INTERLACE_REFRESH_WEIGHT 1.5 +#define SYNC_TOLERANCE 0.01 /* 1 percent */ +#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */ + + +#define OVERLAY_8_32_DUALFB 0x00000001 +#define OVERLAY_8_24_DUALFB 0x00000002 +#define OVERLAY_8_16_DUALFB 0x00000004 +#define OVERLAY_8_32_PLANAR 0x00000008 + +#if 0 +#define LD_RESOLV_IFDONE 0 /* only check if no more + delays pending */ +#define LD_RESOLV_NOW 1 /* finish one delay step */ +#define LD_RESOLV_FORCE 2 /* force checking... */ +#endif + +/* Values of xf86Info.mouseFlags */ +#define MF_CLEAR_DTR 1 +#define MF_CLEAR_RTS 2 + +/* Action Events */ +typedef enum { + ACTION_TERMINATE = 0, /* Terminate Server */ + ACTION_NEXT_MODE = 10, /* Switch to next video mode */ + ACTION_PREV_MODE, + ACTION_DISABLEGRAB = 20, /* Cancel server/pointer/kbd grabs */ + ACTION_CLOSECLIENT, /* Kill client holding grab */ + ACTION_SWITCHSCREEN = 100, /* VT switch */ + ACTION_SWITCHSCREEN_NEXT, + ACTION_SWITCHSCREEN_PREV, + ACTION_MESSAGE = 9999 /* Generic message passing */ +} ActionEvent; + +/* xf86Versions.c */ +/* + * Never change existing values, and always assign values explicitly. + * NUM_BUILTIN_IFS must always be the last entry. + */ +typedef enum { + BUILTIN_IF_OSMOUSE = 0, + BUILTIN_IF_OSKBD = 1, + NUM_BUILTIN_IFS +} BuiltinInterface; + +/* + * These are intentionally the same as the module version macros. + * It is possible to register a module as providing a specific interface, + * in which case the module's version is used. This feature isn't + * really ready for use yet though. + */ + +#define BUILTIN_INTERFACE_VERSION_NUMERIC(maj, min, patch) \ + ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF)) +#define GET_BUILTIN_INTERFACE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF) +#define GET_BUILTIN_INTERFACE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF) +#define GET_BUILTIN_INTERFACE_PATCH_VERSION(vers) ((vers) & 0xFFFF) + +#endif /* _XF86STR_H */ diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c new file mode 100644 index 000000000..7483e20d2 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86xv.c @@ -0,0 +1,2087 @@ +/* + * XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com) + */ +/* + * Copyright (c) 1998-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include +#include "scrnintstr.h" +#include "regionstr.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "mivalidate.h" +#include "validate.h" +#include "resource.h" +#include "gcstruct.h" +#include "dixstruct.h" + +#include +#include +#include "xvdix.h" +#include "xvmodproc.h" + +#include "xf86xvpriv.h" + + +/* XvScreenRec fields */ + +static Bool xf86XVCloseScreen(int, ScreenPtr); +static int xf86XVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *); + +/* XvAdaptorRec fields */ + +static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*); +static int xf86XVFreePort(XvPortPtr); +static int xf86XVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); +static int xf86XVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); +static int xf86XVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); +static int xf86XVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); +static int xf86XVStopVideo(ClientPtr, XvPortPtr, DrawablePtr); +static int xf86XVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32); +static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*); +static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8, + CARD16, CARD16,CARD16, CARD16, + unsigned int*, unsigned int*); +static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, + INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16, + XvImagePtr, unsigned char*, Bool, + CARD16, CARD16); +static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr, + CARD16*, CARD16*, int*, int*); + + +/* ScreenRec fields */ + +static Bool xf86XVDestroyWindow(WindowPtr pWin); +static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2); +static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy); + +/* ScrnInfoRec functions */ + +static Bool xf86XVEnterVT(int, int); +static void xf86XVLeaveVT(int, int); +static void xf86XVAdjustFrame(int index, int x, int y, int flags); + +/* misc */ + +static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int); + + +static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKey; +DevPrivateKey XF86XvScreenKey; +static unsigned long PortResource = 0; + +DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL; +unsigned long (*XvGetRTPortProc)(void) = NULL; +int (*XvScreenInitProc)(ScreenPtr) = NULL; + +#define GET_XV_SCREEN(pScreen) \ + ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey)) + +#define GET_XF86XV_SCREEN(pScreen) \ + ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) + +#define GET_XF86XV_WINDOW(pWin) \ + ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey)) + +static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL; +static int NumGenDrivers = 0; + +_X_EXPORT int +xf86XVRegisterGenericAdaptorDriver( + xf86XVInitGenericAdaptorPtr InitFunc +){ + xf86XVInitGenericAdaptorPtr *newdrivers; + + newdrivers = xrealloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) * + (1 + NumGenDrivers)); + if (!newdrivers) + return 0; + GenDrivers = newdrivers; + + GenDrivers[NumGenDrivers++] = InitFunc; + + return 1; +} + +_X_EXPORT int +xf86XVListGenericAdaptors( + ScrnInfoPtr pScrn, + XF86VideoAdaptorPtr **adaptors +){ + int i,j,n,num; + XF86VideoAdaptorPtr *DrivAdap,*new; + + num = 0; + *adaptors = NULL; + /* + * The v4l driver registers itself first, but can use surfaces registered + * by other drivers. So, call the v4l driver last. + */ + for (i = NumGenDrivers; --i >= 0; ) { + DrivAdap = NULL; + n = (*GenDrivers[i])(pScrn, &DrivAdap); + if (0 == n) + continue; + new = xrealloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num+n)); + if (NULL == new) + continue; + *adaptors = new; + for (j = 0; j < n; j++, num++) + (*adaptors)[num] = DrivAdap[j]; + } + return num; +} + + +/**************** Offscreen surface stuff *******************/ + +typedef struct { + XF86OffscreenImagePtr images; + int num; +} OffscreenImageRec; + +static OffscreenImageRec OffscreenImages[MAXSCREENS]; + +_X_EXPORT Bool +xf86XVRegisterOffscreenImages( + ScreenPtr pScreen, + XF86OffscreenImagePtr images, + int num +){ + OffscreenImages[pScreen->myNum].num = num; + OffscreenImages[pScreen->myNum].images = images; + + return TRUE; +} + +_X_EXPORT XF86OffscreenImagePtr +xf86XVQueryOffscreenImages( + ScreenPtr pScreen, + int *num +){ + *num = OffscreenImages[pScreen->myNum].num; + return OffscreenImages[pScreen->myNum].images; +} + + +_X_EXPORT XF86VideoAdaptorPtr +xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn) +{ + return xcalloc(1, sizeof(XF86VideoAdaptorRec)); +} + +_X_EXPORT void +xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr) +{ + xfree(ptr); +} + + +_X_EXPORT Bool +xf86XVScreenInit( + ScreenPtr pScreen, + XF86VideoAdaptorPtr *adaptors, + int num +){ + ScrnInfoPtr pScrn; + XF86XVScreenPtr ScreenPriv; + XvScreenPtr pxvs; + + if(num <= 0 || + !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc) + return FALSE; + + if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; + + XF86XvScreenKey = (*XvGetScreenKeyProc)(); + PortResource = (*XvGetRTPortProc)(); + + pxvs = GET_XV_SCREEN(pScreen); + + /* Anyone initializing the Xv layer must provide these two. + The Xv di layer calls them without even checking if they exist! */ + + pxvs->ddCloseScreen = xf86XVCloseScreen; + pxvs->ddQueryAdaptors = xf86XVQueryAdaptors; + + /* The Xv di layer provides us with a private hook so that we don't + have to allocate our own screen private. They also provide + a CloseScreen hook so that we don't have to wrap it. I'm not + sure that I appreciate that. */ + + ScreenPriv = xalloc(sizeof(XF86XVScreenRec)); + pxvs->devPriv.ptr = (pointer)ScreenPriv; + + if(!ScreenPriv) return FALSE; + + pScrn = xf86Screens[pScreen->myNum]; + + ScreenPriv->videoGC = NULL; /* for the helper */ + + ScreenPriv->DestroyWindow = pScreen->DestroyWindow; + ScreenPriv->WindowExposures = pScreen->WindowExposures; + ScreenPriv->ClipNotify = pScreen->ClipNotify; + ScreenPriv->EnterVT = pScrn->EnterVT; + ScreenPriv->LeaveVT = pScrn->LeaveVT; + ScreenPriv->AdjustFrame = pScrn->AdjustFrame; + + pScreen->DestroyWindow = xf86XVDestroyWindow; + pScreen->WindowExposures = xf86XVWindowExposures; + pScreen->ClipNotify = xf86XVClipNotify; + pScrn->EnterVT = xf86XVEnterVT; + pScrn->LeaveVT = xf86XVLeaveVT; + if(pScrn->AdjustFrame) + pScrn->AdjustFrame = xf86XVAdjustFrame; + + if(!xf86XVInitAdaptors(pScreen, adaptors, num)) + return FALSE; + + return TRUE; +} + +static void +xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor) +{ + int i; + + xfree(pAdaptor->name); + + if(pAdaptor->pEncodings) { + XvEncodingPtr pEncode = pAdaptor->pEncodings; + + for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) + xfree(pEncode->name); + xfree(pAdaptor->pEncodings); + } + + xfree(pAdaptor->pFormats); + + if(pAdaptor->pPorts) { + XvPortPtr pPort = pAdaptor->pPorts; + XvPortRecPrivatePtr pPriv; + + for(i = 0; i < pAdaptor->nPorts; i++, pPort++) { + pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; + if(pPriv) { + if(pPriv->clientClip) + REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip); + if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) + REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip); + xfree(pPriv); + } + } + xfree(pAdaptor->pPorts); + } + + if(pAdaptor->nAttributes) { + XvAttributePtr pAttribute = pAdaptor->pAttributes; + + for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) + xfree(pAttribute->name); + xfree(pAdaptor->pAttributes); + } + + xfree(pAdaptor->pImages); + xfree(pAdaptor->devPriv.ptr); +} + +static Bool +xf86XVInitAdaptors( + ScreenPtr pScreen, + XF86VideoAdaptorPtr *infoPtr, + int number +) { + XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr adaptorPtr; + XvAdaptorPtr pAdaptor, pa; + XvAdaptorRecPrivatePtr adaptorPriv; + int na, numAdaptor; + XvPortRecPrivatePtr portPriv; + XvPortPtr pPort, pp; + int numPort; + XF86AttributePtr attributePtr; + XvAttributePtr pAttribute, pat; + XF86VideoFormatPtr formatPtr; + XvFormatPtr pFormat, pf; + int numFormat, totFormat; + XF86VideoEncodingPtr encodingPtr; + XvEncodingPtr pEncode, pe; + XF86ImagePtr imagePtr; + XvImagePtr pImage, pi; + int numVisuals; + VisualPtr pVisual; + int i; + + pxvs->nAdaptors = 0; + pxvs->pAdaptors = NULL; + + if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec)))) + return FALSE; + + for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) { + adaptorPtr = infoPtr[na]; + + if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute || + !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize) + continue; + + /* client libs expect at least one encoding */ + if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings) + continue; + + pa->type = adaptorPtr->type; + + if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo) + pa->type &= ~XvVideoMask; + + if(!adaptorPtr->PutStill && !adaptorPtr->GetStill) + pa->type &= ~XvStillMask; + + if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes) + pa->type &= ~XvImageMask; + + if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage && + !adaptorPtr->PutStill) + pa->type &= ~XvInputMask; + + if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill) + pa->type &= ~XvOutputMask; + + if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask))) + continue; + if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask))) + continue; + + pa->pScreen = pScreen; + pa->ddAllocatePort = xf86XVAllocatePort; + pa->ddFreePort = xf86XVFreePort; + pa->ddPutVideo = xf86XVPutVideo; + pa->ddPutStill = xf86XVPutStill; + pa->ddGetVideo = xf86XVGetVideo; + pa->ddGetStill = xf86XVGetStill; + pa->ddStopVideo = xf86XVStopVideo; + pa->ddPutImage = xf86XVPutImage; + pa->ddSetPortAttribute = xf86XVSetPortAttribute; + pa->ddGetPortAttribute = xf86XVGetPortAttribute; + pa->ddQueryBestSize = xf86XVQueryBestSize; + pa->ddQueryImageAttributes = xf86XVQueryImageAttributes; + if((pa->name = xalloc(strlen(adaptorPtr->name) + 1))) + strcpy(pa->name, adaptorPtr->name); + + if(adaptorPtr->nEncodings && + (pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) { + + for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0; + i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++) + { + pe->id = encodingPtr->id; + pe->pScreen = pScreen; + if((pe->name = xalloc(strlen(encodingPtr->name) + 1))) + strcpy(pe->name, encodingPtr->name); + pe->width = encodingPtr->width; + pe->height = encodingPtr->height; + pe->rate.numerator = encodingPtr->rate.numerator; + pe->rate.denominator = encodingPtr->rate.denominator; + } + pa->nEncodings = adaptorPtr->nEncodings; + pa->pEncodings = pEncode; + } + + if(adaptorPtr->nImages && + (pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) { + + for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages; + i < adaptorPtr->nImages; i++, pi++, imagePtr++) + { + pi->id = imagePtr->id; + pi->type = imagePtr->type; + pi->byte_order = imagePtr->byte_order; + memcpy(pi->guid, imagePtr->guid, 16); + pi->bits_per_pixel = imagePtr->bits_per_pixel; + pi->format = imagePtr->format; + pi->num_planes = imagePtr->num_planes; + pi->depth = imagePtr->depth; + pi->red_mask = imagePtr->red_mask; + pi->green_mask = imagePtr->green_mask; + pi->blue_mask = imagePtr->blue_mask; + pi->y_sample_bits = imagePtr->y_sample_bits; + pi->u_sample_bits = imagePtr->u_sample_bits; + pi->v_sample_bits = imagePtr->v_sample_bits; + pi->horz_y_period = imagePtr->horz_y_period; + pi->horz_u_period = imagePtr->horz_u_period; + pi->horz_v_period = imagePtr->horz_v_period; + pi->vert_y_period = imagePtr->vert_y_period; + pi->vert_u_period = imagePtr->vert_u_period; + pi->vert_v_period = imagePtr->vert_v_period; + memcpy(pi->component_order, imagePtr->component_order, 32); + pi->scanline_order = imagePtr->scanline_order; + } + pa->nImages = adaptorPtr->nImages; + pa->pImages = pImage; + } + + if(adaptorPtr->nAttributes && + (pAttribute = xcalloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) + { + for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0; + i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) + { + pat->flags = attributePtr->flags; + pat->min_value = attributePtr->min_value; + pat->max_value = attributePtr->max_value; + if((pat->name = xalloc(strlen(attributePtr->name) + 1))) + strcpy(pat->name, attributePtr->name); + } + pa->nAttributes = adaptorPtr->nAttributes; + pa->pAttributes = pAttribute; + } + + + totFormat = adaptorPtr->nFormats; + + if(!(pFormat = xcalloc(totFormat, sizeof(XvFormatRec)))) { + xf86XVFreeAdaptor(pa); + continue; + } + for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats; + i < adaptorPtr->nFormats; i++, formatPtr++) + { + numVisuals = pScreen->numVisuals; + pVisual = pScreen->visuals; + + while(numVisuals--) { + if((pVisual->class == formatPtr->class) && + (pVisual->nplanes == formatPtr->depth)) { + + if(numFormat >= totFormat) { + void *moreSpace; + totFormat *= 2; + moreSpace = xrealloc(pFormat, + totFormat * sizeof(XvFormatRec)); + if(!moreSpace) break; + pFormat = moreSpace; + pf = pFormat + numFormat; + } + + pf->visual = pVisual->vid; + pf->depth = formatPtr->depth; + + pf++; + numFormat++; + } + pVisual++; + } + } + pa->nFormats = numFormat; + pa->pFormats = pFormat; + if(!numFormat) { + xf86XVFreeAdaptor(pa); + continue; + } + + if(!(adaptorPriv = xcalloc(1, sizeof(XvAdaptorRecPrivate)))) { + xf86XVFreeAdaptor(pa); + continue; + } + + adaptorPriv->flags = adaptorPtr->flags; + adaptorPriv->PutVideo = adaptorPtr->PutVideo; + adaptorPriv->PutStill = adaptorPtr->PutStill; + adaptorPriv->GetVideo = adaptorPtr->GetVideo; + adaptorPriv->GetStill = adaptorPtr->GetStill; + adaptorPriv->StopVideo = adaptorPtr->StopVideo; + adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute; + adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute; + adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize; + adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes; + adaptorPriv->PutImage = adaptorPtr->PutImage; + adaptorPriv->ReputImage = adaptorPtr->ReputImage; + + pa->devPriv.ptr = (pointer)adaptorPriv; + + if(!(pPort = xcalloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) { + xf86XVFreeAdaptor(pa); + continue; + } + for(pp = pPort, i = 0, numPort = 0; + i < adaptorPtr->nPorts; i++) { + + if(!(pp->id = FakeClientID(0))) + continue; + + if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate)))) + continue; + + if(!AddResource(pp->id, PortResource, pp)) { + xfree(portPriv); + continue; + } + + pp->pAdaptor = pa; + pp->pNotify = (XvPortNotifyPtr)NULL; + pp->pDraw = (DrawablePtr)NULL; + pp->client = (ClientPtr)NULL; + pp->grab.client = (ClientPtr)NULL; + pp->time = currentTime; + pp->devPriv.ptr = portPriv; + + portPriv->pScrn = pScrn; + portPriv->AdaptorRec = adaptorPriv; + portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr; + + pp++; + numPort++; + } + pa->nPorts = numPort; + pa->pPorts = pPort; + if(!numPort) { + xf86XVFreeAdaptor(pa); + continue; + } + + pa->base_id = pPort->id; + + pa++; + numAdaptor++; + } + + if(numAdaptor) { + pxvs->nAdaptors = numAdaptor; + pxvs->pAdaptors = pAdaptor; + } else { + xfree(pAdaptor); + return FALSE; + } + + return TRUE; +} + +/* Video should be clipped to the intersection of the window cliplist + and the client cliplist specified in the GC for which the video was + initialized. When we need to reclip a window, the GC that started + the video may not even be around anymore. That's why we save the + client clip from the GC when the video is initialized. We then + use xf86XVUpdateCompositeClip to calculate the new composite clip + when we need it. This is different from what DEC did. They saved + the GC and used it's clip list when they needed to reclip the window, + even if the client clip was different from the one the video was + initialized with. If the original GC was destroyed, they had to stop + the video. I like the new method better (MArk). + + This function only works for windows. Will need to rewrite when + (if) we support pixmap rendering. +*/ + +static void +xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv) +{ + RegionPtr pregWin, pCompositeClip; + WindowPtr pWin; + ScreenPtr pScreen; + Bool freeCompClip = FALSE; + + if(portPriv->pCompositeClip) + return; + + pWin = (WindowPtr)portPriv->pDraw; + pScreen = pWin->drawable.pScreen; + + /* get window clip list */ + if(portPriv->subWindowMode == IncludeInferiors) { + pregWin = NotClippedByChildren(pWin); + freeCompClip = TRUE; + } else + pregWin = &pWin->clipList; + + if(!portPriv->clientClip) { + portPriv->pCompositeClip = pregWin; + portPriv->FreeCompositeClip = freeCompClip; + return; + } + + pCompositeClip = REGION_CREATE(pScreen, NullBox, 1); + REGION_COPY(pScreen, pCompositeClip, portPriv->clientClip); + REGION_TRANSLATE(pScreen, pCompositeClip, + portPriv->pDraw->x + portPriv->clipOrg.x, + portPriv->pDraw->y + portPriv->clipOrg.y); + REGION_INTERSECT(pScreen, pCompositeClip, pregWin, pCompositeClip); + + portPriv->pCompositeClip = pCompositeClip; + portPriv->FreeCompositeClip = TRUE; + + if(freeCompClip) { + REGION_DESTROY(pScreen, pregWin); + } +} + +/* Save the current clientClip and update the CompositeClip whenever + we have a fresh GC */ + +static void +xf86XVCopyClip( + XvPortRecPrivatePtr portPriv, + GCPtr pGC +){ + /* copy the new clip if it exists */ + if((pGC->clientClipType == CT_REGION) && pGC->clientClip) { + if(!portPriv->clientClip) + portPriv->clientClip = REGION_CREATE(pScreen, NullBox, 1); + /* Note: this is in window coordinates */ + REGION_COPY(pScreen, portPriv->clientClip, pGC->clientClip); + } else if(portPriv->clientClip) { /* free the old clientClip */ + REGION_DESTROY(pScreen, portPriv->clientClip); + portPriv->clientClip = NULL; + } + + /* get rid of the old clip list */ + if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) { + REGION_DESTROY(pScreen, portPriv->pCompositeClip); + } + + portPriv->clipOrg = pGC->clipOrg; + portPriv->pCompositeClip = pGC->pCompositeClip; + portPriv->FreeCompositeClip = FALSE; + portPriv->subWindowMode = pGC->subWindowMode; +} + +static int +xf86XVRegetVideo(XvPortRecPrivatePtr portPriv) +{ + RegionRec WinRegion; + RegionRec ClipRegion; + BoxRec WinBox; + ScreenPtr pScreen; + int ret = Success; + Bool clippedAway = FALSE; + + pScreen = portPriv->pDraw->pScreen; + xf86XVUpdateCompositeClip(portPriv); + + /* translate the video region to the screen */ + WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x; + WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; + WinBox.x2 = WinBox.x1 + portPriv->drw_w; + WinBox.y2 = WinBox.y1 + portPriv->drw_h; + + /* clip to the window composite clip */ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_NULL(pScreen, &ClipRegion); + REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); + + /* that's all if it's totally obscured */ + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; + goto CLIP_VIDEO_BAILOUT; + } + + if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + + ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn, + portPriv->vid_x, portPriv->vid_y, + WinBox.x1, WinBox.y1, + portPriv->vid_w, portPriv->vid_h, + portPriv->drw_w, portPriv->drw_h, + &ClipRegion, portPriv->DevPriv.ptr, + portPriv->pDraw); + + if(ret == Success) + portPriv->isOn = XV_ON; + +CLIP_VIDEO_BAILOUT: + + if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) { + (*portPriv->AdaptorRec->StopVideo)( + portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); + portPriv->isOn = XV_PENDING; + } + + /* This clip was copied and only good for one shot */ + if(!portPriv->FreeCompositeClip) + portPriv->pCompositeClip = NULL; + + REGION_UNINIT(pScreen, &WinRegion); + REGION_UNINIT(pScreen, &ClipRegion); + + return ret; +} + + +static int +xf86XVReputVideo(XvPortRecPrivatePtr portPriv) +{ + RegionRec WinRegion; + RegionRec ClipRegion; + BoxRec WinBox; + ScreenPtr pScreen; + int ret = Success; + Bool clippedAway = FALSE; + + pScreen = portPriv->pDraw->pScreen; + + xf86XVUpdateCompositeClip(portPriv); + + /* translate the video region to the screen */ + WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x; + WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; + WinBox.x2 = WinBox.x1 + portPriv->drw_w; + WinBox.y2 = WinBox.y1 + portPriv->drw_h; + + /* clip to the window composite clip */ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_NULL(pScreen, &ClipRegion); + REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); + + /* clip and translate to the viewport */ + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + + VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; + VPBox.x2 = portPriv->pScrn->frameX1; + VPBox.y2 = portPriv->pScrn->frameY1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); + REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } + + /* that's all if it's totally obscured */ + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; + goto CLIP_VIDEO_BAILOUT; + } + + /* bailout if we have to clip but the hardware doesn't support it */ + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || + (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || + (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; + goto CLIP_VIDEO_BAILOUT; + } + } + + if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + + ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn, + portPriv->vid_x, portPriv->vid_y, + WinBox.x1, WinBox.y1, + portPriv->vid_w, portPriv->vid_h, + portPriv->drw_w, portPriv->drw_h, + &ClipRegion, portPriv->DevPriv.ptr, + portPriv->pDraw); + + if(ret == Success) portPriv->isOn = XV_ON; + +CLIP_VIDEO_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { + (*portPriv->AdaptorRec->StopVideo)( + portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); + portPriv->isOn = XV_PENDING; + } + + /* This clip was copied and only good for one shot */ + if(!portPriv->FreeCompositeClip) + portPriv->pCompositeClip = NULL; + + REGION_UNINIT(pScreen, &WinRegion); + REGION_UNINIT(pScreen, &ClipRegion); + + return ret; +} + +static int +xf86XVReputImage(XvPortRecPrivatePtr portPriv) +{ + RegionRec WinRegion; + RegionRec ClipRegion; + BoxRec WinBox; + ScreenPtr pScreen; + int ret = Success; + Bool clippedAway = FALSE; + + pScreen = portPriv->pDraw->pScreen; + + xf86XVUpdateCompositeClip(portPriv); + + /* translate the video region to the screen */ + WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x; + WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; + WinBox.x2 = WinBox.x1 + portPriv->drw_w; + WinBox.y2 = WinBox.y1 + portPriv->drw_h; + + /* clip to the window composite clip */ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_NULL(pScreen, &ClipRegion); + REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); + + /* clip and translate to the viewport */ + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + + VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; + VPBox.x2 = portPriv->pScrn->frameX1; + VPBox.y2 = portPriv->pScrn->frameY1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); + REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } + + /* that's all if it's totally obscured */ + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; + goto CLIP_VIDEO_BAILOUT; + } + + /* bailout if we have to clip but the hardware doesn't support it */ + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || + (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || + (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; + goto CLIP_VIDEO_BAILOUT; + } + } + + if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + + ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn, + WinBox.x1, WinBox.y1, + &ClipRegion, portPriv->DevPriv.ptr, + portPriv->pDraw); + + portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF; + +CLIP_VIDEO_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { + (*portPriv->AdaptorRec->StopVideo)( + portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); + portPriv->isOn = XV_PENDING; + } + + /* This clip was copied and only good for one shot */ + if(!portPriv->FreeCompositeClip) + portPriv->pCompositeClip = NULL; + + REGION_UNINIT(pScreen, &WinRegion); + REGION_UNINIT(pScreen, &ClipRegion); + + return ret; +} + + +static int +xf86XVReputAllVideo(WindowPtr pWin, pointer data) +{ + XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin); + + while(WinPriv) { + if(WinPriv->PortRec->type == XvInputMask) + xf86XVReputVideo(WinPriv->PortRec); + else + xf86XVRegetVideo(WinPriv->PortRec); + WinPriv = WinPriv->next; + } + + return WT_WALKCHILDREN; +} + +static int +xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) +{ + XF86XVWindowPtr winPriv, PrivRoot; + + winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin); + + /* Enlist our port in the window private */ + while(winPriv) { + if(winPriv->PortRec == portPriv) /* we're already listed */ + break; + winPriv = winPriv->next; + } + + if(!winPriv) { + winPriv = xalloc(sizeof(XF86XVWindowRec)); + if(!winPriv) return BadAlloc; + memset(winPriv, 0, sizeof(XF86XVWindowRec)); + winPriv->PortRec = portPriv; + winPriv->next = PrivRoot; + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv); + } + + portPriv->pDraw = (DrawablePtr)pWin; + + return Success; +} + + +static void +xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) +{ + XF86XVWindowPtr winPriv, prevPriv = NULL; + + winPriv = GET_XF86XV_WINDOW(pWin); + + while(winPriv) { + if(winPriv->PortRec == portPriv) { + if(prevPriv) + prevPriv->next = winPriv->next; + else + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + winPriv->next); + xfree(winPriv); + break; + } + prevPriv = winPriv; + winPriv = winPriv->next; + } + portPriv->pDraw = NULL; +} + +/**** ScreenRec fields ****/ + +static Bool +xf86XVDestroyWindow(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); + XF86XVWindowPtr tmp, WinPriv = GET_XF86XV_WINDOW(pWin); + int ret; + + while(WinPriv) { + XvPortRecPrivatePtr pPriv = WinPriv->PortRec; + + if(pPriv->isOn > XV_OFF) { + (*pPriv->AdaptorRec->StopVideo)( + pPriv->pScrn, pPriv->DevPriv.ptr, TRUE); + pPriv->isOn = XV_OFF; + } + + pPriv->pDraw = NULL; + tmp = WinPriv; + if(WinPriv->pGC) { + FreeGC(WinPriv->pGC, 0); + } + WinPriv = WinPriv->next; + xfree(tmp); + } + + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL); + + pScreen->DestroyWindow = ScreenPriv->DestroyWindow; + ret = (*pScreen->DestroyWindow)(pWin); + pScreen->DestroyWindow = xf86XVDestroyWindow; + + return ret; +} + + +static void +xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); + XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin); + XF86XVWindowPtr pPrev; + XvPortRecPrivatePtr pPriv; + Bool AreasExposed; + + AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1)); + + pScreen->WindowExposures = ScreenPriv->WindowExposures; + (*pScreen->WindowExposures)(pWin, reg1, reg2); + pScreen->WindowExposures = xf86XVWindowExposures; + + /* filter out XClearWindow/Area */ + if (!pWin->valdata) return; + + pPrev = NULL; + + while(WinPriv) { + pPriv = WinPriv->PortRec; + + /* Reput anyone with a reput function */ + + switch(pPriv->type) { + case XvInputMask: + xf86XVReputVideo(pPriv); + break; + case XvOutputMask: + xf86XVRegetVideo(pPriv); + break; + default: /* overlaid still/image*/ + if (pPriv->AdaptorRec->ReputImage) + xf86XVReputImage(pPriv); + else if(AreasExposed) { + XF86XVWindowPtr tmp; + + if (pPriv->isOn == XV_ON) { + (*pPriv->AdaptorRec->StopVideo)( + pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); + pPriv->isOn = XV_PENDING; + } + pPriv->pDraw = NULL; + + if(!pPrev) + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + WinPriv->next); + else + pPrev->next = WinPriv->next; + tmp = WinPriv; + WinPriv = WinPriv->next; + xfree(tmp); + continue; + } + break; + } + pPrev = WinPriv; + WinPriv = WinPriv->next; + } +} + + +static void +xf86XVClipNotify(WindowPtr pWin, int dx, int dy) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); + XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin); + XF86XVWindowPtr tmp, pPrev = NULL; + XvPortRecPrivatePtr pPriv; + Bool visible = (pWin->visibility == VisibilityUnobscured) || + (pWin->visibility == VisibilityPartiallyObscured); + + while(WinPriv) { + pPriv = WinPriv->PortRec; + + if(!pPriv) goto next; + + if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) + REGION_DESTROY(pScreen, pPriv->pCompositeClip); + + pPriv->pCompositeClip = NULL; + + /* Stop everything except images, but stop them too if the + window isn't visible. But we only remove the images. */ + + if(pPriv->type || !visible) { + if(pPriv->isOn == XV_ON) { + (*pPriv->AdaptorRec->StopVideo)( + pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); + pPriv->isOn = XV_PENDING; + } + + if(!pPriv->type) { /* overlaid still/image */ + pPriv->pDraw = NULL; + + if(!pPrev) + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + WinPriv->next); + else + pPrev->next = WinPriv->next; + tmp = WinPriv; + WinPriv = WinPriv->next; + xfree(tmp); + continue; + } + } + +next: + pPrev = WinPriv; + WinPriv = WinPriv->next; + } + + if(ScreenPriv->ClipNotify) { + pScreen->ClipNotify = ScreenPriv->ClipNotify; + (*pScreen->ClipNotify)(pWin, dx, dy); + pScreen->ClipNotify = xf86XVClipNotify; + } +} + + + +/**** Required XvScreenRec fields ****/ + +static Bool +xf86XVCloseScreen(int i, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); + XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); + XvAdaptorPtr pa; + int c; + + /* Clear offscreen images */ + (void)memset(&OffscreenImages[pScreen->myNum], 0, sizeof(OffscreenImages[0])); + + if(!ScreenPriv) return TRUE; + + if(ScreenPriv->videoGC) { + FreeGC(ScreenPriv->videoGC, 0); + ScreenPriv->videoGC = NULL; + } + + pScreen->DestroyWindow = ScreenPriv->DestroyWindow; + pScreen->WindowExposures = ScreenPriv->WindowExposures; + pScreen->ClipNotify = ScreenPriv->ClipNotify; + + pScrn->EnterVT = ScreenPriv->EnterVT; + pScrn->LeaveVT = ScreenPriv->LeaveVT; + pScrn->AdjustFrame = ScreenPriv->AdjustFrame; + + for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) { + xf86XVFreeAdaptor(pa); + } + + xfree(pxvs->pAdaptors); + xfree(ScreenPriv); + return TRUE; +} + + +static int +xf86XVQueryAdaptors( + ScreenPtr pScreen, + XvAdaptorPtr *p_pAdaptors, + int *p_nAdaptors +){ + XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); + + *p_nAdaptors = pxvs->nAdaptors; + *p_pAdaptors = pxvs->pAdaptors; + + return (Success); +} + + +/**** ScrnInfoRec fields ****/ + +static Bool +xf86XVEnterVT(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); + Bool ret; + + ret = (*ScreenPriv->EnterVT)(index, flags); + + if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0); + + return ret; +} + +static void +xf86XVLeaveVT(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); + XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); + XvAdaptorPtr pAdaptor; + XvPortPtr pPort; + XvPortRecPrivatePtr pPriv; + int i, j; + + for(i = 0; i < pxvs->nAdaptors; i++) { + pAdaptor = &pxvs->pAdaptors[i]; + for(j = 0; j < pAdaptor->nPorts; j++) { + pPort = &pAdaptor->pPorts[j]; + pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; + if(pPriv->isOn > XV_OFF) { + + (*pPriv->AdaptorRec->StopVideo)( + pPriv->pScrn, pPriv->DevPriv.ptr, TRUE); + pPriv->isOn = XV_OFF; + + if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) + REGION_DESTROY(pScreen, pPriv->pCompositeClip); + + pPriv->pCompositeClip = NULL; + + if(!pPriv->type && pPriv->pDraw) { /* still */ + xf86XVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv); + } + } + } + } + + (*ScreenPriv->LeaveVT)(index, flags); +} + +static void +xf86XVAdjustFrame(int index, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + ScreenPtr pScreen = pScrn->pScreen; + XvScreenPtr pxvs = GET_XV_SCREEN(pScreen); + XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen); + WindowPtr pWin; + XvAdaptorPtr pa; + int c, i; + + if(ScreenPriv->AdjustFrame) { + pScrn->AdjustFrame = ScreenPriv->AdjustFrame; + (*pScrn->AdjustFrame)(index, x, y, flags); + pScrn->AdjustFrame = xf86XVAdjustFrame; + } + + for(c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) { + XvPortPtr pPort = pa->pPorts; + XvPortRecPrivatePtr pPriv; + + for(i = pa->nPorts; i > 0; i--, pPort++) { + pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; + + if(!pPriv->type && (pPriv->isOn == XV_ON)) { /* overlaid still/image */ + + if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) + REGION_DESTROY(pScreen, pPriv->pCompositeClip); + + pPriv->pCompositeClip = NULL; + + pWin = (WindowPtr)pPriv->pDraw; + + if ((pPriv->AdaptorRec->ReputImage) && + ((pWin->visibility == VisibilityUnobscured) || + (pWin->visibility == VisibilityPartiallyObscured))) + { + xf86XVReputImage(pPriv); + } else { + (*pPriv->AdaptorRec->StopVideo)( + pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); + xf86XVRemovePortFromWindow(pWin, pPriv); + pPriv->isOn = XV_PENDING; + continue; + } + } + } + } +} + + +/**** XvAdaptorRec fields ****/ + +static int +xf86XVAllocatePort( + unsigned long port, + XvPortPtr pPort, + XvPortPtr *ppPort +){ + *ppPort = pPort; + return Success; +} + + + +static int +xf86XVFreePort(XvPortPtr pPort) +{ + return Success; +} + + +static int +xf86XVPutVideo( + ClientPtr client, + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, + INT16 vid_x, INT16 vid_y, + CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + int result; + + /* No dumping video to pixmaps... For now anyhow */ + if(pDraw->type != DRAWABLE_WINDOW) { + pPort->pDraw = (DrawablePtr)NULL; + return BadAlloc; + } + + /* If we are changing windows, unregister our port in the old window */ + if(portPriv->pDraw && (portPriv->pDraw != pDraw)) + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); + + /* Register our port with the new window */ + result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); + if(result != Success) return result; + + portPriv->type = XvInputMask; + + /* save a copy of these parameters */ + portPriv->vid_x = vid_x; portPriv->vid_y = vid_y; + portPriv->vid_w = vid_w; portPriv->vid_h = vid_h; + portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; + portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; + + /* make sure we have the most recent copy of the clientClip */ + xf86XVCopyClip(portPriv, pGC); + + /* To indicate to the DI layer that we were successful */ + pPort->pDraw = pDraw; + + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + return(xf86XVReputVideo(portPriv)); +} + +static int +xf86XVPutStill( + ClientPtr client, + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, + INT16 vid_x, INT16 vid_y, + CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + ScreenPtr pScreen; + RegionRec WinRegion; + RegionRec ClipRegion; + BoxRec WinBox; + int ret = Success; + Bool clippedAway = FALSE; + + if (pDraw->type != DRAWABLE_WINDOW) + return BadAlloc; + + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + pScreen = pDraw->pScreen; + + WinBox.x1 = pDraw->x + drw_x; + WinBox.y1 = pDraw->y + drw_y; + WinBox.x2 = WinBox.x1 + drw_w; + WinBox.y2 = WinBox.y1 + drw_h; + + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_NULL(pScreen, &ClipRegion); + REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); + + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + + VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; + VPBox.x2 = portPriv->pScrn->frameX1; + VPBox.y2 = portPriv->pScrn->frameY1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); + REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } + + if(portPriv->pDraw) { + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); + } + + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; + goto PUT_STILL_BAILOUT; + } + + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || + (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || + (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; + goto PUT_STILL_BAILOUT; + } + } + + if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + + ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn, + vid_x, vid_y, WinBox.x1, WinBox.y1, + vid_w, vid_h, drw_w, drw_h, + &ClipRegion, portPriv->DevPriv.ptr, + pDraw); + + if((ret == Success) && + (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) { + + xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); + portPriv->isOn = XV_ON; + portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; + portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; + portPriv->type = 0; /* no mask means it's transient and should + not be reput once it's removed */ + pPort->pDraw = pDraw; /* make sure we can get stop requests */ + } + +PUT_STILL_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { + (*portPriv->AdaptorRec->StopVideo)( + portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); + portPriv->isOn = XV_PENDING; + } + + REGION_UNINIT(pScreen, &WinRegion); + REGION_UNINIT(pScreen, &ClipRegion); + + return ret; +} + +static int +xf86XVGetVideo( + ClientPtr client, + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, + INT16 vid_x, INT16 vid_y, + CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + int result; + + /* No pixmaps... For now anyhow */ + if(pDraw->type != DRAWABLE_WINDOW) { + pPort->pDraw = (DrawablePtr)NULL; + return BadAlloc; + } + + /* If we are changing windows, unregister our port in the old window */ + if(portPriv->pDraw && (portPriv->pDraw != pDraw)) + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); + + /* Register our port with the new window */ + result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); + if(result != Success) return result; + + portPriv->type = XvOutputMask; + + /* save a copy of these parameters */ + portPriv->vid_x = vid_x; portPriv->vid_y = vid_y; + portPriv->vid_w = vid_w; portPriv->vid_h = vid_h; + portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; + portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; + + /* make sure we have the most recent copy of the clientClip */ + xf86XVCopyClip(portPriv, pGC); + + /* To indicate to the DI layer that we were successful */ + pPort->pDraw = pDraw; + + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + return(xf86XVRegetVideo(portPriv)); +} + +static int +xf86XVGetStill( + ClientPtr client, + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, + INT16 vid_x, INT16 vid_y, + CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + ScreenPtr pScreen; + RegionRec WinRegion; + RegionRec ClipRegion; + BoxRec WinBox; + int ret = Success; + Bool clippedAway = FALSE; + + if (pDraw->type != DRAWABLE_WINDOW) + return BadAlloc; + + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + pScreen = pDraw->pScreen; + + WinBox.x1 = pDraw->x + drw_x; + WinBox.y1 = pDraw->y + drw_y; + WinBox.x2 = WinBox.x1 + drw_w; + WinBox.y2 = WinBox.y1 + drw_h; + + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_NULL(pScreen, &ClipRegion); + REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); + + if(portPriv->pDraw) { + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); + } + + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; + goto GET_STILL_BAILOUT; + } + + if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + + ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn, + vid_x, vid_y, WinBox.x1, WinBox.y1, + vid_w, vid_h, drw_w, drw_h, + &ClipRegion, portPriv->DevPriv.ptr, + pDraw); + +GET_STILL_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { + (*portPriv->AdaptorRec->StopVideo)( + portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); + portPriv->isOn = XV_PENDING; + } + + REGION_UNINIT(pScreen, &WinRegion); + REGION_UNINIT(pScreen, &ClipRegion); + + return ret; +} + + + +static int +xf86XVStopVideo( + ClientPtr client, + XvPortPtr pPort, + DrawablePtr pDraw +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + + if(pDraw->type != DRAWABLE_WINDOW) + return BadAlloc; + + xf86XVRemovePortFromWindow((WindowPtr)pDraw, portPriv); + + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + /* Must free resources. */ + + if(portPriv->isOn > XV_OFF) { + (*portPriv->AdaptorRec->StopVideo)( + portPriv->pScrn, portPriv->DevPriv.ptr, TRUE); + portPriv->isOn = XV_OFF; + } + + return Success; +} + +static int +xf86XVSetPortAttribute( + ClientPtr client, + XvPortPtr pPort, + Atom attribute, + INT32 value +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + + return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->pScrn, + attribute, value, portPriv->DevPriv.ptr)); +} + + +static int +xf86XVGetPortAttribute( + ClientPtr client, + XvPortPtr pPort, + Atom attribute, + INT32 *p_value +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + + return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->pScrn, + attribute, p_value, portPriv->DevPriv.ptr)); +} + + + +static int +xf86XVQueryBestSize( + ClientPtr client, + XvPortPtr pPort, + CARD8 motion, + CARD16 vid_w, CARD16 vid_h, + CARD16 drw_w, CARD16 drw_h, + unsigned int *p_w, unsigned int *p_h +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + + (*portPriv->AdaptorRec->QueryBestSize)(portPriv->pScrn, + (Bool)motion, vid_w, vid_h, drw_w, drw_h, + p_w, p_h, portPriv->DevPriv.ptr); + + return Success; +} + + +static int +xf86XVPutImage( + ClientPtr client, + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, + INT16 src_x, INT16 src_y, + CARD16 src_w, CARD16 src_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h, + XvImagePtr format, + unsigned char* data, + Bool sync, + CARD16 width, CARD16 height +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + ScreenPtr pScreen; + RegionRec WinRegion; + RegionRec ClipRegion; + BoxRec WinBox; + int ret = Success; + Bool clippedAway = FALSE; + + if (pDraw->type != DRAWABLE_WINDOW) + return BadAlloc; + + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + pScreen = pDraw->pScreen; + + WinBox.x1 = pDraw->x + drw_x; + WinBox.y1 = pDraw->y + drw_y; + WinBox.x2 = WinBox.x1 + drw_w; + WinBox.y2 = WinBox.y1 + drw_h; + + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_NULL(pScreen, &ClipRegion); + REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); + + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + + VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; + VPBox.x2 = portPriv->pScrn->frameX1 + 1; + VPBox.y2 = portPriv->pScrn->frameY1 + 1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); + REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } + + /* If we are changing windows, unregister our port in the old window */ + if(portPriv->pDraw && (portPriv->pDraw != pDraw)) + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); + + /* Register our port with the new window */ + ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); + if(ret != Success) goto PUT_IMAGE_BAILOUT; + + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; + goto PUT_IMAGE_BAILOUT; + } + + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || + (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || + (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; + goto PUT_IMAGE_BAILOUT; + } + } + + if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) { + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + + ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn, + src_x, src_y, WinBox.x1, WinBox.y1, + src_w, src_h, drw_w, drw_h, format->id, data, width, height, + sync, &ClipRegion, portPriv->DevPriv.ptr, + pDraw); + + if((ret == Success) && + (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) { + + portPriv->isOn = XV_ON; + portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; + portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; + portPriv->type = 0; /* no mask means it's transient and should + not be reput once it's removed */ + pPort->pDraw = pDraw; /* make sure we can get stop requests */ + } + +PUT_IMAGE_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { + (*portPriv->AdaptorRec->StopVideo)( + portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); + portPriv->isOn = XV_PENDING; + } + + REGION_UNINIT(pScreen, &WinRegion); + REGION_UNINIT(pScreen, &ClipRegion); + + return ret; +} + + +static int +xf86XVQueryImageAttributes( + ClientPtr client, + XvPortPtr pPort, + XvImagePtr format, + CARD16 *width, + CARD16 *height, + int *pitches, + int *offsets +){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + + return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn, + format->id, width, height, pitches, offsets); +} + + +_X_EXPORT void +xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) +{ + ScreenPtr pScreen = pDraw->pScreen; + WindowPtr pWin = (WindowPtr)pDraw; + XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin); + GCPtr pGC = NULL; + XID pval[2]; + BoxPtr pbox = REGION_RECTS(clipboxes); + int i, nbox = REGION_NUM_RECTS(clipboxes); + xRectangle *rects; + + if(!xf86Screens[pScreen->myNum]->vtSema) return; + + if(pPriv) + pGC = pPriv->pGC; + + if(!pGC) { + int status; + pval[0] = key; + pval[1] = IncludeInferiors; + pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status, + (XID)0, serverClient); + if(!pGC) return; + ValidateGC(pDraw, pGC); + if (pPriv) pPriv->pGC = pGC; + } else if (key != pGC->fgPixel){ + pval[0] = key; + ChangeGC(pGC, GCForeground, pval); + ValidateGC(pDraw, pGC); + } + + REGION_TRANSLATE(pDraw->pScreen, clipboxes, -pDraw->x, -pDraw->y); + + rects = xalloc(nbox * sizeof(xRectangle)); + + for(i = 0; i < nbox; i++, pbox++) { + rects[i].x = pbox->x1; + rects[i].y = pbox->y1; + rects[i].width = pbox->x2 - pbox->x1; + rects[i].height = pbox->y2 - pbox->y1; + } + + (*pGC->ops->PolyFillRect)(pDraw, pGC, nbox, rects); + + if (!pPriv) FreeGC(pGC, 0); + + xfree(rects); +} + +_X_EXPORT void +xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) +{ + DrawablePtr root = &WindowTable[pScreen->myNum]->drawable; + XID pval[2]; + BoxPtr pbox = REGION_RECTS(clipboxes); + int i, nbox = REGION_NUM_RECTS(clipboxes); + xRectangle *rects; + GCPtr gc; + + if(!xf86Screens[pScreen->myNum]->vtSema) return; + + gc = GetScratchGC(root->depth, pScreen); + pval[0] = key; + pval[1] = IncludeInferiors; + (void) ChangeGC(gc, GCForeground|GCSubwindowMode, pval); + ValidateGC(root, gc); + + rects = xalloc (nbox * sizeof(xRectangle)); + + for(i = 0; i < nbox; i++, pbox++) + { + rects[i].x = pbox->x1; + rects[i].y = pbox->y1; + rects[i].width = pbox->x2 - pbox->x1; + rects[i].height = pbox->y2 - pbox->y1; + } + + (*gc->ops->PolyFillRect)(root, gc, nbox, rects); + + xfree (rects); + FreeScratchGC (gc); +} + +/* xf86XVClipVideoHelper - + + 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. +*/ + +#define DummyScreen screenInfo.screens[0] + +_X_EXPORT Bool +xf86XVClipVideoHelper( + BoxPtr dst, + INT32 *xa, + INT32 *xb, + INT32 *ya, + INT32 *yb, + RegionPtr reg, + INT32 width, + INT32 height +){ + double xsw, xdw, ysw, ydw; + INT32 delta; + BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); + int diff; + + xsw = (*xb - *xa) << 16; + xdw = dst->x2 - dst->x1; + ysw = (*yb - *ya) << 16; + ydw = dst->y2 - dst->y1; + + *xa <<= 16; *xb <<= 16; + *ya <<= 16; *yb <<= 16; + + diff = extents->x1 - dst->x1; + if (diff > 0) { + dst->x1 = extents->x1; + *xa += (diff * xsw) / xdw; + } + diff = dst->x2 - extents->x2; + if (diff > 0) { + dst->x2 = extents->x2; + *xb -= (diff * xsw) / xdw; + } + diff = extents->y1 - dst->y1; + if (diff > 0) { + dst->y1 = extents->y1; + *ya += (diff * ysw) / ydw; + } + diff = dst->y2 - extents->y2; + if (diff > 0) { + dst->y2 = extents->y2; + *yb -= (diff * ysw) / ydw; + } + + if (*xa < 0) { + diff = (((-*xa) * xdw) + xsw - 1) / xsw; + dst->x1 += diff; + *xa += (diff * xsw) / xdw; + } + delta = *xb - (width << 16); + if (delta > 0) { + diff = ((delta * xdw) + xsw - 1) / xsw; + dst->x2 -= diff; + *xb -= (diff * xsw) / xdw; + } + if (*xa >= *xb) return FALSE; + + if (*ya < 0) { + diff = (((-*ya) * ydw) + ysw - 1) / ysw; + dst->y1 += diff; + *ya += (diff * ysw) / ydw; + } + delta = *yb - (height << 16); + if (delta > 0) { + diff = ((delta * ydw) + ysw - 1) / ysw; + dst->y2 -= diff; + *yb -= (diff * ysw) / ydw; + } + if (*ya >= *yb) return FALSE; + + if ((dst->x1 > extents->x1) || (dst->x2 < extents->x2) || + (dst->y1 > extents->y1) || (dst->y2 < extents->y2)) + { + RegionRec clipReg; + REGION_INIT(DummyScreen, &clipReg, dst, 1); + REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); + REGION_UNINIT(DummyScreen, &clipReg); + } + return TRUE; +} + +_X_EXPORT void +xf86XVCopyYUV12ToPacked( + const void *srcy, + const void *srcv, + const void *srcu, + void *dst, + int srcPitchy, + int srcPitchuv, + int dstPitch, + int h, + int w +){ + CARD32 *Dst; + const CARD8 *Y, *U, *V; + int i, j; + + w >>= 1; + + for (j = 0; j < h; j++) { + Dst = dst; + Y = srcy; V = srcv; U = srcu; + i = w; + while (i >= 4) { +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24); + Dst[1] = Y[2] | (Y[3] << 16) | (U[1] << 8) | (V[1] << 24); + Dst[2] = Y[4] | (Y[5] << 16) | (U[2] << 8) | (V[2] << 24); + Dst[3] = Y[6] | (Y[7] << 16) | (U[3] << 8) | (V[3] << 24); +#else + /* This assumes a little-endian framebuffer */ + Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0]; + Dst[1] = (Y[2] << 24) | (Y[3] << 8) | (U[1] << 16) | V[1]; + Dst[2] = (Y[4] << 24) | (Y[5] << 8) | (U[2] << 16) | V[2]; + Dst[3] = (Y[6] << 24) | (Y[7] << 8) | (U[3] << 16) | V[3]; +#endif + Dst += 4; Y += 8; V += 4; U += 4; + i -= 4; + } + + while (i--) { +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24); +#else + /* This assumes a little-endian framebuffer */ + Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0]; +#endif + Dst++; Y += 2; V++; U++; + } + + dst = (CARD8 *)dst + dstPitch; + srcy = (const CARD8 *)srcy + srcPitchy; + if (j & 1) { + srcu = (const CARD8 *)srcu + srcPitchuv; + srcv = (const CARD8 *)srcv + srcPitchuv; + } + } +} + +_X_EXPORT void +xf86XVCopyPacked( + const void *src, + void *dst, + int srcPitch, + int dstPitch, + int h, + int w +){ + const CARD32 *Src; + CARD32 *Dst; + int i; + + w >>= 1; + while (--h >= 0) { + do { + Dst = dst; Src = src; + i = w; + while (i >= 4) { + Dst[0] = Src[0]; + Dst[1] = Src[1]; + Dst[2] = Src[2]; + Dst[3] = Src[3]; + Dst += 4; Src += 4; i -= 4; + } + if (!i) break; + Dst[0] = Src[0]; + if (i == 1) break; + Dst[1] = Src[1]; + if (i == 2) break; + Dst[2] = Src[2]; + } while (0); + + src = (const CARD8 *)src + srcPitch; + dst = (CARD8 *)dst + dstPitch; + } +} diff --git a/xorg-server/hw/xfree86/common/xf86xv.h b/xorg-server/hw/xfree86/common/xf86xv.h new file mode 100644 index 000000000..817e2b994 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86xv.h @@ -0,0 +1,273 @@ + +/* + * Copyright (c) 1998-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86XV_H_ +#define _XF86XV_H_ + +#include "xvdix.h" +#include "xf86str.h" + +#define VIDEO_NO_CLIPPING 0x00000001 +#define VIDEO_INVERT_CLIPLIST 0x00000002 +#define VIDEO_OVERLAID_IMAGES 0x00000004 +#define VIDEO_OVERLAID_STILLS 0x00000008 +#define VIDEO_CLIP_TO_VIEWPORT 0x00000010 + +typedef struct { + int id; + int type; + int byte_order; + unsigned char guid[16]; + int bits_per_pixel; + int format; + int num_planes; + + /* for RGB formats only */ + int depth; + unsigned int red_mask; + unsigned int green_mask; + unsigned int blue_mask; + + /* for YUV formats only */ + unsigned int y_sample_bits; + unsigned int u_sample_bits; + unsigned int v_sample_bits; + unsigned int horz_y_period; + unsigned int horz_u_period; + unsigned int horz_v_period; + unsigned int vert_y_period; + unsigned int vert_u_period; + unsigned int vert_v_period; + char component_order[32]; + int scanline_order; +} XF86ImageRec, *XF86ImagePtr; + + +typedef struct { + ScrnInfoPtr pScrn; + int id; + unsigned short width, height; + int *pitches; /* bytes */ + int *offsets; /* in bytes from start of framebuffer */ + DevUnion devPrivate; +} XF86SurfaceRec, *XF86SurfacePtr; + + +typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn, + short vid_x, short vid_y, short drw_x, short drw_y, + short vid_w, short vid_h, short drw_w, short drw_h, + RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); +typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn, + short vid_x, short vid_y, short drw_x, short drw_y, + short vid_w, short vid_h, short drw_w, short drw_h, + RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); +typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn, + short vid_x, short vid_y, short drw_x, short drw_y, + short vid_w, short vid_h, short drw_w, short drw_h, + RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); +typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn, + short vid_x, short vid_y, short drw_x, short drw_y, + short vid_w, short vid_h, short drw_w, short drw_h, + RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); +typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool Exit); +typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute, + INT32 value, pointer data); +typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute, + INT32 *value, pointer data); +typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, Bool motion, + short vid_w, short vid_h, short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, pointer data); +typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn, + short src_x, short src_y, short drw_x, short drw_y, + short src_w, short src_h, short drw_w, short drw_h, + int image, unsigned char* buf, short width, short height, Bool Sync, + RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); +typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn, short drw_x, short drw_y, + RegionPtr clipBoxes, pointer data, DrawablePtr pDraw ); +typedef int (*QueryImageAttributesFuncPtr)(ScrnInfoPtr pScrn, + int image, unsigned short *width, unsigned short *height, + int *pitches, int *offsets); + +typedef enum { + XV_OFF, + XV_PENDING, + XV_ON +} XvStatus; + +/*** this is what the driver needs to fill out ***/ + +typedef struct { + int id; + char *name; + unsigned short width, height; + XvRationalRec rate; +} XF86VideoEncodingRec, *XF86VideoEncodingPtr; + +typedef struct { + char depth; + short class; +} XF86VideoFormatRec, *XF86VideoFormatPtr; + +typedef struct { + int flags; + int min_value; + int max_value; + char *name; +} XF86AttributeRec, *XF86AttributePtr; + +typedef struct { + unsigned int type; + int flags; + char *name; + int nEncodings; + XF86VideoEncodingPtr pEncodings; + int nFormats; + XF86VideoFormatPtr pFormats; + int nPorts; + DevUnion *pPortPrivates; + int nAttributes; + XF86AttributePtr pAttributes; + int nImages; + XF86ImagePtr pImages; + PutVideoFuncPtr PutVideo; + PutStillFuncPtr PutStill; + GetVideoFuncPtr GetVideo; + GetStillFuncPtr GetStill; + StopVideoFuncPtr StopVideo; + SetPortAttributeFuncPtr SetPortAttribute; + GetPortAttributeFuncPtr GetPortAttribute; + QueryBestSizeFuncPtr QueryBestSize; + PutImageFuncPtr PutImage; + ReputImageFuncPtr ReputImage; + QueryImageAttributesFuncPtr QueryImageAttributes; +} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr; + +typedef struct { + XF86ImagePtr image; + int flags; + int (*alloc_surface)(ScrnInfoPtr pScrn, + int id, + unsigned short width, + unsigned short height, + XF86SurfacePtr surface); + int (*free_surface)(XF86SurfacePtr surface); + int (*display) (XF86SurfacePtr surface, + short vid_x, short vid_y, + short drw_x, short drw_y, + short vid_w, short vid_h, + short drw_w, short drw_h, + RegionPtr clipBoxes); + int (*stop) (XF86SurfacePtr surface); + int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value); + int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value); + int max_width; + int max_height; + int num_attributes; + XF86AttributePtr attributes; +} XF86OffscreenImageRec, *XF86OffscreenImagePtr; + +Bool +xf86XVScreenInit( + ScreenPtr pScreen, + XF86VideoAdaptorPtr *Adaptors, + int num +); + +typedef int (* xf86XVInitGenericAdaptorPtr)(ScrnInfoPtr pScrn, + XF86VideoAdaptorPtr **Adaptors); + +int +xf86XVRegisterGenericAdaptorDriver( + xf86XVInitGenericAdaptorPtr InitFunc +); + +int +xf86XVListGenericAdaptors( + ScrnInfoPtr pScrn, + XF86VideoAdaptorPtr **Adaptors +); + +Bool +xf86XVRegisterOffscreenImages( + ScreenPtr pScreen, + XF86OffscreenImagePtr images, + int num +); + +XF86OffscreenImagePtr +xf86XVQueryOffscreenImages( + ScreenPtr pScreen, + int *num +); + +XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn); + +void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr); + +void +xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes); + +void +xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes); + +Bool +xf86XVClipVideoHelper( + BoxPtr dst, + INT32 *xa, + INT32 *xb, + INT32 *ya, + INT32 *yb, + RegionPtr reg, + INT32 width, + INT32 height +); + +void +xf86XVCopyYUV12ToPacked( + const void *srcy, + const void *srcv, + const void *srcu, + void *dst, + int srcPitchy, + int srcPitchuv, + int dstPitch, + int h, + int w +); + +void +xf86XVCopyPacked( + const void *src, + void *dst, + int srcPitch, + int dstPitch, + int h, + int w +); + +#endif /* _XF86XV_H_ */ diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.c b/xorg-server/hw/xfree86/common/xf86xvmc.c new file mode 100644 index 000000000..05267a240 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86xvmc.c @@ -0,0 +1,229 @@ + +/* + * Copyright (c) 2001-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include +#include "scrnintstr.h" +#include "resource.h" +#include "dixstruct.h" + +#include "xvmodproc.h" + +#include "xf86xvpriv.h" +#include "xf86xvmc.h" + +typedef int (*XvMCScreenInitProcPtr)(ScreenPtr, int, XvMCAdaptorPtr); +_X_EXPORT XvMCScreenInitProcPtr XvMCScreenInitProc = NULL; + + +typedef struct { + CloseScreenProcPtr CloseScreen; + int num_adaptors; + XF86MCAdaptorPtr *adaptors; + XvMCAdaptorPtr dixinfo; +} xf86XvMCScreenRec, *xf86XvMCScreenPtr; + +static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKey; + +#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey) + + +static int +xf86XvMCCreateContext ( + XvPortPtr pPort, + XvMCContextPtr pContext, + int *num_priv, + CARD32 **priv +) +{ + xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen); + ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum]; + + pContext->port_priv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + + return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateContext)( + pScrn, pContext, num_priv, priv); +} + +static void +xf86XvMCDestroyContext ( XvMCContextPtr pContext) +{ + xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen); + ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum]; + + (*pScreenPriv->adaptors[pContext->adapt_num]->DestroyContext)( + pScrn, pContext); +} + +static int +xf86XvMCCreateSurface ( + XvMCSurfacePtr pSurface, + int *num_priv, + CARD32 **priv +) +{ + XvMCContextPtr pContext = pSurface->context; + xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen); + ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum]; + + return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSurface)( + pScrn, pSurface, num_priv, priv); +} + +static void +xf86XvMCDestroySurface (XvMCSurfacePtr pSurface) +{ + XvMCContextPtr pContext = pSurface->context; + xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen); + ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum]; + + (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySurface)( + pScrn, pSurface); +} + +static int +xf86XvMCCreateSubpicture ( + XvMCSubpicturePtr pSubpicture, + int *num_priv, + CARD32 **priv +) +{ + XvMCContextPtr pContext = pSubpicture->context; + xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen); + ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum]; + + return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSubpicture)( + pScrn, pSubpicture, num_priv, priv); +} + +static void +xf86XvMCDestroySubpicture (XvMCSubpicturePtr pSubpicture) +{ + XvMCContextPtr pContext = pSubpicture->context; + xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen); + ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum]; + + (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySubpicture)( + pScrn, pSubpicture); +} + + +static Bool +xf86XvMCCloseScreen (int i, ScreenPtr pScreen) +{ + xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pScreen); + + pScreen->CloseScreen = pScreenPriv->CloseScreen; + + xfree(pScreenPriv->dixinfo); + xfree(pScreenPriv); + + return (*pScreen->CloseScreen)(i, pScreen); +} + +_X_EXPORT Bool xf86XvMCScreenInit( + ScreenPtr pScreen, + int num_adaptors, + XF86MCAdaptorPtr *adaptors +) +{ + XvMCAdaptorPtr pAdapt; + xf86XvMCScreenPtr pScreenPriv; + XvScreenPtr pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + XF86XvScreenKey); + int i, j; + + if(!XvMCScreenInitProc) return FALSE; + + if(!(pAdapt = xalloc(sizeof(XvMCAdaptorRec) * num_adaptors))) + return FALSE; + + if(!(pScreenPriv = xalloc(sizeof(xf86XvMCScreenRec)))) { + xfree(pAdapt); + return FALSE; + } + + dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv); + + pScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = xf86XvMCCloseScreen; + + pScreenPriv->num_adaptors = num_adaptors; + pScreenPriv->adaptors = adaptors; + pScreenPriv->dixinfo = pAdapt; + + for(i = 0; i < num_adaptors; i++) { + pAdapt[i].xv_adaptor = NULL; + for(j = 0; j < pxvs->nAdaptors; j++) { + if(!strcmp((*adaptors)->name, pxvs->pAdaptors[j].name)) { + pAdapt[i].xv_adaptor = &(pxvs->pAdaptors[j]); + break; + } + } + if(!pAdapt[i].xv_adaptor) { + /* no adaptor by that name */ + xfree(pAdapt); + return FALSE; + } + pAdapt[i].num_surfaces = (*adaptors)->num_surfaces; + pAdapt[i].surfaces = (XvMCSurfaceInfoPtr*)((*adaptors)->surfaces); + pAdapt[i].num_subpictures = (*adaptors)->num_subpictures; + pAdapt[i].subpictures = (XvImagePtr*)((*adaptors)->subpictures); + pAdapt[i].CreateContext = xf86XvMCCreateContext; + pAdapt[i].DestroyContext = xf86XvMCDestroyContext; + pAdapt[i].CreateSurface = xf86XvMCCreateSurface; + pAdapt[i].DestroySurface = xf86XvMCDestroySurface; + pAdapt[i].CreateSubpicture = xf86XvMCCreateSubpicture; + pAdapt[i].DestroySubpicture = xf86XvMCDestroySubpicture; + adaptors++; + } + + if(Success != (*XvMCScreenInitProc)(pScreen, num_adaptors, pAdapt)) + return FALSE; + + return TRUE; +} + +_X_EXPORT XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec (void) +{ + return xcalloc(1, sizeof(XF86MCAdaptorRec)); +} + +_X_EXPORT void xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor) +{ + xfree(adaptor); +} diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.h b/xorg-server/hw/xfree86/common/xf86xvmc.h new file mode 100644 index 000000000..bc7a98c6a --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86xvmc.h @@ -0,0 +1,163 @@ + +/* + * Copyright (c) 2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86XVMC_H +#define _XF86XVMC_H + +#include "xvmcext.h" +#include "xf86xv.h" + +typedef struct { + int num_xvimages; + int *xvimage_ids; /* reference the subpictures in the XF86MCAdaptorRec */ +} XF86MCImageIDList; + +typedef struct { + int surface_type_id; /* Driver generated. Must be unique on the port */ + int chroma_format; + int color_description; /* no longer used */ + unsigned short max_width; + unsigned short max_height; + unsigned short subpicture_max_width; + unsigned short subpicture_max_height; + int mc_type; + int flags; + XF86MCImageIDList *compatible_subpictures; /* can be null, if none */ +} XF86MCSurfaceInfoRec, *XF86MCSurfaceInfoPtr; + + +/* + xf86XvMCCreateContextProc + + DIX will fill everything out in the context except the driver_priv. + The port_priv holds the private data specified for the port when + Xv was initialized by the driver. + The driver may store whatever it wants in driver_priv and edit + the width, height and flags. If the driver wants to return something + to the client it can allocate space in priv and specify the number + of 32 bit words in num_priv. This must be dynamically allocated + space because DIX will free it after it passes it to the client. +*/ + + +typedef int (*xf86XvMCCreateContextProcPtr) ( + ScrnInfoPtr pScrn, + XvMCContextPtr context, + int *num_priv, + CARD32 **priv +); + +typedef void (*xf86XvMCDestroyContextProcPtr) ( + ScrnInfoPtr pScrn, + XvMCContextPtr context +); + +/* + xf86XvMCCreateSurfaceProc + + DIX will fill everything out in the surface except the driver_priv. + The driver may store whatever it wants in driver_priv. The driver + may pass data back to the client in the same manner as the + xf86XvMCCreateContextProc. +*/ + + +typedef int (*xf86XvMCCreateSurfaceProcPtr) ( + ScrnInfoPtr pScrn, + XvMCSurfacePtr surface, + int *num_priv, + CARD32 **priv +); + +typedef void (*xf86XvMCDestroySurfaceProcPtr) ( + ScrnInfoPtr pScrn, + XvMCSurfacePtr surface +); + +/* + xf86XvMCCreateSubpictureProc + + DIX will fill everything out in the subpicture except the driver_priv, + num_palette_entries, entry_bytes and component_order. The driver may + store whatever it wants in driver_priv and edit the width and height. + If it is a paletted subpicture the driver needs to fill out the + num_palette_entries, entry_bytes and component_order. These are + not communicated to the client until the time the surface is + created. + + The driver may pass data back to the client in the same manner as the + xf86XvMCCreateContextProc. +*/ + + +typedef int (*xf86XvMCCreateSubpictureProcPtr) ( + ScrnInfoPtr pScrn, + XvMCSubpicturePtr subpicture, + int *num_priv, + CARD32 **priv +); + +typedef void (*xf86XvMCDestroySubpictureProcPtr) ( + ScrnInfoPtr pScrn, + XvMCSubpicturePtr subpicture +); + + +typedef struct { + char *name; + int num_surfaces; + XF86MCSurfaceInfoPtr *surfaces; + int num_subpictures; + XF86ImagePtr *subpictures; + xf86XvMCCreateContextProcPtr CreateContext; + xf86XvMCDestroyContextProcPtr DestroyContext; + xf86XvMCCreateSurfaceProcPtr CreateSurface; + xf86XvMCDestroySurfaceProcPtr DestroySurface; + xf86XvMCCreateSubpictureProcPtr CreateSubpicture; + xf86XvMCDestroySubpictureProcPtr DestroySubpicture; +} XF86MCAdaptorRec, *XF86MCAdaptorPtr; + +/* + xf86XvMCScreenInit + + Unlike Xv, the adaptor data is not copied from this structure. + This structure's data is used so it must stick around for the + life of the server. Note that it's an array of pointers not + an array of structures. +*/ + +Bool xf86XvMCScreenInit( + ScreenPtr pScreen, + int num_adaptors, + XF86MCAdaptorPtr *adaptors +); + +XF86MCAdaptorPtr xf86XvMCCreateAdaptorRec (void); +void xf86XvMCDestroyAdaptorRec(XF86MCAdaptorPtr adaptor); + +#endif /* _XF86XVMC_H */ diff --git a/xorg-server/hw/xfree86/common/xf86xvpriv.h b/xorg-server/hw/xfree86/common/xf86xvpriv.h new file mode 100644 index 000000000..4200dac80 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xf86xvpriv.h @@ -0,0 +1,87 @@ + +/* + * Copyright (c) 2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _XF86XVPRIV_H_ +#define _XF86XVPRIV_H_ + +#include "xf86xv.h" +#include "privates.h" + +/*** These are DDX layer privates ***/ + +extern DevPrivateKey XF86XvScreenKey; + +typedef struct { + DestroyWindowProcPtr DestroyWindow; + ClipNotifyProcPtr ClipNotify; + WindowExposuresProcPtr WindowExposures; + void (*AdjustFrame)(int, int, int, int); + Bool (*EnterVT)(int, int); + void (*LeaveVT)(int, int); + GCPtr videoGC; +} XF86XVScreenRec, *XF86XVScreenPtr; + +typedef struct { + int flags; + PutVideoFuncPtr PutVideo; + PutStillFuncPtr PutStill; + GetVideoFuncPtr GetVideo; + GetStillFuncPtr GetStill; + StopVideoFuncPtr StopVideo; + SetPortAttributeFuncPtr SetPortAttribute; + GetPortAttributeFuncPtr GetPortAttribute; + QueryBestSizeFuncPtr QueryBestSize; + PutImageFuncPtr PutImage; + ReputImageFuncPtr ReputImage; + QueryImageAttributesFuncPtr QueryImageAttributes; +} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr; + +typedef struct { + ScrnInfoPtr pScrn; + DrawablePtr pDraw; + unsigned char type; + unsigned int subWindowMode; + DDXPointRec clipOrg; + RegionPtr clientClip; + RegionPtr pCompositeClip; + Bool FreeCompositeClip; + XvAdaptorRecPrivatePtr AdaptorRec; + XvStatus isOn; + Bool moved; + int vid_x, vid_y, vid_w, vid_h; + int drw_x, drw_y, drw_w, drw_h; + DevUnion DevPriv; +} XvPortRecPrivate, *XvPortRecPrivatePtr; + +typedef struct _XF86XVWindowRec{ + XvPortRecPrivatePtr PortRec; + struct _XF86XVWindowRec *next; + GCPtr pGC; +} XF86XVWindowRec, *XF86XVWindowPtr; + +#endif /* _XF86XVPRIV_H_ */ diff --git a/xorg-server/hw/xfree86/common/xisb.c b/xorg-server/hw/xfree86/common/xisb.c new file mode 100644 index 000000000..d021ec15b --- /dev/null +++ b/xorg-server/hw/xfree86/common/xisb.c @@ -0,0 +1,175 @@ +/* + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +/* + X Input Serial Buffer routines for use in any XInput driver that accesses + a serial device. +*/ + + +/***************************************************************************** + * Standard Headers + ****************************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include "xisb.h" + +/***************************************************************************** + * Local Headers + ****************************************************************************/ + +/***************************************************************************** + * Variables without includable headers + ****************************************************************************/ + +/***************************************************************************** + * Local Variables + ****************************************************************************/ + +/***************************************************************************** + * Function Definitions + ****************************************************************************/ + +_X_EXPORT XISBuffer * +XisbNew (int fd, ssize_t size) +{ + XISBuffer *b; + + b = xalloc (sizeof (XISBuffer)); + if (!b) + return (NULL); + b->buf = xalloc ((sizeof (unsigned char) * size)); + if (!b->buf) + { + xfree (b); + return (NULL); + } + + b->fd = fd; + b->trace = 0; + b->block_duration = 0; + b->current = 1; /* force it to be past the end to trigger initial read */ + b->end = 0; + b->buffer_size = size; + return (b); +} + +_X_EXPORT void +XisbFree (XISBuffer *b) +{ + xfree (b->buf); + xfree (b); +} + +_X_EXPORT int +XisbRead (XISBuffer *b) +{ + int ret; + + if (b->current >= b->end) + { + if (b->block_duration >= 0) + { + if (xf86WaitForInput (b->fd, b->block_duration) < 1) + return (-1); + } + else + { + /* + * automatically clear it so if XisbRead is called in a loop + * the next call will make sure there is data with select and + * thus prevent a blocking read + */ + b->block_duration = 0; + } + + ret = xf86ReadSerial (b->fd, b->buf, b->buffer_size); + switch (ret) + { + case 0: + return (-1); /* timeout */ + case -1: + return (-2); /* error */ + default: + b->end = ret; + b->current = 0; + break; + } + } + if (b->trace) + ErrorF ("read 0x%02x (%c)\n", b->buf[b->current], + isprint(b->buf[b->current])?b->buf[b->current]:'.'); + + return (b->buf[b->current++]); +} + +/* the only purpose of this function is to provide output tracing */ +_X_EXPORT ssize_t +XisbWrite (XISBuffer *b, unsigned char *msg, ssize_t len) +{ + if (b->trace) + { + int i = 0; + for (i = 0; i < len; i++) + ErrorF ("\t\twrote 0x%02x (%c)\n", msg[i], msg[i]); + } + return (xf86WriteSerial (b->fd, msg, len)); +} + +/* turn tracing of this buffer on (1) or off (0) */ +_X_EXPORT void +XisbTrace (XISBuffer *b, int trace) +{ + b->trace = trace; +} + +/* + * specify a block_duration of -1 when you know the buffer's fd is ready to + * read. After a read, it is automatically set to 0 so that the next read + * will use check to select for data and prevent a block. + * It is the caller's responsibility to set the block_duration to -1 if it + * knows that there is data to read (because the main select loop triggered + * the read) and want's to avoid the unnecessary overhead of the select call + * + * a zero or positive block duration will cause the select to block for the + * give duration in usecs. + */ + +_X_EXPORT void +XisbBlockDuration (XISBuffer *b, int block_duration) +{ + b->block_duration = block_duration; +} diff --git a/xorg-server/hw/xfree86/common/xisb.h b/xorg-server/hw/xfree86/common/xisb.h new file mode 100644 index 000000000..b7bdd5682 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xisb.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +#ifndef _xisb_H_ +#define _xisb_H_ + +#include + +/****************************************************************************** + * Definitions + * structs, typedefs, #defines, enums + *****************************************************************************/ + +typedef struct _XISBuffer +{ + int fd; + int trace; + int block_duration; + ssize_t current; /* bytes read */ + ssize_t end; + ssize_t buffer_size; + unsigned char *buf; +} XISBuffer; + +/****************************************************************************** + * Declarations + * variables: use xisb_LOC in front + * of globals. + * put locals in the .c file. + *****************************************************************************/ +XISBuffer * XisbNew (int fd, ssize_t size); +void XisbFree (XISBuffer *b); +int XisbRead (XISBuffer *b); +ssize_t XisbWrite (XISBuffer *b, unsigned char *msg, ssize_t len); +void XisbTrace (XISBuffer *b, int trace); +void XisbBlockDuration (XISBuffer *b, int block_duration); + +/* + * DO NOT PUT ANYTHING AFTER THIS ENDIF + */ +#endif diff --git a/xorg-server/hw/xfree86/common/xorgHelper.c b/xorg-server/hw/xfree86/common/xorgHelper.c new file mode 100644 index 000000000..7f9dd507a --- /dev/null +++ b/xorg-server/hw/xfree86/common/xorgHelper.c @@ -0,0 +1,23 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "servermd.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "propertyst.h" +#include "gcstruct.h" +#include "loaderProcs.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xorgVersion.h" + + +CARD32 +xorgGetVersion() +{ + return XORG_VERSION_CURRENT; +} diff --git a/xorg-server/hw/xfree86/common/xorgVersion.h b/xorg-server/hw/xfree86/common/xorgVersion.h new file mode 100644 index 000000000..f627e87a5 --- /dev/null +++ b/xorg-server/hw/xfree86/common/xorgVersion.h @@ -0,0 +1,49 @@ + +/* + * Copyright (c) 2004, X.Org Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef XORG_VERSION_H +# define XORG_VERSION_H + +# ifndef XORG_VERSION_CURRENT +# error +# endif + +# define XORG_VERSION_NUMERIC(major,minor,patch,snap,dummy) \ + (((major) * 10000000) + ((minor) * 100000) + ((patch) * 1000) + snap) + +# define XORG_GET_MAJOR_VERSION(vers) ((vers) / 10000000) +# define XORG_GET_MINOR_VERSION(vers) (((vers) % 10000000) / 100000) +# define XORG_GET_PATCH_VERSION(vers) (((vers) % 100000) / 1000) +# define XORG_GET_SNAP_VERSION(vers) ((vers) % 1000) + +# define XORG_VERSION_MAJOR XORG_GET_MAJOR_VERSION(XORG_VERSION_CURRENT) +# define XORG_VERSION_MINOR XORG_GET_MINOR_VERSION(XORG_VERSION_CURRENT) +# define XORG_VERSION_PATCH XORG_GET_PATCH_VERSION(XORG_VERSION_CURRENT) +# define XORG_VERSION_SNAP XORG_GET_SNAP_VERSION(XORG_VERSION_CURRENT) + +#endif diff --git a/xorg-server/hw/xfree86/ddc/DDC.HOWTO b/xorg-server/hw/xfree86/ddc/DDC.HOWTO new file mode 100644 index 000000000..833a7ab54 --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/DDC.HOWTO @@ -0,0 +1,97 @@ + DDC.HOWTO + + This file describes how to add DDC support to a chipset driver. + +1) DDC INITIALIZATION + + When implementing DDC in the driver one has the choice between + DDC1 and DDC2. + DDC1 data is contiuously transmitted by a DDC1 capable display + device. The data is send serially over a data line; the Vsync + signal serves as clock. Only one EDID 1.x data block can be + transmitted using DDC1. Since transmission of an EDID1 block + using a regular Vsync frequency would take up several seconds + the driver can increase the Vsync frequency to up to 25 kHz as + soon as it detects DDC1 activety on the data line. + DDC2 data is transmitted using the I2C protocol. This requires + an additional clock line. DDC2 is capable of transmitting EDID1 + and EDID2 block as well as a VDIF block on display devices that + support these. + Display devices switch into the DDC2 mode as soon as they detect + activety on the DDC clock line. Once the are in DDC2 mode they + stop transmitting DDC1 signals until the next power cycle. + + Some graphics chipset configurations which are not capable of + DDC2 might still be able to read DDC1 data. Where available + DDC2 it is preferrable. + + All relevant prototypes and defines are in xf86DDC.h. + DDC2 additionally requires I2C support. The I2C prototypes + are in xf86i2c.h. + + DDC1 Support: + + The driver has to provide a read function which waits for the + end of the next Vsync signal and reads in and returns the status + of the DDC line: + + unsigned int XXX_ddc1Read(ScrnInfoPtr pScrn) + + Additionally a function is required to inclrease the Vsync + frequency to max. 25 kHz. + + void XXX_ddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed) + + If the speed argument is DDC_FAST the function should increase + the Vsync frequency on DDC_SLOW it should restore the original + value. For convenience a generic ddc1SetSpeed() function is provided + in the vga module for VGA-like chipsets. + + void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, sf86ddcSpeed speed). + + To read out the DDC1 data the driver should call + + xf86MonPtr xf86DoEDID_DDC1(int scrnIndex, + void (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed), + unsigned int (*DDC1Read)(ScrnInfoPtr)) + + in PreInit(). DDC1SetSpeed is a pointer to the SetSpeed() + function, DDC1Read has to point to the DDC1 read function. + The function will return a pointer to the xf86Monitor structure + which contains all information retreived by DDC. + NULL will be returned on failure. + + DDC2 Support + + To read out DDC2 information I2C has to be initialized first. + (See documentation for the i2c module). + The function + + xf86MonPtr xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus) + + is provided to read out and process DDC2 data. A pointer + to the I2CBusRec of the appropriate I2C Bus has to be passed + as the second argument. + The function will return a pointer to the xf86Monitor structure + which contains all information retreived by DDC. + NULL will be returned on failure. + + Printing monitor parameters + + To print out the information contained in the xf86Monitor + structure the function + + xf86MonPtr xf86PrintEDID(xf86MonPtr monitor) + + is provided. + + Further processing of the xf86Monitor structure is not yet + implemented. Howerver it is planned to use the information + about video modes, gamma values etc. + Therefore it is strongly recommended to read out DDC data + before any video mode processing is done. + + + + +$XFree86: xc/programs/Xserver/hw/xfree86/ddc/DDC.HOWTO,v 1.2 1998/12/06 13:30:39 dawes Exp $ diff --git a/xorg-server/hw/xfree86/ddc/Makefile.am b/xorg-server/hw/xfree86/ddc/Makefile.am new file mode 100644 index 000000000..cd146c5a3 --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/Makefile.am @@ -0,0 +1,12 @@ +sdk_HEADERS = edid.h xf86DDC.h + +noinst_LIBRARIES = libddc.a + +libddc_a_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \ + ddcProperty.c + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +EXTRA_DIST = ddcPriv.h DDC.HOWTO diff --git a/xorg-server/hw/xfree86/ddc/Makefile.in b/xorg-server/hw/xfree86/ddc/Makefile.in new file mode 100644 index 000000000..9016bc200 --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/Makefile.in @@ -0,0 +1,683 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/ddc +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libddc_a_AR = $(AR) $(ARFLAGS) +libddc_a_LIBADD = +am_libddc_a_OBJECTS = xf86DDC.$(OBJEXT) edid.$(OBJEXT) \ + interpret_edid.$(OBJEXT) print_edid.$(OBJEXT) \ + ddcProperty.$(OBJEXT) +libddc_a_OBJECTS = $(am_libddc_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libddc_a_SOURCES) +DIST_SOURCES = $(libddc_a_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +sdk_HEADERS = edid.h xf86DDC.h +noinst_LIBRARIES = libddc.a +libddc_a_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \ + ddcProperty.c + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +EXTRA_DIST = ddcPriv.h DDC.HOWTO +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/ddc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/ddc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libddc.a: $(libddc_a_OBJECTS) $(libddc_a_DEPENDENCIES) + -rm -f libddc.a + $(libddc_a_AR) libddc.a $(libddc_a_OBJECTS) $(libddc_a_LIBADD) + $(RANLIB) libddc.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ddcProperty.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edid.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interpret_edid.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print_edid.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DDC.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/ddc/ddcPriv.h b/xorg-server/hw/xfree86/ddc/ddcPriv.h new file mode 100644 index 000000000..b5cb9b836 --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/ddcPriv.h @@ -0,0 +1,9 @@ +extern unsigned char *GetEDID_DDC1( + unsigned int * +); + +extern int DDC_checksum( + unsigned char *, + int +); + diff --git a/xorg-server/hw/xfree86/ddc/ddcProperty.c b/xorg-server/hw/xfree86/ddc/ddcProperty.c new file mode 100644 index 000000000..02125dff7 --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/ddcProperty.c @@ -0,0 +1,117 @@ +/* + * Copyright 2006 Luc Verhaegen. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86.h" +#include "xf86DDC.h" +#include +#include "property.h" +#include "propertyst.h" +#include "xf86DDC.h" + +#define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA" +#define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA" + +static void +addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC) +{ + Atom EDID1Atom=-1, EDID2Atom=-1; + CARD8 *EDID1rawdata = NULL; + CARD8 *EDID2rawdata = NULL; + int i, scrnIndex = pScrn->scrnIndex; + Bool makeEDID1prop = FALSE; + Bool makeEDID2prop = FALSE; + + if (DDC->ver.version == 1) { + makeEDID1prop = TRUE; + } else if (DDC->ver.version == 2) { + int checksum1; + int checksum2; + makeEDID2prop = TRUE; + + /* Some monitors (eg Panasonic PanaSync4) + * report version==2 because they used EDID v2 spec document, + * although they use EDID v1 data structure :-( + * + * Try using checksum to determine when we have such a monitor. + */ + checksum2 = 0; + for (i = 0; i < 256; i++) + checksum2 += DDC->rawData[i]; + if (checksum2 % 256) { + xf86DrvMsg(scrnIndex, X_INFO, "Monitor EDID v2 checksum failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, + "XFree86_DDC_EDID2_RAWDATA property may be bad\n"); + checksum1 = 0; + for (i = 0; i < 128; i++) + checksum1 += DDC->rawData[i]; + if (!(checksum1 % 256)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Monitor EDID v1 checksum passed,\n"); + xf86DrvMsg(scrnIndex, X_INFO, + "XFree86_DDC_EDID1_RAWDATA property created\n"); + makeEDID1prop = TRUE; + } + } + } else { + xf86DrvMsg(scrnIndex, X_PROBED, "unexpected EDID version %d.%d\n", + DDC->ver.version, DDC->ver.revision); + return; + } + + if (makeEDID1prop) { + if ((EDID1rawdata = xalloc(128*sizeof(CARD8)))==NULL) + return; + + EDID1Atom = MakeAtom(EDID1_ATOM_NAME, sizeof(EDID1_ATOM_NAME) - 1, TRUE); + memcpy(EDID1rawdata, DDC->rawData, 128); + xf86RegisterRootWindowProperty(scrnIndex, EDID1Atom, XA_INTEGER, 8, + 128, (unsigned char *)EDID1rawdata); + } + + if (makeEDID2prop) { + if ((EDID2rawdata = xalloc(256*sizeof(CARD8)))==NULL) + return; + + memcpy(EDID2rawdata, DDC->rawData, 256); + EDID2Atom = MakeAtom(EDID2_ATOM_NAME, sizeof(EDID2_ATOM_NAME) - 1, TRUE); + xf86RegisterRootWindowProperty(scrnIndex, EDID2Atom, XA_INTEGER, 8, + 256, (unsigned char *)EDID2rawdata); + } +} + +Bool +xf86SetDDCproperties(ScrnInfoPtr pScrn, xf86MonPtr DDC) +{ + if (!pScrn || !pScrn->monitor || !DDC) + return FALSE; + + xf86DDCMonitorSet(pScrn->scrnIndex, pScrn->monitor, DDC); + + addRootWindowProperties(pScrn, DDC); + + return TRUE; +} diff --git a/xorg-server/hw/xfree86/ddc/edid.c b/xorg-server/hw/xfree86/ddc/edid.c new file mode 100644 index 000000000..3ebafbbba --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/edid.c @@ -0,0 +1,140 @@ + +/* edid.c: retrieve EDID record from raw DDC1 data stream: data + * is contained in an array of unsigned int each unsigned int + * contains one bit if bit is 0 unsigned int has to be zero else + * unsigned int > 0 + * + * Copyright 1998 by Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86DDC.h" +#include "ddcPriv.h" +#include + +static int find_start(unsigned int *); +static unsigned char * find_header(unsigned char *); +static unsigned char * resort(unsigned char *); + +unsigned char * +GetEDID_DDC1(unsigned int *s_ptr) +{ + unsigned char *d_block, *d_pos; + unsigned int *s_pos, *s_end; + int s_start; + int i,j; + s_start = find_start(s_ptr); + if (s_start==-1) return NULL; + s_end = s_ptr + NUM; + s_pos = s_ptr + s_start; + d_block=xalloc(EDID1_LEN); + if (!d_block) return NULL; + d_pos = d_block; + for (i=0;i + */ + +#ifndef _EDID_H_ +#define _EDID_H_ + +/* read complete EDID record */ +#define EDID1_LEN 128 +#define BITS_PER_BYTE 9 +#define NUM BITS_PER_BYTE*EDID1_LEN +#define HEADER 6 + +#define STD_TIMINGS 8 +#define DET_TIMINGS 4 + +#ifdef _PARSE_EDID_ + +/* header: 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00 */ +#define HEADER_SECTION 0 +#define HEADER_LENGTH 8 + +/* vendor section */ +#define VENDOR_SECTION (HEADER_SECTION + HEADER_LENGTH) +#define V_MANUFACTURER 0 +#define V_PROD_ID (V_MANUFACTURER + 2) +#define V_SERIAL (V_PROD_ID + 2) +#define V_WEEK (V_SERIAL + 4) +#define V_YEAR (V_WEEK + 1) +#define VENDOR_LENGTH (V_YEAR + 1) + +/* EDID version */ +#define VERSION_SECTION (VENDOR_SECTION + VENDOR_LENGTH) +#define V_VERSION 0 +#define V_REVISION (V_VERSION + 1) +#define VERSION_LENGTH (V_REVISION + 1) + +/* display information */ +#define DISPLAY_SECTION (VERSION_SECTION + VERSION_LENGTH) +#define D_INPUT 0 +#define D_HSIZE (D_INPUT + 1) +#define D_VSIZE (D_HSIZE + 1) +#define D_GAMMA (D_VSIZE + 1) +#define FEAT_S (D_GAMMA + 1) +#define D_RG_LOW (FEAT_S + 1) +#define D_BW_LOW (D_RG_LOW + 1) +#define D_REDX (D_BW_LOW + 1) +#define D_REDY (D_REDX + 1) +#define D_GREENX (D_REDY + 1) +#define D_GREENY (D_GREENX + 1) +#define D_BLUEX (D_GREENY + 1) +#define D_BLUEY (D_BLUEX + 1) +#define D_WHITEX (D_BLUEY + 1) +#define D_WHITEY (D_WHITEX + 1) +#define DISPLAY_LENGTH (D_WHITEY + 1) + +/* supported VESA and other standard timings */ +#define ESTABLISHED_TIMING_SECTION (DISPLAY_SECTION + DISPLAY_LENGTH) +#define E_T1 0 +#define E_T2 (E_T1 + 1) +#define E_TMANU (E_T2 + 1) +#define E_TIMING_LENGTH (E_TMANU + 1) + +/* non predefined standard timings supported by display */ +#define STD_TIMING_SECTION (ESTABLISHED_TIMING_SECTION + E_TIMING_LENGTH) +#define STD_TIMING_INFO_LEN 2 +#define STD_TIMING_INFO_NUM STD_TIMINGS +#define STD_TIMING_LENGTH (STD_TIMING_INFO_LEN * STD_TIMING_INFO_NUM) + +/* detailed timing info of non standard timings */ +#define DET_TIMING_SECTION (STD_TIMING_SECTION + STD_TIMING_LENGTH) +#define DET_TIMING_INFO_LEN 18 +#define MONITOR_DESC_LEN DET_TIMING_INFO_LEN +#define DET_TIMING_INFO_NUM DET_TIMINGS +#define DET_TIMING_LENGTH (DET_TIMING_INFO_LEN * DET_TIMING_INFO_NUM) + +/* number of EDID sections to follow */ +#define NO_EDID (DET_TIMING_SECTION + DET_TIMING_LENGTH) +/* one byte checksum */ +#define CHECKSUM (NO_EDID + 1) + +#if (CHECKSUM != (EDID1_LEN - 1)) +# error "EDID1 length != 128!" +#endif + + +#define SECTION(x,y) (Uchar *)(x + y) +#define GET_ARRAY(y) ((Uchar *)(c + y)) +#define GET(y) *(Uchar *)(c + y) + +/* extract information from vendor section */ +#define _PROD_ID(x) x[0] + (x[1] << 8); +#define PROD_ID _PROD_ID(GET_ARRAY(V_PROD_ID)) +#define _SERIAL_NO(x) x[0] + (x[1] << 8) + (x[2] << 16) + (x[3] << 24) +#define SERIAL_NO _SERIAL_NO(GET_ARRAY(V_SERIAL)) +#define _YEAR(x) (x & 0xFF) + 1990 +#define YEAR _YEAR(GET(V_YEAR)) +#define WEEK GET(V_WEEK) & 0xFF +#define _L1(x) ((x[0] & 0x7C) >> 2) + '@' +#define _L2(x) ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@' +#define _L3(x) (x[1] & 0x1F) + '@'; +#define L1 _L1(GET_ARRAY(V_MANUFACTURER)) +#define L2 _L2(GET_ARRAY(V_MANUFACTURER)) +#define L3 _L3(GET_ARRAY(V_MANUFACTURER)) + +/* extract information from version section */ +#define VERSION GET(V_VERSION) +#define REVISION GET(V_REVISION) + +/* extract information from display section */ +#define _INPUT_TYPE(x) ((x & 0x80) >> 7) +#define INPUT_TYPE _INPUT_TYPE(GET(D_INPUT)) +#define _INPUT_VOLTAGE(x) ((x & 0x60) >> 5) +#define INPUT_VOLTAGE _INPUT_VOLTAGE(GET(D_INPUT)) +#define _SETUP(x) ((x & 0x10) >> 4) +#define SETUP _SETUP(GET(D_INPUT)) +#define _SYNC(x) (x & 0x0F) +#define SYNC _SYNC(GET(D_INPUT)) +#define _DFP(x) (x & 0x01) +#define DFP _DFP(GET(D_INPUT)) +#define _BPC(x) ((x & 0x70) >> 4) +#define BPC _BPC(GET(D_INPUT)) +#define _DIGITAL_INTERFACE(x) (x & 0x0F) +#define DIGITAL_INTERFACE _DIGITAL_INTERFACE(GET(D_INPUT)) +#define _GAMMA(x) (x == 0xff ? 0.0 : ((x + 100.0)/100.0)) +#define GAMMA _GAMMA(GET(D_GAMMA)) +#define HSIZE_MAX GET(D_HSIZE) +#define VSIZE_MAX GET(D_VSIZE) +#define _DPMS(x) ((x & 0xE0) >> 5) +#define DPMS _DPMS(GET(FEAT_S)) +#define _DISPLAY_TYPE(x) ((x & 0x18) >> 3) +#define DISPLAY_TYPE _DISPLAY_TYPE(GET(FEAT_S)) +#define _MSC(x) (x & 0x7) +#define MSC _MSC(GET(FEAT_S)) + + +/* color characteristics */ +#define CC_L(x,y) ((x & (0x03 << y)) >> y) +#define CC_H(x) (x << 2) +#define I_CC(x,y,z) CC_H(y) | CC_L(x,z) +#define F_CC(x) ((x)/1024.0) +#define REDX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDX)),6)) +#define REDY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_REDY)),4)) +#define GREENX F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENX)),2)) +#define GREENY F_CC(I_CC((GET(D_RG_LOW)),(GET(D_GREENY)),0)) +#define BLUEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEX)),6)) +#define BLUEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_BLUEY)),4)) +#define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2)) +#define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0)) + +/* extract information from standard timing section */ +#define T1 GET(E_T1) +#define T2 GET(E_T2) +#define T_MANU GET(E_TMANU) + +/* extract information from estabished timing section */ +#define _VALID_TIMING(x) !(((x[0] == 0x01) && (x[1] == 0x01)) \ + || ((x[0] == 0x00) && (x[1] == 0x00)) \ + || ((x[0] == 0x20) && (x[1] == 0x20)) ) +#define VALID_TIMING _VALID_TIMING(c) +#define _HSIZE1(x) ((x[0] + 31) * 8) +#define HSIZE1 _HSIZE1(c) +#define RATIO(x) ((x[1] & 0xC0) >> 6) +#define RATIO1_1 0 +/* EDID Ver. 1.3 redefined this */ +#define RATIO16_10 RATIO1_1 +#define RATIO4_3 1 +#define RATIO5_4 2 +#define RATIO16_9 3 +#define _VSIZE1(x,y,r) switch(RATIO(x)){ \ + case RATIO1_1: y = ((v->version > 1 || v->revision > 2) \ + ? (_HSIZE1(x) * 10) / 16 : _HSIZE1(x)); break; \ + case RATIO4_3: y = _HSIZE1(x) * 3 / 4; break; \ + case RATIO5_4: y = _HSIZE1(x) * 4 / 5; break; \ + case RATIO16_9: y = _HSIZE1(x) * 9 / 16; break; \ + } +#define VSIZE1(x) _VSIZE1(c,x,v) +#define _REFRESH_R(x) (x[1] & 0x3F) + 60 +#define REFRESH_R _REFRESH_R(c) +#define _ID_LOW(x) x[0] +#define ID_LOW _ID_LOW(c) +#define _ID_HIGH(x) (x[1] << 8) +#define ID_HIGH _ID_HIGH(c) +#define STD_TIMING_ID (ID_LOW | ID_HIGH) +#define _NEXT_STD_TIMING(x) (x = (x + STD_TIMING_INFO_LEN)) +#define NEXT_STD_TIMING _NEXT_STD_TIMING(c) + + +/* EDID Ver. >= 1.2 */ +/** + * Returns true if the pointer is the start of a monitor descriptor block + * instead of a detailed timing descriptor. + * + * Checking the reserved pad fields for zeroes fails on some monitors with + * broken empty ASCII strings. Only the first two bytes are reliable. + */ +#define _IS_MONITOR_DESC(x) (x[0] == 0 && x[1] == 0) +#define IS_MONITOR_DESC _IS_MONITOR_DESC(c) +#define _PIXEL_CLOCK(x) (x[0] + (x[1] << 8)) * 10000 +#define PIXEL_CLOCK _PIXEL_CLOCK(c) +#define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4)) +#define H_ACTIVE _H_ACTIVE(c) +#define _H_BLANK(x) (x[3] + ((x[4] & 0x0F) << 8)) +#define H_BLANK _H_BLANK(c) +#define _V_ACTIVE(x) (x[5] + ((x[7] & 0xF0) << 4)) +#define V_ACTIVE _V_ACTIVE(c) +#define _V_BLANK(x) (x[6] + ((x[7] & 0x0F) << 8)) +#define V_BLANK _V_BLANK(c) +#define _H_SYNC_OFF(x) (x[8] + ((x[11] & 0xC0) << 2)) +#define H_SYNC_OFF _H_SYNC_OFF(c) +#define _H_SYNC_WIDTH(x) (x[9] + ((x[11] & 0x30) << 4)) +#define H_SYNC_WIDTH _H_SYNC_WIDTH(c) +#define _V_SYNC_OFF(x) ((x[10] >> 4) + ((x[11] & 0x0C) << 2)) +#define V_SYNC_OFF _V_SYNC_OFF(c) +#define _V_SYNC_WIDTH(x) ((x[10] & 0x0F) + ((x[11] & 0x03) << 4)) +#define V_SYNC_WIDTH _V_SYNC_WIDTH(c) +#define _H_SIZE(x) (x[12] + ((x[14] & 0xF0) << 4)) +#define H_SIZE _H_SIZE(c) +#define _V_SIZE(x) (x[13] + ((x[14] & 0x0F) << 8)) +#define V_SIZE _V_SIZE(c) +#define _H_BORDER(x) (x[15]) +#define H_BORDER _H_BORDER(c) +#define _V_BORDER(x) (x[16]) +#define V_BORDER _V_BORDER(c) +#define _INTERLACED(x) ((x[17] & 0x80) >> 7) +#define INTERLACED _INTERLACED(c) +#define _STEREO(x) ((x[17] & 0x60) >> 5) +#define STEREO _STEREO(c) +#define _STEREO1(x) (x[17] & 0x1) +#define STEREO1 _STEREO(c) +#define _SYNC_T(x) ((x[17] & 0x18) >> 3) +#define SYNC_T _SYNC_T(c) +#define _MISC(x) ((x[17] & 0x06) >> 1) +#define MISC _MISC(c) + +#define _MONITOR_DESC_TYPE(x) x[3] +#define MONITOR_DESC_TYPE _MONITOR_DESC_TYPE(c) +#define SERIAL_NUMBER 0xFF +#define ASCII_STR 0xFE +#define MONITOR_RANGES 0xFD +#define _MIN_V_OFFSET(x) ((!!(x[4] & 0x01)) * 255) +#define _MAX_V_OFFSET(x) ((!!(x[4] & 0x02)) * 255) +#define _MIN_H_OFFSET(x) ((!!(x[4] & 0x04)) * 255) +#define _MAX_H_OFFSET(x) ((!!(x[4] & 0x08)) * 255) +#define _MIN_V(x) x[5] +#define MIN_V (_MIN_V(c) + _MIN_V_OFFSET(c)) +#define _MAX_V(x) x[6] +#define MAX_V (_MAX_V(c) + _MAX_V_OFFSET(c)) +#define _MIN_H(x) x[7] +#define MIN_H (_MIN_H(c) + _MIN_H_OFFSET(c)) +#define _MAX_H(x) x[8] +#define MAX_H (_MAX_H(c) + _MAX_H_OFFSET(c)) +#define _MAX_CLOCK(x) x[9] +#define MAX_CLOCK _MAX_CLOCK(c) +#define _HAVE_2ND_GTF(x) (x[10] == 0x02) +#define HAVE_2ND_GTF _HAVE_2ND_GTF(c) +#define _F_2ND_GTF(x) (x[12] * 2) +#define F_2ND_GTF _F_2ND_GTF(c) +#define _C_2ND_GTF(x) (x[13] / 2) +#define C_2ND_GTF _C_2ND_GTF(c) +#define _M_2ND_GTF(x) (x[14] + (x[15] << 8)) +#define M_2ND_GTF _M_2ND_GTF(c) +#define _K_2ND_GTF(x) (x[16]) +#define K_2ND_GTF _K_2ND_GTF(c) +#define _J_2ND_GTF(x) (x[17] / 2) +#define J_2ND_GTF _J_2ND_GTF(c) +#define _HAVE_CVT(x) (x[10] == 0x04) +#define HAVE_CVT _HAVE_CVT(c) +#define _MAX_CLOCK_KHZ(x) (x[12] >> 2) +#define MAX_CLOCK_KHZ (MAX_CLOCK * 10000) - (_MAX_CLOCK_KHZ(c) * 250) +#define _MAXWIDTH(x) ((x[13] == 0 ? 0 : x[13] + ((x[12] & 0x03) << 8)) * 8) +#define MAXWIDTH _MAXWIDTH(c) +#define _SUPPORTED_ASPECT(x) x[14] +#define SUPPORTED_ASPECT _SUPPORTED_ASPECT(c) +#define SUPPORTED_ASPECT_4_3 0x80 +#define SUPPORTED_ASPECT_16_9 0x40 +#define SUPPORTED_ASPECT_16_10 0x20 +#define SUPPORTED_ASPECT_5_4 0x10 +#define SUPPORTED_ASPECT_15_9 0x08 +#define _PREFERRED_ASPECT(x) ((x[15] & 0xe0) >> 5) +#define PREFERRED_ASPECT _PREFERRED_ASPECT(c) +#define PREFERRED_ASPECT_4_3 0 +#define PREFERRED_ASPECT_16_9 1 +#define PREFERRED_ASPECT_16_10 2 +#define PREFERRED_ASPECT_5_4 3 +#define PREFERRED_ASPECT_15_9 4 +#define _SUPPORTED_BLANKING(x) ((x[15] & 0x18) >> 3) +#define SUPPORTED_BLANKING _SUPPORTED_BLANKING(c) +#define CVT_STANDARD 0x01 +#define CVT_REDUCED 0x02 +#define _SUPPORTED_SCALING(x) ((x[16] & 0xf0) >> 4) +#define SUPPORTED_SCALING _SUPPORTED_SCALING(c) +#define SCALING_HSHRINK 0x08 +#define SCALING_HSTRETCH 0x04 +#define SCALING_VSHRINK 0x02 +#define SCALING_VSTRETCH 0x01 +#define _PREFERRED_REFRESH(x) x[17] +#define PREFERRED_REFRESH _PREFERRED_REFRESH(c) + +#define MONITOR_NAME 0xFC +#define ADD_COLOR_POINT 0xFB +#define WHITEX F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEX)),2)) +#define WHITEY F_CC(I_CC((GET(D_BW_LOW)),(GET(D_WHITEY)),0)) +#define _WHITEX_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 1)),2)) +#define _WHITEY_ADD(x,y) F_CC(I_CC(((*(x + y))),(*(x + y + 2)),0)) +#define _WHITE_INDEX1(x) x[5] +#define WHITE_INDEX1 _WHITE_INDEX1(c) +#define _WHITE_INDEX2(x) x[10] +#define WHITE_INDEX2 _WHITE_INDEX2(c) +#define WHITEX1 _WHITEX_ADD(c,6) +#define WHITEY1 _WHITEY_ADD(c,6) +#define WHITEX2 _WHITEX_ADD(c,12) +#define WHITEY2 _WHITEY_ADD(c,12) +#define _WHITE_GAMMA1(x) _GAMMA(x[9]) +#define WHITE_GAMMA1 _WHITE_GAMMA1(c) +#define _WHITE_GAMMA2(x) _GAMMA(x[14]) +#define WHITE_GAMMA2 _WHITE_GAMMA2(c) +#define ADD_STD_TIMINGS 0xFA +#define COLOR_MANAGEMENT_DATA 0xF9 +#define CVT_3BYTE_DATA 0xF8 +#define ADD_EST_TIMINGS 0xF7 +#define ADD_DUMMY 0x10 + +#define _NEXT_DT_MD_SECTION(x) (x = (x + DET_TIMING_INFO_LEN)) +#define NEXT_DT_MD_SECTION _NEXT_DT_MD_SECTION(c) + +#endif /* _PARSE_EDID_ */ + +/* input type */ +#define DIGITAL(x) x + +/* DFP */ +#define DFP1(x) x + +/* input voltage level */ +#define V070 0 /* 0.700V/0.300V */ +#define V071 1 /* 0.714V/0.286V */ +#define V100 2 /* 1.000V/0.400V */ +#define V007 3 /* 0.700V/0.000V */ + +/* Signal level setup */ +#define SIG_SETUP(x) (x) + +/* sync characteristics */ +#define SEP_SYNC(x) (x & 0x08) +#define COMP_SYNC(x) (x & 0x04) +#define SYNC_O_GREEN(x) (x & 0x02) +#define SYNC_SERR(x) (x & 0x01) + +/* DPMS features */ +#define DPMS_STANDBY(x) (x & 0x04) +#define DPMS_SUSPEND(x) (x & 0x02) +#define DPMS_OFF(x) (x & 0x01) + +/* display type, analog */ +#define DISP_MONO 0 +#define DISP_RGB 1 +#define DISP_MULTCOLOR 2 + +/* display color encodings, digital */ +#define DISP_YCRCB444 0x01 +#define DISP_YCRCB422 0x02 + +/* Msc stuff EDID Ver > 1.1 */ +#define STD_COLOR_SPACE(x) (x & 0x4) +#define PREFERRED_TIMING_MODE(x) (x & 0x2) +#define GFT_SUPPORTED(x) (x & 0x1) +#define GTF_SUPPORTED(x) (x & 0x1) +#define CVT_SUPPORTED(x) (x & 0x1) + +/* detailed timing misc */ +#define IS_INTERLACED(x) (x) +#define IS_STEREO(x) (x) +#define IS_RIGHT_STEREO(x) (x & 0x01) +#define IS_LEFT_STEREO(x) (x & 0x02) +#define IS_4WAY_STEREO(x) (x & 0x03) +#define IS_RIGHT_ON_SYNC(x) IS_RIGHT_STEREO(x) +#define IS_LEFT_ON_SYNC(x) IS_LEFT_STEREO(x) + + +typedef unsigned int Uint; +typedef unsigned char Uchar; + +struct vendor { + char name[4]; + int prod_id; + Uint serial; + int week; + int year; +}; + +struct edid_version { + int version; + int revision; +}; + +struct disp_features { + unsigned int input_type:1; + unsigned int input_voltage:2; + unsigned int input_setup:1; + unsigned int input_sync:5; + unsigned int input_dfp:1; + unsigned int input_bpc:3; + unsigned int input_interface:4; + /* 15 bit hole */ + int hsize; + int vsize; + float gamma; + unsigned int dpms:3; + unsigned int display_type:2; + unsigned int msc:3; + float redx; + float redy; + float greenx; + float greeny; + float bluex; + float bluey; + float whitex; + float whitey; +}; + +struct established_timings { + Uchar t1; + Uchar t2; + Uchar t_manu; +}; + +struct std_timings { + int hsize; + int vsize; + int refresh; + CARD16 id; +}; + +struct detailed_timings { + int clock; + int h_active; + int h_blanking; + int v_active; + int v_blanking; + int h_sync_off; + int h_sync_width; + int v_sync_off; + int v_sync_width; + int h_size; + int v_size; + int h_border; + int v_border; + unsigned int interlaced:1; + unsigned int stereo:2; + unsigned int sync:2; + unsigned int misc:2; + unsigned int stereo_1:1; +}; + +#define DT 0 +#define DS_SERIAL 0xFF +#define DS_ASCII_STR 0xFE +#define DS_NAME 0xFC +#define DS_RANGES 0xFD +#define DS_WHITE_P 0xFB +#define DS_STD_TIMINGS 0xFA +#define DS_CMD 0xF9 +#define DS_CVT 0xF8 +#define DS_EST_III 0xF7 +#define DS_DUMMY 0x10 +#define DS_UNKOWN 0x100 /* type is an int */ +#define DS_VENDOR 0x101 +#define DS_VENDOR_MAX 0x110 + +struct monitor_ranges { + int min_v; + int max_v; + int min_h; + int max_h; + int max_clock; /* in mhz */ + int gtf_2nd_f; + int gtf_2nd_c; + int gtf_2nd_m; + int gtf_2nd_k; + int gtf_2nd_j; + int max_clock_khz; + int maxwidth; /* in pixels */ + char supported_aspect; + char preferred_aspect; + char supported_blanking; + char supported_scaling; + int preferred_refresh; /* in hz */ +}; + +struct whitePoints{ + int index; + float white_x; + float white_y; + float white_gamma; +}; + +struct cvt_timings { + int width; + int height; + int rate; + int rates; +}; + +/* + * Be careful when adding new sections; this structure can't grow, it's + * embedded in the middle of xf86Monitor which is ABI. Sizes below are + * in bytes, for ILP32 systems. If all else fails just copy the section + * literally like serial and friends. + */ +struct detailed_monitor_section { + int type; + union { + struct detailed_timings d_timings; /* 56 */ + Uchar serial[13]; + Uchar ascii_data[13]; + Uchar name[13]; + struct monitor_ranges ranges; /* 56 */ + struct std_timings std_t[5]; /* 80 */ + struct whitePoints wp[2]; /* 32 */ + /* color management data */ + struct cvt_timings cvt[4]; /* 64 */ + /* established timings III */ + } section; /* max: 80 */ +}; + +typedef struct { + int scrnIndex; + struct vendor vendor; + struct edid_version ver; + struct disp_features features; + struct established_timings timings1; + struct std_timings timings2[8]; + struct detailed_monitor_section det_mon[4]; + void *vdif; /* unused */ + int no_sections; + Uchar *rawData; +} xf86Monitor, *xf86MonPtr; + +extern xf86MonPtr ConfiguredMonitor; + +#endif /* _EDID_H_ */ diff --git a/xorg-server/hw/xfree86/ddc/interpret_edid.c b/xorg-server/hw/xfree86/ddc/interpret_edid.c new file mode 100644 index 000000000..879308520 --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/interpret_edid.c @@ -0,0 +1,447 @@ +/* + * Copyright 1998 by Egbert Eich + * Copyright 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software") + * to deal in the software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * them Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * interpret_edid.c: interpret a primary EDID block + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#define _PARSE_EDID_ +#include "xf86DDC.h" +#include + +static void get_vendor_section(Uchar*, struct vendor *); +static void get_version_section(Uchar*, struct edid_version *); +static void get_display_section(Uchar*, struct disp_features *, + struct edid_version *); +static void get_established_timing_section(Uchar*, struct established_timings *); +static void get_std_timing_section(Uchar*, struct std_timings *, + struct edid_version *); +static void get_dt_md_section(Uchar *, struct edid_version *, + struct detailed_monitor_section *det_mon); +static void copy_string(Uchar *, Uchar *); +static void get_dst_timing_section(Uchar *, struct std_timings *, + struct edid_version *); +static void get_monitor_ranges(Uchar *, struct monitor_ranges *); +static void get_whitepoint_section(Uchar *, struct whitePoints *); +static void get_detailed_timing_section(Uchar*, struct detailed_timings *); +static Bool validate_version(int scrnIndex, struct edid_version *); + +static void +handle_edid_quirks(xf86MonPtr m) +{ + int i, j; + struct detailed_timings *preferred_timing; + struct monitor_ranges *ranges; + + /* + * max_clock is only encoded in EDID in tens of MHz, so occasionally we + * find a monitor claiming a max of 160 with a mode requiring 162, or + * similar. Strictly we should refuse to round up too far, but let's + * see how well this works. + */ + for (i = 0; i < 4; i++) { + if (m->det_mon[i].type == DS_RANGES) { + ranges = &m->det_mon[i].section.ranges; + for (j = 0; j < 4; j++) { + if (m->det_mon[j].type == DT) { + preferred_timing = &m->det_mon[j].section.d_timings; + if (!ranges->max_clock) continue; /* zero is legal */ + if (ranges->max_clock * 1000000 < preferred_timing->clock) { + xf86Msg(X_WARNING, + "EDID preferred timing clock %.2fMHz exceeds " + "claimed max %dMHz, fixing\n", + preferred_timing->clock / 1.0e6, + ranges->max_clock); + ranges->max_clock = + (preferred_timing->clock+999999)/1000000; + return; + } + } + } + } + } + + /* + * some monitors encode the aspect ratio instead of the physical size. + * try to find the largest detailed timing that matches that aspect + * ratio and use that to fill in the feature section. + */ + if ((m->features.hsize == 16 && m->features.vsize == 9) || + (m->features.hsize == 16 && m->features.vsize == 10) || + (m->features.hsize == 4 && m->features.vsize == 3) || + (m->features.hsize == 5 && m->features.vsize == 4)) { + int real_hsize = 0, real_vsize = 0; + float target_aspect, timing_aspect; + + target_aspect = (float)m->features.hsize / (float)m->features.vsize; + for (i = 0; i < 4; i++) { + if (m->det_mon[i].type == DT) { + struct detailed_timings *timing; + timing = &m->det_mon[i].section.d_timings; + + if (!timing->v_size) + continue; + + timing_aspect = (float)timing->h_size / (float)timing->v_size; + if (fabs(1 - (timing_aspect / target_aspect)) < 0.05) { + real_hsize = max(real_hsize, timing->h_size); + real_vsize = max(real_vsize, timing->v_size); + } + } + } + + if (!real_hsize || !real_vsize) { + m->features.hsize = m->features.vsize = 0; + } else if ((m->features.hsize * 10 == real_hsize) && + (m->features.vsize * 10 == real_vsize)) { + /* exact match is just unlikely, should do a better check though */ + m->features.hsize = m->features.vsize = 0; + } else { + /* convert mm to cm */ + m->features.hsize = (real_hsize + 5) / 10; + m->features.vsize = (real_vsize + 5) / 10; + } + + xf86Msg(X_INFO, "Quirked EDID physical size to %dx%d cm\n", + m->features.hsize, m->features.vsize); + } +} + +xf86MonPtr +xf86InterpretEDID(int scrnIndex, Uchar *block) +{ + xf86MonPtr m; + + if (!block) return NULL; + if (! (m = xnfcalloc(sizeof(xf86Monitor),1))) return NULL; + m->scrnIndex = scrnIndex; + m->rawData = block; + + get_vendor_section(SECTION(VENDOR_SECTION,block),&m->vendor); + get_version_section(SECTION(VERSION_SECTION,block),&m->ver); + if (!validate_version(scrnIndex, &m->ver)) goto error; + get_display_section(SECTION(DISPLAY_SECTION,block),&m->features, + &m->ver); + get_established_timing_section(SECTION(ESTABLISHED_TIMING_SECTION,block), + &m->timings1); + get_std_timing_section(SECTION(STD_TIMING_SECTION,block),m->timings2, + &m->ver); + get_dt_md_section(SECTION(DET_TIMING_SECTION,block),&m->ver, m->det_mon); + m->no_sections = (int)*(char *)SECTION(NO_EDID,block); + + handle_edid_quirks(m); + + return (m); + + error: + xfree(m); + return NULL; +} + +static void +get_vendor_section(Uchar *c, struct vendor *r) +{ + r->name[0] = L1; + r->name[1] = L2; + r->name[2] = L3; + r->name[3] = '\0'; + + r->prod_id = PROD_ID; + r->serial = SERIAL_NO; + r->week = WEEK; + r->year = YEAR; +} + +static void +get_version_section(Uchar *c, struct edid_version *r) +{ + r->version = VERSION; + r->revision = REVISION; +} + +static void +get_display_section(Uchar *c, struct disp_features *r, + struct edid_version *v) +{ + r->input_type = INPUT_TYPE; + if (!DIGITAL(r->input_type)) { + r->input_voltage = INPUT_VOLTAGE; + r->input_setup = SETUP; + r->input_sync = SYNC; + } else if (v->revision == 2 || v->revision == 3) { + r->input_dfp = DFP; + } else if (v->revision >= 4) { + r->input_bpc = BPC; + r->input_interface = DIGITAL_INTERFACE; + } + r->hsize = HSIZE_MAX; + r->vsize = VSIZE_MAX; + r->gamma = GAMMA; + r->dpms = DPMS; + r->display_type = DISPLAY_TYPE; + r->msc = MSC; + r->redx = REDX; + r->redy = REDY; + r->greenx = GREENX; + r->greeny = GREENY; + r->bluex = BLUEX; + r->bluey = BLUEY; + r->whitex = WHITEX; + r->whitey = WHITEY; +} + +static void +get_established_timing_section(Uchar *c, struct established_timings *r) +{ + r->t1 = T1; + r->t2 = T2; + r->t_manu = T_MANU; +} + +static void +get_cvt_timing_section(Uchar *c, struct cvt_timings *r) +{ + int i; + + for (i = 0; i < 4; i++) { + if (c[0] && c[1] && c[2]) { + r[i].height = (c[0] + ((c[1] & 0xF0) << 8) + 1) * 2; + switch (c[1] & 0xc0) { + case 0x00: r[i].width = r[i].height * 4 / 3; break; + case 0x40: r[i].width = r[i].height * 16 / 9; break; + case 0x80: r[i].width = r[i].height * 16 / 10; break; + case 0xc0: r[i].width = r[i].height * 15 / 9; break; + } + switch (c[2] & 0x60) { + case 0x00: r[i].rate = 50; break; + case 0x20: r[i].rate = 60; break; + case 0x40: r[i].rate = 75; break; + case 0x60: r[i].rate = 85; break; + } + r[i].rates = c[2] & 0x1f; + } else { + return; + } + c += 3; + } +} + +static void +get_std_timing_section(Uchar *c, struct std_timings *r, + struct edid_version *v) +{ + int i; + + for (i=0;iversion == 1 && ver->revision >= 1 && IS_MONITOR_DESC) { + + switch (MONITOR_DESC_TYPE) { + case SERIAL_NUMBER: + det_mon[i].type = DS_SERIAL; + copy_string(c,det_mon[i].section.serial); + break; + case ASCII_STR: + det_mon[i].type = DS_ASCII_STR; + copy_string(c,det_mon[i].section.ascii_data); + break; + case MONITOR_RANGES: + det_mon[i].type = DS_RANGES; + get_monitor_ranges(c,&det_mon[i].section.ranges); + break; + case MONITOR_NAME: + det_mon[i].type = DS_NAME; + copy_string(c,det_mon[i].section.name); + break; + case ADD_COLOR_POINT: + det_mon[i].type = DS_WHITE_P; + get_whitepoint_section(c,det_mon[i].section.wp); + break; + case ADD_STD_TIMINGS: + det_mon[i].type = DS_STD_TIMINGS; + get_dst_timing_section(c,det_mon[i].section.std_t, ver); + break; + case COLOR_MANAGEMENT_DATA: + det_mon[i].type = DS_CMD; + break; + case CVT_3BYTE_DATA: + det_mon[i].type = DS_CVT; + get_cvt_timing_section(c, det_mon[i].section.cvt); + break; + case ADD_EST_TIMINGS: + det_mon[i].type = DS_EST_III; + break; + case ADD_DUMMY: + det_mon[i].type = DS_DUMMY; + break; + default: + det_mon[i].type = DS_UNKOWN; + break; + } + if (c[3] <= 0x0F) { + det_mon[i].type = DS_VENDOR + c[3]; + } + } else { + det_mon[i].type = DT; + get_detailed_timing_section(c,&det_mon[i].section.d_timings); + } + NEXT_DT_MD_SECTION; + } +} + +static void +copy_string(Uchar *c, Uchar *s) +{ + int i; + c = c + 5; + for (i = 0; (i < 13 && *c != 0x0A); i++) + *(s++) = *(c++); + *s = 0; + while (i-- && (*--s == 0x20)) *s = 0; +} + +static void +get_dst_timing_section(Uchar *c, struct std_timings *t, + struct edid_version *v) +{ + int j; + c = c + 5; + for (j = 0; j < 5; j++) { + t[j].hsize = HSIZE1; + VSIZE1(t[j].vsize); + t[j].refresh = REFRESH_R; + t[j].id = STD_TIMING_ID; + NEXT_STD_TIMING; + } +} + +static void +get_monitor_ranges(Uchar *c, struct monitor_ranges *r) +{ + r->min_v = MIN_V; + r->max_v = MAX_V; + r->min_h = MIN_H; + r->max_h = MAX_H; + r->max_clock = 0; + if(MAX_CLOCK != 0xff) /* is specified? */ + r->max_clock = MAX_CLOCK * 10; + if (HAVE_2ND_GTF) { + r->gtf_2nd_f = F_2ND_GTF; + r->gtf_2nd_c = C_2ND_GTF; + r->gtf_2nd_m = M_2ND_GTF; + r->gtf_2nd_k = K_2ND_GTF; + r->gtf_2nd_j = J_2ND_GTF; + } else { + r->gtf_2nd_f = 0; + } + if (HAVE_CVT) { + r->max_clock_khz = MAX_CLOCK_KHZ; + r->max_clock = r->max_clock_khz / 1000; + r->maxwidth = MAXWIDTH; + r->supported_aspect = SUPPORTED_ASPECT; + r->preferred_aspect = PREFERRED_ASPECT; + r->supported_blanking = SUPPORTED_BLANKING; + r->supported_scaling = SUPPORTED_SCALING; + r->preferred_refresh = PREFERRED_REFRESH; + } else { + r->max_clock_khz = 0; + } +} + +static void +get_whitepoint_section(Uchar *c, struct whitePoints *wp) +{ + wp[1].white_x = WHITEX1; + wp[1].white_y = WHITEY1; + wp[2].white_x = WHITEX2; + wp[2].white_y = WHITEY2; + wp[1].index = WHITE_INDEX1; + wp[2].index = WHITE_INDEX2; + wp[1].white_gamma = WHITE_GAMMA1; + wp[2].white_gamma = WHITE_GAMMA2; +} + +static void +get_detailed_timing_section(Uchar *c, struct detailed_timings *r) +{ + r->clock = PIXEL_CLOCK; + r->h_active = H_ACTIVE; + r->h_blanking = H_BLANK; + r->v_active = V_ACTIVE; + r->v_blanking = V_BLANK; + r->h_sync_off = H_SYNC_OFF; + r->h_sync_width = H_SYNC_WIDTH; + r->v_sync_off = V_SYNC_OFF; + r->v_sync_width = V_SYNC_WIDTH; + r->h_size = H_SIZE; + r->v_size = V_SIZE; + r->h_border = H_BORDER; + r->v_border = V_BORDER; + r->interlaced = INTERLACED; + r->stereo = STEREO; + r->stereo_1 = STEREO1; + r->sync = SYNC_T; + r->misc = MISC; +} + +#define MAX_EDID_MINOR 4 + +static Bool +validate_version(int scrnIndex, struct edid_version *r) +{ + if (r->version != 1) { + xf86DrvMsg(scrnIndex, X_ERROR, "Unknown EDID version %d\n", + r->version); + return FALSE; + } + + if (r->revision > MAX_EDID_MINOR) + xf86DrvMsg(scrnIndex, X_WARNING, + "Assuming version 1.%d is compatible with 1.%d\n", + r->revision, MAX_EDID_MINOR); + + return TRUE; +} diff --git a/xorg-server/hw/xfree86/ddc/print_edid.c b/xorg-server/hw/xfree86/ddc/print_edid.c new file mode 100644 index 000000000..df11bfb3d --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/print_edid.c @@ -0,0 +1,489 @@ +/* + * Copyright 1998 by Egbert Eich + * Copyright 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software") + * to deal in the software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * them Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * print_edid.c: print out all information retrieved from display device + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +/* XXX kinda gross */ +#define _PARSE_EDID_ + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86DDC.h" +#include "edid.h" + +#define EDID_WIDTH 16 + +static void +print_vendor(int scrnIndex, struct vendor *c) +{ + xf86DrvMsg(scrnIndex, X_INFO, "Manufacturer: %s Model: %x Serial#: %u\n", + (char *)&c->name, c->prod_id, c->serial); + xf86DrvMsg(scrnIndex, X_INFO, "Year: %u Week: %u\n", c->year, c->week); +} + +static void +print_version(int scrnIndex, struct edid_version *c) +{ + xf86DrvMsg(scrnIndex,X_INFO,"EDID Version: %u.%u\n",c->version, + c->revision); +} + +static const char *digital_interfaces[] = { + "undefined", + "DVI", + "HDMI-a", + "HDMI-b", + "MDDI", + "DisplayPort", + "unknown" +}; + +static void +print_input_features(int scrnIndex, struct disp_features *c, + struct edid_version *v) +{ + if (DIGITAL(c->input_type)) { + xf86DrvMsg(scrnIndex, X_INFO, "Digital Display Input\n"); + if (v->revision == 2 || v->revision == 3) { + if (DFP1(c->input_dfp)) + xf86DrvMsg(scrnIndex, X_INFO, "DFP 1.x compatible TMDS\n"); + } else if (v->revision >= 4) { + int interface = c->input_interface; + int bpc = c->input_bpc; + if (interface > 6) + interface = 6; /* unknown */ + if (bpc == 0 || bpc == 7) + xf86DrvMsg(scrnIndex, X_INFO, "Undefined color depth\n"); + else + xf86DrvMsg(scrnIndex, X_INFO, "%d bits per channel\n", + bpc * 2 + 4); + xf86DrvMsg(scrnIndex, X_INFO, "Digital interface is %s\n", + digital_interfaces[interface]); + } + } else { + xf86DrvMsg(scrnIndex,X_INFO,"Analog Display Input, "); + xf86ErrorF("Input Voltage Level: "); + switch (c->input_voltage){ + case V070: + xf86ErrorF("0.700/0.300 V\n"); + break; + case V071: + xf86ErrorF("0.714/0.286 V\n"); + break; + case V100: + xf86ErrorF("1.000/0.400 V\n"); + break; + case V007: + xf86ErrorF("0.700/0.700 V\n"); + break; + default: + xf86ErrorF("undefined\n"); + } + if (SIG_SETUP(c->input_setup)) + xf86DrvMsg(scrnIndex,X_INFO,"Signal levels configurable\n"); + xf86DrvMsg(scrnIndex,X_INFO,"Sync:"); + if (SEP_SYNC(c->input_sync)) + xf86ErrorF(" Separate"); + if (COMP_SYNC(c->input_sync)) + xf86ErrorF(" Composite"); + if (SYNC_O_GREEN(c->input_sync)) + xf86ErrorF(" SyncOnGreen"); + if (SYNC_SERR(c->input_sync)) + xf86ErrorF("Serration on. " + "V.Sync Pulse req. if CompSync or SyncOnGreen\n"); + else xf86ErrorF("\n"); + } +} + +static void +print_dpms_features(int scrnIndex, struct disp_features *c, + struct edid_version *v) +{ + if (c->dpms) { + xf86DrvMsg(scrnIndex,X_INFO,"DPMS capabilities:"); + if (DPMS_STANDBY(c->dpms)) xf86ErrorF(" StandBy"); + if (DPMS_SUSPEND(c->dpms)) xf86ErrorF(" Suspend"); + if (DPMS_OFF(c->dpms)) xf86ErrorF(" Off"); + } else + xf86DrvMsg(scrnIndex,X_INFO,"No DPMS capabilities specified"); + if (!c->input_type) { /* analog */ + switch (c->display_type){ + case DISP_MONO: + xf86ErrorF("; Monochorome/GrayScale Display\n"); + break; + case DISP_RGB: + xf86ErrorF("; RGB/Color Display\n"); + break; + case DISP_MULTCOLOR: + xf86ErrorF("; Non RGB Multicolor Display\n"); + break; + default: + xf86ErrorF("\n"); + break; + } + } else { + int enc = c->display_type; + xf86ErrorF("\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Supported color encodings: " + "RGB 4:4:4 %s%s\n", + enc & DISP_YCRCB444 ? "YCrCb 4:4:4 " : "", + enc & DISP_YCRCB422 ? "YCrCb 4:2:2" : ""); + } + + if (STD_COLOR_SPACE(c->msc)) + xf86DrvMsg(scrnIndex,X_INFO, + "Default color space is primary color space\n"); + + if (PREFERRED_TIMING_MODE(c->msc) || v->revision >= 4) { + xf86DrvMsg(scrnIndex, X_INFO, + "First detailed timing is preferred mode\n"); + if (v->revision >= 4) + xf86DrvMsg(scrnIndex, X_INFO, + "Preferred mode is native pixel format and refresh rate\n"); + } else if (v->revision == 3) { + xf86DrvMsg(scrnIndex,X_INFO, + "First detailed timing not preferred " + "mode in violation of standard!"); + } + + if (v->revision >= 4) { + if (GFT_SUPPORTED(c->msc)) { + xf86DrvMsg(scrnIndex, X_INFO, "Display is continuous-frequency\n"); + } + } else { + if (GFT_SUPPORTED(c->msc)) + xf86DrvMsg(scrnIndex, X_INFO, "GTF timings supported\n"); + } +} + +static void +print_whitepoint(int scrnIndex, struct disp_features *disp) +{ + xf86DrvMsg(scrnIndex,X_INFO,"redX: %.3f redY: %.3f ", + disp->redx,disp->redy); + xf86ErrorF("greenX: %.3f greenY: %.3f\n", + disp->greenx,disp->greeny); + xf86DrvMsg(scrnIndex,X_INFO,"blueX: %.3f blueY: %.3f ", + disp->bluex,disp->bluey); + xf86ErrorF("whiteX: %.3f whiteY: %.3f\n", + disp->whitex,disp->whitey); +} + +static void +print_display(int scrnIndex, struct disp_features *disp, + struct edid_version *v) +{ + print_input_features(scrnIndex, disp, v); + if (disp->hsize && disp->vsize) { + xf86DrvMsg(scrnIndex, X_INFO, "Max Image Size [cm]: "); + xf86ErrorF("horiz.: %i ", disp->hsize); + xf86ErrorF("vert.: %i\n", disp->vsize); + } else if (v->revision >= 4 && (disp->hsize || disp->vsize)) { + if (disp->hsize) + xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (landscape)\n", + (disp->hsize + 99) / 100.0); + if (disp->vsize) + xf86DrvMsg(scrnIndex, X_INFO, "Aspect ratio: %.2f (portrait)\n", + 100.0 / (float)(disp->vsize + 99)); + + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Indeterminate output size\n"); + } + + if (!disp->gamma && v->revision >= 1.4) + xf86DrvMsg(scrnIndex, X_INFO, "Gamma defined in extension block\n"); + else + xf86DrvMsg(scrnIndex, X_INFO, "Gamma: %.2f\n", disp->gamma); + + print_dpms_features(scrnIndex, disp, v); + print_whitepoint(scrnIndex, disp); +} + +static void +print_established_timings(int scrnIndex, struct established_timings *t) +{ + unsigned char c; + + if (t->t1 || t->t2 || t->t_manu) + xf86DrvMsg(scrnIndex,X_INFO,"Supported VESA Video Modes:\n"); + c=t->t1; + if (c&0x80) xf86DrvMsg(scrnIndex,X_INFO,"720x400@70Hz\n"); + if (c&0x40) xf86DrvMsg(scrnIndex,X_INFO,"720x400@88Hz\n"); + if (c&0x20) xf86DrvMsg(scrnIndex,X_INFO,"640x480@60Hz\n"); + if (c&0x10) xf86DrvMsg(scrnIndex,X_INFO,"640x480@67Hz\n"); + if (c&0x08) xf86DrvMsg(scrnIndex,X_INFO,"640x480@72Hz\n"); + if (c&0x04) xf86DrvMsg(scrnIndex,X_INFO,"640x480@75Hz\n"); + if (c&0x02) xf86DrvMsg(scrnIndex,X_INFO,"800x600@56Hz\n"); + if (c&0x01) xf86DrvMsg(scrnIndex,X_INFO,"800x600@60Hz\n"); + c=t->t2; + if (c&0x80) xf86DrvMsg(scrnIndex,X_INFO,"800x600@72Hz\n"); + if (c&0x40) xf86DrvMsg(scrnIndex,X_INFO,"800x600@75Hz\n"); + if (c&0x20) xf86DrvMsg(scrnIndex,X_INFO,"832x624@75Hz\n"); + if (c&0x10) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@87Hz (interlaced)\n"); + if (c&0x08) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@60Hz\n"); + if (c&0x04) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@70Hz\n"); + if (c&0x02) xf86DrvMsg(scrnIndex,X_INFO,"1024x768@75Hz\n"); + if (c&0x01) xf86DrvMsg(scrnIndex,X_INFO,"1280x1024@75Hz\n"); + c=t->t_manu; + if (c&0x80) xf86DrvMsg(scrnIndex,X_INFO,"1152x870@75Hz\n"); + xf86DrvMsg(scrnIndex,X_INFO,"Manufacturer's mask: %X\n",c&0x7F); +} + +static void +print_std_timings(int scrnIndex, struct std_timings *t) +{ + int i; + char done = 0; + for (i=0;i 256) { /* sanity check */ + if (!done) { + xf86DrvMsg(scrnIndex,X_INFO,"Supported Future Video Modes:\n"); + done = 1; + } + xf86DrvMsg(scrnIndex,X_INFO, + "#%i: hsize: %i vsize %i refresh: %i vid: %i\n", + i, t[i].hsize, t[i].vsize, t[i].refresh, t[i].id); + } + } +} + +static void +print_cvt_timings(int si, struct cvt_timings *t) +{ + int i; + + for (i = 0; i < 4; i++) { + if (t[i].height) { + xf86DrvMsg(si, X_INFO, "%dx%d @ %s%s%s%s%s Hz\n", + t[i].width, t[i].height, + t[i].rates & 0x10 ? "50," : "", + t[i].rates & 0x08 ? "60," : "", + t[i].rates & 0x04 ? "75," : "", + t[i].rates & 0x02 ? "85," : "", + t[i].rates & 0x01 ? "60RB" : ""); + } else break; + } +} + +static void +print_detailed_timings(int scrnIndex, struct detailed_timings *t) +{ + + if (t->clock > 15000000) { /* sanity check */ + xf86DrvMsg(scrnIndex,X_INFO,"Supported additional Video Mode:\n"); + xf86DrvMsg(scrnIndex,X_INFO,"clock: %.1f MHz ",t->clock/1000000.0); + xf86ErrorF("Image Size: %i x %i mm\n",t->h_size,t->v_size); + xf86DrvMsg(scrnIndex,X_INFO, + "h_active: %i h_sync: %i h_sync_end %i h_blank_end %i ", + t->h_active, t->h_sync_off + t->h_active, + t->h_sync_off + t->h_sync_width + t->h_active, + t->h_active + t->h_blanking); + xf86ErrorF("h_border: %i\n",t->h_border); + xf86DrvMsg(scrnIndex,X_INFO, + "v_active: %i v_sync: %i v_sync_end %i v_blanking: %i ", + t->v_active, t->v_sync_off + t->v_active, + t->v_sync_off + t->v_sync_width + t->v_active, + t->v_active + t->v_blanking); + xf86ErrorF("v_border: %i\n",t->v_border); + if (IS_STEREO(t->stereo)) { + xf86DrvMsg(scrnIndex,X_INFO,"Stereo: "); + if (IS_RIGHT_STEREO(t->stereo)) { + if (!t->stereo_1) + xf86ErrorF("right channel on sync\n"); + else + xf86ErrorF("left channel on sync\n"); + } else if (IS_LEFT_STEREO(t->stereo)) { + if (!t->stereo_1) + xf86ErrorF("right channel on even line\n"); + else + xf86ErrorF("left channel on evel line\n"); + } + if (IS_4WAY_STEREO(t->stereo)) { + if (!t->stereo_1) + xf86ErrorF("4-way interleaved\n"); + else + xf86ErrorF("side-by-side interleaved"); + } + } + } +} + +static void +print_detailed_monitor_section(int scrnIndex, + struct detailed_monitor_section *m) +{ + int i,j; + + for (i=0;imin_v, r->max_v, r->min_h, r->max_h); + if (r->max_clock_khz != 0) { + xf86ErrorF(" PixClock max %i kHz\n", r->max_clock_khz); + if (r->maxwidth) + xf86DrvMsg(scrnIndex, X_INFO, "Maximum pixel width: %d\n", + r->maxwidth); + xf86DrvMsg(scrnIndex, X_INFO, "Supported aspect ratios:"); + if (r->supported_aspect & SUPPORTED_ASPECT_4_3) + xf86ErrorF(" 4:3%s", + r->preferred_aspect == PREFERRED_ASPECT_4_3?"*":""); + if (r->supported_aspect & SUPPORTED_ASPECT_16_9) + xf86ErrorF(" 16:9%s", + r->preferred_aspect == PREFERRED_ASPECT_16_9?"*":""); + if (r->supported_aspect & SUPPORTED_ASPECT_16_10) + xf86ErrorF(" 16:10%s", + r->preferred_aspect == PREFERRED_ASPECT_16_10?"*":""); + if (r->supported_aspect & SUPPORTED_ASPECT_5_4) + xf86ErrorF(" 5:4%s", + r->preferred_aspect == PREFERRED_ASPECT_5_4?"*":""); + if (r->supported_aspect & SUPPORTED_ASPECT_15_9) + xf86ErrorF(" 15:9%s", + r->preferred_aspect == PREFERRED_ASPECT_15_9?"*":""); + xf86ErrorF("\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Supported blankings:"); + if (r->supported_blanking & CVT_STANDARD) + xf86ErrorF(" standard"); + if (r->supported_blanking & CVT_REDUCED) + xf86ErrorF(" reduced"); + xf86ErrorF("\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Supported scalings:"); + if (r->supported_scaling & SCALING_HSHRINK) + xf86ErrorF(" hshrink"); + if (r->supported_scaling & SCALING_HSTRETCH) + xf86ErrorF(" hstretch"); + if (r->supported_scaling & SCALING_VSHRINK) + xf86ErrorF(" vshrink"); + if (r->supported_scaling & SCALING_VSTRETCH) + xf86ErrorF(" vstretch"); + xf86ErrorF("\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Preferred refresh rate: %d\n", + r->preferred_refresh); + } else if (r->max_clock != 0) { + xf86ErrorF(" PixClock max %i MHz\n", r->max_clock); + } else { + xf86ErrorF("\n"); + } + if (r->gtf_2nd_f > 0) + xf86DrvMsg(scrnIndex,X_INFO," 2nd GTF parameters: f: %i kHz " + "c: %i m: %i k %i j %i\n", r->gtf_2nd_f, + r->gtf_2nd_c, r->gtf_2nd_m, r->gtf_2nd_k, + r->gtf_2nd_j); + break; + } + case DS_STD_TIMINGS: + for (j = 0; j<5; j++) + xf86DrvMsg(scrnIndex,X_INFO,"#%i: hsize: %i vsize %i refresh: %i " + "vid: %i\n",i,m[i].section.std_t[i].hsize, + m[i].section.std_t[j].vsize,m[i].section.std_t[j].refresh, + m[i].section.std_t[j].id); + break; + case DS_WHITE_P: + for (j = 0; j<2; j++) + if (m[i].section.wp[j].index != 0) + xf86DrvMsg(scrnIndex,X_INFO, + "White point %i: whiteX: %f, whiteY: %f; gamma: %f\n", + m[i].section.wp[j].index,m[i].section.wp[j].white_x, + m[i].section.wp[j].white_y, + m[i].section.wp[j].white_gamma); + break; + case DS_CMD: + xf86DrvMsg(scrnIndex, X_INFO, + "Color management data: (not decoded)\n"); + break; + case DS_CVT: + xf86DrvMsg(scrnIndex, X_INFO, + "CVT 3-byte-code modes:\n"); + print_cvt_timings(scrnIndex, m[i].section.cvt); + break; + case DS_EST_III: + xf86DrvMsg(scrnIndex, X_INFO, + "Established timings III: (not decoded)\n"); + break; + case DS_DUMMY: + default: + break; + } + if (m[i].type >= DS_VENDOR && m[i].type <= DS_VENDOR_MAX) { + xf86DrvMsg(scrnIndex, X_WARNING, + "Unknown vendor-specific block %hx\n", + m[i].type - DS_VENDOR); + } + } +} + +static void +print_number_sections(int scrnIndex, int num) +{ + if (num) + xf86DrvMsg(scrnIndex,X_INFO,"Number of EDID sections to follow: %i\n", + num); +} + +xf86MonPtr +xf86PrintEDID(xf86MonPtr m) +{ + CARD16 i, j; + char buf[EDID_WIDTH * 2 + 1]; + + if (!(m)) return NULL; + + print_vendor(m->scrnIndex,&m->vendor); + print_version(m->scrnIndex,&m->ver); + print_display(m->scrnIndex,&m->features, &m->ver); + print_established_timings(m->scrnIndex,&m->timings1); + print_std_timings(m->scrnIndex,m->timings2); + print_detailed_monitor_section(m->scrnIndex,m->det_mon); + print_number_sections(m->scrnIndex,m->no_sections); + + xf86DrvMsg(m->scrnIndex, X_INFO, "EDID (in hex):\n"); + + for (i = 0; i < 128; i += j) { + for (j = 0; j < EDID_WIDTH; ++j) { + sprintf(&buf[j * 2], "%02x", m->rawData[i + j]); + } + xf86DrvMsg(m->scrnIndex, X_INFO, "\t%s\n", buf); + } + + return m; +} diff --git a/xorg-server/hw/xfree86/ddc/xf86DDC.c b/xorg-server/hw/xfree86/ddc/xf86DDC.c new file mode 100644 index 000000000..28e2ead28 --- /dev/null +++ b/xorg-server/hw/xfree86/ddc/xf86DDC.c @@ -0,0 +1,292 @@ +/* xf86DDC.c + * + * Copyright 1998,1999 by Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86DDC.h" +#include "ddcPriv.h" +#include + +#define RETRIES 4 + +static unsigned char *EDIDRead_DDC1( + ScrnInfoPtr pScrn, + DDC1SetSpeedProc, + unsigned int (*)(ScrnInfoPtr) +); + +static Bool TestDDC1( + ScrnInfoPtr pScrn, + unsigned int (*)(ScrnInfoPtr) +); + +static unsigned int *FetchEDID_DDC1( + ScrnInfoPtr, + register unsigned int (*)(ScrnInfoPtr) +); + +static unsigned char* EDID1Read_DDC2( + int scrnIndex, + I2CBusPtr pBus +); + +static unsigned char * DDCRead_DDC2( + int scrnIndex, + I2CBusPtr pBus, + int start, + int len +); + +typedef enum { + DDCOPT_NODDC1, + DDCOPT_NODDC2, + DDCOPT_NODDC +} DDCOpts; + +static const OptionInfoRec DDCOptions[] = { + { DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE }, + { DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE }, + { DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE }, +}; + +/** + * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are + * unset. EDID information blocks are interpreted and the results returned in + * an xf86MonPtr. + * + * This function does not affect the list of modes used by drivers -- it is up + * to the driver to decide policy on what to do with EDID information. + * + * @return pointer to a new xf86MonPtr containing the EDID information. + * @return NULL if no monitor attached or failure to interpret the EDID. + */ +xf86MonPtr +xf86DoEDID_DDC1( + int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed, + unsigned int (*DDC1Read)(ScrnInfoPtr) +) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + unsigned char *EDID_block = NULL; + xf86MonPtr tmp = NULL; + int sigio; + /* Default DDC and DDC1 to enabled. */ + Bool noddc = FALSE, noddc1 = FALSE; + OptionInfoPtr options; + + options = xnfalloc(sizeof(DDCOptions)); + (void)memcpy(options, DDCOptions, sizeof(DDCOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); + xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1); + xfree(options); + + if (noddc || noddc1) + return NULL; + + sigio = xf86BlockSIGIO(); + EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read); + xf86UnblockSIGIO(sigio); + + if (EDID_block){ + tmp = xf86InterpretEDID(scrnIndex,EDID_block); + } +#ifdef DEBUG + else ErrorF("No EDID block returned\n"); + if (!tmp) + ErrorF("Cannot interpret EDID block\n"); +#endif + return tmp; +} + +/** + * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are + * unset. EDID information blocks are interpreted and the results returned in + * an xf86MonPtr. + * + * This function does not affect the list of modes used by drivers -- it is up + * to the driver to decide policy on what to do with EDID information. + * + * @return pointer to a new xf86MonPtr containing the EDID information. + * @return NULL if no monitor attached or failure to interpret the EDID. + */ +xf86MonPtr +xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + unsigned char *EDID_block = NULL; + xf86MonPtr tmp = NULL; + /* Default DDC and DDC2 to enabled. */ + Bool noddc = FALSE, noddc2 = FALSE; + OptionInfoPtr options; + + options = xnfalloc(sizeof(DDCOptions)); + (void)memcpy(options, DDCOptions, sizeof(DDCOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); + xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2); + xfree(options); + + if (noddc || noddc2) + return NULL; + + EDID_block = EDID1Read_DDC2(scrnIndex,pBus); + + if (EDID_block){ + tmp = xf86InterpretEDID(scrnIndex,EDID_block); + } else { +#ifdef DEBUG + ErrorF("No EDID block returned\n"); +#endif + return NULL; + } +#ifdef DEBUG + if (!tmp) + ErrorF("Cannot interpret EDID block\n"); + else + ErrorF("Sections to follow: %i\n",tmp->no_sections); +#endif + + return tmp; +} + +/* + * read EDID record , pass it to callback function to interpret. + * callback function will store it for further use by calling + * function; it will also decide if we need to reread it + */ +static unsigned char * +EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed, + unsigned int (*read_DDC)(ScrnInfoPtr)) +{ + unsigned char *EDID_block = NULL; + int count = RETRIES; + + if (!read_DDC) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "chipset doesn't support DDC1\n"); + return NULL; + }; + + if (TestDDC1(pScrn,read_DDC)==-1) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n"); + return NULL; + }; + + if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST); + do { + EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC)); + count --; + } while (!EDID_block && count); + if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW); + + return EDID_block; +} + +/* test if DDC1 return 0 if not */ +static Bool +TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr)) +{ + int old, count; + + old = read_DDC(pScrn); + count = HEADER * BITS_PER_BYTE; + do { + /* wait for next retrace */ + if (old != read_DDC(pScrn)) break; + } while(count--); + return (count); +} + +/* fetch entire EDID record; DDC bit needs to be masked */ +static unsigned int * +FetchEDID_DDC1(register ScrnInfoPtr pScrn, + register unsigned int (*read_DDC)(ScrnInfoPtr)) +{ + int count = NUM; + unsigned int *ptr, *xp; + + ptr=xp=xalloc(sizeof(int)*NUM); + + if (!ptr) return NULL; + do { + /* wait for next retrace */ + *xp = read_DDC(pScrn); + xp++; + } while(--count); + return (ptr); +} + +static unsigned char* +EDID1Read_DDC2(int scrnIndex, I2CBusPtr pBus) +{ + return DDCRead_DDC2(scrnIndex, pBus, 0, EDID1_LEN); +} + +static unsigned char * +DDCRead_DDC2(int scrnIndex, I2CBusPtr pBus, int start, int len) +{ + I2CDevPtr dev; + unsigned char W_Buffer[2]; + int w_bytes; + unsigned char *R_Buffer; + int i; + + /* + * Slow down the bus so that older monitors don't + * miss things. + */ + pBus->RiseFallTime = 20; + + if (!(dev = xf86I2CFindDev(pBus, 0x00A0))) { + dev = xf86CreateI2CDevRec(); + dev->DevName = "ddc2"; + dev->SlaveAddr = 0xA0; + dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */ + dev->StartTimeout = 550; + dev->BitTimeout = 40; + dev->AcknTimeout = 40; + + dev->pI2CBus = pBus; + if (!xf86I2CDevInit(dev)) { + xf86DrvMsg(scrnIndex, X_PROBED, "No DDC2 device\n"); + return NULL; + } + } + if (start < 0x100) { + w_bytes = 1; + W_Buffer[0] = start; + } else { + w_bytes = 2; + W_Buffer[0] = start & 0xFF; + W_Buffer[1] = (start & 0xFF00) >> 8; + } + R_Buffer = xcalloc(1,sizeof(unsigned char) + * (len)); + for (i=0; i + */ + +#ifndef XF86_DDC_H +# define XF86_DDC_H + +#include "edid.h" +#include "xf86i2c.h" +#include "xf86str.h" + +/* speed up / slow down */ +typedef enum { + DDC_SLOW, + DDC_FAST +} xf86ddcSpeed; + +typedef void (* DDC1SetSpeedProc)(ScrnInfoPtr, xf86ddcSpeed); + +extern xf86MonPtr xf86DoEDID_DDC1( + int scrnIndex, + DDC1SetSpeedProc DDC1SetSpeed, + unsigned int (*DDC1Read)(ScrnInfoPtr) +); + +extern xf86MonPtr xf86DoEDID_DDC2( + int scrnIndex, + I2CBusPtr pBus +); + +extern xf86MonPtr xf86PrintEDID( + xf86MonPtr monPtr +); + +extern xf86MonPtr xf86InterpretEDID( + int screenIndex, Uchar *block +); + +extern void +xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC); + +extern Bool xf86SetDDCproperties( + ScrnInfoPtr pScreen, + xf86MonPtr DDC +); + +DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC); + +#endif + + diff --git a/xorg-server/hw/xfree86/dixmods/Makefile.am b/xorg-server/hw/xfree86/dixmods/Makefile.am new file mode 100644 index 000000000..f4457c207 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/Makefile.am @@ -0,0 +1,114 @@ +noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la + +SUBDIRS = extmod + +if GLX +GLXMODS = libglx.la +endif + +if XTRAP +XTRAPMOD = libxtrap.la +endif + +if DBE +DBEMOD = libdbe.la +endif + +if AFB +AFBMOD = libafb.la +endif + +if CFB +CFBMOD = libcfb.la libcfb32.la +endif + +if MFB +MFBMOD = libmfb.la +endif + +if RECORD +RECORDMOD = librecord.la +endif + +module_LTLIBRARIES = $(AFBMOD) \ + $(CFBMOD) \ + libfb.la \ + libwfb.la \ + $(MFBMOD) \ + libshadow.la + +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = $(RECORDMOD) \ + $(DBEMOD) \ + $(GLXMODS) \ + $(XTRAPMOD) + +fontsmoduledir = $(moduledir)/fonts +fontsmodule_LTLIBRARIES = libfreetype.la + +AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow \ + -I$(top_srcdir)/glx + +libafb_la_LDFLAGS = -avoid-version +libafb_la_LIBADD = $(top_builddir)/afb/libafb.la +libafb_la_SOURCES = afbmodule.c + +libcfb_la_LDFLAGS = -avoid-version +libcfb_la_LIBADD = $(top_builddir)/cfb/libcfb.la +libcfb_la_SOURCES = cfbmodule.c + +libcfb32_la_LDFLAGS = -avoid-version +libcfb32_la_LIBADD = $(top_builddir)/cfb32/libcfb32.la +libcfb32_la_SOURCES = cfb32module.c + +libdbe_la_LDFLAGS = -avoid-version +libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la +libdbe_la_SOURCES = dbemodule.c + +libfb_la_LDFLAGS = -avoid-version +libfb_la_LIBADD = $(top_builddir)/fb/libfb.la +libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c +libfb_la_CFLAGS = $(AM_CFLAGS) + +libwfb_la_LDFLAGS = -avoid-version +libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la +libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c +libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER + +libglx_la_LDFLAGS = -avoid-version +if AIGLX +GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la +endif +libglx_la_LIBADD = \ + $(top_builddir)/glx/libglx.la \ + $(GLXDRI_LIBRARY) +libglx_la_SOURCES = glxmodule.c + +libmfb_la_LDFLAGS = -avoid-version +libmfb_la_LIBADD = $(top_builddir)/mfb/libmfb.la +libmfb_la_SOURCES = mfbmodule.c + +librecord_la_LDFLAGS = -avoid-version +librecord_la_LIBADD = $(top_builddir)/record/librecord.la +librecord_la_SOURCES = recordmod.c + +libshadow_la_LDFLAGS = -avoid-version +libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la +libshadow_la_SOURCES = shmodule.c + +libfreetype_la_LDFLAGS = -avoid-version +libfreetype_la_SOURCES = ftmodule.c + +libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c +libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS) + +libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c +libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la + +libxtrap_la_LDFLAGS = -avoid-version +libxtrap_la_LIBADD = $(top_builddir)/XTrap/libxtrap.la +libxtrap_la_SOURCES = xf86XTrapModule.c diff --git a/xorg-server/hw/xfree86/dixmods/Makefile.in b/xorg-server/hw/xfree86/dixmods/Makefile.in new file mode 100644 index 000000000..80451c3b4 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/Makefile.in @@ -0,0 +1,1110 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/dixmods +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(extsmoduledir)" \ + "$(DESTDIR)$(fontsmoduledir)" "$(DESTDIR)$(moduledir)" +extsmoduleLTLIBRARIES_INSTALL = $(INSTALL) +fontsmoduleLTLIBRARIES_INSTALL = $(INSTALL) +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(extsmodule_LTLIBRARIES) $(fontsmodule_LTLIBRARIES) \ + $(module_LTLIBRARIES) $(noinst_LTLIBRARIES) +libafb_la_DEPENDENCIES = $(top_builddir)/afb/libafb.la +am_libafb_la_OBJECTS = afbmodule.lo +libafb_la_OBJECTS = $(am_libafb_la_OBJECTS) +libafb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libafb_la_LDFLAGS) $(LDFLAGS) -o $@ +@AFB_TRUE@am_libafb_la_rpath = -rpath $(moduledir) +libcfb_la_DEPENDENCIES = $(top_builddir)/cfb/libcfb.la +am_libcfb_la_OBJECTS = cfbmodule.lo +libcfb_la_OBJECTS = $(am_libcfb_la_OBJECTS) +libcfb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libcfb_la_LDFLAGS) $(LDFLAGS) -o $@ +@CFB_TRUE@am_libcfb_la_rpath = -rpath $(moduledir) +libcfb32_la_DEPENDENCIES = $(top_builddir)/cfb32/libcfb32.la +am_libcfb32_la_OBJECTS = cfb32module.lo +libcfb32_la_OBJECTS = $(am_libcfb32_la_OBJECTS) +libcfb32_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libcfb32_la_LDFLAGS) $(LDFLAGS) -o $@ +@CFB_TRUE@am_libcfb32_la_rpath = -rpath $(moduledir) +libdbe_la_DEPENDENCIES = $(top_builddir)/dbe/libdbe.la +am_libdbe_la_OBJECTS = dbemodule.lo +libdbe_la_OBJECTS = $(am_libdbe_la_OBJECTS) +libdbe_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdbe_la_LDFLAGS) $(LDFLAGS) -o $@ +@DBE_TRUE@am_libdbe_la_rpath = -rpath $(extsmoduledir) +libdixmods_la_LIBADD = +am_libdixmods_la_OBJECTS = libdixmods_la-miinitext.lo +libdixmods_la_OBJECTS = $(am_libdixmods_la_OBJECTS) +libdixmods_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libdixmods_la_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +libfb_la_DEPENDENCIES = $(top_builddir)/fb/libfb.la +am_libfb_la_OBJECTS = libfb_la-fbcmap_mi.lo libfb_la-fbmodule.lo +libfb_la_OBJECTS = $(am_libfb_la_OBJECTS) +libfb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(libfb_la_CFLAGS) $(CFLAGS) \ + $(libfb_la_LDFLAGS) $(LDFLAGS) -o $@ +libfreetype_la_LIBADD = +am_libfreetype_la_OBJECTS = ftmodule.lo +libfreetype_la_OBJECTS = $(am_libfreetype_la_OBJECTS) +libfreetype_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libfreetype_la_LDFLAGS) $(LDFLAGS) -o $@ +libglx_la_DEPENDENCIES = $(top_builddir)/glx/libglx.la \ + $(GLXDRI_LIBRARY) +am_libglx_la_OBJECTS = glxmodule.lo +libglx_la_OBJECTS = $(am_libglx_la_OBJECTS) +libglx_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libglx_la_LDFLAGS) $(LDFLAGS) -o $@ +@GLX_TRUE@am_libglx_la_rpath = -rpath $(extsmoduledir) +libmfb_la_DEPENDENCIES = $(top_builddir)/mfb/libmfb.la +am_libmfb_la_OBJECTS = mfbmodule.lo +libmfb_la_OBJECTS = $(am_libmfb_la_OBJECTS) +libmfb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libmfb_la_LDFLAGS) $(LDFLAGS) -o $@ +@MFB_TRUE@am_libmfb_la_rpath = -rpath $(moduledir) +librecord_la_DEPENDENCIES = $(top_builddir)/record/librecord.la +am_librecord_la_OBJECTS = recordmod.lo +librecord_la_OBJECTS = $(am_librecord_la_OBJECTS) +librecord_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(librecord_la_LDFLAGS) $(LDFLAGS) -o $@ +@RECORD_TRUE@am_librecord_la_rpath = -rpath $(extsmoduledir) +libshadow_la_DEPENDENCIES = $(top_builddir)/miext/shadow/libshadow.la +am_libshadow_la_OBJECTS = shmodule.lo +libshadow_la_OBJECTS = $(am_libshadow_la_OBJECTS) +libshadow_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libshadow_la_LDFLAGS) $(LDFLAGS) -o $@ +libwfb_la_DEPENDENCIES = $(top_builddir)/fb/libwfb.la +am_libwfb_la_OBJECTS = libwfb_la-fbcmap_mi.lo libwfb_la-fbmodule.lo +libwfb_la_OBJECTS = $(am_libwfb_la_OBJECTS) +libwfb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libwfb_la_CFLAGS) \ + $(CFLAGS) $(libwfb_la_LDFLAGS) $(LDFLAGS) -o $@ +libxorgxkb_la_DEPENDENCIES = $(top_builddir)/dix/libdix.la +am_libxorgxkb_la_OBJECTS = xkbVT.lo xkbPrivate.lo xkbKillSrv.lo +libxorgxkb_la_OBJECTS = $(am_libxorgxkb_la_OBJECTS) +libxtrap_la_DEPENDENCIES = $(top_builddir)/XTrap/libxtrap.la +am_libxtrap_la_OBJECTS = xf86XTrapModule.lo +libxtrap_la_OBJECTS = $(am_libxtrap_la_OBJECTS) +libxtrap_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libxtrap_la_LDFLAGS) $(LDFLAGS) -o $@ +@XTRAP_TRUE@am_libxtrap_la_rpath = -rpath $(extsmoduledir) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libafb_la_SOURCES) $(libcfb_la_SOURCES) \ + $(libcfb32_la_SOURCES) $(libdbe_la_SOURCES) \ + $(libdixmods_la_SOURCES) $(libfb_la_SOURCES) \ + $(libfreetype_la_SOURCES) $(libglx_la_SOURCES) \ + $(libmfb_la_SOURCES) $(librecord_la_SOURCES) \ + $(libshadow_la_SOURCES) $(libwfb_la_SOURCES) \ + $(libxorgxkb_la_SOURCES) $(libxtrap_la_SOURCES) +DIST_SOURCES = $(libafb_la_SOURCES) $(libcfb_la_SOURCES) \ + $(libcfb32_la_SOURCES) $(libdbe_la_SOURCES) \ + $(libdixmods_la_SOURCES) $(libfb_la_SOURCES) \ + $(libfreetype_la_SOURCES) $(libglx_la_SOURCES) \ + $(libmfb_la_SOURCES) $(librecord_la_SOURCES) \ + $(libshadow_la_SOURCES) $(libwfb_la_SOURCES) \ + $(libxorgxkb_la_SOURCES) $(libxtrap_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la +SUBDIRS = extmod +@GLX_TRUE@GLXMODS = libglx.la +@XTRAP_TRUE@XTRAPMOD = libxtrap.la +@DBE_TRUE@DBEMOD = libdbe.la +@AFB_TRUE@AFBMOD = libafb.la +@CFB_TRUE@CFBMOD = libcfb.la libcfb32.la +@MFB_TRUE@MFBMOD = libmfb.la +@RECORD_TRUE@RECORDMOD = librecord.la +module_LTLIBRARIES = $(AFBMOD) \ + $(CFBMOD) \ + libfb.la \ + libwfb.la \ + $(MFBMOD) \ + libshadow.la + +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = $(RECORDMOD) \ + $(DBEMOD) \ + $(GLXMODS) \ + $(XTRAPMOD) + +fontsmoduledir = $(moduledir)/fonts +fontsmodule_LTLIBRARIES = libfreetype.la +AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow \ + -I$(top_srcdir)/glx + +libafb_la_LDFLAGS = -avoid-version +libafb_la_LIBADD = $(top_builddir)/afb/libafb.la +libafb_la_SOURCES = afbmodule.c +libcfb_la_LDFLAGS = -avoid-version +libcfb_la_LIBADD = $(top_builddir)/cfb/libcfb.la +libcfb_la_SOURCES = cfbmodule.c +libcfb32_la_LDFLAGS = -avoid-version +libcfb32_la_LIBADD = $(top_builddir)/cfb32/libcfb32.la +libcfb32_la_SOURCES = cfb32module.c +libdbe_la_LDFLAGS = -avoid-version +libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la +libdbe_la_SOURCES = dbemodule.c +libfb_la_LDFLAGS = -avoid-version +libfb_la_LIBADD = $(top_builddir)/fb/libfb.la +libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c +libfb_la_CFLAGS = $(AM_CFLAGS) +libwfb_la_LDFLAGS = -avoid-version +libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la +libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c +libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER +libglx_la_LDFLAGS = -avoid-version +@AIGLX_TRUE@GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la +libglx_la_LIBADD = \ + $(top_builddir)/glx/libglx.la \ + $(GLXDRI_LIBRARY) + +libglx_la_SOURCES = glxmodule.c +libmfb_la_LDFLAGS = -avoid-version +libmfb_la_LIBADD = $(top_builddir)/mfb/libmfb.la +libmfb_la_SOURCES = mfbmodule.c +librecord_la_LDFLAGS = -avoid-version +librecord_la_LIBADD = $(top_builddir)/record/librecord.la +librecord_la_SOURCES = recordmod.c +libshadow_la_LDFLAGS = -avoid-version +libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la +libshadow_la_SOURCES = shmodule.c +libfreetype_la_LDFLAGS = -avoid-version +libfreetype_la_SOURCES = ftmodule.c +libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c +libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS) +libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c +libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la +libxtrap_la_LDFLAGS = -avoid-version +libxtrap_la_LIBADD = $(top_builddir)/XTrap/libxtrap.la +libxtrap_la_SOURCES = xf86XTrapModule.c +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/dixmods/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/dixmods/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-extsmoduleLTLIBRARIES: $(extsmodule_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(extsmoduledir)" || $(MKDIR_P) "$(DESTDIR)$(extsmoduledir)" + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(extsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(extsmoduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(extsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(extsmoduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-extsmoduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(extsmoduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(extsmoduledir)/$$p"; \ + done + +clean-extsmoduleLTLIBRARIES: + -test -z "$(extsmodule_LTLIBRARIES)" || rm -f $(extsmodule_LTLIBRARIES) + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +install-fontsmoduleLTLIBRARIES: $(fontsmodule_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(fontsmoduledir)" || $(MKDIR_P) "$(DESTDIR)$(fontsmoduledir)" + @list='$(fontsmodule_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(fontsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(fontsmoduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(fontsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(fontsmoduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-fontsmoduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(fontsmodule_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(fontsmoduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(fontsmoduledir)/$$p"; \ + done + +clean-fontsmoduleLTLIBRARIES: + -test -z "$(fontsmodule_LTLIBRARIES)" || rm -f $(fontsmodule_LTLIBRARIES) + @list='$(fontsmodule_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libafb.la: $(libafb_la_OBJECTS) $(libafb_la_DEPENDENCIES) + $(libafb_la_LINK) $(am_libafb_la_rpath) $(libafb_la_OBJECTS) $(libafb_la_LIBADD) $(LIBS) +libcfb.la: $(libcfb_la_OBJECTS) $(libcfb_la_DEPENDENCIES) + $(libcfb_la_LINK) $(am_libcfb_la_rpath) $(libcfb_la_OBJECTS) $(libcfb_la_LIBADD) $(LIBS) +libcfb32.la: $(libcfb32_la_OBJECTS) $(libcfb32_la_DEPENDENCIES) + $(libcfb32_la_LINK) $(am_libcfb32_la_rpath) $(libcfb32_la_OBJECTS) $(libcfb32_la_LIBADD) $(LIBS) +libdbe.la: $(libdbe_la_OBJECTS) $(libdbe_la_DEPENDENCIES) + $(libdbe_la_LINK) $(am_libdbe_la_rpath) $(libdbe_la_OBJECTS) $(libdbe_la_LIBADD) $(LIBS) +libdixmods.la: $(libdixmods_la_OBJECTS) $(libdixmods_la_DEPENDENCIES) + $(libdixmods_la_LINK) $(libdixmods_la_OBJECTS) $(libdixmods_la_LIBADD) $(LIBS) +libfb.la: $(libfb_la_OBJECTS) $(libfb_la_DEPENDENCIES) + $(libfb_la_LINK) -rpath $(moduledir) $(libfb_la_OBJECTS) $(libfb_la_LIBADD) $(LIBS) +libfreetype.la: $(libfreetype_la_OBJECTS) $(libfreetype_la_DEPENDENCIES) + $(libfreetype_la_LINK) -rpath $(fontsmoduledir) $(libfreetype_la_OBJECTS) $(libfreetype_la_LIBADD) $(LIBS) +libglx.la: $(libglx_la_OBJECTS) $(libglx_la_DEPENDENCIES) + $(libglx_la_LINK) $(am_libglx_la_rpath) $(libglx_la_OBJECTS) $(libglx_la_LIBADD) $(LIBS) +libmfb.la: $(libmfb_la_OBJECTS) $(libmfb_la_DEPENDENCIES) + $(libmfb_la_LINK) $(am_libmfb_la_rpath) $(libmfb_la_OBJECTS) $(libmfb_la_LIBADD) $(LIBS) +librecord.la: $(librecord_la_OBJECTS) $(librecord_la_DEPENDENCIES) + $(librecord_la_LINK) $(am_librecord_la_rpath) $(librecord_la_OBJECTS) $(librecord_la_LIBADD) $(LIBS) +libshadow.la: $(libshadow_la_OBJECTS) $(libshadow_la_DEPENDENCIES) + $(libshadow_la_LINK) -rpath $(moduledir) $(libshadow_la_OBJECTS) $(libshadow_la_LIBADD) $(LIBS) +libwfb.la: $(libwfb_la_OBJECTS) $(libwfb_la_DEPENDENCIES) + $(libwfb_la_LINK) -rpath $(moduledir) $(libwfb_la_OBJECTS) $(libwfb_la_LIBADD) $(LIBS) +libxorgxkb.la: $(libxorgxkb_la_OBJECTS) $(libxorgxkb_la_DEPENDENCIES) + $(LINK) $(libxorgxkb_la_OBJECTS) $(libxorgxkb_la_LIBADD) $(LIBS) +libxtrap.la: $(libxtrap_la_OBJECTS) $(libxtrap_la_DEPENDENCIES) + $(libxtrap_la_LINK) $(am_libxtrap_la_rpath) $(libxtrap_la_OBJECTS) $(libxtrap_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afbmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfb32module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbemodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glxmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdixmods_la-miinitext.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfb_la-fbcmap_mi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfb_la-fbmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libwfb_la-fbcmap_mi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libwfb_la-fbmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recordmod.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86XTrapModule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xkbKillSrv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xkbPrivate.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xkbVT.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libdixmods_la-miinitext.lo: $(top_srcdir)/mi/miinitext.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdixmods_la_CFLAGS) $(CFLAGS) -MT libdixmods_la-miinitext.lo -MD -MP -MF $(DEPDIR)/libdixmods_la-miinitext.Tpo -c -o libdixmods_la-miinitext.lo `test -f '$(top_srcdir)/mi/miinitext.c' || echo '$(srcdir)/'`$(top_srcdir)/mi/miinitext.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libdixmods_la-miinitext.Tpo $(DEPDIR)/libdixmods_la-miinitext.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/mi/miinitext.c' object='libdixmods_la-miinitext.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdixmods_la_CFLAGS) $(CFLAGS) -c -o libdixmods_la-miinitext.lo `test -f '$(top_srcdir)/mi/miinitext.c' || echo '$(srcdir)/'`$(top_srcdir)/mi/miinitext.c + +libfb_la-fbcmap_mi.lo: $(top_builddir)/fb/fbcmap_mi.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfb_la_CFLAGS) $(CFLAGS) -MT libfb_la-fbcmap_mi.lo -MD -MP -MF $(DEPDIR)/libfb_la-fbcmap_mi.Tpo -c -o libfb_la-fbcmap_mi.lo `test -f '$(top_builddir)/fb/fbcmap_mi.c' || echo '$(srcdir)/'`$(top_builddir)/fb/fbcmap_mi.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libfb_la-fbcmap_mi.Tpo $(DEPDIR)/libfb_la-fbcmap_mi.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/fb/fbcmap_mi.c' object='libfb_la-fbcmap_mi.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfb_la_CFLAGS) $(CFLAGS) -c -o libfb_la-fbcmap_mi.lo `test -f '$(top_builddir)/fb/fbcmap_mi.c' || echo '$(srcdir)/'`$(top_builddir)/fb/fbcmap_mi.c + +libfb_la-fbmodule.lo: fbmodule.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfb_la_CFLAGS) $(CFLAGS) -MT libfb_la-fbmodule.lo -MD -MP -MF $(DEPDIR)/libfb_la-fbmodule.Tpo -c -o libfb_la-fbmodule.lo `test -f 'fbmodule.c' || echo '$(srcdir)/'`fbmodule.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libfb_la-fbmodule.Tpo $(DEPDIR)/libfb_la-fbmodule.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fbmodule.c' object='libfb_la-fbmodule.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfb_la_CFLAGS) $(CFLAGS) -c -o libfb_la-fbmodule.lo `test -f 'fbmodule.c' || echo '$(srcdir)/'`fbmodule.c + +libwfb_la-fbcmap_mi.lo: $(top_builddir)/fb/fbcmap_mi.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libwfb_la_CFLAGS) $(CFLAGS) -MT libwfb_la-fbcmap_mi.lo -MD -MP -MF $(DEPDIR)/libwfb_la-fbcmap_mi.Tpo -c -o libwfb_la-fbcmap_mi.lo `test -f '$(top_builddir)/fb/fbcmap_mi.c' || echo '$(srcdir)/'`$(top_builddir)/fb/fbcmap_mi.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libwfb_la-fbcmap_mi.Tpo $(DEPDIR)/libwfb_la-fbcmap_mi.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/fb/fbcmap_mi.c' object='libwfb_la-fbcmap_mi.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libwfb_la_CFLAGS) $(CFLAGS) -c -o libwfb_la-fbcmap_mi.lo `test -f '$(top_builddir)/fb/fbcmap_mi.c' || echo '$(srcdir)/'`$(top_builddir)/fb/fbcmap_mi.c + +libwfb_la-fbmodule.lo: fbmodule.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libwfb_la_CFLAGS) $(CFLAGS) -MT libwfb_la-fbmodule.lo -MD -MP -MF $(DEPDIR)/libwfb_la-fbmodule.Tpo -c -o libwfb_la-fbmodule.lo `test -f 'fbmodule.c' || echo '$(srcdir)/'`fbmodule.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libwfb_la-fbmodule.Tpo $(DEPDIR)/libwfb_la-fbmodule.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fbmodule.c' object='libwfb_la-fbmodule.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libwfb_la_CFLAGS) $(CFLAGS) -c -o libwfb_la-fbmodule.lo `test -f 'fbmodule.c' || echo '$(srcdir)/'`fbmodule.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LTLIBRARIES) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(extsmoduledir)" "$(DESTDIR)$(fontsmoduledir)" "$(DESTDIR)$(moduledir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-extsmoduleLTLIBRARIES clean-fontsmoduleLTLIBRARIES \ + clean-generic clean-libtool clean-moduleLTLIBRARIES \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-extsmoduleLTLIBRARIES \ + install-fontsmoduleLTLIBRARIES install-moduleLTLIBRARIES + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-extsmoduleLTLIBRARIES \ + uninstall-fontsmoduleLTLIBRARIES uninstall-moduleLTLIBRARIES + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-extsmoduleLTLIBRARIES \ + clean-fontsmoduleLTLIBRARIES clean-generic clean-libtool \ + clean-moduleLTLIBRARIES clean-noinstLTLIBRARIES ctags \ + ctags-recursive distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-extsmoduleLTLIBRARIES \ + install-fontsmoduleLTLIBRARIES install-html install-html-am \ + install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am \ + uninstall-extsmoduleLTLIBRARIES \ + uninstall-fontsmoduleLTLIBRARIES uninstall-moduleLTLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/dixmods/afbmodule.c b/xorg-server/hw/xfree86/dixmods/afbmodule.c new file mode 100644 index 000000000..b0aea6ddc --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/afbmodule.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(afbSetup); + +static XF86ModuleVersionInfo VersRec = +{ + "afb", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData afbModuleData = { &VersRec, afbSetup, NULL }; + +static pointer +afbSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + /* This modules requires mfb, so load it */ + return LoadSubModule(module, "mfb", NULL, NULL, NULL, NULL, + errmaj, errmin); +} diff --git a/xorg-server/hw/xfree86/dixmods/cfb32module.c b/xorg-server/hw/xfree86/dixmods/cfb32module.c new file mode 100644 index 000000000..23708e4c2 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/cfb32module.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(cfb32Setup); + +static XF86ModuleVersionInfo VersRec = +{ + "cfb32", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData cfb32ModuleData = { &VersRec, cfb32Setup, NULL }; + +static pointer +cfb32Setup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + /* This modules requires cfb, so load it */ + return LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL, + errmaj, errmin); +} diff --git a/xorg-server/hw/xfree86/dixmods/cfbmodule.c b/xorg-server/hw/xfree86/dixmods/cfbmodule.c new file mode 100644 index 000000000..07074c158 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/cfbmodule.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(cfbSetup); + +static XF86ModuleVersionInfo VersRec = +{ + "cfb", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData cfbModuleData = { &VersRec, cfbSetup, NULL }; + +static pointer +cfbSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + /* This modules requires mfb, so load it */ + return LoadSubModule(module, "mfb", NULL, NULL, NULL, NULL, + errmaj, errmin); +} diff --git a/xorg-server/hw/xfree86/dixmods/dbemodule.c b/xorg-server/hw/xfree86/dixmods/dbemodule.c new file mode 100644 index 000000000..73639886f --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/dbemodule.c @@ -0,0 +1,46 @@ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" +#include "globals.h" + +static MODULESETUPPROTO(dbeSetup); + +extern void DbeExtensionInit(INITARGS); + +static ExtensionModule dbeExt = { + DbeExtensionInit, + "DOUBLE-BUFFER", + &noDbeExtension, + NULL, + NULL +}; + +static XF86ModuleVersionInfo VersRec = +{ + "dbe", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_EXTENSION, + {0,0,0,0} +}; + +/* + * Data for the loader + */ +_X_EXPORT XF86ModuleData dbeModuleData = { &VersRec, dbeSetup, NULL }; + +static pointer +dbeSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + LoadExtension(&dbeExt, FALSE); + + /* Need a non-NULL return value to indicate success */ + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am new file mode 100644 index 000000000..f90e144ea --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.am @@ -0,0 +1,38 @@ +sdk_HEADERS = dgaproc.h + +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = libextmod.la + +if DGA +DGA_SRCS = xf86dga.c xf86dga2.c dgaproc.h xf86dgaext.h +endif + +if XV +XV_SRCS = xvmod.c xvmodproc.h +endif + +if XF86MISC +XF86MISC_SRCS = xf86misc.c xf86miscproc.h +endif + +if XF86VIDMODE +XF86VMODE_SRCS = xf86vmode.c vidmodeproc.h +endif + +AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/afb \ + -I$(top_srcdir)/mfb \ + -I$(top_srcdir)/cfb \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow + +libextmod_la_LDFLAGS = -avoid-version +libextmod_la_SOURCES = modinit.c \ + modinit.h \ + $(DGA_SRCS) \ + $(XF86MISC_SRCS) \ + $(XF86VMODE_SRCS) \ + $(XV_SRCS) +libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la diff --git a/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in new file mode 100644 index 000000000..157358c47 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/Makefile.in @@ -0,0 +1,733 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/dixmods/extmod +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(extsmoduledir)" "$(DESTDIR)$(sdkdir)" +extsmoduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(extsmodule_LTLIBRARIES) +libextmod_la_DEPENDENCIES = $(top_builddir)/Xext/libXextmodule.la +am__libextmod_la_SOURCES_DIST = modinit.c modinit.h xf86dga.c \ + xf86dga2.c dgaproc.h xf86dgaext.h xf86misc.c xf86miscproc.h \ + xf86vmode.c vidmodeproc.h xvmod.c xvmodproc.h +@DGA_TRUE@am__objects_1 = xf86dga.lo xf86dga2.lo +@XF86MISC_TRUE@am__objects_2 = xf86misc.lo +@XF86VIDMODE_TRUE@am__objects_3 = xf86vmode.lo +@XV_TRUE@am__objects_4 = xvmod.lo +am_libextmod_la_OBJECTS = modinit.lo $(am__objects_1) $(am__objects_2) \ + $(am__objects_3) $(am__objects_4) +libextmod_la_OBJECTS = $(am_libextmod_la_OBJECTS) +libextmod_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libextmod_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libextmod_la_SOURCES) +DIST_SOURCES = $(am__libextmod_la_SOURCES_DIST) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +sdk_HEADERS = dgaproc.h +extsmoduledir = $(moduledir)/extensions +extsmodule_LTLIBRARIES = libextmod.la +@DGA_TRUE@DGA_SRCS = xf86dga.c xf86dga2.c dgaproc.h xf86dgaext.h +@XV_TRUE@XV_SRCS = xvmod.c xvmodproc.h +@XF86MISC_TRUE@XF86MISC_SRCS = xf86misc.c xf86miscproc.h +@XF86VIDMODE_TRUE@XF86VMODE_SRCS = xf86vmode.c vidmodeproc.h +AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@ +INCLUDES = @XORG_INCS@ \ + -I$(top_srcdir)/afb \ + -I$(top_srcdir)/mfb \ + -I$(top_srcdir)/cfb \ + -I$(top_srcdir)/dbe \ + -I$(top_srcdir)/hw/xfree86/loader \ + -I$(top_srcdir)/miext/shadow + +libextmod_la_LDFLAGS = -avoid-version +libextmod_la_SOURCES = modinit.c \ + modinit.h \ + $(DGA_SRCS) \ + $(XF86MISC_SRCS) \ + $(XF86VMODE_SRCS) \ + $(XV_SRCS) + +libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/dixmods/extmod/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/dixmods/extmod/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-extsmoduleLTLIBRARIES: $(extsmodule_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(extsmoduledir)" || $(MKDIR_P) "$(DESTDIR)$(extsmoduledir)" + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(extsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(extsmoduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(extsmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(extsmoduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-extsmoduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(extsmoduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(extsmoduledir)/$$p"; \ + done + +clean-extsmoduleLTLIBRARIES: + -test -z "$(extsmodule_LTLIBRARIES)" || rm -f $(extsmodule_LTLIBRARIES) + @list='$(extsmodule_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libextmod.la: $(libextmod_la_OBJECTS) $(libextmod_la_DEPENDENCIES) + $(libextmod_la_LINK) -rpath $(extsmoduledir) $(libextmod_la_OBJECTS) $(libextmod_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modinit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86dga.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86dga2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86vmode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xvmod.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(extsmoduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-extsmoduleLTLIBRARIES clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-extsmoduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-extsmoduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-extsmoduleLTLIBRARIES clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-extsmoduleLTLIBRARIES install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-extsmoduleLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h b/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h new file mode 100644 index 000000000..aaea4e20c --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/dgaproc.h @@ -0,0 +1,144 @@ + +#ifndef __DGAPROC_H +#define __DGAPROC_H + +#include +#include "pixmap.h" + +#define DGA_CONCURRENT_ACCESS 0x00000001 +#define DGA_FILL_RECT 0x00000002 +#define DGA_BLIT_RECT 0x00000004 +#define DGA_BLIT_RECT_TRANS 0x00000008 +#define DGA_PIXMAP_AVAILABLE 0x00000010 + +#define DGA_INTERLACED 0x00010000 +#define DGA_DOUBLESCAN 0x00020000 + +#define DGA_FLIP_IMMEDIATE 0x00000001 +#define DGA_FLIP_RETRACE 0x00000002 + +#define DGA_COMPLETED 0x00000000 +#define DGA_PENDING 0x00000001 + +#define DGA_NEED_ROOT 0x00000001 + +typedef struct { + int num; /* A unique identifier for the mode (num > 0) */ + char *name; /* name of mode given in the XF86Config */ + int VSync_num; + int VSync_den; + int flags; /* DGA_CONCURRENT_ACCESS, etc... */ + int imageWidth; /* linear accessible portion (pixels) */ + int imageHeight; + int pixmapWidth; /* Xlib accessible portion (pixels) */ + int pixmapHeight; /* both fields ignored if no concurrent access */ + int bytesPerScanline; + int byteOrder; /* MSBFirst, LSBFirst */ + int depth; + int bitsPerPixel; + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + short visualClass; + int viewportWidth; + int viewportHeight; + int xViewportStep; /* viewport position granularity */ + int yViewportStep; + int maxViewportX; /* max viewport origin */ + int maxViewportY; + int viewportFlags; /* types of page flipping possible */ + int offset; + int reserved1; + int reserved2; +} XDGAModeRec, *XDGAModePtr; + +/* DDX interface */ + +int +DGASetMode( + int Index, + int num, + XDGAModePtr mode, + PixmapPtr *pPix +); + +void +DGASetInputMode( + int Index, + Bool keyboard, + Bool mouse +); + +void +DGASelectInput( + int Index, + ClientPtr client, + long mask +); + +Bool DGAAvailable(int Index); +Bool DGAActive(int Index); +void DGAShutdown(void); +void DGAInstallCmap(ColormapPtr cmap); +int DGAGetViewportStatus(int Index); +int DGASync(int Index); + +int +DGAFillRect( + int Index, + int x, int y, int w, int h, + unsigned long color +); + +int +DGABlitRect( + int Index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +); + +int +DGABlitTransRect( + int Index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +); + +int +DGASetViewport( + int Index, + int x, int y, + int mode +); + +int DGAGetModes(int Index); +int DGAGetOldDGAMode(int Index); + +int DGAGetModeInfo(int Index, XDGAModePtr mode, int num); + +Bool DGAVTSwitch(void); +Bool DGAStealButtonEvent(int Index, int button, int is_down); +Bool DGAStealMotionEvent(int Index, int dx, int dy); +Bool DGAStealKeyEvent(int Index, int key_code, int is_down); +Bool DGAIsDgaEvent (xEvent *e); + +Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e); + +Bool DGAOpenFramebuffer(int Index, char **name, unsigned char **mem, + int *size, int *offset, int *flags); +void DGACloseFramebuffer(int Index); +Bool DGAChangePixmapMode(int Index, int *x, int *y, int mode); +int DGACreateColormap(int Index, ClientPtr client, int id, int mode, + int alloc); + +extern unsigned char DGAReqCode; +extern int DGAErrorBase; +extern int DGAEventBase; +extern int *XDGAEventBase; + + + +#endif /* __DGAPROC_H */ diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.c b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c new file mode 100644 index 000000000..8c8a4ceeb --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c @@ -0,0 +1,286 @@ +/* + * Copyright (c) 1997 Matthieu Herrb + * + * 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 Matthieu Herrb not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Matthieu Herrb makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" +#include "xf86Opt.h" + +#include + +#include "modinit.h" +#include "globals.h" + +static MODULESETUPPROTO(extmodSetup); + +/* + * Array describing extensions to be initialized + */ +static ExtensionModule extensionModules[] = { +#ifdef XSELINUX + { + SELinuxExtensionInit, + SELINUX_EXTENSION_NAME, + &noSELinuxExtension, + NULL, + NULL + }, +#endif +#ifdef SHAPE + { + ShapeExtensionInit, + SHAPENAME, + &noShapeExtension, + NULL, + NULL + }, +#endif +#ifdef MULTIBUFFER + { + MultibufferExtensionInit, + MULTIBUFFER_PROTOCOL_NAME, + &noMultibufferExtension, + NULL, + NULL + }, +#endif +#ifdef MITMISC + { + MITMiscExtensionInit, + MITMISCNAME, + &noMITMiscExtension, + NULL, + NULL + }, +#endif +#ifdef notyet + { + XTestExtensionInit, + XTestExtensionName, + &noTestExtensions, + NULL, + NULL + }, +#endif +#ifdef BIGREQS + { + BigReqExtensionInit, + XBigReqExtensionName, + &noBigReqExtension, + NULL, + NULL + }, +#endif +#ifdef XSYNC + { + SyncExtensionInit, + SYNC_NAME, + &noSyncExtension, + NULL, + NULL + }, +#endif +#ifdef SCREENSAVER + { + ScreenSaverExtensionInit, + ScreenSaverName, + &noScreenSaverExtension, + NULL, + NULL + }, +#endif +#ifdef XCMISC + { + XCMiscExtensionInit, + XCMiscExtensionName, + &noXCMiscExtension, + NULL, + NULL + }, +#endif +#ifdef XF86VIDMODE + { + XFree86VidModeExtensionInit, + XF86VIDMODENAME, + &noXFree86VidModeExtension, + NULL, + NULL + }, +#endif +#ifdef XF86MISC + { + XFree86MiscExtensionInit, + XF86MISCNAME, + &noXFree86MiscExtension, + NULL, + NULL + }, +#endif +#ifdef XFreeXDGA + { + XFree86DGAExtensionInit, + XF86DGANAME, + &noXFree86DGAExtension, + XFree86DGARegister, + NULL + }, +#endif +#ifdef DPMSExtension + { + DPMSExtensionInit, + DPMSExtensionName, + &noDPMSExtension, + NULL, + NULL + }, +#endif +#ifdef FONTCACHE + { + FontCacheExtensionInit, + FONTCACHENAME, + &noFontCacheExtension, + NULL, + NULL + }, +#endif +#ifdef TOGCUP + { + XcupExtensionInit, + XCUPNAME, + &noXcupExtension, + NULL, + NULL + }, +#endif +#ifdef EVI + { + EVIExtensionInit, + EVINAME, + &noEVIExtension, + NULL, + NULL + }, +#endif +#ifdef XV + { + XvExtensionInit, + XvName, + &noXvExtension, + XvRegister, + NULL + }, + { + XvMCExtensionInit, + XvMCName, + &noXvExtension, + NULL, + NULL + }, +#endif +#ifdef RES + { + ResExtensionInit, + XRES_NAME, + &noResExtension, + NULL, + NULL + }, +#endif + { /* DON'T delete this entry ! */ + NULL, + NULL, + NULL, + NULL, + NULL + } +}; + +static XF86ModuleVersionInfo VersRec = +{ + "extmod", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_EXTENSION, + {0,0,0,0} +}; + +/* + * Data for the loader + */ +_X_EXPORT XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL }; + +static pointer +extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + int i; + + /* XXX the option stuff here is largely a sample/test case */ + + for (i = 0; extensionModules[i].name != NULL; i++) { + if (opts) { + char *s; + s = (char *)xalloc(strlen(extensionModules[i].name) + 5); + if (s) { + pointer o; + strcpy(s, "omit"); + strcat(s, extensionModules[i].name); + o = xf86FindOption(opts, s); + xfree(s); + if (o) { + xf86MarkOptionUsed(o); + continue; + } + } + } + +#ifdef XSELINUX + if (! strcmp(SELINUX_EXTENSION_NAME, extensionModules[i].name)) { + pointer o; + selinuxEnforcingState = SELINUX_MODE_DEFAULT; + + if ((o = xf86FindOption(opts, "SELinux mode disabled"))) { + xf86MarkOptionUsed(o); + selinuxEnforcingState = SELINUX_MODE_DISABLED; + } + if ((o = xf86FindOption(opts, "SELinux mode permissive"))) { + xf86MarkOptionUsed(o); + selinuxEnforcingState = SELINUX_MODE_PERMISSIVE; + } + if ((o = xf86FindOption(opts, "SELinux mode enforcing"))) { + xf86MarkOptionUsed(o); + selinuxEnforcingState = SELINUX_MODE_ENFORCING; + } + } +#endif + + LoadExtension(&extensionModules[i], FALSE); + } + /* Need a non-NULL return */ + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.h b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h new file mode 100644 index 000000000..3c2e2022a --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h @@ -0,0 +1,151 @@ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef INITARGS +#define INITARGS void +#endif + +#ifdef SHAPE +#define _SHAPE_SERVER_ /* don't want Xlib structures */ +#include +#endif + +#ifdef MULTIBUFFER +extern void MultibufferExtensionInit(INITARGS); +#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ +#include +#endif + +#ifdef MITMISC +extern void MITMiscExtensionInit(INITARGS); +#define _MITMISC_SERVER_ +#include +#endif + +#ifdef XTEST +extern void XTestExtensionInit(INITARGS); +#define _XTEST_SERVER_ +#include +#include +#endif + +#if 1 +extern void XTestExtension1Init(INITARGS); +#endif + +#ifdef BIGREQS +extern void BigReqExtensionInit(INITARGS); +#include +#endif + +#ifdef XSYNC +extern void SyncExtensionInit(INITARGS); +#define _SYNC_SERVER +#include +#include +#endif + +#ifdef SCREENSAVER +extern void ScreenSaverExtensionInit (INITARGS); +#include +#endif + +#ifdef XCMISC +extern void XCMiscExtensionInit(INITARGS); +#include +#endif + +#ifdef XF86VIDMODE +extern void XFree86VidModeExtensionInit(INITARGS); +#define _XF86VIDMODE_SERVER_ +#include +#endif + +#ifdef XF86MISC +extern void XFree86MiscExtensionInit(INITARGS); +#define _XF86MISC_SERVER_ +#define _XF86MISC_SAVER_COMPAT_ +#include +#endif + +#ifdef XFreeXDGA +extern void XFree86DGAExtensionInit(INITARGS); +extern void XFree86DGARegister(INITARGS); +#define _XF86DGA_SERVER_ +#include +#endif + +#ifdef DPMSExtension +extern void DPMSExtensionInit(INITARGS); +#include +#endif + +#ifdef FONTCACHE +extern void FontCacheExtensionInit(INITARGS); +#define _FONTCACHE_SERVER_ +#include "fontcacheP.h" +#include "fontcachstr.h" +#endif + +#ifdef TOGCUP +extern void XcupExtensionInit(INITARGS); +#define _XCUP_SERVER_ +#include +#endif + +#ifdef EVI +extern void EVIExtensionInit(INITARGS); +#define _XEVI_SERVER_ +#include +#endif + +#ifdef XV +extern void XvExtensionInit(INITARGS); +extern void XvMCExtensionInit(INITARGS); +extern void XvRegister(INITARGS); +#include +#include +#endif + +#ifdef RES +extern void ResExtensionInit(INITARGS); +#include +#endif + +#ifdef SHM +extern void ShmExtensionInit(INITARGS); +#include +extern void ShmSetPixmapFormat( + ScreenPtr pScreen, + int format); +extern void ShmRegisterFuncs( + ScreenPtr pScreen, + ShmFuncsPtr funcs); +#endif + +#ifdef XSELINUX +extern void SELinuxExtensionInit(INITARGS); +#include "xselinux.h" +#endif + +#if 1 +extern void SecurityExtensionInit(INITARGS); +#endif + +#if 1 +extern void XagExtensionInit(INITARGS); +#endif + +#if 1 +extern void XpExtensionInit(INITARGS); +#endif + +#if 1 +extern void PanoramiXExtensionInit(int argc, char *argv[]); +#endif + +#if 1 +extern void XkbExtensionInit(INITARGS); +#endif diff --git a/xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h b/xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h new file mode 100644 index 000000000..c5ad03af2 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/vidmodeproc.h @@ -0,0 +1,77 @@ + +/* Prototypes for DGA functions that the DDX must provide */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef _VIDMODEPROC_H_ +#define _VIDMODEPROC_H_ + + +typedef enum { + VIDMODE_H_DISPLAY, + VIDMODE_H_SYNCSTART, + VIDMODE_H_SYNCEND, + VIDMODE_H_TOTAL, + VIDMODE_H_SKEW, + VIDMODE_V_DISPLAY, + VIDMODE_V_SYNCSTART, + VIDMODE_V_SYNCEND, + VIDMODE_V_TOTAL, + VIDMODE_FLAGS, + VIDMODE_CLOCK +} VidModeSelectMode; + +typedef enum { + VIDMODE_MON_VENDOR, + VIDMODE_MON_MODEL, + VIDMODE_MON_NHSYNC, + VIDMODE_MON_NVREFRESH, + VIDMODE_MON_HSYNC_LO, + VIDMODE_MON_HSYNC_HI, + VIDMODE_MON_VREFRESH_LO, + VIDMODE_MON_VREFRESH_HI +} VidModeSelectMonitor; + +typedef union { + pointer ptr; + int i; + float f; +} vidMonitorValue; + +void XFree86VidModeExtensionInit(void); + +Bool VidModeAvailable(int scrnIndex); +Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeDeleteModeline(int scrnIndex, pointer mode); +Bool VidModeZoomViewport(int scrnIndex, int zoom); +Bool VidModeGetViewPort(int scrnIndex, int *x, int *y); +Bool VidModeSetViewPort(int scrnIndex, int x, int y); +Bool VidModeSwitchMode(int scrnIndex, pointer mode); +Bool VidModeLockZoom(int scrnIndex, Bool lock); +Bool VidModeGetMonitor(int scrnIndex, pointer *monitor); +int VidModeGetNumOfClocks(int scrnIndex, Bool *progClock); +Bool VidModeGetClocks(int scrnIndex, int *Clocks); +ModeStatus VidModeCheckModeForMonitor(int scrnIndex, pointer mode); +ModeStatus VidModeCheckModeForDriver(int scrnIndex, pointer mode); +void VidModeSetCrtcForMode(int scrnIndex, pointer mode); +Bool VidModeAddModeline(int scrnIndex, pointer mode); +int VidModeGetDotClock(int scrnIndex, int Clock); +int VidModeGetNumOfModes(int scrnIndex); +Bool VidModeSetGamma(int scrnIndex, float red, float green, float blue); +Bool VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue); +pointer VidModeCreateMode(void); +void VidModeCopyMode(pointer modefrom, pointer modeto); +int VidModeGetModeValue(pointer mode, int valtyp); +void VidModeSetModeValue(pointer mode, int valtyp, int val); +vidMonitorValue VidModeGetMonitorValue(pointer monitor, int valtyp, int indx); +Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *); +Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *); +int VidModeGetGammaRampSize(int scrnIndex); + +#endif + + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c new file mode 100644 index 000000000..c66bca26b --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga.c @@ -0,0 +1,309 @@ + +/* + +Copyright (c) 1995 Jon Tombs +Copyright (c) 1995, 1996, 1999 XFree86 Inc + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86DGA_SERVER_ +#include +#include +#include "swaprep.h" +#include "dgaproc.h" + +#include "xf86dgaext.h" + + +static DISPATCH_PROC(ProcXF86DGADirectVideo); +static DISPATCH_PROC(ProcXF86DGAGetVidPage); +static DISPATCH_PROC(ProcXF86DGAGetVideoLL); +static DISPATCH_PROC(ProcXF86DGAGetViewPortSize); +static DISPATCH_PROC(ProcXF86DGASetVidPage); +static DISPATCH_PROC(ProcXF86DGASetViewPort); +static DISPATCH_PROC(ProcXF86DGAInstallColormap); +static DISPATCH_PROC(ProcXF86DGAQueryDirectVideo); +static DISPATCH_PROC(ProcXF86DGAViewPortChanged); + + +static int +ProcXF86DGAGetVideoLL(ClientPtr client) +{ + REQUEST(xXF86DGAGetVideoLLReq); + xXF86DGAGetVideoLLReply rep; + XDGAModeRec mode; + int num, offset, flags; + char *name; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if(!DGAAvailable(stuff->screen)) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + /* get the parameters for the mode that best matches */ + DGAGetModeInfo(stuff->screen, &mode, num); + + if(!DGAOpenFramebuffer(stuff->screen, &name, + (unsigned char**)(&rep.offset), + (int*)(&rep.bank_size), &offset, &flags)) + return BadAlloc; + + rep.offset += mode.offset; + rep.width = mode.bytesPerScanline / (mode.bitsPerPixel >> 3); + rep.ram_size = rep.bank_size >> 10; + + WriteToClient(client, SIZEOF(xXF86DGAGetVideoLLReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DGADirectVideo(ClientPtr client) +{ + int num; + PixmapPtr pix; + XDGAModeRec mode; + REQUEST(xXF86DGADirectVideoReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq); + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + if (stuff->enable & XF86DGADirectGraphics) { + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + } else + num = 0; + + if(Success != DGASetMode(stuff->screen, num, &mode, &pix)) + return (DGAErrorBase + XF86DGAScreenNotActive); + + DGASetInputMode (stuff->screen, + (stuff->enable & XF86DGADirectKeyb) != 0, + (stuff->enable & XF86DGADirectMouse) != 0); + + return (client->noClientException); +} + +static int +ProcXF86DGAGetViewPortSize(ClientPtr client) +{ + int num; + XDGAModeRec mode; + REQUEST(xXF86DGAGetViewPortSizeReq); + xXF86DGAGetViewPortSizeReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if (!DGAAvailable(stuff->screen)) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + DGAGetModeInfo(stuff->screen, &mode, num); + + rep.width = mode.viewportWidth; + rep.height = mode.viewportHeight; + + WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DGASetViewPort(ClientPtr client) +{ + REQUEST(xXF86DGASetViewPortReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq); + + if (!DGAAvailable(stuff->screen)) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + if (!DGAActive(stuff->screen)) + { + int num; + PixmapPtr pix; + XDGAModeRec mode; + + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + if(Success != DGASetMode(stuff->screen, num, &mode, &pix)) + return (DGAErrorBase + XF86DGAScreenNotActive); + } + + if (DGASetViewport(stuff->screen, stuff->x, stuff->y, DGA_FLIP_RETRACE) + != Success) + return DGAErrorBase + XF86DGADirectNotActivated; + + return (client->noClientException); +} + +static int +ProcXF86DGAGetVidPage(ClientPtr client) +{ + REQUEST(xXF86DGAGetVidPageReq); + xXF86DGAGetVidPageReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.vpage = 0; /* silently fail */ + + WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), (char *)&rep); + return (client->noClientException); +} + + +static int +ProcXF86DGASetVidPage(ClientPtr client) +{ + REQUEST(xXF86DGASetVidPageReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq); + + /* silently fail */ + + return (client->noClientException); +} + + +static int +ProcXF86DGAInstallColormap(ClientPtr client) +{ + ColormapPtr pcmp; + REQUEST(xXF86DGAInstallColormapReq); + + REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq); + + if (!DGAActive(stuff->screen)) + return (DGAErrorBase + XF86DGADirectNotActivated); + + pcmp = (ColormapPtr )LookupIDByType(stuff->id, RT_COLORMAP); + if (pcmp) { + DGAInstallCmap(pcmp); + return (client->noClientException); + } else { + client->errorValue = stuff->id; + return (BadColor); + } +} + +static int +ProcXF86DGAQueryDirectVideo(ClientPtr client) +{ + REQUEST(xXF86DGAQueryDirectVideoReq); + xXF86DGAQueryDirectVideoReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.flags = 0; + + if (DGAAvailable(stuff->screen)) + rep.flags = XF86DGADirectPresent; + + WriteToClient(client, SIZEOF(xXF86DGAQueryDirectVideoReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DGAViewPortChanged(ClientPtr client) +{ + REQUEST(xXF86DGAViewPortChangedReq); + xXF86DGAViewPortChangedReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq); + + if (!DGAActive(stuff->screen)) + return (DGAErrorBase + XF86DGADirectNotActivated); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.result = 1; + + WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), (char *)&rep); + return (client->noClientException); +} + +int +ProcXF86DGADispatch(register ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) + { + case X_XF86DGAGetVideoLL: + return ProcXF86DGAGetVideoLL(client); + case X_XF86DGADirectVideo: + return ProcXF86DGADirectVideo(client); + case X_XF86DGAGetViewPortSize: + return ProcXF86DGAGetViewPortSize(client); + case X_XF86DGASetViewPort: + return ProcXF86DGASetViewPort(client); + case X_XF86DGAGetVidPage: + return ProcXF86DGAGetVidPage(client); + case X_XF86DGASetVidPage: + return ProcXF86DGASetVidPage(client); + case X_XF86DGAInstallColormap: + return ProcXF86DGAInstallColormap(client); + case X_XF86DGAQueryDirectVideo: + return ProcXF86DGAQueryDirectVideo(client); + case X_XF86DGAViewPortChanged: + return ProcXF86DGAViewPortChanged(client); + default: + return BadRequest; + } +} + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c new file mode 100644 index 000000000..295e05e9e --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -0,0 +1,754 @@ +/* + Copyright (c) 1999 - The XFree86 Project Inc. + + Written by Mark Vojkovich +*/ + + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include "misc.h" +#include "dixstruct.h" +#include "dixevents.h" +#include "pixmapstr.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86DGA_SERVER_ +#include +#include +#include "swaprep.h" +#include "dgaproc.h" +#include "xf86dgaext.h" + +#include + +#include "modinit.h" + +static DISPATCH_PROC(ProcXDGADispatch); +static DISPATCH_PROC(SProcXDGADispatch); +static DISPATCH_PROC(ProcXDGAQueryVersion); +static DISPATCH_PROC(ProcXDGAQueryModes); +static DISPATCH_PROC(ProcXDGASetMode); +static DISPATCH_PROC(ProcXDGAOpenFramebuffer); +static DISPATCH_PROC(ProcXDGACloseFramebuffer); +static DISPATCH_PROC(ProcXDGASetViewport); +static DISPATCH_PROC(ProcXDGAInstallColormap); +static DISPATCH_PROC(ProcXDGASelectInput); +static DISPATCH_PROC(ProcXDGAFillRectangle); +static DISPATCH_PROC(ProcXDGACopyArea); +static DISPATCH_PROC(ProcXDGACopyTransparentArea); +static DISPATCH_PROC(ProcXDGAGetViewportStatus); +static DISPATCH_PROC(ProcXDGASync); +static DISPATCH_PROC(ProcXDGASetClientVersion); +static DISPATCH_PROC(ProcXDGAChangePixmapMode); +static DISPATCH_PROC(ProcXDGACreateColormap); + +static void XDGAResetProc(ExtensionEntry *extEntry); + +static void DGAClientStateChange (CallbackListPtr*, pointer, pointer); + +static ClientPtr DGAClients[MAXSCREENS]; + +unsigned char DGAReqCode = 0; +int DGAErrorBase; +int DGAEventBase; + +static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKey; +static int DGACallbackRefCount = 0; + +/* This holds the client's version information */ +typedef struct { + int major; + int minor; +} DGAPrivRec, *DGAPrivPtr; + +#define DGA_GETPRIV(c) ((DGAPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey)) +#define DGA_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p) + + +void +XFree86DGAExtensionInit(INITARGS) +{ + ExtensionEntry* extEntry; + + if ((extEntry = AddExtension(XF86DGANAME, + XF86DGANumberEvents, + XF86DGANumberErrors, + ProcXDGADispatch, + SProcXDGADispatch, + XDGAResetProc, + StandardMinorOpcode))) { + int i; + + for(i = 0; i < MAXSCREENS; i++) + DGAClients[i] = NULL; + + DGAReqCode = (unsigned char)extEntry->base; + DGAErrorBase = extEntry->errorBase; + DGAEventBase = extEntry->eventBase; + for (i = KeyPress; i <= MotionNotify; i++) + SetCriticalEvent (DGAEventBase + i); + } +} + + + +static void +XDGAResetProc (ExtensionEntry *extEntry) +{ + DeleteCallback (&ClientStateCallback, DGAClientStateChange, NULL); + DGACallbackRefCount = 0; +} + + +static int +ProcXDGAQueryVersion(ClientPtr client) +{ + xXDGAQueryVersionReply rep; + + REQUEST_SIZE_MATCH(xXDGAQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XDGA_MAJOR_VERSION; + rep.minorVersion = XDGA_MINOR_VERSION; + + WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + + +static int +ProcXDGAOpenFramebuffer(ClientPtr client) +{ + REQUEST(xXDGAOpenFramebufferReq); + xXDGAOpenFramebufferReply rep; + char *deviceName; + int nameSize; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + REQUEST_SIZE_MATCH(xXDGAOpenFramebufferReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if(!DGAOpenFramebuffer(stuff->screen, &deviceName, + (unsigned char**)(&rep.mem1), + (int*)&rep.size, (int*)&rep.offset, (int*)&rep.extra)) + { + return BadAlloc; + } + + nameSize = deviceName ? (strlen(deviceName) + 1) : 0; + rep.length = (nameSize + 3) >> 2; + + WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *)&rep); + if(rep.length) + WriteToClient(client, nameSize, deviceName); + + return (client->noClientException); +} + + +static int +ProcXDGACloseFramebuffer(ClientPtr client) +{ + REQUEST(xXDGACloseFramebufferReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + REQUEST_SIZE_MATCH(xXDGACloseFramebufferReq); + + DGACloseFramebuffer(stuff->screen); + + return (client->noClientException); +} + +static int +ProcXDGAQueryModes(ClientPtr client) +{ + int i, num, size; + REQUEST(xXDGAQueryModesReq); + xXDGAQueryModesReply rep; + xXDGAModeInfo info; + XDGAModePtr mode; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXDGAQueryModesReq); + rep.type = X_Reply; + rep.length = 0; + rep.number = 0; + rep.sequenceNumber = client->sequence; + + if (!DGAAvailable(stuff->screen)) { + rep.number = 0; + rep.length = 0; + WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); + return (client->noClientException); + } + + if(!(num = DGAGetModes(stuff->screen))) { + WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); + return (client->noClientException); + } + + if(!(mode = (XDGAModePtr)xalloc(num * sizeof(XDGAModeRec)))) + return BadAlloc; + + for(i = 0; i < num; i++) + DGAGetModeInfo(stuff->screen, mode + i, i + 1); + + size = num * sz_xXDGAModeInfo; + for(i = 0; i < num; i++) + size += (strlen(mode[i].name) + 4) & ~3L; /* plus NULL */ + + rep.number = num; + rep.length = size >> 2; + + WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); + + for(i = 0; i < num; i++) { + size = strlen(mode[i].name) + 1; + + info.byte_order = mode[i].byteOrder; + info.depth = mode[i].depth; + info.num = mode[i].num; + info.bpp = mode[i].bitsPerPixel; + info.name_size = (size + 3) & ~3L; + info.vsync_num = mode[i].VSync_num; + info.vsync_den = mode[i].VSync_den; + info.flags = mode[i].flags; + info.image_width = mode[i].imageWidth; + info.image_height = mode[i].imageHeight; + info.pixmap_width = mode[i].pixmapWidth; + info.pixmap_height = mode[i].pixmapHeight; + info.bytes_per_scanline = mode[i].bytesPerScanline; + info.red_mask = mode[i].red_mask; + info.green_mask = mode[i].green_mask; + info.blue_mask = mode[i].blue_mask; + info.visual_class = mode[i].visualClass; + info.viewport_width = mode[i].viewportWidth; + info.viewport_height = mode[i].viewportHeight; + info.viewport_xstep = mode[i].xViewportStep; + info.viewport_ystep = mode[i].yViewportStep; + info.viewport_xmax = mode[i].maxViewportX; + info.viewport_ymax = mode[i].maxViewportY; + info.viewport_flags = mode[i].viewportFlags; + info.reserved1 = mode[i].reserved1; + info.reserved2 = mode[i].reserved2; + + WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info)); + WriteToClient(client, size, mode[i].name); + } + + xfree(mode); + + return (client->noClientException); +} + + +static void +DGAClientStateChange ( + CallbackListPtr* pcbl, + pointer nulldata, + pointer calldata +){ + NewClientInfoRec* pci = (NewClientInfoRec*) calldata; + ClientPtr client = NULL; + int i; + + for(i = 0; i < screenInfo.numScreens; i++) { + if(DGAClients[i] == pci->client) { + client = pci->client; + break; + } + } + + if(client && + ((client->clientState == ClientStateGone) || + (client->clientState == ClientStateRetained))) { + XDGAModeRec mode; + PixmapPtr pPix; + + DGAClients[i] = NULL; + DGASelectInput(i, NULL, 0); + DGASetMode(i, 0, &mode, &pPix); + + if(--DGACallbackRefCount == 0) + DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); + } +} + +static int +ProcXDGASetMode(ClientPtr client) +{ + REQUEST(xXDGASetModeReq); + xXDGASetModeReply rep; + XDGAModeRec mode; + xXDGAModeInfo info; + PixmapPtr pPix; + int size; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXDGASetModeReq); + rep.type = X_Reply; + rep.length = 0; + rep.offset = 0; + rep.flags = 0; + rep.sequenceNumber = client->sequence; + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + if(DGAClients[stuff->screen] && + (DGAClients[stuff->screen] != client)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + if(!stuff->mode) { + if(DGAClients[stuff->screen]) { + if(--DGACallbackRefCount == 0) + DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); + } + DGAClients[stuff->screen] = NULL; + DGASelectInput(stuff->screen, NULL, 0); + DGASetMode(stuff->screen, 0, &mode, &pPix); + WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); + return (client->noClientException); + } + + if(Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix)) + return BadValue; + + if(!DGAClients[stuff->screen]) { + if(DGACallbackRefCount++ == 0) + AddCallback (&ClientStateCallback, DGAClientStateChange, NULL); + } + + DGAClients[stuff->screen] = client; + + if(pPix) { + if(AddResource(stuff->pid, RT_PIXMAP, (pointer)(pPix))) { + pPix->drawable.id = (int)stuff->pid; + rep.flags = DGA_PIXMAP_AVAILABLE; + } + } + + size = strlen(mode.name) + 1; + + info.byte_order = mode.byteOrder; + info.depth = mode.depth; + info.num = mode.num; + info.bpp = mode.bitsPerPixel; + info.name_size = (size + 3) & ~3L; + info.vsync_num = mode.VSync_num; + info.vsync_den = mode.VSync_den; + info.flags = mode.flags; + info.image_width = mode.imageWidth; + info.image_height = mode.imageHeight; + info.pixmap_width = mode.pixmapWidth; + info.pixmap_height = mode.pixmapHeight; + info.bytes_per_scanline = mode.bytesPerScanline; + info.red_mask = mode.red_mask; + info.green_mask = mode.green_mask; + info.blue_mask = mode.blue_mask; + info.visual_class = mode.visualClass; + info.viewport_width = mode.viewportWidth; + info.viewport_height = mode.viewportHeight; + info.viewport_xstep = mode.xViewportStep; + info.viewport_ystep = mode.yViewportStep; + info.viewport_xmax = mode.maxViewportX; + info.viewport_ymax = mode.maxViewportY; + info.viewport_flags = mode.viewportFlags; + info.reserved1 = mode.reserved1; + info.reserved2 = mode.reserved2; + + rep.length = (sz_xXDGAModeInfo + info.name_size) >> 2; + + WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); + WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info)); + WriteToClient(client, size, mode.name); + + return (client->noClientException); +} + +static int +ProcXDGASetViewport(ClientPtr client) +{ + REQUEST(xXDGASetViewportReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASetViewportReq); + + DGASetViewport(stuff->screen, stuff->x, stuff->y, stuff->flags); + + return (client->noClientException); +} + +static int +ProcXDGAInstallColormap(ClientPtr client) +{ + ColormapPtr cmap; + REQUEST(xXDGAInstallColormapReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAInstallColormapReq); + + cmap = (ColormapPtr)LookupIDByType(stuff->cmap, RT_COLORMAP); + if (cmap) { + DGAInstallCmap(cmap); + return (client->noClientException); + } else { + client->errorValue = stuff->cmap; + return (BadColor); + } + + return (client->noClientException); +} + + +static int +ProcXDGASelectInput(ClientPtr client) +{ + REQUEST(xXDGASelectInputReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASelectInputReq); + + if(DGAClients[stuff->screen] == client) + DGASelectInput(stuff->screen, client, stuff->mask); + + return (client->noClientException); +} + + +static int +ProcXDGAFillRectangle(ClientPtr client) +{ + REQUEST(xXDGAFillRectangleReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAFillRectangleReq); + + if(Success != DGAFillRect(stuff->screen, stuff->x, stuff->y, + stuff->width, stuff->height, stuff->color)) + return BadMatch; + + return (client->noClientException); +} + +static int +ProcXDGACopyArea(ClientPtr client) +{ + REQUEST(xXDGACopyAreaReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGACopyAreaReq); + + if(Success != DGABlitRect(stuff->screen, stuff->srcx, stuff->srcy, + stuff->width, stuff->height, stuff->dstx, stuff->dsty)) + return BadMatch; + + return (client->noClientException); +} + + +static int +ProcXDGACopyTransparentArea(ClientPtr client) +{ + REQUEST(xXDGACopyTransparentAreaReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq); + + if(Success != DGABlitTransRect(stuff->screen, stuff->srcx, stuff->srcy, + stuff->width, stuff->height, stuff->dstx, stuff->dsty, stuff->key)) + return BadMatch; + + return (client->noClientException); +} + + +static int +ProcXDGAGetViewportStatus(ClientPtr client) +{ + REQUEST(xXDGAGetViewportStatusReq); + xXDGAGetViewportStatusReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rep.status = DGAGetViewportStatus(stuff->screen); + + WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXDGASync(ClientPtr client) +{ + REQUEST(xXDGASyncReq); + xXDGASyncReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASyncReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + DGASync(stuff->screen); + + WriteToClient(client, sizeof(xXDGASyncReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXDGASetClientVersion(ClientPtr client) +{ + REQUEST(xXDGASetClientVersionReq); + + DGAPrivPtr pPriv; + + REQUEST_SIZE_MATCH(xXDGASetClientVersionReq); + if ((pPriv = DGA_GETPRIV(client)) == NULL) { + pPriv = xalloc(sizeof(DGAPrivRec)); + /* XXX Need to look into freeing this */ + if (!pPriv) + return BadAlloc; + DGA_SETPRIV(client, pPriv); + } + pPriv->major = stuff->major; + pPriv->minor = stuff->minor; + + return (client->noClientException); +} + +static int +ProcXDGAChangePixmapMode(ClientPtr client) +{ + REQUEST(xXDGAChangePixmapModeReq); + xXDGAChangePixmapModeReply rep; + int x, y; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + x = stuff->x; + y = stuff->y; + + if(!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags)) + return BadMatch; + + rep.x = x; + rep.y = y; + WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), (char *)&rep); + + return (client->noClientException); +} + + +static int +ProcXDGACreateColormap(ClientPtr client) +{ + REQUEST(xXDGACreateColormapReq); + int result; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGACreateColormapReq); + + if(!stuff->mode) + return BadValue; + + result = DGACreateColormap(stuff->screen, client, stuff->id, + stuff->mode, stuff->alloc); + if(result != Success) + return result; + + return (client->noClientException); +} + + +static int +SProcXDGADispatch (ClientPtr client) +{ + return DGAErrorBase + XF86DGAClientNotLocal; +} + +#if 0 +#define DGA_REQ_DEBUG +#endif + +#ifdef DGA_REQ_DEBUG +static char *dgaMinor[] = { + "QueryVersion", + "GetVideoLL", + "DirectVideo", + "GetViewPortSize", + "SetViewPort", + "GetVidPage", + "SetVidPage", + "InstallColormap", + "QueryDirectVideo", + "ViewPortChanged", + "10", + "11", + "QueryModes", + "SetMode", + "SetViewport", + "InstallColormap", + "SelectInput", + "FillRectangle", + "CopyArea", + "CopyTransparentArea", + "GetViewportStatus", + "Sync", + "OpenFramebuffer", + "CloseFramebuffer", + "SetClientVersion", + "ChangePixmapMode", + "CreateColormap", +}; +#endif + +static int +ProcXDGADispatch (ClientPtr client) +{ + REQUEST(xReq); + + if (!LocalClient(client)) + return DGAErrorBase + XF86DGAClientNotLocal; + +#ifdef DGA_REQ_DEBUG + if (stuff->data <= X_XDGACreateColormap) + fprintf (stderr, " DGA %s\n", dgaMinor[stuff->data]); +#endif + + /* divert old protocol */ +#if 1 + if( (stuff->data <= X_XF86DGAViewPortChanged) && + (stuff->data >= X_XF86DGAGetVideoLL)) + return ProcXF86DGADispatch(client); +#endif + + switch (stuff->data){ + case X_XDGAQueryVersion: + return ProcXDGAQueryVersion(client); + case X_XDGAQueryModes: + return ProcXDGAQueryModes(client); + case X_XDGASetMode: + return ProcXDGASetMode(client); + case X_XDGAOpenFramebuffer: + return ProcXDGAOpenFramebuffer(client); + case X_XDGACloseFramebuffer: + return ProcXDGACloseFramebuffer(client); + case X_XDGASetViewport: + return ProcXDGASetViewport(client); + case X_XDGAInstallColormap: + return ProcXDGAInstallColormap(client); + case X_XDGASelectInput: + return ProcXDGASelectInput(client); + case X_XDGAFillRectangle: + return ProcXDGAFillRectangle(client); + case X_XDGACopyArea: + return ProcXDGACopyArea(client); + case X_XDGACopyTransparentArea: + return ProcXDGACopyTransparentArea(client); + case X_XDGAGetViewportStatus: + return ProcXDGAGetViewportStatus(client); + case X_XDGASync: + return ProcXDGASync(client); + case X_XDGASetClientVersion: + return ProcXDGASetClientVersion(client); + case X_XDGAChangePixmapMode: + return ProcXDGAChangePixmapMode(client); + case X_XDGACreateColormap: + return ProcXDGACreateColormap(client); + default: + return BadRequest; + } +} + +void +XFree86DGARegister(INITARGS) +{ + XDGAEventBase = &DGAEventBase; +} diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h b/xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h new file mode 100644 index 000000000..2b1737305 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dgaext.h @@ -0,0 +1,10 @@ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef _XF86DGAEXT_H_ +#define _XF86DGAEXT_H_ + +extern DISPATCH_PROC(ProcXF86DGADispatch); + +#endif /* _XF86DGAEXT_H_ */ diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c new file mode 100644 index 000000000..8127afdff --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86misc.c @@ -0,0 +1,821 @@ + +/* + * Copyright (c) 1995, 1996 The XFree86 Project, Inc + */ + +/* THIS IS NOT AN X CONSORTIUM STANDARD */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "inputstr.h" +#include "servermd.h" +#define _XF86MISC_SERVER_ +#undef _XF86MISC_SAVER_COMPAT_ +#include +#include "swaprep.h" +#include "xf86.h" +#include +#include "xf86miscproc.h" + +#if 0 +#include +#include "../os/osdep.h" +#include +#ifndef USL +#ifndef Lynx +#include +#else +#include +#endif +#endif /* USL */ +#endif + +static int miscErrorBase; +static DevPrivateKey MiscClientPrivateKey = &MiscClientPrivateKey; + +/* This holds the client's version information */ +typedef struct { + int major; + int minor; +} MiscPrivRec, *MiscPrivPtr; + +#define M_GETPRIV(c) ((MiscPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, MiscClientPrivateKey)) +#define M_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, MiscClientPrivateKey, p) + +static void XF86MiscResetProc( + ExtensionEntry* /* extEntry */ +); + +static void +ClientVersion(ClientPtr client, int *major, int *minor) +{ + MiscPrivPtr pPriv; + + pPriv = M_GETPRIV(client); + if (!pPriv) { + if (major) *major = 0; + if (minor) *minor = 0; + return; + } + + if (major) *major = pPriv->major; + if (minor) *minor = pPriv->minor; +} + +static DISPATCH_PROC(ProcXF86MiscDispatch); +static DISPATCH_PROC(ProcXF86MiscQueryVersion); +static DISPATCH_PROC(ProcXF86MiscGetKbdSettings); +static DISPATCH_PROC(ProcXF86MiscGetMouseSettings); +static DISPATCH_PROC(ProcXF86MiscSetKbdSettings); +static DISPATCH_PROC(ProcXF86MiscSetMouseSettings); +static DISPATCH_PROC(ProcXF86MiscSetGrabKeysState); +static DISPATCH_PROC(ProcXF86MiscSetClientVersion); +static DISPATCH_PROC(ProcXF86MiscGetFilePaths); +static DISPATCH_PROC(ProcXF86MiscPassMessage); +#ifdef _XF86MISC_SAVER_COMPAT_ +static DISPATCH_PROC(ProcXF86MiscGetSaver); +static DISPATCH_PROC(ProcXF86MiscSetSaver); +#endif +static DISPATCH_PROC(SProcXF86MiscDispatch); +static DISPATCH_PROC(SProcXF86MiscQueryVersion); +static DISPATCH_PROC(SProcXF86MiscGetKbdSettings); +static DISPATCH_PROC(SProcXF86MiscGetMouseSettings); +static DISPATCH_PROC(SProcXF86MiscSetKbdSettings); +static DISPATCH_PROC(SProcXF86MiscSetMouseSettings); +static DISPATCH_PROC(SProcXF86MiscSetGrabKeysState); +static DISPATCH_PROC(SProcXF86MiscSetClientVersion); +static DISPATCH_PROC(SProcXF86MiscGetFilePaths); +static DISPATCH_PROC(SProcXF86MiscPassMessage); +#ifdef _XF86MISC_SAVER_COMPAT_ +static DISPATCH_PROC(SProcXF86MiscGetSaver); +static DISPATCH_PROC(SProcXF86MiscSetSaver); +#endif + +#if 0 +static unsigned char XF86MiscReqCode = 0; +#endif + +#ifdef DEBUG +# define DEBUG_P(x) ErrorF x; +#else +# define DEBUG_P(x) do {} while (0) +#endif + +#define MISCERR(x) (miscErrorBase + x) + +void +XFree86MiscExtensionInit(void) +{ + ExtensionEntry* extEntry; + + if (!xf86GetModInDevEnabled()) + return; + + if ( + (extEntry = AddExtension(XF86MISCNAME, + XF86MiscNumberEvents, + XF86MiscNumberErrors, + ProcXF86MiscDispatch, + SProcXF86MiscDispatch, + XF86MiscResetProc, + StandardMinorOpcode))) { +#if 0 + XF86MiscReqCode = (unsigned char)extEntry->base; +#endif + miscErrorBase = extEntry->errorBase; + } +} + +/*ARGSUSED*/ +static void +XF86MiscResetProc (extEntry) + ExtensionEntry* extEntry; +{ +} + +static int +ProcXF86MiscQueryVersion(client) + register ClientPtr client; +{ + xXF86MiscQueryVersionReply rep; + register int n; + + REQUEST_SIZE_MATCH(xXF86MiscQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XF86MISC_MAJOR_VERSION; + rep.minorVersion = XF86MISC_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xXF86MiscQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +#ifdef _XF86MISC_SAVER_COMPAT_ +/* THESE HAVE NOT BEEN CONVERTED TO THE NEW DESIGN */ + +/* + * This will go away, but remains for now for compatibility with older + * clients. + */ +static int +ProcXF86MiscSetSaver(client) + register ClientPtr client; +{ + REQUEST(xXF86MiscSetSaverReq); + ScrnInfoPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); + + REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); + + if (stuff->suspendTime < 0) + return BadValue; + if (stuff->offTime < 0) + return BadValue; + + return (client->noClientException); +} + +/* + * This will go away, but remains for now for compatibility with older + * clients. + */ +static int +ProcXF86MiscGetSaver(client) + register ClientPtr client; +{ + REQUEST(xXF86MiscGetSaverReq); + xXF86MiscGetSaverReply rep; + register int n; + ScrnInfoPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); + + REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.suspendTime = 0; + rep.offTime = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.suspendTime, n); + swapl(&rep.offTime, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetSaverReply), (char *)&rep); + return (client->noClientException); +} + +#endif /* _XF86MISC_SAVER_COMPAT_ */ + +static int +ProcXF86MiscGetMouseSettings(client) + register ClientPtr client; +{ + xXF86MiscGetMouseSettingsReply rep; + char *devname; + pointer mouse; + register int n; + int devnamelen; + + REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + + if (!MiscExtGetMouseSettings(&mouse, &devname)) + return BadValue; + + rep.mousetype = MiscExtGetMouseValue(mouse, MISC_MSE_PROTO); + rep.baudrate = MiscExtGetMouseValue(mouse, MISC_MSE_BAUDRATE); + rep.samplerate = MiscExtGetMouseValue(mouse, MISC_MSE_SAMPLERATE); + rep.resolution = MiscExtGetMouseValue(mouse, MISC_MSE_RESOLUTION); + rep.buttons = MiscExtGetMouseValue(mouse, MISC_MSE_BUTTONS); + rep.emulate3buttons = MiscExtGetMouseValue(mouse, MISC_MSE_EM3BUTTONS); + rep.emulate3timeout = MiscExtGetMouseValue(mouse, MISC_MSE_EM3TIMEOUT); + rep.chordmiddle = MiscExtGetMouseValue(mouse, MISC_MSE_CHORDMIDDLE); + rep.flags = MiscExtGetMouseValue(mouse, MISC_MSE_FLAGS); + devnamelen = rep.devnamelen = (devname? strlen(devname): 0); + rep.length = (sizeof(xXF86MiscGetMouseSettingsReply) - + sizeof(xGenericReply) + ((rep.devnamelen+3) & ~3)) >> 2; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.mousetype, n); + swapl(&rep.baudrate, n); + swapl(&rep.samplerate, n); + swapl(&rep.resolution, n); + swapl(&rep.buttons, n); + swapl(&rep.emulate3buttons, n); + swapl(&rep.emulate3timeout, n); + swapl(&rep.chordmiddle, n); + swapl(&rep.flags, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetMouseSettingsReply), (char *)&rep); + MiscExtDestroyStruct(mouse, MISC_POINTER); + + if (devnamelen) + WriteToClient(client, devnamelen, devname); + return (client->noClientException); +} + +static int +ProcXF86MiscGetKbdSettings(client) + register ClientPtr client; +{ + xXF86MiscGetKbdSettingsReply rep; + pointer kbd; + register int n; + + REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + if (!MiscExtGetKbdSettings(&kbd)) + return BadValue; + + rep.kbdtype = MiscExtGetKbdValue(kbd, MISC_KBD_TYPE); + rep.rate = MiscExtGetKbdValue(kbd, MISC_KBD_RATE); + rep.delay = MiscExtGetKbdValue(kbd, MISC_KBD_DELAY); + rep.servnumlock = MiscExtGetKbdValue(kbd, MISC_KBD_SERVNUMLOCK); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.kbdtype, n); + swapl(&rep.rate, n); + swapl(&rep.delay, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetKbdSettingsReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86MiscSetMouseSettings(client) + register ClientPtr client; +{ + MiscExtReturn ret; + pointer mouse; + char *devname = NULL; + int major, minor; + + REQUEST(xXF86MiscSetMouseSettingsReq); + + REQUEST_AT_LEAST_SIZE(xXF86MiscSetMouseSettingsReq); + + ClientVersion(client, &major, &minor); + + if (xf86GetVerbosity() > 1) { + DEBUG_P(("SetMouseSettings - type: %d brate: %d srate: %d chdmid: %d\n", + (int)stuff->mousetype, (int)stuff->baudrate, + (int)stuff->samplerate, stuff->chordmiddle)); + DEBUG_P((" em3but: %d em3tim: %d res: %d flags: %ld\n", + stuff->emulate3buttons, (int)stuff->emulate3timeout, + (int)stuff->resolution, (unsigned long)stuff->flags)); + } + + if ((mouse = MiscExtCreateStruct(MISC_POINTER)) == (pointer) 0) + return BadAlloc; + + MiscExtSetMouseValue(mouse, MISC_MSE_PROTO, stuff->mousetype); + MiscExtSetMouseValue(mouse, MISC_MSE_BAUDRATE, stuff->baudrate); + MiscExtSetMouseValue(mouse, MISC_MSE_SAMPLERATE, stuff->samplerate); + MiscExtSetMouseValue(mouse, MISC_MSE_RESOLUTION, stuff->resolution); + MiscExtSetMouseValue(mouse, MISC_MSE_BUTTONS, stuff->buttons); + MiscExtSetMouseValue(mouse, MISC_MSE_EM3BUTTONS, stuff->emulate3buttons); + MiscExtSetMouseValue(mouse, MISC_MSE_EM3TIMEOUT, stuff->emulate3timeout); + MiscExtSetMouseValue(mouse, MISC_MSE_CHORDMIDDLE, stuff->chordmiddle); + MiscExtSetMouseValue(mouse, MISC_MSE_FLAGS, stuff->flags); + + if ((major > 0 || minor > 5) && stuff->devnamelen) { + int size = sizeof(xXF86MiscSetMouseSettingsReq) + stuff->devnamelen; + size = (size + 3) >> 2; + if (client->req_len < size) + return BadLength; + if (stuff->devnamelen) { + if (!(devname = xalloc(stuff->devnamelen))) + return BadAlloc; + strncpy(devname,(char*)(&stuff[1]),stuff->devnamelen); + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetMouseSettings - device: %s\n",devname)); + MiscExtSetMouseDevice(mouse, devname); + } + } + + ret = MiscExtApply(mouse, MISC_POINTER); + + if (devname) + xfree(devname); + + switch ((ret)) { + case MISC_RET_SUCCESS: break; + case MISC_RET_BADVAL: return BadValue; + case MISC_RET_BADMSEPROTO: return MISCERR(XF86MiscBadMouseProtocol); + case MISC_RET_BADBAUDRATE: return MISCERR(XF86MiscBadMouseBaudRate); + case MISC_RET_BADFLAGS: return MISCERR(XF86MiscBadMouseFlags); + case MISC_RET_BADCOMBO: return MISCERR(XF86MiscBadMouseCombo); + case MISC_RET_NOMODULE: return MISCERR(XF86MiscNoModule); + default: + DEBUG_P(("Unexpected return from MiscExtApply(POINTER) = %d\n", ret)); + return BadImplementation; + } + + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetMouseSettings - Succeeded\n")); + return (client->noClientException); +} + +static int +ProcXF86MiscSetKbdSettings(client) + register ClientPtr client; +{ + MiscExtReturn ret; + pointer kbd; + REQUEST(xXF86MiscSetKbdSettingsReq); + + REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq); + + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetKbdSettings - type: %d rate: %d delay: %d snumlk: %d\n", + (int)stuff->kbdtype, (int)stuff->rate, + (int)stuff->delay, stuff->servnumlock)); + + if ((kbd = MiscExtCreateStruct(MISC_KEYBOARD)) == (pointer) 0) + return BadAlloc; + + MiscExtSetKbdValue(kbd, MISC_KBD_TYPE, stuff->kbdtype); + MiscExtSetKbdValue(kbd, MISC_KBD_RATE, stuff->rate); + MiscExtSetKbdValue(kbd, MISC_KBD_DELAY, stuff->delay); + MiscExtSetKbdValue(kbd, MISC_KBD_SERVNUMLOCK, stuff->servnumlock); + + switch ((ret = MiscExtApply(kbd, MISC_KEYBOARD))) { + case MISC_RET_SUCCESS: break; + case MISC_RET_BADVAL: return BadValue; + case MISC_RET_BADKBDTYPE: return MISCERR(XF86MiscBadKbdType); + default: + DEBUG_P(("Unexpected return from MiscExtApply(KEYBOARD) = %d\n", ret)); + return BadImplementation; + } + + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetKbdSettings - Succeeded\n")); + return (client->noClientException); +} + +static int +ProcXF86MiscSetGrabKeysState(client) + register ClientPtr client; +{ + int n, status; + xXF86MiscSetGrabKeysStateReply rep; + REQUEST(xXF86MiscSetGrabKeysStateReq); + + REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq); + + if ((status = MiscExtSetGrabKeysState(client, stuff->enable)) == 0) { + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetGrabKeysState - %s\n", + stuff->enable ? "enabled" : "disabled")); + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.status = status; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, SIZEOF(xXF86MiscSetGrabKeysStateReply), (char *)&rep); + + return (client->noClientException); +} + +static int +ProcXF86MiscSetClientVersion(ClientPtr client) +{ + REQUEST(xXF86MiscSetClientVersionReq); + + MiscPrivPtr pPriv; + + REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); + + if ((pPriv = M_GETPRIV(client)) == NULL) { + pPriv = xalloc(sizeof(MiscPrivRec)); + if (!pPriv) + return BadAlloc; + M_SETPRIV(client, pPriv); + } + if (xf86GetVerbosity() > 1) + DEBUG_P(("SetClientVersion: %i %i\n",stuff->major,stuff->minor)); + pPriv->major = stuff->major; + pPriv->minor = stuff->minor; + + return (client->noClientException); +} + +static int +ProcXF86MiscGetFilePaths(client) + register ClientPtr client; +{ + xXF86MiscGetFilePathsReply rep; + const char *configfile; + const char *modulepath; + const char *logfile; + register int n; + int configlen, modulelen, loglen; + + REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + + if (!MiscExtGetFilePaths(&configfile, &modulepath, &logfile)) + return BadValue; + + configlen = rep.configlen = (configfile? strlen(configfile): 0); + modulelen = rep.modulelen = (modulepath? strlen(modulepath): 0); + loglen = rep.loglen = (logfile? strlen(logfile): 0); + rep.length = (SIZEOF(xXF86MiscGetFilePathsReply) - SIZEOF(xGenericReply) + + ((rep.configlen + 3) & ~3) + + ((rep.modulelen + 3) & ~3) + + ((rep.loglen + 3) & ~3) ) >> 2; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.configlen, n); + swaps(&rep.modulelen, n); + swaps(&rep.loglen, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetFilePathsReply), (char *)&rep); + + if (configlen) + WriteToClient(client, configlen, (char *)configfile); + if (modulelen) + WriteToClient(client, modulelen, (char *)modulepath); + if (loglen) + WriteToClient(client, loglen, (char *)logfile); + + return (client->noClientException); +} + +static int +ProcXF86MiscPassMessage(client) + register ClientPtr client; +{ + xXF86MiscPassMessageReply rep; + char *msgtype, *msgval, *retstr; + int retval, size; + register int n; + int mesglen; + + REQUEST(xXF86MiscPassMessageReq); + + REQUEST_AT_LEAST_SIZE(xXF86MiscPassMessageReq); + size = (sizeof(xXF86MiscPassMessageReq) + 3) >> 2; + size+= (stuff->typelen + 3) >> 2; + size+= (stuff->vallen + 3) >> 2; + if (client->req_len < size) + return BadLength; + if (stuff->typelen) { + if (!(msgtype = xalloc(stuff->typelen))) + return BadAlloc; + strncpy(msgtype,(char*)(&stuff[1]),stuff->typelen); + } else return BadValue; + if (stuff->vallen) { + if (!(msgval = xalloc(stuff->vallen))) { + xfree(msgtype); + return BadAlloc; + } + strncpy(msgval,(char*)((char*)&stuff[1] + ((stuff->typelen + 3) & ~3)), + stuff->vallen); + } else { + xfree(msgtype); + return BadValue; + } + + if ((retval = MiscExtPassMessage(stuff->screen,msgtype,msgval,&retstr)) != 0) { + xfree(msgtype); + xfree(msgval); + return retval; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + mesglen = rep.mesglen = (retstr? strlen(retstr): 0); + rep.length = (SIZEOF(xXF86MiscPassMessageReply) - SIZEOF(xGenericReply) + + ((rep.mesglen + 3) & ~3)) >> 2; + rep.status = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.mesglen, n); + } + WriteToClient(client, SIZEOF(xXF86MiscPassMessageReply), (char *)&rep); + + if (mesglen) + WriteToClient(client, mesglen, (char *)retstr); + + xfree(msgtype); + xfree(msgval); + + return (client->noClientException); +} + +static int +ProcXF86MiscDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86MiscQueryVersion: + return ProcXF86MiscQueryVersion(client); +#ifdef _XF86MISC_SAVER_COMPAT_ + case X_XF86MiscGetSaver: + return ProcXF86MiscGetSaver(client); + case X_XF86MiscSetSaver: + return ProcXF86MiscSetSaver(client); +#endif + case X_XF86MiscGetMouseSettings: + return ProcXF86MiscGetMouseSettings(client); + case X_XF86MiscGetKbdSettings: + return ProcXF86MiscGetKbdSettings(client); + case X_XF86MiscSetClientVersion: + return ProcXF86MiscSetClientVersion(client); + case X_XF86MiscGetFilePaths: + return ProcXF86MiscGetFilePaths(client); + case X_XF86MiscPassMessage: + return ProcXF86MiscPassMessage(client); + default: + if (!xf86GetModInDevEnabled()) + return miscErrorBase + XF86MiscModInDevDisabled; + if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) { + switch (stuff->data) { + case X_XF86MiscSetMouseSettings: + return ProcXF86MiscSetMouseSettings(client); + case X_XF86MiscSetKbdSettings: + return ProcXF86MiscSetKbdSettings(client); + case X_XF86MiscSetGrabKeysState: + return ProcXF86MiscSetGrabKeysState(client); + default: + return BadRequest; + } + } else + return miscErrorBase + XF86MiscModInDevClientNotLocal; + } +} + +static int +SProcXF86MiscQueryVersion(client) + register ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscQueryVersionReq); + swaps(&stuff->length, n); + return ProcXF86MiscQueryVersion(client); +} + +#ifdef _XF86MISC_SAVER_COMPAT_ +static int +SProcXF86MiscGetSaver(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetSaverReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); + swaps(&stuff->screen, n); + return ProcXF86MiscGetSaver(client); +} + +static int +SProcXF86MiscSetSaver(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetSaverReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); + swaps(&stuff->screen, n); + swapl(&stuff->suspendTime, n); + swapl(&stuff->offTime, n); + return ProcXF86MiscSetSaver(client); +} +#endif /* _XF86MISC_SAVER_COMPAT_ */ + +static int +SProcXF86MiscGetMouseSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetMouseSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq); + return ProcXF86MiscGetMouseSettings(client); +} + +static int +SProcXF86MiscGetKbdSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetKbdSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq); + return ProcXF86MiscGetKbdSettings(client); +} + +static int +SProcXF86MiscSetMouseSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetMouseSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetMouseSettingsReq); + swapl(&stuff->mousetype, n); + swapl(&stuff->baudrate, n); + swapl(&stuff->samplerate, n); + swapl(&stuff->resolution, n); + swapl(&stuff->buttons, n); + swapl(&stuff->emulate3timeout, n); + swapl(&stuff->flags, n); + return ProcXF86MiscSetMouseSettings(client); +} + +static int +SProcXF86MiscSetKbdSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetKbdSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq); + swapl(&stuff->kbdtype, n); + swapl(&stuff->rate, n); + swapl(&stuff->delay, n); + return ProcXF86MiscSetKbdSettings(client); +} + +static int +SProcXF86MiscSetGrabKeysState(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetGrabKeysStateReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq); + swaps(&stuff->enable, n); + return ProcXF86MiscSetGrabKeysState(client); +} + +static int +SProcXF86MiscSetClientVersion(ClientPtr client) +{ + register int n; + REQUEST(xXF86MiscSetClientVersionReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); + swaps(&stuff->major, n); + swaps(&stuff->minor, n); + return ProcXF86MiscSetClientVersion(client); +} + +static int +SProcXF86MiscGetFilePaths(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetFilePathsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq); + return ProcXF86MiscGetFilePaths(client); +} + +static int +SProcXF86MiscPassMessage(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscPassMessageReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscPassMessageReq); + return ProcXF86MiscPassMessage(client); +} + +static int +SProcXF86MiscDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86MiscQueryVersion: + return SProcXF86MiscQueryVersion(client); +#ifdef _XF86MISC_SAVER_COMPAT_ + case X_XF86MiscGetSaver: + return SProcXF86MiscGetSaver(client); + case X_XF86MiscSetSaver: + return SProcXF86MiscSetSaver(client); +#endif + case X_XF86MiscGetMouseSettings: + return SProcXF86MiscGetMouseSettings(client); + case X_XF86MiscGetKbdSettings: + return SProcXF86MiscGetKbdSettings(client); + case X_XF86MiscSetClientVersion: + return SProcXF86MiscSetClientVersion(client); + case X_XF86MiscGetFilePaths: + return SProcXF86MiscGetFilePaths(client); + case X_XF86MiscPassMessage: + return SProcXF86MiscPassMessage(client); + default: + if (!xf86GetModInDevEnabled()) + return miscErrorBase + XF86MiscModInDevDisabled; + if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) { + switch (stuff->data) { + case X_XF86MiscSetMouseSettings: + return SProcXF86MiscSetMouseSettings(client); + case X_XF86MiscSetKbdSettings: + return SProcXF86MiscSetKbdSettings(client); + case X_XF86MiscSetGrabKeysState: + return SProcXF86MiscSetGrabKeysState(client); + default: + return BadRequest; + } + } else + return miscErrorBase + XF86MiscModInDevClientNotLocal; + } +} + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h b/xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h new file mode 100644 index 000000000..93b193ca7 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86miscproc.h @@ -0,0 +1,69 @@ + +/* Prototypes for Pointer/Keyboard functions that the DDX must provide */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef _XF86MISCPROC_H_ +#define _XF86MISCPROC_H_ + +typedef enum { + MISC_MSE_PROTO, + MISC_MSE_BAUDRATE, + MISC_MSE_SAMPLERATE, + MISC_MSE_RESOLUTION, + MISC_MSE_BUTTONS, + MISC_MSE_EM3BUTTONS, + MISC_MSE_EM3TIMEOUT, + MISC_MSE_CHORDMIDDLE, + MISC_MSE_FLAGS +} MiscExtMseValType; + +typedef enum { + MISC_KBD_TYPE, + MISC_KBD_RATE, + MISC_KBD_DELAY, + MISC_KBD_SERVNUMLOCK +} MiscExtKbdValType; + +typedef enum { + MISC_RET_SUCCESS, + MISC_RET_BADVAL, + MISC_RET_BADMSEPROTO, + MISC_RET_BADBAUDRATE, + MISC_RET_BADFLAGS, + MISC_RET_BADCOMBO, + MISC_RET_BADKBDTYPE, + MISC_RET_NOMODULE +} MiscExtReturn; + +typedef enum { + MISC_POINTER, + MISC_KEYBOARD +} MiscExtStructType; + +#define MISC_MSEFLAG_CLEARDTR 1 +#define MISC_MSEFLAG_CLEARRTS 2 +#define MISC_MSEFLAG_REOPEN 128 + +void XFree86MiscExtensionInit(void); + +Bool MiscExtGetMouseSettings(pointer *mouse, char **devname); +int MiscExtGetMouseValue(pointer mouse, MiscExtMseValType valtype); +Bool MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value); +Bool MiscExtGetKbdSettings(pointer *kbd); +int MiscExtGetKbdValue(pointer kbd, MiscExtKbdValType valtype); +Bool MiscExtSetKbdValue(pointer kbd, MiscExtKbdValType valtype, int value); +int MiscExtSetGrabKeysState(ClientPtr client, int enable); +pointer MiscExtCreateStruct(MiscExtStructType mse_or_kbd); +void MiscExtDestroyStruct(pointer structure, MiscExtStructType mse_or_kbd); +MiscExtReturn MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd); +Bool MiscExtSetMouseDevice(pointer mouse, char* device); +Bool MiscExtGetFilePaths(const char **configfile, const char **modulepath, + const char **logfile); +int MiscExtPassMessage(int scrn, const char *msgtype, const char *msgval, + char **retstr); + +#endif + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c new file mode 100644 index 000000000..718d40fbd --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -0,0 +1,2186 @@ + +/* + +Copyright 1995 Kaleb S. KEITHLEY + +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 Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of Kaleb S. KEITHLEY +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +from Kaleb S. KEITHLEY + +*/ +/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86VIDMODE_SERVER_ +#include +#include "swaprep.h" +#include "xf86.h" +#include "vidmodeproc.h" + +#define DEFAULT_XF86VIDMODE_VERBOSITY 3 + +static int VidModeErrorBase; +static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKey; + +/* This holds the client's version information */ +typedef struct { + int major; + int minor; +} VidModePrivRec, *VidModePrivPtr; + +#define VM_GETPRIV(c) ((VidModePrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey)) +#define VM_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p) + +static void XF86VidModeResetProc( + ExtensionEntry* /* extEntry */ +); + +static DISPATCH_PROC(ProcXF86VidModeDispatch); +static DISPATCH_PROC(ProcXF86VidModeGetAllModeLines); +static DISPATCH_PROC(ProcXF86VidModeGetModeLine); +static DISPATCH_PROC(ProcXF86VidModeGetMonitor); +static DISPATCH_PROC(ProcXF86VidModeLockModeSwitch); +static DISPATCH_PROC(ProcXF86VidModeAddModeLine); +static DISPATCH_PROC(ProcXF86VidModeDeleteModeLine); +static DISPATCH_PROC(ProcXF86VidModeModModeLine); +static DISPATCH_PROC(ProcXF86VidModeValidateModeLine); +static DISPATCH_PROC(ProcXF86VidModeQueryVersion); +static DISPATCH_PROC(ProcXF86VidModeSwitchMode); +static DISPATCH_PROC(ProcXF86VidModeSwitchToMode); +static DISPATCH_PROC(ProcXF86VidModeGetViewPort); +static DISPATCH_PROC(ProcXF86VidModeSetViewPort); +static DISPATCH_PROC(ProcXF86VidModeGetDotClocks); +static DISPATCH_PROC(ProcXF86VidModeSetGamma); +static DISPATCH_PROC(ProcXF86VidModeGetGamma); +static DISPATCH_PROC(ProcXF86VidModeSetClientVersion); +static DISPATCH_PROC(ProcXF86VidModeGetGammaRamp); +static DISPATCH_PROC(ProcXF86VidModeSetGammaRamp); +static DISPATCH_PROC(ProcXF86VidModeGetGammaRampSize); +static DISPATCH_PROC(SProcXF86VidModeDispatch); +static DISPATCH_PROC(SProcXF86VidModeGetAllModeLines); +static DISPATCH_PROC(SProcXF86VidModeGetModeLine); +static DISPATCH_PROC(SProcXF86VidModeGetMonitor); +static DISPATCH_PROC(SProcXF86VidModeLockModeSwitch); +static DISPATCH_PROC(SProcXF86VidModeAddModeLine); +static DISPATCH_PROC(SProcXF86VidModeDeleteModeLine); +static DISPATCH_PROC(SProcXF86VidModeModModeLine); +static DISPATCH_PROC(SProcXF86VidModeValidateModeLine); +static DISPATCH_PROC(SProcXF86VidModeQueryVersion); +static DISPATCH_PROC(SProcXF86VidModeSwitchMode); +static DISPATCH_PROC(SProcXF86VidModeSwitchToMode); +static DISPATCH_PROC(SProcXF86VidModeGetViewPort); +static DISPATCH_PROC(SProcXF86VidModeSetViewPort); +static DISPATCH_PROC(SProcXF86VidModeGetDotClocks); +static DISPATCH_PROC(SProcXF86VidModeSetGamma); +static DISPATCH_PROC(SProcXF86VidModeGetGamma); +static DISPATCH_PROC(SProcXF86VidModeSetClientVersion); +static DISPATCH_PROC(SProcXF86VidModeGetGammaRamp); +static DISPATCH_PROC(SProcXF86VidModeSetGammaRamp); +static DISPATCH_PROC(SProcXF86VidModeGetGammaRampSize); + +#if 0 +static unsigned char XF86VidModeReqCode = 0; +#endif + +/* The XF86VIDMODE_EVENTS code is far from complete */ + +#ifdef XF86VIDMODE_EVENTS +static int XF86VidModeEventBase = 0; + +static void SXF86VidModeNotifyEvent(); + xXF86VidModeNotifyEvent * /* from */, + xXF86VidModeNotifyEvent * /* to */ +); + +extern WindowPtr *WindowTable; + +static RESTYPE EventType; /* resource type for event masks */ + +typedef struct _XF86VidModeEvent *XF86VidModeEventPtr; + +typedef struct _XF86VidModeEvent { + XF86VidModeEventPtr next; + ClientPtr client; + ScreenPtr screen; + XID resource; + CARD32 mask; +} XF86VidModeEventRec; + +static int XF86VidModeFreeEvents(); + +typedef struct _XF86VidModeScreenPrivate { + XF86VidModeEventPtr events; + Bool hasWindow; +} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr; + +static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey; + +#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ + dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey)) +#define SetScreenPrivate(s,v) \ + dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v) +#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s) + +#define New(t) (xalloc (sizeof (t))) +#endif + +#ifdef DEBUG +# define DEBUG_P(x) ErrorF(x"\n"); +#else +# define DEBUG_P(x) /**/ +#endif + +void +XFree86VidModeExtensionInit(void) +{ + ExtensionEntry* extEntry; + ScreenPtr pScreen; + int i; + Bool enabled = FALSE; + + DEBUG_P("XFree86VidModeExtensionInit"); + +#ifdef XF86VIDMODE_EVENTS + EventType = CreateNewResourceType(XF86VidModeFreeEvents); +#endif + + for(i = 0; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + if (VidModeExtensionInit(pScreen)) + enabled = TRUE; +#ifdef XF86VIDMODE_EVENTS + SetScreenPrivate (pScreen, NULL); +#endif + } + /* This means that the DDX doesn't want the vidmode extension enabled */ + if (!enabled) + return; + + if ( +#ifdef XF86VIDMODE_EVENTS + EventType && +#endif + (extEntry = AddExtension(XF86VIDMODENAME, + XF86VidModeNumberEvents, + XF86VidModeNumberErrors, + ProcXF86VidModeDispatch, + SProcXF86VidModeDispatch, + XF86VidModeResetProc, + StandardMinorOpcode))) { +#if 0 + XF86VidModeReqCode = (unsigned char)extEntry->base; +#endif + VidModeErrorBase = extEntry->errorBase; +#ifdef XF86VIDMODE_EVENTS + XF86VidModeEventBase = extEntry->eventBase; + EventSwapVector[XF86VidModeEventBase] = (EventSwapPtr)SXF86VidModeNotifyEvent; +#endif + } +} + +/*ARGSUSED*/ +static void +XF86VidModeResetProc (extEntry) + ExtensionEntry* extEntry; +{ +} + +static int +ClientMajorVersion(ClientPtr client) +{ + VidModePrivPtr pPriv; + + pPriv = VM_GETPRIV(client); + if (!pPriv) + return 0; + else + return pPriv->major; +} + +#ifdef XF86VIDMODE_EVENTS +static void +CheckScreenPrivate (pScreen) + ScreenPtr pScreen; +{ + SetupScreen (pScreen); + + if (!pPriv) + return; + if (!pPriv->events && !pPriv->hasWindow) { + xfree (pPriv); + SetScreenPrivate (pScreen, NULL); + } +} + +static XF86VidModeScreenPrivatePtr +MakeScreenPrivate (pScreen) + ScreenPtr pScreen; +{ + SetupScreen (pScreen); + + if (pPriv) + return pPriv; + pPriv = New (XF86VidModeScreenPrivateRec); + if (!pPriv) + return 0; + pPriv->events = 0; + pPriv->hasWindow = FALSE; + SetScreenPrivate (pScreen, pPriv); + return pPriv; +} + +static unsigned long +getEventMask (ScreenPtr pScreen, ClientPtr client) +{ + SetupScreen(pScreen); + XF86VidModeEventPtr pEv; + + if (!pPriv) + return 0; + for (pEv = pPriv->events; pEv; pEv = pEv->next) + if (pEv->client == client) + return pEv->mask; + return 0; +} + +static Bool +setEventMask (ScreenPtr pScreen, ClientPtr client, unsigned long mask) +{ + SetupScreen(pScreen); + XF86VidModeEventPtr pEv, *pPrev; + + if (getEventMask (pScreen, client) == mask) + return TRUE; + if (!pPriv) { + pPriv = MakeScreenPrivate (pScreen); + if (!pPriv) + return FALSE; + } + for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next) + if (pEv->client == client) + break; + if (mask == 0) { + *pPrev = pEv->next; + xfree (pEv); + CheckScreenPrivate (pScreen); + } else { + if (!pEv) { + pEv = New (ScreenSaverEventRec); + if (!pEv) { + CheckScreenPrivate (pScreen); + return FALSE; + } + *pPrev = pEv; + pEv->next = NULL; + pEv->client = client; + pEv->screen = pScreen; + pEv->resource = FakeClientID (client->index); + } + pEv->mask = mask; + } + return TRUE; +} + +static int +XF86VidModeFreeEvents(pointer value, XID id) +{ + XF86VidModeEventPtr pOld = (XF86VidModeEventPtr)value; + ScreenPtr pScreen = pOld->screen; + SetupScreen (pScreen); + XF86VidModeEventPtr pEv, *pPrev; + + if (!pPriv) + return TRUE; + for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next) + if (pEv == pOld) + break; + if (!pEv) + return TRUE; + *pPrev = pEv->next; + xfree (pEv); + CheckScreenPrivate (pScreen); + return TRUE; +} + +static void +SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced) +{ + XF86VidModeScreenPrivatePtr pPriv; + XF86VidModeEventPtr pEv; + unsigned long mask; + xXF86VidModeNotifyEvent ev; + ClientPtr client; + int kind; + + UpdateCurrentTimeIf (); + mask = XF86VidModeNotifyMask; + pScreen = screenInfo.screens[pScreen->myNum]; + pPriv = GetScreenPrivate(pScreen); + if (!pPriv) + return; + kind = XF86VidModeModeChange; + for (pEv = pPriv->events; pEv; pEv = pEv->next) + { + client = pEv->client; + if (client->clientGone) + continue; + if (!(pEv->mask & mask)) + continue; + ev.type = XF86VidModeNotify + XF86VidModeEventBase; + ev.state = state; + ev.sequenceNumber = client->sequence; + ev.timestamp = currentTime.milliseconds; + ev.root = WindowTable[pScreen->myNum]->drawable.id; + ev.kind = kind; + ev.forced = forced; + WriteEventsToClient (client, 1, (xEvent *) &ev); + } +} + +static void +SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent *from, + xXF86VidModeNotifyEvent *to) +{ + to->type = from->type; + to->state = from->state; + cpswaps (from->sequenceNumber, to->sequenceNumber); + cpswapl (from->timestamp, to->timestamp); + cpswapl (from->root, to->root); + to->kind = from->kind; + to->forced = from->forced; +} +#endif + +static int +ProcXF86VidModeQueryVersion(ClientPtr client) +{ + xXF86VidModeQueryVersionReply rep; + register int n; + + DEBUG_P("XF86VidModeQueryVersion"); + + REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XF86VIDMODE_MAJOR_VERSION; + rep.minorVersion = XF86VIDMODE_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86VidModeGetModeLine(ClientPtr client) +{ + REQUEST(xXF86VidModeGetModeLineReq); + xXF86VidModeGetModeLineReply rep; + xXF86OldVidModeGetModeLineReply oldrep; + pointer mode; + register int n; + int dotClock; + int ver; + + DEBUG_P("XF86VidModeGetModeline"); + + ver = ClientMajorVersion(client); + REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); + rep.type = X_Reply; + if (ver < 2) { + rep.length = (SIZEOF(xXF86OldVidModeGetModeLineReply) - + SIZEOF(xGenericReply)) >> 2; + } else { + rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) - + SIZEOF(xGenericReply)) >> 2; + } + rep.sequenceNumber = client->sequence; + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + rep.dotclock = dotClock; + rep.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY); + rep.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART); + rep.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND); + rep.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL); + rep.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW); + rep.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY); + rep.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART); + rep.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND); + rep.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL); + rep.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS); + + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("GetModeLine - scrn: %d clock: %ld\n", + stuff->screen, (unsigned long)rep.dotclock); + ErrorF("GetModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n", + rep.hdisplay, rep.hsyncstart, + rep.hsyncend, rep.htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n", + rep.vdisplay, rep.vsyncstart, rep.vsyncend, + rep.vtotal, (unsigned long)rep.flags); + } + + /* + * Older servers sometimes had server privates that the VidMode + * extention made available. So to be compatiable pretend that + * there are no server privates to pass to the client + */ + rep.privsize = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.dotclock, n); + swaps(&rep.hdisplay, n); + swaps(&rep.hsyncstart, n); + swaps(&rep.hsyncend, n); + swaps(&rep.htotal, n); + swaps(&rep.hskew, n); + swaps(&rep.vdisplay, n); + swaps(&rep.vsyncstart, n); + swaps(&rep.vsyncend, n); + swaps(&rep.vtotal, n); + swapl(&rep.flags, n); + swapl(&rep.privsize, n); + } + if (ver < 2) { + oldrep.type = rep.type; + oldrep.sequenceNumber = rep.sequenceNumber; + oldrep.length = rep.length; + oldrep.dotclock = rep.dotclock; + oldrep.hdisplay = rep.hdisplay; + oldrep.hsyncstart = rep.hsyncstart; + oldrep.hsyncend = rep.hsyncend; + oldrep.htotal = rep.htotal; + oldrep.vdisplay = rep.vdisplay; + oldrep.vsyncstart = rep.vsyncstart; + oldrep.vsyncend = rep.vsyncend; + oldrep.vtotal = rep.vtotal; + oldrep.flags = rep.flags; + oldrep.privsize = rep.privsize; + WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply), + (char *)&oldrep); + } else { + WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), + (char *)&rep); + } + return (client->noClientException); +} + +static int +ProcXF86VidModeGetAllModeLines(ClientPtr client) +{ + REQUEST(xXF86VidModeGetAllModeLinesReq); + xXF86VidModeGetAllModeLinesReply rep; + xXF86VidModeModeInfo mdinf; + xXF86OldVidModeModeInfo oldmdinf; + pointer mode; + int modecount, dotClock; + register int n; + int ver; + + DEBUG_P("XF86VidModeGetAllModelines"); + + REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + ver = ClientMajorVersion(client); + + modecount = VidModeGetNumOfModes(stuff->screen); + if (modecount < 1) + return (VidModeErrorBase + XF86VidModeExtensionDisabled); + + if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + rep.type = X_Reply; + rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) - + SIZEOF(xGenericReply); + if (ver < 2) + rep.length += modecount * sizeof(xXF86OldVidModeModeInfo); + else + rep.length += modecount * sizeof(xXF86VidModeModeInfo); + rep.length >>= 2; + rep.sequenceNumber = client->sequence; + rep.modecount = modecount; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.modecount, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), (char *)&rep); + + do { + mdinf.dotclock = dotClock; + mdinf.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY); + mdinf.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART); + mdinf.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND); + mdinf.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL); + mdinf.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW); + mdinf.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY); + mdinf.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART); + mdinf.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND); + mdinf.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL); + mdinf.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS); + mdinf.privsize = 0; + if (client->swapped) { + swapl(&mdinf.dotclock, n); + swaps(&mdinf.hdisplay, n); + swaps(&mdinf.hsyncstart, n); + swaps(&mdinf.hsyncend, n); + swaps(&mdinf.htotal, n); + swaps(&mdinf.hskew, n); + swaps(&mdinf.vdisplay, n); + swaps(&mdinf.vsyncstart, n); + swaps(&mdinf.vsyncend, n); + swaps(&mdinf.vtotal, n); + swapl(&mdinf.flags, n); + swapl(&mdinf.privsize, n); + } + if (ver < 2) { + oldmdinf.dotclock = mdinf.dotclock; + oldmdinf.hdisplay = mdinf.hdisplay; + oldmdinf.hsyncstart = mdinf.hsyncstart; + oldmdinf.hsyncend = mdinf.hsyncend; + oldmdinf.htotal = mdinf.htotal; + oldmdinf.vdisplay = mdinf.vdisplay; + oldmdinf.vsyncstart = mdinf.vsyncstart; + oldmdinf.vsyncend = mdinf.vsyncend; + oldmdinf.vtotal = mdinf.vtotal; + oldmdinf.flags = mdinf.flags; + oldmdinf.privsize = mdinf.privsize; + WriteToClient(client, sizeof(xXF86OldVidModeModeInfo), + (char *)&oldmdinf); + } else { + WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf); + } + + } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); + + return (client->noClientException); +} + +#define MODEMATCH(mode,stuff) \ + (VidModeGetModeValue(mode, VIDMODE_H_DISPLAY) == stuff->hdisplay \ + && VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART) == stuff->hsyncstart \ + && VidModeGetModeValue(mode, VIDMODE_H_SYNCEND) == stuff->hsyncend \ + && VidModeGetModeValue(mode, VIDMODE_H_TOTAL) == stuff->htotal \ + && VidModeGetModeValue(mode, VIDMODE_V_DISPLAY) == stuff->vdisplay \ + && VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART) == stuff->vsyncstart \ + && VidModeGetModeValue(mode, VIDMODE_V_SYNCEND) == stuff->vsyncend \ + && VidModeGetModeValue(mode, VIDMODE_V_TOTAL) == stuff->vtotal \ + && VidModeGetModeValue(mode, VIDMODE_FLAGS) == stuff->flags ) + +static int +ProcXF86VidModeAddModeLine(ClientPtr client) +{ + REQUEST(xXF86VidModeAddModeLineReq); + xXF86OldVidModeAddModeLineReq *oldstuff = + (xXF86OldVidModeAddModeLineReq *)client->requestBuffer; + xXF86VidModeAddModeLineReq newstuff; + pointer mode; + int len; + int dotClock; + int ver; + + DEBUG_P("XF86VidModeAddModeline"); + + ver = ClientMajorVersion(client); + if (ver < 2) { + /* convert from old format */ + stuff = &newstuff; + stuff->length = oldstuff->length; + stuff->screen = oldstuff->screen; + stuff->dotclock = oldstuff->dotclock; + stuff->hdisplay = oldstuff->hdisplay; + stuff->hsyncstart = oldstuff->hsyncstart; + stuff->hsyncend = oldstuff->hsyncend; + stuff->htotal = oldstuff->htotal; + stuff->hskew = 0; + stuff->vdisplay = oldstuff->vdisplay; + stuff->vsyncstart = oldstuff->vsyncstart; + stuff->vsyncend = oldstuff->vsyncend; + stuff->vtotal = oldstuff->vtotal; + stuff->flags = oldstuff->flags; + stuff->privsize = oldstuff->privsize; + stuff->after_dotclock = oldstuff->after_dotclock; + stuff->after_hdisplay = oldstuff->after_hdisplay; + stuff->after_hsyncstart = oldstuff->after_hsyncstart; + stuff->after_hsyncend = oldstuff->after_hsyncend; + stuff->after_htotal = oldstuff->after_htotal; + stuff->after_hskew = 0; + stuff->after_vdisplay = oldstuff->after_vdisplay; + stuff->after_vsyncstart = oldstuff->after_vsyncstart; + stuff->after_vsyncend = oldstuff->after_vsyncend; + stuff->after_vtotal = oldstuff->after_vtotal; + stuff->after_flags = oldstuff->after_flags; + } + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("AddModeLine - scrn: %d clock: %ld\n", + (int)stuff->screen, (unsigned long)stuff->dotclock); + ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, (unsigned long)stuff->flags); + ErrorF(" after - scrn: %d clock: %ld\n", + (int)stuff->screen, (unsigned long)stuff->after_dotclock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->after_hdisplay, stuff->after_hsyncstart, + stuff->after_hsyncend, stuff->after_htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n", + stuff->after_vdisplay, stuff->after_vsyncstart, + stuff->after_vsyncend, stuff->after_vtotal, + (unsigned long)stuff->after_flags); + } + + if (ver < 2) { + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq); + len = client->req_len - (sizeof(xXF86OldVidModeAddModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2); + } + if (len != stuff->privsize) + return BadLength; + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (stuff->hsyncstart < stuff->hdisplay || + stuff->hsyncend < stuff->hsyncstart || + stuff->htotal < stuff->hsyncend || + stuff->vsyncstart < stuff->vdisplay || + stuff->vsyncend < stuff->vsyncstart || + stuff->vtotal < stuff->vsyncend) + return BadValue; + + if (stuff->after_hsyncstart < stuff->after_hdisplay || + stuff->after_hsyncend < stuff->after_hsyncstart || + stuff->after_htotal < stuff->after_hsyncend || + stuff->after_vsyncstart < stuff->after_vdisplay || + stuff->after_vsyncend < stuff->after_vsyncstart || + stuff->after_vtotal < stuff->after_vsyncend) + return BadValue; + + if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) { + Bool found = FALSE; + if (VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) { + do { + if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) + == dotClock) && MODEMATCH(mode, stuff)) { + found = TRUE; + break; + } + } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); + } + if (!found) + return BadValue; + } + + + mode = VidModeCreateMode(); + if (mode == NULL) + return BadValue; + + VidModeSetModeValue(mode, VIDMODE_CLOCK, stuff->dotclock); + VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay); + VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart); + VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend); + VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal); + VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew); + VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay); + VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart); + VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend); + VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal); + VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags); + + if (stuff->privsize) + ErrorF("AddModeLine - Privates in request have been ignored\n"); + + /* Check that the mode is consistent with the monitor specs */ + switch (VidModeCheckModeForMonitor(stuff->screen, mode)) { + case MODE_OK: + break; + case MODE_HSYNC: + case MODE_H_ILLEGAL: + xfree(mode); + return VidModeErrorBase + XF86VidModeBadHTimings; + case MODE_VSYNC: + case MODE_V_ILLEGAL: + xfree(mode); + return VidModeErrorBase + XF86VidModeBadVTimings; + default: + xfree(mode); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + + /* Check that the driver is happy with the mode */ + if (VidModeCheckModeForDriver(stuff->screen, mode) != MODE_OK) { + xfree(mode); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + + VidModeSetCrtcForMode(stuff->screen, mode); + + VidModeAddModeline(stuff->screen, mode); + + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) + ErrorF("AddModeLine - Succeeded\n"); + return client->noClientException; +} + +static int +ProcXF86VidModeDeleteModeLine(ClientPtr client) +{ + REQUEST(xXF86VidModeDeleteModeLineReq); + xXF86OldVidModeDeleteModeLineReq *oldstuff = + (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer; + xXF86VidModeDeleteModeLineReq newstuff; + pointer mode; + int len, dotClock; + int ver; + + DEBUG_P("XF86VidModeDeleteModeline"); + + ver = ClientMajorVersion(client); + if (ver < 2) { + /* convert from old format */ + stuff = &newstuff; + stuff->length = oldstuff->length; + stuff->screen = oldstuff->screen; + stuff->dotclock = oldstuff->dotclock; + stuff->hdisplay = oldstuff->hdisplay; + stuff->hsyncstart = oldstuff->hsyncstart; + stuff->hsyncend = oldstuff->hsyncend; + stuff->htotal = oldstuff->htotal; + stuff->hskew = 0; + stuff->vdisplay = oldstuff->vdisplay; + stuff->vsyncstart = oldstuff->vsyncstart; + stuff->vsyncend = oldstuff->vsyncend; + stuff->vtotal = oldstuff->vtotal; + stuff->flags = oldstuff->flags; + stuff->privsize = oldstuff->privsize; + } + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("DeleteModeLine - scrn: %d clock: %ld\n", + (int)stuff->screen, (unsigned long)stuff->dotclock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, (unsigned long)stuff->flags); + } + + if (ver < 2) { + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq); + len = client->req_len - (sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2); + } + if (len != stuff->privsize) { + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, " + "len = %d, length = %d\n", + (unsigned long)client->req_len, + (int)sizeof(xXF86VidModeDeleteModeLineReq)>>2, + (unsigned long)stuff->privsize, len, stuff->length); + } + return BadLength; + } + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("Checking against clock: %d (%d)\n", + VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + VidModeGetModeValue(mode, VIDMODE_H_DISPLAY), + VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART), + VidModeGetModeValue(mode, VIDMODE_H_SYNCEND), + VidModeGetModeValue(mode, VIDMODE_H_TOTAL)); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + VidModeGetModeValue(mode, VIDMODE_V_DISPLAY), + VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART), + VidModeGetModeValue(mode, VIDMODE_V_SYNCEND), + VidModeGetModeValue(mode, VIDMODE_V_TOTAL), + VidModeGetModeValue(mode, VIDMODE_FLAGS)); + } + if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) && + MODEMATCH(mode, stuff)) + return BadValue; + + if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + do { + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("Checking against clock: %d (%d)\n", + VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + VidModeGetModeValue(mode, VIDMODE_H_DISPLAY), + VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART), + VidModeGetModeValue(mode, VIDMODE_H_SYNCEND), + VidModeGetModeValue(mode, VIDMODE_H_TOTAL)); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + VidModeGetModeValue(mode, VIDMODE_V_DISPLAY), + VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART), + VidModeGetModeValue(mode, VIDMODE_V_SYNCEND), + VidModeGetModeValue(mode, VIDMODE_V_TOTAL), + VidModeGetModeValue(mode, VIDMODE_FLAGS)); + } + if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) && + MODEMATCH(mode, stuff)) { + VidModeDeleteModeline(stuff->screen, mode); + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) + ErrorF("DeleteModeLine - Succeeded\n"); + return(client->noClientException); + } + } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); + + return BadValue; +} + +static int +ProcXF86VidModeModModeLine(ClientPtr client) +{ + REQUEST(xXF86VidModeModModeLineReq); + xXF86OldVidModeModModeLineReq *oldstuff = + (xXF86OldVidModeModModeLineReq *)client->requestBuffer; + xXF86VidModeModModeLineReq newstuff; + pointer mode, modetmp; + int len, dotClock; + int ver; + + DEBUG_P("XF86VidModeModModeline"); + + ver = ClientMajorVersion(client); + if (ver < 2 ) { + /* convert from old format */ + stuff = &newstuff; + stuff->length = oldstuff->length; + stuff->screen = oldstuff->screen; + stuff->hdisplay = oldstuff->hdisplay; + stuff->hsyncstart = oldstuff->hsyncstart; + stuff->hsyncend = oldstuff->hsyncend; + stuff->htotal = oldstuff->htotal; + stuff->hskew = 0; + stuff->vdisplay = oldstuff->vdisplay; + stuff->vsyncstart = oldstuff->vsyncstart; + stuff->vsyncend = oldstuff->vsyncend; + stuff->vtotal = oldstuff->vtotal; + stuff->flags = oldstuff->flags; + stuff->privsize = oldstuff->privsize; + } + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n", + (int)stuff->screen, stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, (unsigned long)stuff->flags); + } + + if (ver < 2) { + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq); + len = client->req_len - (sizeof(xXF86OldVidModeModModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2); + } + if (len != stuff->privsize) + return BadLength; + + if (stuff->hsyncstart < stuff->hdisplay || + stuff->hsyncend < stuff->hsyncstart || + stuff->htotal < stuff->hsyncend || + stuff->vsyncstart < stuff->vdisplay || + stuff->vsyncend < stuff->vsyncstart || + stuff->vtotal < stuff->vsyncend) + return BadValue; + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + modetmp = VidModeCreateMode(); + VidModeCopyMode(mode, modetmp); + + VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay); + VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart); + VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend); + VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal); + VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew); + VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay); + VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart); + VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend); + VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal); + VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags); + + if (stuff->privsize) + ErrorF("ModModeLine - Privates in request have been ignored\n"); + + /* Check that the mode is consistent with the monitor specs */ + switch (VidModeCheckModeForMonitor(stuff->screen, modetmp)) { + case MODE_OK: + break; + case MODE_HSYNC: + case MODE_H_ILLEGAL: + xfree(modetmp); + return VidModeErrorBase + XF86VidModeBadHTimings; + case MODE_VSYNC: + case MODE_V_ILLEGAL: + xfree(modetmp); + return VidModeErrorBase + XF86VidModeBadVTimings; + default: + xfree(modetmp); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + + /* Check that the driver is happy with the mode */ + if (VidModeCheckModeForDriver(stuff->screen, modetmp) != MODE_OK) { + xfree(modetmp); + return VidModeErrorBase + XF86VidModeModeUnsuitable; + } + xfree(modetmp); + + VidModeSetModeValue(mode, VIDMODE_H_DISPLAY, stuff->hdisplay); + VidModeSetModeValue(mode, VIDMODE_H_SYNCSTART, stuff->hsyncstart); + VidModeSetModeValue(mode, VIDMODE_H_SYNCEND, stuff->hsyncend); + VidModeSetModeValue(mode, VIDMODE_H_TOTAL, stuff->htotal); + VidModeSetModeValue(mode, VIDMODE_H_SKEW, stuff->hskew); + VidModeSetModeValue(mode, VIDMODE_V_DISPLAY, stuff->vdisplay); + VidModeSetModeValue(mode, VIDMODE_V_SYNCSTART, stuff->vsyncstart); + VidModeSetModeValue(mode, VIDMODE_V_SYNCEND, stuff->vsyncend); + VidModeSetModeValue(mode, VIDMODE_V_TOTAL, stuff->vtotal); + VidModeSetModeValue(mode, VIDMODE_FLAGS, stuff->flags); + + VidModeSetCrtcForMode(stuff->screen, mode); + VidModeSwitchMode(stuff->screen, mode); + + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) + ErrorF("ModModeLine - Succeeded\n"); + return(client->noClientException); +} + +static int +ProcXF86VidModeValidateModeLine(ClientPtr client) +{ + REQUEST(xXF86VidModeValidateModeLineReq); + xXF86OldVidModeValidateModeLineReq *oldstuff = + (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer; + xXF86VidModeValidateModeLineReq newstuff; + xXF86VidModeValidateModeLineReply rep; + pointer mode, modetmp = NULL; + int len, status, dotClock; + int ver; + + DEBUG_P("XF86VidModeValidateModeline"); + + ver = ClientMajorVersion(client); + if (ver < 2) { + /* convert from old format */ + stuff = &newstuff; + stuff->length = oldstuff->length; + stuff->screen = oldstuff->screen; + stuff->dotclock = oldstuff->dotclock; + stuff->hdisplay = oldstuff->hdisplay; + stuff->hsyncstart = oldstuff->hsyncstart; + stuff->hsyncend = oldstuff->hsyncend; + stuff->htotal = oldstuff->htotal; + stuff->hskew = 0; + stuff->vdisplay = oldstuff->vdisplay; + stuff->vsyncstart = oldstuff->vsyncstart; + stuff->vsyncend = oldstuff->vsyncend; + stuff->vtotal = oldstuff->vtotal; + stuff->flags = oldstuff->flags; + stuff->privsize = oldstuff->privsize; + } + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("ValidateModeLine - scrn: %d clock: %ld\n", + (int)stuff->screen, (unsigned long)stuff->dotclock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, (unsigned long)stuff->flags); + } + + if (ver < 2) { + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq); + len = client->req_len - + (sizeof(xXF86OldVidModeValidateModeLineReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2); + } + if (len != stuff->privsize) + return BadLength; + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + status = MODE_OK; + + if (stuff->hsyncstart < stuff->hdisplay || + stuff->hsyncend < stuff->hsyncstart || + stuff->htotal < stuff->hsyncend || + stuff->vsyncstart < stuff->vdisplay || + stuff->vsyncend < stuff->vsyncstart || + stuff->vtotal < stuff->vsyncend) + { + status = MODE_BAD; + goto status_reply; + } + + if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + modetmp = VidModeCreateMode(); + VidModeCopyMode(mode, modetmp); + + VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay); + VidModeSetModeValue(modetmp, VIDMODE_H_SYNCSTART, stuff->hsyncstart); + VidModeSetModeValue(modetmp, VIDMODE_H_SYNCEND, stuff->hsyncend); + VidModeSetModeValue(modetmp, VIDMODE_H_TOTAL, stuff->htotal); + VidModeSetModeValue(modetmp, VIDMODE_H_SKEW, stuff->hskew); + VidModeSetModeValue(modetmp, VIDMODE_V_DISPLAY, stuff->vdisplay); + VidModeSetModeValue(modetmp, VIDMODE_V_SYNCSTART, stuff->vsyncstart); + VidModeSetModeValue(modetmp, VIDMODE_V_SYNCEND, stuff->vsyncend); + VidModeSetModeValue(modetmp, VIDMODE_V_TOTAL, stuff->vtotal); + VidModeSetModeValue(modetmp, VIDMODE_FLAGS, stuff->flags); + if (stuff->privsize) + ErrorF("ValidateModeLine - Privates in request have been ignored\n"); + + /* Check that the mode is consistent with the monitor specs */ + if ((status = VidModeCheckModeForMonitor(stuff->screen, modetmp)) != MODE_OK) + goto status_reply; + + /* Check that the driver is happy with the mode */ + status = VidModeCheckModeForDriver(stuff->screen, modetmp); + +status_reply: + if(modetmp) + xfree(modetmp); + + rep.type = X_Reply; + rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply) + - SIZEOF(xGenericReply)) >> 2; + rep.sequenceNumber = client->sequence; + rep.status = status; + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), (char *)&rep); + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) + ErrorF("ValidateModeLine - Succeeded (status = %d)\n", status); + return(client->noClientException); +} + +static int +ProcXF86VidModeSwitchMode(ClientPtr client) +{ + REQUEST(xXF86VidModeSwitchModeReq); + + DEBUG_P("XF86VidModeSwitchMode"); + + REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + VidModeZoomViewport(stuff->screen, (short)stuff->zoom); + + return (client->noClientException); +} + +static int +ProcXF86VidModeSwitchToMode(ClientPtr client) +{ + REQUEST(xXF86VidModeSwitchToModeReq); + xXF86OldVidModeSwitchToModeReq *oldstuff = + (xXF86OldVidModeSwitchToModeReq *)client->requestBuffer; + xXF86VidModeSwitchToModeReq newstuff; + pointer mode; + int len, dotClock; + int ver; + + DEBUG_P("XF86VidModeSwitchToMode"); + + ver = ClientMajorVersion(client); + if (ver < 2) { + /* convert from old format */ + stuff = &newstuff; + stuff->length = oldstuff->length; + stuff->screen = oldstuff->screen; + stuff->dotclock = oldstuff->dotclock; + stuff->hdisplay = oldstuff->hdisplay; + stuff->hsyncstart = oldstuff->hsyncstart; + stuff->hsyncend = oldstuff->hsyncend; + stuff->htotal = oldstuff->htotal; + stuff->hskew = 0; + stuff->vdisplay = oldstuff->vdisplay; + stuff->vsyncstart = oldstuff->vsyncstart; + stuff->vsyncend = oldstuff->vsyncend; + stuff->vtotal = oldstuff->vtotal; + stuff->flags = oldstuff->flags; + stuff->privsize = oldstuff->privsize; + } + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("SwitchToMode - scrn: %d clock: %ld\n", + (int)stuff->screen, (unsigned long)stuff->dotclock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %ld\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, (unsigned long)stuff->flags); + } + + if (ver < 2) { + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq); + len = client->req_len - (sizeof(xXF86OldVidModeSwitchToModeReq) >> 2); + } else { + REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq); + len = client->req_len - (sizeof(xXF86VidModeSwitchToModeReq) >> 2); + } + if (len != stuff->privsize) + return BadLength; + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeGetCurrentModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) + && MODEMATCH(mode, stuff)) + return (client->noClientException); + + if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) + return BadValue; + + do { + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { + ErrorF("Checking against clock: %d (%d)\n", + VidModeGetModeValue(mode, VIDMODE_CLOCK), dotClock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + VidModeGetModeValue(mode, VIDMODE_H_DISPLAY), + VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART), + VidModeGetModeValue(mode, VIDMODE_H_SYNCEND), + VidModeGetModeValue(mode, VIDMODE_H_TOTAL)); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + VidModeGetModeValue(mode, VIDMODE_V_DISPLAY), + VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART), + VidModeGetModeValue(mode, VIDMODE_V_SYNCEND), + VidModeGetModeValue(mode, VIDMODE_V_TOTAL), + VidModeGetModeValue(mode, VIDMODE_FLAGS)); + } + if ((VidModeGetDotClock(stuff->screen, stuff->dotclock) == dotClock) && + MODEMATCH(mode, stuff)) { + + if (!VidModeSwitchMode(stuff->screen, mode)) + return BadValue; + + if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) + ErrorF("SwitchToMode - Succeeded\n"); + return(client->noClientException); + } + } while (VidModeGetNextModeline(stuff->screen, &mode, &dotClock)); + + return BadValue; +} + +static int +ProcXF86VidModeLockModeSwitch(ClientPtr client) +{ + REQUEST(xXF86VidModeLockModeSwitchReq); + + REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq); + + DEBUG_P("XF86VidModeLockModeSwitch"); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeLockZoom(stuff->screen, (short)stuff->lock)) + return VidModeErrorBase + XF86VidModeZoomLocked; + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetMonitor(ClientPtr client) +{ + REQUEST(xXF86VidModeGetMonitorReq); + xXF86VidModeGetMonitorReply rep; + register int n; + CARD32 *hsyncdata, *vsyncdata; + int i, nHsync, nVrefresh; + pointer monitor; + + DEBUG_P("XF86VidModeGetMonitor"); + + REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeGetMonitor(stuff->screen, &monitor)) + return BadValue; + + nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i; + nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i; + + rep.type = X_Reply; + if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr) + rep.vendorLength = strlen((char *)(VidModeGetMonitorValue(monitor, + VIDMODE_MON_VENDOR, 0)).ptr); + else + rep.vendorLength = 0; + if ((char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr) + rep.modelLength = strlen((char *)(VidModeGetMonitorValue(monitor, + VIDMODE_MON_MODEL, 0)).ptr); + else + rep.modelLength = 0; + rep.length = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) + + (nHsync + nVrefresh) * sizeof(CARD32) + + ((rep.vendorLength + 3) & ~3) + + ((rep.modelLength + 3) & ~3)) >> 2; + rep.sequenceNumber = client->sequence; + rep.nhsync = nHsync; + rep.nvsync = nVrefresh; + hsyncdata = xalloc(nHsync * sizeof(CARD32)); + if (!hsyncdata) { + return BadAlloc; + } + + vsyncdata = xalloc(nVrefresh * sizeof(CARD32)); + if (!vsyncdata) { + xfree(hsyncdata); + return BadAlloc; + } + + for (i = 0; i < nHsync; i++) { + hsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor, + VIDMODE_MON_HSYNC_LO, i)).f | + (unsigned short)(VidModeGetMonitorValue(monitor, + VIDMODE_MON_HSYNC_HI, i)).f << 16; + } + for (i = 0; i < nVrefresh; i++) { + vsyncdata[i] = (unsigned short)(VidModeGetMonitorValue(monitor, + VIDMODE_MON_VREFRESH_LO, i)).f | + (unsigned short)(VidModeGetMonitorValue(monitor, + VIDMODE_MON_VREFRESH_HI, i)).f << 16; + } + + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + } + WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *)&rep); + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; + WriteSwappedDataToClient(client, nHsync * sizeof(CARD32), + hsyncdata); + WriteSwappedDataToClient(client, nVrefresh * sizeof(CARD32), + vsyncdata); + if (rep.vendorLength) + WriteToClient(client, rep.vendorLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr); + if (rep.modelLength) + WriteToClient(client, rep.modelLength, (char *)(VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr); + + xfree(hsyncdata); + xfree(vsyncdata); + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetViewPort(ClientPtr client) +{ + REQUEST(xXF86VidModeGetViewPortReq); + xXF86VidModeGetViewPortReply rep; + int x, y, n; + + DEBUG_P("XF86VidModeGetViewPort"); + + REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + VidModeGetViewPort(stuff->screen, &x, &y); + rep.x = x; + rep.y = y; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.x, n); + swapl(&rep.y, n); + } + WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86VidModeSetViewPort(ClientPtr client) +{ + REQUEST(xXF86VidModeSetViewPortReq); + + DEBUG_P("XF86VidModeSetViewPort"); + + REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeSetViewPort(stuff->screen, stuff->x, stuff->y)) + return BadValue; + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetDotClocks(ClientPtr client) +{ + REQUEST(xXF86VidModeGetDotClocksReq); + xXF86VidModeGetDotClocksReply rep; + register int n; + int numClocks; + CARD32 dotclock; + int *Clocks = NULL; + Bool ClockProg; + + DEBUG_P("XF86VidModeGetDotClocks"); + + REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg); + + rep.type = X_Reply; + rep.length = (SIZEOF(xXF86VidModeGetDotClocksReply) + - SIZEOF(xGenericReply) + numClocks) >> 2; + rep.sequenceNumber = client->sequence; + rep.clocks = numClocks; + rep.maxclocks = MAXCLOCKS; + rep.flags = 0; + + if (!ClockProg) { + Clocks = xalloc(numClocks * sizeof(int)); + if (!Clocks) + return BadValue; + if (!VidModeGetClocks(stuff->screen, Clocks)) { + xfree(Clocks); + return BadValue; + } + } + + if (ClockProg) { + rep.flags |= CLKFLAG_PROGRAMABLE; + } + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.clocks, n); + swapl(&rep.maxclocks, n); + swapl(&rep.flags, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), (char *)&rep); + if (!ClockProg) { + for (n = 0; n < numClocks; n++) { + dotclock = *Clocks++; + if (client->swapped) { + WriteSwappedDataToClient(client, 4, (char *)&dotclock); + } else { + WriteToClient(client, 4, (char *)&dotclock); + } + } + } + + xfree(Clocks); + return (client->noClientException); +} + +static int +ProcXF86VidModeSetGamma(ClientPtr client) +{ + REQUEST(xXF86VidModeSetGammaReq); + + DEBUG_P("XF86VidModeSetGamma"); + + REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if (!VidModeSetGamma(stuff->screen, ((float)stuff->red)/10000., + ((float)stuff->green)/10000., ((float)stuff->blue)/10000.)) + return BadValue; + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetGamma(ClientPtr client) +{ + REQUEST(xXF86VidModeGetGammaReq); + xXF86VidModeGetGammaReply rep; + register int n; + float red, green, blue; + + DEBUG_P("XF86VidModeGetGamma"); + + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + if (!VidModeGetGamma(stuff->screen, &red, &green, &blue)) + return BadValue; + rep.red = (CARD32)(red * 10000.); + rep.green = (CARD32)(green * 10000.); + rep.blue = (CARD32)(blue * 10000.); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.red, n); + swapl(&rep.green, n); + swapl(&rep.blue, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86VidModeSetGammaRamp(ClientPtr client) +{ + CARD16 *r, *g, *b; + int length; + REQUEST(xXF86VidModeSetGammaRampReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if(stuff->size != VidModeGetGammaRampSize(stuff->screen)) + return BadValue; + + length = (stuff->size + 1) & ~1; + + REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6); + + r = (CARD16*)&stuff[1]; + g = r + length; + b = g + length; + + if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b)) + return BadValue; + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetGammaRamp(ClientPtr client) +{ + CARD16 *ramp = NULL; + int n, length, i; + xXF86VidModeGetGammaRampReply rep; + REQUEST(xXF86VidModeGetGammaRampReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + if(stuff->size != VidModeGetGammaRampSize(stuff->screen)) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq); + + length = (stuff->size + 1) & ~1; + + if(stuff->size) { + if(!(ramp = xalloc(length * 3 * sizeof(CARD16)))) + return BadAlloc; + + if (!VidModeGetGammaRamp(stuff->screen, stuff->size, + ramp, ramp + length, ramp + (length * 2))) { + xfree(ramp); + return BadValue; + } + } + + rep.type = X_Reply; + rep.length = (length >> 1) * 3; + rep.sequenceNumber = client->sequence; + rep.size = stuff->size; + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.size, n); + for(i = 0; i < length * 3; i++) + swaps(&ramp[i],n); + } + WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep); + + if(stuff->size) { + WriteToClient(client, rep.length << 2, (char*)ramp); + xfree(ramp); + } + + return (client->noClientException); +} + + +static int +ProcXF86VidModeGetGammaRampSize(ClientPtr client) +{ + xXF86VidModeGetGammaRampSizeReply rep; + int n; + REQUEST(xXF86VidModeGetGammaRampSizeReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.size = VidModeGetGammaRampSize(stuff->screen); + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.size, n); + } + WriteToClient(client,sizeof(xXF86VidModeGetGammaRampSizeReply),(char*)&rep); + + return (client->noClientException); +} + +static int +ProcXF86VidModeGetPermissions(ClientPtr client) +{ + xXF86VidModeGetPermissionsReply rep; + int n; + REQUEST(xXF86VidModeGetPermissionsReq); + + if(stuff->screen >= screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.permissions = XF86VM_READ_PERMISSION; + if (xf86GetVidModeEnabled() && + (xf86GetVidModeAllowNonLocal() || LocalClient (client))) { + rep.permissions |= XF86VM_WRITE_PERMISSION; + } + if(client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.permissions, n); + } + WriteToClient(client,sizeof(xXF86VidModeGetPermissionsReply),(char*)&rep); + + return (client->noClientException); +} + + +static int +ProcXF86VidModeSetClientVersion(ClientPtr client) +{ + REQUEST(xXF86VidModeSetClientVersionReq); + + VidModePrivPtr pPriv; + + DEBUG_P("XF86VidModeSetClientVersion"); + + REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); + + if ((pPriv = VM_GETPRIV(client)) == NULL) { + pPriv = xalloc(sizeof(VidModePrivRec)); + if (!pPriv) + return BadAlloc; + VM_SETPRIV(client, pPriv); + } + pPriv->major = stuff->major; + pPriv->minor = stuff->minor; + + return (client->noClientException); +} + +static int +ProcXF86VidModeDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86VidModeQueryVersion: + return ProcXF86VidModeQueryVersion(client); + case X_XF86VidModeGetModeLine: + return ProcXF86VidModeGetModeLine(client); + case X_XF86VidModeGetMonitor: + return ProcXF86VidModeGetMonitor(client); + case X_XF86VidModeGetAllModeLines: + return ProcXF86VidModeGetAllModeLines(client); + case X_XF86VidModeValidateModeLine: + return ProcXF86VidModeValidateModeLine(client); + case X_XF86VidModeGetViewPort: + return ProcXF86VidModeGetViewPort(client); + case X_XF86VidModeGetDotClocks: + return ProcXF86VidModeGetDotClocks(client); + case X_XF86VidModeSetClientVersion: + return ProcXF86VidModeSetClientVersion(client); + case X_XF86VidModeGetGamma: + return ProcXF86VidModeGetGamma(client); + case X_XF86VidModeGetGammaRamp: + return ProcXF86VidModeGetGammaRamp(client); + case X_XF86VidModeGetGammaRampSize: + return ProcXF86VidModeGetGammaRampSize(client); + case X_XF86VidModeGetPermissions: + return ProcXF86VidModeGetPermissions(client); + default: + if (!xf86GetVidModeEnabled()) + return VidModeErrorBase + XF86VidModeExtensionDisabled; + if (xf86GetVidModeAllowNonLocal() || LocalClient (client)) { + switch (stuff->data) { + case X_XF86VidModeAddModeLine: + return ProcXF86VidModeAddModeLine(client); + case X_XF86VidModeDeleteModeLine: + return ProcXF86VidModeDeleteModeLine(client); + case X_XF86VidModeModModeLine: + return ProcXF86VidModeModModeLine(client); + case X_XF86VidModeSwitchMode: + return ProcXF86VidModeSwitchMode(client); + case X_XF86VidModeSwitchToMode: + return ProcXF86VidModeSwitchToMode(client); + case X_XF86VidModeLockModeSwitch: + return ProcXF86VidModeLockModeSwitch(client); + case X_XF86VidModeSetViewPort: + return ProcXF86VidModeSetViewPort(client); + case X_XF86VidModeSetGamma: + return ProcXF86VidModeSetGamma(client); + case X_XF86VidModeSetGammaRamp: + return ProcXF86VidModeSetGammaRamp(client); + default: + return BadRequest; + } + } else + return VidModeErrorBase + XF86VidModeClientNotLocal; + } +} + +static int +SProcXF86VidModeQueryVersion(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeQueryVersionReq); + swaps(&stuff->length, n); + return ProcXF86VidModeQueryVersion(client); +} + +static int +SProcXF86VidModeGetModeLine(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetModeLineReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetModeLine(client); +} + +static int +SProcXF86VidModeGetAllModeLines(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetAllModeLinesReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetAllModeLines(client); +} + +static int +SProcXF86VidModeAddModeLine(ClientPtr client) +{ + xXF86OldVidModeAddModeLineReq *oldstuff = + (xXF86OldVidModeAddModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeAddModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeAddModeLine(client); +} + +static int +SProcXF86VidModeDeleteModeLine(ClientPtr client) +{ + xXF86OldVidModeDeleteModeLineReq *oldstuff = + (xXF86OldVidModeDeleteModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeDeleteModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeDeleteModeLine(client); +} + +static int +SProcXF86VidModeModModeLine(ClientPtr client) +{ + xXF86OldVidModeModModeLineReq *oldstuff = + (xXF86OldVidModeModModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeModModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeModModeLine(client); +} + +static int +SProcXF86VidModeValidateModeLine(ClientPtr client) +{ + xXF86OldVidModeValidateModeLineReq *oldstuff = + (xXF86OldVidModeValidateModeLineReq *)client->requestBuffer; + int ver; + register int n; + + REQUEST(xXF86VidModeValidateModeLineReq); + ver = ClientMajorVersion(client); + if (ver < 2) { + swaps(&oldstuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq); + swapl(&oldstuff->screen, n); + swaps(&oldstuff->hdisplay, n); + swaps(&oldstuff->hsyncstart, n); + swaps(&oldstuff->hsyncend, n); + swaps(&oldstuff->htotal, n); + swaps(&oldstuff->vdisplay, n); + swaps(&oldstuff->vsyncstart, n); + swaps(&oldstuff->vsyncend, n); + swaps(&oldstuff->vtotal, n); + swapl(&oldstuff->flags, n); + swapl(&oldstuff->privsize, n); + SwapRestL(oldstuff); + } else { + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->hskew, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + } + return ProcXF86VidModeValidateModeLine(client); +} + +static int +SProcXF86VidModeSwitchMode(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSwitchModeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq); + swaps(&stuff->screen, n); + swaps(&stuff->zoom, n); + return ProcXF86VidModeSwitchMode(client); +} + +static int +SProcXF86VidModeSwitchToMode(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSwitchToModeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeSwitchToMode(client); +} + +static int +SProcXF86VidModeLockModeSwitch(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeLockModeSwitchReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq); + swaps(&stuff->screen, n); + swaps(&stuff->lock, n); + return ProcXF86VidModeLockModeSwitch(client); +} + +static int +SProcXF86VidModeGetMonitor(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetMonitorReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetMonitor(client); +} + +static int +SProcXF86VidModeGetViewPort(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetViewPortReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetViewPort(client); +} + +static int +SProcXF86VidModeSetViewPort(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSetViewPortReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq); + swaps(&stuff->screen, n); + swapl(&stuff->x, n); + swapl(&stuff->y, n); + return ProcXF86VidModeSetViewPort(client); +} + +static int +SProcXF86VidModeGetDotClocks(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetDotClocksReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetDotClocks(client); +} + +static int +SProcXF86VidModeSetClientVersion(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSetClientVersionReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); + swaps(&stuff->major, n); + swaps(&stuff->minor, n); + return ProcXF86VidModeSetClientVersion(client); +} + +static int +SProcXF86VidModeSetGamma(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeSetGammaReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq); + swaps(&stuff->screen, n); + swapl(&stuff->red, n); + swapl(&stuff->green, n); + swapl(&stuff->blue, n); + return ProcXF86VidModeSetGamma(client); +} + +static int +SProcXF86VidModeGetGamma(ClientPtr client) +{ + register int n; + REQUEST(xXF86VidModeGetGammaReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetGamma(client); +} + +static int +SProcXF86VidModeSetGammaRamp(ClientPtr client) +{ + CARD16 *ramp; + int length, n; + REQUEST(xXF86VidModeSetGammaRampReq); + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq); + swaps(&stuff->size, n); + swaps(&stuff->screen, n); + length = ((stuff->size + 1) & ~1) * 6; + REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length); + ramp = (CARD16*)&stuff[1]; + while(length--) { + swaps(ramp, n); + ramp++; + } + return ProcXF86VidModeSetGammaRamp(client); +} + +static int +SProcXF86VidModeGetGammaRamp(ClientPtr client) +{ + int n; + REQUEST(xXF86VidModeGetGammaRampReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq); + swaps(&stuff->size, n); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetGammaRamp(client); +} + +static int +SProcXF86VidModeGetGammaRampSize(ClientPtr client) +{ + int n; + REQUEST(xXF86VidModeGetGammaRampSizeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetGammaRampSize(client); +} + +static int +SProcXF86VidModeGetPermissions(ClientPtr client) +{ + int n; + REQUEST(xXF86VidModeGetPermissionsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetPermissions(client); +} + + +static int +SProcXF86VidModeDispatch(ClientPtr client) +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86VidModeQueryVersion: + return SProcXF86VidModeQueryVersion(client); + case X_XF86VidModeGetModeLine: + return SProcXF86VidModeGetModeLine(client); + case X_XF86VidModeGetMonitor: + return SProcXF86VidModeGetMonitor(client); + case X_XF86VidModeGetAllModeLines: + return SProcXF86VidModeGetAllModeLines(client); + case X_XF86VidModeGetViewPort: + return SProcXF86VidModeGetViewPort(client); + case X_XF86VidModeValidateModeLine: + return SProcXF86VidModeValidateModeLine(client); + case X_XF86VidModeGetDotClocks: + return SProcXF86VidModeGetDotClocks(client); + case X_XF86VidModeSetClientVersion: + return SProcXF86VidModeSetClientVersion(client); + case X_XF86VidModeGetGamma: + return SProcXF86VidModeGetGamma(client); + case X_XF86VidModeGetGammaRamp: + return SProcXF86VidModeGetGammaRamp(client); + case X_XF86VidModeGetGammaRampSize: + return SProcXF86VidModeGetGammaRampSize(client); + case X_XF86VidModeGetPermissions: + return SProcXF86VidModeGetPermissions(client); + default: + if (!xf86GetVidModeEnabled()) + return VidModeErrorBase + XF86VidModeExtensionDisabled; + if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) { + switch (stuff->data) { + case X_XF86VidModeAddModeLine: + return SProcXF86VidModeAddModeLine(client); + case X_XF86VidModeDeleteModeLine: + return SProcXF86VidModeDeleteModeLine(client); + case X_XF86VidModeModModeLine: + return SProcXF86VidModeModModeLine(client); + case X_XF86VidModeSwitchMode: + return SProcXF86VidModeSwitchMode(client); + case X_XF86VidModeSwitchToMode: + return SProcXF86VidModeSwitchToMode(client); + case X_XF86VidModeLockModeSwitch: + return SProcXF86VidModeLockModeSwitch(client); + case X_XF86VidModeSetViewPort: + return SProcXF86VidModeSetViewPort(client); + case X_XF86VidModeSetGamma: + return SProcXF86VidModeSetGamma(client); + case X_XF86VidModeSetGammaRamp: + return SProcXF86VidModeSetGammaRamp(client); + default: + return BadRequest; + } + } else + return VidModeErrorBase + XF86VidModeClientNotLocal; + } +} diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xvmod.c b/xorg-server/hw/xfree86/dixmods/extmod/xvmod.c new file mode 100644 index 000000000..6b3f1149a --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xvmod.c @@ -0,0 +1,23 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "misc.h" +#include "scrnintstr.h" +#include "gc.h" +#include +#include +#include "xvdix.h" +#include "xvmodproc.h" + +void +XvRegister() +{ + XvScreenInitProc = XvScreenInit; + XvGetScreenKeyProc = XvGetScreenKey; + XvGetRTPortProc = XvGetRTPort; + XvMCScreenInitProc = XvMCScreenInit; +} + diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h b/xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h new file mode 100644 index 000000000..b39c915b4 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/extmod/xvmodproc.h @@ -0,0 +1,13 @@ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "xvmcext.h" + +extern DevPrivateKey (*XvGetScreenKeyProc)(void); +extern unsigned long (*XvGetRTPortProc)(void); +extern int (*XvScreenInitProc)(ScreenPtr); +extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr); + +extern void XvRegister(void); diff --git a/xorg-server/hw/xfree86/dixmods/fbmodule.c b/xorg-server/hw/xfree86/dixmods/fbmodule.c new file mode 100644 index 000000000..4df2646dd --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/fbmodule.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" +#include "fb.h" + +static XF86ModuleVersionInfo VersRec = +{ +#ifdef FB_ACCESS_WRAPPER + "wfb", +#else + "fb", +#endif + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData FBPREFIX(ModuleData) = { &VersRec, NULL, NULL }; diff --git a/xorg-server/hw/xfree86/dixmods/ftmodule.c b/xorg-server/hw/xfree86/dixmods/ftmodule.c new file mode 100644 index 000000000..382c0b3b7 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/ftmodule.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 1998-2002 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" + +#include +#include "xf86Module.h" + +static MODULESETUPPROTO(freetypeSetup); + + /* + * This is the module data function that is accessed when loading + * libfreetype as a module. + */ + +static XF86ModuleVersionInfo VersRec = +{ + "freetype", + MODULEVENDORSTRING " & the After X-TT Project", + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 2, 1, 0, + ABI_CLASS_FONT, /* Font module */ + ABI_FONT_VERSION, + MOD_CLASS_FONT, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData freetypeModuleData = { &VersRec, freetypeSetup, NULL }; + +extern void FreeTypeRegisterFontFileFunctions(void); + +static FontModule freetypeModule = { + FreeTypeRegisterFontFileFunctions, + "FreeType", + NULL +}; + +static pointer +freetypeSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + freetypeModule.module = module; + LoadFont(&freetypeModule); + + /* Need a non-NULL return */ + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/dixmods/glxmodule.c b/xorg-server/hw/xfree86/dixmods/glxmodule.c new file mode 100644 index 000000000..f6fda4b07 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/glxmodule.c @@ -0,0 +1,122 @@ +/************************************************************************** + +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: + * Kevin E. Martin + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" +#include "xf86Priv.h" +#include "xf86.h" +#include "colormap.h" +#include "micmap.h" +#include "globals.h" +#include "glxserver.h" + +static MODULESETUPPROTO(glxSetup); + +static const char *initdeps[] = { "DOUBLE-BUFFER", "COMPOSITE", NULL }; + +static ExtensionModule GLXExt = +{ + GlxExtensionInit, + "GLX", + &noGlxExtension, + NULL, + initdeps +}; + +static XF86ModuleVersionInfo VersRec = +{ + "glx", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL }; + +static pointer +glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + __GLXprovider *provider; + + if (setupDone) { + if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } + + setupDone = TRUE; + + provider = LoaderSymbol("__glXDRISWRastProvider"); + if (provider == NULL) + return NULL; + GlxPushProvider(provider); + + xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n", + xf86Info.aiglx ? "enabled" : "disabled"); + if (xf86Info.aiglx) { + provider = LoaderSymbol("__glXDRIProvider"); + if (provider) + GlxPushProvider(provider); + provider = LoaderSymbol("__glXDRI2Provider"); + if (provider) + GlxPushProvider(provider); + } + + switch (xf86Info.glxVisuals) { + case XF86_GlxVisualsMinimal: + GlxSetVisualConfig(GLX_MINIMAL_VISUALS); + xf86Msg(xf86Info.aiglxFrom, "Exporting only minimal set of GLX visuals\n"); + break; + case XF86_GlxVisualsTypical: + GlxSetVisualConfig(GLX_TYPICAL_VISUALS); + xf86Msg(xf86Info.aiglxFrom, "Exporting typical set of GLX visuals\n"); + break; + case XF86_GlxVisualsAll: + GlxSetVisualConfig(GLX_ALL_VISUALS); + xf86Msg(xf86Info.aiglxFrom, "Exporting all GLX visuals\n"); + break; + } + + LoadExtension(&GLXExt, FALSE); + + return module; +} diff --git a/xorg-server/hw/xfree86/dixmods/mfbmodule.c b/xorg-server/hw/xfree86/dixmods/mfbmodule.c new file mode 100644 index 000000000..91539d709 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/mfbmodule.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" + +static XF86ModuleVersionInfo VersRec = +{ + "mfb", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData mfbModuleData = { &VersRec, NULL, NULL }; diff --git a/xorg-server/hw/xfree86/dixmods/recordmod.c b/xorg-server/hw/xfree86/dixmods/recordmod.c new file mode 100644 index 000000000..63d340e75 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/recordmod.c @@ -0,0 +1,44 @@ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" + +extern Bool noTestExtensions; + +static MODULESETUPPROTO(recordSetup); + +extern void RecordExtensionInit(INITARGS); + +static ExtensionModule recordExt = { + RecordExtensionInit, + "RECORD", + &noTestExtensions, + NULL, + NULL +}; + +static XF86ModuleVersionInfo VersRec = { + "record", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 13, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_EXTENSION, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData recordModuleData = { &VersRec, recordSetup, NULL }; + +static pointer +recordSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + LoadExtension(&recordExt, FALSE); + + /* Need a non-NULL return value to indicate success */ + return (pointer)1; +} + diff --git a/xorg-server/hw/xfree86/dixmods/shmodule.c b/xorg-server/hw/xfree86/dixmods/shmodule.c new file mode 100644 index 000000000..3136c0c05 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/shmodule.c @@ -0,0 +1,54 @@ +/* + * 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_XORG_CONFIG_H +#include +#endif + +#include "xf86Module.h" +#include +#include "scrnintstr.h" +#include "windowstr.h" +#include +#include "dixfontstr.h" +#include +#include "mi.h" +#include "regionstr.h" +#include "globals.h" +#include "gcstruct.h" +#include "shadow.h" + +static XF86ModuleVersionInfo VersRec = +{ + "shadow", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 1, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData shadowModuleData = { &VersRec, NULL, NULL }; diff --git a/xorg-server/hw/xfree86/dixmods/xf86XTrapModule.c b/xorg-server/hw/xfree86/dixmods/xf86XTrapModule.c new file mode 100644 index 000000000..e89d7751d --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/xf86XTrapModule.c @@ -0,0 +1,45 @@ +/* This is the xf86 module code for the DEC_XTRAP extension. */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "xf86Module.h" + +#include + +extern void DEC_XTRAPInit(INITARGS); + +static MODULESETUPPROTO(xtrapSetup); + +static ExtensionModule xtrapExt = +{ + DEC_XTRAPInit, + XTrapExtName, + NULL, + NULL, + NULL +}; + +static XF86ModuleVersionInfo xtrapVersRec = +{ + "xtrap", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, /* needs the server extension ABI */ + ABI_EXTENSION_VERSION, + MOD_CLASS_EXTENSION, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData xtrapModuleData = { &xtrapVersRec, xtrapSetup, NULL }; + +static pointer +xtrapSetup(pointer module, pointer opts, int *errmaj, int *errmin) { + LoadExtension(&xtrapExt, FALSE); + /* Need a non-NULL return value to indicate success */ + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/dixmods/xkbKillSrv.c b/xorg-server/hw/xfree86/dixmods/xkbKillSrv.c new file mode 100644 index 000000000..9074fd390 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/xkbKillSrv.c @@ -0,0 +1,55 @@ +/************************************************************ +Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting +documentation, and that the name of Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#define NEED_EVENTS 1 +#include +#include +#include +#include "inputstr.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include +#include + +#include "xf86.h" + +int +XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act) +{ + if (dev != inputInfo.keyboard) + xf86ProcessActionEvent(ACTION_TERMINATE, NULL); + + return 0; +} diff --git a/xorg-server/hw/xfree86/dixmods/xkbPrivate.c b/xorg-server/hw/xfree86/dixmods/xkbPrivate.c new file mode 100644 index 000000000..e0cd21739 --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/xkbPrivate.c @@ -0,0 +1,41 @@ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#define NEED_EVENTS 1 +#include +#include "windowstr.h" +#define XKBSRV_NEED_FILE_FUNCS +#include + +#include "xf86.h" + +int +XkbDDXPrivate(DeviceIntPtr dev,KeyCode key,XkbAction *act) +{ + XkbAnyAction *xf86act = &(act->any); + char msgbuf[XkbAnyActionDataSize+1]; + + if (xf86act->type == XkbSA_XFree86Private) { + memcpy(msgbuf, xf86act->data, XkbAnyActionDataSize); + msgbuf[XkbAnyActionDataSize]= '\0'; + if (strcasecmp(msgbuf, "-vmode")==0) + xf86ProcessActionEvent(ACTION_PREV_MODE, NULL); + else if (strcasecmp(msgbuf, "+vmode")==0) + xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL); + else if (strcasecmp(msgbuf, "ungrab")==0) + xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL); + else if (strcasecmp(msgbuf, "clsgrb")==0) + xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL); + else + xf86ProcessActionEvent(ACTION_MESSAGE, (void *) msgbuf); + } + + return 0; +} diff --git a/xorg-server/hw/xfree86/dixmods/xkbVT.c b/xorg-server/hw/xfree86/dixmods/xkbVT.c new file mode 100644 index 000000000..e6d69e2eb --- /dev/null +++ b/xorg-server/hw/xfree86/dixmods/xkbVT.c @@ -0,0 +1,65 @@ +/************************************************************ +Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting +documentation, and that the name of Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#define NEED_EVENTS 1 +#include +#include +#include +#include "inputstr.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include +#include + +#include "xf86.h" + +int +XkbDDXSwitchScreen(DeviceIntPtr dev,KeyCode key,XkbAction *act) +{ + int scrnnum = XkbSAScreen(&act->screen); + + if (act->screen.flags & XkbSA_SwitchApplication) { + if (act->screen.flags & XkbSA_SwitchAbsolute) + xf86ProcessActionEvent(ACTION_SWITCHSCREEN,(void *) &scrnnum); + else { + if (scrnnum < 0) + xf86ProcessActionEvent(ACTION_SWITCHSCREEN_PREV,NULL); + else + xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT,NULL); + } + } + + return 1; +} diff --git a/xorg-server/hw/xfree86/doc/Makefile.am b/xorg-server/hw/xfree86/doc/Makefile.am new file mode 100644 index 000000000..6d8f4d213 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/Makefile.am @@ -0,0 +1,10 @@ +if BUILDDOCS +SUBDIRS = devel man sgml +else +SUBDIRS = man +endif + +EXTRA_DIST = \ + README.DRI \ + README.fonts \ + README.rapidaccess diff --git a/xorg-server/hw/xfree86/doc/Makefile.in b/xorg-server/hw/xfree86/doc/Makefile.in new file mode 100644 index 000000000..434646e22 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/Makefile.in @@ -0,0 +1,696 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/doc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = man devel sgml +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +@BUILDDOCS_FALSE@SUBDIRS = man +@BUILDDOCS_TRUE@SUBDIRS = devel man sgml +EXTRA_DIST = \ + README.DRI \ + README.fonts \ + README.rapidaccess + +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/doc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/doc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + ctags ctags-recursive distclean distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/doc/README.DRI b/xorg-server/hw/xfree86/doc/README.DRI new file mode 100644 index 000000000..7fc52eb32 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/README.DRI @@ -0,0 +1,1256 @@ + DRI User Guide + + VA Linux Systems, Inc. Professional Services - Graphics. + + 15 June 2001 + +1. Preamble + +1.1 Copyright + +Copyright 2000-2001 by VA Linux Systems, Inc. All Rights Reserved. + +Permission is granted to make and distribute verbatim copies of this document +provided the copyright notice and this permission notice are preserved on all +copies. + +1.2 Trademarks + +OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics, +Inc. Unix is a registered trademark of The Open Group. The `X' device and X +Window System are trademarks of The Open Group. XFree86 is a trademark of +The XFree86 Project. Linux is a registered trademark of Linus Torvalds. +Intel is a registered trademark of Intel Corporation. 3Dlabs, GLINT, and +Oxygen are either registered trademarks or trademarks of 3Dlabs Inc. Ltd. +3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of 3dfx Inter- +active, Incorporated. Matrox is a registered trademark of Matrox Electronic +Systems Ltd. ATI Rage and Radeon are registered trademarks of ATI Technolo- +gies, Inc. All other trademarks mentioned are the property of their respec- +tive owners. + +2. Introduction + +With XFree86 4.x and the Direct Rendering Interface (DRI), hardware acceler- +ated 3D graphics can be considered a standard feature on Linux workstations. +Support for other operating systems, such as FreeBSD, is underway. + +This document describes how to use the DRI system and troubleshoot problems +which may occur. Readers should have a basic understanding of Linux, X and +OpenGL. See the resources section at the end for more documentation and +software downloads. + +This document does not cover compilation or installation of XFree86 4.x. It +is assumed that you've already installed a Linux distribution which includes +XFree86 4.x or that you're an experienced Linux developer who has compiled +the DRI for himself. DRI download, compilation and installation instructions +can be found at http://dri.sourceforge.net/DRIcompile.html + +Edits, corrections and updates to this document may be mailed to . + +3. Supported Architectures & Hardware + +3.1 CPU Architectures + +The architectures currently supported by the DRI have grown from the initial +Intel i386 systems to now include the Alpha Processor and the Sun SPARC +machines. + +Intel's SSE (a.k.a. Katmai) instructions are used in optimized vertex trans- +formation functions in Mesa-based drivers. This requires a recent Linux ker- +nel both at compile and runtime. See the DRI Compile Guide for compile-time +requirements. At runtime a check is made to determine if the CPU can execute +SSE instructions. They're disabled otherwise. + +AMD's 3DNow! instructions are also used in optimized vertex transformation +functions in the Mesa-based DRI drivers. 3DNow! is supported in most ver- +sions of Linux. Like the SSE optimizations, a runtime check is made to +determine if the CPU can execute 3DNow! instructions. + +Alpha-based systems can use Compaq's optimized math library for improved 3D +performance. See the DRI Compilation Guide for details. + +3.2 Graphics Hardware + +XFree86 4.2 (or later versions) includes 3D acceleration for the following +graphics hardware: + + o 3dfx, supported on Intel x86, AMD and Alpha: + + o Voodoo5 5500 + + o Voodoo4 4500 + + o Voodoo3 3500 TV + + o Voodoo3 3000 AGP + + o Voodoo3 3000 PCI + + o Voodoo3 2000 AGP + + o Voodoo3 2000 PCI + + o Voodoo Banshee + + o Velocity 100/200 + + There are many configurations of 3dfx cards on the market. Not all have + been tested. + + o Matrox, supported on Intel x86 and AMD: + + o Matrox G200 + + o Matrox G400 + + o Intel i810/i815/i830 (motherboard chipsets) + + o i810 + + o i810-dc100 + + o i810e + + o i815 + + o i830 + + o ATI Rage 128, supported on Intel x86, AMD and Alpha: + + o Rage Fury + + o Rage Magnum + + o XPERT 2000 + + o XPERT 128 + + o XPERT 99 + + o All-in-Wonder 128 + + o Rage 128 PCI (Alpha-based systems) + + Note that both PCI and AGP versions of Rage 128 based cards are sup- + ported at this time. + + o ATI Radeon, supported on Intel x86, AMD and Alpha: + + o Radeon SDR AGP + + o Radeon DDR AGP + + o Radeon 32MB SDR PCI (Alpha-based systems) + + o Radeon 7000, M6 (RV100) + + o Radeon 7200 (R100) + + o Radeon 7500, M7 (RV200) + + o Radeon 8500, 9100 (R200) + + o Radeon 9000, M9 (RV250) + + o 3Dlabs, supported on Intel x86 and AMD: + + o Oxygen GMX 2000 (MX/Gamma based). Note: this driver is no longer + being actively developed. + +Support for other hardware is underway. Most of the DRI development work is +funded by contracts with IHVs. These contracts often prevent us from +announcing drivers before they're released. Queries about upcoming drivers +may not be answerable. + +4. Prerequisite Software + + o The DRI is available in XFree86 4.0 and later. + + o Some hardware drivers require specific versions of the Linux kernel for + AGP support, etc. See section 10 for specifics. + + o You DO NOT need to install Mesa separately. The parts of Mesa needed + for hardware acceleration are already in the XFree86/DRI project. + +5. Kernel Modules + +3D hardware acceleration requires a DRI kernel module that's specific to your +graphics hardware. + +The DRI kernel module version must exactly match your running kernel version. +Since there are so many versions of the kernel, it's difficult to provide +precompiled kernel modules. + +While the Linux source tree includes the DRI kernel module sources, the lat- +est DRI kernel sources will be found in the DRI source tree. + +See the DRI Compilation Guide for information on compiling the DRI kernel +modules. + +XFree86 4.0.1 added automatic kernel module loading to the X server. On +Linux, the X server uses modprobe to load kernel modules. In Linux 2.4.x the +DRM kernel modules should be kept in /lib/modules/2.4.x/ker- +nel/drivers/char/drm/ for automatic loading to work. + +Optionally, DRM kernel modules can be loaded manually with insmod prior to +starting the X server. + +You can verify that the kernel module was installed with lsmod, checking the +X server startup log, and checking that /proc/dri/0 exists. + +6. XF86Config file + +The XFree86 configuration file is usually found in /etc/X11/XF86Config. This +section describes the parts which must be specially set for the DRI. + +First, the XF86Config file must load the GLX and DRI modules: + + Section "Module" + ... + # This loads the GLX module + Load "glx" + # This loads the DRI module + Load "dri" + EndSection + +Next, the DRI section can be used to restrict access to direct rendering. A +client can only use direct rendering if it has permission to open the +/dev/dri/card? file(s). The permissions on these DRI device files is con- +trolled by the "DRI" section in the XF86Config file. + +If you want all of the users on your system to be able to use direct-render- +ing, then use a simple DRI section like this: + + Section "DRI" + Mode 0666 + EndSection + +This section will allow any user with a current connection to the X server to +use direct rendering. + +If you want to restrict the use of direct-rendering to a certain group of +users, then create a group for those users by editing the /etc/group file on +your system. For example, you may want to create a group called xf86dri and +place two users (e.g., fred and jane) in that group. To do that, you might +add the following line to /etc/group: + + xf86dri:x:8000:fred,jane + +You have to be careful that the group id (8000 in this example) is unique. + +Then you would use the following DRI section: + + Section "DRI" + Group "xf86dri" + Mode 0660 + EndSection + +This would limit access to direct-rendering to those users in the xf86dri +group (fred and jane in this example). When other users tried to use direct +rendering, they would fall back to unaccelerated indirect rendering. + +[Note that there is a known bug in XFree86 4.0 that prevents some changes to +the DRI section from taking effect. Until this bug is fixed, if you change +the DRI section, please also remove the /dev/dri directory with the rm -rf +/dev/dri command.] + +Finally, the XF86Config file needs Device and Screen sections specific to +your hardware. Look in section 10: Hardware-Specific Information and Trou- +bleshooting for details. + +7. Memory usage + +Using the 3D features of a graphics card requires more memory than when it's +just used as a 2D device. Double buffering, depth buffering, stencil +buffers, textures, etc. all require extra graphics memory. These features +may require four times the memory used for a simple 2D display. + +If your graphics card doesn't have a lot of memory (less than 16MB, for exam- +ple), you may have to reduce your screen size and/or color depth in order to +use 3D features. Reducing the screen resolution will also leave more space +for texture images, possibly improving 3D performance. If, for example, you +play Quake3 at 1024x768 but start your display at 1600x1200 you might con- +sider restarting X at 1024x768 in order to maximize your texture memory +space. + +The documentation included with your card should have information about maxi- +mum screen size when using 3D. + +8. Using 3D Acceleration + +This section describes how to link your application with libGL.so and verify +that you are in fact using 3D acceleration. + +8.1 libGL.so + +Your OpenGL program must link with the libGL.so.1.2 library provided by +XFree86. The libGL.so.1.2 library contains a GLX protocol encoder for indi- +rect/remote rendering and DRI code for accessing hardware drivers. In par- +ticular, be sure you're not using libGL.so from another source such as Mesa +or the Utah GLX project. + +Unless it was built in a special way, the libGL.so library does not contain +any 3D hardware driver code. Instead, libGL.so dynamically loads the appro- +priate 3D driver during initialization. + +Most simple OpenGL programs also use the GLUT and GLU libraries. A source +for these libraries is listed in the Resources section below. + +8.2 Compiling and linking an OpenGL program + +A simple GLUT/OpenGL program may be compiled and linked as follows: + + gcc program.c -I/usr/local/include -L/usr/local/lib -L/usr/X11R6/lib -lglut -lGLU -lGL -o program + +The -I option is used to specify where the GL/glut.h (and possibly the +GL/gl.h and GL/glu.h) header file may be found. + +The -L options specify where the libglut.so and the X libraries are located. +libGL.so and libGLU.so should be in /usr/lib, as specified by the +Linux/OpenGL ABI standard. + +The -lglut -lGLU -lGL arguments specify that the application should link with +the GLUT, GLU and GL libraries, in that order. + +8.3 Running your OpenGL program + +Simply typing ./program in your shell should execute the program. + +If you get an error message such as + + gears: error in loading shared libraries: libGL.so.1: cannot + open shared object file: No such file or directory + +if means that the libGL.so.1 file is not the right location. Proceed to the +trouble shooting section. + +8.4 libOSMesa.so + +OSMesa (Off-Screen Mesa) is an interface and driver for rendering 3D images +into a user-allocated block of memory rather than an on-screen window. It +was originally developed for Mesa before Mesa became part of the XFree86/DRI +project. It can now be used with the XFree86/DRI libGL.so as well. + +libOSMesa.so implements the OSMesa interface and it must be linked with your +application if you want to use the OSMesa functions. You must also link with +libGL.so. For example: + + gcc osdemo.c -lOSMesa -lGLU -lGL -o osdemo + +In stand-alone Mesa this interface was compiled into the monolithic libGL.so +(formerly libMesaGL.so) library. In XFree86 4.0.1 and later this interface +is implemented in a separate library. + +8.5 glxinfo + +glxinfo is a useful program for checking which version of libGL you're using +as well as which DRI-based driver. Simply type glxinfo and examine the +OpenGL vendor, renderer, and version lines. Among the output you should see +something like this: + + OpenGL vendor string: VA Linux Systems, Inc. + OpenGL renderer string: Mesa DRI Voodoo3 20000224 + OpenGL version string: 1.2 Mesa 3.4 + +or this: + + OpenGL vendor string: VA Linux Systems, Inc. + OpenGL renderer string: Mesa GLX Indirect + OpenGL version string: 1.2 Mesa 3.4 + +The first example indicates that the 3dfx driver is using Voodoo3 hardware. +The second example indicates that no hardware driver was found and indirect, +unaccelerated rendering is being used. + +If you see that indirect rendering is being used when direct rendering was +expected, proceed to the troubleshooting section. + +glxinfo also lists all of the GLX-enhanced visuals available so you can +determine which visuals are double-bufferd, have depth (Z) buffers, stencil +buffers, accumulation buffers, etc. + +8.6 Environment Variables + +The libGL.so library recognizes three environment variables. Normally, none +of them need to be defined. If you're using the csh or tcsh shells, type +setenv VARNAME value to set the variable. Otherwise, if you're using sh or +bash, type export VARNAME=value. + + 1. LIBGL_DEBUG, if defined will cause libGL.so to print error and diagnos- + tic messages. This can help to solve problems. Setting LIBGL_DEBUG to + verbose may provide additional information. + + 2. LIBGL_ALWAYS_INDIRECT, if defined this will force libGL.so to always + use indirect rendering instead of hardware acceleration. This can be + useful to isolate rendering errors. + + 3. LIBGL_DRIVERS_PATH can be used to override the default directories + which are searched for 3D drivers. The value is one or more paths sep- + arated by colons. In a typical XFree86 installation, the 3D drivers + should be in /usr/X11R6/lib/modules/dri/ and LIBGL_DRIVERS_PATH need + not be defined. Note that this feature is disabled for set-uid pro- + grams. This variable replaces the LIBGL_DRIVERS_DIR env var used in + XFree86 4.0. + + 4. MESA_DEBUG, if defined, will cause Mesa-based 3D drivers to print user + error messages to stderr. These are errors that you'd otherwise detect + by calling glGetError. + +Mesa-based drivers (this includes most of the drivers listed above) also +observe many of the existing Mesa environment variables. These include the +MESA_DEBUG and MESA_INFO variables. + +9. General Trouble Shooting + +This section contains information to help you diagnose general problems. See +below for additional information for specific hardware. + +9.1 Bus Mastering + +DMA-based DRI drivers (that's most DRI drivers) cannot function unless bus +mastering is enabled for your graphics card. By default, some systems don't +having bus mastering on. You should enable it in your BIOS. + +Alternately, you can check the status of bus mastering and change the setting +from within Linux. There may be similar procedures for other operating sys- +tems. + +Run lspci (as root) and find the information describing your graphics +adapter. For example: + + 00:00.0 Host bridge: Intel Corporation 440BX/ZX - 82443BX/ZX Host bridge (rev 03) + 00:01.0 PCI bridge: Intel Corporation 440BX/ZX - 82443BX/ZX AGP bridge (rev 03) + 00:07.0 ISA bridge: Intel Corporation 82371AB PIIX4 ISA (rev 02) + 00:07.1 IDE interface: Intel Corporation 82371AB PIIX4 IDE (rev 01) + 00:07.2 USB Controller: Intel Corporation 82371AB PIIX4 USB (rev 01) + 00:07.3 Bridge: Intel Corporation 82371AB PIIX4 ACPI (rev 02) + 00:11.0 Ethernet controller: Intel Corporation 82557 [Ethernet Pro 100] (rev 08) + 00:12.0 SCSI storage controller: Symbios Logic Inc. (formerly NCR) 53c895 (rev 02) + 00:14.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 08) + 01:00.0 VGA compatible controller: 3Dfx Interactive, Inc.: Unknown device 0009 (rev 01) + +The bus, device, and function number comprise the device id, which is conven- +tionally written in the form bus:dev.func, or in this case 01:00.0. + +Use the setpci command to examine bit two of register 4 for your graphics +card. This will indicate whether or not bus mastering is enabled. + + setpci -s 01:00.0 4.w + +A hexadecimal value will be printed. Convert the least significant digit to +binary. For example, if you see 3, that's 0011 in binary (bit two is 0). If +you see 7, that's 0111 in binary (bit two is 1). In the first example, bus +mastering is disabled. It's enabled in the second example. + +The following shell script will enabled bus mastering for your graphics card +and host bridge. Run it as root. + + #!/bin/bash + dev=01:00.0 # change as appropriate + echo Enabling bus mastering on device $dev + setpci -s $dev 4.w=$(printf %x $((0x$(setpci -s $dev 4.w)|4))) + dev=00:00.0 + echo Enabling bus mastering on host bridge $dev + setpci -s $dev 4.w=$(printf %x $((0x$(setpci -s $dev 4.w)|4))) + +You can check if this worked by running the first setpci command again. + +9.2 The X Server + + 1. Before you start the X server, verify the appropriate 3D kernel module + is installed. Type lsmod and look for the appropriate kernel module. + For 3dfx hardware you should see tdfx, for example. + + 2. Verify you're running XFree86 4.0 (or newer) and not an older version. + If you run xdpyinfo and look for the following line near the top: + + vendor release number: 4000 + + 3. Verify that your XF86Config file (usually found at /etc/X11/XF86Config) + loads the glx and dri modules and has a DRI section. + + See the Software Resources section below for sample XF86Config files. + + 4. Examine the messages printed during X server startup and check that the + DRM module loaded. Using the Voodoo3 as an example: + + (==) TDFX(0): Write-combining range (0xf0000000,0x2000000) + (II) TDFX(0): Textures Memory 7.93 MB + (0): [drm] created "tdfx" driver at busid "PCI:1:0:0" + (0): [drm] added 4096 byte SAREA at 0xc65dd000 + (0): [drm] mapped SAREA 0xc65dd000 to 0x40013000 + (0): [drm] framebuffer handle = 0xf0000000 + (0): [drm] added 1 reserved context for kernel + (II) TDFX(0): [drm] Registers = 0xfc000000 + (II) TDFX(0): visual configs initialized + (II) TDFX(0): Using XFree86 Acceleration Architecture (XAA) + Screen to screen bit blits + Solid filled rectangles + 8x8 mono pattern filled rectangles + Indirect CPU to Screen color expansion + Solid Lines + Dashed Lines + Offscreen Pixmaps + Driver provided NonTEGlyphRenderer replacement + Setting up tile and stipple cache: + 10 128x128 slots + (==) TDFX(0): Backing store disabled + (==) TDFX(0): Silken mouse enabled + (0): X context handle = 0x00000001 + (0): [drm] installed DRM signal handler + (0): [DRI] installation complete + (II) TDFX(0): direct rendering enabled + + 5. After the X server has started, verify that the required X server + extensions are loaded. Run xdpyinfo and look for the following entries + in the extensions list: + + GLX + SGI-GLX + XFree86-DRI + +9.3 Linking, running and verifying 3D acceleration + +After you've verified that the X server and DRI have started correctly it's +time to verify that the GL library and hardware drivers are working cor- +rectly. + + 1. Verify that you're using the correct libGL.so library with ldd. The + /usr/lib and /usr/X11R6/lib directories are expected locations for + libGL.so. + + Example: + + % ldd /usr/local/bin/glxinfo + libglut.so.3 => /usr/local/lib/libglut.so.3 (0x40019000) + libGLU.so.1 => /usr/local/lib/libGLU.so.1 (0x40051000) + libGL.so.1 => /usr/lib/libGL.so.1 (0x40076000) + libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0x402ee000) + libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x40301000) + libm.so.6 => /lib/libm.so.6 (0x40309000) + libc.so.6 => /lib/libc.so.6 (0x40325000) + libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40419000) + libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x404bd000) + libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x40509000) + libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x40512000) + libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40529000) + libvga.so.1 => /usr/lib/libvga.so.1 (0x40537000) + libpthread.so.0 => /lib/libpthread.so.0 (0x4057d000) + /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) + + 2. You may also double check that libGL.so is in fact DRI-capable. Run + strings libGL.so.1.2 | grep DRI and look for symbols prefixed with + "XF86DRI", such as "XF86DRIQueryExtension". + + 3. To be safe one should run ldconfig after installing libGL.so to be sure + the runtime loader will find the proper library. + + 4. Verify that the appropriate 3D driver is in /usr/X11R6/lib/modules/dri/ + For example, the 3dfx driver will be named tdfx_dri.so. + + 5. Set the LIBGL_DEBUG environment variable. This will cause libGL.so to + print an error message if it fails to load a DRI driver. Any error + message printed should be self-explanatory. + + 6. Run glxinfo. Note the line labeled "OpenGL renderer string". It + should have a value which starts with "Mesa DRI" followed by the name + of your hardware. + + 7. Older Linux OpenGL applications may have been linked against Mesa's GL + library and will not automatically use libGL.so. In some cases, making + symbolic links from the Mesa GL library to libGL.so.1 will solve the + problem: + + ln -s libGL.so.1 libMesaGL.so.3 + + In other cases, the application will have to be relinked against the + new XFree86 libGL.so. + + It is reported that part of the problem is that running ldconfig will + silently rewrite symbolic links based on the SONAME field in libraries. + +If you're still having trouble, look in the next section for information spe- +cific to your graphics card. + +10. Hardware-Specific Information and Troubleshooting + +This section presents hardware-specific information for normal use and trou- +bleshooting. + +10.1 3dfx Banshee, Voodoo3, Voodoo4 and Voodoo5 Series + +10.1.1 Requirements + +The 3dfx DRI driver requires special versions of the 3dfx Glide library. +Different versions of Glide are needed for Banshee/Voodoo3 than for +Voodoo4/5. The Glide libraries can be downloaded from the DRI website. + +10.1.2 Configuration + +Your XF86Config file's device section must specify the tdfx device. For +example: + + Section "Device" + Identifier "Voodoo3" + VendorName "3dfx" + Driver "tdfx" + EndSection + +Or, + + Section "Device" + Identifier "Voodoo5" + VendorName "3dfx" + Driver "tdfx" + EndSection + +The Screen section should then reference the Voodoo device: + + Section "Screen" + Identifier "Screen 1" + Device "Voodoo3" + Monitor "High Res Monitor" + DefaultDepth 16 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +Or, + + Section "Screen" + Identifier "Screen 1" + Device "Voodoo5" + Monitor "High Res Monitor" + DefaultDepth 24 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + Subsection "Display" + Depth 24 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +The kernel module for 3dfx hardware is named tdfx.o and should be installed +in /lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically +loaded by the Xserver if needed. + +The DRI 3D driver for 3dfx hardware should be in /usr/X11R6/lib/mod- +ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. + +The Voodoo5 supports 3D rendering in 16 and 32 bpp modes. When running in +32bpp mode an 8-bit stencil buffer and 24-bit Z (depth) buffer are offered. +When running in 16bpp mode only a 16-bit Z (depth) buffer is offered and +stencil is implemented in software. + +A software-based accumulation buffer is available in both 16 and 32bpp modes. + +10.1.3 Troubleshooting + + o If you try to run an OpenGL application and see an error message similar + to + + gd error (glide): gd error (glide): grSstSelect: non-existent SSTgd error (glide): grSstSelect: non-existent SSTS + + it means that you have the wrong version of the Glide library for your + hardware. + + o 3D acceleration for Banshee and Voodoo3 is only supported in the 16 + bit/pixel screen mode. Use xdpyinfo to verify that all your visuals are + depth 16. Edit your XF86Config file if needed. + + o The /dev/3dfx device is not used for DRI; it's only for Glide on older + 3dfx hardware. + + o Different versions of Glide are needed for Voodoo3 and Voodoo5. See the + DRI website's resources page to download the right version of Glide. + + o Voodoo4/5 may be run at 24bpp (instead of 32bpp, the default) but 3D + acceleration is not supported in that mode. 32bpp mode is fully 3D + accelerated. + +10.1.4 Performance and Features + + o Normally, buffer swapping in double-buffered applications is synchro- + nized to your monitor's refresh rate. This may be overridden by setting + the FX_GLIDE_SWAPINTERVAL environment variable. The value of this vari- + able indicates the maximum number of swap buffer commands can be + buffered. Zero allows maximum frame rate. + + o On Voodoo4/5, rendering with 16-bits/texel textures is faster than using + 32-bit per texel textures. The internalFormat parameter to glTexImage2D + can be used to control texel size. Quake3 and other games let you con- + trol this as well. + + o The glTexEnv mode GL_BLEND is not directly supported by the Voodoo3 + hardware. It can be accomplished with a multipass algorithm but it's + not implemented at this time. Applications which use that mode, such as + the Performer Town demo, may become sluggish when falling back to soft- + ware rendering to render in that mode. + + o The Voodoo3/Banshee driver reverts to software rendering under the fol- + lowing conditions: + + o Setting GL_LIGHT_MODEL_COLOR_CONTROL to GL_SEPARATE_SPECULAR_COLOR. + + o Enabling line stippling or polygon stippling. + + o Enabling point smoothing or polygon smoothing. + + o Enabling line smoothing when line width is not 1.0. That is, + antialiased lines are done in hardware only when the line width is + 1.0. + + o Using 1-D or 3-D texture maps. + + o Using the GL_BLEND texture environment. + + o Using stencil operations. + + o Using the accumulation buffer. + + o Using glBlendEquation(GL_LOGIC_OP). + + o Using glDrawBuffer(GL_FRONT_AND_BACK). + + o Using glPolygonMode(face, GL_POINT) or glPolygonMode(face, + GL_LINE). + + o Using point size attenuation (i.e. GL_DISTANCE_ATTENUATION_EXT). + + o Using glColorMask(r, g, b, a) when r!=g or g!=b. + + o The Voodoo5 driver reverts to software rendering under the same condi- + tions Voodoo3 with three exceptions. First, stencil operations are + implemented in hardware when the screen is configured for 32 bits/pixel. + Second, the GL_BLEND texture env mode is fully supported in hardware. + Third, glColorMask is fully supported in hardware when the screen is + configured for 32 bits/pixel. + + o As of January, 2001 the second VSA-100 chip on the Voodoo5 is not yet + operational. Therefore, the board isn't being used to its full capac- + ity. The second VSA-100 chip will allow Scan-Line Interleave (SLI) mode + for full-screen applications and games, potentially doubling the sys- + tem's fill rate. When the second VSA-100 chip is activated glGet- + String(GL_RENDERER) will report Voodoo5 instead of Voodoo4. + + o The lowest mipmap level is sometimes miscolored in trilinear- sampled + polygons. + + o The GL_EXT_texture_env_combine extension is supported on the Voodoo4 and + Voodoo5. + +10.1.5 Known Problems + + o The lowest mipmap level is sometimes miscolored in trilinear- sampled + polygons (Voodoo3/Banshee). + + o Fog doesn't work with orthographic projections. + + o The accuracy of blending operations on Voodoo4/5 isn't always very good. + If you run Glean, you'll find some test failures. + + o The Glide library cannot be used directly; it's only meant to be used + via the tdfx DRI driver. + + o SSystem has problems because of poorly set near and far clipping planes. + The office.unc Performer model also suffers from this problem. + +10.2 Intel i810 + +10.2.1 Requirements + +A kernel with AGP GART support (such as Linux 2.4.x) is needed. + +10.2.2 Configuration + +Your XF86Config file's device section must specify the i810 device, and spec- +ify a usable amount of video ram to reserve. + + Section "Device" + Identifier "i810" + VendorName "Intel" + Driver "i810" + Option "AGPMode" "1" + VideoRam 10000 + EndSection + +The Screen section should then reference the i810 device: + + Section "Screen" + Identifier "Screen 1" + Device "i810" + Monitor "High Res Monitor" + DefaultDepth 16 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +The kernel module for the i810 is named i810.o and should be installed in +/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded +by the Xserver if needed. + +The DRI 3D driver for the i810 should be in /usr/X11R6/lib/mod- +ules/dri/i810_dri.so. This will be automatically loaded by libGL.so. + +10.2.3 Troubleshooting + + o 3D acceleration for the i810 is only available in the 16 bit/pixel + screen mode at this time. 32bpp acceleration is not supported by this + hardware. Use xdpyinfo to verify that all your visuals are depth 16. + Edit your XF86Config file if needed. + + o The i810 uses system ram for video and 3d graphics. The X server will + ordinarily reserve 4mb of ram for graphics, which is too little for an + effective 3d setup. To tell the driver to use a larger amount, specify + a VideoRam option in the Device section of your XF86Config file. A num- + ber between 10000 and 16384 seems adequate for most requirements. If + too little memory is available for DMA buffers, back and depth buffers + and textures, direct rendering will be disabled. + +10.2.4 Performance and Features + +Basically all of the i810 features which can be exposed through OpenGL 1.2 +are implemented. However, the following OpenGL features are implemented in +software and will be slow: + + o Stencil buffer and accumulation buffer operations + + o Blend subtract, min/max and logic op blend modes + + o glColorMask when any mask is set to false + + o GL_SEPARATE_SPECULAR_COLOR lighting mode + + o glDrawBuffer(GL_FRONT_AND_BACK) + + o Using 1D or 3D textures + + o Using texture borders + +10.3 Matrox G200 and G400 + +10.3.1 Requirements + +A kernel with AGP GART support (such as Linux 2.4.x) is needed. + +10.3.2 Configuration + +Your XF86Config file's device section must specify the mga device: + + Section "Device" + Identifier "MGA" + VendorName "Matrox" + Driver "mga" + Option "AGPMode" "1" + VideoRam 32768 + EndSection + +The Screen section should then reference the MGA device: + + Section "Screen" + Identifier "Screen 1" + Device "MGA" + Monitor "High Res Monitor" + DefaultDepth 16 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +To use a 32bpp screen mode, use this Screen section instead: + + Section "Screen" + Identifier "Screen 1" + Device "MGA" + Monitor "High Res Monitor" + DefaultDepth 24 + DefaultFbBpp 32 + Subsection "Display" + Depth 24 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +The kernel module for the G200/G400 is named mga.o and should be installed in +/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded +by the Xserver if needed. + +The DRI 3D driver for the G200/G400 should be in /usr/X11R6/lib/mod- +ules/dri/mga_dri.so. This will be automatically loaded by libGL.so. + +10.3.3 Performance and Features + +Software rendering will be used under any of the following conditions: + + o Using glDrawBuffer(GL_FRONT_AND_BACK). + + o Using point, line, or triangle smoothing. + + o Using glLogicOp. + + o Using glPolygonStipple or glLineStipple. + + o Using 1D or 3D textures. + + o Using texture borders. + + o Using glDepthFunc(GL_NEVER). + + o Using the accumulation buffer. + +The AGP mode may be set to 1, 2, or 4. One is used by default. Higher AGP +speeds may result in unreliable performance depending on your motherboard. + +Compaq has funded the implementation of AGP accelerated ReadPixels and Draw- +Pixels in this driver. With this implementation, on a G400 drawing directly +from AGP memory (exported to the client), throughput of up to 1 GB/sec has +been measured. + +Additionally Compaq's funding has produced several new extensions in Mesa, +including one (packed_depth_stencil_MESA) which enables Read/DrawPixels func- +tionality to operate directly on the packed 24/8 depth/stencil buffers of +this hardware. + +In order to access this functionality, the application must ensure that all +pixel processing operations are disabled. There are in addition a fairly +complex set of rules regarding which packing/unpacking modes must be used, +and which data formats are supported, and alignment constraints. See the +files in lib/GL/mesa/src/drv/mga/DOCS for a summary of these. The extension +definitions are included in the Mesa 3.4 source distribution. + +10.3.4 IRQ Assignment + +There have been problems in the past with the MGA driver being very sluggish +when the DRI is enabled (to the point of being unusable.) This is caused by +the graphics card not having an interrupt assigned to it. The current DRI +trunk will attempt to detect this condition and bail out gracefully. + +The solution to the above problem is to assign an interrupt to your graphics +card. This is something you must turn on in your system BIOS configuration. +Please consult your system BIOS manual for instructions on how to enable an +interrupt for your graphics card. + +10.3.5 MGA HAL lib + +MGAHALlib.a is a binary library Matrox has provided for use under Linux to +expose functionality for which they can not provide documentation. (For +example TV-Out requires MacroVision be enabled on the output.) This binary +library also sets the pixel/memory clocks to the optimal settings for your +Matrox card. + +Currently the MGAHAL library is required for the G450 to work. You can down- +load this from the driver section on Matrox's website: www.matrox.com/mga + +Here modifications to the DRI build instructions which make the mga ddx +driver use the MGAHAL library: + + 1.Put the following define in your host.def file + #define UseMatroxHal YES + 2. Place mgaHALlib.a in the following directory + xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/ + +You can use DualHead on the G400/G450 DH cards by creating two device sec- +tions which both point to the same BusID. For most AGP devices the BusID +will be "PCI:1:0:0". Configure your screen section as you would normally +configure XFree86 4.x Multihead. It should be noted that currently the sec- +ond head does not support direct rendering. + +10.3.6 Known Problems + +None. + +10.4 ATI Rage 128 + +10.4.1 Requirements + +A kernel with AGP GART support (such as Linux 2.4.x) is needed. + +10.4.2 Configuration + +Your XF86Config file's device section must specify the ati device: + + Section "Device" + Identifier "Rage128" + VendorName "ATI" + Driver "ati" + Option "AGPMode" "1" + Option "UseCCEFor2D" "false" + EndSection + +The Screen section should then reference the Rage 128 device: + + Section "Screen" + Identifier "Screen 1" + Device "Rage128" + Monitor "High Res Monitor" + DefaultDepth 16 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + Subsection "Display" + Depth 32 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +The kernel module for the Rage 128 is named r128.o and should be installed in +/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded +by the Xserver if needed. + +The DRI 3D driver for the Rage 128 should be in /usr/X11R6/lib/mod- +ules/dri/r128_dri.so. This will be automatically loaded by libGL.so. + +You may also set your screen depth to 32 for 32bpp mode. + +10.4.3 Performance and Features + +While PCI Rage 128 based cards are supported, they do not yet support PCI +GART, so they will not perform as well as their AGP counterparts. + +For AGP cards, the AGP mode may be set to 1, 2, or 4. One is used by +default. Higher AGP speeds may result in unreliable performance depending on +your motherboard. + +Note that even at 32bpp there is no alpha channel. + +The following OpenGL features are implemented in software and will be slow: + + o accumulation buffer operations + + o stencil, when using a 16bpp screen + + o Blend subtract, min/max and logic op blend modes + + o GL_SEPARATE_SPECULAR_COLOR lighting mode + + o glDrawBuffer(GL_FRONT_AND_BACK) + + o Using 1D or 3D textures + + o Using texture borders + +10.4.4 Known Problems + +If you experience stability problems you may try setting the UseCCEFor2D +option to true. This will effectively disable 2D hardware acceleration. +Performance will be degraded, of course. + +10.5 ATI Radeon + +10.5.1 Requirements + +A kernel with AGP GART support (such as Linux 2.4.x) is needed. + +10.5.2 Configuration + +Your XF86Config file's device section must specify the ati device: + + Section "Device" + Identifier "Radeon" + VendorName "ATI" + Driver "ati" + Option "AGPMode" "1" + EndSection + +The Screen section should then reference the Radeon device: + + Section "Screen" + Identifier "Screen 1" + Device "Radeon" + Monitor "High Res Monitor" + DefaultDepth 16 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + Subsection "Display" + Depth 32 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +The kernel module for the Radeon is named radeon.o and should be installed in +/lib/modules/2.4.x/kernel/drivers/char/drm/. It will be automatically loaded +by the Xserver if needed. + +The DRI 3D driver for the Radeon should be in /usr/X11R6/lib/mod- +ules/dri/radeon_dri.so. This will be automatically loaded by libGL.so. + +You may also set your screen depth to 32 for 32bpp mode. + +10.5.3 Performance and Features + +While this driver supports many of the features of ATI Radeon cards, we do +not yet fully support the card's TCL features. This work is progressing, but +is not yet ready. + +The AGP mode may be set to 1, 2, or 4. One is used by default. Higher AGP +speeds may result in unreliable performance depending on your motherboard. + +The following OpenGL features are implemented in software and will be slow: + + o Blend subtract, blend min/max and blend logicops + + o Stencil and accumulation operations + + o 1D and 3D textures + + o Texture borders + +The GL_EXT_texture_env_combine, GL_EXT_texture_env_add and GL_EXT_tex- +ture_env_dot3 extensions are supported (or will be soon supported in the new +driver based on Mesa 3.5). + +We hope to implement support for the following features in the future: + + o Vertex transformation, clipping and lighting (TCL) + + o Hardware stencil buffer + + o Cube map textures + + o 3D textures + + o Three texture units + +10.5.4 Known Problems + +Certain (early?) revisions of the AMD Irongate chipset have AGPGART problems +which effect Radeon, and other graphics cards. The card may work unreliably, +or not work at all. If the DRM kernel module is not loaded, the 2D Xserver +may work. There's hope that this can be fixed in the future. + +10.6 3DLabs Oxygen GMX 2000 + +The driver for this hardware was experimental and is no longer being devel- +oped or supported. + +11. General Limitations and Known Bugs + +11.1 OpenGL + +The following OpenGL features are not supported at this time: overlays, +stereo, hardware-accelerated indirect rendering. + +OpenGL-like functionality is provided with the Mesa library. XFree86 4.1.0 +uses Mesa 3.4.2. Subsequent releases of XFree86 will use newer versions of +Mesa. When newer versions of Mesa are available, the 3D drivers can be +updated without reinstalling XFree86 or libGL.so. + +11.2 GLX + +The GLX 1.3 API is exported but none of the new 1.3 functions are opera- +tional. + +The new glXGetProcAddressARB function is fully supported. + +GLXPixmap rendering is only supported for indirect rendering contexts. This +is a common OpenGL limitation. Attempting to use a direct rendering context +with a GLXPixmap will result in an X protocol error. + +11.3 Debugging + +Debugging DRI drivers with gdb can be difficult because of the locking +involved. When debugging OpenGL applications, you should avoid stepping +inside the GL functions. If you're trying to debug a DRI driver it's recom- +mended that you do so remotely, from a second system. + +11.4 Scheduling + +When you run multiple GL applications at once you may notice poor time slic- +ing. This is due to an interaction problem with the Linux scheduler which +will be addressed in the future. + +11.5 libGL.so and dlopen() + +A number of popular OpenGL applications on Linux (such as Quake3, HereticII, +Heavy Gear 2, etc) dynamically open the libGL.so library at runtime with +dlopen(), rather than linking with -lGL at compile/link time. + +If dynamic loading of libGL.so is not implemented carefully, there can be a +number of serious problems. Here are the things to be careful of in your +application: + + o Specify the RTLD_GLOBAL flag to dlopen(). If you don't do this then + you'll likely see a runtime error message complaining that _glapi_Con- + text is undefined when libGL.so tries to open a hardware-specific + driver. Without this flag, nested opening of dynamic libraries does not + work. + + o Do not close the library with dlclose() until after XCloseDisplay() has + been called. When libGL.so initializes itself it registers several + callbacks functions with Xlib. When XCloseDisplay() is called those + callback functions are called. If libGL.so has already been unloaded + with dlclose() this will cause a segmentation fault. + + o Your application should link with -lpthread. On Linux, libGL.so uses + the pthreads library in order to provide thread safety. There is appar- + ently a bug in the dlopen()/dlclose() code which causes crashes if the + library uses pthreads but the parent application doesn't. The only + known work-around is to link the application with -lpthread. + +Some applications don't yet incorporate these procedures and may fail. For +example, changing the graphics settings in some video games will expose this +problem. The DRI developers are working with game vendors to prevent this +problem in the future. + +11.6 Bug Database + +The DRI bug database which includes bugs related to specific drivers is at +the SourceForge DRI Bug Database + +Please scan both the open and closed bug lists to determine if your problem +has already been reported and perhaps fixed. + +12. Resources + +12.1 Software + +A collection of useful configuration files, libraries, headers, utilities and +demo programs is available from http://dri.sourceforge.net/res.phtml + +12.2 Documentation + + o General OpenGL information is available at the OpenGL Home Page + + o XFree86 information is available at the XFree86 Home Page + + o Information about the design of the DRI is available from Precision + Insight, Inc. + + o Visit the DRI project on SourceForge.net for the latest development news + about the DRI and 3D drivers. + + o The DRI Compilation Guide explains how to download, compile and install + the DRI for yourself. + +12.3 Support + + o The DRI-users mailing list at SourceForge is a forum for people to dis- + cuss DRI problems. + + o In the future there may be IHV and Linux vendor support resources for + the DRI. + + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.28 dawes Exp $ + + diff --git a/xorg-server/hw/xfree86/doc/README.fonts b/xorg-server/hw/xfree86/doc/README.fonts new file mode 100644 index 000000000..0ad2b49d0 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/README.fonts @@ -0,0 +1,1158 @@ + Fonts in X11R6.9 + + Juliusz Chroboczek, + + 25 March 2004 + +1. Introduction + +This document describes the support for fonts in X11R6.9. Installing fonts +(section 2., page 1) is aimed at the casual user wishing to install fonts in +X11R6.9 the rest of the document describes the font support in more detail. + +We assume some familiarity with digital fonts. If anything is not clear to +you, please consult Appendix: Background (section 5., page 1) at the end of +this document for background information. + +1.1 Two font systems + +X includes two font systems: the original core X11 fonts system, which is +present in all implementations of X11, and the Xft fonts system, which may +not be distributed with implementations of X11 that are not based on X11R6.9 +but will hopefully be included by them in the future + +The core X11 fonts system is directly derived from the fonts system included +with X11R1 in 1987, which could only use monochrome bitmap fonts. Over the +years, it has been more or less happily coerced into dealing with scalable +fonts and rotated glyphs. + +Xft was designed from the start to provide good support for scalable fonts, +and do so efficiently. Unlike the core fonts system, it supports features +such as anti-aliasing and sub-pixel rasterisation. Perhaps more importantly, +it gives applications full control over the way glyphs are rendered, making +fine typesetting and WYSIWIG display possible. Finally, it allows applica- +tions to use fonts that are not installed system-wide for displaying docu- +ments with embedded fonts. + +Xft is not compatible with the core fonts system: usage of Xft requires mak- +ing fairly extensive changes to toolkits (user-interface libraries). While +X.org will continue to maintain the core fonts system, toolkit authors are +encouraged to switch to Xft as soon as possible. + +2. Installing fonts + +This section explains how to configure both Xft and the core fonts system to +access newly-installed fonts. + +2.1 Configuring Xft + +Xft has no configuration mechanism itself, rather it relies upon the fontcon- +fig library to configure and customize fonts. That library is not specific +to X11R6.9 or indeed on any particular font output mechanism. This discus- +sion describes how fontconfig, rather than Xft, works. + +2.1.1 Installing fonts in Xft + +Fontconfig looks for fonts in a set of well-known directories that include +all of X11R6.9's standard font directories (`/usr/X11R6/lib/X11/lib/fonts/*') +by default) as well as a directory called `.fonts/' in the user's home direc- +tory. Installing a font for use by Xft applications is as simple as copying +a font file into one of these directories. + + $ cp lucbr.ttf ~/.fonts/ + +Fontconfig will notice the new font at the next opportunity and rebuild its +list of fonts. If you want to trigger this update from the command line (for +example in order to globally update the system-wide Fontconfig information), +you may run the command `fc-cache'. + + $ fc-cache + +2.1.2 Fine-tuning Xft + +Fontconfig's behaviour is controlled by a set of configuration files: a sys- +tem-wide configuration file, `/etc/fonts/fonts.conf', and a user-specific +file called `.fonts.conf' in the user's home directory (this can be overrid- +den with the `FONTCONFIG_FILE' environment variable). + +Every Fontconfig configuration file must start with the following boiler- +plate: + + + + + +In addition, every Fontconfig configuration file must end with the following +line: + + + +The default Fontconfig configuration file includes the directory `~/.fonts/' +in the list of directories searched for font files, and this is where user- +specific font files should be installed. In the unlikely case that a new +font directory needs to be added, this can be done with the following syntax: + + /usr/local/share/fonts/ + +Another useful option is the ability to disable anti-aliasing (font smooth- +ing) for selected fonts. This can be done with the following syntax: + + + + Lucida Console + + + false + + + +Anti-aliasing can be disabled for all fonts by the following incantation: + + + + false + + + +Xft supports sub-pixel rasterisation on LCD displays. X11R6.9 should auto- +matically enable this feature on laptops and when using an LCD monitor con- +nected with a DVI cable; you can check whether this was done by typing + + $ xdpyinfo -ext RENDER | grep sub-pixel + +If this doesn't print anything, you will need to configure Render for your +particular LCD hardware manually; this is done with the following syntax: + + + + rgb + + + +The string `rgb' within the `'...`' specifies the order of +pixel components on your display, and should be changed to match your hard- +ware; it can be one of `rgb (normal LCD screen), `bgr' (backwards LCD +screen), `vrgb' (LCD screen rotated clockwise) or `vbgr' (LCD screen rotated +counterclockwise). + +2.1.3 Configuring applications + +Because most current applications use the core fonts system by default, it is +necessary to explicitly configure them to use Xft. How this is done depends +on the application. + +XTerm can be set to use Xft by using the `-fa' command line option or by set- +ting the `XTerm*faceName' resource: + + XTerm*faceName: Courier + +or + + $ xterm -fa "Courier" + +For applications based on GTK+ 2.0 (including GNOME 2 applications), the +environment variable `GDK_USE_XFT' should be set to `1': + + $ export GDK_USE_XFT=1 + +GTK+ 2.2 uses Xft by default. + +For KDE applications, you should select ``Anti-alias fonts'' in the ``Fonts'' +panel of KDE's ``Control Center''. Note that this option is misnamed: it +switches KDE to using Xft but doesn't enable anti-aliasing in case it was +disabled by your Xft configuration file. + +(What about Mozilla?) + +2.1.4 Troubleshooting + +If some Xft-based applications don't seem to notice the changes you are mak- +ing to your configuration files, they may be linked against an old version of +Xft. In order to fix the problem, you should relink them against a current +version of Xft; on most systems, it is enough to install the current version +of the Xft and Fontconfig libraries. + +If, for some reason, you cannot upgrade the shared libraries, please check +the Xft(3) manual page included with XFree86 4.2 for the configuration mecha- +nisms of the previous version of Xft. + +2.2 Configuring the core X11 fonts system + +Installing fonts in the core system is a two step process. First, you need +to create a font directory that contains all the relevant font files as well +as some index files. You then need to inform the X server of the existence +of this new directory by including it in the font path. + +2.2.1 Installing bitmap fonts + +The X11R6.9 server can use bitmap fonts in both the cross-platform BDF format +and the somewhat more efficient binary PCF format. (X11R6.9 also supports +the obsolete SNF format.) + +Bitmap fonts are normally distributed in the BDF format. Before installing +such fonts, it is desirable (but not absolutely necessary) to convert the +font files to the PCF format. This is done by using the command `bdftopcf', +e.g. + + $ bdftopcf courier12.bdf + +You will then want to compress the resulting PCF font files: + + $ gzip courier12.pcf + +After the fonts have been converted, you should copy all the font files that +you wish to make available into a arbitrary directory, say +`/usr/local/share/fonts/bitmap/'. You should then create the index file +`fonts.dir' by running the command `mkfontdir' (please see the mkfontdir(1) +manual page for more information): + + $ mkdir /usr/local/share/fonts/bitmap/ + $ cp *.pcf.gz /usr/local/share/fonts/bitmap/ + $ mkfontdir /usr/local/share/fonts/bitmap/ + +All that remains is to tell the X server about the existence of the new font +directory; see Setting the server font path (section 2.2.4, page 1) below. + +2.2.2 Installing scalable fonts + +The X11R6.9 server supports scalable fonts in three formats: Type 1, TrueType +and CIDFont. This section only applies to the first two; for information on +CIDFonts, please see Installing CIDFonts (section 2.2.3, page 1) later in +this document. Previous versions also included support for the Speedo scal- +able font format, but that is disabled in the default builds of X11R6.9 and +not included in X11R7.0 and later releases. + +Installing scalable fonts is very similar to installing bitmap fonts: you +create a directory with the font files, and run `mkfontdir' to create an +index file called `fonts.dir'. + +There is, however, a big difference: `mkfontdir' cannot automatically recog- +nise scalable font files. For that reason, you must first index all the font +files in a file called `fonts.scale'. While this can be done by hand, it is +best done by using the `mkfontscale' utility. + + $ mkfontscale /usr/local/share/fonts/Type1/ + $ mkfontdir /usr/local/share/fonts/Type1/ + +Under some circumstances, it may be necessary to modify the `fonts.scale' +file generated by mkfontscale; for more information, please see the mkfont- +dir(1) and mkfontscale(1) manual pages and Core fonts and internationalisa- +tion (section 4.1, page 1) later in this document. + +2.2.3 Installing CID-keyed fonts + +The CID-keyed font format was designed by Adobe Systems for fonts with large +character sets. A CID-keyed font, or CIDFont for short, contains a collec- +tion of glyphs indexed by character ID (CID). + +In order to map such glyphs to meaningful indices, Adobe provide a set of +CMap files. The PostScript name of a font generated from a CIDFont consists +of the name of the CIDFont and the name of the CMap separated by two dashes. +For example, the font generated from the CIDFont `Munhwa-Regular' using the +CMap `UniKS-UCS2-H' is called + + Munhwa-Regular--UniKS-UCS2-H + +The CIDFont code in X11R6.9 requires a very rigid directory structure. The +main directory must be called `CID' (its location defaults to +`/usr/X11R6/lib/X11/fonts/CID' but it may be located anywhere), and it should +contain a subdirectory for every CID collection. Every subdirectory must +contain subdirectories called CIDFont (containing the actual CIDFont files), +CMap (containing all the needed CMaps), AFM (containing the font metric +files) and CFM (initially empty). For example, in the case of the font +Munhwa-Regular that uses the CID collection Adobe-Korea1-0, the directory +structure should be as follows: + + CID/Adobe-Korea1/CIDFont/Munhwa-Regular + CID/Adobe-Korea1/CMap/UniKS-UCS2-H + CID/Adobe-Korea1/AFM/Munhwa-Regular.afm + CID/Adobe-Korea1/CFM/ + CID/fonts.dir + CID/fonts.scale + +After creating this directory structure and copying the relevant files, you +should create a `fonts.scale' file. This file has the same format as in the +case of (non-CID) scalable fonts, except that its first column contains +PostScript font names with the extension `.cid' appended rather than actual +filenames: + + 1 + Adobe-Korea1/Munhwa-Regular--UniKS-UCS2-H.cid \ + -adobe-munhwa-medium-r-normal--0-0-0-0-p-0-iso10646-1 + +(both names on the same line). Running `mkfontdir' creates the `fonts.dir' +file: + + $ cd /usr/local/share/fonts/CID + $ mkfontdir + +Finally, you should create the font metrics summary files in the directory +`CFM' by running the command `mkcfm': + + $ mkcfm /usr/local/share/fonts/CID + +If no CFM files are available, the server will still be able to use the CID +fonts but querying them will take a long time. You should run `mkcfm' again +whenever a change is made to any of the CID-keyed fonts, or when the CID- +keyed fonts are copied to a machine with a different architecture. + +2.2.4 Setting the server's font path + +The list of directories where the server looks for fonts is known as the font +path. Informing the server of the existence of a new font directory consists +of putting it on the font path. + +The font path is an ordered list; if a client's request matches multiple +fonts, the first one in the font path is the one that gets used. When match- +ing fonts, the server makes two passes over the font path: during the first +pass, it searches for an exact match; during the second, it searches for +fonts suitable for scaling. + +For best results, scalable fonts should appear in the font path before the +bitmap fonts; this way, the server will prefer bitmap fonts to scalable fonts +when an exact match is possible, but will avoid scaling bitmap fonts when a +scalable font can be used. (The `:unscaled' hack, while still supported, +should no longer be necessary in X11R6.9.) + +You may check the font path of the running server by typing the command + + $ xset q + +2.2.4.1 Temporary modification of the font path + +The `xset' utility may be used to modify the font path for the current ses- +sion. The font path is set with the command xset fp; a new element is added +to the front with xset +fp, and added to the end with xset fp+. For example, + + $ xset +fp /usr/local/fonts/Type1 + $ xset fp+ /usr/local/fonts/bitmap + +Conversely, an element may be removed from the front of the font path with +`xset -fp', and removed from the end with `xset fp-'. You may reset the font +path to its default value with `xset fp default'. + +For more information, please consult the xset(1) manual page. + +2.2.4.2 Permanent modification of the font path + +The default font path (the one used just after server startup or after `xset +fp default') is specified in the X server's `xorg.conf' file. It is computed +by appending all the directories mentioned in the `FontPath' entries of the +`Files' section in the order in which they appear. + + FontPath "/usr/local/fonts/Type1" + ... + FontPath "/usr/local/fonts/bitmap" + +For more information, please consult the xorg.conf(5) manual page. + +2.2.5 Troubleshooting + +If you seem to be unable to use some of the fonts you have installed, the +first thing to check is that the `fonts.dir' files are correct and that they +are readable by the server (the X server usually runs as root, beware of NFS- +mounted font directories). If this doesn't help, it is quite possible that +you are trying to use a font in a format that is not supported by your +server. + +X11R6.9 supports the BDF, PCF, SNF, Type 1, TrueType, OpenType and CIDFont +font formats. However, not all X11R6.9 servers come with all the font back- +ends configured in. + +On most platforms, the X11R6.9 servers are modular: the font backends are +included in modules that are loaded at runtime. The modules to be loaded are +specified in the `xorg.conf' file using the `Load' directive: + + Load "type1" + +If you have trouble installing fonts in a specific format, you may want to +check the server's log file in order to see whether the relevant modules are +properly loaded. The list of font modules distributed with X11R6.9 is as +follows: + + o "bitmap": bitmap fonts (`*.bdf', `*.pcf' and `*.snf'); + + o "freetype": TrueType fonts (`*.ttf' and `*.ttc'), OpenType fonts + (`*.otf' and `*.otc') and Type 1 fonts (`*.pfa' and `*.pfb'); + + o "type1": alternate Type 1 backend (`*.pfa' and `*.pfb') and CIDFont + backend; + + o "xtt": alternate TrueType backend (`*.ttf' and `*.ttc'). + +Please note that the argument of the `Load' directive is case-sensitive. + +3. Fonts included with X11R6.9 + +3.1 Standard bitmap fonts + +The Sample Implementation of X11 (SI) comes with a large number of bitmap +fonts, including the `fixed' family, and bitmap versions of Courier, Times, +Helvetica and some members of the Lucida family. In the SI, these fonts are +provided in the ISO 8859-1 encoding (ISO Latin Western-European). + +In X11R6.9, a number of these fonts are provided in Unicode-encoded font +files instead. At build time, these fonts are split into font files encoded +according to legacy encodings, a process which allows us to provide the stan- +dard fonts in a number of regional encodings with no duplication of work. + +For example, the font file + + /usr/X11R6/lib/X11/fonts/misc/6x13.bdf + +with XLFD + + -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 + +is a Unicode-encoded version of the standard `fixed' font with added support +for the Latin, Greek, Cyrillic, Georgian, Armenian, IPA and other scripts +plus numerous technical symbols. It contains over 2800 glyphs, covering all +characters of ISO 8859 parts 1-5, 7-10, 13-15, as well as all European IBM +and Microsoft code pages, KOI8, WGL4, and the repertoires of many other char- +acter sets. + +This font is used at build time for generating the font files + + 6x13-ISO8859-1.bdf + 6x13-ISO8859-2.bdf + ... + 6x13-ISO8859-15.bdf + 6x13-KOI8-R.bdf + +with respective XLFDs + + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1 + ... + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-15 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-koi8-r + +The standard short name `fixed' is normally an alias for + + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1 + +3.2 The ClearlyU Unicode font family + +The ClearlyU family of fonts provides a set of 12 pt, 100 dpi proportional +fonts with many of the glyphs needed for Unicode text. Together, the fonts +contain approximately 7500 glyphs. + +The main ClearlyU font has the XLFD + + -mutt-clearlyu-medium-r-normal--17-120-100-100-p-101-iso10646-1 + +and resides in the font file + + /usr/X11R6/lib/X11/fonts/misc/cu12.pcf.gz + +Additional ClearlyU fonts include + + -mutt-clearlyu alternate glyphs-medium-r-normal--17-120-100-100-p-91-iso10646-1 + -mutt-clearlyu pua-medium-r-normal--17-120-100-100-p-111-iso10646-1 + -mutt-clearlyu arabic extra-medium-r-normal--17-120-100-100-p-103-fontspecific-0 + -mutt-clearlyu ligature-medium-r-normal--17-120-100-100-p-141-fontspecific-0 + +The Alternate Glyphs font contains additional glyph shapes that are needed +for certain languages. A second alternate glyph font will be provided later +for cases where a character has more than one commonly used alternate shape +(e.g. the Urdu heh). + +The PUA font contains extra glyphs that are useful for certain rendering pur- +poses. + +The Arabic Extra font contains the glyphs necessary for characters that don't +have all of their possible shapes encoded in ISO 10646. The glyphs are +roughly ordered according to the order of the characters in the ISO 10646 +standard. + +The Ligature font contains ligatures for various scripts that may be useful +for improved presentation of text. + +3.3 Standard scalable fonts + +X11R6.9 includes all the scalable fonts distributed with X11R6. + +3.3.1 Standard Type 1 fonts + +The IBM Courier set of fonts cover ISO 8859-1 and ISO 8859-2 as well as Adobe +Standard Encoding. These fonts have XLFD + + -adobe-courier-medium-*-*--0-0-0-0-m-0-*-* + +and reside in the font files + + /usr/X11R6/lib/X11/fonts/Type1/cour*.pfa + +The Adobe Utopia set of fonts only cover ISO 8859-1 as well as Adobe Standard +Encoding. These fonts have XLFD + + -adobe-utopia-*-*-normal--0-0-0-0-p-0-iso8859-1 + +and reside in the font files + + /usr/X11R6/lib/X11/fonts/Type1/UT*.pfa + +Finally, X11R6.9 also comes with Type 1 versions of Bitstream Courier and +Charter. These fonts have XLFD + + -bitstream-courier-*-*-normal--0-0-0-0-m-0-iso8859-1 + -bitstream-charter-*-*-normal--0-0-0-0-p-0-iso8859-1 + +and reside in the font files + + /usr/X11R6/lib/X11/fonts/Type1/c*bt_.pfb + +3.4 The Bigelow & Holmes Luxi family + +X11R6.9 includes the Luxi family of scalable fonts, in both TrueType and +Type 1 format. This family consists of the fonts Luxi Serif, with XLFD + + -b&h-luxi serif-medium-*-normal--*-*-*-*-p-*-*-* + +Luxi Sans, with XLFD + + -b&h-luxi sans-medium-*-normal--*-*-*-*-p-*-*-* + +and Luxi Mono, with XLFD + + -b&h-luxi mono-medium-*-normal--*-*-*-*-m-*-*-* + +Each of these fonts comes Roman, oblique, bold and bold oblique variants The +TrueType version have glyphs covering the basic ASCII Unicode range, the +Latin 1 range, as well as the Extended Latin range and some additional punc- +tuation characters. In particular, these fonts include all the glyphs needed +for ISO 8859 parts 1, 2, 3, 4, 9, 13 and 15, as well as all the glyphs in the +Adobe Standard encoding and the Windows 3.1 character set. + +The glyph coverage of the Type 1 versions is somewhat reduced, and only cov- +ers ISO 8859 parts 1, 2 and 15 as well as the Adobe Standard encoding. + +The Luxi fonts are original designs by Kris Holmes and Charles Bigelow. Luxi +fonts include seriffed, sans serif, and monospaced styles, in roman and +oblique, and normal and bold weights. The fonts share stem weight, x-height, +capital height, ascent and descent, for graphical harmony. + +The character width metrics of Luxi roman and bold fonts match those of core +fonts bundled with popular operating and window systems. + +The license terms for the Luxi fonts are included in the file `COPYRIGHT.BH', +as well as in the License document. + +Charles Bigelow and Kris Holmes from Bigelow and Holmes Inc. developed the +Luxi typeface designs in Ikarus digital format. + +URW++ Design and Development GmbH converted the Ikarus format fonts to True- +Type and Type1 font programs and implemented the grid-fitting "hints" and +kerning tables in the Luxi fonts. + +For more information, please contact or +, or consult the URW++ web site . + +An earlier version of the Luxi fonts was made available under the name +Lucidux. This name should no longer be used due to trademark uncertainties, +and all traces of the Lucidux name have been removed from X11R6.9. + +4. More about core fonts + +This section describes X11R6.9-specific enhancements to the core X11 fonts +system. + +4.1 Core fonts and internationalisation + +The scalable font backends (Type 1 and TrueType) can automatically re-encode +fonts to the encoding specified in the XLFD in `fonts.dir'. For example, a +`fonts.dir' file can contain entries for the Type 1 Courier font such as + + cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 + cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-2 + +which will lead to the font being recoded to ISO 8859-1 and ISO 8859-2 +respectively. + +4.1.1 The fontenc layer + +Two of the scalable backends (Type 1 and the FreeType TrueType backend) use a +common fontenc layer for font re-encoding. This allows these backends to +share their encoding data, and allows simple configuration of new locales +independently of font type. + +Please note: the X-TrueType (X-TT) backend is not included in X11R6.9. That +functionality has been merged into the FreeType backend.> + +In the fontenc layer, an encoding is defined by a name (such as iso8859-1), +possibly a number of aliases (alternate names), and an ordered collection of +mappings. A mapping defines the way the encoding can be mapped into one of +the target encodings known to fontenc; currently, these consist of Unicode, +Adobe glyph names, and arbitrary TrueType ``cmap''s. + +A number of encodings are hardwired into fontenc, and are therefore always +available; the hardcoded encodings cannot easily be redefined. These +include: + + o iso10646-1: Unicode; + + o iso8859-1: ISO Latin-1 (Western Europe); + + o iso8859-2: ISO Latin-2 (Eastern Europe); + + o iso8859-3: ISO Latin-3 (Southern Europe); + + o iso8859-4: ISO Latin-4 (Northern Europe); + + o iso8859-5: ISO Cyrillic; + + o iso8859-6: ISO Arabic; + + o iso8859-7: ISO Greek; + + o iso8859-8: ISO Hebrew; + + o iso8859-9: ISO Latin-5 (Turkish); + + o iso8859-10: ISO Latin-6 (Nordic); + + o iso8859-15: ISO Latin-9, or Latin-0 (Revised Western-European); + + o koi8-r: KOI8 Russian; + + o koi8-u: KOI8 Ukrainian (see RFC 2319); + + o koi8-ru: KOI8 Russian/Ukrainian; + + o koi8-uni: KOI8 ``Unified'' (Russian, Ukrainian, and Byelorussian); + + o koi8-e: KOI8 ``European,'' ISO-IR-111, or ECMA-Cyrillic; + + o microsoft-symbol and apple-roman: these are only likely to be useful + with TrueType symbol fonts. + +Additional encodings can be added by defining encoding files. When a font +encoding is requested that the fontenc layer doesn't know about, the backend +checks the directory in which the font file resides (not necessarily the +directory with fonts.dir!) for a file named `encodings.dir'. If found, this +file is scanned for the requested encoding, and the relevant encoding defini- +tion file is read in. The `mkfontdir' utility, when invoked with the `-e' +option followed by the name of a directory containing encoding files, can be +used to automatically build `encodings.dir' files. Please see the mkfont- +dir(1) manual page for more details. + +A number of encoding files for common encodings are included with X11R6.9. +Information on writing new encoding files can be found in Format of encodings +directory files (section 4.1.3, page 1) and Format of encoding files (section +4.1.4, page 1) later in this document. + +4.1.2 Backend-specific notes about fontenc + +4.1.2.1 The FreeType backend + +For TrueType and OpenType fonts, the FreeType backend scans the mappings in +order. Mappings with a target of PostScript are ignored; mappings with a +TrueType or Unicode target are checked against all the cmaps in the file. +The first applicable mapping is used. + +For Type 1 fonts, the FreeType backend first searches for a mapping with a +target of PostScript. If one is found, it is used. Otherwise, the backend +searches for a mapping with target Unicode, which is then composed with a +built-in table mapping codes to glyph names. Note that this table only cov- +ers part of the Unicode code points that have been assigned names by Adobe. + +Specifying an encoding value of adobe-fontspecific for a Type 1 font disables +the encoding mechanism. This is useful with symbol and incorrectly encoded +fonts (see Incorrectly encoded fonts (section 4.1.6, page 1) below). + +If a suitable mapping is not found, the FreeType backend defaults to +ISO 8859-1. + +4.1.2.2 Type 1 + +The Type 1 backend behaves similarly to the FreeType backend with Type 1 +fonts, except that it limits all encodings to 8-bit codes. + +4.1.3 Format of encoding directory files + +In order to use a font in an encoding that the font backend does not know +about, you need to have an `encodings.dir' file either in the same directory +as the font file used or in a system-wide location +(`/usr/X11R6/lib/X11/fonts/encodings/' by default). + +The `encodings.dir' file has a similar format to `fonts.dir'. Its first line +specifies the number of encodings, while every successive line has two +columns, the name of the encoding, and the name of the encoding file; this +can be relative to the current directory, or absolute. Every encoding name +should agree with the encoding name defined in the encoding file. For exam- +ple, + + 3 + mulearabic-0 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-0.enc + mulearabic-1 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-1.enc + mulearabic-2 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-2.enc + +The name of an encoding must be specified in the encoding file's `STARTENCOD- +ING' or `ALIAS' line. It is not enough to create an `encodings.dir' entry. + +If your platform supports it (it probably does), encoding files may be com- +pressed or gzipped. + +The `encoding.dir' files are best maintained by the `mkfontdir' utility. +Please see the mkfontdir(1) manual page for more information. + +4.1.4 Format of encoding files + +The encoding files are ``free form,'' i.e. any string of whitespace is equiv- +alent to a single space. Keywords are parsed in a non-case-sensitive manner, +meaning that `size', `SIZE', and `SiZE' all parse as the same keyword; on the +other hand, case is significant in glyph names. + +Numbers can be written in decimal, as in `256', in hexadecimal, as in +`0x100', or in octal, as in `0400'. + +Comments are introduced by a hash sign `#'. A `#' may appear at any point in +a line, and all characters following the `#' are ignored, up to the end of +the line. + +The encoding file starts with the definition of the name of the encoding, and +possibly its alternate names (aliases): + + STARTENCODING mulearabic-0 + ALIAS arabic-0 + +The name of the encoding and its aliases should be suitable for use in an +XLFD font name, and therefore contain exactly one dash `-'. + +The encoding file may then optionally declare the size of the encoding. For +a linear encoding (such as ISO 8859-1), the SIZE line specifies the maximum +code plus one: + + SIZE 0x2B + +For a matrix encoding, it should specify two numbers. The first is the num- +ber of the last row plus one, the other, the highest column number plus one. +In the case of `jisx0208.1990-0' (JIS X 0208(1990), double-byte encoding, +high bit clear), it should be + + SIZE 0x75 0x80 + +In the case of a matrix encoding, a `FIRSTINDEX' line may be included to +specify the minimum glyph index in an encoding. The keyword `FIRSTINDEX' is +followed by two integers, the minimum row number followed by the minimum col- +umn number: + + FIRSTINDEX 0x20 0x20 + +In the case of a linear encoding, a `FIRSTINDEX' line is not very useful. If +for some reason however you chose to include on, it should be followed by a +single integer. + +Note that in most font backends inclusion of a `FIRSTINDEX' line has the side +effect of disabling default glyph generation, and this keyword should there- +fore be avoided unless absolutely necessary. + +Codes outside the region defined by the `SIZE' and `FIRSTINDEX' lines are +understood to be undefined. Encodings default to linear encoding with a size +of 256 (0x100). This means that you must declare the size of all 16 bit +encodings. + +What follows is one or more mapping sections. A mapping section starts with +a `STARTMAPPING' line stating the target of the mapping. The target may be +one of: + + o Unicode (ISO 10646): + + STARTMAPPING unicode + + o a given TrueType ``cmap'': + + STARTMAPPING cmap 3 1 + + o PostScript glyph names: + + STARTMAPPING postscript + +Every line in a mapping section maps one from the encoding being defined to +the target of the mapping. In mappings with a Unicode or TrueType mapping, +codes are mapped to codes: + + 0x21 0x0660 + 0x22 0x0661 + ... + +As an abbreviation, it is possible to map a contiguous range of codes in a +single line. A line consisting of three integers + + ) and has the X-TT functionalities for CJKV +support provided by the After X-TT Project (see the After X-TT Project web +site ). The FreeType module has support for +the ``fontenc'' style of internationalisation (see The fontenc layer (section +4.1.1, page 1)). This backend supports TrueType font files (`*.ttf'), Open- +Type font files (`*.otf'), TrueType Collections (`*.ttc'), OpenType Collec- +tions (`*.otc') and Type 1 font files (`*.pfa' and `*.pfb'). + +In order to access the faces in a TrueType Collection file, the face number +must be specified in the fonts.dir file before the filename, within a pair of +colons, or by setting the 'fn' TTCap option. For example, + + :1:mincho.ttc -misc-pmincho-medium-r-normal--0-0-0-0-p-0-jisx0208.1990-0 + +refers to face 1 in the `mincho.ttc' TrueType Collection file. + +The new FreeType backend supports the extended `fonts.dir' syntax introduced +by X-TrueType with a number of options, collectively known as `TTCap'. A +`TTCap' entry follows the general syntax + + option=value: + +and should be specified before the filename. The new FreeType almost per- +fectly supports TTCap options that are compatible with X-TT 1.4. The Auto- +matic Italic (`ai'), Double Strike (`ds') and Bounding box Width (`bw') +options are indispensable in CJKV. For example, + + mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0 + ds=y:mincho.ttc -misc-mincho-bold-r-normal--0-0-0-0-c-0-jisx0208.1990-0 + ai=0.2:mincho.ttc -misc-mincho-medium-i-normal--0-0-0-0-c-0-jisx0208.1990-0 + ds=y:ai=0.2:mincho.ttc -misc-mincho-bold-i-normal--0-0-0-0-c-0-jisx0208.1990-0 + bw=0.5:mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0201.1976-0 + bw=0.5:ds=y:mincho.ttc -misc-mincho-bold-r-normal--0-0-0-0-c-0-jisx0201.1976-0 + bw=0.5:ai=0.2:mincho.ttc -misc-mincho-medium-i-normal--0-0-0-0-c-0-jisx0201.1976-0 + bw=0.5:ds=y:ai=0.2:mincho.ttc -misc-mincho-bold-i-normal--0-0-0-0-c-0-jisx0201.1976-0 + +setup the complete combination of jisx0208 and jisx0201 using mincho.ttc +only. More information on the TTCap syntax is found on the After X-TT Pro- +ject page . + +The FreeType backend uses the fontenc layer in order to support recoding of +fonts; this was described in The fontenc layer (section 4.1.1, page 1) and +especially FreeType-specific notes about fontenc (section 4.1.2.1, page 1) +earlier in this document. + +4.2.2 About the X-TrueType TrueType backend + +The `X-TrueType' backend is a backend based on version 1 of the FreeType +library. X-TrueType doesn't use the `fontenc' layer for managing font encod- +ings, but instead uses its own database of encodings. + +Since the functionalities for CJKV support introduced by X-TT have been +merged into the new FreeType backend, the X-TT backend will be removed from +X11R6.9's tree near the future. Therefore, the use of FreeType backend is +preferred over the X-TT backend. + +General information on X-TrueType may be found at the After X-TT Project page +. + +4.2.3 Delayed glyph rasterisation + +When loading a proportional fonts which contain a huge number of glyphs, the +old FreeType delayed glyph rasterisation until the time at which the glyph +was first used. The new FreeType (libfreetype-xtt2) has an improved `very +lazy' metric calculation method to speed up the process when loading TrueType +or OpenType fonts. Although the X-TT module also has this method, the +"vl=y" TTCap option must be set if you want to use it. This is the default +method for FreeType when it loads multi-byte fonts. Even if you use a uni- +code font which has tens of thousands of glyphs, this delay will not be wor- +risome as long as you use the new FreeType backend -- its `very lazy' method +is super-fast. + +The maximum error of bitmap position using `very lazy' method is 1 pixel, and +is the same as that of a character-cell spacing. When the X-TT backend is +used with the `vl=y' option, a chipped bitmap is displayed with certain +fonts. However, the new FreeType backend has minimal problem with this, +since it corrects left- and right-side bearings using `italicAngle' in the +TrueType/OpenType post table, and does automatic correction of bitmap posi- +tions when rasterisation so that chipped bitmaps are not displayed. Never- +theless if you don't want to use the `very lazy' method when using multi- +bytes fonts, set `vl=n' in the TTCap option to disable it: + + vl=n:luxirr.ttf -b&h-Luxi Serif-medium-r-normal--0-0-0-0-p-0-iso10646-1 + +Of course, both backends also support an optimisation for character-cell +fonts (fonts with all glyph metrics equal, or terminal fonts). A font with +an XLFD specifying a character-cell spacing `c', as in + + -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0 + +or + + fs=c:mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-p-0-jisx0208.1990-0 + +will not compute the metric for each glyph, but instead trust the font to be +a character-cell font. You are encouraged to make use of this optimisation +when useful, but be warned that not all monospaced fonts are character-cell +fonts. + +5. Appendix: background and terminology + +5.1 Characters and glyphs + +A computer text-processing system inputs keystrokes and outputs glyphs, small +pictures that are assembled on paper or on a computer screen. Keystrokes and +glyphs do not, in general, coincide: for example, if the system does generate +ligatures, then to the sequence of two keystrokes will typically cor- +respond a single glyph. Similarly, if the system shapes Arabic glyphs in a +vaguely reasonable manner, then multiple different glyphs may correspond to a +single keystroke. + +The complex transformation rules from keystrokes to glyphs are usually fac- +tored into two simpler transformations, from keystrokes to characters and +from characters to glyphs. You may want to think of characters as the basic +unit of text that is stored e.g. in the buffer of your text editor. While +the definition of a character is intrinsically application-specific, a number +of standardised collections of characters have been defined. + +A coded character set is a set of characters together with a mapping from +integer codes --- known as codepoints --- to characters. Examples of coded +character sets include US-ASCII, ISO 8859-1, KOI8-R, and JIS X 0208(1990). + +A coded character set need not use 8 bit integers to index characters. Many +early systems used 6 bit character sets, while 16 bit (or more) character +sets are necessary for ideographic writing systems. + +5.2 Font files, fonts, and XLFD + +Traditionally, typographers speak about typefaces and founts. A typeface is +a particular style or design, such as Times Italic, while a fount is a +molten-lead incarnation of a given typeface at a given size. + +Digital fonts come in font files. A font file contains the information nec- +essary for generating glyphs of a given typeface, and applications using font +files may access glyph information in an arbitrary order. + +Digital fonts may consist of bitmap data, in which case they are said to be +bitmap fonts. They may also consist of a mathematical description of glyph +shapes, in which case they are said to be scalable fonts. Common formats for +scalable font files are Type 1 (sometimes incorrectly called ATM fonts or +PostScript fonts), TrueType and OpenType. + +The glyph data in a digital font needs to be indexed somehow. How this is +done depends on the font file format. In the case of Type 1 fonts, glyphs +are identified by glyph names. In the case of TrueType fonts, glyphs are +indexed by integers corresponding to one of a number of indexing schemes +(usually Unicode --- see below). + +The X11 core fonts system uses the data in a font file to generate font +instances, which are collections of glyphs at a given size indexed according +to a given encoding. + +X11 core font instances are usually specified using a notation known as the X +Logical Font Description (XLFD). An XLFD starts with a dash `-', and con- +sists of fourteen fields separated by dashes, for example: + + -adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1 + +Or particular interest are the last two fields `iso8859-1', which specify the +font instance's encoding. + +A scalable font is specified by an XLFD which contains zeroes instead of some +fields: + + -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 + +X11 font instances may also be specified by short name. Unlike an XLFD, a +short name has no structure and is simply a conventional name for a font +instance. Two short names are of particular interest, as the server will not +start if font instances with these names cannot be opened. These are +`fixed', which specifies the fallback font to use when the requested font +cannot be opened, and `cursor', which specifies the set of glyphs to be used +by the mouse pointer. + +Short names are usually implemented as aliases to XLFDs; the standard `fixed' +and `cursor' aliases are defined in + + /usr/X11R6/lib/X11/font/misc/fonts.alias + +5.3 Unicode + +Unicode (urlnam ) is a coded character set with +the goal of uniquely identifying all characters for all scripts, current and +historical. While Unicode was explicitly not designed as a glyph encoding +scheme, it is often possible to use it as such. + +Unicode is an open character set, meaning that codepoint assignments may be +added to Unicode at any time (once specified, though, an assignment can never +be changed). For this reason, a Unicode font will be sparse, meaning that it +only defines glyphs for a subset of the character registry of Unicode. + +The Unicode standard is defined in parallel with the international standard +ISO 10646. Assignments in the two standards are always equivalent, and we +often use the terms Unicode and ISO 10646 interchangeably. + +When used in the X11 core fonts system, Unicode-encoded fonts should have the +last two fields of their XLFD set to `iso10646-1'. + +6. References + +X11R6.9 comes with extensive documentation in the form of manual pages and +typeset documents. Before installing fonts, you really should read the font- +config(3) and mkfontdir(1) manual pages; other manual pages of interest +include X(7), Xserver(1), xset(1), Xft(3), xlsfonts(1) and showfont(1). In +addition, you may want to read the X Logical Font Description document, by +Jim Flowers, which is provided in the file `xc/doc/xlfd.PS.Z'. + +The latest released version of the X11R6.9 documentation (including this doc- +ument and all manual pages) can be found from current X11R6.9 documentation +. + +The comp.fonts FAQ , which is +unfortunately no longer being maintained, contains a wealth of information +about digital fonts. + +Xft and Fontconfig are described on Keith Packard's Fontconfig site +. + +The xfsft home page +has been superseded by this document, and is now obsolete; you may however +still find some of the information that it contains useful. Joerg Pommnitz' +xfsft page is the +canonical source for the `ttmkfdir' utility, which is the ancestor of +mkfontscale. + +The author's software pages +might or might not contain related scribbles and development versions of +software. + +The documentation of X-TrueType is available from the After X-TT Project page +. + +A number of East-Asian CIDFonts are available from O'Reilly's FTP site +. + +While the Unicode consortium site may be of +interest, you are more likely to find what you need in Markus Kuhn's UTF-8 +and Unicode FAQ . + +The IANA RFC documents, available from a number of sites throughout the +world, often provide interesting information about character set issues; see +for example RFC 373. + + +$XdotOrg$ diff --git a/xorg-server/hw/xfree86/doc/README.rapidaccess b/xorg-server/hw/xfree86/doc/README.rapidaccess new file mode 100644 index 000000000..39f515ee2 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/README.rapidaccess @@ -0,0 +1,48 @@ +The IBM Rapid Access keyboard have some extra buttons +on it to launch programs, control a cd-player and so on. + +These buttons is not functional when the computer is turned +on but have to be activated by sending the codes 0xea 0x71 +to it. + +I've written the following hack to send codes to the keyboard: + +-------------------------------------------------------------- +/* gcc -O2 -s -Wall -osend_to_keyboard send_to_keyboard.c */ +#include +#include +#include + +int main( int argc, char *argv[] ) +{ + int i; + + ioperm( 0x60, 3, 1 ); + + for( i = 1; i < argc; i++ ) { + int x = strtol( argv[i], 0, 16 ); + + usleep( 300 ); + outb( x, 0x60 ); + } + + return 0; +} +-------------------------------------------------------------- + +As root you can then call this program (in your boot scripts) +as "send_to_keyboard ea 71" to turn on the extra buttons. + +It's not a good idea to run several instances of this program +at the same time. It is a hack but it works. If you try to +send other codes to the keyboard it probably will lock up. +For other codes see: + +http://www.win.tue.nl/~aeb/linux/kbd/scancodes-2.html#ss2.22 + +-- +Dennis Björklund + + + +$XFree86$ diff --git a/xorg-server/hw/xfree86/doc/devel/DebuggingHints b/xorg-server/hw/xfree86/doc/devel/DebuggingHints new file mode 100644 index 000000000..300fe4813 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/DebuggingHints @@ -0,0 +1,192 @@ + + Xserver Debugging + ================= + +This file is intended to collect helpful hints on Xserver debugging. +I merely outline my experiences here. Somebody else might have better +methods on doing it. This person is therefore invited to share this +experience with the rest of the world by adding it here. + +Paul Flinders has made some patches to gdb to add support for loadable +modules. This version of gdb is currently available as binary for +Linux/x86 on Paul's web site: + + www.dawa.demon.co.uk/xfree-gdb + +This web-site also contains the patches to gdb 4.18 so you may port it +to other platforms. + +It loads the module symbols and supports all gdb features like +breakpointing, disassembling and single stepping. It also shows the +exact location of a signal 11. Paul has fixed the code so that all of +this is working even if using modules compiled without -g. You can +find his latest version on his web site. + +If no module aware gdb is available the following hints might help: + +1. Use remote login. This can be done thru a network connection or + simply by connecting a serial console. This enables you to watch + the Xservers output while running set breakpoints with gdb etc. + Don't even try to run the Xserver from a system console. Whenever + something happens gdb waits for input. However the Xserver has + locked the system console including the keyboard, therefore you'll + never be able to send any input to gdb. Even if your process + doesn't crash or you haven't set any breakpoints a vt switch can be + hazardous: When doing vt switching a signal is sent; unless you did + + gdb> handle SIGUSR1 nostop + + gdb waits for you to continue the program which cannot happen as + you don't have access to gdb's console. + +2. You can compile any source file with debugging symbols to obtain + more information about where an error occurred. Simply go to the + directory which holds the corresponding object file and do: + + # rm .o + # xc/config/util/makeg.sh .o + + After relinking the server or module gdb is able to obtain the + necessary debugging information and will show the exact line in the + source where the error ccurred. See also: + xc/config/util/makeg.man. + +3. In some cases it might be useful to have the assembler output of a + compiled source file. This can be obtained by doing: + + # make .s + + or + + # xc/config/util/makeg.sh .s + + Make will use exactly the same rules it uses for building *.o files. + +4. In some cases it might be useful to set breakpoints in modules. If + no module aware gdb is available you should add a call to one of + the three dummy breakpoint functions + + xf86Break1(), xf86Break2() and xf86Break3() + + to the source file and recompile the module. You now just have to + set a breakpoint onto the appropriate dummy functions. These + functions are located in the core part of the server and therefore + will be available any time. + +5. Without module support gdb is not able to print the function where + an error occurred in a module. + + If you get a line like: + + (gdb) bt + #0 0x823b4f5 in ?? () + .... + + You may obtain the function the address belongs to by calling + LoaderPrintSymbol(): + + (gdb) call LoaderPrintSymbol(0x823b4f5) + + The symbol returned might not always be the name of the function + which contains the address. In case of static functions the symbol + is not known to the loader. However LoaderPrintSymbol() will print + the nearest known function and the offset from its start. You may + easily find the exact location of the address if you do: + + # objdump --disassemble .o + + .o is the name of the object file containing the symbol printed. + +6. Locating static symbols in modules is simpler if the module is a + single object file instead of a library. Such a object file can + easily be build from a library: # mkdir tmp # cd tmp; ar x + module-path/.a # ld -r *.o -o module-path/.o + + When calling LoaderPrintSymbol() the closes public symbol will be + printed together with the offset from the symbol's address. If a + static symbol comes before the first public symbol in a module The + following trick may help: + + create a file 1-.c in tmp/ + containing: + void Dummy-() {} + + Compile it: + + # gcc -c 1-.c + + and do the link step above. + + This way Dummy-() will be the first public function in the + module. All addresses in static function can now be printed + relatively to this address if no other public function comes before + this static one. + +7. In some situations it is quite helpful to add debugging symbols to + the binary. This can be done per object file. Simply remove the + object file and do + + # makeg + + When looking for a bug in a module these debugging infos can be + very helpful: Calling LoaderPrintSymbol() as described above will + return a function and an offset giving the exact location of the + address with respect to this function entry point. When + disassembling an object file with debugging symbols: # objdump -d + -l .o one will receive a disassembled output containing line + number information. Thus one can locate the exact line of code + where the error occurred. + +8. To quickly trace the value of a variable declared in a module three + dummy variables have been added to the core part: + + CARD32 xf86DummyVar1; + CARD32 xf86DummyVar2; + CARD32 xf86DummyVar3; + + The variable can be assigned to one of them. One can then use gdb + to return the value of this variable: + + gdb> p /x xf86DummyVar1 + +9. Sometimes it might be useful to check how the preprocessor replaced + symbols. One can obtain a preprocessed version of the source file + by doing: + + make .i + + This will generate a preprocessed source in .i. + +10. xfree() can catch if one tries to free a memory range twice. You + will get the message: + + Xalloc error: range already freed in Xrealloc() :-( + + To find the location from which xfree() was called one can + breakpoint on XfreeTrap(). The backtrace should show the origin of the + call this call. + +11. To access mapped physical memory the following functions might be + useful. + + These may be used to access physical memory that was mapped using + the flags VIDMEM_FRAMEBUFFER or VIDMEM_MMIO32: + + CARD8 xf86PeekFb8(CARD8 *p); + CARD16 xf86PeekFb16(CARD16 *p); + CARD32 xf86PeekFb32(CARD32 *p); + void xf86PokeFb8(CARD8 *p, CARD8 v); + void xf86PokeFb16(CARD16 *p, CARD16 v); + void xf86PokeFb32(CARD16 *p, CARD32 v); + + Physical memory which was mapped by setting VIDMEM_MMIO should be + accessed using the following. Here the base address to which the + memory is mapped and the offset are required separately. + + CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset); + CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset); + CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset); + void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v); + void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v); + void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v); + diff --git a/xorg-server/hw/xfree86/doc/devel/Domain.note b/xorg-server/hw/xfree86/doc/devel/Domain.note new file mode 100644 index 000000000..ce0812b22 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/Domain.note @@ -0,0 +1,159 @@ +The purpose of the changes described here is to implement a more general +framework for multi-head on systems with more than one host-to-PCI bridge. +The changes also implement a basic port of XFree86 to SPARC Solaris. + +These changes are derived from David S. Miller's submission #4653 to the +patch list. David Andrew of Sun Microsystems was also kind enough to +arrange for a hardware loan for development of these changes. + +These changes are known to work on several SPARC SunOS and UltraSPARC +Linux configurations. Linux kernel work is in progress to port these +changes to Linux/PowerPC. + +Several loose ends still need to be addressed before these changes can be +considered stable. The bulk of this note is devoted to enumerating what +remains to be done, along with other notes, broken down into various broad +categories. + +SPARC SunOS (aka Solaris) +------------------------- +- An overview of this XFree86 port is available in README.Solaris. +- The keyboard map code in hw/xfree86/os-support/sunos/sun_kbdEv.c needs + to be extended to handle more than only the sun5 keyboard I targeted it + for. Even for the sun5, the map is incomplete as several keys are not + mapped. What is there is just barely usable. +- On exit, the server will zero out /dev/fb, but that might not be the + right thing to do for all primary adapters. This does however + appear to emulate the behaviour of Sun's commercial servers. It also + eliminates the need for output drivers to save and restore video memory + contents. (They still need to save/restore the mode timing however.) + This also chimes into a long-standing XFree86 policy to not save/restore + video memory contents if the mode on entry is found to be non-VGA, a + policy several existing drivers comply with. +- The SBUS drivers (sunbw2, suncg14, suncg3, suncg6, sunffb, sunleo and + suntcx), the common layer's SBUS code and the fbdev driver have all + only been compile tested. There are likely to be Linux'isms within + them that remain to be dealt with. +- It still needs to be verified whether or not this work adversely + affected support for ix86 Solaris. + +UltraSPARC Linux +---------------- +- Although this code can be compiled using any Linux/SPARC64 kernel, it + can only run successfully using 2.4.12 or later. +- I haven't had time to sufficiently dig into XKB to properly configure it + for sun5 keyboards. Given XFree86 on Linux/SPARC has been around for a + while, it's likely someone has already done this, and I'd appreciate + receiving a copy of a working XF86Config input section. + +PowerPC Linux +------------- +- As mentioned above, kernel work is in progress to port this PCI scheme + to Linux/PowerPC. +- Aside from kernel work, the inX() and outX() definitions in compiler.h + will need to be changed to do something akin to their SPARC definitions, + i.e. consider their port argument to be a virtual address. + +Other Linux ports to multi-domain architectures +----------------------------------------------- +- Comments in os-support/bus/linuxPci.c document the kernel interface + required to port these changes. In short, Linux ports, such as Alpha + and mips, should follow SPARC and PowerPC's lead in providing support to + mmap() PCI devices through their /proc/bus/pci pseudo-files and to treat + such requests for host bridges as requests to mmap() space provided by + these bridges. + +Other OS's +---------- +- In the right hands, either linuxPci.c or sparcPci.c can be used as a + guide for what would need to be done to port this scheme to other OS's. + Perhaps the largest difference between the two (in terms of interface to + the common layer) is that the SunOS port includes internally generated + domain numbers in PCITAG's, whereas the Linux port doesn't need to. The + remainder of the PCI code (which is OS-independent) can handle either + scheme. +- Required entry points are xf86GetPciDomain(), xf86MapDomainMemory(), + xf86MapDomainIO() and xf86ReadDomainMemory(). Replacements for + xf86BusAccWindowsFromOS(), xf86PciBusAccWindowsFromOS() and + xf86AccResFromOS() might also be required. +- Development of these changes has detected the fact that the XFree86 port + to the PowerMax OS is broken, and has been for some time, i.e. since + shortly after its introduction, back in the 3.9* days. + +SPARC PCI (OS-independent) +-------------------------- +- The "Simba" PCI-to-PCI bridge used in SPARC's does not implement VGA + routing, as defined in the PCI specs. Fortunately, OpenPROM seems to + always route VGA resources to the bus with PCI connectors, but this also + causes the common layer to not mark any PCI adapter as primary. + +Multiple PCI domains (architecture- and OS-independent) +------------------------------------------------------- +- This implementation assumes every host-to-PCI bridge provides access to + a separate PCI domain. Each such domain provides three different + "address" spaces: PCI configuration, I/O and memory. The + implementation can also deal with situations where more than one PCI + domain share (different subsets of) the same PCI configuration space. I + have unconfirmed information that suggests it might be necessary to also + allow the sharing of PCI memory spaces. +- This implementation also assumes the CPU's physical address space + includes the entirety of each domain's I/O and memory spaces. I know + this'll need to be changed to deal with the so-called UniNorth bridge, + found on PowerPC's, which allows access to only a subset of the memory + space behind it. +- Ideally, the common layer should mark as primary up to one PCI adapter + per domain. This has yet to be done. +- Something needs to be done about PCI master aborts on primary buses. + For details on this, see my long-winded diatribe in sparcPci.c, and + related comments in linuxPci.c. Suffice it to say here that I see the + eventual implementation of host bridge drivers within XFree86 as + unavoidable at this point. +- DGA is broken on multi-domain platforms. The information passed to the + client to locate the framebuffer still needs to be revised. The best way + to deal with this is to change all drivers' OpenFramebuffer() function to + call a common layer routine to set the device name and displacements to be + returned to the DGA client. + +Output drivers +-------------- +Most drivers currently used on ix86 need(ed) source code changes. +- Calls to xf86ReadBIOS() and xf86MapVidMem() were replaced with calls to + xf86ReadDomainMemory() and xf86MapDomainMemory() respectively. Except + for the "ati" and "atimisc" modules, this has already been done. +- All ix86-style I/O port numbers need to be declared as an IOADDRESS, a + type defined in xf86Pci.h as "unsigned long". Such port numbers also + need to be offset by a displacement which is also defined as an + IOADDRESS. Before a driver's PreInit() is called, the common layer + makes this displacement available in ScrnInfoRec.domainIOBase. For + single-domain architectures, such as ix86, domainIOBase will always be + zero. Current use of vgaHWRec.PIOOffset has also been adjusted + accordingly. Some drivers have been changed to keep a copy of this + displacement in their private structure. Internally, an IOADDRESS is + actually a pointer that has been recasted to an unsigned long, but the + common layer "hides" this fact from the driver ABI, which means that I/O + port numbers, as seen by drivers, remain as integers rather than + addresses. Aside from the ati and atimisc modules, s3, sis and tseng + are the only modules left whose I/O still needs to be converted (I've + temporarily run out of steam). +- Note that these conversions are not necessarily sufficient to produce + drivers that will work on any given multi-domain architecture. A driver + that, for example, had endianness problems, still does. But, at least, + these conversions, along with the supporting common layer changes, make + PCI drivers more widely amenable to porting. +- rdinx(), wrinx(), modinx(), testrg(), testinx() and testinx2() are not + given enough information to allow for the relocation of their I/O. They + are consequently being deleted. The apm and ark drivers, the only + remaining callers of the first three, have been changed to use local + definitions instead. The last three (test*()) were already unused. +- As a temporary measure, these changes completely disable ISA-style + probing on SPARC's and PowerPC's. This means that driver calls to + xf86MatchIsaInstances(), while still valid, will always return detection + failure on SPARC's and PowerPC's. This will be dealt with when a more + general master abort handling scheme is implemented. +- I need to make a decision about the master abort issues mentionned above + before I can convert the "ati" and "atimisc" modules. Consequently, + these modules still need to be compiled with -DAVOID_CPIO on + multi-domain architectures, and support for Mach64 variants as + non-primary heads is not yet available. + +$XFree86$ diff --git a/xorg-server/hw/xfree86/doc/devel/Makefile.am b/xorg-server/hw/xfree86/doc/devel/Makefile.am new file mode 100644 index 000000000..6ca350c38 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/Makefile.am @@ -0,0 +1,10 @@ +# Documentation for developers that is distributed with the source but +# not installed on the system for end-users + +EXTRA_DIST = \ + DebuggingHints \ + Domain.note \ + RAC.Notes \ + Registry \ + exa-driver.txt \ + README.DRIcomp diff --git a/xorg-server/hw/xfree86/doc/devel/Makefile.in b/xorg-server/hw/xfree86/doc/devel/Makefile.in new file mode 100644 index 000000000..7c169aff3 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/Makefile.in @@ -0,0 +1,542 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Documentation for developers that is distributed with the source but +# not installed on the system for end-users +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/doc/devel +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +EXTRA_DIST = \ + DebuggingHints \ + Domain.note \ + RAC.Notes \ + Registry \ + exa-driver.txt \ + README.DRIcomp + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/doc/devel/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/doc/devel/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/doc/devel/RAC.Notes b/xorg-server/hw/xfree86/doc/devel/RAC.Notes new file mode 100644 index 000000000..0aec9d795 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/RAC.Notes @@ -0,0 +1,696 @@ +I. Abstract +=========== + +Graphics devices are accessed thru ranges in I/O or memory space. While +most modern graphics devices allow relocation of such ranges many of +them still require the use of well established interfaces such as VGA +memory and IO ranges or 8514/A IO ranges. Up to version 3.3 of +XFree86 only a single graphics device could be driven. Therfore there +was no need to address the issue of sharing such memory or I/O ranges +among several devices. Starting with version 4.0 XFree86 is capable of +driving more than one graphics interface in a multi-head environment. +Therefore a mechanism needed to be designed which was capable of +controlling the sharing the access to memory and I/O ranges. In this +document we describe to use of the RAC (Resource Access Control) +system in the XFree86 server which provides the service of controlling +access to interface resources. + +II. Introduction +================ + +Terms and definitions: + +II.1. Bus +--------- + +'Bus' is ambiguous as it is used for different things: It may refer to +physical incompatible extension connectors in a computer system. The +RAC system knows two such systems: The ISA bus and the PCI bus. (On +the software level EISA, MC and VL buses are currently treated like +ISA buses). 'Bus' may always refer to logically different entities on +a single bus system which are connected via bridges. A PCI system may +have several distinct PCI buses connecting each other by PCI-PCI +bridges or to the host CPU by HOST-PCI bridges. + +Systems that host more than one bus system link these together using +bridges. Bridges are a concern to RAC as they might block or pass +specific resources. PCI-PCI bridges may be set up to pass VGA +resources to the secondary bus. PCI-ISA buses pass any resources not +decoded on the primary PCI bus to the ISA bus. This way VGA resources +(although exclusive on the ISA bus) can be shared by ISA and PCI +cards. Currently HOST-PCI bridges are not yet handled by RACY as they +require specific drivers. + +II.2. Entity +------------ + +The smallest independently addressable unit on a system bus is +referred to as an entity. So far we know ISA and PCI entities. PCI +entities can be located on the PCI bus by an unique ID consisting of +the bus, card and function number. + +II.3. Resource +-------------- + + 'Resource' refers to a range of memory or I/O addresses an entity +can decode. + +If a device is capable of disabling this decoding the resource is +called sharable. For PCI devices a generic method is provided to +control resource decoding. Other devices will have to provide a device +specific function to control decoding. + +If the entity is capable of decoding this range at a different +location this resource is considered relocatable. Resource which start +at a specific address and occupy a single continuous range are called +block resources. + +Alternatively resource addresses can be decoded in a way that they +satisfy the condition: + + address & mask == base + +with base & mask == base. Resources addressed in such a way are +considered sparse resources. + + +II.4. Server States +------------------ + +The resource access control system knows two server states: the SETUP +and the OPERATING state. The setup state is entered whenever a mode +change takes place or the server exits or does VT switching. During +this state any entity resource is under resource access control. +During OPERATING state only those entities are controlled which +actually have shared resources that conflict with others. The +determination which entity is to be placed under RAC during OPERATING +state takes place after ScreenInit() during the first server +generation. This doesn't apply if only one screen is active: in this +case no RAC is needed and the screen is simply left enabled while the +server is active. + + +III. Theory of operation +======================== + +III.1. General +-------------- + +The common level has knowledge of generic access control mechanisms +for devices on certain bus systems (currently the PCI bus) as well as +of methods to enable or disable access to the buses +itself. Furthermore it can access information on resources decoded by +these devices and if necessary modify it. + +When first starting the Xserver collects all this information, saves +it for restoration checks it for consistency and if necessary corrects +it. Finally it disables all resources on a generic level prior to +calling any driver function. + + The user should provide a device section in XF86Config for each +graphics device installed in his system. Each such entity which is +never to be used as X display device might be marked as inactive by +adding the keyword "Inactive" to the device section. + +When the Probe() function of each driver is called the device sections +are matched against the devices found in the system. The driver may +probe devices at this stage that cannot be identified by using device +independent methods. Access to all resources that can be controlled in +a device independent way is disabled. The Probe() function should +register all non-relocatable resources at this stage. If a resource +conflict is found between exclusive resources the driver will fail +immediately. Optionally the driver might specify an EntityInit(), +EntityLeave() and EntityEnter() function. + +EntityInit() can be used to disable any shared resources that are not +controlled by the generic access control functions. It is called prior +to the PreInit phase regardless if an entity is active or not. When +calling the EntityInit(), EntityEnter() and EntityLeave() functions +the common level will disable access to all other entities on a +generic level. Since the common level has no knowledge of device +specific methods to disable access to resources it cannot be +guaranteed that certain resources are not decoded by any other entity +until the EntityInit() or EntityEnter() phase is finished. Device +drivers should therefore register all those resources which they are +going to disable. If these resources are never to be used by any +driver function they may be flagged 'ResInit' so that they can be +removed from the resource list after processing all EntityInit() +functions. EntityEnter() should disable decoding of all resources +which are not registered as exclusive and which are not handled by the +generic access control in the common level. The difference to +EntityInit() is that the latter one is only called once during +lifetime of the server. It can therefore be used to set up variables +prior to disabling resources. EntityLeave() should restore the +original state when exiting the server or switching to a different vt. +It also needs to disable device specific access functions if they need +to be disabled on server exit or VT switch. The default state is to +enable them before giving up the VT. + +In PreInit() phase each driver should check if any sharable resources +it has registered during Probe() has been denied and take appropriate +action which could simply be to fail. If it needs to access resources +it has disabled during EntitySetup() it can do so provided it has +registered these and will disable them before returning from +PreInit(). This also applies to all other driver functions. Several +functions are provided to request resource ranges, register these, +correct PCI config space and add replacements for the generic access +functions. Resources may be marked 'disabled' or 'unused' during +OPERATING stage. Although these steps could also be performed in +ScreenInit(), this is not desirable. + +Following PreInit() phase the common level determines if resource +access control is needed. This is the case if more than one screen is +used. If necessary the RAC wrapper module is loaded. In ScreenInit() +the drivers can decide which operations need to be placed under +RAC. Available are the frame buffer operations, the pointer operations +and the colormap operations. Any operation that requires resources +which might be disabled during OPERATING state should be set to use +RAC. This can be specified separately for memory and IO resources. + +When ScreenInit() phase is done the common level will determine which +shared resources are requested by more than one driver and set the +access functions accordingly. This is done following these rules: + +a. The sharable resources registered by each entity are compared. if + a resource is registered by more than one entity the entity will be + marked to need to share this resources type (IO or MEM). + +b. A resource marked 'disabled' during OPERATING state will be ignored + entirely. + +c. A resource marked 'unused' will only conflicts with an overlapping + resource of an other entity if the second is actually in use during + OPERATING state. + +d. If an 'unused' resource was found to conflict however the entity + does not use any other resource of this type the entire resource + type will be disabled for that entity. + +The driver has the choice among different ways to control access to +certain resources: + +a. It can relay on the generic access functions. This is probably the + most common case. Here the driver only needs to register any + resource it is going to use. + +b. It can replace the generic access functions by driver specific + ones. This will mostly be used in cases where no generic access + functions are available. In this case the driver has to make sure + these resources are disabled when entering the PreInit() stage. + Since the replacement functions are registered in PreInit() the + driver will have to enable these resources itself if it needs to + access them during this state. The driver can specify if the + replacement functions can control memory and/or I/O resources + separately. + +c. The driver can enable resources itself when it needs them. Each + driver function enabling them needs to disable them before it will + return. This should be used if a resource which can be controlled + in a device dependent way is only required during SETUP state. This + way it can be marked 'unused' during OPERATING state. + +A resource which is decoded during OPERATING state however never +accessed by the driver should be marked unused. + +Since access switching latencies are an issue during Xserver +operation, the common level attempts to minimize the number of +entities that need to be placed under RAC control. When a wrapped +operation is called, the EnableAccess() function is called before +control is passed on. EnableAccess() checks if a screen is under +access control. If not it just establishes bus routing and returns. If +the screen needs to be under access control, EnableAccess() determines +which resource types (MEM,IO) are required. Then it tests if this +access is already established. If so it simply returns. If not it +disables the currently established access, fixes bus routing and +enables access to all entities registered for this screen. + +Whenever a mode switch or a vt-switch is performed the common level +will return to SETUP state. + +III.3. Resource Types +--------------------- + +Resource have certain properties. When registering resources each +range is accompanied by a flag consisting of the or'ed flags of the +different properties the resource has. Each resource range may be +classified according to + +- its physical properties ie. if it addresses + memory (ResMem) or + I/O space (ResIo), +- if it addresses a + block (ResBlock) or + sparse (ResSparse) + range, +- its access properties. + +There are two known access properties: + +- ResExclusive + for resources which may not be shared with any other device and +- ResShared + for resources which can be disabled and therefore can be shared. + +If it is desirable to test a resource against any type a generic +access type 'ResAny' is provided. If this is set the resource will +conflict with any resource of a different entity intersecting its +range. Further it can be specified that a resource is decoded however +never used during any stage (ResUnused) or during OPERATING state +(ResUnusedOpr). A resource only visible during the init functions (ie. +EntityInit(), EntityEnter() and EntityLeave() should be registered +with the flag 'ResInit'. A resource that might conflict with +background resource ranges may be flagged with 'ResBios'. This might +be useful when registering resources ranges that were assigned by the +system Bios. + +Several predefined resource lists are available for VGA and 8514/A +resources in common/sf86Resources.h. + +IV. Available Functions +======================= + +The functions provided for resource management will be listed in order +of use in the driver. + +IV.1. Probe phase +----------------- + +In this stage each driver detects those resources it is able to drive, +creates an entity record for each of them, registers non-relocatable +resources and allocates screens and adds the resources to screens. + +Two helper functions are provided for matching device sections in the +XF86Config file to the devices: + + int xf86MatchPciInstances(const char *driverName, int vendorID, + SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, + int **foundEntities); + + int xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets, + IsaChipsets *ISAchipsets, DriverPtr drvp, + FindIsaDevProc FindIsaDevice, GDevPtr *devList, + int numDevs, int **foundEntities); + +Both functions return the number of matched entities and their indices +in foundEntities list. + +They make use of several sub functions which are also available on the +driver level: + + Bool xf86ComparePciBusString(const char *busID, int bus, + int device, int func); + +and + + Bool xf86ParseIsaBusString(const char *busID); + +are called to interpret the busID in the device section. The functions: + + int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active); + + int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool + active); + +are used to allocate the entities and initialize their data +structures. Both functions return the index of the newly allocated +entity record or (-1) should the function fail. Before probing an ISA +card + + Bool xf86IsPrimaryIsa(); + +gets called to determine if the primary card was not detected on the +PCI bus. + +Two helper functions are provided to aid configuring entities: + + Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex, + PciChipsets *p_chip, resList res, + EntityProc init, EntityProc enter, + EntityProc leave, pointer private); + Bool xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex, + IsaChipsets *i_chip, resList res, + EntityProc init, EntityProc enter, + EntityProc leave, pointer private); + +They are used to register the init/enter/leave functions described +above as well as the non-relocatable resources. Generally the list of +fixed resources is obtained from the Isa/PciChipsets lists. However +an additional list of resources may be passed. Generally this is not +required. The init/enter/leave functions have to be of type + + typedef void (*EntityProc)(int entityIndex,pointer private); + +They are passed the entity index and a pointer to a private scratch +area. This are can be set up during Probe() and its address can be +passed to xf86ConfigActiveIsaEntity() xf86ConfigActivePciEntity() as +the last argument. + +These helper functions use: + + void xf86ClaimFixedResources(resList list, int entityIndex); + + To register the non relocatable resources which cannot be disabled + and which therefore would cause the server to fail immediately if + they were found to conflict. It also records non-relocatable but + sharable resources for processing after the Probe() phase. + + Bool xf86SetEntityFuncs(int entityIndex, EntityProc init, + EntityProc enter, EntityProc leave, pointer); + + This function registers the init/enter/leave() functions along with + the pointer to their private area to the entity. + + void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex); + + adds the entity to the screen. + +These functions are also available on the driver level. A detailed +Probe() function is listed below. For most drivers this can be used +with little change. + +Please note that VGA resources have to be claimed in Probe() +phase. Otherwise they are not routed to the bus. + +IV.2. PreInit() phase +--------------------- + +During this phase the remaining resource should be registered. +PreInit() should call + + EntityInfoPtr xf86GetEntityInfo(int entityIndex); + +To obtain a pointer to an EntityInfoRec for each entity it is able to +drive and check if any resource are listed in 'resources'. These have +been rejected in the post-Probe() phase. The driver should decide if +it can continue without using these or if it should fail. The pointer +to the EntityInfoRec should be freed if not needed any more. + +Several functions are provided to simplify resource registration: + + Bool xf86IsEntityPrimary(int entityIndex); + +is used to determine if the entity is the display device that is used +during boot-up and text mode. + + Bool xf86IsScreenPrimary(int scrnIndex); + +finds out if the primary entity is registered for the screen with +specified index. + + pciVideoPtr xf86GetPciInfoForEntity(int entityIndex); + +returns a pointer to the pciVideoRec of the specified entity. If the +entity is not a PCI device NULL is returned. + +The primary function for registration of resources is + + resPtr xf86RegisterResources(int entityIndex, resList list, int access); + +it tries to register the resources in 'list'. If list is NULL it tries +to determine the resources automatically. This only works for entities +that provide a generic way to read out the resource ranges they +decode. So far this is only the case for PCI devices. By default the +PCI resources are registered as shared (ResShared) if the driver wants +to set a different access type it can do so by specifying the access +flags in the third argument. A value of 0 means to use the default +settings. If for any reason the resource broker is not able to +register some of the requested resources the function will return a +pointer to a list of the failed ones. In this case the driver may move +the resource to different locations. In case of PCI bus entities this +is done by passing the list of failed resources to + + resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes); + +this function returns a list of reallocated resource. This list needs +to be passed to xf86RegisterResources() again to be registered with +the broker. + +Two functions are provided to obtain a resource range of a given type: + + resRange xf86GetBlock(long type, memType size, + memType window_start, memType window_end, + memType align_mask, resPtr avoid); + resRange xf86GetSparse(long type, unsigned long fixed_bits, + unsigned long decode_mask, unsigned long address_mask, + resPtr avoid); + +The first one tries to find a block range of size 'size' and type +'type' in a window bound by window_start and window_end with the +alignment specified in alignment mask. Optionally a list of resource +ranges which should be avoided inside this window can be passed. On +failure it will return a zero range of type 'ResEnd'. + +The latter function does the same for sparse resources. A spares range +is determined by to parameters: the mask and the base value. An +address satisfying + + mask & address == base + +belongs to the specific spares range. 'mask' and 'base' themselves +have to satisfy: + + mask & base == base. + +Here three values have to be specified: the address mask which marks +all bits of the mask part of the address, the decode_mask which masks +out the bits which are hard coded and are therefore not available for +relocation and the values of the fixed bits. The function tries to +find a base that satisfies the given condition. If the function fails +it will return a zero range of type 'ResEnd'. Optionally it might be +passed a list of resource ranges to avoid. + +Certain PCI devices are broken in the sense that they return invalid +size information for a certain resource. In this case the driver can +supply the correct size and make sure that the resource range +allocated for the card is large enough to hold the address range +decoded by the card. The function: + + Bool xf86FixPciResource(int entityIndex, unsigned int prt, CARD32 alignment, + long type); + +is used for that. The parameter prt contains the number of the PCI +base register that needs to be modified. A value of 6 refers to the +BIOS base register. The size is specified in the alignment +register. Since PCI resources need to span an integral range of the +size 2^n the alignment also specifies the number of addresses that +will be decoded. If the driver specifies a type mask it can override +the default type for PCI resources which is 'ResShared'. The resource +broker needs to know that to find a matching resource range. This +function should be called before calling xf86RegisterResources(). + + Bool xf86CheckPciMemBase(pciVideoPtr pPci, unsigned long base); + +checks that the memory base value specified in base matches one of the +PCI base address register values for the given PCI device. + +The driver may replace the generic access control functions for an +entity by it's own ones. + + void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs, + xf86SetAccessFuncPtr oldFuncs); + + with: + + typedef struct { + xf86AccessPtr mem; + xf86AccessPtr io; + xf86AccessPtr io_mem; + } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr; + +is used for that. The driver can pass three functions: one for I/O +access, one for memory access and one for combined memory and I/O +access. If the memory access and combined access functions are +identical the common level assumes that the memory access cannot be +controlled independently of I/O access, if the I/O access function and +the combined access functions are the same it is assumed that I/O can +not be controlled independently. If memory and I/O have to be +controlled together all three values should be the same. If a non +NULL value is passed as third argument it is interpreted as an address +where to store the old access records. If the third argument is NULL +it will be assumed that the generic access should be enabled before +replacing the access functions. Otherwise it will be disabled. The +driver may enable them itself using the returned values. It should do +this from his replacement access functions as the generic access may +be disabled by the common level on certain occasions. If replacement +functions are specified they must control all resources of the +specific type registered for the entity. + +To find out if specific resource range is conflicting with another +resource + + memType xf86ChkConflict(resRange *rgp, int entityIndex); + +may be called. If a non-zero value is returned a conflict is found. + + resPtr xf86SetOperatingState(resList list, int entityIndex, int mask); + +is used to set the state of a resource during OPERATING state. 'list' +holds a list to which 'mask' is to be applied. The parameter 'mask' +may have the value 'ResUnusedOpr' and 'ResDisableOpr'. The first one +should be used if a resource isn't used during OPERATING state however +decoded by the device while the latter one indicates that the resource +is not decoded during OPERATING state. Note that the resource ranges +have to match those specified during registration. If a range has been +specified starting at A and ending at B and suppose C us a value +satisfying A < C < B one may not specify the resource range (A,B) by +splitting it into two ranges (A,C) and (C,B). + +Two functions are provided for special cases: + + void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex); + +may be used to remove an entity from a screen. This only makes sense +if a screen has more than one entity assigned or the screen is to be +deleted. No test is made if the screen has any entities left. + + void xf86DeallocateResourcesForEntity(int entityIndex, long type); + +deallocates all resources of a given type registered for a certain +entity from the resource broker list. + +IV.3. ScreenInit() phase +------------------------ + +Setting up the rac flags is all that remains to do in ScreenInit() +phase (Note that these flags might also be set up in PreInit() phase). +The ScrnInfoRec has separate flags for memory and PIO access: +racIoFlags and racMemFlags. They specifies which graphics operations +might require the use of resources which might be disabled for some +reason. Note that even exclusive resources might be disabled if they +are disabled along with shared resources. For example if a driver has +registered the VGA PIO resources and lets the common level disable +these by disabling PIO access in PCI config space (the standard way), +exclusive PCI PIO ranges will also be disabled. Therefore the driver +has to flag any operations requiring PCI PIO resources in racIoFlags. +The avaliable flags are defined in rac/xf86RAC.h. Available are: + + RAC_FB for framebuffer operations (including hw acceleration) + RAC_CURSOR for Cursor operations + (??? I'm not sure if we need this for SW cursor it depends + on which level the sw cursor is drawn) + RAC_COLORMAP for colormap operations + RAC_VIEWPORT for the call to RACAdjustFrame() + +The flags are or'ed. + +V. Appendix +=========== + +A. Sample Probe() Function +-------------------------- + +static Bool +XXXProbe(DriverPtr drv, int flags) +{ + Bool foundScreen = FALSE; + int numDevSections, numUsed; + GDevPtr *devSections; + int *usedChips; + int i; + + /* + * Find the config file Device sections that match this + * driver, and return if there are none. + */ + if ((numDevSections = xf86MatchDevice(CHIPS_DRIVER_NAME, + &devSections)) <= 0) { + return FALSE; + } + /* PCI BUS */ + /* test if PCI bus present */ + if (xf86GetPciVideoInfo() ) { + /* match PCI instances with ones supported by the driver */ + numUsed = xf86MatchPciInstances(XXX_NAME, PCI_VENDOR_XXX, + XXXChipsets, XXXPCIchipsets, + devSections,numDevSections, drv, + &usedChips); + if (numUsed > 0) { + for (i = 0; i < numUsed; i++) { + /* Allocate a ScrnInfoRec */ + ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0); + pScrn->driverVersion = VERSION; + pScrn->driverName = XXX_DRIVER_NAME; + pScrn->name = XXX_NAME; + pScrn->Probe = XXXProbe; + pScrn->PreInit = XXXPreInit; + pScrn->ScreenInit = XXXScreenInit; + pScrn->SwitchMode = XXXSwitchMode; + pScrn->AdjustFrame = XXXAdjustFrame; + pScrn->EnterVT = XXXEnterVT; + pScrn->LeaveVT = XXXLeaveVT; + pScrn->FreeScreen = XXXFreeScreen; + pScrn->ValidMode = XXXValidMode; + foundScreen = TRUE; + /* add screen to entity */ + xf86ConfigActivePciEntity(pScrn,usedChips[i],XXXPCIchipsets, + NULL,NULL,NULL,NULL,NULL); + } + } + } + + /* Isa Bus */ + numUsed = xf86MatchIsaInstances(XXX_NAME,XXXChipsets,XXXISAchipsets, + drv,chipsFindIsaDevice,devSections, + numDevSections,&usedChips); + if(numUsed >= 0) + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0); + + pScrn->driverVersion = VERSION; + pScrn->driverName = XXX_DRIVER_NAME; + pScrn->name = XXX_NAME; + pScrn->Probe = XXXProbe; + pScrn->PreInit = XXXPreInit; + pScrn->ScreenInit = XXXScreenInit; + pScrn->SwitchMode = XXXSwitchMode; + pScrn->AdjustFrame = XXXAdjustFrame; + pScrn->EnterVT = XXXEnterVT; + pScrn->LeaveVT = XXXLeaveVT; + pScrn->FreeScreen = XXXFreeScreen; + pScrn->ValidMode = XXXValidMode; + foundScreen = TRUE; + xf86ConfigActiveIsaEntity(pScrn,usedChips[i],XXXISAchipsets, + NULL,NULL,NULL,NULL,NULL); + } + xfree(devSections); + return foundScreen; +} + +B. Porting Issues +----------------- + +Here are some hints on porting code developed for RAC 1 to RAC 2. + +1. a. Initialization of RAC is now entirely done on the common level. + Therefore the call to xf86RACInit() can be removed. + + b. Also there is no need for the racSymbols list. + + c. LoadSubModule(..,rac) should be removed. + + d. racSymbols should be removed from LoaderRequestSymList(racSymbols,..) + +2. a. if the driver uses the predefined resource lists xf86Resources.h + needs to be included. + + b. RES_VGA should be changed to RES_EXCLUSIVE_VGA + +3. The device list now belongs to the EntityInfoRec. + Change pScrn->device to xxx->pEnt->device. + +4. Rewrite the Probe() function. The example given above should work + as a guideline. + +5. Register all necessary resources in PreInit() by calling + xf86RegisterResources(). + +6. If applicable set the operating state of the registered resources + by calling xf86SetOperatingState(). This should be done during + PreInit(). If necessary it might still be done in ScreenInit() + +7. Set up the racIoFlags and racMemFlags. + + + LocalWords: ISA diff --git a/xorg-server/hw/xfree86/doc/devel/README.DRIcomp b/xorg-server/hw/xfree86/doc/devel/README.DRIcomp new file mode 100644 index 000000000..89f40a759 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/README.DRIcomp @@ -0,0 +1,556 @@ + DRI Compilation Guide + + VA Linux Systems, Inc. Professional Services - Graphics. + + 21 April 2001 + +1. Preamble + +1.1 Copyright + +Copyright 2000-2001 by VA Linux Systems, Inc. All Rights Reserved. + +Permission is granted to make and distribute verbatim copies of this document +provided the copyright notice and this permission notice are preserved on all +copies. + +1.2 Trademarks + +OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics, +Inc. Unix is a registered trademark of The Open Group. The `X' device and X +Window System are trademarks of The Open Group. XFree86 is a trademark of +The XFree86 Project. Linux is a registered trademark of Linus Torvalds. +Intel is a registered trademark of Intel Corporation. 3Dlabs, GLINT, and +Oxygen are either registered trademarks or trademarks of 3Dlabs Inc. Ltd. +3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of 3dfx Inter- +active, Incorporated. Matrox is a registered trademark of Matrox Electronic +Systems Ltd. ATI Rage and Radeon is a registered trademark of ATI Technolo- +gies, Inc. All other trademarks mentioned are the property of their respec- +tive owners. + +2. Introduction + +This document describes how to download, compile and install the DRI. The +DRI provides 3D graphics hardware acceleration for the XFree86 project. This +information is intended for experienced Linux developers. Beginners are +probably better off installing precompiled packages. + +Edits, corrections and updates to this document may be mailed to . + +Last updated on 13 February 2002 by Brian Paul. + +3. Prerequisites + +You'll need the following: + + o An installation of XFree86 4.1 or later. The DRI tree has been pruned + down to minimize its size. But in order to build the DRI tree you need + to have recent X header files, etc. already installed. If you don't + have XFree86 4.1 (or later) installed you can probably install it from + RPMs (or another package format). Or, you can download XFree86 as + sources and compile/install it yourself. + + o At least 200MB of free disk space. If you compile for debugging (the -g + option) then you'll need about 600MB. + + o GCC compiler and related tools. + + o ssh (secure shell) if you're a DRI developer and don't want to use + anonymous CVS download. + + o A 2.4.x Linux Kernel. See below for details. + + o FreeBSD support is not currently being maintained and may not work. + +The DRI 3D drivers generally work on systems with Intel or AMD CPUs. How- +ever, limited support for Alpha and PowerPC support is underway. + +For 3dfx Voodoo hardware, you'll also need the Glide3 runtime library +(libglide3-v3.so for Voodoo3 or libglide3-v5.so for Voodoo4/5). These can be +downloaded from the DRI website. You can compile them yourself, but it's +often a painful process. + +For Matrox G200/G400, Intel i810/i830 or ATI Rage128/Radeon hardware, you'll +also need AGP support in your Linux kernel, either built-in or as a loadable +module. + +4. Linux Kernel Preparation + +Only the Linux 2.4.x kernels are currently supported by the DRI hardware +drivers. 2.5.x kernels may work, but aren't tested. + +Most of the DRI drivers require AGP support and using Intel Pentium III SSE +optimizations also requires an up-to-date Linux kernel. Configuring your +kernel correctly is very important, as features such as SSE optimizations +will be disabled if your kernel does not support them. Thus, if you have a +Pentium III processor, you must configure your kernel for the Pentium III +processor family. + +Building a new Linux kernel can be difficult for beginners but there are +resources on the Internet to help. This document assumes experience with +configuring, building and installing Linux kernels. + +Linux kernels can be downloaded from www.kernel.org + +Here are the basic steps for kernel setup. + + o Download the needed kernel and put it in /usr/src. Create a directory + for the source and unpack it. For example: + + cd /usr/src + rm -f linux + mkdir linux-2.4.x + ln -s linux-2.4.x linux + bzcat linux-2.4.x.tar.bz2 | tar xf - + + It is critical that /usr/src/linux point to your new kernel sources, + otherwise the kernel headers will not be used when building the DRI. + This will almost certainly cause compilation problems. + + o Read /usr/src/linux/Documentation/Changes. This file lists the minimum + requirements for all software packages required to build the kernel. + You must upgrade at least gcc, make, binutils and modutils to at least + the versions specified in this file. The other packages may not be + needed. If you are upgrading from Linux 2.2.x you must upgrade your + modutils package for Linux 2.4.x. + + o Configure your kernel. You might, for example, use make menuconfig and + do the following: + + o Go to Code maturity level options + + o Enable Prompt for development and/or incomplete code/drivers + + o hit ESC to return to the top-level menu + + o Go to Processor type and features + + o Select your processor type from Processor Family + + o hit ESC to return to the top-level menu + + o Go to Character devices + + o Disable Direct Rendering Manager (XFree86 DRI support) since we'll + use the DRI code from the XFree86/DRI tree and will compile it + there. + + o Go to /dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW) + + o Hit SPACE twice to build AGP support into the kernel + + o Enable all chipsets' support for AGP + + o It's recommended that you turn on MTRRs under Processor type and + Features, but not required. + + o Configure the rest of the kernel as required for your system (i.e. Eth- + ernet, SCSI, etc) + + o Exit, saving your kernel configuration. + + o Edit your /etc/lilo.conf file. Make sure you have an image entry as + follows (or similar): + + image=/boot/vmlinuz + label=linux.2.4.x + read-only + root=/dev/hda1 + + The important part is that you have /boot/vmlinuz without a trailing + version number. If this is the first entry in your /etc/lilo.conf AND + you haven't set a default, then this will be your default kernel. + + o Compile the new kernel. + + cd /usr/src/linux-2.4.x + make dep + make bzImage + make modules + make modules_install + make install + + Note that last make command will automatically run lilo for you. + + o Now reboot to use the new kernel. + +5. CPU Architectures + +In general, nothing special has to be done to use the DRI on different CPU +architectures. There are, however, a few optimizations that are CPU-depen- +dent. Mesa will determine at runtime which CPU-dependent optimizations +should be used and enable them where appropriate. + +5.1 Intel Pentium III Features + +The Pentium III SSE instructions are used in optimized vertex transformation +functions in the Mesa-based DRI drivers. On Linux, SSE requires a recent +kernel (such as 2.4.0-test11 or later) both at compile time and runtime. + +5.2 AMD 3DNow! Features + +AMD's 3DNow! instructions are used in optimized vertex transformation func- +tions in the Mesa-based DRI drivers. 3DNow! is supported in most versions of +Linux. + +5.3 Alpha Features + +On newer Alpha processors a significant performance increase can be seen with +the addition of the -mcpu= option to GCC. This option is dependent on the +architecture of the processor. For example, -mcpu=ev6 will build specifi- +cally for the EV6 based AXP's, giving both byte and word alignment access to +the DRI/Mesa drivers. + +To enable this optimization edit your xc/config/host.def file and add the +line: + +#define DefaultGcc2AxpOpt -O2 -mcpu=ev6 + +Additional speed improvements to 3D rendering can be achieved by installing +Compaq's Math Libraries (CPML) which can be obtained from http://www.sup- +port.compaq.com/alpha-tools/software/index.html + +Once installed, you can add this line to your host.def to build with the CPML +libraries: + +#define UseCompaqMathLibrary YES + +The host.def file is explained below. + +6. Downloading the XFree86/DRI CVS Sources + +The DRI project is hosted by SourceForge. The DRI source code, which is a +subset of the XFree86 source tree, is kept in a CVS repository there. + +The DRI CVS sources may be accessed either anonymously or as a registered +SourceForge user. It's recommended that you become a registered SourceForge +user so that you may submit non-anonymous bug reports and can participate in +the mailing lists. + +6.1 Anonymous CVS download: + + 1. Create a directory to store the CVS files: + + cd ~ + mkdir DRI-CVS + + You could put your CVS directory in a different place but we'll use + ~/DRI-CVS/ here. + + 2. Check out the CVS sources: + + cd ~/DRI-CVS + cvs -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri login + (hit ENTER when prompted for a password) + cvs -z3 -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri co xc + + The -z3 flag causes compression to be used in order to reduce the down- + load time. + +6.2 Registered CVS download: + + 1. Create a directory to store the CVS files: + + cd ~ + mkdir DRI-CVS + + You could put your CVS directory in a different place but we'll use + ~/DRI-CVS/ here. + + 2. Set the CVS_RSH environment variable: + + setenv CVS_RSH ssh // if using csh or tcsh + export CVS_RSH=ssh // if using sh or bash + + 3. Check out the CVS sources: + + cd ~/DRI-CVS + cvs -z3 -d:ext:YOURID@cvs.dri.sourceforge.net:/cvsroot/dri co xc + + Replace YOURID with your CVS login name. You'll be prompted to enter + your sourceforge password. + + The -z3 flag causes compression to be used in order to reduce the down- + load time. + +6.3 Updating your CVS sources + +In the future you'll want to occasionally update your local copy of the DRI +source code to get the latest changes. This can be done with: + + cd ~/DRI-CVS + cvs -z3 update -dA xc + +The -d flag causes any new subdirectories to be created and -A causes most +recent trunk sources to be fetched, not branch sources. + +7. Mesa + +Most of the DRI 3D drivers are based on Mesa (the free implementation of the +OpenGL API). The relevant files from Mesa are already included in the +XFree86/DRI source tree. There is no need to download or install the Mesa +source files separately. + +Sometimes a newer version of Mesa will be available than the version included +in XFree86/DRI. Upgrading Mesa within XFree86/DRI is not always straightfor- +ward. It can be an error-prone undertaking, especially for beginners, and is +not generally recommended. The DRI developers will upgrade Mesa when appro- +priate. + +8. Compiling the XFree86/DRI tree + +8.1 Make a build tree + +Rather than placing object files and library files right in the source tree, +they're instead put into a parallel build tree. The build tree is made with +the lndir command: + + cd ~/DRI-CVS + ln -s xc XFree40 + mkdir build + cd build + lndir -silent -ignorelinks ../XFree40 + +The build tree will be populated with symbolic links which point back into +the CVS source tree. + +Advanced users may have several build trees for compiling and testing with +different options. + +8.2 Edit the host.def file + +The ~/DRI-CVS/build/xc/config/cf/host.def file is used to configure the +XFree86 build process. You can change it to customize your build options or +make adjustments for your particular system configuration + +The default host.def file will look something like this: + + #define DefaultCCOptions -Wall + (i386) #define DefaultGcc2i386Opt -O2 + (Alpha) #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar) + #define LibraryCDebugFlags -O2 + #define BuildServersOnly YES + #define XF86CardDrivers vga tdfx mga ati i810 + #define LinuxDistribution LinuxRedHat + #define DefaultCCOptions -ansi GccWarningOptions -pipe + #define BuildXF86DRI YES + /* Optionally turn these on for debugging */ + /* #define GlxBuiltInTdfx YES */ + /* #define GlxBuiltInMga YES */ + /* #define GlxBuiltInR128 YES */ + /* #define GlxBuiltInRadeon YES */ + /* #define DoLoadableServer NO */ + #define SharedLibFont NO + +The ProjectRoot variable specifies where the XFree86 files will be installed. +We recommend installing the DRI files over your existing XFree86 installation +- it's generally safe to do and less error-prone. This policy is different +than what we used to recommend. + +If XFree86 4.x is not installed in /usr/X11R6/ you'll have to add the follow- +ing to the host.def file: + + #define ProjectRoot pathToYourXFree86installation + +Note the XF86CardDrivers line to be sure your card's driver is listed. + +If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you +should add the following: + + #define MesaUse3DNow YES + +You don't have to be using an AMD processor in order to enable this option. +The DRI will look for 3DNow! support and runtime and only enable it if appli- +cable. + +If you want to enable SSE optimizations in Mesa and the DRI drivers, you must +upgrade to a Linux 2.4.x kernel. Mesa will verify that SSE is supported by +both your processor and your operating system, but to build Mesa inside the +DRI you need to have the Linux 2.4.x kernel headers in /usr/src/linux. If +you enable SSE optimizations with an earlier version of the Linux kernel in +/usr/src/linux, Mesa will not compile. You have been warned. If you do have +a 2.4.x kernel, you should add the following: + + #define MesaUseSSE YES + +If you want to build the DRM kernel modules as part of the full build pro- +cess, add the following: + + #define BuildXF86DRM YES + +Otherwise, you'll need to build them separately as described below. + +8.3 Compilation + +To compile the complete DRI tree: + + cd ~/DRI-CVS/build/xc/ + make World >& world.log + +Or if you want to watch the compilation progress: + + cd ~/DRI-CVS/build/xc/ + make World >& world.log & + tail -f world.log + +With the default compilation flags it's normal to get a lot of warnings dur- +ing compilation. + +Building will take some time so you may want to go check your email or visit +slashdot. + +WARNING: do not use the -j option with make. It's reported that it does not +work with XFree86/DRI. + +8.4 Check for compilation errors + +Using your text editor, examine world.log for errors by searching for the +pattern ***. + +After fixing the errors, run make World again. Later, you might just compile +parts of the source tree but it's important that the whole tree will build +first. + +If you edited your host.def file to enable automatic building of the DRI ker- +nel module(s), verify that they were built: + + cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel + ls + +Otherwise, build them now by running + + cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel + make -f Makefile.linux + +For the 3dfx Voodoo, you should see tdfx.o. For the Matrox G200/G400, you +should see mga.o. For the ATI Rage 128, you should see r128.o. For the ATI +Radeon, you should see radeon.o. For the Intel i810, you should see i810.o. + +If the DRI kernel module(s) failed to build you should verify that you're +using the right version of the Linux kernel. The most recent kernels are not +always supported. + +If your build machine is running a different version of the kernel than your +target machine (i.e. 2.2.x vs. 2.4.x), make will select the wrong kernel +source tree. This can be fixed by explicitly setting the value of LINUXDIR. +If the path to your kernel source is /usr/src/linux-2.4.x, + + cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel + make -f Makefile.linux LINUXDIR=/usr/src/linux-2.4.x + +or alternatively, edit Makefile.linux to set LINUXDIR before the ifndef LIN- +UXDIR line. + +8.5 DRI kernel module installation + +The DRI kernel modules will be in ~/DRI-CVS/build/xc/pro- +grams/Xserver/hw/xfree86/os-support/linux/drm/kernel/. + +To load the appropriate DRM module in your running kernel you can either use +ismod and restart your X server or copy the kernel module to /lib/mod- +ules/2.4.x/kernel/drivers/char/drm/ then run depmod and restart your X +server. + +Make sure you first unload any older DRI kernel modules that might be already +loaded. + +Note that some DRM modules require that the agpgart module be loaded first. + +9. Normal Installation and Configuration + +Most users will want to install the new X server and use it in place of their +old X server. This section explains how to do that. + +Developers, on the other hand, may just want to test the X server without +actually installing it as their default server. If you want to do that, skip +to the next section. + +9.1 Installation + +Here are the installation commands: + + su + cd ~/DRI-CVS/build/xc + make install + +9.2 Update the XF86Config File + +You may need to edit your XF86Config file to enable the DRI. The config file +is usually installed as /etc/X11/XF86Config-4. See the DRI User Guide for +details, but basically, you need to load the "glx" and "dri" modules and add +a "DRI" section. + +On the DRI web site, in the resources section, you'll find example XF86Config +files for a number of graphics cards. These configuration files also setup +DRI options so it's highly recommended that you look at these examples. + +The XFree86 4.x server can generate a basic configuration file itself. Sim- +ply do this: + + cd /usr/X11R6/bin + ./XFree86 -configure + +A file named /root/XF86Config.new will be created. It should allow you to +try your X server but you'll almost certainly have to edit it. For example, +you should add HorizSync and VertRefresh options to the Monitor section and +Modes options to the Screen section. Also, the ModulePath option in the +Files section should be set to /usr/X11R6/lib/modules. + +9.3 Start the New X Server + +The new X server should be ready to use now. Start your X server in your +usual manner. Often times the startx command is used: + + startx + +10. Testing the Server Without Installing It + +As mentioned at the start of section 9, developers may want to simply run the +X server without installing it. This can save some time and allow you to +keep a number of X servers available for testing. + +10.1 Configuration + +As described in the preceding section, you'll need to create a configuration +file for the new server. Put the XF86Config file in your ~/DRI- +CVS/build/xc/programs/Xserver directory. + +Be sure the ModulePath option in your XF86Config file is set correctly. + +10.2 A Startup Script + +A simple shell script can be used to start the X server. Here's an example. + + #!/bin/sh + export DISPLAY=:0 + ./XFree86 -xf86config XF86Config & \ + sleep 2 + fvwm2 & + xset b off + xmodmap -e "clear mod4" + xsetroot -solid "#00306f" + xterm -geometry 80x40+0+0 + +You might name this script start-dri. Put it in your ~/DRI-CVS/build/xc/pro- +grams/Xserver directory. + +To test the server run the script: + + cd ~/DRI-CVS/build/xc/programs/Xserver + ./start-dri + +For debugging, you may also want to capture the log messages printed by the +server in a file. If you're using the C-shell: + + ./start-dri >& log + +11. Where To Go From Here + +At this point your X server should be up and running with hardware-acceler- +ated direct rendering. Please read the DRI User Guide for information about +trouble shooting and how to use the DRI-enabled X server for 3D applications. + + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.19 dawes Exp $ + + diff --git a/xorg-server/hw/xfree86/doc/devel/Registry b/xorg-server/hw/xfree86/doc/devel/Registry new file mode 100644 index 000000000..1fec230e8 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/Registry @@ -0,0 +1,409 @@ +This is the XFree86 driver/module registry. To avoid name space clashes and +to maintain some consistency between drivers the important name spaces are +maintained here. + +1. Module Names. + +Each module is required to have a unique name. Registered names are: + +GLcore +acecad +afb +apm +ark +ati +atimisc +bitmap +bt8xx +calcomp +cfb +cfb16 +cfb24 +cfb32 +chips +cirrus +citron +cyrix +dbe +ddc +digitaledge +dmc +dri +drm +dynapro +elo2300 +elographics +extmod +fb +fbdev +fbdevhw +fi12x6 +freetype +glide +glint +glx +hyperpen +i128 +i2c +i740 +i810 +imstt +int10 +joystick +keyboard +layer +magellan +magictouch +mfb +mga +microtouch +mouse +msp34xx +mutouch +neomagic +newport +nv +pcidata +penmount +pex5 +r128 +radeon +rac +ramdac +record +rendition +s3 +s3virge +savage +shadow +shadowfb +siliconmotion +sis +spaceorb +speedo +summa +sunbw2 +suncg14 +suncg3 +suncg6 +sunffb +sunleo +suntcx +tdfx +tga +trident +tseng +type1 +v4l +vbe +vesa +vga +vgahw +vmware +void +wacom +xaa +xf1bpp +xf24_32bpp +xf4bpp +xf8_16bpp +xf8_32bpp +xf8_32wid +xie +xtrap +xtt + +2. External Module Object Symbols. + +Each module is required to use a unique prefix or prefixes for all of +its externally visible symbols. They should be unique without regard to +case. Registered prefixes are: + +ati +bt8xx +cfb +chips +fi12x6 +glide +glint +mfb +mga +msp34xx +neo +permedia +tseng +vga +vgahw +vmware +xaa +xf1bpp +xf4bpp + +3. Chipset Names. + +Each video driver is required to use a unique set of chipset names. Case, +white space and underscore characters are ignored when comparing chipset +names. All names listed here are in lower case with all white space and +underscores removed. Registered chipset names are: + +ati +ativga +ct64200 +ct64300 +ct65520 +ct65525 +ct65530 +ct65535 +ct65540 +ct65545 +ct65546 +ct65548 +ct65550 +ct65554 +ct65555 +ct68554 +ct69000 +et4000 +et4000w32 +et4000w32i +et4000w32p +et6000 +et6100 +generic +ibmvga +ibm8514 +mach32 +mach64 +mach8 +mga2064w +mga1064sg +mga2164w +mga2164wagp +neo2070 +neo2090 +neo2093 +neo2097 +neo2160 +neo2200 +tipm2 +vgawonder +voodoo + +4. Option Names. + +Option names and their usage should be consistent between drivers. +Case, white space and underscore characters are ignored when comparing +option names. The prefix "no" may be added or removed from boolean +option names. All names listed here are in their preferred user-visible +form. Some registered option names are: + +Types are: B = boolean, O = set/unset (no value), I = integer, S = string, + A = optional string, F = floating point number Q = frequency + +Scopes are: F = global flags, V = video driver, C = common (per screen), + I = input drivers, X = XAA, Xv = Xv extension, M = misc. + +Names currently in use: + +Name Type Scope Description +---------------------------------------------------------------------------- +AllowMouseOpenFail B F ignore mouse dev open failure +AllowNonLocalModInDev B F allow non-local mod of input devs +AllowNonLocalXvidtune B F allow non-local VidMode connections +BlankTime I F Screen saver timeout (min) +DisableModInDev B F disallow changing input devs +DisableVidModeExtension B F disable VidMode extension +DontVTSwitch B F disable Ctrl-Alt-Fn +DontZap B F disable Ctrl-Alt-BS sequence +DontZoom B F disable Ctrl-Alt-+/- +NoTrapSignals B F don't trap signals +OffTime I F Time before DPMS off mode active (min) +PciProbe1 O F use PCI probe algorithm 1 +PciProbe2 O F use PCI probe algorithm 2 +PciForceConfig1 O F force PCI config type 1 +PciForceConfig2 O F force PCI config type 2 +Pixmap I F depth 24 pixmap size (24 or 32) +StandbyTime I F Time before DPMS standby active (min) +SuspendTime I F Time before DPMS suspend mode active (min) + +BackingStore B C Enable backing store +DDC B C Enable/disable DDC +DDC1 B C Enable/disable DDC1 +DDC2 B C Enable/disable DDC2 +DPMS O C Enable DPMS +MTRR B C Enable/disable setting MTRRs + +BaudRate I I Serial port baud rate +ButtonNumber I I Button number (for touch screen?) +ButtonThreshold I I ?? +ClearDTR O I Clear serial port DTR +ClearRTS O I Clear serial port RTS +DataBits I I Serial port data bits +DemandLoad O I ?? +Device S I Device file name +DeviceName S I Input device name +FlowControl S I Serial flow control ("xon", "none") +HistorySize I I ?? +MaxX I I Maximum X coordinate +MaxY I I Maximum Y coordinate +MinX I I Minimum X coordinate +MinY I I Minimum Y coordinate +Parity S I Serial port parity ("odd", "even", "none") +ReportDelay I I ?? +ReportingMode S I may be "raw" or "scaled" +ScreenNumber I I Screen number (for touch screen) +SendCoreEvents B I Send core events +SendDragEvents B I Send drag events +StopBits I I Serial port stop bits +SwapXY B I Swap the X and Y axes +UntouchDelay I I ?? +Vmin I I Tty VMIN +Vtime I I Tty VTIME + + +18BitBus B V ?? +8Plus16 B V Enable depth 8 + depth 16 with overlay +8Plus24 B V Enable depth 8 + depth 24 with overlay +BlockWrite B V Enable/disable block write +ColorKey I V Set the color key for overlay modes +CompositeSync B V Composite sync +CRTDisplay B V Force display on CRT, not LCD +CRTScreen B V Display on CRT, not LCD (Obsolete) +EarlyRasPrecharge O V Early RAS pre-charge +FastDRAM O V Fast DRAM +FifoAggressive O V Aggressive FIFO setting +FifoConservative O V Conservative FIFO setting +FifoModerate O V Moderate FIFO setting +FireGL3000 B V Card is Diamond FireGL3000 +FixPanelSize B V ?? +FPClock8 Q V Flat panel clock for 8bpp fb (MHz) +FPClock16 Q V Flat panel clock for 16bpp fb (MHz) +FPClock24 Q V Flat panel clock for 24bpp fb (MHz) +FPClock32 Q V Flat panel clock for 32bpp fb (MHz) +FPMVRAM O V Fast page mode VRAM +FramebufferWC B V Enable/disable WC for the framebuffer +GlideDevice I V Selects which Voodoo board to use +HiBitHigh O V High clock bit default to set +HiBitLow O V High clock bit default to cleared +HWClocks B V Enable/disable HW clocks +HWCursor B V Enable/disable HW cursor +LateRasPrecharge O V Late RAS pre-charge +Legend O V Card is Legend ET4000 +LCDCenter B V Enable/disable centering for LCD displays +Linear B V Enable/disable linear framebuffer +MCLK Q V Specify the current MCLK value (MHz) +MedDRAM B V Medium speed DRAM +MemCfg1 I V ?? +MemCfg2 I V ?? +MGASDRAM B V Mga card has SDRAM +MMIO B V Enable/disable memory mapped I/O +MMIOCache B V Enable/Disable MMIO cache +MuxThreshold I V Multiplexing threshold (kHz) +NoAccel B V Disable/enable acceleration +NoClockChip B V ?? +NoStretch B V Disable/enable stretching for LCD displays +OnAtExit B V Leave video signal on when exiting server +OverclockMem B V Enable memory overclocking +Overlay A V Enable multi-depth/overlay. An optional + string "M,N" may be specified, where + M, N are the depths. +PanelDisplay B V Force display on LCD +PciBurst B V Enable/disable PCI burst mode +PciRetry B V Enable/disable PCI retries +ProbeClocks B V Force probe for non-programmable clocks +ReferenceClock Q V Clock generator reference frequency +RGBbits I V Number of significant bits per rgb +Rotate S V Rotate the virtual display (CW or CCW) +SetLCDClk Q V Set LCD clock (MHz) +SetMclk Q V Set Memory Clock (MHz) +ShadowFB B V Enable shadow framebuffer layer +ShowCache B V Enable viewing of offscreen memory +ShowOverscan O V Set the overscan area to a visible colour +SlowDRAM O V Slow DRAM +SlowEDODRAM O V Slow EDO DRAM +STN B V STN screen type (??) +SWCursor B V Enable/disable SW cursor +SuspendHack B V ?? +SyncOnGreen B V Enable/disable sync on green +TurboQueue B V Enable/disable turbo queue +UseFBDev B V Use the fbdev driver interface +UseModeLine B V Use Modeline (??) +W32Interleave B V ?? + +Buffers I Xv Number of buffers +Device S Xv Device file name +Expose B Xv Disable occlusion clipping (see DESIGN) +FramesPerSec I Xv Max. refresh frequency + +XAA options. All are of type "O" and scope "X", and are self-explanatory + +XaaNoColor8x8PatternFillRect +XaaNoColor8x8PatternFillTrap +XaaNoCPUToScreenColorExpandFill +XaaNoDashedBresenhamLine +XaaNoDashedTwoPointLine +XaaNoScreenToScreenCopy +XaaNoImageReadRect +XaaNoImageWriteRect +XaaNoMono8x8PatternFillRect +XaaNoMono8x8PatternFillTrap +XaaNoOffscreenPixmaps +XaaNoPixmapCache +XaaNoScanlineCPUToScreenColorExpandFill +XaaNoScanlineImageWriteRect +XaaNoScreenToScreenColorExpandFill +XaaNoSolidBresenhamLine +XaaNoSolidFillRect +XaaNoSolidFillTrap +XaaNoSolidHorVertLine +XaaNoSolidTwoPointLine + + +Names used in previous versions: + +16Clocks +8Clocks +ClkDiv2 +EDO VRAM +ExternDisp +ExtFramBuf +FastVRAM +FavorBitBlt +InternDisp +NoBitBlt +NoFontCache +NoImageBlt +NoMemAccess +NoPciDisconnect +NoPixmapCache +NoProgramClocks +NoSplitXfer +OverrideBIOS +OverrideValidateMode +ProgLcdModeRegs +ProgLcdModeStretch +SlowDRAMrefresh +SlowVRAM +SwapHiBit + + +5. Ramdac Names. + +Ramdac names should be consistent between drivers. Case, white space +and underscore characters are ignored when comparing ramdac names. All +names listed here are in lower case with all white space and underscores +removed. + + +6. Clock Chip Names. + +Clock chip names should be consistent between drivers. Case, white +space and underscore characters are ignored when comparing clock chip +names. All names listed here are in lower case with all white space +and underscores removed. + + + + + +$XFree86: xc/programs/Xserver/hw/xfree86/Registry,v 1.18 2002/04/06 18:31:09 tsi Exp $ diff --git a/xorg-server/hw/xfree86/doc/devel/exa-driver.txt b/xorg-server/hw/xfree86/doc/devel/exa-driver.txt new file mode 100644 index 000000000..048307ee7 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/devel/exa-driver.txt @@ -0,0 +1,94 @@ +Adding EXA support to your X.Org video driver +--------------------------------------------- +EXA (for EXcellent Architecture or Ex-kaa aXeleration Architecture or +whatever) aims to extend the life of the venerable XFree86 video drivers by +introducing a new set of acceleration hooks that efficiently accelerate the X +Render extension, including solid fills, blits within screen memory and to and +from system memory, and Porter-Duff compositing and transform operations. + +Configuration +------------- +A new config file option, AccelMethod, should be added to your driver, to allow +the user to select between the EXA and XAA acceleration APIs. + +Some drivers implement a per-instance useEXA flag to track whether EXA is +active or not. It can be helpful to also conditionalize XAA support with an +ifdef so that it can easily be turned off/removed in the future. + +Setting the flag and checking for AccelMethod can be done in the driver's +Options parsing routine. + +Loading EXA +------------ +EXA drivers in the XFree86 DDX should use the loadable module loader to load +the EXA core. Careful versioning allows the EXA API to be extended without +breaking the ABI for older versions of drivers. Example code for loading EXA: + +static const char *exaSymbols[] = { + "exaDriverAlloc", + "exaDriverInit", + "exaDriverFini", + "exaOffscreenAlloc", + "exaOffscreenFree", + "exaGetPixmapOffset", + "exaGetPixmapPitch", + "exaGetPixmapSize", + "exaMarkSync", + "exaWaitSync", + NULL +}; + + if (info->useEXA) { + info->exaReq.majorversion = 2; + info->exaReq.minorversion = 0; + + if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL, + &info->exaReq, &errmaj, &errmin)) { + LoaderErrorMsg(NULL, "exa", errmaj, errmin); + return FALSE; + } + xf86LoaderReqSymLists(exaSymbols, NULL); + } + +EXA is then initialized using exaDriverAlloc and exaDriverInit. See doxygen +documentation for getting started there. + +Further documentation +------------ +The EXA driver interface and public API is documented using doxygen in +xserver/xorg/exa/. To build the documentation, run: + doxygen -g + doxygen Doxyfile +The resulting documentation will appear an html/index.html under the current +directory. + +EXA initialization +------------------ +Your driver's AccelInit routine must initialize an ExaDriverRec structure if +EXA support is enabled, with appropriate error handling (i.e. NoAccel and +NoXvideo should be set to true if EXA fails to initialize for whatever +reason). + +The AccelInit routine also needs to make sure that there's enough offscreen +memory for certain operations to function, like Xvideo, which should advertise +a maximum size no larger than can be dealt with given the amount of offscreen +memory available. + +EXA and Xv +---------- +Video support becomes easier with EXA since AllocateFBMemory can use +exaOffscreenAlloc directly, freeing a previous area if necessary and +allocating a new one. Likewise, FreeFBMemory can call exaOffscreenFree. + +EXA teardown +------------ +At screen close time, EXA drivers should call exaDriverFini with their screen +pointer, free their EXADriver structure, and do any other necessary teardown. + +EXA misc. +--------- +In many drivers, DGA support will need to be changed to be aware of the new +EXA support. + +Send updates and corrections to Jesse Barnes or +just check them in if you have permission. diff --git a/xorg-server/hw/xfree86/doc/man/Makefile.am b/xorg-server/hw/xfree86/doc/man/Makefile.am new file mode 100644 index 000000000..d8b2aa73d --- /dev/null +++ b/xorg-server/hw/xfree86/doc/man/Makefile.am @@ -0,0 +1,24 @@ +# Xserver.man covers options generic to all X servers built in this tree +MAN_SRCS = Xorg.man.pre xorg.conf.man.pre + +appmandir = $(APP_MAN_DIR) +appman_DATA = Xorg.$(APP_MAN_SUFFIX) + +filemandir = $(FILE_MAN_DIR) +fileman_DATA = xorg.conf.$(FILE_MAN_SUFFIX) + +Xorg.$(APP_MAN_SUFFIX): Xorg.man + -rm -f Xorg.$(APP_MAN_SUFFIX) + $(LN_S) Xorg.man Xorg.$(APP_MAN_SUFFIX) + +xorg.conf.$(FILE_MAN_SUFFIX): xorg.conf.man + -rm -f xorg.conf.$(FILE_MAN_SUFFIX) + $(LN_S) xorg.conf.man xorg.conf.$(FILE_MAN_SUFFIX) + +include $(top_srcdir)/cpprules.in + +EXTRAMANDEFS = -D__logdir__=$(logdir) + +CLEANFILES = $(appman_DATA) $(fileman_DATA) xorg.conf.man Xorg.man + +EXTRA_DIST = $(MAN_SRCS) diff --git a/xorg-server/hw/xfree86/doc/man/Makefile.in b/xorg-server/hw/xfree86/doc/man/Makefile.in new file mode 100644 index 000000000..09fbe07f1 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/man/Makefile.in @@ -0,0 +1,646 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/cpprules.in +subdir = hw/xfree86/doc/man +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(appmandir)" "$(DESTDIR)$(filemandir)" +appmanDATA_INSTALL = $(INSTALL_DATA) +filemanDATA_INSTALL = $(INSTALL_DATA) +DATA = $(appman_DATA) $(fileman_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ + +# Xserver.man covers options generic to all X servers built in this tree +MAN_SRCS = Xorg.man.pre xorg.conf.man.pre +appmandir = $(APP_MAN_DIR) +appman_DATA = Xorg.$(APP_MAN_SUFFIX) +filemandir = $(FILE_MAN_DIR) +fileman_DATA = xorg.conf.$(FILE_MAN_SUFFIX) +SUFFIXES = .pre .man .man.pre + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + +EXTRAMANDEFS = -D__logdir__=$(logdir) +CLEANFILES = $(appman_DATA) $(fileman_DATA) xorg.conf.man Xorg.man +EXTRA_DIST = $(MAN_SRCS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/doc/man/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/doc/man/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-appmanDATA: $(appman_DATA) + @$(NORMAL_INSTALL) + test -z "$(appmandir)" || $(MKDIR_P) "$(DESTDIR)$(appmandir)" + @list='$(appman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(appmanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appmandir)/$$f'"; \ + $(appmanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appmandir)/$$f"; \ + done + +uninstall-appmanDATA: + @$(NORMAL_UNINSTALL) + @list='$(appman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(appmandir)/$$f'"; \ + rm -f "$(DESTDIR)$(appmandir)/$$f"; \ + done +install-filemanDATA: $(fileman_DATA) + @$(NORMAL_INSTALL) + test -z "$(filemandir)" || $(MKDIR_P) "$(DESTDIR)$(filemandir)" + @list='$(fileman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(filemanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(filemandir)/$$f'"; \ + $(filemanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(filemandir)/$$f"; \ + done + +uninstall-filemanDATA: + @$(NORMAL_UNINSTALL) + @list='$(fileman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(filemandir)/$$f'"; \ + rm -f "$(DESTDIR)$(filemandir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(appmandir)" "$(DESTDIR)$(filemandir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-appmanDATA install-filemanDATA + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-appmanDATA uninstall-filemanDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-appmanDATA install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am \ + install-filemanDATA install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-appmanDATA uninstall-filemanDATA + + +Xorg.$(APP_MAN_SUFFIX): Xorg.man + -rm -f Xorg.$(APP_MAN_SUFFIX) + $(LN_S) Xorg.man Xorg.$(APP_MAN_SUFFIX) + +xorg.conf.$(FILE_MAN_SUFFIX): xorg.conf.man + -rm -f xorg.conf.$(FILE_MAN_SUFFIX) + $(LN_S) xorg.conf.man xorg.conf.$(FILE_MAN_SUFFIX) + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/doc/man/Xorg.man.pre b/xorg-server/hw/xfree86/doc/man/Xorg.man.pre new file mode 100644 index 000000000..8b48951e7 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/man/Xorg.man.pre @@ -0,0 +1,693 @@ +.\" $XdotOrg: xserver/xorg/hw/xfree86/doc/man/Xorg.man.pre,v 1.3 2005/07/04 18:41:01 ajax Exp $ +.TH __xservername__ __appmansuffix__ __vendorversion__ +.SH NAME +__xservername__ - X11R7 X server +.SH SYNOPSIS +.B __xservername__ +.RI [\fB:\fP display ] +.RI [ option +.IR ... ] +.SH DESCRIPTION +.B __xservername__ +is a full featured X server that was originally designed for UNIX and +UNIX-like operating systems running on Intel x86 hardware. It now runs +on a wider range of hardware and OS platforms. +.PP +This work was derived by the X.Org Foundation from the XFree86 Project's +.I "XFree86\ 4.4rc2" +release. +The XFree86 release was originally derived from +.I "X386\ 1.2" +by Thomas Roell which was contributed to X11R5 by Snitily Graphics +Consulting Service. +.SH PLATFORMS +.PP +.B __xservername__ +operates under a wide range of operating systems and hardware platforms. +The Intel x86 (IA32) architecture is the most widely supported hardware +platform. Other hardware platforms include Compaq Alpha, Intel IA64, AMD64, +SPARC and PowerPC. The most widely supported operating systems are the +free/OpenSource UNIX-like systems such as Linux, FreeBSD, NetBSD, +OpenBSD, and Solaris. Commercial UNIX operating systems such as +UnixWare are also supported. Other supported operating systems include +LynxOS, and GNU Hurd. Darwin and Mac OS X are supported with the +XDarwin(__appmansuffix__) X server. Win32/Cygwin is supported with the +XWin(__appmansuffix__) X server. +.PP +.SH "NETWORK CONNECTIONS" +.B __xservername__ +supports connections made using the following reliable +byte-streams: +.TP 4 +.I "Local" +On most platforms, the "Local" connection type is a UNIX-domain socket. +On some System V platforms, the "local" connection types also include +STREAMS pipes, named pipes, and some other mechanisms. +.TP 4 +.I TCP\/IP +.B __xservername__ +listens on port +.RI 6000+ n , +where +.I n +is the display number. This connection type can be disabled with the +.B \-nolisten +option (see the Xserver(1) man page for details). +.SH "ENVIRONMENT VARIABLES" +For operating systems that support local connections other than Unix +Domain sockets (SVR3 and SVR4), there is a compiled-in list specifying +the order in which local connections should be attempted. This list +can be overridden by the +.I XLOCAL +environment variable described below. If the display name indicates a +best-choice connection should be made (e.g. +.BR :0.0 ), +each connection mechanism is tried until a connection succeeds or no +more mechanisms are available. Note: for these OSs, the Unix Domain +socket connection is treated differently from the other local connection +types. To use it the connection must be made to +.BR unix:0.0 . +.PP +The +.I XLOCAL +environment variable should contain a list of one more +more of the following: +.PP +.RS 8 +.nf +NAMED +PTS +SCO +ISC +.fi +.RE +.PP +which represent SVR4 Named Streams pipe, Old-style USL Streams pipe, +SCO XSight Streams pipe, and ISC Streams pipe, respectively. You can +select a single mechanism (e.g. +.IR XLOCAL=NAMED ), +or an ordered list (e.g. \fIXLOCAL="NAMED:PTS:SCO"\fP). +his variable overrides the compiled-in defaults. For SVR4 it is +recommended that +.I NAMED +be the first preference connection. The default setting is +.IR PTS:NAMED:ISC:SCO . +.PP +To globally override the compiled-in defaults, you should define (and +export if using +.B sh +or +.BR ksh ) +.I XLOCAL +globally. If you use startx(1) or xinit(1), the definition should be +at the top of your +.I .xinitrc +file. If you use xdm(1), the definitions should be early on in the +.I __projectroot__/lib/X11/xdm/Xsession +script. +.SH OPTIONS +.B __xservername__ +supports several mechanisms for supplying/obtaining configuration and +run-time parameters: command line options, environment variables, the +__xconfigfile__(__filemansuffix__) configuration file, auto-detection, and +fallback defaults. When the same information is supplied in more than +one way, the highest precedence mechanism is used. The list of mechanisms +is ordered from highest precedence to lowest. Note that not all parameters +can be supplied via all methods. The available command line options +and environment variables (and some defaults) are described here and in +the Xserver(__appmansuffix__) manual page. Most configuration file +parameters, with their defaults, are described in the +__xconfigfile__(__filemansuffix__) manual page. Driver and module specific +configuration parameters are described in the relevant driver or module +manual page. +.PP +In addition to the normal server options described in the +Xserver(__appmansuffix__) manual page, +.B __xservername__ +accepts the following command line switches: +.TP 8 +.BI vt XX +.I XX +specifies the Virtual Terminal device number which +.B __xservername__ +will use. Without this option, +.B __xservername__ +will pick the first available Virtual Terminal that it can locate. This +option applies only to platforms such as Linux, BSD, SVR3 and SVR4, that +have virtual terminal support. +.TP +.B \-allowMouseOpenFail +Allow the server to start up even if the mouse device can't be opened +or initialised. This is equivalent to the +.B AllowMouseOpenFail +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B \-allowNonLocalModInDev +Allow changes to keyboard and mouse settings from non-local clients. +By default, connections from non-local clients are not allowed to do +this. This is equivalent to the +.B AllowNonLocalModInDev +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B \-allowNonLocalXvidtune +Make the VidMode extension available to remote clients. This allows +the xvidtune client to connect from another host. This is equivalent +to the +.B AllowNonLocalXvidtune +__xconfigfile__(__filemansuffix__) file option. By default non-local +connections are not allowed. +.TP 8 +.BI \-bgamma " value" +Set the blue gamma correction. +.I value +must be between 0.1 and 10. +The default is 1.0. Not all drivers support this. See also the +.BR \-gamma , +.BR \-rgamma , +and +.B \-ggamma +options. +.TP 8 +.BI \-bpp " n" +No longer supported. Use +.B \-depth +to set the color depth, and use +.B \-fbbpp +if you really need to force a non-default framebuffer (hardware) pixel +format. +.TP +.B \-configure +When this option is specified, the +.B __xservername__ +server loads all video driver modules, probes for available hardware, +and writes out an initial __xconfigfile__(__filemansuffix__) file based on +what was detected. This option currently has some problems on some +platforms, but in most cases it is a good way to bootstrap the +configuration process. This option is only available when the server +is run as root (i.e, with real-uid 0). +.TP 8 +.BI "\-crt /dev/tty" XX +SCO only. This is the same as the +.B vt +option, and is provided for compatibility with the native SCO X server. +.TP 8 +.BI \-depth " n" +Sets the default color depth. Legal values are 1, 4, 8, 15, 16, and +24. Not all drivers support all values. +.TP 8 +.B \-disableModInDev +Disable dynamic modification of input device settings. This is equivalent +to the +.B DisableModInDev +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B \-disableVidMode +Disable the parts of the VidMode extension (used by the xvidtune +client) that can be used to change the video modes. This is equivalent +to the +.B DisableVidModeExtension +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B \-fbbpp \fIn\fP +Sets the number of framebuffer bits per pixel. You should only set this +if you're sure it's necessary; normally the server can deduce the correct +value from +.B \-depth +above. Useful if you want to run a depth 24 configuration with a 24 +bpp framebuffer rather than the (possibly default) 32 bpp framebuffer +(or vice versa). Legal values are 1, 8, 16, 24, 32. Not all drivers +support all values. +.TP 8 +.B \-flipPixels +Swap the default values for the black and white pixels. +.TP 8 +.BI \-gamma " value" +Set the gamma correction. +.I value +must be between 0.1 and 10. The default is 1.0. This value is applied +equally to the R, G and B values. Those values can be set independently +with the +.BR \-rgamma , +.BR \-bgamma , +and +.B \-ggamma +options. Not all drivers support this. +.TP 8 +.BI \-ggamma " value" +Set the green gamma correction. +.I value +must be between 0.1 and 10. The default is 1.0. Not all drivers support +this. See also the +.BR \-gamma , +.BR \-rgamma , +and +.B \-bgamma +options. +.TP 8 +.B \-ignoreABI +The +.B __xservername__ +server checks the ABI revision levels of each module that it loads. It +will normally refuse to load modules with ABI revisions that are newer +than the server's. This is because such modules might use interfaces +that the server does not have. When this option is specified, mismatches +like this are downgraded from fatal errors to warnings. This option +should be used with care. +.TP 8 +.B \-isolateDevice \fIbus\-id\fP +Restrict device resets to the device at +.IR bus\-id . +The +.I bus\-id +string has the form +.IB bustype : bus : device : function +(e.g., \(oqPCI:1:0:0\(cq). +At present, only isolation of PCI devices is supported; i.e., this option +is ignored if +.I bustype +is anything other than \(oqPCI\(cq. +.TP 8 +.B \-keeptty +Prevent the server from detaching its initial controlling terminal. +This option is only useful when debugging the server. Not all platforms +support (or can use) this option. +.TP 8 +.BI \-keyboard " keyboard-name" +Use the __xconfigfile__(__filemansuffix__) file +.B InputDevice +section called +.I keyboard-name +as the core keyboard. This option is ignored when the +.B Layout +section specifies a core keyboard. In the absence of both a Layout +section and this option, the first relevant +.B InputDevice +section is used for the core keyboard. +.TP 8 +.BI \-layout " layout-name" +Use the __xconfigfile__(__filemansuffix__) file +.B Layout +section called +.IR layout-name . +By default the first +.B Layout +section is used. +.TP 8 +.BI \-logfile " filename" +Use the file called +.I filename +as the +.B __xservername__ +server log file. The default log file is +.BI __logdir__/__xservername__. n .log +on most platforms, where +.I n +is the display number of the +.B __xservername__ +server. The default may be in a different directory on some platforms. +This option is only available when the server is run as root (i.e, with +real-uid 0). +.TP 8 +.BR \-logverbose " [\fIn\fP]" +Sets the verbosity level for information printed to the +.B __xservername__ +server log file. If the +.I n +value isn't supplied, each occurrence of this option increments the log +file verbosity level. When the +.I n +value is supplied, the log file verbosity level is set to that value. +The default log file verbosity level is 3. +.TP 8 +.BI \-modulepath " searchpath" +Set the module search path to +.IR searchpath . +.I searchpath +is a comma separated list of directories to search for +.B __xservername__ +server modules. This option is only available when the server is run +as root (i.e, with real-uid 0). +.TP 8 +.B \-nosilk +Disable Silken Mouse support. +.TP 8 +.B \-pixmap24 +Set the internal pixmap format for depth 24 pixmaps to 24 bits per pixel. +The default is usually 32 bits per pixel. There is normally little +reason to use this option. Some client applications don't like this +pixmap format, even though it is a perfectly legal format. This is +equivalent to the +.B Pixmap +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B \-pixmap32 +Set the internal pixmap format for depth 24 pixmaps to 32 bits per pixel. +This is usually the default. This is equivalent to the +.B Pixmap +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.BI \-pointer " pointer-name" +Use the __xconfigfile__(__filemansuffix__) file +.B InputDevice +section called +.I pointer-name +as the core pointer. This option is ignored when the +.B Layout +section specifies a core pointer. In the absence of both a Layout +section and this option, the first relevant +.B InputDevice +section is used for the core pointer. +.TP 8 +.B \-probeonly +Causes the server to exit after the device probing stage. The +__xconfigfile__(__filemansuffix__) file is still used when this option is +given, so information that can be auto-detected should be commented out. +.TP 8 +.B \-quiet +Suppress most informational messages at startup. The verbosity level +is set to zero. +.TP 8 +.BI \-rgamma " value" +Set the red gamma correction. +.I value +must be between 0.1 and 10. The default is 1.0. Not all drivers support +this. See also the +.BR \-gamma , +.BR \-bgamma , +and +.B \-ggamma +options. +.TP 8 +.BI \-screen " screen-name" +Use the __xconfigfile__(__filemansuffix__) file +.B Screen +section called +.IR screen-name . +By default the screens referenced by the default +.B Layout +section are used, or the first +.B Screen +section when there are no +.B Layout +sections. +.TP 8 +.B \-showconfig +This is the same as the +.B \-version +option, and is included for compatibility reasons. It may be removed +in a future release, so the +.B \-version +option should be used instead. +.TP 8 +.BI \-weight " nnn" +Set RGB weighting at 16 bpp. The default is 565. This applies only to +those drivers which support 16 bpp. +.TP 8 +.BR \-verbose " [\fIn\fP]" +Sets the verbosity level for information printed on stderr. If the +.I n +value isn't supplied, each occurrence of this option increments the +verbosity level. When the +.I n +value is supplied, the verbosity level is set to that value. The default +verbosity level is 0. +.TP 8 +.B \-version +Print out the server version, patchlevel, release date, the operating +system/platform it was built on, and whether it includes module loader +support. +.TP 8 +.B \-showDefaultModulePath +Print out the default module path the server was compiled with. +.TP 8 +.B \-showDefaultLibPath +Print out the path libraries should be installed to. +.TP 8 +.BI \-config " file" +Read the server configuration from +.IR file . +This option will work for any file when the server is run as root (i.e, +with real-uid 0), or for files relative to a directory in the config +search path for all other users. +.SH "KEYBOARD" +.PP +The +.B __xservername__ +server is normally configured to recognize various special combinations +of key presses that instruct the server to perform some action, rather +than just sending the key press event to a client application. The +default XKEYBOARD keymap defines the key combinations listed below. +The server also has these key combinations builtin to its event handler +for cases where the XKEYBOARD extension is not being used. When using +the XKEYBOARD extension, which key combinations perform which actions +is completely configurable. +.PP +For more information about when the builtin event handler +is used to recognize the special key combinations, see +the documentation on the +.B HandleSpecialKeys +option in the __xconfigfile__(__filemansuffix__) man page. +.PP +The special combinations of key presses recognized directly +by +.B __xservername__ +are: +.TP 8 +.B Ctrl+Alt+Backspace +Immediately kills the server -- no questions asked. This can be disabled +with the +.B DontZap +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B Ctrl+Alt+Keypad-Plus +Change video mode to next one specified in the configuration file. +This can be disabled with the +.B DontZoom +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B Ctrl+Alt+Keypad-Minus +Change video mode to previous one specified in the configuration file. +This can be disabled with the +.B DontZoom +__xconfigfile__(__filemansuffix__) file option. +.TP 8 +.B Ctrl+Alt+Keypad-Multiply +Not treated specially by default. If the +.B AllowClosedownGrabs +__xconfigfile__(__filemansuffix__) file option is specified, this key sequence +kills clients with an active keyboard or mouse grab as well as killing any +application that may have locked the server, normally using the +XGrabServer(__libmansuffix__) Xlib function. +.TP 8 +.B Ctrl+Alt+Keypad-Divide +Not treated specially by default. If the +.B AllowDeactivateGrabs +__xconfigfile__(__filemansuffix__) file option is specified, this key sequence +deactivates any active keyboard and mouse grabs. +.TP 8 +.B Ctrl+Alt+F1...F12 +For BSD and Linux systems with virtual terminal support, these keystroke +combinations are used to switch to virtual terminals 1 through 12, +respectively. This can be disabled with the +.B DontVTSwitch +__xconfigfile__(__filemansuffix__) file option. +.SH CONFIGURATION +.B __xservername__ +typically uses a configuration file called +.B __xconfigfile__ +for its initial setup. +Refer to the __xconfigfile__(__filemansuffix__) manual page for information +about the format of this file. +.PP +.B __xservername__ +has a mechanism for automatically generating a built-in configuration +at run-time when no +.B __xconfigfile__ +file is present. The current version of this automatic configuration +mechanism works in two ways. +.PP +The first is via enhancements that have made many components of the +.B __xconfigfile__ +file optional. This means that information that can be probed or +reasonably deduced doesn't need to be specified explicitly, greatly +reducing the amount of built-in configuration information that needs to +be generated at run-time. +.PP +The second is to have "safe" fallbacks for most configuration information. +This maximises the likelihood that the +.B __xservername__ +server will start up in some usable configuration even when information +about the specific hardware is not available. +.PP +The automatic configuration support for __xservername__ is work in progress. +It is currently aimed at the most popular hardware and software platforms +supported by __xservername__. Enhancements are planned for future releases. +.SH FILES +The +.B __xservername__ +server config file can be found in a range of locations. These are +documented fully in the __xconfigfile__(__filemansuffix__) manual page. The +most commonly used locations are shown here. +.TP 30 +.B /etc/X11/__xconfigfile__ +Server configuration file. +.TP 30 +.B /etc/X11/__xconfigfile__-4 +Server configuration file. +.TP 30 +.B /etc/__xconfigfile__ +Server configuration file. +.TP 30 +.B __projectroot__/etc/__xconfigfile__ +Server configuration file. +.TP 30 +.B __projectroot__/lib/X11/__xconfigfile__ +Server configuration file. +.TP 30 +.BI __logdir__/__xservername__. n .log +Server log file for display +.IR n . +.TP 30 +.B __projectroot__/bin/\(** +Client binaries. +.TP 30 +.B __projectroot__/include/\(** +Header files. +.TP 30 +.B __projectroot__/lib/\(** +Libraries. +.TP 30 +.B __projectroot__/lib/X11/fonts/\(** +Fonts. +.TP 30 +.B __projectroot__/share/X11/rgb.txt +Color names to RGB mapping. +.TP 30 +.B __projectroot__/share/X11/XErrorDB +Client error message database. +.TP 30 +.B __projectroot__/lib/X11/app-defaults/\(** +Client resource specifications. +.TP 30 +.B __mandir__/man?/\(** +Manual pages. +.TP 30 +.BI /etc/X n .hosts +Initial access control list for display +.IR n . +.SH "SEE ALSO" +X(__miscmansuffix__), Xserver(__appmansuffix__), xdm(__appmansuffix__), xinit(__appmansuffix__), +__xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), xorgcfg(__appmansuffix__), xvidtune(__appmansuffix__), +apm(__drivermansuffix__), +ati(__drivermansuffix__), +chips(__drivermansuffix__), +cirrus(__drivermansuffix__), +cyrix(__drivermansuffix__), +fbdev(__drivermansuffix__), +glide(__drivermansuffix__), +glint(__drivermansuffix__), +i128(__drivermansuffix__), +i740(__drivermansuffix__), +i810(__drivermansuffix__), +imstt(__drivermansuffix__), +mga(__drivermansuffix__), +neomagic(__drivermansuffix__), +nsc(__drivermansuffix__), +nv(__drivermansuffix__), +r128(__drivermansuffix__), +rendition(__drivermansuffix__), +s3virge(__drivermansuffix__), +siliconmotion(__drivermansuffix__), +sis(__drivermansuffix__), +sunbw2(__drivermansuffix__), +suncg14(__drivermansuffix__), +suncg3(__drivermansuffix__), +suncg6(__drivermansuffix__), +sunffb(__drivermansuffix__), +sunleo(__drivermansuffix__), +suntcx(__drivermansuffix__), +tdfx(__drivermansuffix__), +tga(__drivermansuffix__), +trident(__drivermansuffix__), +tseng(__drivermansuffix__), +v4l(__drivermansuffix__), +vesa(__drivermansuffix__), +vga(__drivermansuffix__), +vmware(__drivermansuffix__), +.br +Web site +.IR . + +.SH AUTHORS +__xservername__ has many contributors world wide. The names of most of them +can be found in the documentation, CHANGELOG files in the source tree, +and in the actual source code. +.PP +__xservername__ was originally based on XFree86 4.4rc2. +That was originally based on \fIX386 1.2\fP by Thomas Roell, which +was contributed to the then X Consortium's X11R5 distribution by SGCS. +.PP +__xservername__ is released by the X.Org Foundation. +.PP +The project that became XFree86 was originally founded in 1992 by +David Dawes, Glenn Lai, Jim Tsillas and David Wexelblat. +.PP +XFree86 was later integrated in the then X Consortium's X11R6 release +by a group of dedicated XFree86 developers, including the following: +.PP +.RS 4 +.nf +Stuart Anderson \fIanderson@metrolink.com\fP +Doug Anson \fIdanson@lgc.com\fP +Gertjan Akkerman \fIakkerman@dutiba.twi.tudelft.nl\fP +Mike Bernson \fImike@mbsun.mlb.org\fP +Robin Cutshaw \fIrobin@XFree86.org\fP +David Dawes \fIdawes@XFree86.org\fP +Marc Evans \fImarc@XFree86.org\fP +Pascal Haible \fIhaible@izfm.uni-stuttgart.de\fP +Matthieu Herrb \fIMatthieu.Herrb@laas.fr\fP +Dirk Hohndel \fIhohndel@XFree86.org\fP +David Holland \fIdavidh@use.com\fP +Alan Hourihane \fIalanh@fairlite.demon.co.uk\fP +Jeffrey Hsu \fIhsu@soda.berkeley.edu\fP +Glenn Lai \fIglenn@cs.utexas.edu\fP +Ted Lemon \fImellon@ncd.com\fP +Rich Murphey \fIrich@XFree86.org\fP +Hans Nasten \fInasten@everyware.se\fP +Mark Snitily \fImark@sgcs.com\fP +Randy Terbush \fIrandyt@cse.unl.edu\fP +Jon Tombs \fItombs@XFree86.org\fP +Kees Verstoep \fIversto@cs.vu.nl\fP +Paul Vixie \fIpaul@vix.com\fP +Mark Weaver \fIMark_Weaver@brown.edu\fP +David Wexelblat \fIdwex@XFree86.org\fP +Philip Wheatley \fIPhilip.Wheatley@ColumbiaSC.NCR.COM\fP +Thomas Wolfram \fIwolf@prz.tu-berlin.de\fP +Orest Zborowski \fIorestz@eskimo.com\fP +.fi +.RE +.PP +__xservername__ source is available from the FTP server +\fI\fP, and from the X.Org +server \fI\fP. Documentation and other +information can be found from the X.Org web site +\fI\fP. + +.SH LEGAL +.PP +.B __xservername__ +is copyright software, provided under licenses that permit modification +and redistribution in source and binary form without fee. +.B __xservername__ is copyright by numerous authors and +contributors from around the world. Licensing information can be found +at +.IR . +Refer to the source code for specific copyright notices. +.PP +.B XFree86(TM) +is a trademark of The XFree86 Project, Inc. +.PP +.B X11(TM) +and +.B X Window System(TM) +are trademarks of The Open Group. diff --git a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre new file mode 100644 index 000000000..de93aaf36 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre @@ -0,0 +1,2223 @@ +.\" $XdotOrg: xserver/xorg/hw/xfree86/doc/man/xorg.conf.man.pre,v 1.7 2006/05/26 00:12:18 reed Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH __xconfigfile__ __filemansuffix__ __vendorversion__ +.SH NAME +__xconfigfile__ \- configuration File for __xservername__ X server +.SH INTRODUCTION +.B __xservername__ +supports several mechanisms for supplying/obtaining configuration and +run-time parameters: command line options, environment variables, the +__xconfigfile__ configuration file, auto-detection, and fallback defaults. +When the same information is supplied in more than one way, the highest +precedence mechanism is used. The list of mechanisms is ordered from +highest precedence to lowest. Note that not all parameters can be +supplied via all methods. The available command line options and +environment variables (and some defaults) are described in the Xserver(__appmansuffix__) +and __xservername__(__appmansuffix__) manual pages. Most configuration file parameters, with +their defaults, are described below. Driver and module specific +configuration parameters are described in the relevant driver or module +manual page. +.SH DESCRIPTION +.B __xservername__ +uses a configuration file called +.I __xconfigfile__ +for its initial setup. +This configuration file is searched for in the following places when the +server is started as a normal user: +.PP +.RS 4 +.nf +.IR /etc/X11/ +.IR __projectroot__/etc/X11/ +.IB /etc/X11/ $XORGCONFIG +.IB __projectroot__/etc/X11/ $XORGCONFIG +.I /etc/X11/__xconfigfile__\-4 +.I /etc/X11/__xconfigfile__ +.I /etc/__xconfigfile__ +.IR __projectroot__/etc/X11/__xconfigfile__. +.I __projectroot__/etc/X11/__xconfigfile__\-4 +.I __projectroot__/etc/X11/__xconfigfile__ +.IR __projectroot__/lib/X11/__xconfigfile__. +.I __projectroot__/lib/X11/__xconfigfile__\-4 +.I __projectroot__/lib/X11/__xconfigfile__ +.fi +.RE +.PP +where +.I +is a relative path (with no \(lq..\(rq components) specified with the +.B \-config +command line option, +.B $XORGCONFIG +is the relative path (with no \(lq..\(rq components) specified by that +environment variable, and +.I +is the machine's hostname as reported by +.BR gethostname (__oslibmansuffix__). +.PP +When the __xservername__ server is started by the \(lqroot\(rq user, the config file +search locations are as follows: +.PP +.RS 4 +.nf + +.IR /etc/X11/ +.IR __projectroot__/etc/X11/ +.B $XORGCONFIG +.IB /etc/X11/ $XORGCONFIG +.IB __projectroot__/etc/X11/ $XORGCONFIG +.BI $HOME /__xconfigfile__ +.I /etc/X11/__xconfigfile__\-4 +.I /etc/X11/__xconfigfile__ +.I /etc/__xconfigfile__ +.IR __projectroot__/etc/X11/__xconfigfile__. +.I __projectroot__/etc/X11/__xconfigfile__\-4 +.I __projectroot__/etc/X11/__xconfigfile__ +.IR __projectroot__/lib/X11/__xconfigfile__. +.I __projectroot__/lib/X11/__xconfigfile__\-4 +.I __projectroot__/lib/X11/__xconfigfile__ +.fi +.RE +.PP +where +.I +is the path specified with the +.B \-config +command line option (which may be absolute or relative), +.B $XORGCONFIG +is the path specified by that +environment variable (absolute or relative), +.B $HOME +is the path specified by that environment variable (usually the home +directory), and +.I +is the machine's hostname as reported by +.BR gethostname (__oslibmansuffix__). +.PP +The +.I __xconfigfile__ +file is composed of a number of sections which may be present in any order. +Each section has the form: +.PP +.RS 4 +.nf +.BI "Section \*q" SectionName \*q +.RI " " SectionEntry + ... +.B EndSection +.fi +.RE +.PP +The section names are: +.PP +.RS 4 +.nf +.BR "Files " "File pathnames" +.BR "ServerFlags " "Server flags" +.BR "Module " "Dynamic module loading" +.BR "InputDevice " "Input device description" +.BR "Device " "Graphics device description" +.BR "VideoAdaptor " "Xv video adaptor description" +.BR "Monitor " "Monitor description" +.BR "Modes " "Video modes descriptions" +.BR "Screen " "Screen configuration" +.BR "ServerLayout " "Overall layout" +.BR "DRI " "DRI\-specific configuration" +.BR "Vendor " "Vendor\-specific configuration" +.fi +.RE +.PP +The following obsolete section names are still recognised for compatibility +purposes. +In new config files, the +.B InputDevice +section should be used instead. +.PP +.RS 4 +.nf +.BR "Keyboard " "Keyboard configuration" +.BR "Pointer " "Pointer/mouse configuration" +.fi +.RE +.PP +The old +.B XInput +section is no longer recognised. +.PP +The +.B ServerLayout +sections are at the highest level. +They bind together the input and output devices that will be used in a session. +The input devices are described in the +.B InputDevice +sections. +Output devices usually consist of multiple independent components (e.g., +a graphics board and a monitor). +These multiple components are bound together in the +.B Screen +sections, and it is these that are referenced by the +.B ServerLayout +section. +Each +.B Screen +section binds together a graphics board and a monitor. +The graphics boards are described in the +.B Device +sections, and the monitors are described in the +.B Monitor +sections. +.PP +Config file keywords are case\-insensitive, and \(lq_\(rq characters are +ignored. +Most strings (including +.B Option +names) are also case-insensitive, and insensitive to white space and +\(lq_\(rq characters. +.PP +Each config file entry usually takes up a single line in the file. They +consist of a keyword, which is possibly followed by one or more arguments, +with the number and types of the arguments depending on the keyword. +The argument types are: +.PP +.RS 4 +.nf +.BR "Integer " "an integer number in decimal, hex or octal" +.BR "Real " "a floating point number" +.BR "String " "a string enclosed in double quote marks (\*q)" +.fi +.RE +.PP +Note: hex integer values must be prefixed with \(lq0x\(rq, and octal values +with \(lq0\(rq. +.PP +A special keyword called +.B Option +may be used to provide free\-form data to various components of the server. +The +.B Option +keyword takes either one or two string arguments. +The first is the option name, and the optional second argument is the +option value. +Some commonly used option value types include: +.PP +.RS 4 +.nf +.BR "Integer " "an integer number in decimal, hex or octal" +.BR "Real " "a floating point number" +.BR "String " "a sequence of characters" +.BR "Boolean " "a boolean value (see below)" +.BR "Frequency " "a frequency value (see below)" +.fi +.RE +.PP +Note that +.I all +.B Option +values, not just strings, must be enclosed in quotes. +.PP +Boolean options may optionally have a value specified. +When no value is specified, the option's value is +.BR TRUE . +The following boolean option values are recognised as +.BR TRUE : +.PP +.RS 4 +.BR 1 , +.BR on , +.BR true , +.B yes +.RE +.PP +and the following boolean option values are recognised as +.BR FALSE : +.PP +.RS 4 +.BR 0 , +.BR off , +.BR false , +.B no +.RE +.PP +If an option name is prefixed with +.RB \*q No \*q, +then the option value is negated. +.PP +Example: the following option entries are equivalent: +.PP +.RS 4 +.nf +.B "Option \*qAccel\*q \*qOff\*q" +.B "Option \*qNoAccel\*q" +.B "Option \*qNoAccel\*q \*qOn\*q" +.B "Option \*qAccel\*q \*qfalse\*q" +.B "Option \*qAccel\*q \*qno\*q" +.fi +.RE +.PP +Frequency option values consist of a real number that is optionally +followed by one of the following frequency units: +.PP +.RS 4 +.BR Hz , +.BR k , +.BR kHz , +.BR M , +.B MHz +.RE +.PP +When the unit name is omitted, the correct units will be determined from +the value and the expectations of the appropriate range of the value. +It is recommended that the units always be specified when using frequency +option values to avoid any errors in determining the value. +.SH "FILES SECTION" +The +.B Files +section is used to specify some path names required by the server. +Some of these paths can also be set from the command line (see +.BR Xserver (__appmansuffix__) +and +.BR __xservername__ (__appmansuffix__)). +The command line settings override the values specified in the config +file. +The +.B Files +section is optional, as are all of the entries that may appear in it. +.PP +The entries that can appear in this section are: +.TP 7 +.BI "FontPath \*q" path \*q +sets the search path for fonts. +This path is a comma separated list of font path elements which the __xservername__ +server searches for font databases. +Multiple +.B FontPath +entries may be specified, and they will be concatenated to build up the +fontpath used by the server. Font path elements can be absolute +directory paths, catalogue directories or a font server identifier. The +formats of the later two are explained below: +.PP +.RS 7 +Catalogue directories: +.PP +.RS 4 +Catalogue directories can be specified using the prefix \fBcatalogue:\fR +before the directory name. The directory can then be populated with +symlinks pointing to the real font directories, using the following +syntax in the symlink name: +.PP +.RS 4 +.IR : [attribute]: pri= +.RE +.PP +where +.I +is an alphanumeric identifier, +.I [attribute] +is an attribute wich will be passed to the underlying FPE and +.I +is a number used to order the fontfile FPEs. Examples: +.PP +.RS 4 +.nf +.I 75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi +.I gscript:pri=60 -> /usr/share/fonts/default/ghostscript +.I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc +.fi +.PP +.RE .RE .RE +.PP +.RS 7 +Font server identifiers: +.PP +.RS 4 +Font server identifiers have the form: +.RS 4 +.PP +.IR / : +.RE +.PP +where +.I +is the transport type to use to connect to the font server (e.g., +.B unix +for UNIX\-domain sockets or +.B tcp +for a TCP/IP connection), +.I +is the hostname of the machine running the font server, and +.I +is the port number that the font server is listening on (usually 7100). +.RE +.PP +When this entry is not specified in the config file, the server falls back +to the compiled\-in default font path, which contains the following +font path elements (which can be set inside a catalogue directory): +.PP +.RS 4 +.nf +.I __projectroot__/lib/X11/fonts/misc/ +.I __projectroot__/lib/X11/fonts/TTF/ +.I __projectroot__/lib/X11/fonts/Type1/ +.I __projectroot__/lib/X11/fonts/75dpi/ +.I __projectroot__/lib/X11/fonts/100dpi/ +.fi +.RE +.PP +The recommended font path contains the following font path elements: +.PP +.RS 4 +.nf +.I __projectroot__/lib/X11/fonts/local/ +.I __projectroot__/lib/X11/fonts/misc/ +.I __projectroot__/lib/X11/fonts/75dpi/:unscaled +.I __projectroot__/lib/X11/fonts/100dpi/:unscaled +.I __projectroot__/lib/X11/fonts/Type1/ +.I __projectroot__/lib/X11/fonts/75dpi/ +.I __projectroot__/lib/X11/fonts/100dpi/ +.fi +.RE +.PP +Font path elements that are found to be invalid are removed from the +font path when the server starts up. +.RE +.TP 7 +.BI "ModulePath \*q" path \*q +sets the search path for loadable __xservername__ server modules. +This path is a comma separated list of directories which the __xservername__ server +searches for loadable modules loading in the order specified. +Multiple +.B ModulePath +entries may be specified, and they will be concatenated to build the +module search path used by the server. +.\" The LogFile keyword is not currently implemented +.ig +.TP 7 +.BI "LogFile \*q" path \*q +sets the name of the __xservername__ server log file. +The default log file name is +.PP +.RS 11 +.RI __logdir__/__xservername__. .log +.RE +.PP +.RS 7 +where +.I +is the display number for the __xservername__ server. +.. +.SH "SERVERFLAGS SECTION" +In addition to options specific to this section (described below), the +.B ServerFlags +section is used to specify some global +__xservername__ server options. +All of the entries in this section are +.BR Options , +although for compatibility purposes some of the old style entries are +still recognised. +Those old style entries are not documented here, and using them is +discouraged. +The +.B ServerFlags +section is optional, as are the entries that may be specified in it. +.PP +.B Options +specified in this section (with the exception of the +.B \*qDefaultServerLayout\*q +.BR Option ) +may be overridden by +.B Options +specified in the active +.B ServerLayout +section. +Options with command line equivalents are overridden when their command +line equivalent is used. +The options recognised by this section are: +.TP 7 +.BI "Option \*qDefaultServerLayout\*q \*q" layout\-id \*q +This specifies the default +.B ServerLayout +section to use in the absence of the +.B \-layout +command line option. +.TP 7 +.BI "Option \*qNoTrapSignals\*q \*q" boolean \*q +This prevents the __xservername__ server from trapping a range of unexpected fatal +signals and exiting cleanly. +Instead, the __xservername__ server will die and drop core where the fault occurred. +The default behaviour is for the __xservername__ server to exit cleanly, but still drop a +core file. +In general you never want to use this option unless you are debugging an __xservername__ +server problem and know how to deal with the consequences. +.TP 7 +.BI "Option \*qDontVTSwitch\*q \*q" boolean \*q +This disallows the use of the +.BI Ctrl+Alt+F n +sequence (where +.RI F n +refers to one of the numbered function keys). +That sequence is normally used to switch to another \*qvirtual terminal\*q +on operating systems that have this feature. +When this option is enabled, that key sequence has no special meaning and +is passed to clients. +Default: off. +.TP 7 +.BI "Option \*qDontZap\*q \*q" boolean \*q +This disallows the use of the +.B Ctrl+Alt+Backspace +sequence. +That sequence is normally used to terminate the __xservername__ server. +When this option is enabled, that key sequence has no special meaning and +is passed to clients. +Default: off. +.TP 7 +.BI "Option \*qDontZoom\*q \*q" boolean \*q +This disallows the use of the +.B Ctrl+Alt+Keypad\-Plus +and +.B Ctrl+Alt+Keypad\-Minus +sequences. +These sequences allows you to switch between video modes. +When this option is enabled, those key sequences have no special meaning +and are passed to clients. +Default: off. +.TP 7 +.BI "Option \*qDisableVidModeExtension\*q \*q" boolean \*q +This disables the parts of the VidMode extension used by the xvidtune client +that can be used to change the video modes. +Default: the VidMode extension is enabled. +.TP 7 +.BI "Option \*qAllowNonLocalXvidtune\*q \*q" boolean \*q +This allows the xvidtune client (and other clients that use the VidMode +extension) to connect from another host. +Default: off. +.TP 7 +.BI "Option \*qDisableModInDev\*q \*q" boolean \*q +This disables the parts of the XFree86\-Misc extension that can be used to +modify the input device settings dynamically. +Default: that functionality is enabled. +.TP 7 +.BI "Option \*qAllowNonLocalModInDev\*q \*q" boolean \*q +This allows a client to connect from another host and change keyboard +and mouse settings in the running server. +Default: off. +.TP 7 +.BI "Option \*qAllowMouseOpenFail\*q \*q" boolean \*q +This allows the server to start up even if the mouse device can't be +opened/initialised. +Default: false. +.TP 7 +.BI "Option \*qVTSysReq\*q \*q" boolean \*q +enables the SYSV\-style VT switch sequence for non\-SYSV systems +which support VT switching. +This sequence is +.B Alt\-SysRq +followed by a function key +.RB ( Fn ). +This prevents the __xservername__ server trapping the +keys used for the default VT switch sequence, which means that clients can +access them. +Default: off. +.TP 7 +.BI "Option \*qXkbDisable\*q \*q" boolean \*q +disable/enable the XKEYBOARD extension. +The \-kb command line option overrides this config file option. +Default: XKB is enabled. +.\" The following four options are "undocumented". +.ig +.TP 7 +.BI "Option \*qPciProbe1\*q" +Use PCI probe method 1. +Default: set. +.TP 7 +.BI "Option \*qPciProbe2\*q" +Use PCI probe method 2. +Default: not set. +.TP 7 +.BI "Option \*qPciForceConfig1\*q" +Force the use PCI config type 1. +Default: not set. +.TP 7 +.BI "Option \*qPciForceConfig2\*q" +Force the use PCI config type 2. +Default: not set. +.. +.TP 7 +.BI "Option \*qBlankTime\*q \*q" time \*q +sets the inactivity timeout for the +.B blank +phase of the screensaver. +.I time +is in minutes. +This is equivalent to the __xservername__ server's +.B \-s +flag, and the value can be changed at run\-time with +.BR xset(__appmansuffix__). +Default: 10 minutes. +.TP 7 +.BI "Option \*qStandbyTime\*q \*q" time \*q +sets the inactivity timeout for the +.B standby +phase of DPMS mode. +.I time +is in minutes, and the value can be changed at run\-time with +.BR xset(__appmansuffix__). +Default: 20 minutes. +This is only suitable for VESA DPMS compatible monitors, and may not be +supported by all video drivers. +It is only enabled for screens that have the +.B \*qDPMS\*q +option set (see the MONITOR section below). +.TP 7 +.BI "Option \*qSuspendTime\*q \*q" time \*q +sets the inactivity timeout for the +.B suspend +phase of DPMS mode. +.I time +is in minutes, and the value can be changed at run\-time with +.BR xset(__appmansuffix__). +Default: 30 minutes. +This is only suitable for VESA DPMS compatible monitors, and may not be +supported by all video drivers. +It is only enabled for screens that have the +.B \*qDPMS\*q +option set (see the MONITOR section below). +.TP 7 +.BI "Option \*qOffTime\*q \*q" time \*q +sets the inactivity timeout for the +.B off +phase of DPMS mode. +.I time +is in minutes, and the value can be changed at run\-time with +.BR xset(__appmansuffix__). +Default: 40 minutes. +This is only suitable for VESA DPMS compatible monitors, and may not be +supported by all video drivers. +It is only enabled for screens that have the +.B \*qDPMS\*q +option set (see the MONITOR section below). +.TP 7 +.BI "Option \*qPixmap\*q \*q" bpp \*q +This sets the pixmap format to use for depth 24. +Allowed values for +.I bpp +are 24 and 32. +Default: 32 unless driver constraints don't allow this (which is rare). +Note: some clients don't behave well when this value is set to 24. +.TP 7 +.BI "Option \*qPC98\*q \*q" boolean \*q +Specify that the machine is a Japanese PC\-98 machine. +This should not be enabled for anything other than the Japanese\-specific +PC\-98 architecture. +Default: auto\-detected. +.\" Doubt this should be documented. +.ig +.TP 7 +.BI "Option \*qEstimateSizesAggressively\*q \*q" value \*q +This option affects the way that bus resource sizes are estimated. +Default: 0. +.. +.TP 7 +.BI "Option \*qNoPM\*q \*q" boolean \*q +Disables something to do with power management events. +Default: PM enabled on platforms that support it. +.TP 7 +.BI "Option \*qXinerama\*q \*q" boolean \*q +enable or disable XINERAMA extension. +Default is disabled. +.TP 7 +.BI "Option \*qAllowDeactivateGrabs\*q \*q" boolean \*q +This option enables the use of the +.B Ctrl+Alt+Keypad\-Divide +key sequence to deactivate any active keyboard and mouse grabs. +Default: off. +.TP 7 +.BI "Option \*qAllowClosedownGrabs\*q \*q" boolean \*q +This option enables the use of the +.B Ctrl+Alt+Keypad\-Multiply +key sequence to kill clients with an active keyboard or mouse grab as well +as killing any application that may have locked the server, normally using +the +.BR XGrabServer(__libmansuffix__) +Xlib function. +Default: off. +.br +Note that the options +.B AllowDeactivateGrabs +and +.B AllowClosedownGrabs +will allow users to remove the grab used by screen saver/locker programs. +An API was written to such cases. +If you enable this option, make sure your screen saver/locker is updated. +Default: off. +.TP 7 +.BI "Option \*qHandleSpecialKeys\*q \*q" when \*q +This option controls when the server uses the builtin handler to process +special key combinations (such as +.BR Ctrl+Alt+Backspace ). +Normally the XKEYBOARD extension keymaps will provide mappings for each of +the special key combinations, so the builtin handler is not needed unless +the XKEYBOARD extension is disabled. +The value of +.I when +can be +.BR Always , +.BR Never , +or +.BR WhenNeeded . +Default: Use the builtin handler only if needed. +The server will scan the keymap for a mapping to the +.B Terminate +action and, if found, use XKEYBOARD for processing actions, otherwise +the builtin handler will be used. +.TP 7 +.BI "Option \*qAIGLX\*q \*q" boolean \*q +enable or disable AIGLX. AIGLX is enabled by default. +.TP 7 +.BI "Option \*qGlxVisuals\*q \*q" string \*q +This option controls how many GLX visuals the GLX modules sets up. +The default value is +.BR "typical" , +which will setup up a typical subset of +the GLXFBConfigs provided by the driver as GLX visuals. Other options are +.BR "minimal" , +which will set up the minimal set allowed by the GLX specification and +.BR "all" +which will setup GLX visuals for all GLXFBConfigs. +.TP 7 +.BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q +Include the default font path even if other paths are specified in +xorg.conf. If enabled, other font paths are included as well. Enabled by +default. +.TP 7 +.BI "Option \*qIgnoreABI\*q \*q" boolean \*q +Allow modules built for a different, potentially incompatible version of +the X server to load. Disabled by default. +.TP 7 +.BI "Option \*qAllowEmptyInput\*q \*q" boolean \*q +If enabled, don't add the standard keyboard and mouse drivers, if there are no +input devices in the config file. Enabled by default if AutoAddDevices and +AutoEnableDevices is enabled, otherwise disabled. +If AllowEmptyInput is on, devices using the kbd or mouse driver are ignored. +.TP 7 +.BI "Option \*qAutoAddDevices\*q \*q" boolean \*q +If this option is disabled, then no devices will be added from HAL events. +Enabled by default. +.TP 7 +.BI "Option \*qAutoEnableDevices\*q \*q" boolean \*q +If this option is disabled, then the devices will be added (and the +DevicePresenceNotify event sent), but not enabled, thus leaving policy up +to the client. +Enabled by default. +.SH "MODULE SECTION" +The +.B Module +section is used to specify which __xservername__ server modules should be loaded. +This section is ignored when the __xservername__ server is built in static form. +The types of modules normally loaded in this section are __xservername__ server +extension modules, and font rasteriser modules. +Most other module types are loaded automatically when they are needed via +other mechanisms. +The +.B Module +section is optional, as are all of the entries that may be specified in +it. +.PP +Entries in this section may be in two forms. +The first and most commonly used form is an entry that uses the +.B Load +keyword, as described here: +.TP 7 +.BI "Load \*q" modulename \*q +This instructs the server to load the module called +.IR modulename . +The module name given should be the module's standard name, not the +module file name. +The standard name is case\-sensitive, and does not include the \(lqlib\(rq +prefix, or the \(lq.a\(rq, \(lq.o\(rq, or \(lq.so\(rq suffixes. +.PP +.RS 7 +Example: the FreeType font rasteriser can be loaded with the following entry: +.PP +.RS 4 +.B "Load \*qfreetype\*q" +.RE +.RE +.TP 7 +.BI "Disable \*q" modulename \*q +This instructs the server to not load the module called +.IR modulename . +Some modules are loaded by default in the server, and this overrides that +default. If a +.B Load +instruction is given for the same module, it overrides the +.B Disable +instruction and the module is loaded. The module name given should be the +module's standard name, not the module file name. As with the +.B Load +instruction, the standard name is case-sensitive, and does not include the +"lib" prefix, or the ".a", ".o", or ".so" suffixes. +.PP +The second form of entry is a +.BR SubSection, +with the subsection name being the module name, and the contents of the +.B SubSection +being +.B Options +that are passed to the module when it is loaded. +.PP +Example: the extmod module (which contains a miscellaneous group of +server extensions) can be loaded, with the XFree86\-DGA extension +disabled by using the following entry: +.PP +.RS 4 +.nf +.B "SubSection \*qextmod\*q" +.B " Option \*qomit XFree86\-DGA\*q" +.B EndSubSection +.fi +.RE +.PP +Modules are searched for in each directory specified in the +.B ModulePath +search path, and in the drivers, input, extensions, fonts, and +internal subdirectories of each of those directories. +In addition to this, operating system specific subdirectories of all +the above are searched first if they exist. +.PP +To see what font and extension modules are available, check the contents +of the following directories: +.PP +.RS 4 +.nf +__projectroot__/lib/modules/fonts +__projectroot__/lib/modules/extensions +.fi +.RE +.PP +The \(lqbitmap\(rq font module is loaded automatically. +It is recommended +that at very least the \(lqextmod\(rq extension module be loaded. +If it isn't, some commonly used server extensions (like the SHAPE +extension) will not be available. +.SH "INPUTDEVICE SECTION" +The config file may have multiple +.B InputDevice +sections. +There will normally be at least two: one for the core (primary) keyboard, +and one of the core pointer. +If either of these two is missing, a default configuration for the missing +ones will be used. +Currently the default configuration may not work as expected on all platforms. +.PP +.B InputDevice +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qInputDevice\*q" +.BI " Identifier \*q" name \*q +.BI " Driver \*q" inputdriver \*q +.I " options" +.I " ..." +.B "EndSection" +.fi +.RE +.PP +The +.B Identifier +and +.B Driver +entries are required in all +.B InputDevice +sections. +All other entries are optional. +.PP +The +.B Identifier +entry specifies the unique name for this input device. +The +.B Driver +entry specifies the name of the driver to use for this input device. +When using the loadable server, the input driver module +.RI \*q inputdriver \*q +will be loaded for each active +.B InputDevice +section. +An +.B InputDevice +section is considered active if it is referenced by an active +.B ServerLayout +section, if it is referenced by the +.B \-keyboard +or +.B \-pointer +command line options, or if it is selected implicitly as the core pointer +or keyboard device in the absence of such explicit references. +The most commonly used input drivers are +.BR keyboard (__drivermansuffix__) +and +.BR mouse (__drivermansuffix__). +.PP +In the absence of an explicitly specified core input device, the first +.B InputDevice +marked as +.B CorePointer +(or +.BR CoreKeyboard ) +is used. +If there is no match there, the first +.B InputDevice +that uses the \(lqmouse\(rq (or \(lqkeyboard\(rq or \(lqkbd\(rq) driver is used. +The final fallback is to use built\-in default configurations. +.PP +.B InputDevice +sections recognise some driver\-independent +.BR Options , +which are described here. +See the individual input driver manual pages for a description of the +device\-specific options. +.TP 7 +.BI "Option \*qCorePointer\*q" +When this is set, the input device is installed as the core (primary) +pointer device. +There must be exactly one core pointer. +If this option is not set here, or in the +.B ServerLayout +section, or from the +.B \-pointer +command line option, then the first input device that is capable of +being used as a core pointer will be selected as the core pointer. +This option is implicitly set when the obsolete +.B Pointer +section is used. +.TP 7 +.BI "Option \*qCoreKeyboard\*q" +When this is set, the input device is to be installed as the core +(primary) keyboard device. +There must be exactly one core keyboard. +If this option is not set here, in the +.B ServerLayout +section, or from the +.B \-keyboard +command line option, then the first input device that is capable of +being used as a core keyboard will be selected as the core keyboard. +This option is implicitly set when the obsolete +.B Keyboard +section is used. +.TP 7 +.BI "Option \*qAlwaysCore\*q \*q" boolean \*q +.TP 7 +.BI "Option \*qSendCoreEvents\*q \*q" boolean \*q +Both of these options are equivalent, and when enabled cause the +input device to always report core events. +This can be used, for example, to allow an additional pointer device to +generate core pointer events (like moving the cursor, etc). +.TP 4 +.BI "Option \*qHistorySize\*q \*q" number \*q +Sets the motion history size. +Default: 0. +.TP 7 +.BI "Option \*qSendDragEvents\*q \*q" boolean \*q +??? +.SH "DEVICE SECTION" +The config file may have multiple +.B Device +sections. +There must be at least one, for the video card being used. +.PP +.B Device +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" name \*q +.BI " Driver \*q" driver \*q +.I " entries" +.I " ..." +.B "EndSection" +.fi +.RE +.PP +The +.B Identifier +and +.B Driver +entries are required in all +.B Device +sections. All other entries are optional. +.PP +The +.B Identifier +entry specifies the unique name for this graphics device. +The +.B Driver +entry specifies the name of the driver to use for this graphics device. +When using the loadable server, the driver module +.RI \*q driver \*q +will be loaded for each active +.B Device +section. +A +.B Device +section is considered active if it is referenced by an active +.B Screen +section. +.PP +.B Device +sections recognise some driver\-independent entries and +.BR Options , +which are described here. +Not all drivers make use of these +driver\-independent entries, and many of those that do don't require them +to be specified because the information is auto\-detected. +See the individual graphics driver manual pages for further information +about this, and for a description of the device\-specific options. +Note that most of the +.B Options +listed here (but not the other entries) may be specified in the +.B Screen +section instead of here in the +.B Device +section. +.TP 7 +.BI "BusID \*q" bus\-id \*q +This specifies the bus location of the graphics card. +For PCI/AGP cards, +the +.I bus\-id +string has the form +.BI PCI: bus : device : function +(e.g., \(lqPCI:1:0:0\(rq might be appropriate for an AGP card). +This field is usually optional in single-head configurations when using +the primary graphics card. +In multi-head configurations, or when using a secondary graphics card in a +single-head configuration, this entry is mandatory. +Its main purpose is to make an unambiguous connection between the device +section and the hardware it is representing. +This information can usually be found by running the pciaccess tool +scanpci. +.TP 7 +.BI "Screen " number +This option is mandatory for cards where a single PCI entity can drive more +than one display (i.e., multiple CRTCs sharing a single graphics accelerator +and video memory). +One +.B Device +section is required for each head, and this +parameter determines which head each of the +.B Device +sections applies to. +The legal values of +.I number +range from 0 to one less than the total number of heads per entity. +Most drivers require that the primary screen (0) be present. +.TP 7 +.BI "Chipset \*q" chipset \*q +This usually optional entry specifies the chipset used on the graphics +board. +In most cases this entry is not required because the drivers will probe the +hardware to determine the chipset type. +Don't specify it unless the driver-specific documentation recommends that you +do. +.TP 7 +.BI "Ramdac \*q" ramdac\-type \*q +This optional entry specifies the type of RAMDAC used on the graphics +board. +This is only used by a few of the drivers, and in most cases it is not +required because the drivers will probe the hardware to determine the +RAMDAC type where possible. +Don't specify it unless the driver-specific documentation recommends that you +do. +.TP 7 +.BI "DacSpeed " speed +.TP 7 +.BI "DacSpeed " "speed\-8 speed\-16 speed\-24 speed\-32" +This optional entry specifies the RAMDAC speed rating (which is usually +printed on the RAMDAC chip). +The speed is in MHz. +When one value is given, it applies to all framebuffer pixel sizes. +When multiple values are given, they apply to the framebuffer pixel sizes +8, 16, 24 and 32 respectively. +This is not used by many drivers, and only needs to be specified when the +speed rating of the RAMDAC is different from the defaults built in to +driver, or when the driver can't auto-detect the correct defaults. +Don't specify it unless the driver-specific documentation recommends that you +do. +.TP 7 +.BI "Clocks " "clock ..." +specifies the pixel that are on your graphics board. +The clocks are in MHz, and may be specified as a floating point number. +The value is stored internally to the nearest kHz. +The ordering of the clocks is important. +It must match the order in which they are selected on the graphics board. +Multiple +.B Clocks +lines may be specified, and each is concatenated to form the list. +Most drivers do not use this entry, and it is only required for some older +boards with non-programmable clocks. +Don't specify this entry unless the driver-specific documentation explicitly +recommends that you do. +.TP +.BI "ClockChip \*q" clockchip\-type \*q +This optional entry is used to specify the clock chip type on graphics +boards which have a programmable clock generator. +Only a few __xservername__ drivers support programmable clock chips. +For details, see the appropriate driver manual page. +.TP 7 +.BI "VideoRam " "mem" +This optional entry specifies the amount of video ram that is installed +on the graphics board. +This is measured in kBytes. +In most cases this is not required because the __xservername__ server probes +the graphics board to determine this quantity. +The driver-specific documentation should indicate when it might be needed. +.TP 7 +.BI "BiosBase " "baseaddress" +This optional entry specifies the base address of the video BIOS for +the VGA board. +This address is normally auto-detected, and should only be specified if the +driver-specific documentation recommends it. +.TP 7 +.BI "MemBase " "baseaddress" +This optional entry specifies the memory base address of a graphics +board's linear frame buffer. +This entry is not used by many drivers, and it should only be specified if +the driver-specific documentation recommends it. +.TP 7 +.BI "IOBase " "baseaddress" +This optional entry specifies the IO base address. +This entry is not used by many drivers, and it should only be specified if +the driver-specific documentation recommends it. +.TP 7 +.BI "ChipID " "id" +This optional entry specifies a numerical ID representing the chip type. +For PCI cards, it is usually the device ID. +This can be used to override the auto-detection, but that should only be done +when the driver-specific documentation recommends it. +.TP 7 +.BI "ChipRev " "rev" +This optional entry specifies the chip revision number. +This can be used to override the auto-detection, but that should only be done +when the driver-specific documentation recommends it. +.TP 7 +.BI "TextClockFreq " "freq" +This optional entry specifies the pixel clock frequency that is used +for the regular text mode. +The frequency is specified in MHz. +This is rarely used. +.TP 7 +.BI "Option \*qModeDebug\*q \*q" boolean \*q +Enable printing of additional debugging information about modesetting to +the server log. +.ig +.TP 7 +This optional entry allows an IRQ number to be specified. +.. +.TP 7 +.B Options +Option flags may be specified in the +.B Device +sections. +These include driver\-specific options and driver\-independent options. +The former are described in the driver\-specific documentation. +Some of the latter are described below in the section about the +.B Screen +section, and they may also be included here. + +.SH "VIDEOADAPTOR SECTION" +Nobody wants to say how this works. +Maybe nobody knows ... + +.SH "MONITOR SECTION" +The config file may have multiple +.B Monitor +sections. +There should normally be at least one, for the monitor being used, +but a default configuration will be created when one isn't specified. +.PP +.B Monitor +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qMonitor\*q" +.BI " Identifier \*q" name \*q +.I " entries" +.I " ..." +.B "EndSection" +.fi +.RE +.PP +The only mandatory entry in a +.B Monitor +section is the +.B Identifier +entry. +.PP +The +.B Identifier +entry specifies the unique name for this monitor. +The +.B Monitor +section may be used to provide information about the specifications of the +monitor, monitor-specific +.BR Options , +and information about the video modes to use with the monitor. +.PP +With RandR 1.2-enabled drivers, monitor sections may be tied to specific +outputs of the video card. Using the name of the output defined by the video +driver plus the identifier of a monitor section, one associates a monitor +section with an output by adding an option to the Device section in the +following format: + +.B Option \*qMonitor-outputname\*q \*qmonitorsection\*q + +(for example, +.B Option \*qMonitor-VGA\*q \*qVGA monitor\*q +for a VGA output) +.PP +In the absence of specific association of monitor sections to outputs, if a +monitor section is present the server will associate it with an output to +preserve compatibility for previous single-head configurations. +.PP +Specifying video modes is optional because the server will use the DDC or other +information provided by the monitor to automatically configure the list of +modes available. +When modes are specified explicitly in the +.B Monitor +section (with the +.BR Modes , +.BR ModeLine , +or +.B UseModes +keywords), built-in modes with the same names are not included. +Built-in modes with different names are, however, still implicitly included, +when they meet the requirements of the monitor. +.PP +The entries that may be used in +.B Monitor +sections are described below. +.TP 7 +.BI "VendorName \*q" vendor \*q +This optional entry specifies the monitor's manufacturer. +.TP 7 +.BI "ModelName \*q" model \*q +This optional entry specifies the monitor's model. +.TP 7 +.BI "HorizSync " "horizsync\-range" +gives the range(s) of horizontal sync frequencies supported by the +monitor. +.I horizsync\-range +may be a comma separated list of either discrete values or ranges of +values. +A range of values is two values separated by a dash. +By default the values are in units of kHz. +They may be specified in MHz or Hz +if +.B MHz +or +.B Hz +is added to the end of the line. +The data given here is used by the __xservername__ server to determine if video +modes are within the specifications of the monitor. +This information should be available in the monitor's handbook. +If this entry is omitted, a default range of 28\-33kHz is used. +.TP 7 +.BI "VertRefresh " "vertrefresh\-range" +gives the range(s) of vertical refresh frequencies supported by the +monitor. +.I vertrefresh\-range +may be a comma separated list of either discrete values or ranges of +values. +A range of values is two values separated by a dash. +By default the values are in units of Hz. +They may be specified in MHz or kHz +if +.B MHz +or +.B kHz +is added to the end of the line. +The data given here is used by the __xservername__ server to determine if video +modes are within the specifications of the monitor. +This information should be available in the monitor's handbook. +If this entry is omitted, a default range of 43\-72Hz is used. +.TP 7 +.BI "DisplaySize " "width height" +This optional entry gives the width and height, in millimetres, of the +picture area of the monitor. +If given this is used to calculate the horizontal and vertical pitch (DPI) of +the screen. +.TP 7 +.BI "Gamma " "gamma\-value" +.TP 7 +.BI "Gamma " "red\-gamma green\-gamma blue\-gamma" +This is an optional entry that can be used to specify the gamma correction +for the monitor. +It may be specified as either a single value or as three separate RGB values. +The values should be in the range 0.1 to 10.0, and the default is 1.0. +Not all drivers are capable of using this information. +.TP 7 +.BI "UseModes \*q" modesection\-id \*q +Include the set of modes listed in the +.B Modes +section called +.IR modesection\-id. +This makes all of the modes defined in that section available for use by +this monitor. +.TP 7 +.BI "Mode \*q" name \*q +This is an optional multi-line entry that can be used to provide +definitions for video modes for the monitor. +In most cases this isn't necessary because the built-in set of VESA standard +modes will be sufficient. +The +.B Mode +keyword indicates the start of a multi-line video mode description. +The mode description is terminated with the +.B EndMode +keyword. +The mode description consists of the following entries: +.RS 7 +.TP 4 +.BI "DotClock " clock +is the dot (pixel) clock rate to be used for the mode. +.TP 4 +.BI "HTimings " "hdisp hsyncstart hsyncend htotal" +specifies the horizontal timings for the mode. +.TP 4 +.BI "VTimings " "vdisp vsyncstart vsyncend vtotal" +specifies the vertical timings for the mode. +.TP 4 +.BI "Flags \*q" flag \*q " ..." +specifies an optional set of mode flags, each of which is a separate +string in double quotes. +.B \*qInterlace\*q +indicates that the mode is interlaced. +.B \*qDoubleScan\*q +indicates a mode where each scanline is doubled. +.B \*q+HSync\*q +and +.B \*q\-HSync\*q +can be used to select the polarity of the HSync signal. +.B \*q+VSync\*q +and +.B \*q\-VSync\*q +can be used to select the polarity of the VSync signal. +.B \*qComposite\*q +can be used to specify composite sync on hardware where this is supported. +Additionally, on some hardware, +.B \*q+CSync\*q +and +.B \*q\-CSync\*q +may be used to select the composite sync polarity. +.TP 4 +.BI "HSkew " hskew +specifies the number of pixels (towards the right edge of the screen) by +which the display enable signal is to be skewed. +Not all drivers use this information. +This option might become necessary to override the default value supplied +by the server (if any). +\(lqRoving\(rq horizontal lines indicate this value needs to be increased. +If the last few pixels on a scan line appear on the left of the screen, +this value should be decreased. +.TP 4 +.BI "VScan " vscan +specifies the number of times each scanline is painted on the screen. +Not all drivers use this information. +Values less than 1 are treated as 1, which is the default. +Generally, the +.B \*qDoubleScan\*q +.B Flag +mentioned above doubles this value. +.RE +.TP 7 +.BI "ModeLine \*q" name \*q " mode\-description" +This entry is a more compact version of the +.B Mode +entry, and it also can be used to specify video modes for the monitor. +is a single line format for specifying video modes. +In most cases this isn't necessary because the built\-in set of VESA +standard modes will be sufficient. +.PP +.RS 7 +The +.I mode\-description +is in four sections, the first three of which are mandatory. +The first is the dot (pixel) clock. +This is a single number specifying the pixel clock rate for the mode in +MHz. +The second section is a list of four numbers specifying the horizontal +timings. +These numbers are the +.IR hdisp , +.IR hsyncstart , +.IR hsyncend , +and +.I htotal +values. +The third section is a list of four numbers specifying the vertical +timings. +These numbers are the +.IR vdisp , +.IR vsyncstart , +.IR vsyncend , +and +.I vtotal +values. +The final section is a list of flags specifying other characteristics of +the mode. +.B Interlace +indicates that the mode is interlaced. +.B DoubleScan +indicates a mode where each scanline is doubled. +.B +HSync +and +.B \-HSync +can be used to select the polarity of the HSync signal. +.B +VSync +and +.B \-VSync +can be used to select the polarity of the VSync signal. +.B Composite +can be used to specify composite sync on hardware where this is supported. +Additionally, on some hardware, +.B +CSync +and +.B \-CSync +may be used to select the composite sync polarity. +The +.B HSkew +and +.B VScan +options mentioned above in the +.B Modes +entry description can also be used here. +.RE +.TP 7 +.BI "Option " "\*qDPMS\*q " \*qbool\*q +This option controls whether the server should enable the DPMS extension +for power management for this screen. The default is to enable the +extension. +.TP 7 +.BI "Option " "\*qSyncOnGreen\*q " \*qbool\*q +This option controls whether the video card should drive the sync signal +on the green color pin. Not all cards support this option, and most +monitors do not require it. The default is off. +.TP 7 +.BI "Option " "\*qTargetRefresh\*q " \*qrate\*q +This optional entry specifies the vertical refresh rate that the server +should aim for when selecting video modes. Without this option, the +default is to prefer modes with higher refresh rates. +.TP 7 +.BI "Option " "\*qPreferredMode\*q " \*qstring\*q +This optional entry specifies a mode to be marked as the preferred initial mode +of the monitor. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qPosition\*q " "\*qx y\*q" +This optional entry specifies the position of the monitor within the X +screen. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qLeftOf\*q " \*qoutput\*q +This optional entry specifies that the monitor should be positioned to the +left of the output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qRightOf\*q " \*qoutput\*q +This optional entry specifies that the monitor should be positioned to the +right of the output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qAbove\*q " \*qoutput\*q +This optional entry specifies that the monitor should be positioned above the +output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qBelow\*q " \*qoutput\*q +This optional entry specifies that the monitor should be positioned below the +output (not monitor) of the given name. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qEnable\*q " \*qbool\*q +This optional entry specifies whether the monitor should be turned on +at startup. By default, the server will attempt to enable all connected +monitors. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qMinClock\*q " \*qfrequency\*q +This optional entry specifies the minimum dot clock, in kHz, that is supported +by the monitor. +.TP 7 +.BI "Option " "\*qMaxClock\*q " \*qfrequency\*q +This optional entry specifies the maximum dot clock, in kHz, that is supported +by the monitor. +.TP 7 +.BI "Option " "\*qIgnore\*q " \*qbool\*q +This optional entry specifies that the monitor should be ignored entirely, +and not reported through RandR. This is useful if the hardware reports the +presence of outputs that don't exist. +(RandR 1.2-supporting drivers only) +.TP 7 +.BI "Option " "\*qRotate\*q " \*qrotation\*q +This optional entry specifies the initial rotation of the given monitor. +Valid values for rotation are \*qnormal\*q, \*qleft\*q, \*qright\*q, and +\*qinverted\*q. +(RandR 1.2-supporting drivers only) + +.SH "MODES SECTION" +The config file may have multiple +.B Modes +sections, or none. +These sections provide a way of defining sets of video modes independently +of the +.B Monitor +sections. +.B Monitor +sections may include the definitions provided in these sections by +using the +.B UseModes +keyword. +In most cases the +.B Modes +sections are not necessary because the built\-in set of VESA standard modes +will be sufficient. +.PP +.B Modes +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qModes\*q" +.BI " Identifier \*q" name \*q +.I " entries" +.I " ..." +.B "EndSection" +.fi +.RE +.PP +The +.B Identifier +entry specifies the unique name for this set of mode descriptions. +The other entries permitted in +.B Modes +sections are the +.B Mode +and +.B ModeLine +entries that are described above in the +.B Monitor +section. +.SH "SCREEN SECTION" +The config file may have multiple +.B Screen +sections. +There must be at least one, for the \(lqscreen\(rq being used. +A \(lqscreen\(rq represents the binding of a graphics device +.RB ( Device +section) and a monitor +.RB ( Monitor +section). +A +.B Screen +section is considered \(lqactive\(rq if it is referenced by an active +.B ServerLayout +section or by the +.B \-screen +command line option. +If neither of those is present, the first +.B Screen +section found in the config file is considered the active one. +.PP +.B Screen +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qScreen\*q" +.BI " Identifier \*q" name \*q +.BI " Device \*q" devid \*q +.BI " Monitor \*q" monid \*q +.I " entries" +.I " ..." +.BI " SubSection \*qDisplay\*q" +.I " entries" +.I " ... +.B " EndSubSection" +.I " ..." +.B "EndSection" +.fi +.RE +.PP +The +.B Identifier +and +.B Device +entries are mandatory. +All others are optional. +.PP +The +.B Identifier +entry specifies the unique name for this screen. +The +.B Screen +section provides information specific to the whole screen, including +screen\-specific +.BR Options . +In multi\-head configurations, there will be multiple active +.B Screen +sections, one for each head. +The entries available +for this section are: +.TP 7 +.BI "Device \*q" device\-id \*q +This mandatory entry specifies the +.B Device +section to be used for this screen. +This is what ties a specific graphics card to a screen. +The +.I device\-id +must match the +.B Identifier +of a +.B Device +section in the config file. +.TP 7 +.BI "Monitor \*q" monitor\-id \*q +specifies which monitor description is to be used for this screen. +If a +.B Monitor +name is not specified, a default configuration is used. +Currently the default configuration may not function as expected on all +platforms. +.TP 7 +.BI "VideoAdaptor \*q" xv\-id \*q +specifies an optional Xv video adaptor description to be used with this +screen. +.TP 7 +.BI "DefaultDepth " depth +specifies which color depth the server should use by default. +The +.B \-depth +command line option can be used to override this. +If neither is specified, the default depth is driver\-specific, but in most +cases is 8. +.TP 7 +.BI "DefaultFbBpp " bpp +specifies which framebuffer layout to use by default. +The +.B \-fbbpp +command line option can be used to override this. +In most cases the driver will chose the best default value for this. +The only case where there is even a choice in this value is for depth 24, +where some hardware supports both a packed 24 bit framebuffer layout and a +sparse 32 bit framebuffer layout. +.TP 7 +.B Options +Various +.B Option +flags may be specified in the +.B Screen +section. +Some are driver\-specific and are described in the driver documentation. +Others are driver\-independent, and will eventually be described here. +.\" XXX These should really be in an xaa man page. +.TP 7 +.BI "Option \*qAccel\*q" +Enables XAA (X Acceleration Architecture), a mechanism that makes video +cards' 2D hardware acceleration available to the __xservername__ server. +This option is on by default, but it may be necessary to turn it off if +there are bugs in the driver. +There are many options to disable specific accelerated operations, listed +below. +Note that disabling an operation will have no effect if the operation is +not accelerated (whether due to lack of support in the hardware or in the +driver). +.TP 7 +.BI "Option \*qInitPrimary\*q \*q" boolean \*q +Use the Int10 module to initialize the primary graphics card. +Normally, only secondary cards are soft-booted using the Int10 module, as the +primary card has already been initialized by the BIOS at boot time. +Default: false. +.TP 7 +.BI "Option \*qNoInt10\*q \*q" boolean \*q +Disables the Int10 module, a module that uses the int10 call to the BIOS +of the graphics card to initialize it. +Default: false. +.TP 7 +.BI "Option \*qNoMTRR\*q" +Disables MTRR (Memory Type Range Register) support, a feature of modern +processors which can improve video performance by a factor of up to 2.5. +Some hardware has buggy MTRR support, and some video drivers have been +known to exhibit problems when MTRR's are used. +.TP 7 +.BI "Option \*qXaaNoCPUToScreenColorExpandFill\*q" +Disables accelerated rectangular expansion blits from source patterns +stored in system memory (using a memory\-mapped aperture). +.TP 7 +.BI "Option \*qXaaNoColor8x8PatternFillRect\*q" +Disables accelerated fills of a rectangular region with a full\-color +pattern. +.TP 7 +.BI "Option \*qXaaNoColor8x8PatternFillTrap\*q" +Disables accelerated fills of a trapezoidal region with a full\-color +pattern. +.TP 7 +.BI "Option \*qXaaNoDashedBresenhamLine\*q" +Disables accelerated dashed Bresenham line draws. +.TP 7 +.BI "Option \*qXaaNoDashedTwoPointLine\*q" +Disables accelerated dashed line draws between two arbitrary points. +.TP 7 +.BI "Option \*qXaaNoImageWriteRect\*q" +Disables accelerated transfers of full\-color rectangular patterns from +system memory to video memory (using a memory\-mapped aperture). +.TP 7 +.BI "Option \*qXaaNoMono8x8PatternFillRect\*q" +Disables accelerated fills of a rectangular region with a monochrome +pattern. +.TP 7 +.BI "Option \*qXaaNoMono8x8PatternFillTrap\*q" +Disables accelerated fills of a trapezoidal region with a monochrome +pattern. +.TP 7 +.BI "Option \*qXaaNoOffscreenPixmaps\*q" +Disables accelerated draws into pixmaps stored in offscreen video memory. +.TP 7 +.BI "Option \*qXaaNoPixmapCache\*q" +Disables caching of patterns in offscreen video memory. +.TP 7 +.BI "Option \*qXaaNoScanlineCPUToScreenColorExpandFill\*q" +Disables accelerated rectangular expansion blits from source patterns +stored in system memory (one scan line at a time). +.TP 7 +.BI "Option \*qXaaNoScanlineImageWriteRect\*q" +Disables accelerated transfers of full\-color rectangular patterns from +system memory to video memory (one scan line at a time). +.TP 7 +.BI "Option \*qXaaNoScreenToScreenColorExpandFill\*q" +Disables accelerated rectangular expansion blits from source patterns +stored in offscreen video memory. +.TP 7 +.BI "Option \*qXaaNoScreenToScreenCopy\*q" +Disables accelerated copies of rectangular regions from one part of +video memory to another part of video memory. +.TP 7 +.BI "Option \*qXaaNoSolidBresenhamLine\*q" +Disables accelerated solid Bresenham line draws. +.TP 7 +.BI "Option \*qXaaNoSolidFillRect\*q" +Disables accelerated solid\-color fills of rectangles. +.TP 7 +.BI "Option \*qXaaNoSolidFillTrap\*q" +Disables accelerated solid\-color fills of Bresenham trapezoids. +.TP 7 +.BI "Option \*qXaaNoSolidHorVertLine\*q" +Disables accelerated solid horizontal and vertical line draws. +.TP 7 +.BI "Option \*qXaaNoSolidTwoPointLine\*q" +Disables accelerated solid line draws between two arbitrary points. +.PP +Each +.B Screen +section may optionally contain one or more +.B Display +subsections. +Those subsections provide depth/fbbpp specific configuration information, +and the one chosen depends on the depth and/or fbbpp that is being used for +the screen. +The +.B Display +subsection format is described in the section below. + +.SH "DISPLAY SUBSECTION" +Each +.B Screen +section may have multiple +.B Display +subsections. +The \(lqactive\(rq +.B Display +subsection is the first that matches the depth and/or fbbpp values being +used, or failing that, the first that has neither a depth or fbbpp value +specified. +The +.B Display +subsections are optional. +When there isn't one that matches the depth and/or fbbpp values being used, +all the parameters that can be specified here fall back to their defaults. +.PP +.B Display +subsections have the following format: +.PP +.RS 4 +.nf +.B " SubSection \*qDisplay\*q" +.BI " Depth " depth +.I " entries" +.I " ..." +.B " EndSubSection" +.fi +.RE +.TP 7 +.BI "Depth " depth +This entry specifies what colour depth the +.B Display +subsection is to be used for. +This entry is usually specified, but it may be omitted to create a match\-all +.B Display +subsection or when wishing to match only against the +.B FbBpp +parameter. +The range of +.I depth +values that are allowed depends on the driver. +Most drivers support 8, 15, 16 and 24. +Some also support 1 and/or 4, and some may support other values (like 30). +Note: +.I depth +means the number of bits in a pixel that are actually used to determine +the pixel colour. +32 is not a valid +.I depth +value. +Most hardware that uses 32 bits per pixel only uses 24 of them to hold the +colour information, which means that the colour depth is 24, not 32. +.TP 7 +.BI "FbBpp " bpp +This entry specifies the framebuffer format this +.B Display +subsection is to be used for. +This entry is only needed when providing depth 24 configurations that allow +a choice between a 24 bpp packed framebuffer format and a 32bpp sparse +framebuffer format. +In most cases this entry should not be used. +.TP 7 +.BI "Weight " "red\-weight green\-weight blue\-weight" +This optional entry specifies the relative RGB weighting to be used +for a screen is being used at depth 16 for drivers that allow multiple +formats. +This may also be specified from the command line with the +.B \-weight +option (see +.BR __xservername__(__appmansuffix__)). +.TP 7 +.BI "Virtual " "xdim ydim" +This optional entry specifies the virtual screen resolution to be used. +.I xdim +must be a multiple of either 8 or 16 for most drivers, and a multiple +of 32 when running in monochrome mode. +The given value will be rounded down if this is not the case. +Video modes which are too large for the specified virtual size will be +rejected. +If this entry is not present, the virtual screen resolution will be set to +accommodate all the valid video modes given in the +.B Modes +entry. +Some drivers/hardware combinations do not support virtual screens. +Refer to the appropriate driver\-specific documentation for details. +.TP 7 +.BI "ViewPort " "x0 y0" +This optional entry sets the upper left corner of the initial display. +This is only relevant when the virtual screen resolution is different +from the resolution of the initial video mode. +If this entry is not given, then the initial display will be centered in +the virtual display area. +.TP 7 +.BI "Modes \*q" mode\-name \*q " ..." +This optional entry specifies the list of video modes to use. +Each +.I mode\-name +specified must be in double quotes. +They must correspond to those specified or referenced in the appropriate +.B Monitor +section (including implicitly referenced built\-in VESA standard modes). +The server will delete modes from this list which don't satisfy various +requirements. +The first valid mode in this list will be the default display mode for +startup. +The list of valid modes is converted internally into a circular list. +It is possible to switch to the next mode with +.B Ctrl+Alt+Keypad\-Plus +and to the previous mode with +.BR Ctrl+Alt+Keypad\-Minus . +When this entry is omitted, the valid modes referenced by the appropriate +.B Monitor +section will be used. If the +.B Monitor +section contains no modes, then the selection will be taken from the +built-in VESA standard modes. +.TP 7 +.BI "Visual \*q" visual\-name \*q +This optional entry sets the default root visual type. +This may also be specified from the command line (see the +.BR Xserver(__appmansuffix__) +man page). +The visual types available for depth 8 are (default is +.BR PseudoColor ): +.PP +.RS 11 +.nf +.B StaticGray +.B GrayScale +.B StaticColor +.B PseudoColor +.B TrueColor +.B DirectColor +.fi +.RE +.PP +.RS 7 +The visual type available for the depths 15, 16 and 24 are (default is +.BR TrueColor ): +.PP +.RS 4 +.nf +.B TrueColor +.B DirectColor +.fi +.RE +.PP +Not all drivers support +.B DirectColor +at these depths. +.PP +The visual types available for the depth 4 are (default is +.BR StaticColor ): +.PP +.RS 4 +.nf +.B StaticGray +.B GrayScale +.B StaticColor +.B PseudoColor +.fi +.RE +.PP +The visual type available for the depth 1 (monochrome) is +.BR StaticGray . +.RE +.TP 7 +.BI "Black " "red green blue" +This optional entry allows the \(lqblack\(rq colour to be specified. +This is only supported at depth 1. +The default is black. +.TP 7 +.BI "White " "red green blue" +This optional entry allows the \(lqwhite\(rq colour to be specified. +This is only supported at depth 1. +The default is white. +.TP 7 +.B Options +Option flags may be specified in the +.B Display +subsections. +These may include driver\-specific options and driver\-independent options. +The former are described in the driver\-specific documentation. +Some of the latter are described above in the section about the +.B Screen +section, and they may also be included here. +.SH "SERVERLAYOUT SECTION" +The config file may have multiple +.B ServerLayout +sections. +A \(lqserver layout\(rq represents the binding of one or more screens +.RB ( Screen +sections) and one or more input devices +.RB ( InputDevice +sections) to form a complete configuration. +In multi\-head configurations, it also specifies the relative layout of the +heads. +A +.B ServerLayout +section is considered \(lqactive\(rq if it is referenced by the +.B \-layout +command line option or by an +.B "Option \*qDefaultServerLayout\*q" +entry in the +.B ServerFlags +section (the former takes precedence over the latter). +If those options are not used, the first +.B ServerLayout +section found in the config file is considered the active one. +If no +.B ServerLayout +sections are present, the single active screen and two active (core) +input devices are selected as described in the relevant sections above. +.PP +.B ServerLayout +sections have the following format: +.PP +.RS 4 +.nf +.B "Section \*qServerLayout\*q" +.BI " Identifier \*q" name \*q +.BI " Screen \*q" screen\-id \*q +.I " ..." +.BI " InputDevice \*q" idev\-id \*q +.I " ..." +.I " options" +.I " ..." +.B "EndSection" +.fi +.RE +.PP +Each +.B ServerLayout +section must have an +.B Identifier +entry and at least one +.B Screen +entry. +.PP +The +.B Identifier +entry specifies the unique name for this server layout. +The +.B ServerLayout +section provides information specific to the whole session, including +session\-specific +.BR Options . +The +.B ServerFlags +options (described above) may be specified here, and ones given here +override those given in the +.B ServerFlags +section. +.PP +The entries that may be used in this section are described here. +.TP 7 +.BI "Screen " "screen\-num" " \*qscreen\-id\*q " "position\-information" +One of these entries must be given for each screen being used in +a session. +The +.I screen\-id +field is mandatory, and specifies the +.B Screen +section being referenced. +The +.I screen\-num +field is optional, and may be used to specify the screen number +in multi\-head configurations. +When this field is omitted, the screens will be numbered in the order that +they are listed in. +The numbering starts from 0, and must be consecutive. +The +.I position\-information +field describes the way multiple screens are positioned. +There are a number of different ways that this information can be provided: +.RS 7 +.TP 4 +.I "x y" +.TP 4 +.BI "Absolute " "x y" +These both specify that the upper left corner's coordinates are +.RI ( x , y ). +The +.B Absolute +keyword is optional. +Some older versions of XFree86 (4.2 and earlier) don't recognise the +.B Absolute +keyword, so it's safest to just specify the coordinates without it. +.TP 4 +.BI "RightOf \*q" screen\-id \*q +.TP 4 +.BI "LeftOf \*q" screen\-id \*q +.TP 4 +.BI "Above \*q" screen\-id \*q +.TP 4 +.BI "Below \*q" screen\-id \*q +.TP 4 +.BI "Relative \*q" screen\-id \*q " x y" +These give the screen's location relative to another screen. +The first four position the screen immediately to the right, left, above or +below the other screen. +When positioning to the right or left, the top edges are aligned. +When positioning above or below, the left edges are aligned. +The +.B Relative +form specifies the offset of the screen's origin (upper left corner) +relative to the origin of another screen. +.RE +.TP 7 +.BI "InputDevice \*q" idev\-id "\*q \*q" option \*q " ..." +One of these entries should be given for each input device being used in +a session. +Normally at least two are required, one each for the core pointer and +keyboard devices. +If either of those is missing, suitable +.B InputDevice +entries are searched for using the method described above in the +.B INPUTDEVICE +section. The +.I idev\-id +field is mandatory, and specifies the name of the +.B InputDevice +section being referenced. +Multiple +.I option +fields may be specified, each in double quotes. +The options permitted here are any that may also be given in the +.B InputDevice +sections. +Normally only session\-specific input device options would be used here. +The most commonly used options are: +.PP +.RS 11 +.nf +.B \*qCorePointer\*q +.B \*qCoreKeyboard\*q +.B \*qSendCoreEvents\*q +.fi +.RE +.PP +.RS 7 +and the first two should normally be used to indicate the core pointer +and core keyboard devices respectively. +.RE +.TP 7 +.B Options +In addition to the following, any option permitted in the +.B ServerFlags +section may also be specified here. +When the same option appears in both places, the value given here overrides +the one given in the +.B ServerFlags +section. +.TP 7 +.BI "Option \*qIsolateDevice\*q \*q" bus\-id \*q +Restrict device resets to the specified +.IR bus\-id . +See the +.B BusID +option (described in +.BR "DEVICE SECTION" , +above) for the format of the +.I bus\-id +parameter. +This option overrides +.BR SingleCard , +if specified. +At present, only PCI devices can be isolated in this manner. +.TP 7 +.BI "Option \*qSingleCard\*q \*q" boolean \*q +As +.BR IsolateDevice , +except that the bus ID of the first device in the layout is used. +.PP +Here is an example of a +.B ServerLayout +section for a dual headed configuration with two mice: +.PP +.RS 4 +.nf +.B "Section \*qServerLayout\*q" +.B " Identifier \*qLayout 1\*q" +.B " Screen \*qMGA 1\*q" +.B " Screen \*qMGA 2\*q RightOf \*qMGA 1\*q" +.B " InputDevice \*qKeyboard 1\*q \*qCoreKeyboard\*q" +.B " InputDevice \*qMouse 1\*q \*qCorePointer\*q" +.B " InputDevice \*qMouse 2\*q \*qSendCoreEvents\*q" +.B " Option \*qBlankTime\*q \*q5\*q" +.B "EndSection" +.fi +.RE +.SH "DRI SECTION" +This optional section is used to provide some information for the +Direct Rendering Infrastructure. +Details about the format of this section +can be found in the README.DRI document, which is also available on-line at +.IR . +.SH "VENDOR SECTION" +The optional +.B Vendor +section may be used to provide vendor\-specific configuration information. +Multiple +.B Vendor +sections may be present, and they may contain an +.B Identifier +entry and multiple +.B Option +flags. +The data therein is not used in this release. +.PP +.SH "SEE ALSO" +General: +.BR X (__miscmansuffix__), +.BR Xserver (__appmansuffix__), +.BR __xservername__ (__appmansuffix__), +.BR cvt (__appmansuffix__), +.BR gtf (__appmansuffix__). +.PP +.B Not all modules or interfaces are available on all platforms. +.PP +Display drivers: +.BR apm (__drivermansuffix__), +.\" .BR ati (__drivermansuffix__), +.BR chips (__drivermansuffix__), +.BR cirrus (__drivermansuffix__), +.BR cyrix (__drivermansuffix__), +.BR fbdev (__drivermansuffix__), +.BR glide (__drivermansuffix__), +.BR glint (__drivermansuffix__), +.BR i128 (__drivermansuffix__), +.BR i740 (__drivermansuffix__), +.BR i810 (__drivermansuffix__), +.BR imstt (__drivermansuffix__), +.BR mga (__drivermansuffix__), +.BR neomagic (__drivermansuffix__), +.BR nv (__drivermansuffix__), +.BR r128 (__drivermansuffix__), +.BR rendition (__drivermansuffix__), +.BR savage (__drivermansuffix__), +.BR s3virge (__drivermansuffix__), +.BR siliconmotion (__drivermansuffix__), +.BR sis (__drivermansuffix__), +.BR sunbw2 (__drivermansuffix__), +.BR suncg14 (__drivermansuffix__), +.BR suncg3 (__drivermansuffix__), +.BR suncg6 (__drivermansuffix__), +.BR sunffb (__drivermansuffix__), +.BR sunleo (__drivermansuffix__), +.BR suntcx (__drivermansuffix__), +.BR tdfx (__drivermansuffix__), +.BR tga (__drivermansuffix__), +.BR trident (__drivermansuffix__), +.BR tseng (__drivermansuffix__), +.BR vesa (__drivermansuffix__), +.BR vga (__drivermansuffix__), +.BR via (__drivermansuffix__), +.BR vmware (__drivermansuffix__). +.PP +Input drivers: +.\" .BR acecad (__drivermansuffix__), +.\" .BR calcomp (__drivermansuffix__), +.BR citron (__drivermansuffix__), +.BR dmc (__drivermansuffix__), +.BR dynapro (__drivermansuffix__), +.BR elographics (__drivermansuffix__), +.BR fpit (__drivermansuffix__), +.BR js_x (__drivermansuffix__), +.BR kbd (__drivermansuffix__), +.BR keyboard (__drivermansuffix__), +.\" .BR magictouch (__drivermansuffix__), +.BR microtouch (__drivermansuffix__), +.BR mouse (__drivermansuffix__), +.BR mutouch (__drivermansuffix__), +.BR palmax (__drivermansuffix__), +.BR penmount (__drivermansuffix__), +.BR tek4957 (__drivermansuffix__), +.\" .BR ur98 (__drivermansuffix__), +.BR void (__drivermansuffix__), +.BR wacom (__drivermansuffix__). +.PP +Other modules and interfaces: +.BR fbdevhw (__drivermansuffix__), +.\" .BR shadowfb (__drivermansuffix__), +.BR v4l (__drivermansuffix__). +.br +.SH AUTHORS +This manual page was largely rewritten by David Dawes +.IR . diff --git a/xorg-server/hw/xfree86/doc/sgml/DESIGN.sgml b/xorg-server/hw/xfree86/doc/sgml/DESIGN.sgml new file mode 100644 index 000000000..5beff653f --- /dev/null +++ b/xorg-server/hw/xfree86/doc/sgml/DESIGN.sgml @@ -0,0 +1,7414 @@ + %defs; + + + + + + + + + + + + + + + + + + + + + + +] > + +
+ +XFree86 server 4.x Design (DRAFT) +<author>The XFree86 Project, Inc +<and>Updates for X11R&relvers; by Jim Gettys +<date>19 December 2003 + + + + + + + +<ident> +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.53 2003/08/23 14:10:14 dawes Exp $ +</ident> + + +<p> +<bf>NOTE</bf>: This is a DRAFT document, and the interfaces described here +are subject to change without notice. + + +<sect>Preface +<p> + +The broad design principles are: +<itemize> + <item>keep it reasonable + <itemize> + <item>We cannot rewrite the complete server + <item>We don't want to re-invent the wheel + </itemize> + <item>keep it modular + <itemize> + <item>As many things as possible should go into modules + <item>The basic loader binary should be minimal + <item>A clean design with well defined layering is important + <item>DDX specific global variables are a nono + <item>The structure should be flexible enough to allow + future extensions + <item> The structure should minimize duplication of common code + </itemize> + <item>keep important features in mind + <itemize> + <item>multiple screens, including multiple instances of drivers + <item>mixing different color depths and visuals on different + and ideally even on the same screen + <item>better control of the PCI device used + <item>better config file parser + <item>get rid of all VGA compatibility assumptions + </itemize> +</itemize> + +Unless we find major deficiencies in the DIX layer, we should avoid +making changes there. + +<sect>The xorg.conf File +<p> + +The xorg.conf file format is similar to the old format, with the following +changes: + +<sect1>&k.device; section +<p> + + The &k.device; sections are similar to what they used to be, and + describe hardware-specific information for a single video card. + &k.device; + Some new keywords are added: + + + <descrip> + <tag>Driver "drivername"</tag> + Specifies the name of the driver to be used for the card. This + is mandatory. + <tag>BusID "busslot"</tag> + Specifies uniquely the location of the card on the bus. The + purpose is to identify particular cards in a multi-headed + configuration. The format of the argument is intentionally + vague, and may be architecture dependent. For a PCI bus, it + is something like "bus:slot:func". + </descrip> + + A &k.device; section is considered ``active'' if there is a reference + to it in an active &k.screen; section. + +<sect1>&k.screen; section +<p> + + The &k.screen; sections are similar to what they used to be. They + no longer have a &k.driver; keyword, but an &k.identifier; keyword + is added. (The &k.driver; keyword may be accepted in place of the + &k.identifier; keyword for compatibility purposes.) The identifier + can be used to identify which screen is to be active when multiple + &k.screen sections are present. It is possible to specify the active + screen from the command line. A default is chosen in the absence + of one being specified. A &k.screen; section is considered ``active'' + if there is a reference to it either from the command line, or from + an active &k.serverlayout; section. + +<sect1>&k.inputdevice; section +<p> + + The &k.inputdevice; section is a new section that describes + configuration information for input devices. It replaces the old + &s.key;Keyboard&e.key;, &s.key;Pointer&e.key; and &s.key;XInput&e.key; + sections. Like the &k.device; section, it has two mandatory keywords: + &k.identifier; and &k.driver;. For compatibility purposes the old + &s.key;Keyboard&e.key; and &s.key;Pointer&e.key; sections are + converted by the parser into &k.inputdevice; sections as follows: + + <descrip> + <tag>&s.key;Keyboard&e.key;</tag> + &k.identifier; "Implicit Core Keyboard"<newline> + &k.driver; "keyboard" + <tag>&s.key;Pointer&e.key;</tag> + &k.identifier; "Implicit Core Pointer"<newline> + &k.driver; "mouse" + </descrip> + + An &k.inputdevice; section is considered active if there is a + reference to it in an active &k.serverlayout; section. An + &k.inputdevice; section may also be referenced implicitly if there + is no &k.serverlayout; section, if the &s.cmd;-screen&e.cmd; command + line options is used, or if the &k.serverlayout; section doesn't + reference any &k.inputdevice; sections. In this case, the first + sections with drivers "keyboard" and "mouse" are used as the core + keyboard and pointer respectively. + +<sect1>&k.serverlayout; section +<p> + + The &k.serverlayout; section is a new section that is used to identify + which &k.screen; sections are to be used in a multi-headed configuration, + and the relative layout of those screens. It also identifies which + &k.inputdevice; sections are to be used. Each &k.serverlayout section + has an identifier, a list of &k.screen; section identifiers, and a list of + &k.inputdevice; section identifiers. &k.serverflags; options may also be + included in a &k.serverlayout; section, making it possible to override + the global values in the &k.serverflags; section. + + A &k.serverlayout; section can be made active by being referenced on + the command line. In the absence of this, a default will be chosen + (the first one found). The screen names may optionally be followed + by a number specifying the preferred screen number, and optionally + by information specifying the physical positioning of the screen, + either in absolute terms or relative to another screen (or screens). + When no screen number is specified, they are numbered according to + the order in which they are listed. The old (now obsolete) method + of providing the positioning information is to give the names of + the four adjacent screens. The order of these is top, bottom, left, + right. Here is an example of a &k.serverlayout; section for two + screens using the old method, with the second located to the right + of the first: + + <code> + Section "ServerLayout" + Identifier "Main Layout" + Screen 0 "Screen 1" "" "" "" "Screen 2" + Screen 1 "Screen 2" + Screen "Screen 3" + EndSection + </code> + + The preferred way of specifying the layout is to explicitly specify + the screen's location in absolute terms or relative to another + screen. + + In the absolute case, the upper left corner's coordinates are given + after the &s.key;Absolute&e.key; keyword. If the coordinates are + omitted, a value of &s.code;(0,0)&e.code; is assumed. An example + of absolute positioning follows: + + <code> + Section "ServerLayout" + Identifier "Main Layout" + Screen 0 "Screen 1" Absolute 0 0 + Screen 1 "Screen 2" Absolute 1024 0 + Screen "Screen 3" Absolute 2048 0 + EndSection + </code> + + In the relative case, the position is specified by either using one of + the following keywords followed by the name of the reference screen: + + <quote> + &s.key;RightOf&nl; + LeftOf&nl; + Above&nl; + Below&nl; + Relative&e.key; + </quote> + + When the &s.key;Relative&e.key; keyword is used, the reference screen + name is followed by the coordinates of the new screen's origin + relative to reference screen. The following example shows how to use + some of the relative positioning options. + + <code> + Section "ServerLayout" + Identifier "Main Layout" + Screen 0 "Screen 1" + Screen 1 "Screen 2" RightOf "Screen 1" + Screen "Screen 3" Relative "Screen 1" 2048 0 + EndSection + </code> + +<sect1>Options +<p> + + Options are used more extensively. They may appear in most sections + now. Options related to drivers can be present in the &k.screen;, + &k.device; and &k.monitor; sections and the &k.display; subsections. + The order of precedence is &k.display;, &k.screen;, &k.monitor;, + &k.device;. Options have been extended to allow an optional value + to be specified in addition to the option name. For more details + about options, see the <ref id="options" name="Options"> section + for details. + +<sect>Driver Interface +<p> + +The driver interface consists of a minimal set of entry points that are +required based on the external events that the driver must react to. +No non-essential structure is imposed on the way they are used beyond +that. This is a significant difference compared with the old design. + +The entry points for drawing operations are already taken care of by +the framebuffer code (including, XAA). Extensions and enhancements to +framebuffer code are outside the scope of this document. + +This approach to the driver interface provides good flexibility, but does +increase the complexity of drivers. To help address this, the XFree86 +common layer provides a set of ``helper'' functions to take care of things +that most drivers need. These helpers help minimise the amount of code +duplication between drivers. The use of helper functions by drivers is +however optional, though encouraged. The basic philosophy behind the +helper functions is that they should be useful to many drivers, that +they should balance this against the complexity of their interface. It +is inevitable that some drivers may find some helpers unsuitable and +need to provide their own code. + +Events that a driver needs to react to are: + + <descrip> + <tag>ScreenInit</tag> + + An initialisation function is called from the DIX layer for each + screen at the start of each server generation. + + <tag>Enter VT</tag> + + The server takes control of the console. + + <tag>Leave VT</tag> + + The server releases control of the console. + + <tag>Mode Switch</tag> + + Change video mode. + + <tag>ViewPort change</tag> + + Change the origin of the physical view port. + + <tag>ScreenSaver state change</tag> + + Screen saver activation/deactivation. + + <tag>CloseScreen</tag> + + A close screen function is called from the DIX layer for each screen + at the end of each server generation. + </descrip> + + +In addition to these events, the following functions are required by +the XFree86 common layer: + + <descrip> + <tag>Identify</tag> + + Print a driver identifying message. + + <tag>Probe</tag> + + This is how a driver identifies if there is any hardware present that + it knows how to drive. + + <tag>PreInit</tag> + + Process information from the xorg.conf file, determine the + full characteristics of the hardware, and determine if a valid + configuration is present. + </descrip> + +The VidMode extension also requires: + + <descrip> + <tag>ValidMode</tag> + + Identify if a new mode is usable with the current configuration. + The PreInit function (and/or helpers it calls) may also make use + of the ValidMode function or something similar. + </descrip> + + +Other extensions may require other entry points. The drivers will +inform the common layer of these in such cases. + +<sect>Resource Access Control Introduction +<p> + +Graphics devices are accessed through ranges in I/O or memory space. +While most modern graphics devices allow relocation of such ranges many +of them still require the use of well established interfaces such as +VGA memory and IO ranges or 8514/A IO ranges. With modern buses (like +PCI) it is possible for multiple video devices to share access to these +resources. The RAC (Resource Access Control) subsystem provides a +mechanism for this. + +<sect1>Terms and Definitions +<p> + +<sect2>Bus +<p> + + ``Bus'' is ambiguous as it is used for different things: it may refer + to physical incompatible extension connectors in a computer system. + The RAC system knows two such systems: The ISA bus and the PCI bus. + (On the software level EISA, MCA and VL buses are currently treated + like ISA buses). ``Bus'' may also refer to logically different + entities on a single bus system which are connected via bridges. A + PCI system may have several distinct PCI buses connecting each other + by PCI-PCI bridges or to the host CPU by HOST-PCI bridges. + + Systems that host more than one bus system link these together using + bridges. Bridges are a concern to RAC as they might block or pass + specific resources. PCI-PCI bridges may be set up to pass VGA + resources to the secondary bus. PCI-ISA buses pass any resources not + decoded on the primary PCI bus to the ISA bus. This way VGA resources + (although exclusive on the ISA bus) can be shared by ISA and PCI + cards. Currently HOST-PCI bridges are not yet handled by RAC as they + require specific drivers. + +<sect2>Entity +<p> + + The smallest independently addressable unit on a system bus is + referred to as an entity. So far we know ISA and PCI entities. PCI + entities can be located on the PCI bus by an unique ID consisting of + the bus, card and function number. + +<sect2>Resource +<p> + + ``Resource'' refers to a range of memory or I/O addresses an entity + can decode. + + If a device is capable of disabling this decoding the resource is + called sharable. For PCI devices a generic method is provided to + control resource decoding. Other devices will have to provide a + device specific function to control decoding. + + If the entity is capable of decoding this range at a different + location this resource is considered relocatable. + + Resources which start at a specific address and occupy a single + continuous range are called block resources. + + Alternatively resource addresses can be decoded in a way that they + satisfy the conditions: + <quote><verb> + address & mask == base + </verb></quote> + and + <quote><verb> + base & mask == base + </verb></quote> + Resources addressed in such a way are called sparse resources. + +<sect2>Server States +<p> + + The resource access control system knows two server states: the + SETUP and the OPERATING state. The SETUP state is entered whenever + a mode change takes place or the server exits or does VT switching. + During this state all entity resources are under resource access + control. During OPERATING state only those entities are controlled + which actually have shared resources that conflict with others. + +<sect>Control Flow in the Server and Mandatory Driver Functions +<p> + +At the start of each server generation, &s.code;main()&e.code; +(&s.code;dix/main.c&e.code;) calls the DDX function +&s.code;InitOutput()&e.code;. This is the first place that the DDX gets +control. &s.code;InitOutput()&e.code; is expected to fill in the global +&s.code;screenInfo&e.code; struct, and one +&s.code;screenInfo.screen[]&e.code; entry for each screen present. Here +is what &s.code;InitOutput()&e.code; does: + +<sect1>Parse the xorg.conf file +<p> + + This is done at the start of the first server generation only. + + The xorg.conf file is read in full, and the resulting information + stored in data structures. None of the parsed information is + processed at this point. The parser data structures are opaque to + the video drivers and to most of the common layer code. + + The entire file is parsed first to remove any section ordering + requirements. + + +<sect1>Initial processing of parsed information and command line options +<p> + + This is done at the start of the first server generation only. + + The initial processing is to determine paths like the + &s.key;ModulePath&e.key;, etc, and to determine which &k.serverlayout;, + &k.screen; and &k.device; sections are active. + + +<sect1>Enable port I/O access +<p> + + Port I/O access is controlled from the XFree86 common layer, and is + ``all or nothing''. It is enabled prior to calling driver probes, at + the start of subsequent server generations, and when VT switching + back to the Xserver. It is disabled at the end of server generations, + and when VT switching away from the Xserver. + + The implementation details of this may vary on different platforms. + + +<sect1>General bus probe +<p> + + This is done at the start of the first server generation only. + + In the case of ix86 machines, this will be a general PCI probe. + The full information obtained here will be available to the drivers. + This information persists for the life of the Xserver. In the PCI + case, the PCI information for all video cards found is available by + calling &s.code;xf86GetPciVideoInfo()&e.code;. + + <quote> + &s.code;pciVideoPtr *xf86GetPciVideoInfo(void)&e.code; + <quote><p> + returns a pointer to a list of pointers to + &s.code;pciVideoRec&e.code; entries, of which there is one for + each detected PCI video card. The list is terminated with a + &s.code;NULL&e.code; pointer. If no PCI video cards were + detected, the return value is &s.code;NULL&e.code;. + + </quote> + </quote> + + After the bus probe, the resource broker is initialised. + + +<sect1>Load initial set of modules +<p> + + This is done at the start of the first server generation only. + + The core server contains a list of mandatory modules. These are loaded + first. Currently the only module on this list is the bitmap font module. + + The next set of modules loaded are those specified explicitly in the + &k.module; section of the config file. + + The final set of initial modules are the driver modules referenced + by the active &k.device; and &k.inputdevice; sections in the config + file. Each of these modules is loaded exactly once. + + +<sect1>Register Video and Input Drivers +<p> + + This is done at the start of the first server generation only. + + When a driver module is loaded, the loader calls its + &s.code;Setup&e.code; function. For video drivers, this function + calls &s.code;xf86AddDriver()&e.code; to register the driver's + &s.code;DriverRec&e.code;, which contains a small set of essential + details and driver entry points required during the early phase of + &s.code;InitOutput()&e.code;. &s.code;xf86AddDriver()&e.code; adds + it to the global &s.code;xf86DriverList[]&e.code; array. + + The &s.code;DriverRec&e.code; contains the driver canonical name, + the &s.code;Identify()&e.code;, + &s.code;Probe()&e.code; and &s.code;AvailableOptions()&e.code; + function entry points as well as a pointer + to the driver's module (as returned from the loader when the driver + was loaded) and a reference count which keeps track of how many + screens are using the driver. The entry driver entry points are + those required prior to the driver allocating and filling in its + &s.code;ScrnInfoRec&e.code;. + + For a static server, the &s.code;xf86DriverList[]&e.code; array is + initialised at build time, and the loading of modules is not done. + + A similar procedure is used for input drivers. The input driver's + &s.code;Setup&e.code; function calls + &s.code;xf86AddInputDriver()&e.code; to register the driver's + &s.code;InputDriverRec&e.code;, which contains a small set of + essential details and driver entry points required during the early + phase of &s.code;InitInput()&e.code;. + &s.code;xf86AddInputDriver()&e.code; adds it to the global + &s.code;xf86InputDriverList[]&e.code; array. For a static server, + the &s.code;xf86InputDriverList[]&e.code; array is initialised at + build time. + + Both the &s.code;xf86DriverList[]&e.code; and + &s.code;xf86InputDriverList[]&e.code; arrays have been initialised + by the end of this stage. + + Once all the drivers are registered, their + &s.code;ChipIdentify()&e.code; functions are called. + + <quote> + &s.code;void ChipIdentify(int flags)&e.code; + <quote> + This is expected to print a message indicating the driver name, + a short summary of what it supports, and a list of the chipset + names that it supports. It may use the xf86PrintChipsets() helper + to do this. + </quote> + </quote> + + <quote> + &s.code;void xf86PrintChipsets(const char *drvname, const char *drvmsg, + &f.indent;SymTabPtr chips)&e.code; + <quote> + This function provides an easy way for a driver's ChipIdentify + function to format the identification message. + </quote> + </quote> + +<sect1>Initialise Access Control +<p> + + This is done at the start of the first server generation only. + + The Resource Access Control (RAC) subsystem is initialised before + calling any driver functions that may access hardware. All generic + bus information is probed and saved (for restoration later). All + (shared resource) video devices are disabled at the generic bus + level, and a probe is done to find the ``primary'' video device. These + devices remain disabled for the next step. + + +<sect1>Video Driver Probe<label id="probe"> +<p> + This is done at the start of the first server generation only. The + &s.code;ChipProbe()&e.code; function of each registered video driver + is called. + + <quote><p> + &s.code;Bool ChipProbe(DriverPtr drv, int flags)&e.code; + <quote><p> + The purpose of this is to identify all instances of hardware + supported by the driver. The flags value is currently either 0, + &s.code;PROBE_DEFAULT&e.code; or &s.code;PROBE_DETECT&e.code;. + &s.code;PROBE_DETECT&e.code; is used if "-configure" or "-probe" + command line arguments are given and indicates to the + &s.code;Probe()&e.code; function that it should not configure the + bus entities and that no xorg.conf information is available. + + The probe must find the active device sections that match the + driver by calling &s.code;xf86MatchDevice()&e.code;. The number + of matches found limits the maximum number of instances for this + driver. If no matches are found, the function should return + &s.code;FALSE&e.code; immediately. + + Devices that cannot be identified by using device-independent + methods should be probed at this stage (keeping in mind that access + to all resources that can be disabled in a device-independent way + are disabled during this phase). The probe must be a minimal + probe. It should just determine if there is a card present that + the driver can drive. It should use the least intrusive probe + methods possible. It must not do anything that is not essential, + like probing for other details such as the amount of memory + installed, etc. It is recommended that the + &s.code;xf86MatchPciInstances()&e.code; helper function be used + for identifying matching PCI devices, and similarly the + &s.code;xf86MatchIsaInstances()&e.code; for ISA (non-PCI) devices + (see the <ref id="rac" name="RAC"> section). These helpers also + checks and claims the appropriate entity. When not using the + helper, that should be done with &s.code;xf86CheckPciSlot()&e.code; + and &s.code;xf86ClaimPciSlot()&e.code; for PCI devices and + &s.code;xf86ClaimIsaSlot()&e.code; for ISA devices (see the + <ref id="rac" name="RAC"> section). + + The probe must register all non-relocatable resources at this + stage. If a resource conflict is found between exclusive resources + the driver will fail immediately. This is usually best done with + the &s.code;xf86ConfigPciEntity()&e.code; helper function + for PCI and &s.code;xf86ConfigIsaEntity()&e.code; for ISA + (see the <ref id="rac" name="RAC"> section). It is possible to + register some entity specific functions with those helpers. When + not using the helpers, the &s.code;xf86AddEntityToScreen()&e.code; + &s.code;xf86ClaimFixedResources()&e.code; and + &s.code;xf86SetEntityFuncs()&e.code; should be used instead (see + the <ref id="rac" name="RAC"> section). + + If a chipset is specified in an active device section which the + driver considers relevant (ie it has no driver specified, or the + driver specified matches the driver doing the probe), the Probe + must return &s.code;FALSE&e.code; if the chipset doesn't match + one supported by the driver. + + If there are no active device sections that the driver considers + relevant, it must return &s.code;FALSE&e.code;. + + Allocate a &s.code;ScrnInfoRec&e.code; for each active instance of the + hardware found, and fill in the basic information, including the + other driver entry points. This is best done with the + &s.code;xf86ConfigIsaEntity()&e.code; helper function for ISA + instances or &s.code;xf86ConfigPciEntity()&e.code; for PCI instances. + These functions allocate a &s.code;ScrnInfoRec&e.code; for active + entities. Optionally &s.code;xf86AllocateScreen()&e.code; + function may also be used to allocate the &s.code;ScrnInfoRec&e.code;. + Any of these functions take care of initialising fields to defined + ``unused'' values. + + Claim the entities for each instance of the hardware found. This + prevents other drivers from claiming the same hardware. + + Must leave hardware in the same state it found it in, and must not + do any hardware initialisation. + + All detection can be overridden via the config file, and that + parsed information is available to the driver at this stage. + + Returns &s.code;TRUE&e.code; if one or more instances are found, + and &s.code;FALSE&e.code; otherwise. + + </quote> + + &s.code;int xf86MatchDevice(const char *drivername, + &f.indent;GDevPtr **driversectlist)&e.code; + <quote><p> + + This function takes the name of the driver and returns via + &s.code;driversectlist&e.code; a list of device sections that + match the driver name. The function return value is the number + of matches found. If a fatal error is encountered the return + value is &s.code;-1&e.code;. + + The caller should use &s.code;xfree()&e.code; to free + &s.code;*driversectlist&e.code; when it is no longer needed. + + </quote> + + &s.code;ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags)&e.code; + <quote><p> + This function allocates a new &s.code;ScrnInfoRec&e.code; in the + &s.code;xf86Screens[]&e.code; array. This function is normally + called by the video driver &s.code;ChipProbe()&e.code; functions. + The return value is a pointer to the newly allocated + &s.code;ScrnInfoRec&e.code;. The &s.code;scrnIndex&e.code;, + &s.code;origIndex&e.code;, &s.code;module&e.code; and + &s.code;drv&e.code; fields are initialised. The reference count + in &s.code;drv&e.code; is incremented. The storage for any + currently allocated ``privates'' pointers is also allocated and + the &s.code;privates&e.code; field initialised (the privates data + is of course not allocated or initialised). This function never + returns on failure. If the allocation fails, the server exits + with a fatal error. The flags value is not currently used, and + should be set to zero. + </quote> + </quote> + + At the completion of this, a list of &s.code;ScrnInfoRecs&e.code; + have been allocated in the &s.code;xf86Screens[]&e.code; array, and + the associated entities and fixed resources have been claimed. The + following &s.code;ScrnInfoRec&e.code; fields must be initialised at + this point: + + <quote><verb> + driverVersion + driverName + scrnIndex(*) + origIndex(*) + drv(*) + module(*) + name + Probe + PreInit + ScreenInit + EnterVT + LeaveVT + numEntities + entityList + access + </verb></quote> + + <tt>(*)</tt> These are initialised when the &s.code;ScrnInfoRec&e.code; + is allocated, and not explicitly by the driver. + + The following &s.code;ScrnInfoRec&e.code; fields must be initialised + if the driver is going to use them: + + <quote><verb> + SwitchMode + AdjustFrame + FreeScreen + ValidMode + </verb></quote> + +<sect1>Matching Screens +<p> + + This is done at the start of the first server generation only. + + After the Probe phase is finished, there will be some number of + &s.code;ScrnInfoRecs&e.code;. These are then matched with the active + &k.screen; sections in the xorg.conf, and those not having an active + &k.screen; section are deleted. If the number of remaining screens + is 0, &s.code;InitOutput()&e.code; sets + &s.code;screenInfo.numScreens&e.code; to &s.code;0&e.code; and + returns. + + At this point the following fields of the &s.code;ScrnInfoRecs&e.code; + must be initialised: + + <quote><verb> + confScreen + </verb></quote> + + +<sect1>Allocate non-conflicting resources +<p> + + This is done at the start of the first server generation only. + + Before calling the drivers again, the resource information collected + from the Probe phase is processed. This includes checking the extent + of PCI resources for the probed devices, and resolving any conflicts + in the relocatable PCI resources. It also reports conflicts, checks + bus routing issues, and anything else that is needed to enable the + entities for the next phase. + + If any drivers registered an &s.code;EntityInit()&e.code; function + during the Probe phase, then they are called here. + + +<sect1>Sort the Screens and pre-check Monitor Information +<p> + + This is done at the start of the first server generation only. + + The list of screens is sorted to match the ordering requested in the + config file. + + The list of modes for each active monitor is checked against the + monitor's parameters. Invalid modes are pruned. + + +<sect1>PreInit +<p> + + This is done at the start of the first server generation only. + + For each &s.code;ScrnInfoRec&e.code;, enable access to the screens entities and call + the &s.code;ChipPreInit()&e.code; function. + + <quote><p> + &s.code;Bool ChipPreInit(ScrnInfoRec screen, int flags)&e.code; + <quote><p> + The purpose of this function is to find out all the information + required to determine if the configuration is usable, and to + initialise those parts of the &s.code;ScrnInfoRec&e.code; that + can be set once at the beginning of the first server generation. + + The number of entities registered for the screen should be checked + against the expected number (most drivers expect only one). The + entity information for each of them should be retrieved (with + &s.code;xf86GetEntityInfo()&e.code;) and checked for the correct + bus type and that none of the sharable resources registered during + the Probe phase was rejected. + + Access to resources for the entities that can be controlled in a + device-independent way are enabled before this function is called. + If the driver needs to access any resources that it has disabled + in an &s.code;EntityInit()&e.code; function that it registered, + then it may enable them here providing that it disables them before + this function returns. + + This includes probing for video memory, clocks, ramdac, and all + other HW info that is needed. It includes determining the + depth/bpp/visual and related info. It includes validating and + determining the set of video modes that will be used (and anything + that is required to determine that). + + This information should be determined in the least intrusive way + possible. The state of the HW must remain unchanged by this + function. Although video memory (including MMIO) may be mapped + within this function, it must be unmapped before returning. Driver + specific information should be stored in a structure hooked into + the &s.code;ScrnInfoRec&e.code;'s &s.code;driverPrivate&e.code; + field. Any other modules which require persistent data (ie data + that persists across server generations) should be initialised in + this function, and they should allocate a ``privates'' index to + hook their data into by calling + &s.code;xf86AllocateScrnInfoPrivateIndex().&e.code; The ``privates'' + data is persistent. + + Helper functions for some of these things are provided at the + XFree86 common level, and the driver can choose to make use of + them. + + All additional resources that the screen needs must be registered + here. This should be done with + &s.code;xf86RegisterResources()&e.code;. If some of the fixed + resources registered in the Probe phase are not needed or not + decoded by the hardware when in the OPERATING server state, their + status should be updated with + &s.code;xf86SetOperatingState()&e.code;. + + Modules may be loaded at any point in this function, and all + modules that the driver will need must be loaded before the end + of this function. Either the &s.code;xf86LoadSubModule()&e.code; + or the &s.code;xf86LoadDrvSubModule()&e.code; function should be + used to load modules depending on whether a + &s.code;ScrnInfoRec&e.code; has been set up. A driver may unload + a module within this function if it was only needed temporarily, + and the &s.code;xf86UnloadSubModule()&e.code; function should be used + to do that. Otherwise there is no need to explicitly unload modules + because the loader takes care of module dependencies and will + unload submodules automatically if/when the driver module is + unloaded. + + The bulk of the &s.code;ScrnInfoRec&e.code; fields should be filled + out in this function. + + &s.code;ChipPreInit()&e.code; returns &s.code;FALSE&e.code; when + the configuration is unusable in some way (unsupported depth, no + valid modes, not enough video memory, etc), and &s.code;TRUE&e.code; + if it is usable. + + It is expected that if the &s.code;ChipPreInit()&e.code; function + returns &s.code;TRUE&e.code;, then the only reasons that subsequent + stages in the driver might fail are lack or resources (like xalloc + failures). All other possible reasons for failure should be + determined by the &s.code;ChipPreInit()&e.code; function. + + </quote> + </quote> + + The &s.code;ScrnInfoRecs&e.code; for screens where the &s.code;ChipPreInit()&e.code; fails are removed. + If none remain, &s.code;InitOutput()&e.code; sets &s.code;screenInfo.numScreens&e.code; to &s.code;0&e.code; and returns. + + At this point, further fields of the &s.code;ScrnInfoRecs&e.code; would normally be + filled in. Most are not strictly mandatory, but many are required + by other layers and/or helper functions that the driver may choose + to use. The documentation for those layers and helper functions + indicates which they require. + + The following fields of the &s.code;ScrnInfoRecs&e.code; should be filled in if the + driver is going to use them: + + <quote><verb> + monitor + display + depth + pixmapBPP + bitsPerPixel + weight (>8bpp only) + mask (>8bpp only) + offset (>8bpp only) + rgbBits (8bpp only) + gamma + defaultVisual + maxHValue + maxVValue + virtualX + virtualY + displayWidth + frameX0 + frameY0 + frameX1 + frameY1 + zoomLocked + modePool + modes + currentMode + progClock (TRUE if clock is programmable) + chipset + ramdac + clockchip + numClocks (if not programmable) + clock[] (if not programmable) + videoRam + biosBase + memBase + memClk + driverPrivate + chipID + chipRev + </verb></quote> + + <quote><p> + &s.code;pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)&e.code: + and + &s.code;pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name)&e.code: + <quote><p> + Load a module that a driver depends on. This function loads the + module &s.code;name&e.code; as a sub module of the driver. The + return value is a handle identifying the new module. If the load + fails, the return value will be &s.code;NULL&e.code;. If a driver + needs to explicitly unload a module it has loaded in this way, + the return value must be saved and passed to + &s.code;xf86UnloadSubModule()&e.code; when unloading. + + </quote> + + &s.code;void xf86UnloadSubModule(pointer module)&e.code; + <quote><p> + Unloads the module referenced by &s.code;module&e.code;. + &s.code;module&e.code; should be a pointer returned previously + by &s.code;xf86LoadSubModule()&e.code; or + &s.code;xf86LoadDrvSubModule()&e.code; . + + </quote> + </quote> + +<sect1>Cleaning up Unused Drivers +<p> + + At this point it is known which screens will be in use, and which + drivers are being used. Unreferenced drivers (and modules they + may have loaded) are unloaded here. + + +<sect1>Consistency Checks +<p> + + The parameters that must be global to the server, like pixmap formats, + bitmap bit order, bitmap scanline unit and image byte order are + compared for each of the screens. If a mismatch is found, the server + exits with an appropriate message. + + +<sect1>Check if Resource Control is Needed +<p> + + Determine if resource access control is needed. This is the case + if more than one screen is used. If necessary the RAC wrapper module + is loaded. + +<sect1>AddScreen (ScreenInit) +<p> + + At this point, the valid screens are known. + &s.code;AddScreen()&e.code; is called for each of them, passing + &s.code;ChipScreenInit()&e.code; as the argument. + &s.code;AddScreen()&e.code; is a DIX function that allocates a new + &s.code;screenInfo.screen[]&e.code; entry (aka + &s.code;pScreen&e.code;), and does some basic initialisation of it. + It then calls the &s.code;ChipScreenInit()&e.code; function, with + &s.code;pScreen&e.code; as one of its arguments. If + &s.code;ChipScreenInit()&e.code; returns &s.code;FALSE&e.code;, + &s.code;AddScreen()&e.code; returns &s.code;-1&e.code;. Otherwise + it returns the index of the screen. &s.code;AddScreen()&e.code; + should only fail because of programming errors or failure to allocate + resources (like memory). All configuration problems should be + detected BEFORE this point. + + <quote><p> + &s.code;Bool ChipScreenInit(int index, ScreenPtr pScreen, + &f.indent;int argc, char **argv)&e.code; + <quote><p> + This is called at the start of each server generation. + + Fill in all of &s.code;pScreen&e.code;, possibly doing some of + this by calling ScreenInit functions from other layers like mi, + framebuffers (cfb, etc), and extensions. + + Decide which operations need to be placed under resource access + control. The classes of operations are the frame buffer operations + (&s.code;RAC_FB&e.code;), the pointer operations + (&s.code;RAC_CURSOR&e.code;), the viewport change operations + (&s.code;RAC_VIEWPORT&e.code;) and the colormap operations + (&s.code;RAC_COLORMAP&e.code;). Any operation that requires + resources which might be disabled during OPERATING state should + be set to use RAC. This can be specified separately for memory + and IO resources (the &s.code;racMemFlags&e.code; and + &s.code;racIoFlags&e.code; fields of the &s.code;ScrnInfoRec&e.code; + respectively). + + Map any video memory or other memory regions. + + Save the video card state. Enough state must be saved so that + the original state can later be restored. + + Initialise the initial video mode. The &s.code;ScrnInfoRec&e.code;'s + &s.code;vtSema&e.code; field should be set to &s.code;TRUE&e.code; + just prior to changing the video hardware's state. + + </quote> + </quote> + + + The &s.code;ChipScreenInit()&e.code; function (or functions from other + layers that it calls) should allocate entries in the + &s.code;ScreenRec&e.code;'s &s.code;devPrivates&e.code; area by + calling &s.code;AllocateScreenPrivateIndex()&e.code; if it needs + per-generation storage. Since the &s.code;ScreenRec&e.code;'s + &s.code;devPrivates&e.code; information is cleared for each server + generation, this is the correct place to initialise it. + + After &s.code;AddScreen()&e.code; has successfully returned, the + following &s.code;ScrnInfoRec&e.code; fields are initialised: + + <quote><verb> + pScreen + racMemFlags + racIoFlags + </verb></quote> + + The &s.code;ChipScreenInit()&e.code; function should initialise the + &s.code;CloseScreen&e.code; and &s.code;SaveScreen&e.code; fields + of &s.code;pScreen&e.code;. The old value of + &s.code;pScreen->CloseScreen&e.code; should be saved as part of + the driver's per-screen private data, allowing it to be called from + &s.code;ChipCloseScreen()&e.code;. This means that the existing + &s.code;CloseScreen()&e.code; function is wrapped. + +<sect1>Finalising RAC Initialisation +<p> + + After all the &s.code;ChipScreenInit()&e.code; functions have been + called, each screen has registered its RAC requirements. This + information is used to determine which shared resources are requested + by more than one driver and set the access functions accordingly. + This is done following these rules: + + <enum> + <item>The sharable resources registered by each entity are compared. + If a resource is registered by more than one entity the entity + will be marked to indicate that it needs to share this resources + type (IO or MEM). + + <item>A resource marked ``disabled'' during OPERATING state will be + ignored entirely. + + <item>A resource marked ``unused'' will only conflict with an overlapping + resource of an other entity if the second is actually in use + during OPERATING state. + + <item>If an ``unused'' resource was found to conflict but the entity + does not use any other resource of this type the entire resource + type will be disabled for that entity. + </enum> + + +<sect1>Finishing InitOutput() +<p> + + At this point &s.code;InitOutput()&e.code; is finished, and all the + screens have been setup in their initial video mode. + + +<sect1>Mode Switching +<p> + + When a SwitchMode event is received, &s.code;ChipSwitchMode()&e.code; + is called (when it exists): + + <quote><p> + &s.code;Bool ChipSwitchMode(int index, DisplayModePtr mode, int flags)&e.code; + <quote><p> + Initialises the new mode for the screen identified by + &s.code;index;&e.code;. The viewport may need to be adjusted + also. + + </quote> + </quote> + + +<sect1>Changing Viewport +<p> + + When a Change Viewport event is received, + &s.code;ChipAdjustFrame()&e.code; is called (when it exists): + + <quote><p> + &s.code;void ChipAdjustFrame(int index, int x, int y, int flags)&e.code; + <quote><p> + Changes the viewport for the screen identified by + &s.code;index;&e.code;. + + It should be noted that many chipsets impose restrictions on where the + viewport may be placed in the virtual resolution, either for alignment + reasons, or to prevent the start of the viewport from being positioned + within a pixel (as can happen in a 24bpp mode). After calculating the + value the chipset's panning registers need to be set to for non-DGA + modes, this function should recalculate the ScrnInfoRec's + &s.code;frameX0&e.code;, &s.code;frameY0&e.code, &s.code;frameX1&e.code; + and &s.code;frameY1&e.code; fields to correspond to that value. If + this is not done, switching to another mode might cause the position + of a hardware cursor to change. + + </quote> + </quote> + + +<sect1>VT Switching +<p> + + When a VT switch event is received, &s.code;xf86VTSwitch()&e.code; + is called. &s.code;xf86VTSwitch()&e.code; does the following: + + <descrip> + <tag>On ENTER:</tag> + <itemize> + <item>enable port I/O access + + <item>save and initialise the bus/resource state + + <item>enter the SETUP server state + + <item>calls &s.code;ChipEnterVT()&e.code; for each screen + + <item>enter the OPERATING server state + + <item>validate GCs + + <item>Restore fb from saved pixmap for each screen + + <item>Enable all input devices + </itemize> + <tag>On LEAVE:</tag> + <itemize> + <item>Save fb to pixmap for each screen + + <item>validate GCs + + <item>enter the SETUP server state + + <item>calls &s.code;ChipLeaveVT()&e.code; for each screen + + <item>disable all input devices + + <item>restore bus/resource state + + <item>disables port I/O access + </itemize> + </descrip> + + <quote><p> + &s.code;Bool ChipEnterVT(int index, int flags)&e.code; + <quote><p> + This function should initialise the current video mode and + initialise the viewport, turn on the HW cursor if appropriate, + etc. + + Should it re-save the video state before initialising the video + mode? + + </quote> + + &s.code;void ChipLeaveVT(int index, int flags)&e.code; + <quote><p> + This function should restore the saved video state. If + appropriate it should also turn off the HW cursor, and invalidate + any pixmap/font caches. + + </quote> + + Optionally, &s.code;ChipLeaveVT()&e.code; may also unmap memory + regions. If so, &s.code;ChipEnterVT()&e.code; will need to remap + them. Additionally, if an aperture used to access video memory is + unmapped and remapped in this fashion, &s.code;ChipEnterVT()&e.code; + will also need to notify the framebuffer layers of the aperture's new + location in virtual memory. This is done with a call to the screen's + &s.code;ModifyPixmapHeader()&e.code; function, as follows + + <quote><p> + &s.code;(*pScreen->ModifyPixmapHeader)(pScrn->ppix, + &f.indent;-1, -1, -1, -1, -1, <it>NewApertureAddress</it>);&e.code; + <quote><p> + where the &s.code``ppix''&e.code; field in a ScrnInfoRec + points to the pixmap used by the screen's + &s.code;SaveRestoreImage()&e.code; function to hold the screen's + contents while switched out. + + </quote> + </quote> + + Currently, aperture remapping, as described here, should not be + attempted if the driver uses the &s.code;xf8_16bpp&e.code; or + &s.code;xf8_32bpp&e.code; framebuffer layers. A pending + restructuring of VT switching will address this restriction in + the near future. + + </quote> + + Other layers may wrap the &s.code;ChipEnterVT()&e.code; and + &s.code;ChipLeaveVT()&e.code; functions if they need to take some + action when these events are received. + +<sect1>End of server generation +<p> + + At the end of each server generation, the DIX layer calls + &s.code;ChipCloseScreen()&e.code; for each screen: + + <quote><p> + &s.code;Bool ChipCloseScreen(int index, ScreenPtr pScreen)&e.code; + <quote><p> + This function should restore the saved video state and unmap the + memory regions. + + It should also free per-screen data structures allocated by the + driver. Note that the persistent data held in the + &s.code;ScrnInfoRec&e.code;'s &s.code;driverPrivate&e.code; field + should not be freed here because it is needed by subsequent server + generations. + + The &s.code;ScrnInfoRec&e.code;'s &s.code;vtSema&e.code; field + should be set to &s.code;FALSE&e.code; once the video HW state + has been restored. + + Before freeing the per-screen driver data the saved + &s.code;CloseScreen&e.code; value should be restored to + &s.code;pScreen->CloseScreen&e.code;, and that function should + be called after freeing the data. + + </quote> + </quote> + +<sect>Optional Driver Functions +<p> + +The functions outlined here can be called from the XFree86 common layer, +but their presence is optional. + +<sect1>Mode Validation +<p> + + When a mode validation helper supplied by the XFree86-common layer is + being used, it can be useful to provide a function to check for hw + specific mode constraints: + + <quote><p> + &s.code;ModeStatus ChipValidMode(int index, DisplayModePtr mode, + &f.indent;Bool verbose, int flags)&e.code; + <quote><p> + Check the passed mode for hw-specific constraints, and return the + appropriate status value. + + </quote> + </quote> + +<p> +This function may also modify the effective timings and clock of the passed +mode. These have been stored in the mode's &s.code;Crtc*&e.code; and +&s.code;SynthClock&e.code; elements, and have already been adjusted for +interlacing, doublescanning, multiscanning and clock multipliers and dividers. +The function should not modify any other mode field, unless it wants to modify +the mode timings reported to the user by &s.code;xf86PrintModes()&e.code;. + +<p> +The function is called once for every mode in the xorg.conf Monitor section +assigned to the screen, with &s.code;flags&e.code; set to +&s.code;MODECHECK_INITIAL&e.code;. It is subsequently called for every mode +in the xorg.conf Display subsection assigned to the screen, with +&s.code;flags&e.code; set to &s.code;MODECHECK_FINAL&e.code;. In the second +case, the mode will have successfully passed all other tests. In addition, +the &s.code;ScrnInfoRec&e.code;'s &s.code;virtualX&e.code;, +&s.code;virtualY&e.code; and &s.code;displayWidth&e.code; fields will have been +set as if the mode to be validated were to be the last mode accepted. + +<p> +In effect, calls with MODECHECK_INITIAL are intended for checks that do not +depend on any mode other than the one being validated, while calls with +MODECHECK_FINAL are intended for checks that may involve more than one mode. + +<sect1>Free screen data +<p> + + When a screen is deleted prior to the completion of the ScreenInit + phase the &s.code;ChipFreeScreen()&e.code; function is called when defined. + + <quote><p> + &s.code;void ChipFreeScreen(int scrnindex, int flags)&e.code; + <quote><p> + Free any driver-allocated data that may have been allocated up to + and including an unsuccessful &s.code;ChipScreenInit()&e.code; + call. This would predominantly be data allocated by + &s.code;ChipPreInit()&e.code; that persists across server + generations. It would include the &s.code;driverPrivate&e.code;, + and any ``privates'' entries that modules may have allocated. + + </quote> + </quote> + + +<sect>Recommended driver functions +<p> + +The functions outlined here are for internal use by the driver only. +They are entirely optional, and are never accessed directly from higher +layers. The sample function declarations shown here are just examples. +The interface (if any) used is up to the driver. + +<sect1>Save +<p> + + Save the video state. This could be called from &s.code;ChipScreenInit()&e.code; and + (possibly) &s.code;ChipEnterVT()&e.code;. + + <quote><p> + &s.code;void ChipSave(ScrnInfoPtr pScrn)&e.code; + <quote><p> + Saves the current state. This will only be saving pre-server + states or states before returning to the server. There is only + one current saved state per screen and it is stored in private + storage in the screen. + + </quote> + </quote> + +<sect1>Restore +<p> + + Restore the original video state. This could be called from the + &s.code;ChipLeaveVT()&e.code; and &s.code;ChipCloseScreen()&e.code; + functions. + + <quote><p> + &s.code;void ChipRestore(ScrnInfoPtr pScrn)&e.code; + <quote><p> + Restores the saved state from the private storage. Usually only + used for restoring text modes. + + </quote> + </quote> + + +<sect1>Initialise Mode +<p> + + Initialise a video mode. This could be called from the + &s.code;ChipScreenInit()&e.code;, &s.code;ChipSwitchMode()&e.code; + and &s.code;ChipEnterVT()&e.code; functions. + + <quote><p> + &s.code;Bool ChipModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)&e.code; + <quote><p> + Programs the hardware for the given video mode. + + </quote> + </quote> + + +<sect>Data and Data Structures +<p> + +<sect1>Command line data +<p> + +Command line options are typically global, and are stored in global +variables. These variables are read-only and are available to drivers +via a function call interface. Most of these command line values are +processed via helper functions to ensure that they are treated consistently +by all drivers. The other means of access is provided for cases where +the supplied helper functions might not be appropriate. + +Some of them are: + +<quote><verb> + xf86Verbose verbosity level + xf86Bpp -bpp from the command line + xf86Depth -depth from the command line + xf86Weight -weight from the command line + xf86Gamma -{r,g,b,}gamma from the command line + xf86FlipPixels -flippixels from the command line + xf86ProbeOnly -probeonly from the command line + defaultColorVisualClass -cc from the command line +</verb></quote> + +If we ever do allow for screen-specific command line options, we may +need to rethink this. + +These can be accessed in a read-only manner by drivers with the following +functions: + + <quote><p> + &s.code;int xf86GetVerbosity()&e.code; + <quote><p> + Returns the value of &s.code;xf86Verbose&e.code;. + + </quote> + + &s.code;int xf86GetDepth()&e.code; + <quote><p> + Returns the &s.cmd;-depth&e.cmd; command line setting. If not + set on the command line, &s.code;-1&e.code; is returned. + + </quote> + + &s.code;rgb xf86GetWeight()&e.code; + <quote><p> + Returns the &s.cmd;-weight&e.cmd; command line setting. If not + set on the command line, &s.code;{0, 0, 0}&e.code; is returned. + + </quote> + + &s.code;Gamma xf86GetGamma()&e.code; + <quote><p> + Returns the &s.cmd;-gamma&e.cmd; or &s.cmd;-rgamma&e.cmd;, + &s.cmd;-ggamma&e.cmd;, &s.cmd;-bgamma&e.cmd; command line settings. + If not set on the command line, &s.code;{0.0, 0.0, 0.0}&e.code; + is returned. + + </quote> + + &s.code;Bool xf86GetFlipPixels()&e.code; + <quote><p> + Returns &s.code;TRUE&e.code; if &s.cmd;-flippixels&e.cmd; is + present on the command line, and &s.code;FALSE&e.code; otherwise. + + </quote> + + &s.code;const char *xf86GetServerName()&e.code; + <quote><p> + Returns the name of the X server from the command line. + + </quote> + </quote> + +<sect1>Data handling +<p> + +Config file data contains parts that are global, and parts that are +Screen specific. All of it is parsed into data structures that neither +the drivers or most other parts of the server need to know about. + +The global data is typically not required by drivers, and as such, most +of it is stored in the private &s.code;xf86InfoRec&e.code;. + +The screen-specific data collected from the config file is stored in +screen, device, display, monitor-specific data structures that are separate +from the &s.code;ScrnInfoRecs&e.code;, with the appropriate elements/fields +hooked into the &s.code;ScrnInfoRecs&e.code; as required. The screen +config data is held in &s.code;confScreenRec&e.code;, device data in +the &s.code;GDevRec&e.code;, monitor data in the &s.code;MonRec&e.code;, +and display data in the &s.code;DispRec&e.code;. + +The XFree86 common layer's screen specific data (the actual data in use +for each screen) is held in the &s.code;ScrnInfoRecs&e.code;. As has +been outlined above, the &s.code;ScrnInfoRecs&e.code; are allocated at probe +time, and it is the responsibility of the Drivers' &s.code;Probe()&e.code; +and &s.code;PreInit()&e.code; functions to finish filling them in based +on both data provided on the command line and data provided from the +Config file. The precedence for this is: + + <quote> + command line -> config file -> probed/default data + </quote> + +For most things in this category there are helper functions that the +drivers can use to ensure that the above precedence is consistently +used. + +As well as containing screen-specific data that the XFree86 common layer +(including essential parts of the server infrastructure as well as helper +functions) needs to access, it also contains some data that drivers use +internally. When considering whether to add a new field to the +&s.code;ScrnInfoRec&e.code;, consider the balance between the convenience +of things that lots of drivers need and the size/obscurity of the +&s.code;ScrnInfoRec&e.code;. + +Per-screen driver specific data that cannot be accommodated with the +static &s.code;ScrnInfoRec&e.code; fields is held in a driver-defined +data structure, a pointer to which is assigned to the +&s.code;ScrnInfoRec&e.code;'s &s.code;driverPrivate&e.code; field. This +is per-screen data that persists across server generations (as does the +bulk of the static &s.code;ScrnInfoRec&e.code; data). It would typically +also include the video card's saved state. + +Per-screen data for other modules that the driver uses (for example, +the XAA module) that is reset for each server generation is hooked into +the &s.code;ScrnInfoRec&e.code; through it's &s.code;privates&e.code; +field. + +Once it has stabilised, the data structures and variables accessible to +video drivers will be documented here. In the meantime, those things +defined in the &s.code;xf86.h&e.code; and &s.code;xf86str.h&e.code; +files are visible to video drivers. Things defined in +&s.code;xf86Priv.h&e.code; and &s.code;xf86Privstr.h&e.code; are NOT +intended to be visible to video drivers, and it is an error for a driver +to include those files. + + +<sect1>Accessing global data +<p> + +Some other global state information that the drivers may access via +functions is as follows: + + <quote><p> + &s.code;Bool xf86ServerIsExiting()&e.code; + <quote><p> + Returns &s.code;TRUE&e.code; if the server is at the end of a + generation and is in the process of exiting, and + &s.code;FALSE&e.code; otherwise. + + </quote> + + &s.code;Bool xf86ServerIsResetting()&e.code; + <quote><p> + Returns &s.code;TRUE&e.code; if the server is at the end of a + generation and is in the process of resetting, and + &s.code;FALSE&e.code; otherwise. + + </quote> + + &s.code;Bool xf86ServerIsInitialising()&e.code; + <quote><p> + Returns &s.code;TRUE&e.code; if the server is at the beginning of + a generation and is in the process of initialising, and + &s.code;FALSE&e.code; otherwise. + + </quote> + + &s.code;Bool xf86ServerIsOnlyProbing()&e.code; + <quote><p> + Returns &s.code;TRUE&e.code; if the -probeonly command line flag + was specified, and &s.code;FALSE&e.code; otherwise. + + </quote> + + &s.code;Bool xf86CaughtSignal()&e.code; + <quote><p> + Returns &s.code;TRUE&e.code; if the server has caught a signal, + and &s.code;FALSE&e.code; otherwise. + + </quote> + </quote> + +<sect1>Allocating private data +<p> + +A driver and any module it uses may allocate per-screen private storage +in either the &s.code;ScreenRec&e.code; (DIX level) or +&s.code;ScrnInfoRec&e.code; (XFree86 common layer level). +&s.code;ScreenRec&e.code; storage persists only for a single server +generation, and &s.code;ScrnInfoRec&e.code; storage persists across +generations for the lifetime of the server. + +The &s.code;ScreenRec&e.code; &s.code;devPrivates&e.code; data must be +reallocated/initialised at the start of each new generation. This is +normally done from the &s.code;ChipScreenInit()&e.code; function, and +Init functions for other modules that it calls. Data allocated in this +way should be freed by the driver's &s.code;ChipCloseScreen()&e.code; +functions, and Close functions for other modules that it calls. A new +&s.code;devPrivates&e.code; entry is allocated by calling the +&s.code;AllocateScreenPrivateIndex()&e.code; function. + + <quote><p> + &s.code;int AllocateScreenPrivateIndex()&e.code; + <quote><p> + This function allocates a new element in the + &s.code;devPrivates&e.code; field of all currently existing + &s.code;ScreenRecs&e.code;. The return value is the index of this + new element in the &s.code;devPrivates&e.code; array. The + &s.code;devPrivates&e.code; field is of type + &s.code;DevUnion&e.code;: + + <verb> + typedef union _DevUnion { + pointer ptr; + long val; + unsigned long uval; + pointer (*fptr)(void); + } DevUnion; + </verb> + + which allows the element to be used for any of the above types. + It is commonly used as a pointer to data that the caller allocates + after the new index has been allocated. + + This function will return &s.code;-1&e.code; when there is an + error allocating the new index. + + </quote> + </quote> + +The &s.code;ScrnInfoRec&e.code; &s.code;privates&e.code; data persists +for the life of the server, so only needs to be allocated once. This +should be done from the &s.code;ChipPreInit()&e.code; function, and Init +functions for other modules that it calls. Data allocated in this way +should be freed by the driver's &s.code;ChipFreeScreen()&e.code; functions, +and Free functions for other modules that it calls. A new +&s.code;privates&e.code; entry is allocated by calling the +&s.code;xf86AllocateScrnInfoPrivateIndex()&e.code; function. + + + <quote><p> + &s.code;int xf86AllocateScrnInfoPrivateIndex()&e.code; + <quote><p> + This function allocates a new element in the &s.code;privates&e.code; + field of all currently existing &s.code;ScrnInfoRecs&e.code;. + The return value is the index of this new element in the + &s.code;privates&e.code; array. The &s.code;privates&e.code; + field is of type &s.code;DevUnion&e.code;: + + <verb> + typedef union _DevUnion { + pointer ptr; + long val; + unsigned long uval; + pointer (*fptr)(void); + } DevUnion; + </verb> + + which allows the element to be used for any of the above types. + It is commonly used as a pointer to data that the caller allocates + after the new index has been allocated. + + This function will not return when there is an error allocating + the new index. When there is an error it will cause the server + to exit with a fatal error. The similar function for allocation + privates in the &s.code;ScreenRec&e.code; + (&s.code;AllocateScreenPrivateIndex()&e.code;) differs in this + respect by returning &s.code;-1&e.code; when the allocation fails. + + </quote> + </quote> + +<sect>Keeping Track of Bus Resources<label id="rac"> +<p> + +<sect1>Theory of Operation +<p> + +The XFree86 common layer has knowledge of generic access control mechanisms +for devices on certain bus systems (currently the PCI bus) as well as +of methods to enable or disable access to the buses itself. Furthermore +it can access information on resources decoded by these devices and if +necessary modify it. + +When first starting the Xserver collects all this information, saves it +for restoration, checks it for consistency, and if necessary, corrects +it. Finally it disables all resources on a generic level prior to +calling any driver function. + +When the &s.code;Probe()&e.code; function of each driver is called the +device sections are matched against the devices found in the system. +The driver may probe devices at this stage that cannot be identified by +using device independent methods. Access to all resources that can be +controlled in a device independent way is disabled. The +&s.code;Probe()&e.code; function should register all non-relocatable +resources at this stage. If a resource conflict is found between +exclusive resources the driver will fail immediately. Optionally the +driver might specify an &s.code;EntityInit()&e.code;, +&s.code;EntityLeave()&e.code; and &s.code;EntityEnter()&e.code; function. + +&s.code;EntityInit()&e.code; can be used to disable any shared resources +that are not controlled by the generic access control functions. It is +called prior to the PreInit phase regardless if an entity is active or +not. When calling the &s.code;EntityInit()&e.code;, +&s.code;EntityEnter()&e.code; and &s.code;EntityLeave()&e.code; functions +the common level will disable access to all other entities on a generic +level. Since the common level has no knowledge of device specific +methods to disable access to resources it cannot be guaranteed that +certain resources are not decoded by any other entity until the +&s.code;EntityInit()&e.code; or &s.code;EntityEnter()&e.code; phase is +finished. Device drivers should therefore register all those resources +which they are going to disable. If these resources are never to be +used by any driver function they may be flagged &s.code;ResInit&e.code; +so that they can be removed from the resource list after processing all +&s.code;EntityInit()&e.code; functions. &s.code;EntityEnter()&e.code; +should disable decoding of all resources which are not registered as +exclusive and which are not handled by the generic access control in +the common level. The difference to &s.code;EntityInit()&e.code; is +that the latter one is only called once during lifetime of the server. +It can therefore be used to set up variables prior to disabling resources. +&s.code;EntityLeave()&e.code; should restore the original state when +exiting the server or switching to a different VT. It also needs to +disable device specific access functions if they need to be disabled on +server exit or VT switch. The default state is to enable them before +giving up the VT. + +In &s.code;PreInit()&e.code; phase each driver should check if any +sharable resources it has registered during &s.code;Probe()&e.code; has +been denied and take appropriate action which could simply be to fail. +If it needs to access resources it has disabled during +&s.code;EntitySetup()&e.code; it can do so provided it has registered +these and will disable them before returning from +&s.code;PreInit()&e.code;. This also applies to all other driver +functions. Several functions are provided to request resource ranges, +register these, correct PCI config space and add replacements for the +generic access functions. Resources may be marked ``disabled'' or +``unused'' during OPERATING stage. Although these steps could also be +performed in &s.code;ScreenInit()&e.code;, this is not desirable. + +Following &s.code;PreInit()&e.code; phase the common level determines +if resource access control is needed. This is the case if more than +one screen is used. If necessary the RAC wrapper module is loaded. In +&s.code;ScreenInit()&e.code; the drivers can decide which operations +need to be placed under RAC. Available are the frame buffer operations, +the pointer operations and the colormap operations. Any operation that +requires resources which might be disabled during OPERATING state should +be set to use RAC. This can be specified separately for memory and IO +resources. + +When &s.code;ScreenInit()&e.code; phase is done the common level will +determine which shared resources are requested by more than one driver +and set the access functions accordingly. This is done following these +rules: + +<enum> +<item>The sharable resources registered by each entity are compared. If + a resource is registered by more than one entity the entity will be + marked to need to share this resources type (&s.code;IO&e.code; or + &s.code;MEM&e.code;). + +<item>A resource marked ``disabled'' during OPERATING state will be ignored + entirely. + +<item>A resource marked ``unused'' will only conflicts with an overlapping + resource of an other entity if the second is actually in use during + OPERATING state. + +<item>If an ``unused'' resource was found to conflict however the entity + does not use any other resource of this type the entire resource type + will be disabled for that entity. +</enum> + +The driver has the choice among different ways to control access to +certain resources: + +<enum> +<item>It can rely on the generic access functions. This is probably the + most common case. Here the driver only needs to register any resource + it is going to use. + +<item>It can replace the generic access functions by driver specific + ones. This will mostly be used in cases where no generic access + functions are available. In this case the driver has to make sure + these resources are disabled when entering the &s.code;PreInit()&e.code; + stage. Since the replacement functions are registered in + &s.code;PreInit()&e.code; the driver will have to enable these + resources itself if it needs to access them during this state. The + driver can specify if the replacement functions can control memory + and/or I/O resources separately. + +<item>The driver can enable resources itself when it needs them. Each + driver function enabling them needs to disable them before it will + return. This should be used if a resource which can be controlled + in a device dependent way is only required during SETUP state. This + way it can be marked ``unused'' during OPERATING state. +</enum> + +A resource which is decoded during OPERATING state however never accessed +by the driver should be marked unused. + +Since access switching latencies are an issue during Xserver operation, +the common level attempts to minimize the number of entities that need +to be placed under RAC control. When a wrapped operation is called, +the &s.code;EnableAccess()&e.code; function is called before control is +passed on. &s.code;EnableAccess()&e.code; checks if a screen is under +access control. If not it just establishes bus routing and returns. +If the screen needs to be under access control, +&s.code;EnableAccess()&e.code; determines which resource types +(&s.code;MEM&e.code;, &s.code;IO&e.code;) are required. Then it tests +if this access is already established. If so it simply returns. If +not it disables the currently established access, fixes bus routing and +enables access to all entities registered for this screen. + +Whenever a mode switch or a VT-switch is performed the common level will +return to SETUP state. + +<sect1>Resource Types +<p> + +Resource have certain properties. When registering resources each range +is accompanied by a flag consisting of the ORed flags of the different +properties the resource has. Each resource range may be classified +according to + +<itemize> + <item>its physical properties i.e., if it addresses + memory (&s.code;ResMem&e.code;) or + I/O space (&s.code;ResIo&e.code;), + <item>if it addresses a + block (&s.code;ResBlock&e.code;) or + sparse (&s.code;ResSparse&e.code;) + range, + <item>its access properties. +</itemize> + +There are two known access properties: + +<itemize> + <item>&s.code;ResExclusive&e.code; + for resources which may not be shared with any other device and + <item>&s.code;ResShared&e.code; + for resources which can be disabled and therefore can be shared. +</itemize> + +If it is necessary to test a resource against any type a generic access +type &s.code;ResAny&e.code; is provided. If this is set the resource +will conflict with any resource of a different entity intersecting its +range. Further it can be specified that a resource is decoded however +never used during any stage (&s.code;ResUnused&e.code;) or during +OPERATING state (&s.code;ResUnusedOpr&e.code;). A resource only visible +during the init functions (ie. &s.code;EntityInit()&e.code;, +&s.code;EntityEnter()&e.code; and &s.code;EntityLeave()&e.code; should +be registered with the flag &s.code;ResInit&e.code;. A resource that +might conflict with background resource ranges may be flagged with +&s.code;ResBios&e.code;. This might be useful when registering resources +ranges that were assigned by the system Bios. + +Several predefined resource lists are available for VGA and 8514/A +resources in &s.code;common/xf86Resources.h&e.code;. + +<sect1>Available Functions<label id="avail"> +<p> + +The functions provided for resource management are listed in their order +of use in the driver. + + +<sect2>Probe Phase +<p> + +In this phase each driver detects those resources it is able to drive, +creates an entity record for each of them, registers non-relocatable +resources and allocates screens and adds the resources to screens. + +Two helper functions are provided for matching device sections in the +xorg.conf file to the devices: + + <quote><p> + &s.code;int xf86MatchPciInstances(const char *driverName, int vendorID, + &f.indent;SymTabPtr chipsets, PciChipsets *PCIchipsets, + &f.indent;GDevPtr *devList, int numDevs, DriverPtr drvp, + &f.indent;int **foundEntities)&e.code; + <quote><p> + This function finds matches between PCI cards that a driver supports + and config file device sections. It is intended for use in the + &s.code;ChipProbe()&e.code; function of drivers for PCI cards. + Only probed PCI devices with a vendor ID matching + &s.code;vendorID&e.code; are considered. &s.code;devList&e.code; + and &s.code;numDevs&e.code; are typically those found from + calling &s.code;xf86MatchDevice()&e.code;, and represent the active + config file device sections relevant to the driver. + &s.code;PCIchipsets&e.code; is a table that provides a mapping + between the PCI device IDs, the driver's internal chipset tokens + and a list of fixed resources. + + When a device section doesn't have a &s.key;BusID&e.key; entry it + can only match the primary video device. Secondary devices are + only matched with device sections that have a matching + &s.key;BusID&e.key; entry. + + Once the preliminary matches have been found, a final match is + confirmed by checking if the chipset override, ChipID override or + probed PCI chipset type match one of those given in the + &s.code;chipsets&e.code; and &s.code;PCIchipsets&e.code; lists. + The &s.code;PCIchipsets&e.code; list includes a list of the PCI + device IDs supported by the driver. The list should be terminated + with an entry with PCI ID &s.code;-1&e.code;". The + &s.code;chipsets&e.code; list is a table mapping the driver's + internal chipset tokens to names, and should be terminated with + a &s.code;NULL&e.code; entry. Only those entries with a + corresponding entry in the &s.code;PCIchipsets&e.code; list are + considered. The order of precedence is: config file chipset, + config file ChipID, probed PCI device ID. + + In cases where a driver handles PCI chipsets with more than one + vendor ID, it may set &s.code;vendorID&e.code; to + &s.code;0&e.code;, and OR each devID in the list with (the + vendor ID << 16). + + Entity index numbers for confirmed matches are returned as an + array via &s.code;foundEntities&e.code;. The PCI information, + chipset token and device section for each match are found in the + &s.code;EntityInfoRec&e.code; referenced by the indices. + + The function return value is the number of confirmed matches. A + return value of &s.code;-1&e.code; indicates an internal error. + The returned &s.code;foundEntities&e.code; array should be freed + by the driver with &s.code;xfree()&e.code; when it is no longer + needed in cases where the return value is greater than zero. + + </quote> + + &s.code;int xf86MatchIsaInstances(const char *driverName, + &f.indent;SymTabPtr chipsets, IsaChipsets *ISAchipsets, + &f.indent;DriverPtr drvp, FindIsaDevProc FindIsaDevice, + &f.indent;GDevPtr *devList, int numDevs, + int **foundEntities)&e.code; + <quote><p> + This function finds matches between ISA cards that a driver supports + and config file device sections. It is intended for use in the + &s.code;ChipProbe()&e.code; function of drivers for ISA cards. + &s.code;devList&e.code; and &s.code;numDevs&e.code; are + typically those found from calling &s.code;xf86MatchDevice()&e.code;, + and represent the active config file device sections relevant to + the driver. &s.code;ISAchipsets&e.code; is a table that provides + a mapping between the driver's internal chipset tokens and the + resource classes. &s.code;FindIsaDevice&e.code; is a + driver-provided function that probes the hardware and returns the + chipset token corresponding to what was detected, and + &s.code;-1&e.code; if nothing was detected. + + If the config file device section contains a chipset entry, then + it is checked against the &s.code;chipsets&e.code; list. When + no chipset entry is present, the &s.code;FindIsaDevice&e.code; + function is called instead. + + Entity index numbers for confirmed matches are returned as an + array via &s.code;foundEntities&e.code;. The chipset token and + device section for each match are found in the + &s.code;EntityInfoRec&e.code; referenced by the indices. + + The function return value is the number of confirmed matches. A + return value of &s.code;-1&e.code; indicates an internal error. + The returned &s.code;foundEntities&e.code; array should be freed + by the driver with &s.code;xfree()&e.code; when it is no longer + needed in cases where the return value is greater than zero. + + </quote> + </quote> + +These two helper functions make use of several core functions that are +available at the driver level: + + <quote><p> + &s.code;Bool xf86ParsePciBusString(const char *busID, int *bus, + &f.indent;int *device, int *func)&e.code; + <quote><p> + Takes a &s.code;BusID&e.code; string, and if it is in the correct + format, returns the PCI &s.code;bus&e.code;, &s.code;device&e.code;, + &s.code;func&e.code; values that it indicates. The format of the + string is expected to be "PCI:bus:device:func" where each of `bus', + `device' and `func' are decimal integers. The ":func" part may + be omitted, and the func value assumed to be zero, but this isn't + encouraged. The "PCI" prefix may also be omitted. The prefix + "AGP" is currently equivalent to the "PCI" prefix. If the string + isn't a valid PCI BusID, the return value is &s.code;FALSE&e.code;. + + </quote> + + + &s.code;Bool xf86ComparePciBusString(const char *busID, int bus, + &f.indent;int device, int func)&e.code; + <quote><p> + Compares a &s.code;BusID&e.code; string with PCI &s.code;bus&e.code;, + &s.code;device&e.code;, &s.code;func&e.code; values. If they + match &s.code;TRUE&e.code; is returned, and &s.code;FALSE&e.code; + if they don't. + + </quote> + + &s.code;Bool xf86ParseIsaBusString(const char *busID)&e.code; + <quote><p> + Compares a &s.code;BusID&e.code; string with the ISA bus ID string + ("ISA" or "ISA:"). If they match &s.code;TRUE&e.code; is returned, + and &s.code;FALSE&e.code; if they don't. + + </quote> + + &s.code;Bool xf86CheckPciSlot(int bus, int device, int func)&e.code; + <quote><p> + Checks if the PCI slot &s.code;bus:device:func&e.code; has been + claimed. If so, it returns &s.code;FALSE&e.code;, and otherwise + &s.code;TRUE&e.code;. + + </quote> + + &s.code;int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp, + &f.indent;int chipset, GDevPtr dev, Bool active)&e.code; + <quote><p> + This function is used to claim a PCI slot, allocate the associated + entity record and initialise their data structures. The return + value is the index of the newly allocated entity record, or + &s.code;-1&e.code; if the claim fails. This function should always + succeed if &s.code;xf86CheckPciSlot()&e.code; returned + &s.code;TRUE&e.code; for the same PCI slot. + + </quote> + + &s.code;Bool xf86IsPrimaryPci(void)&e.code; + <quote><p> + This function returns &s.code;TRUE&e.code; if the primary card is + a PCI device, and &s.code;FALSE&e.code; otherwise. + + </quote> + + &s.code;int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, + &f.indent;GDevPtr dev, Bool active)&e.code; + <quote><p> + This allocates an entity record entity and initialise the data + structures. The return value is the index of the newly allocated + entity record. + + </quote> + + &s.code;Bool xf86IsPrimaryIsa(void)&e.code; + <quote><p> + This function returns &s.code;TRUE&e.code; if the primary card is + an ISA (non-PCI) device, and &s.code;FALSE&e.code; otherwise. + + </quote> + </quote> + +Two helper functions are provided to aid configuring entities: + <quote><p> + &s.code;ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, + &f.indent;int scrnFlag, int entityIndex, + &f.indent;PciChipsets *p_chip, + &f.indent;resList res, EntityProc init, + &f.indent;EntityProc enter, EntityProc leave, + &f.indent;pointer private)&e.code; + <p> + &s.code;ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn, + &f.indent;int scrnFlag, int entityIndex, + &f.indent;IsaChipsets *i_chip, + &f.indent;resList res, EntityProc init, + &f.indent;EntityProc enter, EntityProc leave, + &f.indent;pointer private)&e.code; + <quote><p> + These functions are used to register the non-relocatable resources + for an entity, and the optional entity-specific &s.code;Init&e.code;, &s.code;Enter&e.code; and + &s.code;Leave&e.code; functions. Usually the list of fixed resources is obtained + from the Isa/PciChipsets lists. However an additional list of + resources may be passed. Generally this is not required. + For active entities a &s.code;ScrnInfoRec&e.code; is allocated + if the &s.code;pScrn&e.code; argument is &s.code;NULL&e.code;. +The + return value is &s.code;TRUE&e.code; when successful. The init, enter, leave + functions are defined as follows: + + <quote> + &s.code;typedef void (*EntityProc)(int entityIndex, + &f.indent;pointer private)&e.code; + </quote> + + They are passed the entity index and a pointer to a private scratch + area. This can be set up during &s.code;Probe()&e.code; and + its address can be passed to + &s.code;xf86ConfigIsaEntity()&e.code; and + &s.code;xf86ConfigPciEntity()&e.code; as the last argument. + + </quote> + </quote> + +These two helper functions make use of several core functions that are +available at the driver level: + <quote><p> + &s.code;void xf86ClaimFixedResources(resList list, int entityIndex)&e.code; + <quote><p> + This function registers the non-relocatable resources which cannot + be disabled and which therefore would cause the server to fail + immediately if they were found to conflict. It also records + non-relocatable but sharable resources for processing after the + &s.code;Probe()&e.code; phase. + + </quote> + + &s.code;Bool xf86SetEntityFuncs(int entityIndex, EntityProc init, + &f.indent;EntityProc enter, EntityProc leave, pointer)&e.code; + <quote><p> + This function registers with an entity the &s.code;init&e.code;, + &s.code;enter&e.code;, &s.code;leave&e.code; functions along + with the pointer to their private area. + + </quote> + + &s.code;void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)&e.code; + <quote><p> + This function associates the entity referenced by + &s.code;entityIndex&e.code; with the screen. + + </quote> + </quote> + +<sect2>PreInit Phase +<p> + +During this phase the remaining resources should be registered. +&s.code;PreInit()&e.code; should call &s.code;xf86GetEntityInfo()&e.code; +to obtain a pointer to an &s.code;EntityInfoRec&e.code; for each entity +it is able to drive and check if any resource are listed in its +&s.code;resources&e.code; field. If resources registered in the Probe +phase have been rejected in the post-Probe phase +(&s.code;resources&e.code; is non-&s.code;NULL&e.code;), then the driver should +decide if it can continue without using these or if it should fail. + + <quote><p> + &s.code;EntityInfoPtr xf86GetEntityInfo(int entityIndex)&e.code; + <quote><p> + This function returns a pointer to the &s.code;EntityInfoRec&e.code; + referenced by &s.code;entityIndex&e.code;. The returned + &s.code;EntityInfoRec&e.code; should be freed with + &s.code;xfree()&e.code; when no longer needed. + + </quote> + </quote> +Several functions are provided to simplify resource registration: + <quote><p> + &s.code;Bool xf86IsEntityPrimary(int entityIndex)&e.code; + <quote><p> + This function returns &s.code;TRUE&e.code; if the entity referenced + by &s.code;entityIndex&e.code; is the primary display device (i.e., + the one initialised at boot time and used in text mode). + + </quote> + + &s.code;Bool xf86IsScreenPrimary(int scrnIndex)&e.code; + <quote><p> + This function returns &s.code;TRUE&e.code; if the primary entity + is registered with the screen referenced by + &s.code;scrnIndex&e.code;. + + </quote> + + &s.code;pciVideoPtr xf86GetPciInfoForEntity(int entityIndex)&e.code; + <quote><p> + This function returns a pointer to the &s.code;pciVideoRec&e.code; + for the specified entity. If the entity is not a PCI device, + &s.code;NULL&e.code; is returned. + + </quote> + </quote> + +The primary function for registration of resources is: + <quote><p> + &s.code;resPtr xf86RegisterResources(int entityIndex, resList list, + &f.indent;int access)&e.code; + <quote><p> + This function tries to register the resources in + &s.code;list&e.code;. If list is &s.code;NULL&e.code; it tries + to determine the resources automatically. This only works for + entities that provide a generic way to read out the resource ranges + they decode. So far this is only the case for PCI devices. By + default the PCI resources are registered as shared + (&s.code;ResShared&e.code;) if the driver wants to set a different + access type it can do so by specifying the access flags in the + third argument. A value of &s.code;0&e.code; means to use the + default settings. If for any reason the resource broker is not + able to register some of the requested resources the function will + return a pointer to a list of the failed ones. In this case the + driver may be able to move the resource to different locations. + In case of PCI bus entities this is done by passing the list of + failed resources to &s.code;xf86ReallocatePciResources()&e.code;. + When the registration succeeds, the return value is + &s.code;NULL&e.code;. + + </quote> + + &s.code;resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes)&e.code; + <quote><p> + This function takes a list of PCI resources that need to be + reallocated and returns &s.code;NULL&e.code when all relocations are + successful. + &s.code;xf86RegisterResources()&e.code; should be called again to + register the relocated resources with the broker. + If the reallocation fails, a list of the resources that could not be + relocated is returned. + + </quote> + </quote> + +Two functions are provided to obtain a resource range of a given type: + <quote><p> + &s.code;resRange xf86GetBlock(long type, memType size, + &f.indent;memType window_start, memType window_end, + &f.indent;memType align_mask, resPtr avoid)&e.code; + <quote><p> + This function tries to find a block range of size + &s.code;size&e.code; and type &s.code;type&e.code; in a window + bound by &s.code;window_start&e.code; and &s.code;window_end&e.code; + with the alignment specified in &s.code;align_mask&e.code;. + Optionally a list of resource ranges which should be avoided within + the window can be supplied. On failure a zero-length range of + type &s.code;ResEnd&e.code; will be returned. + + </quote> + &s.code;resRange xf86GetSparse(long type, memType fixed_bits, + &f.indent;memType decode_mask, memType address_mask, + &f.indent;resPtr avoid)&e.code; + <quote><p> + This function is like the previous one, but attempts to find a + sparse range instead of a block range. Here three values have to + be specified: the &s.code;address_mask&e.code; which marks all + bits of the mask part of the address, the &s.code;decode_mask&e.code; + which masks out the bits which are hardcoded and are therefore + not available for relocation and the values of the fixed bits. + The function tries to find a base that satisfies the given condition. + If the function fails it will return a zero range of type + &s.code;ResEnd&e.code;. Optionally it might be passed a list of + resource ranges to avoid. + + </quote> + </quote> + +Some PCI devices are broken in the sense that they return invalid size +information for a certain resource. In this case the driver can supply +the correct size and make sure that the resource range allocated for +the card is large enough to hold the address range decoded by the card. +The function &s.code;xf86FixPciResource()&e.code; can be used to do this: + <quote><p> + &s.code;Bool xf86FixPciResource(int entityIndex, unsigned int prt, + &f.indent;CARD32 alignment, long type)&e.code; + <quote><p> + This function fixes a PCI resource allocation. The + &s.code;prt&e.code; parameter contains the number of the PCI base + register that needs to be fixed (&s.code;0-5&e.code;, and + &s.code;6&e.code; for the BIOS base register). The size is + specified by the alignment. Since PCI resources need to span an + integral range of size &s.code;2^n&e.code;, the alignment also + specifies the number of addresses that will be decoded. If the + driver specifies a type mask it can override the default type for + PCI resources which is &s.code;ResShared&e.code;. The resource + broker needs to know that to find a matching resource range. This + function should be called before calling + &s.code;xf86RegisterResources()&e.code;. The return value is + &s.code;TRUE&e.code; when the function succeeds. + + </quote> + + &s.code;Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base)&e.code; + <quote><p> + This function checks that the memory base address specified matches + one of the PCI base address register values for the given PCI + device. This is mostly used to check that an externally provided + base address (e.g., from a config file) matches an actual value + allocated to a device. + + </quote> + </quote> + +The driver may replace the generic access control functions for an entity. +This is done with the &s.code;xf86SetAccessFuncs()&e.code;: + <quote><p> + &s.code;void xf86SetAccessFuncs(EntityInfoPtr pEnt, + &f.indent;xf86SetAccessFuncPtr funcs, + &f.indent;xf86SetAccessFuncPtr oldFuncs)&e.code; + <quote><p> + with: + </quote> + + <verb> + typedef struct { + xf86AccessPtr mem; + xf86AccessPtr io; + xf86AccessPtr io_mem; + } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr; + </verb> + + <quote><p> + The driver can pass three functions: one for I/O access, one for + memory access and one for combined memory and I/O access. If the + memory access and combined access functions are identical the + common level assumes that the memory access cannot be controlled + independently of I/O access, if the I/O access function and the + combined access functions are the same it is assumed that I/O can + not be controlled independently. If memory and I/O have to be + controlled together all three values should be the same. If a + non &s.code;NULL&e.code; value is passed as third argument it is + interpreted as an address where to store the old access record. + If the third argument is &s.code;NULL&e.code; it will be assumed + that the generic access should be enabled before replacing the + access functions. Otherwise it will be disabled. The driver may + enable them itself using the returned values. It should do this + from its replacement access functions as the generic access may + be disabled by the common level on certain occasions. If replacement + functions are specified they must control all resources of the + specific type registered for the entity. + + </quote> + </quote> + +To find out if a specific resource range conflicts with another +resource the &s.code;xf86ChkConflict()&e.code; function may be used: + <quote><p> + &s.code;memType xf86ChkConflict(resRange *rgp, int entityIndex)&e.code; + <quote><p> + This function checks if the resource range &s.code;rgp&e.code; of + for the specified entity conflicts with with another resource. + If a conflict is found, the address of the start of the conflict + is returned. The return value is zero when there is no conflict. + + </quote> + </quote> + +The OPERATING state properties of previously registered fixed resources +can be set with the &s.code;xf86SetOperatingState()&e.code; function: + <quote><p> + &s.code;resPtr xf86SetOperatingState(resList list, int entityIndex, + &f.indent;int mask)&e.code; + <quote><p> + This function is used to set the status of a resource during + OPERATING state. &s.code;list&e.code; holds a list to which + &s.code;mask&e.code; is to be applied. The parameter + &s.code;mask&e.code; may have the value &s.code;ResUnusedOpr&e.code; + and &s.code;ResDisableOpr&e.code;. The first one should be used + if a resource isn't used by the driver during OPERATING state + although it is decoded by the device, while the latter one indicates + that the resource is not decoded during OPERATING state. Note + that the resource ranges have to match those specified during + registration. If a range has been specified starting at + &s.code;A&e.code; and ending at &s.code;B&e.code; and suppose + &s.code;C&e.code; us a value satisfying + &s.code;A < C < B&e.code; one may not + specify the resource range &s.code;(A,B)&e.code; by splitting it + into two ranges &s.code;(A,C)&e.code; and &s.code;(C,B)&e.code;. + + </quote> + </quote> + +The following two functions are provided for special cases: + <quote><p> + &s.code;void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)&e.code; + <quote><p> + This function may be used to remove an entity from a screen. This + only makes sense if a screen has more than one entity assigned or + the screen is to be deleted. No test is made if the screen has + any entities left. + + </quote> + + &s.code;void xf86DeallocateResourcesForEntity(int entityIndex, long type)&e.code; + <quote><p> + This function deallocates all resources of a given type registered + for a certain entity from the resource broker list. + + </quote> + </quote> + +<sect2>ScreenInit Phase +<p> + +All that is required in this phase is to setup the RAC flags. Note that +it is also permissible to set these flags up in the PreInit phase. The +RAC flags are held in the &s.code;racIoFlags&e.code; and &s.code;racMemFlags&e.code; fields of the +&s.code;ScrnInfoRec&e.code; for each screen. They specify which graphics operations +might require the use of shared resources. This can be specified +separately for memory and I/O resources. The available flags are defined +in &s.code;rac/xf86RAC.h&e.code;. They are: + + &s.code;RAC_FB&e.code; + <quote> + for framebuffer operations (including hw acceleration) + </quote> + &s.code;RAC_CURSOR&e.code; + <quote> + for Cursor operations + (??? I'm not sure if we need this for SW cursor it depends + on which level the sw cursor is drawn) + </quote> + &s.code;RAC_COLORMAP&e.code; + <quote> + for colormap operations + </quote> + &s.code;RAC_VIEWPORT&e.code; + <quote> + for the call to &s.code;ChipAdjustFrame()&e.code; </quote> + + +The flags are ORed together. + +<sect>Config file ``Option'' entries<label id="options"> +<p> + +Option entries are permitted in most sections and subsections of the +config file. There are two forms of option entries: + +<descrip> +<tag>Option "option-name"</tag> + A boolean option. +<tag>Option "option-name" "option-value"</tag> + An option with an arbitrary value. +</descrip> + +The option entries are handled by the parser, and a list of the parsed +options is included with each of the appropriate data structures that +the drivers have access to. The data structures used to hold the option +information are opaque to the driver, and a driver must not access the +option data directly. Instead, the common layer provides a set of +functions that may be used to access, check and manipulate the option +data. + +First, the low level option handling functions. In most cases drivers +would not need to use these directly. + + <quote><p> + &s.code;pointer xf86FindOption(pointer options, const char *name)&e.code; + <quote><p> + Takes a list of options and an option name, and returns a handle + for the first option entry in the list matching the name. Returns + &s.code;NULL&e.code; if no match is found. + + </quote> + + &s.code;char *xf86FindOptionValue(pointer options, const char *name)&e.code; + <quote><p> + Takes a list of options and an option name, and returns the value + associated with the first option entry in the list matching the + name. If the matching option has no value, an empty string + (&s.code;""&e.code;) is returned. Returns &s.code;NULL&e.code; + if no match is found. + + </quote> + + &s.code;void xf86MarkOptionUsed(pointer option)&e.code; + <quote><p> + Takes a handle for an option, and marks that option as used. + + </quote> + + &s.code;void xf86MarkOptionUsedByName(pointer options, const char *name)&e.code; + <quote><p> + Takes a list of options and an option name and marks the first + option entry in the list matching the name as used. + + </quote> + </quote> + + +Next, the higher level functions that most drivers would use. + <quote><p> + &s.code;void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts)&e.code; + <quote><p> + Collect the options from each of the config file sections used by + the screen (&s.code;pScrn&e.code;) and return the merged list as + &s.code;pScrn->options&e.code;. This function requires that + &s.code;pScrn->confScreen&e.code;, &s.code;pScrn->display&e.code;, + &s.code;pScrn->monitor&e.code;, + &s.code;pScrn->numEntities&e.code;, and + &s.code;pScrn->entityList&e.code; are initialised. + &s.code;extraOpts&e.code; may optionally be set to an additional + list of options to be combined with the others. The order of + precedence for options is &s.code;extraOpts&e.code;, display, + confScreen, monitor, device. + + </quote> + + &s.code;void xf86ProcessOptions(int scrnIndex, pointer options, + &f.indent;OptionInfoPtr optinfo)&e.code; + <quote><p> + Processes a list of options according to the information in the + array of &s.code;OptionInfoRecs&e.code; (&s.code;optinfo&e.code;). + The resulting information is stored in the &s.code;value&e.code; + fields of the appropriate &s.code;optinfo&e.code; entries. The + &s.code;found&e.code; fields are set to &s.code;TRUE&e.code; + when an option with a value of the correct type if found, and + &s.code;FALSE&e.code; otherwise. The &s.code;type&e.code; field + is used to determine the expected value type for each option. + Each option in the list of options for which there is a name match + (but not necessarily a value type match) is marked as used. + Warning messages are printed when option values don't match the + types specified in the optinfo data. + + NOTE: If this function is called before a driver's screen number + is known (e.g., from the &s.code;ChipProbe()&e.code; function) a + &s.code;scrnIndex&e.code; value of &s.code;-1&e.code; should be + used. + + NOTE 2: Given that this function stores into the + &s.code;OptionInfoRecs&e.code; pointed to by &s.code;optinfo&e.code, + the caller should ensure the &s.code;OptionInfoRecs&e.code; are + (re-)initialised before the call, especially if the caller expects + to use the predefined option values as defaults. + + The &s.code;OptionInfoRec&e.code; is defined as follows: + + <verb> + typedef struct { + double freq; + int units; + } OptFrequency; + + typedef union { + unsigned long num; + char * str; + double realnum; + Bool bool; + OptFrequency freq; + } ValueUnion; + + typedef enum { + OPTV_NONE = 0, + OPTV_INTEGER, + OPTV_STRING, /* a non-empty string */ + OPTV_ANYSTR, /* Any string, including an empty one */ + OPTV_REAL, + OPTV_BOOLEAN, + OPTV_FREQ + } OptionValueType; + + typedef enum { + OPTUNITS_HZ = 1, + OPTUNITS_KHZ, + OPTUNITS_MHZ + } OptFreqUnits; + + typedef struct { + int token; + const char* name; + OptionValueType type; + ValueUnion value; + Bool found; + } OptionInfoRec, *OptionInfoPtr; + </verb> + + &s.code;OPTV_FREQ&e.code; can be used for options values that are + frequencies. These values are a floating point number with an + optional unit name appended. The unit name can be one of "Hz", + "kHz", "k", "MHz", "M". The multiplier associated with the unit + is stored in &s.code;freq.units&e.code;, and the scaled frequency + is stored in &s.code;freq.freq&e.code;. When no unit is specified, + &s.code;freq.units&e.code; is set to &s.code;0&e.code;, and + &s.code;freq.freq&e.code; is unscaled. + + Typical usage is to setup an array of + &s.code;OptionInfoRecs&e.code; with all fields initialised. + The &s.code;value&e.code; and &s.code;found&e.code; fields get + set by &s.code;xf86ProcessOptions()&e.code;. For cases where the + value parsing is more complex, the driver should specify + &s.code;OPTV_STRING&e.code;, and parse the string itself. An + example of using this option handling is included in the + <ref id="sample" name="Sample Driver"> section. + + </quote> + + &s.code;void xf86ShowUnusedOptions(int scrnIndex, pointer options)&e.code; + <quote><p> + Prints out warning messages for each option in the list of options + that isn't marked as used. This is intended to show options that + the driver hasn't recognised. It would normally be called near + the end of the &s.code;ChipScreenInit()&e.code; function, but only + when &s.code;serverGeneration == 1&e.code;. + + </quote> + + &s.code;OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table, + &f.indent;int token)&e.code; + + <quote><p> + Returns a pointer to the &s.code;OptionInfoRec&e.code; in + &s.code;table&e.code; with a token field matching + &s.code;token&e.code;. Returns &s.code;NULL&e.code; if no match + is found. + + </quote> + + &s.code;Bool xf86IsOptionSet(const OptionInfoRec *table, int token)&e.code; + <quote><p> + Returns the &s.code;found&e.code; field of the + &s.code;OptionInfoRec&e.code; in &s.code;table&e.code; with a + &s.code;token&e.code; field matching &s.code;token&e.code;. This + can be used for options of all types. Note that for options of + type &s.code;OPTV_BOOLEAN&e.code;, it isn't sufficient to check + this to determine the value of the option. Returns + &s.code;FALSE&e.code; if no match is found. + + </quote> + + &s.code;char *xf86GetOptValString(const OptionInfoRec *table, int token)&e.code; + <quote><p> + Returns the &s.code;value.str&e.code; field of the + &s.code;OptionInfoRec&e.code; in &s.code;table&e.code; with a + token field matching &s.code;token&e.code;. Returns + &s.code;NULL&e.code; if no match is found. + + </quote> + + &s.code;Bool xf86GetOptValInteger(const OptionInfoRec *table, int token, + &f.indent;int *value)&e.code; + <quote><p> + Returns via &s.code;*value&e.code; the &s.code;value.num&e.code; + field of the &s.code;OptionInfoRec&e.code; in &s.code;table&e.code; + with a &s.code;token&e.code; field matching &s.code;token&e.code;. + &s.code;*value&e.code; is only changed when a match is found so + it can be safely initialised with a default prior to calling this + function. The function return value is as for + &s.code;xf86IsOptionSet()&e.code;. + + </quote> + + &s.code;Bool xf86GetOptValULong(const OptionInfoRec *table, int token, + &f.indent;unsigned long *value)&e.code; + <quote><p> + Like &s.code;xf86GetOptValInteger()&e.code;, except the value is + treated as an &s.code;unsigned long&e.code;. + + </quote> + + &s.code;Bool xf86GetOptValReal(const OptionInfoRec *table, int token, + &f.indent;double *value)&e.code; + <quote><p> + Like &s.code;xf86GetOptValInteger()&e.code;, except that + &s.code;value.realnum&e.code; is used. + + </quote> + + &s.code;Bool xf86GetOptValFreq(const OptionInfoRec *table, int token, + &f.indent;OptFreqUnits expectedUnits, double *value)&e.code; + <quote><p> + Like &s.code;xf86GetOptValInteger()&e.code;, except that the + &s.code;value.freq&e.code; data is returned. The frequency value + is scaled to the units indicated by &s.code;expectedUnits&e.code;. + The scaling is exact when the units were specified explicitly in + the option's value. Otherwise, the &s.code;expectedUnits&e.code; + field is used as a hint when doing the scaling. In this case, + values larger than &s.code;1000&e.code; are assumed to have be + specified in the next smallest units. For example, if the Option + value is "10000" and expectedUnits is &s.code;OPTUNITS_MHZ&e.code;, + the value returned is &s.code;10&e.code;. + + </quote> + + &s.code;Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value)&e.code; + <quote><p> + This function is used to check boolean options + (&s.code;OPTV_BOOLEAN&e.code;). If the function return value is + &s.code;FALSE&e.code;, it means the option wasn't set. Otherwise + &s.code;*value&e.code; is set to the boolean value indicated by + the option's value. No option &s.code;value&e.code; is interpreted + as &s.code;TRUE&e.code;. Option values meaning &s.code;TRUE&e.code; + are "1", "yes", "on", "true", and option values meaning + &s.code;FALSE&e.code; are "0", "no", "off", "false". Option names + both with the "no" prefix in their names, and with that prefix + removed are also checked and handled in the obvious way. + &s.code;*value&e.code; is not changed when the option isn't present. + It should normally be set to a default value before calling this + function. + + </quote> + + &s.code;Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def)&e.code; + <quote><p> + This function is used to check boolean options + (&s.code;OPTV_BOOLEAN&e.code;). If the option is set, its value + is returned. If the options is not set, the default value specified + by &s.code;def&e.code; is returned. The option interpretation is + the same as for &s.code;xf86GetOptValBool()&e.code;. + + </quote> + + &s.code;int xf86NameCmp(const char *s1, const char *s2)&e.code; + <quote><p> + This function should be used when comparing strings from the config + file with expected values. It works like &s.code;strcmp()&e.code;, + but is not case sensitive and space, tab, and `<tt>_</tt>' characters + are ignored in the comparison. The use of this function isn't + restricted to parsing option values. It may be used anywhere + where this functionality required. + + </quote> + </quote> + +<sect>Modules, Drivers, Include Files and Interface Issues +<p> + +NOTE: this section is incomplete. + + +<sect1>Include files +<p> + +The following include files are typically required by video drivers: + + <quote><p> + All drivers should include these: + <quote> + &s.code;"xf86.h"&nl; + "xf86_OSproc.h"&nl; + "xf86_ansic.h"&nl; + "xf86Resources.h"&e.code; + </quote> + Wherever inb/outb (and related things) are used the following should be + included: + <quote> + &s.code;"compiler.h"&e.code; + </quote> + Note: in drivers, this must be included after &s.code;"xf86_ansic.h"&e.code;. + + Drivers that need to access PCI vendor/device definitions need this: + <quote> + &s.code;"xf86PciInfo.h"&e.code; + </quote> + + Drivers that need to access the PCI config space need this: + <quote> + &s.code;"xf86Pci.h"&e.code; + </quote> + + Drivers that initialise a SW cursor need this: + <quote> + &s.code;"mipointer.h"&e.code; + </quote> + + All drivers implementing backing store need this: + <quote> + &s.code;"mibstore.h"&e.code; + </quote> + + All drivers using the mi colourmap code need this: + <quote> + &s.code;"micmap.h"&e.code; + </quote> + + If a driver uses the vgahw module, it needs this: + <quote> + &s.code;"vgaHW.h"&e.code; + </quote> + + Drivers supporting VGA or Hercules monochrome screens need: + <quote> + &s.code;"xf1bpp.h"&e.code; + </quote> + + Drivers supporting VGA or EGC 16-colour screens need: + <quote> + &s.code;"xf4bpp.h"&e.code; + </quote> + + Drivers using cfb need: + <quote> + &s.code;#define PSZ 8&nl; + #include "cfb.h"&nl; + #undef PSZ&e.code; + </quote> + + Drivers supporting bpp 16, 24 or 32 with cfb need one or more of: + <quote> + &s.code;"cfb16.h"&nl; + "cfb24.h"&nl; + "cfb32.h"&e.code; + </quote> + + If a driver uses XAA, it needs these: + <quote> + &s.code;"xaa.h"&nl; + "xaalocal.h"&e.code; + </quote> + + If a driver uses the fb manager, it needs this: + <quote> + &s.code;"xf86fbman.h"&e.code; + </quote> + </quote> + +Non-driver modules should include &s.code;"xf86_ansic.h"&e.code; to get the correct +wrapping of ANSI C/libc functions. + +All modules must NOT include any system include files, or the following: + + <quote> + &s.code;"xf86Priv.h"&nl; + "xf86Privstr.h"&nl; + "xf86_OSlib.h"&nl; + "Xos.h"&e.code; + </quote> + +In addition, "xf86_libc.h" must not be included explicitly. It is +included implicitly by "xf86_ansic.h". + + +<sect>Offscreen Memory Manager +<p> + +Management of offscreen video memory may be handled by the XFree86 +framebuffer manager. Once the offscreen memory manager is running, +drivers or extensions may allocate, free or resize areas of offscreen +video memory using the following functions (definitions taken from +&s.code;xf86fbman.h&e.code;): + +<code> + typedef struct _FBArea { + ScreenPtr pScreen; + BoxRec box; + int granularity; + void (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*) + void (*RemoveAreaCallback)(struct _FBArea*) + DevUnion devPrivate; + } FBArea, *FBAreaPtr; + + typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr from, FBAreaPtr to) + typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr) + + FBAreaPtr xf86AllocateOffscreenArea ( + ScreenPtr pScreen, + int width, int height, + int granularity, + MoveAreaCallbackProcPtr MoveAreaCallback, + RemoveAreaCallbackProcPtr RemoveAreaCallback, + pointer privData + ) + + void xf86FreeOffscreenArea (FBAreaPtr area) + + Bool xf86ResizeOffscreenArea ( + FBAreaPtr area + int w, int h + ) +</code> + +The function: +<quote> + &s.code;Bool xf86FBManagerRunning(ScreenPtr pScreen)&e.code; +</quote> + +can be used by an extension to check if the driver has initialized +the memory manager. The manager is not available if this returns +&s.code;FALSE&e.code; and the functions above will all fail. + + +&s.code;xf86AllocateOffscreenArea()&e.code; can be used to request a +rectangle of dimensions &s.code;width&e.code; x &s.code;height&e.code; +(in pixels) from unused offscreen memory. &s.code;granularity&e.code; +specifies that the leftmost edge of the rectangle must lie on some +multiple of &s.code;granularity&e.code; pixels. A granularity of zero +means the same thing as a granularity of one - no alignment preference. +A &s.code;MoveAreaCallback&e.code; can be provided to notify the requester +when the offscreen area is moved. If no &s.code;MoveAreaCallback&e.code; +is supplied then the area is considered to be immovable. The +&s.code;privData&e.code; field will be stored in the manager's internal +structure for that allocated area and will be returned to the requester +in the &s.code;FBArea&e.code; passed via the +&s.code;MoveAreaCallback&e.code;. An optional +&s.code;RemoveAreaCallback&e.code; is provided. If the driver provides +this it indicates that the area should be allocated with a lower priority. +Such an area may be removed when a higher priority request (one that +doesn't have a &s.code;RemoveAreaCallback&e.code;) is made. When this +function is called, the driver will have an opportunity to do whatever +cleanup it needs to do to deal with the loss of the area, but it must +finish its cleanup before the function exits since the offscreen memory +manager will free the area immediately after. + +&s.code;xf86AllocateOffscreenArea()&e.code; returns &s.code;NULL&e.code; +if it was unable to allocate the requested area. When no longer needed, +areas should be freed with &s.code;xf86FreeOffscreenArea()&e.code;. + +&s.code;xf86ResizeOffscreenArea()&e.code; resizes an existing +&s.code;FBArea&e.code;. &s.code;xf86ResizeOffscreenArea()&e.code; +returns &s.code;TRUE&e.code; if the resize was successful. If +&s.code;xf86ResizeOffscreenArea()&e.code; returns &s.code;FALSE&e.code;, +the original &s.code;FBArea&e.code; is left unmodified. Resizing an +area maintains the area's original &s.code;granularity&e.code;, +&s.code;devPrivate&e.code;, and &s.code;MoveAreaCallback&e.code;. +&s.code;xf86ResizeOffscreenArea()&e.code; has considerably less overhead +than freeing the old area then reallocating the new size, so it should +be used whenever possible. + +The function: + <quote> + &s.code;Bool xf86QueryLargestOffscreenArea( + &f.indent;ScreenPtr pScreen, + &f.indent;int *width, int *height, + &f.indent;int granularity, + &f.indent;int preferences, + &f.indent;int priority + &nl)&e.code; + </quote> + +is provided to query the width and height of the largest single +&s.code;FBArea&e.code; allocatable given a particular priority. +&s.code;preferences&e.code; can be one of the following to indicate +whether width, height or area should be considered when determining +which is the largest single &s.code;FBArea&e.code; available. + + <quote> + &s.code;FAVOR_AREA_THEN_WIDTH&nl; + FAVOR_AREA_THEN_HEIGHT&nl; + FAVOR_WIDTH_THEN_AREA&nl; + FAVOR_HEIGHT_THEN_AREA&e.code; + </quote> + +&s.code;priority&e.code; is one of the following: + + <quote><p> + &s.code;PRIORITY_LOW&e.code; + <quote><p> + Return the largest block available without stealing anyone else's + space. This corresponds to the priority of allocating a + &s.code;FBArea&e.code; when a &s.code;RemoveAreaCallback&e.code; + is provided. + + </quote> + &s.code;PRIORITY_NORMAL&e.code; + <quote><p> + Return the largest block available if it is acceptable to steal a + lower priority area from someone. This corresponds to the priority + of allocating a &s.code;FBArea&e.code; without providing a + &s.code;RemoveAreaCallback&e.code;. + + </quote> + &s.code;PRIORITY_EXTREME&e.code; + <quote><p> + Return the largest block available if all &s.code;FBAreas&e.code; + that aren't locked down were expunged from memory first. This + corresponds to any allocation made directly after a call to + &s.code;xf86PurgeUnlockedOffscreenAreas()&e.code;. + + </quote> + </quote> + + +The function: + + <quote> + &s.code;Bool xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)&e.code; + </quote> + +is provided as an extreme method to free up offscreen memory. This +will remove all removable &s.code;FBArea&e.code; allocations. + + +Initialization of the XFree86 framebuffer manager is done via + + <quote> + &s.code;Bool xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox)&e.code; + </quote> + +&s.code;FullBox&e.code; represents the area of the framebuffer that the +manager is allowed to manage. This is typically a box with a width of +&s.code;pScrn->displayWidth&e.code; and a height of as many lines as +can be fit within the total video memory, however, the driver can reserve +areas at the extremities by passing a smaller area to the manager. + +&s.code;xf86InitFBManager()&e.code; must be called before XAA is +initialized since XAA uses the manager for it's pixmap cache. + +An alternative function is provided to allow the driver to initialize +the framebuffer manager with a Region rather than a box. + + <quote> + &s.code;Bool xf86InitFBManagerRegion(ScreenPtr pScreen, + &f.indent;RegionPtr FullRegion)&e.code; + </quote> + +&s.code;xf86InitFBManagerRegion()&e.code;, unlike +&s.code;xf86InitFBManager()&e.code;, does not remove the area used for +the visible screen so that area should not be included in the region +passed to the function. &s.code;xf86InitFBManagerRegion()&e.code; is +useful when non-contiguous areas are available to be managed, and is +required when multiple framebuffers are stored in video memory (as in +the case where an overlay of a different depth is stored as a second +framebuffer in offscreen memory). + + +<sect>Colormap Handling<label id="cmap"> +<p> + +A generic colormap handling layer is provided within the XFree86 common +layer. This layer takes care of most of the details, and only requires +a function from the driver that loads the hardware palette when required. +To use the colormap layer, a driver calls the +&s.code;xf86HandleColormaps()&e.code; function. + + <quote><p> + &s.code;Bool xf86HandleColormaps(ScreenPtr pScreen, int maxColors, + &f.indent;int sigRGBbits, LoadPaletteFuncPtr loadPalette, + &f.indent;SetOverscanFuncPtr setOverscan, + unsigned int flags)&e.code; + <quote><p> + This function must be called after the default colormap has been + initialised. The &s.code;pScrn->gamma&e.code; field must also + be initialised, preferably by calling &s.code;xf86SetGamma()&e.code;. + &s.code;maxColors&e.code; is the number of entries in the palette. + &s.code;sigRGBbits&e.code; is the size in bits of each color + component in the DAC's palette. &s.code;loadPalette&e.code; + is a driver-provided function for loading a colormap into the + hardware, and is described below. &s.code;setOverscan&e.code; is + an optional function that may be provided when the overscan color + is an index from the standard LUT and when it needs to be adjusted + to keep it as close to black as possible. The + &s.code;setOverscan&e.code; function programs the overscan index. + It shouldn't normally be used for depths other than 8. + &s.code;setOverscan&e.code; should be set to &s.code;NULL&e.code; + when it isn't needed. &s.code;flags&e.code; may be set to the + following (which may be ORed together): + + &s.code;CMAP_PALETTED_TRUECOLOR&e.code; + <quote><p> + the TrueColor visual is paletted and is + just a special case of DirectColor. + This flag is only valid for + &s.code;bpp > 8&e.code;. + + </quote> + + &s.code;CMAP_RELOAD_ON_MODE_SWITCH&e.code; + <quote><p> + reload the colormap automatically + after mode switches. This is useful + for when the driver is resetting the + hardware during mode switches and + corrupting or erasing the hardware + palette. + + </quote> + + &s.code;CMAP_LOAD_EVEN_IF_OFFSCREEN&e.code; + <quote><p> + reload the colormap even if the screen + is switched out of the server's VC. + The palette is <it>not</it> reloaded when + the screen is switched back in, nor after + mode switches. This is useful when the + driver needs to keep track of palette + changes. + + </quote> + + The colormap layer normally reloads the palette after VT enters so it + is not necessary for the driver to save and restore the palette + when switching VTs. The driver must, however, still save the + initial palette during server start up and restore it during + server exit. + + </quote> + + &s.code;void LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + &f.indent;LOCO *colors, VisualPtr pVisual)&e.code; + <quote><p> + &s.code;LoadPalette()&e.code; is a driver-provided function for + loading a colormap into hardware. &s.code;colors&e.code; is the + array of RGB values that represent the full colormap. + &s.code;indices&e.code; is a list of index values into the colors + array. These indices indicate the entries that need to be updated. + &s.code;numColors&e.code; is the number of the indices to be + updated. + + </quote> + + &s.code;void SetOverscan(ScrnInfoPtr pScrn, int overscan)&e.code; + <quote><p> + &s.code;SetOverscan()&e.code; is a driver-provided function for + programming the &s.code;overscan&e.code; index. As described + above, it is normally only appropriate for LUT modes where all + colormap entries are available for the display, but where one of + them is also used for the overscan (typically 8bpp for VGA compatible + LUTs). It isn't required in cases where the overscan area is + never visible. + + </quote> + </quote> + + +<sect>DPMS Extension +<p> + +Support code for the DPMS extension is included in the XFree86 common layer. +This code provides an interface between the main extension code, and a means +for drivers to initialise DPMS when they support it. One function is +available to drivers to do this initialisation, and it is always available, +even when the DPMS extension is not supported by the core server (in +which case it returns a failure result). + + + <quote><p> + &s.code;Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)&e.code; + <quote><p> + This function registers a driver's DPMS level programming function + &s.code;set&e.code;. It also checks + &s.code;pScrn->options&e.code; for the "dpms" option, and when + present marks DPMS as being enabled for that screen. The + &s.code;set&e.code; function is called whenever the DPMS level + changes, and is used to program the requested level. + &s.code;flags&e.code; is currently not used, and should be + &s.code;0&e.code;. If the initialisation fails for any reason, + including when there is no DPMS support in the core server, the + function returns &s.code;FALSE&e.code;. + + </quote> + </quote> + + +Drivers that implement DPMS support must provide the following function, +that gets called when the DPMS level is changed: + + + <quote><p> + &s.code;void ChipDPMSSet(ScrnInfoPtr pScrn, int level, int flags)&e.code; + <quote><p> + Program the DPMS level specified by &s.code;level&e.code;. Valid + values of &s.code;level&e.code; are &s.code;DPMSModeOn&e.code;, + &s.code;DPMSModeStandby&e.code;, &s.code;DPMSModeSuspend&e.code;, + &s.code;DPMSModeOff&e.code;. These values are defined in + &s.code;"extensions/dpms.h"&e.code;. + + </quote> + </quote> + + +<sect>DGA Extension +<p> + +Drivers can support the XFree86 Direct Graphics Architecture (DGA) by +filling out a structure of function pointers and a list of modes and +passing them to DGAInit. + + <quote><p> + &s.code;Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, + &f.indent;DGAModePtr modes, int num)&e.code; + <quote><p> + <verb> +/** The DGAModeRec **/ + +typedef struct { + int num; + DisplayModePtr mode; + int flags; + int imageWidth; + int imageHeight; + int pixmapWidth; + int pixmapHeight; + int bytesPerScanline; + int byteOrder; + int depth; + int bitsPerPixel; + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + int viewportWidth; + int viewportHeight; + int xViewportStep; + int yViewportStep; + int maxViewportX; + int maxViewportY; + int viewportFlags; + int offset; + unsigned char *address; + int reserved1; + int reserved2; +} DGAModeRec, *DGAModePtr; +</verb> + + &s.code;num&e.code; + <quote> + Can be ignored. The DGA DDX will assign these numbers. + </quote> + + &s.code;mode&e.code; + <quote> + A pointer to the &s.code;DisplayModeRec&e.code; for this mode. + </quote> + + &s.code;flags&e.code; + <quote><p> + The following flags are defined and may be OR'd together: + + &s.code;DGA_CONCURRENT_ACCESS&e.code; + <quote><p> + Indicates that the driver supports concurrent graphics + accelerator and linear framebuffer access. + + </quote> + + &s.code;DGA_FILL_RECT&nl; + DGA_BLIT_RECT&nl; + DGA_BLIT_RECT_TRANS&e.code; + <quote><p> + Indicates that the driver supports the FillRect, BlitRect + or BlitTransRect functions in this mode. + + </quote> + + &s.code;DGA_PIXMAP_AVAILABLE&e.code; + <quote><p> + Indicates that Xlib may be used on the framebuffer. + This flag will usually be set unless the driver wishes + to prohibit this for some reason. + + </quote> + + &s.code;DGA_INTERLACED&nl; + DGA_DOUBLESCAN&e.code; + <quote><p> + Indicates that these are interlaced or double scan modes. + + </quote> + </quote> + + &s.code;imageWidth&nl; + imageHeight&e.code; + <quote><p> + These are the dimensions of the linear framebuffer + accessible by the client. + + </quote> + + &s.code;pixmapWidth&nl; + pixmapHeight&e.code; + <quote><p> + These are the dimensions of the area of the + framebuffer accessible by the graphics accelerator. + + </quote> + + &s.code;bytesPerScanline&e.code; + <quote><p> + Pitch of the framebuffer in bytes. + + </quote> + + &s.code;byteOrder&e.code; + <quote><p> + Usually the same as + &s.code;pScrn->imageByteOrder&e.code;. + + </quote> + + &s.code;depth&e.code; + <quote><p> + The depth of the framebuffer in this mode. + + </quote> + + &s.code;bitsPerPixel&e.code; + <quote><p> + The number of bits per pixel in this mode. + + </quote> + + &s.code;red_mask&nl; + green_mask&nl; + blue_mask&e.code; + <quote><p> + The RGB masks for this mode, if applicable. + + </quote> + + &s.code;viewportWidth&nl; + viewportHeight&e.code; + <quote><p> + Dimensions of the visible part of the framebuffer. + Usually &s.code;mode->HDisplay&e.code; and + &s.code;mode->VDisplay&e.code;. + + </quote> + + &s.code;xViewportStep&nl; + yViewportStep&e.code; + <quote><p> + The granularity of x and y viewport positions that + the driver supports in this mode. + + </quote> + + &s.code;maxViewportX&nl; + maxViewportY&e.code; + <quote><p> + The maximum viewport position supported by the + driver in this mode. + + </quote> + + &s.code;viewportFlags&e.code; + <quote><p> + The following may be OR'd together: + + &s.code;DGA_FLIP_IMMEDIATE&e.code; + <quote><p> + The driver supports immediate viewport changes. + + </quote> + &s.code;DGA_FLIP_RETRACE&e.code; + <quote<p> + The driver supports viewport changes at retrace. + + </quote> + </quote> + + &s.code;offset&e.code; + <quote><p> + The offset into the linear framebuffer that corresponds to + pixel (0,0) for this mode. + + </quote> + + &s.code;address&e.code; + <quote><p> + The virtual address of the framebuffer as mapped by the driver. + This is needed when DGA_PIXMAP_AVAILABLE is set. + + </quote> + + <verb> +/** The DGAFunctionRec **/ + +typedef struct { + Bool (*OpenFramebuffer)( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *extra + ); + void (*CloseFramebuffer)(ScrnInfoPtr pScrn); + Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode); + void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags); + int (*GetViewport)(ScrnInfoPtr pScrn); + void (*Sync)(ScrnInfoPtr); + void (*FillRect)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color + ); + void (*BlitRect)( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty + ); + void (*BlitTransRect)( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color + ); +} DGAFunctionRec, *DGAFunctionPtr; +</verb> + + </quote> + + &s.code;Bool OpenFramebuffer (pScrn, name, mem, size, offset, extra)&e.code; + <quote><p> + &s.code;OpenFramebuffer()&e.code; should pass the client everything + it needs to know to be able to open the framebuffer. These + parameters are OS specific and their meanings are to be interpreted + by an OS specific client library. + + &s.code;name&e.code; + <quote><p> + The name of the device to open or &s.code;NULL&e.code; if + there is no special device to open. A &s.code;NULL&e.code; + name tells the client that it should open whatever device + one would usually open to access physical memory. + + </quote> + &s.code;mem&e.code; + <quote><p> + The physical address of the start of the framebuffer. + + </quote> + &s.code;size&e.code; + <quote><p> + The size of the framebuffer in bytes. + + </quote> + &s.code;offset&e.code; + <quote><p> + Any offset into the device, if applicable. + + </quote> + &s.code;flags&e.code; + <quote><p> + Any additional information that the client may need. + Currently, only the &s.code;DGA_NEED_ROOT&e.code; flag is + defined. + + </quote> + </quote> + + &s.code;void CloseFramebuffer (pScrn)&e.code; + <quote><p> + &s.code;CloseFramebuffer()&e.code; merely informs the driver (if it + even cares) that client no longer needs to access the framebuffer + directly. This function is optional. + + </quote> + + &s.code;Bool SetMode (pScrn, pMode)&e.code; + <quote><p> + &s.code;SetMode()&e.code; tells the driver to initialize the mode + passed to it. If &s.code;pMode&e.code; is &s.code;NULL&e.code;, + then the driver should restore the original pre-DGA mode. + + </quote> + + &s.code;void SetViewport (pScrn, x, y, flags)&e.code; + <quote><p> + &s.code;SetViewport()&e.code; tells the driver to make the upper + left-hand corner of the visible screen correspond to coordinate + &s.code;(x,y)&e.code; on the framebuffer. &s.code;Flags&e.code; + currently defined are: + + &s.code;DGA_FLIP_IMMEDIATE&e.code; + <quote><p> + The viewport change should occur immediately. + + </quote> + &s.code;DGA_FLIP_RETRACE&e.code; + <quote><p> + The viewport change should occur at the + vertical retrace, but this function should + return sooner if possible. + + </quote> + The &s.code;(x,y)&e.code; locations will be passed as the client + specified them, however, the driver is expected to round these + locations down to the next supported location as specified by the + &s.code;xViewportStep&e.code; and &s.code;yViewportStep&e.code; + for the current mode. + + </quote> + + &s.code;int GetViewport (pScrn)&e.code; + <quote><p> + &s.code;GetViewport()&e.code; gets the current page flip status. + Set bits in the returned int correspond to viewport change requests + still pending. For instance, set bit zero if the last SetViewport + request is still pending, bit one if the one before that is still + pending, etc. + + </quote> + + &s.code;void Sync (pScrn)&e.code; + <quote><p> + This function should ensure that any graphics accelerator operations + have finished. This function should not return until the graphics + accelerator is idle. + + </quote> + + &s.code;void FillRect (pScrn, x, y, w, h, color)&e.code; + <quote><p> + This optional function should fill a rectangle + &s.code;w × h&e.code; located at + &s.code;(x,y)&e.code; in the given color. + + </quote> + + &s.code;void BlitRect (pScrn, srcx, srcy, w, h, dstx, dsty)&e.code; + <quote><p> + This optional function should copy an area + &s.code;w × h&e.code; located at + &s.code;(srcx,srcy)&e.code; to location &s.code;(dstx,dsty)&e.code;. + This function will need to handle copy directions as appropriate. + + </quote> + + &s.code;void BlitTransRect (pScrn, srcx, srcy, w, h, dstx, dsty, color)&e.code; + <quote><p> + This optional function is the same as BlitRect except that pixels + in the source corresponding to the color key &s.code;color&e.code; + should be skipped. + + </quote> + </quote> + +<sect>The XFree86 X Video Extension (Xv) Device Dependent Layer +<p> + +XFree86 offers the X Video Extension which allows clients to treat video +as any another primitive and ``Put'' video into drawables. By default, +the extension reports no video adaptors as being available since the +DDX layer has not been initialized. The driver can initialize the DDX +layer by filling out one or more &s.code;XF86VideoAdaptorRecs&e.code; +as described later in this document and passing a list of +&s.code;XF86VideoAdaptorPtr&e.code; pointers to the following function: + + <quote> + &s.code;Bool xf86XVScreenInit( + &f.indent;ScreenPtr pScreen, + &f.indent;XF86VideoAdaptorPtr *adaptPtrs, + &f.indent;int num)&e.code; + </quote> + +After doing this, the extension will report video adaptors as being +available, providing the data in their respective +&s.code;XF86VideoAdaptorRecs&e.code; was valid. +&s.code;xf86XVScreenInit()&e.code; <em>copies</em> data from the structure +passed to it so the driver may free it after the initialization. At +the moment, the DDX only supports rendering into Window drawables. +Pixmap rendering will be supported after a sufficient survey of suitable +hardware is completed. + +The &s.code;XF86VideoAdaptorRec&e.code;: + +<quote><p> +<verb> +typedef struct { + unsigned int type; + int flags; + char *name; + int nEncodings; + XF86VideoEncodingPtr pEncodings; + int nFormats; + XF86VideoFormatPtr pFormats; + int nPorts; + DevUnion *pPortPrivates; + int nAttributes; + XF86AttributePtr pAttributes; + int nImages; + XF86ImagePtr pImages; + PutVideoFuncPtr PutVideo; + PutStillFuncPtr PutStill; + GetVideoFuncPtr GetVideo; + GetStillFuncPtr GetStill; + StopVideoFuncPtr StopVideo; + SetPortAttributeFuncPtr SetPortAttribute; + GetPortAttributeFuncPtr GetPortAttribute; + QueryBestSizeFuncPtr QueryBestSize; + PutImageFuncPtr PutImage; + QueryImageAttributesFuncPtr QueryImageAttributes; +} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr; +</verb> + + Each adaptor will have its own XF86VideoAdaptorRec. The fields are + as follows: + + &s.code;type&e.code; + <quote><p> + This can be any of the following flags OR'd together. + + &s.code;XvInputMask&e.code; + &s.code;XvOutputMask&e.code; + <quote><p> + These refer to the target drawable and are similar to a Window's + class. &s.code;XvInputMask&e.code; indicates that the adaptor + can put video into a drawable. &s.code;XvOutputMask&e.code; + indicates that the adaptor can get video from a drawable. + </quote> + + &s.code;XvVideoMask&e.code; + &s.code;XvStillMask&e.code; + &s.code;XvImageMask&e.code; + <quote><p> + These indicate that the adaptor supports video, still or + image primitives respectively. + </quote> + + &s.code;XvWindowMask&e.code; + &s.code;XvPixmapMask&e.code; + <quote><p> + These indicate the types of drawables the adaptor is capable + of rendering into. At the moment, Pixmap rendering is not + supported and the &s.code;XvPixmapMask&e.code; flag is ignored. + </quote> + + </quote> + + &s.code;flags&e.code; + <quote><p> + Currently, the following flags are defined: + + &s.code;VIDEO_NO_CLIPPING&e.code; + <quote><p> + This indicates that the video adaptor does not support + clipping. The driver will never receive ``Put'' requests + where less than the entire area determined by + &s.code;drw_x&e.code;, &s.code;drw_y&e.code;, + &s.code;drw_w&e.code; and &s.code;drw_h&e.code; is visible. + This flag does not apply to ``Get'' requests. Hardware + that is incapable of clipping ``Gets'' may punt or get + the extents of the clipping region passed to it. + + </quote> + + &s.code;VIDEO_INVERT_CLIPLIST&e.code; + <quote><p> + This indicates that the video driver requires the clip + list to contain the regions which are obscured rather + than the regions which are are visible. + + </quote> + + &s.code;VIDEO_OVERLAID_STILLS&e.code; + <quote><p> + Implementing PutStill for hardware that does video as an + overlay can be awkward since it's unclear how long to leave + the video up for. When this flag is set, StopVideo will be + called whenever the destination gets clipped or moved so that + the still can be left up until then. + + </quote> + + &s.code;VIDEO_OVERLAID_IMAGES&e.code; + <quote><p> + Same as &s.code;VIDEO_OVERLAID_STILLS&e.code; but for images. + </quote> + + &s.code;VIDEO_CLIP_TO_VIEWPORT&e.code; + <quote><p> + Indicates that the clip region passed to the driver functions + should be clipped to the visible portion of the screen in the + case where the viewport is smaller than the virtual desktop. + </quote> + + </quote> + + &s.code;name&e.code; + <quote><p> + The name of the adaptor. + + </quote> + + &s.code;nEncodings&nl; + pEncodings&e.code; + <quote><p> + The number of encodings the adaptor is capable of and pointer + to the &s.code;XF86VideoEncodingRec&e.code; array. The + &s.code;XF86VideoEncodingRec&e.code; is described later on. + For drivers that only support XvImages there should be an encoding + named "XV_IMAGE" and the width and height should specify + the maximum size source image supported. + + </quote> + + &s.code;nFormats&nl; + pFormats&e.code; + <quote><p> + The number of formats the adaptor is capable of and pointer to + the &s.code;XF86VideoFormatRec&e.code; array. The + &s.code;XF86VideoFormatRec&e.code; is described later on. + + </quote> + + &s.code;nPorts&nl; + pPortPrivates&e.code; + <quote><p> + The number of ports is the number of separate data streams which + the adaptor can handle simultaneously. If you have more than + one port, the adaptor is expected to be able to render into more + than one window at a time. &s.code;pPortPrivates&e.code; is + an array of pointers or ints - one for each port. A port's + private data will be passed to the driver any time the port is + requested to do something like put the video or stop the video. + In the case where there may be many ports, this enables the + driver to know which port the request is intended for. Most + commonly, this will contain a pointer to the data structure + containing information about the port. In Xv, all ports on + a particular adaptor are expected to be identical in their + functionality. + + </quote> + + &s.code;nAttributes&nl; + pAttributes&e.code; + <quote><p> + The number of attributes recognized by the adaptor and a pointer to + the array of &s.code;XF86AttributeRecs&e.code;. The + &s.code;XF86AttributeRec&e.code; is described later on. + + </quote> + + &s.code;nImages&nl; + pImages&e.code; + <quote><p> + The number of &s.code;XF86ImageRecs&e.code; supported by the adaptor + and a pointer to the array of &s.code;XF86ImageRecs&e.code;. The + &s.code;XF86ImageRec&e.code; is described later on. + + </quote> + + + &s.code;PutVideo PutStill GetVideo GetStill StopVideo + SetPortAttribute GetPortAttribute QueryBestSize PutImage + QueryImageAttributes&e.code; + <quote><p> + These functions define the DDX->driver interface. In each + case, the pointer &s.code;data&e.code; is passed to the driver. + This is the port private for that port as described above. All + fields are required except under the following conditions: + + <enum> + <item>&s.code;PutVideo&e.code;, &s.code;PutStill&e.code; and + the image routines &s.code;PutImage&e.code; and + &s.code;QueryImageAttributes&e.code; are not required when the + adaptor type does not contain &s.code;XvInputMask&e.code;. + + <item>&s.code;GetVideo&e.code; and &s.code;GetStill&e.code; + are not required when the adaptor type does not contain + &s.code;XvOutputMask&e.code;. + + <item>&s.code;GetVideo&e.code; and &s.code;PutVideo&e.code; + are not required when the adaptor type does not contain + &s.code;XvVideoMask&e.code;. + + <item>&s.code;GetStill&e.code; and &s.code;PutStill&e.code; + are not required when the adaptor type does not contain + &s.code;XvStillMask&e.code;. + + <item>&s.code;PutImage&e.code; and &s.code;QueryImageAttributes&e.code; + are not required when the adaptor type does not contain + &s.code;XvImageMask&e.code;. + + </enum> + + With the exception of &s.code;QueryImageAttributes&e.code;, these + functions should return &s.code;Success&e.code; if the operation was + completed successfully. They can return &s.code;XvBadAlloc&e.code; + otherwise. &s.code;QueryImageAttributes&e.code; returns the size + of the XvImage queried. + + If the &s.code;VIDEO_NO_CLIPPING&e.code; + flag is set, the &s.code;clipBoxes&e.code; may be ignored by + the driver. &s.code;ClipBoxes&e.code; is an &s.code;X-Y&e.code; + banded region identical to those used throughout the server. + The clipBoxes represent the visible portions of the area determined + by &s.code;drw_x&e.code;, &s.code;drw_y&e.code;, + &s.code;drw_w&e.code; and &s.code;drw_h&e.code; in the Get/Put + function. The boxes are in screen coordinates, are guaranteed + not to overlap and an empty region will never be passed. + If the driver has specified &s.code;VIDEO_INVERT_CLIPLIST&e.code;, + &s.code;clipBoxes&e.code; will indicate the areas of the primitive + which are obscured rather than the areas visible. + + </quote> + + &s.code;typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn, + &f.indent;short vid_x, short vid_y, short drw_x, short drw_y, + &f.indent;short vid_w, short vid_h, short drw_w, short drw_h, + &f.indent;RegionPtr clipBoxes, pointer data )&e.code; + <quote><p> + This indicates that the driver should take a subsection + &s.code;vid_w&e.code; by &s.code;vid_h&e.code; at location + &s.code;(vid_x,vid_y)&e.code; from the video stream and direct + it into the rectangle &s.code;drw_w&e.code; by &s.code;drw_h&e.code; + at location &s.code;(drw_x,drw_y)&e.code; on the screen, scaling as + necessary. Due to the large variations in capabilities of + the various hardware expected to be used with this extension, + it is not expected that all hardware will be able to do this + exactly as described. In that case the driver should just do + ``the best it can,'' scaling as closely to the target rectangle + as it can without rendering outside of it. In the worst case, + the driver can opt to just not turn on the video. + + </quote> + + &s.code;typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn, + &f.indent;short vid_x, short vid_y, short drw_x, short drw_y, + &f.indent;short vid_w, short vid_h, short drw_w, short drw_h, + &f.indent;RegionPtr clipBoxes, pointer data )&e.code; + <quote><p> + This is same as &s.code;PutVideo&e.code; except that the driver + should place only one frame from the stream on the screen. + + </quote> + + &s.code;typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn, + &f.indent;short vid_x, short vid_y, short drw_x, short drw_y, + &f.indent;short vid_w, short vid_h, short drw_w, short drw_h, + &f.indent;RegionPtr clipBoxes, pointer data )&e.code; + <quote><p> + This is same as &s.code;PutVideo&e.code; except that the driver + gets video from the screen and outputs it. The driver should + do the best it can to get the requested dimensions correct + without reading from an area larger than requested. + + </quote> + + &s.code;typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn, + &f.indent;short vid_x, short vid_y, short drw_x, short drw_y, + &f.indent;short vid_w, short vid_h, short drw_w, short drw_h, + &f.indent;RegionPtr clipBoxes, pointer data )&e.code; + <quote><p> + This is the same as &s.code;GetVideo&e.code; except that the + driver should place only one frame from the screen into the + output stream. + + </quote> + + &s.code;typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, + &f.indent;pointer data, Bool cleanup)&e.code; + <quote><p> + This indicates the driver should stop displaying the video. + This is used to stop both input and output video. The + &s.code;cleanup&e.code; field indicates that the video is + being stopped because the client requested it to stop or + because the server is exiting the current VT. In that case + the driver should deallocate any offscreen memory areas (if + there are any) being used to put the video to the screen. If + &s.code;cleanup&e.code; is not set, the video is being stopped + temporarily due to clipping or moving of the window, etc... + and video will likely be restarted soon so the driver should + not deallocate any offscreen areas associated with that port. + + </quote> + &s.code;typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, + &f.indent;Atom attribute,INT32 value, pointer data)&e.code; + + &s.code;typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, + &f.indent;Atom attribute,INT32 *value, pointer data)&e.code; + + <quote><p> + A port may have particular attributes such as hue, + saturation, brightness or contrast. Xv clients set and + get these attribute values by sending attribute strings + (Atoms) to the server. Such requests end up at these + driver functions. It is recommended that the driver provide + at least the following attributes mentioned in the Xv client + library docs: + <quote> + &s.code;XV_ENCODING&nl; + XV_HUE&nl; + XV_SATURATION&nl; + XV_BRIGHTNESS&nl; + XV_CONTRAST&e.code; + </quote> + but the driver may recognize as many atoms as it wishes. If + a requested attribute is unknown by the driver it should return + &s.code;BadMatch&e.code;. &s.code;XV_ENCODING&e.code; is the + attribute intended to let the client specify which video + encoding the particular port should be using (see the description + of &s.code;XF86VideoEncodingRec&e.code; below). If the + requested encoding is unsupported, the driver should return + &s.code;XvBadEncoding&e.code;. If the value lies outside the + advertised range &s.code;BadValue&e.code; may be returned. + &s.code;Success&e.code; should be returned otherwise. + + </quote> + + &s.code;typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, + &f.indent;Bool motion, short vid_w, short vid_h, + &f.indent;short drw_w, short drw_h, + &f.indent;unsigned int *p_w, unsigned int *p_h, pointer data)&e.code; + <quote><p> + &s.code;QueryBestSize&e.code; provides the client with a way + to query what the destination dimensions would end up being + if they were to request that an area + &s.code;vid_w&e.code by &s.code;vid_h&e.code; from the video + stream be scaled to rectangle of + &s.code;drw_w&e.code; by &s.code;drw_h&e.code; on the screen. + Since it is not expected that all hardware will be able to + get the target dimensions exactly, it is important that the + driver provide this function. + + </quote> + + &s.code;typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn, + &f.indent;short src_x, short src_y, short drw_x, short drw_y, + &f.indent;short src_w, short src_h, short drw_w, short drw_h, + &f.indent;int image, char *buf, short width, short height, + &f.indent;Bool sync, RegionPtr clipBoxes, pointer data )&e.code; + <quote><p> + This is similar to &s.code;PutStill&e.code; except that the + source of the video is not a port but the data stored in a system + memory buffer at &s.code;buf&e.code;. The data is in the format + indicated by the &s.code;image&e.code; descriptor and represents a + source of size &s.code;width&e.code; by &s.code;height&e.code;. + If &s.code;sync&e.code; is TRUE the driver should not return + from this function until it is through reading the data + from &s.code;buf&e.code;. Returning when &s.code;sync&e.code; + is TRUE indicates that it is safe for the data at &s.code;buf&e.code; + to be replaced, freed, or modified. + + </quote> + + &s.code;typedef int (* QueryImageAttributesFuncPtr)( ScrnInfoPtr pScrn, + &f.indent;int image, short *width, short *height, + &f.indent;int *pitches, int *offsets)&e.code; + <quote><p> + This function is called to let the driver specify how data for + a particular &s.code;image&e.code; of size &s.code;width&e.code; + by &s.code;height&e.code; should be stored. Sometimes only + the size and corrected width and height are needed. In that + case &s.code;pitches&e.code; and &s.code;offsets&e.code; are + NULL. The size of the memory required for the image is returned + by this function. The &s.code;width&e.code; and + &s.code;height&e.code; of the requested image can be altered by + the driver to reflect format limitations (such as component + sampling periods that are larger than one). If + &s.code;pitches&e.code; and &s.code;offsets&e.code; are not NULL, + these will be arrays with as many elements in them as there + are planes in the &s.code;image&e.code; format. The driver + should specify the pitch (in bytes) of each scanline in the + particular plane as well as the offset to that plane (in bytes) + from the beginning of the image. + + </quote> + + </quote> + +The XF86VideoEncodingRec: +<quote><p> +<verb> +typedef struct { + int id; + char *name; + unsigned short width, height; + XvRationalRec rate; +} XF86VideoEncodingRec, *XF86VideoEncodingPtr; + +</verb> + The &s.code;XF86VideoEncodingRec&e.code; specifies what encodings + the adaptor can support. Most of this data is just informational + and for the client's benefit, and is what will be reported by + &s.code;XvQueryEncodings&e.code;. The &s.code;id&e.code; field is + expected to be a unique identifier to allow the client to request a + certain encoding via the &s.code;XV_ENCODING&e.code; attribute string. + +</quote> + +The XF86VideoFormatRec: + +<quote><p> +<verb> +typedef struct { + char depth; + short class; +} XF86VideoFormatRec, *XF86VideoFormatPtr; +</verb> + + This specifies what visuals the video is viewable in. + &s.code;depth&e.code; is the depth of the visual (not bpp). + &s.code;class&e.code; is the visual class such as + &s.code;TrueColor&e.code;, &s.code;DirectColor&e.code; or + &s.code;PseudoColor&e.code;. Initialization of an adaptor will fail + if none of the visuals on that screen are supported. + +</quote> + +The XF86AttributeRec: + +<quote><p> +<verb> +typedef struct { + int flags; + int min_value; + int max_value; + char *name; +} XF86AttributeListRec, *XF86AttributeListPtr; + +</verb> + + Each adaptor may have an array of these advertising the attributes + for its ports. Currently defined flags are &s.code;XvGettable&e.code; + and &s.code;XvSettable&e.code; which may be OR'd together indicating that + attribute is ``gettable'' or ``settable'' by the client. The + &s.code;min&e.code; and &s.code;max&e.code; field specify the valid range + for the value. &s.code;Name&e.code; is a text string describing the + attribute by name. + +</quote> + +The XF86ImageRec: + +<quote><p> +<verb> +typedef struct { + int id; + int type; + int byte_order; + char guid[16]; + int bits_per_pixel; + int format; + int num_planes; + + /* for RGB formats */ + int depth; + unsigned int red_mask; + unsigned int green_mask; + unsigned int blue_mask; + + /* for YUV formats */ + unsigned int y_sample_bits; + unsigned int u_sample_bits; + unsigned int v_sample_bits; + unsigned int horz_y_period; + unsigned int horz_u_period; + unsigned int horz_v_period; + unsigned int vert_y_period; + unsigned int vert_u_period; + unsigned int vert_v_period; + char component_order[32]; + int scanline_order; +} XF86ImageRec, *XF86ImagePtr; +</verb> + + XF86ImageRec describes how video source data is laid out in memory. + The fields are as follows: + + &s.code;id&e.code; + <quote><p> + This is a unique descriptor for the format. It is often good to + set this value to the FOURCC for the format when applicable. + </quote> + + &s.code;type&e.code; + <quote><p> + This is &s.code;XvRGB&e.code; or &s.code;XvYUV&e.code;. + </quote> + + &s.code;byte_order&e.code; + <quote><p> + This is &s.code;LSBFirst&e.code; or &s.code;MSBFirst&e.code;. + </quote> + + &s.code;guid&e.code; + <quote><p> + This is the Globally Unique IDentifier for the format. When + not applicable, all characters should be NULL. + </quote> + + &s.code;bits_per_pixel&e.code; + <quote><p> + The number of bits taken up (but not necessarily used) by each + pixel. Note that for some planar formats which have fractional + bits per pixel (such as IF09) this number may be rounded _down_. + </quote> + + &s.code;format&e.code; + <quote><p> + This is &s.code;XvPlanar&e.code; or &s.code;XvPacked&e.code;. + </quote> + + &s.code;num_planes&e.code; + <quote><p> + The number of planes in planar formats. This should be set to + one for packed formats. + </quote> + + &s.code;depth&e.code; + <quote><p> + The significant bits per pixel in RGB formats (analgous to the + depth of a pixmap format). + </quote> + + &s.code;red_mask&e.code; + &s.code;green_mask&e.code; + &s.code;blue_mask&e.code; + <quote><p> + The red, green and blue bitmasks for packed RGB formats. + </quote> + + &s.code;y_sample_bits&e.code; + &s.code;u_sample_bits&e.code; + &s.code;v_sample_bits&e.code; + <quote><p> + The y, u and v sample sizes (in bits). + </quote> + + &s.code;horz_y_period&e.code; + &s.code;horz_u_period&e.code; + &s.code;horz_v_period&e.code; + <quote><p> + The y, u and v sampling periods in the horizontal direction. + </quote> + + &s.code;vert_y_period&e.code; + &s.code;vert_u_period&e.code; + &s.code;vert_v_period&e.code; + <quote><p> + The y, u and v sampling periods in the vertical direction. + </quote> + + &s.code;component_order&e.code; + <quote><p> + Uppercase ascii characters representing the order that + samples are stored within packed formats. For planar formats + this represents the ordering of the planes. Unused characters + in the 32 byte string should be set to NULL. + </quote> + + &s.code;scanline_order&e.code; + <quote><p> + This is &s.code;XvTopToBottom&e.code; or &s.code;XvBottomToTop&e.code;. + </quote> + + Since some formats (particular some planar YUV formats) may not +be completely defined by the parameters above, the guid, when +available, should provide the most accurate description of the +format. + +</quote> + +<sect>The Loader +<p> + +This section describes the interfaces to the module loader. The loader +interfaces can be divided into two groups: those that are only available to +the XFree86 common layer, and those that are also available to modules. + +<sect1>Loader Overview +<p> + +The loader is capable of loading modules in a range of object formats, +and knowledge of these formats is built in to the loader. Knowledge of +new object formats can be added to the loader in a straightforward +manner. This makes it possible to provide OS-independent modules (for +a given CPU architecture type). In addition to this, the loader can +load modules via the OS-provided &s.code;dlopen(3)&e.code; service where +available. Such modules are not platform independent, and the semantics +of &s.code;dlopen()&e.code; on most systems results in significant +limitations in the use of modules of this type. Support for +&s.code;dlopen()&e.code; modules in the loader is primarily for +experimental and development purposes. + +Symbols exported by the loader (on behalf of the core X server) to +modules are determined at compile time. Only those symbols explicitly +exported are available to modules. All external symbols of loaded +modules are exported to other modules, and to the core X server. The +loader can be requested to check for unresolved symbols at any time, +and the action to be taken for unresolved symbols can be controlled by +the caller of the loader. Typically the caller identifies which symbols +can safely remain unresolved and which cannot. + +NOTE: Now that ISO-C allows pointers to functions and pointers to data to +have different internal representations, some of the following interfaces +will need to be revisited. + +<sect1>Semi-private Loader Interface +<p> + +The following is the semi-private loader interface that is available to the +XFree86 common layer. + + <quote><p> + &s.code;void LoaderInit(void)&e.code; + <quote><p> + The &s.code;LoaderInit()&e.code; function initialises the loader, + and it must be called once before calling any other loader functions. + This function initialises the tables of exported symbols, and anything + else that might need to be initialised. + + </quote> + + &s.code;void LoaderSetPath(const char *path)&e.code; + <quote><p> + The &s.code;LoaderSetPath()&e.code; function initialises a default + module search path. This must be called if calls to other functions + are to be made without explicitly specifying a module search path. + The search path &s.code;path&e.code; must be a string of one or more + comma separated absolute paths. Modules are expected to be located + below these paths, possibly in subdirectories of these paths. + + </quote> + + &s.code;pointer LoadModule(const char *module, const char *path, + &f.indent;const char **subdirlist, const char **patternlist, + &f.indent;pointer options, const XF86ModReqInfo * modreq, + &f.indent;int *errmaj, int *errmin)&e.code; + <quote><p> + The &s.code;LoadModule()&e.code; function loads the module called + &s.code;module&e.code;. The return value is a module handle, and + may be used in future calls to the loader that require a reference + to a loaded module. The module name &s.code;module&e.code; is + normally the module's canonical name, which doesn't contain any + directory path information, or any object/library file prefixes of + suffixes. Currently a full pathname and/or filename is also accepted. + This might change. The other parameters are: + + &s.code;path&e.code; + <quote><p> + An optional comma-separated list of module search paths. + When &s.code;NULL&e.code;, the default search path is used. + + </quote> + + &s.code;subdirlist&e.code; + <quote><p> + An optional &s.code;NULL&e.code; terminated list of + subdirectories to search. When &s.code;NULL&e.code;, + the default built-in list is used (refer to + &s.code;stdSubdirs&e.code; in &s.code;loadmod.c&e.code;). + The default list is also substituted for entries in + &s.code;subdirlist&e.code; with the value + &s.code;DEFAULT_LIST&e.code;. This makes is possible + to augment the default list instead of replacing it. + Subdir elements must be relative, and must not contain + &s.code;".."&e.code;. If any violate this requirement, + the load fails. + + </quote> + + &s.code;patternlist&e.code; + <quote><p> + An optional &s.code;NULL&e.code; terminated list of + POSIX regular expressions used to connect module + filenames with canonical module names. Each regex + should contain exactly one subexpression that corresponds + to the canonical module name. When &s.code;NULL&e.code;, + the default built-in list is used (refer to + &s.code;stdPatterns&e.code; in + &s.code;loadmod.c&e.code;). The default list is also + substituted for entries in &s.code;patternlist&e.code; + with the value &s.code;DEFAULT_LIST&e.code;. This + makes it possible to augment the default list instead + of replacing it. + + </quote> + + &s.code;options&e.code; + <quote><p> + An optional parameter that is passed to the newly + loaded module's &s.code;SetupProc&e.code; function + (if it has one). This argument is normally a + &s.code;NULL&e.code; terminated list of + &s.code;Options&e.code;, and must be interpreted that + way by modules loaded directly by the XFree86 common + layer. However, it may be used for application-specific + parameter passing in other situations. + + When loading ``external'' modules (modules that don't + have the standard entry point, for example a + special shared library) the options parameter can be + set to &s.code;EXTERN_MODULE&e.code; to tell the + loader not to reject the module when it doesn't find + the standard entry point. + + </quote> + + &s.code;modreq&e.code; + <quote><p> + An optional &s.code;XF86ModReqInfo*&e.code; containing + version/ABI/vendor information to requirements to + check the newly loaded module against. The main + purpose of this is to allow the loader to verify that + a module of the correct type/version before running + its &s.code;SetupProc&e.code; function. + + The &s.code;XF86ModReqInfo&e.code; struct is defined + as follows: +<verb> +typedef struct { + CARD8 majorversion; /* MAJOR_UNSPEC */ + CARD8 minorversion; /* MINOR_UNSPEC */ + CARD16 patchlevel; /* PATCH_UNSPEC */ + const char * abiclass; /* ABI_CLASS_NONE */ + CARD32 abiversion; /* ABI_VERS_UNSPEC */ + const char * moduleclass; /* MOD_CLASS_NONE */ +} XF86ModReqInfo; +</verb> + + The information here is compared against the equivalent + information in the module's + &s.code;XF86ModuleVersionInfo&e.code; record (which + is described below). The values in comments above + indicate ``don't care'' settings for each of the fields. + The comparisons made are as follows: + + &s.code;majorversion&e.code; + <quote><p> + Must match the module's majorversion + exactly. + + </quote> + &s.code;minorversion&e.code; + <quote><p> + The module's minor version must be + no less than this value. This + comparison is only made if + &s.code;majorversion&e.code; is + specified and matches. + + </quote> + &s.code;patchlevel&e.code; + <quote><p> + The module's patchlevel must be no + less than this value. This comparison + is only made if + &s.code;minorversion&e.code; is + specified and matches. + + </quote> + &s.code;abiclass&e.code; + <quote><p> + String must match the module's abiclass + string. + + </quote> + &s.code;abiversion&e.code; + <quote><p> + Must be consistent with the module's + abiversion (major equal, minor no + older). + + </quote> + &s.code;moduleclass&e.code; + <quote><p> + String must match the module's + moduleclass string. + + </quote> + + </quote> + + &s.code;errmaj&e.code; + <quote><p> + An optional pointer to a variable holding the major + part or the error code. When provided, + &s.code;*errmaj&e.code; is filled in when + &s.code;LoadModule()&e.code; fails. + + </quote> + + &s.code;errmin&e.code; + <quote><p> + Like &s.code;errmaj&e.code;, but for the minor part + of the error code. + + </quote> + + </quote> + + &s.code;void UnloadModule(pointer mod)&e.code; + <quote><p> + This function unloads the module referred to by the handle mod. + All child modules are also unloaded recursively. This function must + not be used to directly unload modules that are child modules (i.e., + those that have been loaded with the &s.code;LoadSubModule()&e.code; + described below). + + </quote> + </quote> + +<sect1>Module Requirements +<p> + +Modules must provide information about themselves to the loader, and +may optionally provide entry points for "setup" and "teardown" functions +(those two functions are referred to here as &s.code;SetupProc&e.code; +and &s.code;TearDownProc&e.code;). + +The module information is contained in the +&s.code;XF86ModuleVersionInfo&e.code; struct, which is defined as follows: + +<quote><p><verb> +typedef struct { + const char * modname; /* name of module, e.g. "foo" */ + const char * vendor; /* vendor specific string */ + CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */ + CARD32 _modinfo2_; /* infoarea with a binary editor/sign tool */ + CARD32 xf86version; /* contains XF86_VERSION_CURRENT */ + CARD8 majorversion; /* module-specific major version */ + CARD8 minorversion; /* module-specific minor version */ + CARD16 patchlevel; /* module-specific patch level */ + const char * abiclass; /* ABI class that the module uses */ + CARD32 abiversion; /* ABI version */ + const char * moduleclass; /* module class */ + CARD32 checksum[4]; /* contains a digital signature of the */ + /* version info structure */ +} XF86ModuleVersionInfo; +</verb> + +The fields are used as follows: + + &s.code;modname&e.code; + <quote><p> + The module's name. This field is currently only for + informational purposes, but the loader may be modified + in future to require it to match the module's canonical + name. + + </quote> + + &s.code;vendor&e.code; + <quote><p> + The module vendor. This field is for informational purposes + only. + + </quote> + + &s.code;_modinfo1_&e.code; + <quote><p> + This field holds the first part of a signature that can + be used to locate this structure in the binary. It should + always be initialised to &s.code;MODINFOSTRING1&e.code;. + + </quote> + + &s.code;_modinfo2_&e.code; + <quote><p> + This field holds the second part of a signature that can + be used to locate this structure in the binary. It should + always be initialised to &s.code;MODINFOSTRING2&e.code;. + + </quote> + + &s.code;xf86version&e.code; + <quote><p> + The XFree86 version against which the module was compiled. + This is mostly for informational/diagnostic purposes. It + should be initialised to &s.code;XF86_VERSION_CURRENT&e.code;, which is + defined in &s.code;xf86Version.h&e.code;. + + </quote> + + &s.code;majorversion&e.code; + <quote><p> + The module-specific major version. For modules where this + version is used for more than simply informational + purposes, the major version should only change (be + incremented) when ABI incompatibilities are introduced, + or ABI components are removed. + + </quote> + + &s.code;minorversion&e.code; + <quote><p> + The module-specific minor version. For modules where this + version is used for more than simply informational + purposes, the minor version should only change (be + incremented) when ABI additions are made in a backward + compatible way. It should be reset to zero when the major + version is increased. + + </quote> + + &s.code;patchlevel&e.code; + <quote><p> + The module-specific patch level. The patch level should + increase with new revisions of the module where there + are no ABI changes, and it should be reset to zero when + the minor version is increased. + + </quote> + + &s.code;abiclass&e.code; + <quote><p> + The ABI class that the module requires. The class is + specified as a string for easy extensibility. It should + indicate which (if any) of the X server's built-in ABI + classes that the module relies on, or a third-party ABI + if appropriate. Built-in ABI classes currently defined are: + + <quote> + &s.code;ABI_CLASS_NONE&e.code; + <quote>no class</quote> + &s.code;ABI_CLASS_ANSIC&e.code; + <quote>only requires the ANSI C interfaces</quote> + &s.code;ABI_CLASS_VIDEODRV&e.code; + <quote>requires the video driver ABI</quote> + &s.code;ABI_CLASS_XINPUT&e.code; + <quote>requires the XInput driver ABI</quote> + &s.code;ABI_CLASS_EXTENSION&e.code; + <quote>requires the extension module ABI</quote> + &s.code;ABI_CLASS_FONT&e.code; + <quote>requires the font module ABI</quote> + </quote> + + </quote> + + &s.code;abiversion&e.code; + <quote><p> + The version of abiclass that the module requires. The + version consists of major and minor components. The + major version must match and the minor version must be + no newer than that provided by the server or parent + module. Version identifiers for the built-in classes + currently defined are: + + <quote> + &s.code;ABI_ANSIC_VERSION&nl; + ABI_VIDEODRV_VERSION&nl; + ABI_XINPUT_VERSION&nl; + ABI_EXTENSION_VERSION&nl; + ABI_FONT_VERSION&e.code; + </quote> + + </quote> + + &s.code;moduleclass&e.code; + <quote><p> + This is similar to the abiclass field, except that it + defines the type of module rather than the ABI it + requires. For example, although all video drivers require + the video driver ABI, not all modules that require the + video driver ABI are video drivers. This distinction + can be made with the moduleclass. Currently pre-defined + module classes are: + + <quote> + &s.code;MOD_CLASS_NONE&nl; + MOD_CLASS_VIDEODRV&nl; + MOD_CLASS_XINPUT&nl; + MOD_CLASS_FONT&nl; + MOD_CLASS_EXTENSION&e.code; + </quote> + + </quote> + + &s.code;checksum&e.code; + <quote><p> + Not currently used. + + </quote> + +</quote> + +The module version information, and the optional &s.code;SetupProc&e.code; +and &s.code;TearDownProc&e.code; entry points are found by the loader +by locating a data object in the module called "modnameModuleData", +where "modname" is the canonical name of the module. Modules must +contain such a data object, and it must be declared with global scope, +be compile-time initialised, and is of the following type: + +<quote> +<verb> +typedef struct { + XF86ModuleVersionInfo * vers; + ModuleSetupProc setup; + ModuleTearDownProc teardown; +} XF86ModuleData; +</verb> +</quote> + +The vers parameter must be initialised to a pointer to a correctly +initialised &s.code;XF86ModuleVersionInfo&e.code; struct. The other +two parameter are optional, and should be initialised to +&s.code;NULL&e.code; when not required. The other parameters are defined +as + + <quote><p> + &s.code;typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *)&e.code; + + &s.code;typedef void (*ModuleTearDownProc)(pointer)&e.code; + + + &s.code;pointer SetupProc(pointer module, pointer options, + &f.indent;int *errmaj, int *errmin)&e.code; + <quote><p> + When defined, this function is called by the loader after successfully + loading a module. module is a handle for the newly loaded module, + and maybe used by the &s.code;SetupProc&e.code; if it calls other + loader functions that require a reference to it. The remaining + arguments are those that were passed to the + &s.code;LoadModule()&e.code; (or &s.code;LoadSubModule()&e.code;), + and are described above. When the &s.code;SetupProc&e.code; is + successful it must return a non-&s.code;NULL&e.code; value. The + loader checks this, and if it is &s.code;NULL&e.code; it unloads + the module and reports the failure to the caller of + &s.code;LoadModule()&e.code;. If the &s.code;SetupProc&e.code; + does things that need to be undone when the module is unloaded, + it should define a &s.code;TearDownProc&e.code;, and return a + pointer that the &s.code;TearDownProc&e.code; can use to undo what + has been done. + + When a module is loaded multiple times, the &s.code;SetupProc&e.code; + is called once for each time it is loaded. + + </quote> + + &s.code;void TearDownProc(pointer tearDownData)&e.code; + <quote><p> + When defined, this function is called when the loader unloads a + module. The &s.code;tearDownData&e.code; parameter is the return + value of the &s.code;SetupProc()&e.code; that was called when the + module was loaded. The purpose of this function is to clean up + before the module is unloaded (for example, by freeing allocated + resources). + + </quote> + </quote> + +<sect1>Public Loader Interface +<p> + +The following is the Loader interface that is available to any part of +the server, and may also be used from within modules. + + <quote><p> + &s.code;pointer LoadSubModule(pointer parent, const char *module, + &f.indent;const char **subdirlist, const char **patternlist, + &f.indent;pointer options, const XF86ModReqInfo * modreq, + &f.indent;int *errmaj, int *errmin)&e.code; + <quote><p> + This function is like the &s.code;LoadModule()&e.code; function + described above, except that the module loaded is registered as a + child of the calling module. The &s.code;parent&e.code; parameter + is the calling module's handle. Modules loaded with this function + are automatically unloaded when the parent module is unloaded. The + other difference is that the path parameter may not be specified. + The module search path used for modules loaded with this function + is the default search path as initialised with + &s.code;LoaderSetPath()&e.code;. + + </quote> + + &s.code;void UnloadSubModule(pointer module)&e.code; + <quote><p> + This function unloads the module with handle &s.code;module&e.code;. + If that module itself has children, they are also unloaded. It is + like &s.code;UnloadModule()&e.code;, except that it is safe to use + for unloading child modules. + + </quote> + + &s.code;pointer LoaderSymbol(const char *symbol)&e.code; + <quote><p> + This function returns the address of the symbol with name + &s.code;symbol&e.code;. This may be used to locate a module entry + point with a known name. + + </quote> + + &s.code;char **LoaderlistDirs(const char **subdirlist, + &f.indent;const char **patternlist)&e.code; + <quote><p> + This function returns a &s.code;NULL&e.code; terminated list of + canonical modules names for modules found in the default module + search path. The &s.code;subdirlist&e.code; and + &s.code;patternlist&e.code; parameters are as described above, and + can be used to control the locations and names that are searched. + If no modules are found, the return value is &s.code;NULL&e.code;. + The returned list should be freed by calling + &s.code;LoaderFreeDirList()&e.code; when it is no longer needed. + + </quote> + + &s.code;void LoaderFreeDirList(char **list)&e.code; + <quote><p> + This function frees a module list created by + &s.code;LoaderlistDirs()&e.code;. + + </quote> + + &s.code;void LoaderReqSymLists(const char **list0, ...)&e.code; + <quote><p> + This function allows the registration of required symbols with the + loader. It is normally used by a caller of + &s.code;LoadSubModule()&e.code;. If any symbols registered in this + way are found to be unresolved when + &s.code;LoaderCheckUnresolved()&e.code; is called then + &s.code;LoaderCheckUnresolved()&e.code; will report a failure. + The function takes one or more &s.code;NULL&e.code; terminated + lists of symbols. The end of the argument list is indicated by a + &s.code;NULL&e.code; argument. + + </quote> + + &s.code;void LoaderReqSymbols(const char *sym0, ...)&e.code; + <quote><p> + This function is like &s.code;LoaderReqSymLists()&e.code; except + that its arguments are symbols rather than lists of symbols. This + function is more convenient when single functions are to be registered, + especially when the single function might depend on runtime factors. + The end of the argument list is indicated by a &s.code;NULL&e.code; + argument. + + </quote> + + &s.code;void LoaderRefSymLists(const char **list0, ...)&e.code; + <quote><p> + This function allows the registration of possibly unresolved symbols + with the loader. When &s.code;LoaderCheckUnresolved()&e.code; is + run it won't generate warnings for symbols registered in this way + unless they were also registered as required symbols. + The function takes one or more &s.code;NULL&e.code; terminated + lists of symbols. The end of the argument list is indicated by a + &s.code;NULL&e.code; argument. + + </quote> + + &s.code;void LoaderRefSymbols(const char *sym0, ...)&e.code; + <quote><p> + This function is like &s.code;LoaderRefSymLists()&e.code; except + that its arguments are symbols rather than lists of symbols. This + function is more convenient when single functions are to be registered, + especially when the single function might depend on runtime factors. + The end of the argument list is indicated by a &s.code;NULL&e.code; + argument. + + </quote> + + &s.code;int LoaderCheckUnresolved(int delayflag)&e.code; + <quote><p> + This function checks for unresolved symbols. It generates warnings + for unresolved symbols that have not been registered with + &s.code;LoaderRefSymLists()&e.code;, and maps them to a dummy + function. This behaviour may change in future. If unresolved + symbols are found that have been registered with + &s.code;LoaderReqSymLists()&e.code; or + &s.code;LoaderReqSymbols()&e.code; then this function returns a + non-zero value. If none of these symbols are unresolved the return + value is zero, indicating success. + + The &s.code;delayflag&e.code; parameter should normally be set to + &s.code;LD_RESOLV_IFDONE&e.code;. + + </quote> + + &s.code;LoaderErrorMsg(const char *name, const char *modname, + &f.indent;int errmaj, int errmin)&e.code; + <quote><p> + This function prints an error message that includes the text ``Failed + to load module'', the module name &s.code;modname&e.code;, a message + specific to the &s.code;errmaj&e.code; value, and the value if + &s.code;errmin&e.code;. If &s.code;name&e.code; is + non-&s.code;NULL&e.code;, it is printed as an identifying prefix + to the message (followed by a `:'). + + </quote> + </quote> + +<sect1>Special Registration Functions +<p> + +The loader contains some functions for registering some classes of modules. +These may be moved out of the loader at some point. + + <quote><p> + &s.code;void LoadExtension(ExtensionModule *ext)&e.code; + <quote><p> + This registers the entry points for the extension identified by + &s.code;ext&e.code;. The &s.code;ExtensionModule&e.code; struct is + defined as: + +<quote> +<verb> +typedef struct { + InitExtension initFunc; + char * name; + Bool *disablePtr; + InitExtension setupFunc; +} ExtensionModule; +</verb> +</quote> + + </quote> + + &s.code;void LoadFont(FontModule *font)&e.code; + <quote><p> + This registers the entry points for the font rasteriser module + identified by &s.code;font&e.code;. The &s.code;FontModule&e.code; + struct is defined as: + +<quote> +<verb> +typedef struct { + InitFont initFunc; + char * name; + pointer module; +} FontModule; +</verb> +</quote> + + </quote> + </quote> + +</sect> + + +<sect>Helper Functions +<p> + +This section describe ``helper'' functions that video driver +might find useful. While video drivers are not required to use any of +these to be considered ``compliant'', the use of appropriate helpers is +strongly encouraged to improve the consistency of driver behaviour. + +<sect1>Functions for printing messages +<p> + + <quote><p> + &s.code;ErrorF(const char *format, ...)&e.code; + <quote><p> + This is the basic function for writing to the error log (typically + stderr and/or a log file). Video drivers should usually avoid + using this directly in favour of the more specialised functions + described below. This function is useful for printing messages + while debugging a driver. + + </quote> + + &s.code;FatalError(const char *format, ...)&e.code; + <quote><p> + This prints a message and causes the Xserver to abort. It should + rarely be used within a video driver, as most error conditions + should be flagged by the return values of the driver functions. + This allows the higher layers to decide how to proceed. In rare + cases, this can be used within a driver if a fatal unexpected + condition is found. + + </quote> + + &s.code;xf86ErrorF(const char *format, ...)&e.code; + <quote><p> + This is like &s.code;ErrorF()&e.code;, except that the message is + only printed when the Xserver's verbosity level is set to the + default (&s.code;1&e.code;) or higher. It means that the messages + are not printed when the server is started with the + &s.cmd;-quiet&e.cmd; flag. Typically this function would only be + used for continuing messages started with one of the more specialised + functions described below. + + </quote> + + &s.code;xf86ErrorFVerb(int verb, const char *format, ...)&e.code; + <quote><p> + Like &s.code;xf86ErrorF()&e.code;, except the minimum verbosity + level for which the message is to be printed is given explicitly. + Passing a &s.code;verb&e.code; value of zero means the message + is always printed. A value higher than &s.code;1&e.code; can be + used for information would normally not be needed, but which might + be useful when diagnosing problems. + + </quote> + + &s.code;xf86Msg(MessageType type, const char *format, ...)&e.code; + <quote><p> + This is like &s.code;xf86ErrorF()&e.code;, except that the message + is prefixed with a marker determined by the value of + &s.code;type&e.code;. The marker is used to indicate the type of + message (warning, error, probed value, config value, etc). Note + the &s.code;xf86Verbose&e.code; value is ignored for messages of + type &s.code;X_ERROR&e.code;. + + The marker values are: + + <quote> + &s.code;X_PROBED&e.code; + <quote>Value was probed.</quote> + &s.code;X_CONFIG&e.code; + <quote>Value was given in the config file.</quote> + &s.code;X_DEFAULT&e.code; + <quote>Value is a default.</quote> + &s.code;X_CMDLINE&e.code; + <quote>Value was given on the command line.</quote> + &s.code;X_NOTICE&e.code; + <quote>Notice.</quote> + &s.code;X_ERROR&e.code; + <quote>Error message.</quote> + &s.code;X_WARNING&e.code; + <quote>Warning message.</quote> + &s.code;X_INFO&e.code; + <quote>Informational message.</quote> + &s.code;X_NONE&e.code; + <quote>No prefix.</quote> + &s.code;X_NOT_IMPLEMENTED&e.code; + <quote>The message relates to functionality that is not yet + implemented.</quote> + </quote> + + + </quote> + + &s.code;xf86MsgVerb(MessageType type, int verb, const char *format, ...)&e.code; + <quote><p> + Like &s.code;xf86Msg()&e.code;, but with the verbosity level given + explicitly. + + </quote> + + &s.code;xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)&e.code; + <quote><p> + This is like &s.code;xf86Msg()&e.code; except that the driver's + name (the &s.code;name&e.code; field of the + &s.code;ScrnInfoRec&e.code;) followed by the + &s.code;scrnIndex&e.code; in parentheses is printed following the + prefix. This should be used by video drivers in most cases as it + clearly indicates which driver/screen the message is for. If + &s.code;scrnIndex&e.code; is negative, this function behaves + exactly like &s.code;xf86Msg()&e.code;. + + NOTE: This function can only be used after the + &s.code;ScrnInfoRec&e.code; and its &s.code;name&e.code; field + have been allocated. Normally, this means that it can not be + used before the END of the &s.code;ChipProbe()&e.code; function. + Prior to that, use &s.code;xf86Msg()&e.code;, providing the + driver's name explicitly. No screen number can be supplied at + that point. + + </quote> + + &s.code;xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, + &f.indent;const char *format, ...)&e.code; + <quote><p> + Like &s.code;xf86DrvMsg()&e.code;, but with the verbosity level + given explicitly. + + </quote> + </quote> + + +<sect1>Functions for setting values based on command line and config file +<p> + + <quote><p> + &s.code;Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, + &f.indent;int fbbpp, int depth24flags)&e.code; + <quote><p> + This function sets the &s.code;depth&e.code;, &s.code;pixmapBPP&e.code; and &s.code;bitsPerPixel&e.code; fields + of the &s.code;ScrnInfoRec&e.code;. It also determines the defaults for display-wide + attributes and pixmap formats the screen will support, and finds + the Display subsection that matches the depth/bpp. This function + should normally be called very early from the + &s.code;ChipPreInit()&e.code; function. + + It requires that the &s.code;confScreen&e.code; field of the &s.code;ScrnInfoRec&e.code; be + initialised prior to calling it. This is done by the XFree86 + common layer prior to calling &s.code;ChipPreInit()&e.code;. + + The parameters passed are: + + &s.code;depth&e.code; + <quote><p> + driver's preferred default depth if no other is given. + If zero, use the overall server default. + + </quote> + &s.code;bpp&e.code; + <quote><p> + Same, but for the pixmap bpp. + + </quote> + &s.code;fbbpp&e.code; + <quote><p> + Same, but for the framebuffer bpp. + + </quote> + &s.code;depth24flags&e.code; + <quote><p> + Flags that indicate the level of 24/32bpp support + and whether conversion between different framebuffer + and pixmap formats is supported. The flags for this + argument are defined as follows, and multiple flags + may be ORed together: + + &s.code;NoDepth24Support&e.code; + <quote>No depth 24 formats supported</quote> + &s.code;Support24bppFb&e.code; + <quote>24bpp framebuffer supported</quote> + &s.code;Support32bppFb&e.code; + <quote>32bpp framebuffer supported</quote> + &s.code;SupportConvert24to32&e.code; + <quote>Can convert 24bpp pixmap to 32bpp fb</quote> + &s.code;SupportConvert32to24&e.code; + <quote>Can convert 32bpp pixmap to 24bpp fb</quote> + &s.code;ForceConvert24to32&e.code; + <quote>Force 24bpp pixmap to 32bpp fb conversion</quote> + &s.code;ForceConvert32to24&e.code; + <quote>Force 32bpp pixmap to 24bpp fb conversion</quote> + + </quote> + + It uses the command line, config file, and default values in the + correct order of precedence to determine the depth and bpp values. + It is up to the driver to check the results to see that it supports + them. If not the &s.code;ChipPreInit()&e.code; function should + return &s.code;FALSE&e.code;. + + If only one of depth/bpp is given, the other is set to a reasonable + (and consistent) default. + + If a driver finds that the initial &s.code;depth24flags&e.code; + it uses later results in a fb format that requires more video + memory than is available it may call this function a second time + with a different &s.code;depth24flags&e.code; setting. + + On success, the return value is &s.code;TRUE&e.code;. On failure + it prints an error message and returns &s.code;FALSE&e.code;. + + The following fields of the &s.code;ScrnInfoRec&e.code; are + initialised by this function: + + <quote> + &s.code;depth&e.code;, &s.code;bitsPerPixel&e.code;, + &s.code;display&e.code;, &s.code;imageByteOrder&e.code;, + &s.code;bitmapScanlinePad&e.code;, + &s.code;bitmapScanlineUnit&e.code;, &s.code;bitmapBitOrder&e.code;, + &s.code;numFormats&e.code;, &s.code;formats&e.code;, + &s.code;fbFormat&e.code;. + </quote> + + </quote> + + &s.code;void xf86PrintDepthBpp(scrnInfoPtr scrp)&e.code; + <quote><p> + This function can be used to print out the depth and bpp settings. + It should be called after the final call to + &s.code;xf86SetDepthBpp()&e.code;. + + </quote> + + &s.code;Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask)&e.code; + <quote><p> + This function sets the &s.code;weight&e.code;, &s.code;mask&e.code;, + &s.code;offset&e.code; and &s.code;rgbBits&e.code; fields of the + &s.code;ScrnInfoRec&e.code;. It would normally be called fairly + early in the &s.code;ChipPreInit()&e.code; function for + depths > 8bpp. + + It requires that the &s.code;depth&e.code; and + &s.code;display&e.code; fields of the &s.code;ScrnInfoRec&e.code; + be initialised prior to calling it. + + The parameters passed are: + + &s.code;weight&e.code; + <quote><p> + driver's preferred default weight if no other is given. + If zero, use the overall server default. + + </quote> + + &s.code;mask&e.code; + <quote><p> + Same, but for mask. + + </quote> + + It uses the command line, config file, and default values in the + correct order of precedence to determine the weight value. It + derives the mask and offset values from the weight and the defaults. + It is up to the driver to check the results to see that it supports + them. If not the &s.code;ChipPreInit()&e.code; function should + return &s.code;FALSE&e.code;. + + On success, this function prints a message showing the weight + values selected, and returns &s.code;TRUE&e.code;. + + On failure it prints an error message and returns &s.code;FALSE&e.code;. + + The following fields of the &s.code;ScrnInfoRec&e.code; are + initialised by this function: + + <quote> + &s.code;weight&e.code;, &s.code;mask&e.code;, &s.code;offset&e.code;. + </quote> + + </quote> + + &s.code;Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual)&e.code; + <quote><p> + This function sets the &s.code;defaultVisual&e.code; field of the + &s.code;ScrnInfoRec&e.code;. It would normally be called fairly + early from the &s.code;ChipPreInit()&e.code; function. + + It requires that the &s.code;depth&e.code; and + &s.code;display&e.code; fields of the &s.code;ScrnInfoRec&e.code; + be initialised prior to calling it. + + The parameters passed are: + + &s.code;visual&e.code; + <quote><p> + driver's preferred default visual if no other is given. + If &s.code;-1&e.code;, use the overall server default. + + </quote> + + It uses the command line, config file, and default values in the + correct order of precedence to determine the default visual value. + It is up to the driver to check the result to see that it supports + it. If not the &s.code;ChipPreInit()&e.code; function should + return &s.code;FALSE&e.code;. + + On success, this function prints a message showing the default visual + selected, and returns &s.code;TRUE&e.code;. + + On failure it prints an error message and returns &s.code;FALSE&e.code;. + + </quote> + + &s.code;Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)&e.code; + <quote><p> + This function sets the &s.code;gamma&e.code; field of the + &s.code;ScrnInfoRec&e.code;. It would normally be called fairly + early from the &s.code;ChipPreInit()&e.code; function in cases + where the driver supports gamma correction. + + It requires that the &s.code;monitor&e.code; field of the + &s.code;ScrnInfoRec&e.code; be initialised prior to calling it. + + The parameters passed are: + + &s.code;gamma&e.code; + <quote><p> + driver's preferred default gamma if no other is given. + If zero (&s.code;< 0.01&e.code;), use the overall server + default. + + </quote> + + It uses the command line, config file, and default values in the + correct order of precedence to determine the gamma value. It is + up to the driver to check the results to see that it supports + them. If not the &s.code;ChipPreInit()&e.code; function should + return &s.code;FALSE&e.code;. + + On success, this function prints a message showing the gamma + value selected, and returns &s.code;TRUE&e.code;. + + On failure it prints an error message and returns &s.code;FALSE&e.code;. + + </quote> + + &s.code;void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)&e.code; + <quote><p> + This function sets the &s.code;xDpi&e.code; and &s.code;yDpi&e.code; + fields of the &s.code;ScrnInfoRec&e.code;. The driver can specify + preferred defaults by setting &s.code;x&e.code; and &s.code;y&e.code; + to non-zero values. The &s.cmd;-dpi&e.cmd; command line option + overrides all other settings. Otherwise, if the + &s.key;DisplaySize&e.key; entry is present in the screen's &k.monitor; + config file section, it is used together with the virtual size to + calculate the dpi values. This function should be called after + all the mode resolution has been done. + + </quote> + + &s.code;void xf86SetBlackWhitePixels(ScrnInfoPtr pScrn)&e.code; + <quote><p> + This functions sets the &s.code;blackPixel&e.code; and + &s.code;whitePixel&e.code; fields of the &s.code;ScrnInfoRec&e.code; + according to whether or not the &s.cmd;-flipPixels&e.cmd; command + line options is present. + + </quote> + + &s.code;const char *xf86GetVisualName(int visual)&e.code; + <quote><p> + Returns a printable string with the visual name matching the + numerical visual class provided. If the value is outside the + range of valid visual classes, &s.code;NULL&e.code; is returned. + + </quote> + </quote> + + +<sect1>Primary Mode functions +<p> + +The primary mode helper functions are those which would normally be +used by a driver, unless it has unusual requirements which cannot +be catered for the by the helpers. + + <quote><p> + &s.code;int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, + &f.indent;char **modeNames, ClockRangePtr clockRanges, + &f.indent;int *linePitches, int minPitch, int maxPitch, + &f.indent;int pitchInc, int minHeight, int maxHeight, + &f.indent;int virtualX, int virtualY, + &f.indent;unsigned long apertureSize, + &f.indent;LookupModeFlags strategy)&e.code; + <quote><p> + This function basically selects the set of modes to use based on + those available and the various constraints. It also sets some + other related parameters. It is normally called near the end of + the &s.code;ChipPreInit()&e.code; function. + + The parameters passed to the function are: + + &s.code;availModes&e.code; + <quote><p> + List of modes available for the monitor. + + </quote> + &s.code;modeNames&e.code; + <quote><p> + List of mode names that the screen is requesting. + + </quote> + &s.code;clockRanges&e.code; + <quote><p> + A list of clock ranges allowed by the driver. Each + range includes whether interlaced or multiscan modes + are supported for that range. See below for more on + &s.code;clockRanges&e.code;. + + </quote> + &s.code;linePitches&e.code; + <quote><p> + List of line pitches supported by the driver. + This is optional and should be &s.code;NULL&e.code; when + not used. + + </quote> + &s.code;minPitch&e.code; + <quote><p> + Minimum line pitch supported by the driver. This must + be supplied when &s.code;linePitches&e.code; is + &s.code;NULL&e.code;, and is ignored otherwise. + + </quote> + &s.code;maxPitch&e.code; + <quote><p> + Maximum line pitch supported by the driver. This is + required when &s.code;minPitch&e.code; is required. + + </quote> + &s.code;pitchInc&e.code; + <quote><p> + Granularity of horizontal pitch values as supported by + the chipset. This is expressed in bits. This must be + supplied. + + </quote> + &s.code;minHeight&e.code; + <quote><p> + minimum virtual height allowed. If zero, no limit is + imposed. + + </quote> + &s.code;maxHeight&e.code; + <quote><p> + maximum virtual height allowed. If zero, no limit is + imposed. + + </quote> + &s.code;virtualX&e.code; + <quote><p> + If greater than zero, this is the virtual width value + that will be used. Otherwise, the virtual width is + chosen to be the smallest that can accommodate the modes + selected. + + </quote> + &s.code;virtualY&e.code; + <quote><p> + If greater than zero, this is the virtual height value + that will be used. Otherwise, the virtual height is + chosen to be the smallest that can accommodate the modes + selected. + + </quote> + &s.code;apertureSize&e.code; + <quote><p> + The size (in bytes) of the aperture used to access video + memory. + + </quote> + &s.code;strategy&e.code; + <quote><p> + The strategy to use when choosing from multiple modes + with the same name. The options are: + + &s.code;LOOKUP_DEFAULT&e.code; + <quote>???</quote> + &s.code;LOOKUP_BEST_REFRESH&e.code; + <quote>mode with best refresh rate</quote> + &s.code;LOOKUP_CLOSEST_CLOCK&e.code; + <quote>mode with closest matching clock</quote> + &s.code;LOOKUP_LIST_ORDER&e.code; + <quote>first usable mode in list</quote> + + The following options can also be combined (OR'ed) with + one of the above: + + &s.code;LOOKUP_CLKDIV2&e.code; + <quote>Allow halved clocks</quote> + &s.code;LOOKUP_OPTIONAL_TOLERANCES&e.code; + <quote>Allow missing horizontal sync and/or vertical refresh + ranges in the xorg.conf Monitor section</quote> + + &s.code;LOOKUP_OPTIONAL_TOLERANCES&e.code; should only be + specified when the driver can ensure all modes it generates + can sync on, or at least not damage, the monitor or digital + flat panel. Horizontal sync and/or vertical refresh ranges + specified by the user will still be honoured (and acted upon). + + </quote> + + This function requires that the following fields of the + &s.code;ScrnInfoRec&e.code; are initialised prior to calling it: + + &s.code;clock[]&e.code; + <quote>List of discrete clocks (when non-programmable)</quote> + &s.code;numClocks&e.code; + <quote>Number of discrete clocks (when non-programmable)</quote> + &s.code;progClock&e.code; + <quote>Whether the clock is programmable or not</quote> + &s.code;monitor&e.code; + <quote>Pointer to the applicable xorg.conf monitor section</quote> + &s.code;fdFormat&e.code; + <quote>Format of the screen buffer</quote> + &s.code;videoRam&e.code; + <quote>total video memory size (in bytes)</quote> + &s.code;maxHValue&e.code; + <quote>Maximum horizontal timing value allowed</quote> + &s.code;maxVValue&e.code; + <quote>Maximum vertical timing value allowed</quote> + &s.code;xInc&e.code; + <quote>Horizontal timing increment in pixels (defaults to 8)</quote> + + This function fills in the following &s.code;ScrnInfoRec&e.code; + fields: + + &s.code;modePool&e.code; + <quote><p> + A subset of the modes available to the monitor which + are compatible with the driver. + + </quote> + &s.code;modes&e.code; + <quote><p> + One mode entry for each of the requested modes, with + the status field of each filled in to indicate if + the mode has been accepted or not. This list of + modes is a circular list. + + </quote> + &s.code;virtualX&e.code; + <quote><p> + The resulting virtual width. + + </quote> + &s.code;virtualY&e.code; + <quote><p> + The resulting virtual height. + + </quote> + &s.code;displayWidth&e.code; + <quote><p> + The resulting line pitch. + + </quote> + &s.code;virtualFrom&e.code; + <quote><p> + Where the virtual size was determined from. + + </quote> + + The first stage of this function checks that the + &s.code;virtualX&e.code; and &s.code;virtualY&e.code; values + supplied (if greater than zero) are consistent with the line pitch + and &s.code;maxHeight&e.code; limitations. If not, an error + message is printed, and the return value is &s.code;-1&e.code;. + + The second stage sets up the mode pool, eliminating immediately + any modes that exceed the driver's line pitch limits, and also + the virtual width and height limits (if greater than zero). For + each mode removed an informational message is printed at verbosity + level &s.code;2&e.code;. If the mode pool ends up being empty, + a warning message is printed, and the return value is + &s.code;0&e.code;. + + The final stage is to lookup each mode name, and fill in the remaining + parameters. If an error condition is encountered, a message is + printed, and the return value is &s.code;-1&e.code;. Otherwise, + the return value is the number of valid modes found + (&s.code;0&e.code; if none are found). + + Even if the supplied mode names include duplicates, no two names will + ever match the same mode. Furthermore, if the supplied mode names do not + yield a valid mode (including the case where no names are passed at all), + the function will continue looking through the mode pool until it finds + a mode that survives all checks, or until the mode pool is exhausted. + + A message is only printed by this function when a fundamental + problem is found. It is intended that this function may be called + more than once if there is more than one set of constraints that + the driver can work within. + + If this function returns &s.code;-1&e.code;, the + &s.code;ChipPreInit()&e.code; function should return + &s.code;FALSE&e.code;. + + &s.code;clockRanges&e.code; is a linked list of clock ranges + allowed by the driver. If a mode doesn't fit in any of the defined + &s.code;clockRanges&e.code;, it is rejected. The first + &s.code;clockRange&e.code; that matches all requirements is used. + This structure needs to be initialized to NULL when allocated. + + &s.code;clockRanges&e.code; contains the following fields: + + &s.code;minClock&nl; + maxClock&e.code; + <quote><p> + The lower and upper mode clock bounds for which the rest + of the &s.code;clockRange&e.code; parameters apply. + Since these are the mode clocks, they are not scaled + with the &s.code;ClockMulFactor&e.code; and + &s.code;ClockDivFactor&e.code;. It is up to the driver + to adjust these values if they depend on the clock + scaling factors. + + </quote> + &s.code;clockIndex&e.code; + <quote><p> + (not used yet) &s.code;-1&e.code; for programmable clocks + + </quote> + &s.code;interlaceAllowed&e.code; + <quote><p> + &s.code;TRUE&e.code; if interlacing is allowed for this + range + + </quote> + &s.code;doubleScanAllowed&e.code; + <quote><p> + &s.code;TRUE&e.code; if doublescan or multiscan is allowed + for this range + + </quote> + &s.code;ClockMulFactor&nl; + ClockDivFactor&e.code; + <quote><p> + Scaling factors that are applied to the mode clocks ONLY + before selecting a clock index (when there is no + programmable clock) or a &s.code;SynthClock&e.code; + value. This is useful for drivers that support pixel + multiplexing or that need to scale the clocks because + of hardware restrictions (like sending 24bpp data to an + 8 bit RAMDAC using a tripled clock). + + Note that these parameters describe what must be done + to the mode clock to achieve the data transport clock + between graphics controller and RAMDAC. For example + for &s.code;2:1&e.code; pixel multiplexing, two pixels + are sent to the RAMDAC on each clock. This allows the + RAMDAC clock to be half of the actual pixel clock. + Hence, &s.code;ClockMulFactor=1&e.code; and + &s.code;ClockDivFactor=2&e.code;. This means that the + clock used for clock selection (ie, determining the + correct clock index from the list of discrete clocks) + or for the &s.code;SynthClock&e.code; field in case of + a programmable clock is: (&s.code;mode->Clock * + ClockMulFactor) / ClockDivFactor&e.code;. + + </quote> + &s.code;PrivFlags&e.code; + <quote><p> + This field is copied into the + &s.code;mode->PrivFlags&e.code; field when this + &s.code;clockRange&e.code; is selected by + &s.code;xf86ValidateModes()&e.code;. It allows the + driver to find out what clock range was selected, so it + knows it needs to set up pixel multiplexing or any other + range-dependent feature. This field is purely + driver-defined: it may contain flag bits, an index or + anything else (as long as it is an &s.code;INT&e.code;). + </quote> + + Note that the &s.code;mode->SynthClock&e.code; field is always + filled in by &s.code;xf86ValidateModes()&e.code;: it will contain + the ``data transport clock'', which is the clock that will have + to be programmed in the chip when it has a programmable clock, or + the clock that will be picked from the clocks list when it is not + a programmable one. Thus: + + &s.code;mode->SynthClock = + &f.indent;(mode->Clock * ClockMulFactor) / ClockDivFactor&e.code; + + </quote> + + &s.code;void xf86PruneDriverModes(ScrnInfoPtr scrp)&e.code; + <quote><p> + This function deletes modes in the modes field of the + &s.code;ScrnInfoRec&e.code; that have been marked as invalid. + This is normally run after having run + &s.code;xf86ValidateModes()&e.code; for the last time. For each + mode that is deleted, a warning message is printed out indicating + the reason for it being deleted. + + </quote> + + &s.code;void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags)&e.code; + <quote><p> + This function fills in the &s.code;Crtc*&e.code; fields for all + the modes in the &s.code;modes&e.code; field of the + &s.code;ScrnInfoRec&e.code;. The &s.code;adjustFlags&e.code; + parameter determines how the vertical CRTC values are scaled for + interlaced modes. They are halved if it is + &s.code;INTERLACE_HALVE_V&e.code;. The vertical CRTC values are + doubled for doublescan modes, and are further multiplied by the + &s.code;VScan&e.code; value. + + This function is normally called after calling + &s.code;xf86PruneDriverModes()&e.code;. + + </quote> + + &s.code;void xf86PrintModes(ScrnInfoPtr scrp)&e.code; + <quote><p> + This function prints out the virtual size setting, and the line + pitch being used. It also prints out two lines for each mode being + used. The first line includes the mode's pixel clock, horizontal sync + rate, refresh rate, and whether it is interlaced, doublescanned and/or + multi-scanned. The second line is the mode's Modeline. + + This function is normally called after calling + &s.code;xf86SetCrtcForModes()&e.code;. + + </quote> + </quote> + + +<sect1>Secondary Mode functions +<p> + +The secondary mode helper functions are functions which are normally +used by the primary mode helper functions, and which are not normally +called directly by a driver. If a driver has unusual requirements +and needs to do its own mode validation, it might be able to make +use of some of these secondary mode helper functions. + + <quote><p> + &s.code;int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2, + &f.indent;int *divider)&e.code; + <quote><p> + This function returns the index of the closest clock to the + frequency &s.code;freq&e.code; given (in kHz). It assumes that + the number of clocks is greater than zero. It requires that the + &s.code;numClocks&e.code; and &s.code;clock&e.code; fields of the + &s.code;ScrnInfoRec&e.code; are initialised. The + &s.code;allowDiv2&e.code; field determines if the clocks can be + halved. The &s.code;*divider&e.code; return value indicates + whether clock division is used when determining the clock returned. + + This function is only for non-programmable clocks. + + </quote> + + &s.code;const char *xf86ModeStatusToString(ModeStatus status)&e.code; + <quote><p> + This function converts the &s.code;status&e.code; value to a + descriptive printable string. + + </quote> + + &s.code;ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, + &f.indent;ClockRangePtr clockRanges, LookupModeFlags strategy)&e.code; + <quote><p> + This function takes a pointer to a mode with the name filled in, + and looks for a mode in the &s.code;modePool&e.code; list which + matches. The parameters of the matching mode are filled in to + &s.code;*modep&e.code;. The &s.code;clockRanges&e.code; and + &s.code;strategy&e.code; parameters are as for the + &s.code;xf86ValidateModes()&e.code; function above. + + This function requires the &s.code;modePool&e.code;, + &s.code;clock[]&e.code;, &s.code;numClocks&e.code; and + &s.code;progClock&e.code; fields of the &s.code;ScrnInfoRec&e.code; + to be initialised before being called. + + The return value is &s.code;MODE_OK&e.code; if a mode was found. + Otherwise it indicates why a matching mode could not be found. + + </quote> + + &s.code;ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, + &f.indent;DisplayModePtr mode, ClockRangePtr clockRanges, + &f.indent;LookupModeFlags strategy, int maxPitch, + &f.indent;int virtualX, int virtualY)&e.code; + <quote><p> + This function checks the passed mode against some basic driver + constraints. Apart from the ones passed explicitly, the + &s.code;maxHValue&e.code; and &s.code;maxVValue&e.code; fields of + the &s.code;ScrnInfoRec&e.code; are also used. If the + &s.code;ValidMode&e.code; field of the &s.code;ScrnInfoRec&e.code; + is set, that function is also called to check the mode. Next, the + mode is checked against the monitor's constraints. + + If the mode is consistent with all constraints, the return value + is &s.code;MODE_OK&e.code;. Otherwise the return value indicates + which constraint wasn't met. + + </quote> + + &s.code;void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode)&e.code; + <quote><p> + This function deletes the &s.code;mode&e.code; given from the + &s.code;modeList&e.code;. It never prints any messages, so it is + up to the caller to print a message if required. + + </quote> + </quote> + +<sect1>Functions for handling strings and tokens +<p> + + Tables associating strings and numerical tokens combined with the + following functions provide a compact way of handling strings from + the config file, and for converting tokens into printable strings. + The table data structure is: + +<quote><verb> +typedef struct { + int token; + const char * name; +} SymTabRec, *SymTabPtr; +</verb></quote> + + A table is an initialised array of &s.code;SymTabRec&e.code;. The + tokens must be non-negative integers. Multiple names may be mapped + to a single token. The table is terminated with an element with a + &s.code;token&e.code; value of &s.code;-1&e.code; and + &s.code;NULL&e.code; for the &s.code;name&e.code;. + + + <quote><p> + &s.code;const char *xf86TokenToString(SymTabPtr table, int token)&e.code; + <quote><p> + This function returns the first string in &s.code;table&e.code; + that matches &s.code;token&e.code;. If no match is found, + &s.code;NULL&e.code; is returned (NOTE, older versions of this + function would return the string "unknown" when no match is found). + + </quote> + + &s.code;int xf86StringToToken(SymTabPtr table, const char *string)&e.code; + <quote><p> + This function returns the first token in &s.code;table&e.code; + that matches &s.code;string&e.code;. The + &s.code;xf86NameCmp()&e.code; function is used to determine the + match. If no match is found, &s.code;-1&e.code; is returned. + + </quote> + </quote> + + +<sect1>Functions for finding which config file entries to use +<p> + + These functions can be used to select the appropriate config file + entries that match the detected hardware. They are described above + in the <ref id="probe" name="Probe"> and + <ref id="avail" name="Available Functions"> sections. + + +<sect1>Probing discrete clocks on old hardware +<p> + + The &s.code;xf86GetClocks()&e.code; function may be used to assist + in finding the discrete pixel clock values on older hardware. + + + <quote><p> + &s.code;void xf86GetClocks(ScrnInfoPtr pScrn, int num, + &f.indent;Bool (*ClockFunc)(ScrnInfoPtr, int), + &f.indent;void (*ProtectRegs)(ScrnInfoPtr, Bool), + &f.indent;void (*BlankScreen)(ScrnInfoPtr, Bool), + &f.indent;int vertsyncreg, int maskval, int knownclkindex, + &f.indent;int knownclkvalue)&e.code; + <quote><p> + This function uses a comparative sampling method to measure the + discrete pixel clock values. The number of discrete clocks to + measure is given by &s.code;num&e.code;. &s.code;clockFunc&e.code; + is a function that selects the &s.code;n&e.code;'th clock. It + should also save or restore any state affected by programming the + clocks when the index passed is &s.code;CLK_REG_SAVE&e.code; or + &s.code;CLK_REG_RESTORE&e.code;. &s.code;ProtectRegs&e.code; is + a function that does whatever is required to protect the hardware + state while selecting a new clock. &s.code;BlankScreen&e.code; + is a function that blanks the screen. &s.code;vertsyncreg&e.code; + and &s.code;maskval&e.code; are the register and bitmask to + check for the presence of vertical sync pulses. + &s.code;knownclkindex&e.code; and &s.code;knownclkvalue&e.code; + are the index and value of a known clock. These are the known + references on which the comparative measurements are based. The + number of clocks probed is set in &s.code;pScrn->numClocks&e.code;, + and the probed clocks are set in the &s.code;pScrn->clock[]&e.code; + array. All of the clock values are in units of kHz. + + </quote> + + &s.code;void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from)&e.code; + <quote><p> + Print out the pixel clocks &s.code;scrp->clock[]&e.code;. + &s.code;from&e.code; indicates whether the clocks were probed + or from the config file. + + </quote> + </quote> + +<sect1>Other helper functions +<p> + <quote><p> + &s.code;Bool xf86IsUnblank(int mode)&e.code; + <quote><p> + Returns &s.code;TRUE&e.code; when the screen saver mode specified + by &s.code;mode&e.code; requires the screen be unblanked, + and &s.code;FALSE&e.code; otherwise. The screen saver modes that + require blanking are &s.code;SCREEN_SAVER_ON&e.code; and + &s.code;SCREEN_SAVER_CYCLE&e.code;, and the screen saver modes that + require unblanking are &s.code;SCREEN_SAVER_OFF&e.code; and + &s.code;SCREEN_SAVER_FORCER&e.code;. Drivers may call this helper + from their &s.code;SaveScreen()&e.code; function to interpret the + screen saver modes. + + </quote> + </quote> + +<sect>The vgahw module +<p> + +The vgahw modules provides an interface for saving, restoring and +programming the standard VGA registers, and for handling VGA colourmaps. + +<sect1>Data Structures +<p> + + The public data structures used by the vgahw module are + &s.code;vgaRegRec&e.code; and &s.code;vgaHWRec&e.code;. They are + defined in &s.code;vgaHW.h.&e.code; + + +<sect1>General vgahw Functions +<p> + + <quote><p> + &s.code;Bool vgaHWGetHWRec(ScrnInfoPtr pScrn)&e.code; + <quote><p> + This function allocates a &s.code;vgaHWRec&e.code; structure, and + hooks it into the &s.code;ScrnInfoRec&e.code;'s + &s.code;privates&e.code;. Like all information hooked into the + &s.code;privates&e.code;, it is persistent, and only needs to be + allocated once per screen. This function should normally be called + from the driver's &s.code;ChipPreInit()&e.code; function. The + &s.code;vgaHWRec&e.code; is zero-allocated, and the following + fields are explicitly initialised: + + &s.code;ModeReg.DAC[]&e.code; + <quote>initialised with a default colourmap</quote> + &s.code;ModeReg.Attribute[0x11]&e.code; + <quote>initialised with the default overscan index</quote> + &s.code;ShowOverscan&e.code; + <quote>initialised according to the "ShowOverscan" option</quote> + &s.code;paletteEnabled&e.code; + <quote>initialised to FALSE</quote> + &s.code;cmapSaved&e.code; + <quote>initialised to FALSE</quote> + &s.code;pScrn&e.code; + <quote>initialised to pScrn</quote> + + In addition to the above, &s.code;vgaHWSetStdFuncs()&e.code; is + called to initialise the register access function fields with the + standard VGA set of functions. + + Once allocated, a pointer to the &s.code;vgaHWRec&e.code; can be + obtained from the &s.code;ScrnInfoPtr&e.code; with the + &s.code;VGAHWPTR(pScrn)&e.code; macro. + + </quote> + + &s.code;void vgaHWFreeHWRec(ScrnInfoPtr pScrn)&e.code; + <quote><p> + This function frees a &s.code;vgaHWRec&e.code; structure. It + should be called from a driver's &s.code;ChipFreeScreen()&e.code; + function. + + </quote> + + &s.code;Bool vgaHWSetRegCounts(ScrnInfoPtr pScrn, int numCRTC, + &f.indent;int numSequencer, int numGraphics, int numAttribute)&e.code; + <quote><p> + This function allows the number of CRTC, Sequencer, Graphics and + Attribute registers to be changed. This makes it possible for + extended registers to be saved and restored with + &s.code;vgaHWSave()&e.code; and &s.code;vgaHWRestore()&e.code;. + This function should be called after a &s.code;vgaHWRec&e.code; + has been allocated with &s.code;vgaHWGetHWRec()&e.code;. The + default values are defined in &s.code;vgaHW.h&e.code; as follows: + + <quote><verb> +#define VGA_NUM_CRTC 25 +#define VGA_NUM_SEQ 5 +#define VGA_NUM_GFX 9 +#define VGA_NUM_ATTR 21 + </verb></quote> + + </quote> + + &s.code;Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src)&e.code; + <quote><p> + This function copies the contents of the VGA saved registers in + &s.code;src&e.code; to &s.code;dst&e.code;. Note that it isn't + possible to simply do this with &s.code;memcpy()&e.code; (or + similar). This function returns &s.code;TRUE&e.code; unless there + is a problem allocating space for the &s.code;CRTC&e.code and + related fields in &s.code;dst&e.code;. + + </quote> + + &s.code;void vgaHWSetStdFuncs(vgaHWPtr hwp)&e.code; + <quote><p> + This function initialises the register access function fields of + &s.code;hwp&e.code; with the standard VGA set of functions. This + is called by &s.code;vgaHWGetHWRec()&e.code;, so there is usually + no need to call this explicitly. The register access functions + are described below. If the registers are shadowed in some other + port I/O space (for example a PCI I/O region), these functions + can be used to access the shadowed registers if + &s.code;hwp->PIOOffset&e.code; is initialised with + &s.code;offset&e.code;, calculated in such a way that when the + standard VGA I/O port value is added to it the correct offset into + the PIO area results. This value is initialised to zero in + &s.code;vgaHWGetHWRec()&e.code;. (Note: the PIOOffset functionality + is present in XFree86 4.1.0 and later.) + + </quote> + + &s.code;void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset)&e.code; + <quote><p> + This function initialised the register access function fields of + hwp with a generic MMIO set of functions. + &s.code;hwp->MMIOBase&e.code; is initialised with + &s.code;base&e.code;, which must be the virtual address that the + start of MMIO area is mapped to. &s.code;hwp->MMIOOffset&e.code; + is initialised with &s.code;offset&e.code;, which must be calculated + in such a way that when the standard VGA I/O port value is added + to it the correct offset into the MMIO area results. That means + that these functions are only suitable when the VGA I/O ports are + made available in a direct mapping to the MMIO space. If that is + not the case, the driver will need to provide its own register + access functions. The register access functions are described + below. + + </quote> + + &s.code;Bool vgaHWMapMem(ScrnInfoPtr pScrn)&e.code; + <quote><p> + This function maps the VGA memory window. It requires that the + &s.code;vgaHWRec&e.code; be allocated. If a driver requires + non-default &s.code;MapPhys&e.code; or &s.code;MapSize&e.code; + settings (the physical location and size of the VGA memory window) + then those fields of the &s.code;vgaHWRec&e.code; must be initialised + before calling this function. Otherwise, this function initialiases + the default values of &s.code;0xA0000&e.code; for + &s.code;MapPhys&e.code; and &s.code;(64 * 1024)&e.code; for + &s.code;MapSize&e.code;. This function must be called before + attempting to save or restore the VGA state. If the driver doesn't + call it explicitly, the &s.code;vgaHWSave()&e.code; and + &s.code;vgaHWRestore()&e.code; functions may call it if they need + to access the VGA memory (in which case they will also call + &s.code;vgaHWUnmapMem()&e.code; to unmap the VGA memory before + exiting). + + </quote> + + &s.code;void vgaHWUnmapMem(ScrnInfoPtr pScrn)&e.code; + <quote><p> + This function unmaps the VGA memory window. It must only be called + after the memory has been mapped. The &s.code;Base&e.code; field + of the &s.code;vgaHWRec&e.code; field is set to &s.code;NULL&e.code; + to indicate that the memory is no longer mapped. + + </quote> + + &s.code;void vgaHWGetIOBase(vgaHWPtr hwp)&e.code; + <quote><p> + This function initialises the &s.code;IOBase&e.code; field of the + &s.code;vgaHWRec&e.code;. This function must be called before + using any other functions that access the video hardware. + + A macro &s.code;VGAHW_GET_IOBASE()&e.code; is also available in + &s.code;vgaHW.h&e.code; that returns the I/O base, and this may + be used when the vgahw module is not loaded (for example, in the + &s.code;ChipProbe()&e.code; function). + + </quote> + + &s.code;void vgaHWUnlock(vgaHWPtr hwp)&e.code; + <quote><p> + This function unlocks the VGA &s.code;CRTC[0-7]&e.code; registers, + and must be called before attempting to write to those registers. + + </quote> + + &s.code;void vgaHWLock(vgaHWPtr hwp)&e.code; + <quote><p> + This function locks the VGA &s.code;CRTC[0-7]&e.code; registers. + + </quote> + + &s.code;void vgaHWEnable(vgaHWPtr hwp)&e.code; + <quote><p> + This function enables the VGA subsystem. (Note, this function is + present in XFree86 4.1.0 and later.). + + </quote> + + &s.code;void vgaHWDisable(vgaHWPtr hwp)&e.code; + <quote><p> + This function disables the VGA subsystem. (Note, this function is + present in XFree86 4.1.0 and later.). + + </quote> + + &s.code;void vgaHWSave(ScrnInfoPtr pScrn, vgaRegPtr save, int flags)&e.code; + <quote><p> + This function saves the VGA state. The state is written to the + &s.code;vgaRegRec&e.code; pointed to by &s.code;save&e.code;. + &s.code;flags&e.code; is set to one or more of the following flags + ORed together: + + &s.code;VGA_SR_MODE&e.code; + <quote>the mode setting registers are saved</quote> + &s.code;VGA_SR_FONTS&e.code; + <quote>the text mode font/text data is saved</quote> + &s.code;VGA_SR_CMAP&e.code; + <quote>the colourmap (LUT) is saved</quote> + &s.code;VGA_SR_ALL&e.code; + <quote>all of the above are saved</quote> + + The &s.code;vgaHWRec&e.code; and its &s.code;IOBase&e.code; fields + must be initialised before this function is called. If + &s.code;VGA_SR_FONTS&e.code; is set in &s.code;flags&e.code;, the + VGA memory window must be mapped. If it isn't then + &s.code;vgaHWMapMem()&e.code; will be called to map it, and + &s.code;vgaHWUnmapMem()&e.code; will be called to unmap it + afterwards. &s.code;vgaHWSave()&e.code; uses the three functions + below in the order &s.code;vgaHWSaveColormap()&e.code;, + &s.code;vgaHWSaveMode()&e.code;, &s.code;vgaHWSaveFonts()&e.code; to + carry out the different save phases. It is undecided at this + stage whether they will remain part of the vgahw module's public + interface or not. + + </quote> + + &s.code;void vgaHWSaveMode(ScrnInfoPtr pScrn, vgaRegPtr save)&e.code; + <quote><p> + This function saves the VGA mode registers. They are saved to + the &s.code;vgaRegRec&e.code; pointed to by &s.code;save&e.code;. + The registers saved are: + + <quote> + &s.code;MiscOut&nl; + CRTC[0-0x18]&nl; + Attribute[0-0x14]&nl; + Graphics[0-8]&nl; + Sequencer[0-4]&e.code; + </quote> + + The number of registers actually saved may be modified by a prior call + to &s.code;vgaHWSetRegCounts()&e.code;. + + </quote> + + &s.code;void vgaHWSaveFonts(ScrnInfoPtr pScrn, vgaRegPtr save)&e.code; + <quote><p> + This function saves the text mode font and text data held in the + video memory. If called while in a graphics mode, no save is + done. The VGA memory window must be mapped with + &s.code;vgaHWMapMem()&e.code; before to calling this function. + + On some platforms, one or more of the font/text plane saves may be + no-ops. This is the case when the platform's VC driver already + takes care of this. + + </quote> + + &s.code;void vgaHWSaveColormap(ScrnInfoPtr pScrn, vgaRegPtr save)&e.code; + <quote><p> + This function saves the VGA colourmap (LUT). Before saving it, it + attempts to verify that the colourmap is readable. In rare cases + where it isn't readable, a default colourmap is saved instead. + + </quote> + + &s.code;void vgaHWRestore(ScrnInfoPtr pScrn, vgaRegPtr restore, int flags)&e.code; + <quote><p> + This function programs the VGA state. The state programmed is + that contained in the &s.code;vgaRegRec&e.code; pointed to by + &s.code;restore&e.code;. &s.code;flags&e.code; is the same + as described above for the &s.code;vgaHWSave()&e.code; function. + + The &s.code;vgaHWRec&e.code; and its &s.code;IOBase&e.code; fields + must be initialised before this function is called. If + &s.code;VGA_SR_FONTS&e.code; is set in &s.code;flags&e.code;, the + VGA memory window must be mapped. If it isn't then + &s.code;vgaHWMapMem()&e.code; will be called to map it, and + &s.code;vgaHWUnmapMem()&e.code; will be called to unmap it + afterwards. &s.code;vgaHWRestore()&e.code; uses the three functions + below in the order &s.code;vgaHWRestoreFonts()&e.code;, + &s.code;vgaHWRestoreMode()&e.code;, + &s.code;vgaHWRestoreColormap()&e.code; to carry out the different + restore phases. It is undecided at this stage whether they will + remain part of the vgahw module's public interface or not. + + </quote> + + &s.code;void vgaHWRestoreMode(ScrnInfoPtr pScrn, vgaRegPtr restore)&e.code; + <quote><p> + This function restores the VGA mode registers. They are restored + from the data in the &s.code;vgaRegRec&e.code; pointed to by + &s.code;restore&e.code;. The registers restored are: + + <quote> + &s.code;MiscOut&nl; + CRTC[0-0x18]&nl; + Attribute[0-0x14]&nl; + Graphics[0-8]&nl; + Sequencer[0-4]&e.code; + </quote> + + The number of registers actually restored may be modified by a prior call + to &s.code;vgaHWSetRegCounts()&e.code;. + + </quote> + + &s.code;void vgaHWRestoreFonts(ScrnInfoPtr pScrn, vgaRegPtr restore)&e.code; + <quote><p> + This function restores the text mode font and text data to the + video memory. The VGA memory window must be mapped with + &s.code;vgaHWMapMem()&e.code; before to calling this function. + + On some platforms, one or more of the font/text plane restores + may be no-ops. This is the case when the platform's VC driver + already takes care of this. + + </quote> + + &s.code;void vgaHWRestoreColormap(ScrnInfoPtr pScrn, vgaRegPtr restore)&e.code; + <quote><p> + This function restores the VGA colourmap (LUT). + + </quote> + + &s.code;void vgaHWInit(ScrnInfoPtr pScrn, DisplayModePtr mode)&e.code; + <quote><p> + This function fills in the &s.code;vgaHWRec&e.code;'s + &s.code;ModeReg&e.code; field with the values appropriate for + programming the given video mode. It requires that the + &s.code;ScrnInfoRec&e.code;'s &s.code;depth&e.code; field is + initialised, which determines how the registers are programmed. + + </quote> + + &s.code;void vgaHWSeqReset(vgaHWPtr hwp, Bool start)&e.code; + <quote><p> + Do a VGA sequencer reset. If start is &s.code;TRUE&e.code;, the + reset is started. If start is &s.code;FALSE&e.code;, the reset + is ended. + + </quote> + + &s.code;void vgaHWProtect(ScrnInfoPtr pScrn, Bool on)&e.code; + <quote><p> + This function protects VGA registers and memory from corruption + during loads. It is typically called with on set to + &s.code;TRUE&e.code; before programming, and with on set to + &s.code;FALSE&e.code; after programming. + + </quote> + + &s.code;Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode)&e.code; + <quote><p> + This function blanks and unblanks the screen. It is blanked when + &s.code;mode&e.code; is &s.code;SCREEN_SAVER_ON&e.code; or + &s.code;SCREEN_SAVER_CYCLE&e.code;, and unblanked when + &s.code;mode&e.code; is &s.code;SCREEN_SAVER_OFF&e.code; or + &s.code;SCREEN_SAVER_FORCER&e.code;. + + </quote> + + &s.code;void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on)&e.code; + <quote><p> + This function blanks and unblanks the screen. It is blanked when + &s.code;on&e.code; is &s.code;FALSE&e.code;, and unblanked when + &s.code;on&e.code; is &s.code;TRUE&e.code;. This function is + provided for use in cases where the &s.code;ScrnInfoRec&e.code; + can't be derived from the &s.code;ScreenRec&e.code; (while probing + for clocks, for example). + + </quote> + </quote> + +<sect1>VGA Colormap Functions +<p> + + The vgahw module uses the standard colormap support (see the + <ref id="cmap" name="Colormap Handling"> section. This is initialised + with the following function: + + <quote> + &s.code;Bool vgaHWHandleColormaps(ScreenPtr pScreen)&e.code; + </quote> + + +<sect1>VGA Register Access Functions +<p> + + The vgahw module abstracts access to the standard VGA registers by + using a set of functions held in the &s.code;vgaHWRec&e.code;. When + the &s.code;vgaHWRec&e.code; is created these function pointers are + initialised with the set of standard VGA I/O register access functions. + In addition to these, the vgahw module includes a basic set of MMIO + register access functions, and the &s.code;vgaHWRec&e.code; function + pointers can be initialised to these by calling the + &s.code;vgaHWSetMmioFuncs()&e.code; function described above. Some + drivers/platforms may require a different set of functions for VGA + access. The access functions are described here. + + + <quote><p> + &s.code;void writeCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)&e.code; + <quote><p> + Write &s.code;value&e.code; to CRTC register &s.code;index&e.code;. + + </quote> + + &s.code;CARD8 readCrtc(vgaHWPtr hwp, CARD8 index)&e.code; + <quote><p> + Return the value read from CRTC register &s.code;index&e.code;. + + </quote> + + &s.code;void writeGr(vgaHWPtr hwp, CARD8 index, CARD8 value)&e.code; + <quote><p> + Write &s.code;value&e.code; to Graphics Controller register + &s.code;index&e.code;. + + </quote> + + &s.code;CARD8 readGR(vgaHWPtr hwp, CARD8 index)&e.code; + <quote><p> + Return the value read from Graphics Controller register + &s.code;index&e.code;. + + </quote> + + &s.code;void writeSeq(vgaHWPtr hwp, CARD8 index, CARD8, value)&e.code; + <quote><p> + Write &s.code;value&e.code; to Sequencer register + &s.code;index&e.code;. + + </quote> + + &s.code;CARD8 readSeq(vgaHWPtr hwp, CARD8 index)&e.code; + <quote><p> + Return the value read from Sequencer register &s.code;index&e.code;. + + </quote> + + &s.code;void writeAttr(vgaHWPtr hwp, CARD8 index, CARD8, value)&e.code; + <quote><p> + Write &s.code;value&e.code; to Attribute Controller register + &s.code;index&e.code;. When writing out the index value this + function should set bit 5 (&s.code;0x20&e.code;) according to the + setting of &s.code;hwp->paletteEnabled&e.code; in order to + preserve the palette access state. It should be cleared when + &s.code;hwp->paletteEnabled&e.code; is &s.code;TRUE&e.code; + and set when it is &s.code;FALSE&e.code;. + + </quote> + + &s.code;CARD8 readAttr(vgaHWPtr hwp, CARD8 index)&e.code; + <quote><p> + Return the value read from Attribute Controller register + &s.code;index&e.code;. When writing out the index value this + function should set bit 5 (&s.code;0x20&e.code;) according to the + setting of &s.code;hwp->paletteEnabled&e.code; in order to + preserve the palette access state. It should be cleared when + &s.code;hwp->paletteEnabled&e.code; is &s.code;TRUE&e.code; + and set when it is &s.code;FALSE&e.code;. + + </quote> + + &s.code;void writeMiscOut(vgaHWPtr hwp, CARD8 value)&e.code; + <quote><p> + Write `&s.code;value&e.code;' to the Miscellaneous Output register. + + </quote> + + &s.code;CARD8 readMiscOut(vgwHWPtr hwp)&e.code; + <quote><p> + Return the value read from the Miscellaneous Output register. + + </quote> + + &s.code;void enablePalette(vgaHWPtr hwp)&e.code; + <quote><p> + Clear the palette address source bit in the Attribute Controller + index register and set &s.code;hwp->paletteEnabled&e.code; to + &s.code;TRUE&e.code;. + + </quote> + + &s.code;void disablePalette(vgaHWPtr hwp)&e.code; + <quote><p> + Set the palette address source bit in the Attribute Controller + index register and set &s.code;hwp->paletteEnabled&e.code; to + &s.code;FALSE&e.code;. + + </quote> + + &s.code;void writeDacMask(vgaHWPtr hwp, CARD8 value)&e.code; + <quote><p> + Write &s.code;value&e.code; to the DAC Mask register. + + </quote> + + &s.code;CARD8 readDacMask(vgaHWptr hwp)&e.code; + <quote><p> + Return the value read from the DAC Mask register. + + </quote> + + &s.code;void writeDacReadAddress(vgaHWPtr hwp, CARD8 value)&e.code; + <quote><p> + Write &s.code;value&e.code; to the DAC Read Address register. + + </quote> + + &s.code;void writeDacWriteAddress(vgaHWPtr hwp, CARD8 value)&e.code; + <quote><p> + Write &s.code;value&e.code; to the DAC Write Address register. + + </quote> + + &s.code;void writeDacData(vgaHWPtr hwp, CARD8 value)&e.code; + <quote><p> + Write &s.code;value&e.code; to the DAC Data register. + + </quote> + + &s.code;CARD8 readDacData(vgaHWptr hwp)&e.code; + <quote><p> + Return the value read from the DAC Data register. + + </quote> + + &s.code;CARD8 readEnable(vgaHWptr hwp)&e.code; + <quote><p> + Return the value read from the VGA Enable register. (Note: This + function is present in XFree86 4.1.0 and later.) + + </quote> + + &s.code;void writeEnable(vgaHWPtr hwp, CARD8 value)&e.code; + <quote><p> + Write &s.code;value&e.code; to the VGA Enable register. (Note: This + function is present in XFree86 4.1.0 and later.) + + </quote> + </quote> + +<sect>Some notes about writing a driver<label id="sample"> +<p> + +<em>NOTE: some parts of this are not up to date</em> + +The following is an outline for writing a basic unaccelerated driver +for a PCI video card with a linear mapped framebuffer, and which has a +VGA core. It is includes some general information that is relevant to +most drivers (even those which don't fit that basic description). + +The information here is based on the initial conversion of the Matrox +Millennium driver to the ``new design''. For a fleshing out and sample +implementation of some of the bits outlined here, refer to that driver. +Note that this is an example only. The approach used here will not be +appropriate for all drivers. + +Each driver must reserve a unique driver name, and a string that is used +to prefix all of its externally visible symbols. This is to avoid name +space clashes when loading multiple drivers. The examples here are for +the ``ZZZ'' driver, which uses the ``ZZZ'' or ``zzz'' prefix for its externally +visible symbols. + + +<sect1>Include files +<p> + + All drivers normally include the following headers: + <quote> + &s.code;"xf86.h"&nl; + "xf86_OSproc.h"&nl; + "xf86_ansic.h"&nl; + "xf86Resources.h"&e.code; + </quote> + Wherever inb/outb (and related things) are used the following should be + included: + <quote> + &s.code;"compiler.h"&e.code; + </quote> + Note: in drivers, this must be included after &s.code;"xf86_ansic.h"&e.code;. + + Drivers that need to access PCI vendor/device definitions need this: + <quote> + &s.code;"xf86PciInfo.h"&e.code; + </quote> + + Drivers that need to access the PCI config space need this: + <quote> + &s.code;"xf86Pci.h"&e.code; + </quote> + + Drivers using the mi banking wrapper need: + + <quote> + &s.code;"mibank.h"&e.code; + </quote> + + Drivers that initialise a SW cursor need this: + <quote> + &s.code;"mipointer.h"&e.code; + </quote> + + All drivers implementing backing store need this: + <quote> + &s.code;"mibstore.h"&e.code; + </quote> + + All drivers using the mi colourmap code need this: + <quote> + &s.code;"micmap.h"&e.code; + </quote> + + If a driver uses the vgahw module, it needs this: + <quote> + &s.code;"vgaHW.h"&e.code; + </quote> + + Drivers supporting VGA or Hercules monochrome screens need: + <quote> + &s.code;"xf1bpp.h"&e.code; + </quote> + + Drivers supporting VGA or EGC 16-colour screens need: + <quote> + &s.code;"xf4bpp.h"&e.code; + </quote> + + Drivers using cfb need: + <quote> + &s.code;#define PSZ 8&nl; + #include "cfb.h"&nl; + #undef PSZ&e.code; + </quote> + + Drivers supporting bpp 16, 24 or 32 with cfb need one or more of: + <quote> + &s.code;"cfb16.h"&nl; + "cfb24.h"&nl; + "cfb32.h"&e.code; + </quote> + + The driver's own header file: + <quote> + &s.code;"zzz.h"&e.code; + </quote> + + Drivers must NOT include the following: + + <quote> + &s.code;"xf86Priv.h"&nl; + "xf86Privstr.h"&nl; + "xf86_libc.h"&nl; + "xf86_OSlib.h"&nl; + "Xos.h"&e.code;&nl; + any OS header + </quote> + + +<sect1>Data structures and initialisation +<p> + +<itemize> + <item>The following macros should be defined: + <code> +#define VERSION <version-as-an-int> +#define ZZZ_NAME "ZZZ" /* the name used to prefix messages */ +#define ZZZ_DRIVER_NAME "zzz" /* the driver name as used in config file */ +#define ZZZ_MAJOR_VERSION <int> +#define ZZZ_MINOR_VERSION <int> +#define ZZZ_PATCHLEVEL <int> + </code> +<p> + NOTE: &s.code;ZZZ_DRIVER_NAME&e.code; should match the name of the + driver module without things like the "lib" prefix, the "_drv" suffix + or filename extensions. +<p> + + <item>A DriverRec must be defined, which includes the functions required + at the pre-probe phase. The name of this DriverRec must be an + upper-case version of ZZZ_DRIVER_NAME (for the purposes of static + linking). +<p> + <code> +DriverRec ZZZ = { + VERSION, + ZZZ_DRIVER_NAME, + ZZZIdentify, + ZZZProbe, + ZZZAvailableOptions, + NULL, + 0 +}; + </code> + + <item>Define list of supported chips and their matching ID: +<p> + <code> +static SymTabRec ZZZChipsets[] = { + { PCI_CHIP_ZZZ1234, "zzz1234a" }, + { PCI_CHIP_ZZZ5678, "zzz5678a" }, + { -1, NULL } +}; + </code> +<p> + The token field may be any integer value that the driver may use to + uniquely identify the supported chipsets. For drivers that support + only PCI devices using the PCI device IDs might be a natural choice, + but this isn't mandatory. For drivers that support both PCI and other + devices (like ISA), some other ID should probably used. When other + IDs are used as the tokens it is recommended that the names be + defined as an &s.code;enum&e.code; type. +<p> + <item>If the driver uses the &s.code;xf86MatchPciInstances(&e.code;) + helper (recommended for drivers that support PCI cards) a list that + maps PCI IDs to chip IDs and fixed resources must be defined: +<p> + <code> +static PciChipsets ZZZPciChipsets[] = { + { PCI_CHIP_ZZZ1234, PCI_CHIP_ZZZ1234, RES_SHARED_VGA }, + { PCI_CHIP_ZZZ5678, PCI_CHIP_ZZZ5678, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +} + </code> +<p> + <item>Define the &s.code;XF86ModuleVersionInfo&e.code; struct for the + driver. This is required for the dynamically loaded version: +<p> + <code> +static XF86ModuleVersionInfo zzzVersRec = +{ + "zzz", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + ZZZ_MAJOR_VERSION, ZZZ_MINOR_VERSION, ZZZ_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0,0,0,0} +}; + </code> +<p> + <item>Define a data structure to hold the driver's screen-specific data. + This must be used instead of global variables. This would be defined + in the &s.code;"zzz.h"&e.code; file, something like: +<p> + <code> +typedef struct { + type1 field1; + type2 field2; + int fooHack; + Bool pciRetry; + Bool noAccel; + Bool hwCursor; + CloseScreenProcPtr CloseScreen; + OptionInfoPtr Options; + ... +} ZZZRec, *ZZZPtr; + </code> +<p> + <item>Define the list of config file Options that the driver accepts. For + consistency between drivers those in the list of ``standard'' options + should be used where appropriate before inventing new options. +<p> + <code> +typedef enum { + OPTION_FOO_HACK, + OPTION_PCI_RETRY, + OPTION_HW_CURSOR, + OPTION_NOACCEL +} ZZZOpts; + +static const OptionInfoRec ZZZOptions[] = { + { OPTION_FOO_HACK, "FooHack", OPTV_INTEGER, {0}, FALSE }, + { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + </code> +<p> +</itemize> + +<sect1>Functions +<p> + + +<sect2>SetupProc +<p> + + For dynamically loaded modules, a &s.code;ModuleData&e.code; + variable is required. It is should be the name of the driver + prepended to "ModuleData". A &s.code;Setup()&e.code; function is + also required, which calls &s.code;xf86AddDriver()&e.code; to add + the driver to the main list of drivers. + + <code> +static MODULESETUPPROTO(zzzSetup); + +XF86ModuleData zzzModuleData = { &zzzVersRec, zzzSetup, NULL }; + +static pointer +zzzSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + /* This module should be loaded only once, but check to be sure. */ + + if (!setupDone) { + /* + * Modules that this driver always requires may be loaded + * here by calling LoadSubModule(). + */ + + setupDone = TRUE; + xf86AddDriver(&MGA, module, 0); + + /* + * The return value must be non-NULL on success even though + * there is no TearDownProc. + */ + return (pointer)1; + } else { + if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } +} + </code> + +<sect2>GetRec, FreeRec +<p> + + A function is usually required to allocate the driver's + screen-specific data structure and hook it into the + &s.code;ScrnInfoRec&e.code;'s &s.code;driverPrivate&e.code; field. + The &s.code;ScrnInfoRec&e.code;'s &s.code;driverPrivate&e.code; is + initialised to &s.code;NULL&e.code;, so it is easy to check if the + initialisation has already been done. After allocating it, initialise + the fields. By using &s.code;xnfcalloc()&e.code; to do the allocation + it is zeroed, and if the allocation fails the server exits. +<p> + NOTE: + When allocating structures from inside the driver which are defined + on the common level it is important to initialize the structure to + zero. + Only this guarantees that the server remains source compatible to + future changes in common level structures. + + <code> +static Bool +ZZZGetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate != NULL) + return TRUE; + pScrn->driverPrivate = xnfcalloc(sizeof(ZZZRec), 1); + /* Initialise as required */ + ... + return TRUE; +} + </code> + + Define a macro in &s.code;"zzz.h"&e.code; which gets a pointer to + the &s.code;ZZZRec&e.code; when given &s.code;pScrn&e.code;: + + <code> +#define ZZZPTR(p) ((ZZZPtr)((p)->driverPrivate)) + </code> + + Define a function to free the above, setting it to &s.code;NULL&e.code; + once it has been freed: + + <code> +static void +ZZZFreeRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate == NULL) + return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + </code> + +<sect2>Identify +<p> + + Define the &s.code;Identify()&e.code; function. It is run before + the Probe, and typically prints out an identifying message, which + might include the chipsets it supports. This function is mandatory: + + <code> +static void +ZZZIdentify(int flags) +{ + xf86PrintChipsets(ZZZ_NAME, "driver for ZZZ Tech chipsets", + ZZZChipsets); +} + </code> + +<sect2>Probe +<p> + + Define the &s.code;Probe()&e.code; function. The purpose of this + is to find all instances of the hardware that the driver supports, + and for the ones not already claimed by another driver, claim the + slot, and allocate a &s.code;ScrnInfoRec&e.code;. This should be + a minimal probe, and it should under no circumstances leave the + state of the hardware changed. Because a device is found, don't + assume that it will be used. Don't do any initialisations other + than the required &s.code;ScrnInfoRec&e.code; initialisations. + Don't allocate any new data structures. + + This function is mandatory. + + NOTE: The &s.code;xf86DrvMsg()&e.code; functions cannot be used from + the Probe. + + <code> +static Bool +ZZZProbe(DriverPtr drv, int flags) +{ + Bool foundScreen = FALSE; + int numDevSections, numUsed; + GDevPtr *devSections; + int *usedChips; + int i; + + /* + * Find the config file Device sections that match this + * driver, and return if there are none. + */ + if ((numDevSections = xf86MatchDevice(ZZZ_DRIVER_NAME, + &devSections)) <= 0) { + return FALSE; + } + + /* + * Since this is a PCI card, "probing" just amounts to checking + * the PCI data that the server has already collected. If there + * is none, return. + * + * Although the config file is allowed to override things, it + * is reasonable to not allow it to override the detection + * of no PCI video cards. + * + * The provided xf86MatchPciInstances() helper takes care of + * the details. + */ + /* test if PCI bus present */ + if (xf86GetPciVideoInfo()) { + + numUsed = xf86MatchPciInstances(ZZZ_NAME, PCI_VENDOR_ZZZ, + ZZZChipsets, ZZZPciChipsets, devSections, + numDevSections, drv, &usedChips); + + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + if ((pScrn = xf86ConfigPciEntity(pScrn, flags, usedChips[i], + ZZZPciChipsets, NULL, NULL, + NULL, NULL, NULL))) { + /* Allocate a ScrnInfoRec */ + pScrn->driverVersion = VERSION; + pScrn->driverName = ZZZ_DRIVER_NAME; + pScrn->name = ZZZ_NAME; + pScrn->Probe = ZZZProbe; + pScrn->PreInit = ZZZPreInit; + pScrn->ScreenInit = ZZZScreenInit; + pScrn->SwitchMode = ZZZSwitchMode; + pScrn->AdjustFrame = ZZZAdjustFrame; + pScrn->EnterVT = ZZZEnterVT; + pScrn->LeaveVT = ZZZLeaveVT; + pScrn->FreeScreen = ZZZFreeScreen; + pScrn->ValidMode = ZZZValidMode; + foundScreen = TRUE; + /* add screen to entity */ + } + } + xfree(usedChips); + } + +#ifdef HAS_ISA_DEVS + /* + * If the driver supports ISA hardware, the following block + * can be included too. + */ + numUsed = xf86MatchIsaInstances(ZZZ_NAME, ZZZChipsets, + ZZZIsaChipsets, drv, ZZZFindIsaDevice, + devSections, numDevSections, &usedChips); + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + if ((pScrn = xf86ConfigIsaEntity(pScrn, flags, usedChips[i], + ZZZIsaChipsets, NULL, NULL, NULL, + NULL, NULL))) { + pScrn->driverVersion = VERSION; + pScrn->driverName = ZZZ_DRIVER_NAME; + pScrn->name = ZZZ_NAME; + pScrn->Probe = ZZZProbe; + pScrn->PreInit = ZZZPreInit; + pScrn->ScreenInit = ZZZScreenInit; + pScrn->SwitchMode = ZZZSwitchMode; + pScrn->AdjustFrame = ZZZAdjustFrame; + pScrn->EnterVT = ZZZEnterVT; + pScrn->LeaveVT = ZZZLeaveVT; + pScrn->FreeScreen = ZZZFreeScreen; + pScrn->ValidMode = ZZZValidMode; + foundScreen = TRUE; + } + } + xfree(usedChips); +#endif /* HAS_ISA_DEVS */ + + xfree(devSections); + return foundScreen; + </code> + +<sect2>AvailableOptions +<p> + + Define the &s.code;AvailableOptions()&e.code; function. The purpose + of this is to return the available driver options back to the + -configure option, so that an xorg.conf file can be built and the + user can see which options are available for them to use. + +<sect2>PreInit +<p> + + Define the &s.code;PreInit()&e.code; function. The purpose of + this is to find all the information required to determine if the + configuration is usable, and to initialise those parts of the + &s.code;ScrnInfoRec&e.code; that can be set once at the beginning + of the first server generation. The information should be found in + the least intrusive way possible. + + This function is mandatory. + + NOTES: + <enum> + <item>The &s.code;PreInit()&e.code; function is only called once + during the life of the X server (at the start of the first + generation). + + <item>Data allocated here must be of the type that persists for + the life of the X server. This means that data that hooks into + the &s.code;ScrnInfoRec&e.code;'s &s.code;privates&e.code; + field should be allocated here, but data that hooks into the + &s.code;ScreenRec&e.code;'s &s.code;devPrivates&e.code; field + should not be allocated here. The &s.code;driverPrivate&e.code; + field should also be allocated here. + + <item>Although the &s.code;ScrnInfoRec&e.code; has been allocated + before this function is called, the &s.code;ScreenRec&e.code; + has not been allocated. That means that things requiring it + cannot be used in this function. + + <item>Very little of the &s.code;ScrnInfoRec&e.code; has been + initialised when this function is called. It is important to + get the order of doing things right in this function. + + </enum> + + <code> +static Bool +ZZZPreInit(ScrnInfoPtr pScrn, int flags) +{ + /* Fill in the monitor field */ + pScrn->monitor = pScrn->confScreen->monitor; + + /* + * If using the vgahw module, it will typically be loaded + * here by calling xf86LoadSubModule(pScrn, "vgahw"); + */ + + /* + * Set the depth/bpp. Use the globally preferred depth/bpp. If the + * driver has special default depth/bpp requirements, the defaults should + * be specified here explicitly. + * We support both 24bpp and 32bpp framebuffer layouts. + * This sets pScrn->display also. + */ + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, + Support24bppFb | Support32bppFb)) { + return FALSE; + } else { + if (depth/bpp isn't one we support) { + print error message; + return FALSE; + } + } + /* Print out the depth/bpp that was set */ + xf86PrintDepthBpp(pScrn); + + /* Set bits per RGB for 8bpp */ + if (pScrn->depth <= 8) { + /* Take into account a dac_6_bit option here */ + pScrn->rgbBits = 6 or 8; + } + + /* + * xf86SetWeight() and xf86SetDefaultVisual() must be called + * after pScrn->display is initialised. + */ + + /* Set weight/mask/offset for depth > 8 */ + if (pScrn->depth > 8) { + if (!xf86SetWeight(pScrn, defaultWeight, defaultMask)) { + return FALSE; + } else { + if (weight isn't one we support) { + print error message; + return FALSE; + } + } + } + + /* Set the default visual. */ + if (!xf86SetDefaultVisual(pScrn, -1)) { + return FALSE; + } else { + if (visual isn't one we support) { + print error message; + return FALSE; + } + } + + /* If the driver supports gamma correction, set the gamma. */ + if (!xf86SetGamma(pScrn, default_gamma)) { + return FALSE; + } + + /* This driver uses a programmable clock */ + pScrn->progClock = TRUE; + + /* Allocate the ZZZRec driverPrivate */ + if (!ZZZGetRec(pScrn)) { + return FALSE; + } + + pZzz = ZZZPTR(pScrn); + + /* Collect all of the option flags (fill in pScrn->options) */ + xf86CollectOptions(pScrn, NULL); + + /* + * Process the options based on the information in ZZZOptions. + * The results are written to pZzz->Options. If all of the options + * processing is done within this function a local variable "options" + * can be used instead of pZzz->Options. + */ + if (!(pZzz->Options = xalloc(sizeof(ZZZOptions)))) + return FALSE; + (void)memcpy(pZzz->Options, ZZZOptions, sizeof(ZZZOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pZzz->Options); + + /* + * Set various fields of ScrnInfoRec and/or ZZZRec based on + * the options found. + */ + from = X_DEFAULT; + pZzz->hwCursor = FALSE; + if (xf86IsOptionSet(pZzz->Options, OPTION_HW_CURSOR)) { + from = X_CONFIG; + pZzz->hwCursor = TRUE; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", + pZzz->hwCursor ? "HW" : "SW"); + if (xf86IsOptionSet(pZzz->Options, OPTION_NOACCEL)) { + pZzz->noAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Acceleration disabled\n"); + } else { + pZzz->noAccel = FALSE; + } + if (xf86IsOptionSet(pZzz->Options, OPTION_PCI_RETRY)) { + pZzz->UsePCIRetry = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI retry enabled\n"); + } + pZzz->fooHack = 0; + if (xf86GetOptValInteger(pZzz->Options, OPTION_FOO_HACK, + &pZzz->fooHack)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Foo Hack set to %d\n", + pZzz->fooHack); + } + + /* + * Find the PCI slot(s) that this screen claimed in the probe. + * In this case, exactly one is expected, so complain otherwise. + * Note in this case we're not interested in the card types so + * that parameter is set to NULL. + */ + if ((i = xf86GetPciInfoForScreen(pScrn->scrnIndex, &pciList, NULL)) + != 1) { + print error message; + ZZZFreeRec(pScrn); + if (i > 0) + xfree(pciList); + return FALSE; + } + /* Note that pciList should be freed below when no longer needed */ + + /* + * Determine the chipset, allowing config file chipset and + * chipid values to override the probed information. The config + * chipset value has precedence over its chipid value if both + * are present. + * + * It isn't necessary to fill in pScrn->chipset if the driver + * keeps track of the chipset in its ZZZRec. + */ + + ... + + /* + * Determine video memory, fb base address, I/O addresses, etc, + * allowing the config file to override probed values. + * + * Set the appropriate pScrn fields (videoRam is probably the + * most important one that other code might require), and + * print out the settings. + */ + + ... + + /* Initialise a clockRanges list. */ + + ... + + /* Set any other chipset specific things in the ZZZRec */ + + ... + + /* Select valid modes from those available */ + + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + pScrn->display->modes, clockRanges, + NULL, minPitch, maxPitch, rounding, + minHeight, maxHeight, + pScrn->display->virtualX, + pScrn->display->virtualY, + pScrn->videoRam * 1024, + LOOKUP_BEST_REFRESH); + if (i == -1) { + ZZZFreeRec(pScrn); + return FALSE; + } + + /* Prune the modes marked as invalid */ + + xf86PruneDriverModes(pScrn); + + /* If no valid modes, return */ + + if (i == 0 || pScrn->modes == NULL) { + print error message; + ZZZFreeRec(pScrn); + return FALSE; + } + + /* + * Initialise the CRTC fields for the modes. This driver expects + * vertical values to be halved for interlaced modes. + */ + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); + + /* Set the current mode to the first in the list. */ + pScrn->currentMode = pScrn->modes; + + /* Print the list of modes being used. */ + xf86PrintModes(pScrn); + + /* Set the DPI */ + xf86SetDpi(pScrn, 0, 0); + + /* Load bpp-specific modules */ + switch (pScrn->bitsPerPixel) { + case 1: + mod = "xf1bpp"; + break; + case 4: + mod = "xf4bpp"; + break; + case 8: + mod = "cfb"; + break; + case 16: + mod = "cfb16"; + break; + case 24: + mod = "cfb24"; + break; + case 32: + mod = "cfb32"; + break; + } + if (mod && !xf86LoadSubModule(pScrn, mod)) + ZZZFreeRec(pScrn); + return FALSE; + + /* Load XAA if needed */ + if (!pZzz->noAccel || pZzz->hwCursor) + if (!xf86LoadSubModule(pScrn, "xaa")) { + ZZZFreeRec(pScrn); + return FALSE; + } + + /* Done */ + return TRUE; +} + </code> + +<sect2>MapMem, UnmapMem +<p> + + Define functions to map and unmap the video memory and any other + memory apertures required. These functions are not mandatory, but + it is often useful to have such functions. + + <code> +static Bool +ZZZMapMem(ScrnInfoPtr pScrn) +{ + /* Call xf86MapPciMem() to map each PCI memory area */ + ... + return TRUE or FALSE; +} + +static Bool +ZZZUnmapMem(ScrnInfoPtr pScrn) +{ + /* Call xf86UnMapVidMem() to unmap each memory area */ + ... + return TRUE or FALSE; +} + </code> + +<sect2>Save, Restore +<p> + + Define functions to save and restore the original video state. These + functions are not mandatory, but are often useful. + + <code> +static void +ZZZSave(ScrnInfoPtr pScrn) +{ + /* + * Save state into per-screen data structures. + * If using the vgahw module, vgaHWSave will typically be + * called here. + */ + ... +} + +static void +ZZZRestore(ScrnInfoPtr pScrn) +{ + /* + * Restore state from per-screen data structures. + * If using the vgahw module, vgaHWRestore will typically be + * called here. + */ + ... +} + </code> + +<sect2>ModeInit +<p> + + Define a function to initialise a new video mode. This function isn't + mandatory, but is often useful. + + <code> +static Bool +ZZZModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + /* + * Program a video mode. If using the vgahw module, + * vgaHWInit and vgaRestore will typically be called here. + * Once up to the point where there can't be a failure + * set pScrn->vtSema to TRUE. + */ + ... +} + </code> + +<sect2>ScreenInit +<p> + + Define the &s.code;ScreenInit()&e.code; function. This is called + at the start of each server generation, and should fill in as much + of the &s.code;ScreenRec&e.code; as possible as well as any other + data that is initialised once per generation. It should initialise + the framebuffer layers it is using, and initialise the initial video + mode. + + This function is mandatory. + + NOTE: The &s.code;ScreenRec&e.code; (&s.code;pScreen&e.code;) is + passed to this driver, but it and the + &s.code;ScrnInfoRecs&e.code; are not yet hooked into each + other. This means that in this function, and functions it + calls, one cannot be found from the other. + + <code> +static Bool +ZZZScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + /* Get the ScrnInfoRec */ + pScrn = xf86Screens[pScreen->myNum]; + + /* + * If using the vgahw module, its data structures and related + * things are typically initialised/mapped here. + */ + + /* Save the current video state */ + ZZZSave(pScrn); + + /* Initialise the first mode */ + ZZZModeInit(pScrn, pScrn->currentMode); + + /* Set the viewport if supported */ + + ZZZAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* + * Setup the screen's visuals, and initialise the framebuffer + * code. + */ + + /* Reset the visual list */ + miClearVisualTypes(); + + /* + * Setup the visuals supported. This driver only supports + * TrueColor for bpp > 8, so the default set of visuals isn't + * acceptable. To deal with this, call miSetVisualTypes with + * the appropriate visual mask. + */ + + if (pScrn->bitsPerPixel > 8) { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } else { + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } + + /* + * Initialise the framebuffer. + */ + + switch (pScrn->bitsPerPixel) { + case 1: + ret = xf1bppScreenInit(pScreen, FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; + case 4: + ret = xf4bppScreenInit(pScreen, FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; + case 8: + ret = cfbScreenInit(pScreen, FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; + case 16: + ret = cfb16ScreenInit(pScreen, FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; + case 24: + ret = cfb24ScreenInit(pScreen, FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; + case 32: + ret = cfb32ScreenInit(pScreen, FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; + default: + print a message about an internal error; + ret = FALSE; + break; + } + + if (!ret) + return FALSE; + + /* Override the default mask/offset settings */ + if (pScrn->bitsPerPixel > 8) { + for (i = 0, visual = pScreen->visuals; + i < pScreen->numVisuals; i++, visual++) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + /* + * If banking is needed, initialise an miBankInfoRec (defined in + * "mibank.h"), and call miInitializeBanking(). + */ + if (!miInitializeBanking(pScreen, pScrn->virtualX, pScrn->virtualY, + pScrn->displayWidth, pBankInfo)) + return FALSE; + + /* + * If backing store is to be supported (as is usually the case), + * initialise it. + */ + miInitializeBackingStore(pScreen); + + /* + * Set initial black & white colourmap indices. + */ + xf86SetBlackWhitePixels(pScreen); + + /* + * Install colourmap functions. If using the vgahw module, + * vgaHandleColormaps would usually be called here. + */ + + ... + + /* + * Initialise cursor functions. This example is for the mi + * software cursor. + */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Initialise the default colourmap */ + switch (pScrn->depth) { + case 1: + if (!xf1bppCreateDefColormap(pScreen)) + return FALSE; + break; + case 4: + if (!xf4bppCreateDefColormap(pScreen)) + return FALSE; + break; + default: + if (!cfbCreateDefColormap(pScreen)) + return FALSE; + break; + } + + /* + * Wrap the CloseScreen vector and set SaveScreen. + */ + ZZZPTR(pScrn)->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = ZZZCloseScreen; + pScreen->SaveScreen = ZZZSaveScreen; + + /* Report any unused options (only for the first generation) */ + if (serverGeneration == 1) { + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + } + + /* Done */ + return TRUE; +} + </code> + + +<sect2>SwitchMode +<p> + + Define the &s.code;SwitchMode()&e.code; function if mode switching + is supported by the driver. + + <code> +static Bool +ZZZSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return ZZZModeInit(xf86Screens[scrnIndex], mode); +} + </code> + + +<sect2>AdjustFrame +<p> + + Define the &s.code;AdjustFrame()&e.code; function if the driver + supports this. + + <code> +static void +ZZZAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + /* Adjust the viewport */ +} + </code> + + +<sect2>EnterVT, LeaveVT +<p> + + Define the &s.code;EnterVT()&e.code; and &s.code;LeaveVT()&e.code; + functions. + + These functions are mandatory. + + <code> +static Bool +ZZZEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + return ZZZModeInit(pScrn, pScrn->currentMode); +} + +static void +ZZZLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ZZZRestore(pScrn); +} + </code> + +<sect2>CloseScreen +<p> + + Define the &s.code;CloseScreen()&e.code; function: + + This function is mandatory. Note that it unwraps the previously + wrapped &s.code;pScreen->CloseScreen&e.code;, and finishes by + calling it. + + <code> +static Bool +ZZZCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + if (pScrn->vtSema) { + ZZZRestore(pScrn); + ZZZUnmapMem(pScrn); + } + pScrn->vtSema = FALSE; + pScreen->CloseScreen = ZZZPTR(pScrn)->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + </code> + +<sect2>SaveScreen +<p> + + Define the &s.code;SaveScreen()&e.code; function (the screen + blanking function). When using the vgahw module, this will typically + be: + + <code> +static Bool +ZZZSaveScreen(ScreenPtr pScreen, int mode) +{ + return vgaHWSaveScreen(pScreen, mode); +} + </code> + + This function is mandatory. Before modifying any hardware register + directly this function needs to make sure that the Xserver is active + by checking if &s.code;pScrn&e.code; is non-NULL and for + &s.code;pScrn->vtSema == TRUE&e.code;. + +<sect2>FreeScreen +<p> + + Define the &s.code;FreeScreen()&e.code; function. This function + is optional. It should be defined if the &s.code;ScrnInfoRec&e.code; + &s.code;driverPrivate&e.code; field is used so that it can be freed + when a screen is deleted by the common layer for reasons possibly + beyond the driver's control. This function is not used in during + normal (error free) operation. The per-generation data is freed by + the &s.code;CloseScreen()&e.code; function. + + <code> +static void +ZZZFreeScreen(int scrnIndex, int flags) +{ + /* + * If the vgahw module is used vgaHWFreeHWRec() would be called + * here. + */ + ZZZFreeRec(xf86Screens[scrnIndex]); +} + </code> + + +</article> diff --git a/xorg-server/hw/xfree86/doc/sgml/Makefile.am b/xorg-server/hw/xfree86/doc/sgml/Makefile.am new file mode 100644 index 000000000..d2c821c03 --- /dev/null +++ b/xorg-server/hw/xfree86/doc/sgml/Makefile.am @@ -0,0 +1,54 @@ +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software +# and its documentation for any purpose is hereby granted without +# fee, provided that the above copyright notice appear in all copies +# and that both that copyright notice and this permission notice +# appear in supporting documentation, and that the name of Red Hat +# not be used in advertising or publicity pertaining to distribution +# of the software without specific, written prior permission. Red +# Hat makes no representations about the suitability of this software +# for any purpose. It is provided "as is" without express or implied +# warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN +# NO EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +SGML_FILES = DESIGN.sgml + +if BUILD_LINUXDOC +TXT_FILES = $(SGML_FILES:%.sgml=%.txt) +PS_FILES = $(SGML_FILES:%.sgml=%.ps) +if BUILD_PDFDOC +PDF_FILES = $(SGML_FILES:%.sgml=%.pdf) +endif +HTML_FILES = $(SGML_FILES:%.sgml=%.html) + +SUFFIXES = .sgml .txt .html .ps .pdf + +.sgml.txt: + @rm -f $@ + $(MAKE_TEXT) $< + +.sgml.ps: + @rm -f $@ + $(MAKE_PS) $< + +.ps.pdf: + @rm -f $@ + $(MAKE_PDF) $< + +.sgml.html: + @rm -f $@ + $(MAKE_HTML) $< + +noinst_DATA = $(TXT_FILES) $(PS_FILES) $(PDF_FILES) $(HTML_FILES) +CLEANFILES = $(TXT_FILES) $(PS_FILES) $(PDF_FILES) $(HTML_FILES) +endif + +EXTRA_DIST = $(SGML_FILES) diff --git a/xorg-server/hw/xfree86/doc/sgml/Makefile.in b/xorg-server/hw/xfree86/doc/sgml/Makefile.in new file mode 100644 index 000000000..3ee4d8cdd --- /dev/null +++ b/xorg-server/hw/xfree86/doc/sgml/Makefile.in @@ -0,0 +1,581 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 2005 Red Hat, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software +# and its documentation for any purpose is hereby granted without +# fee, provided that the above copyright notice appear in all copies +# and that both that copyright notice and this permission notice +# appear in supporting documentation, and that the name of Red Hat +# not be used in advertising or publicity pertaining to distribution +# of the software without specific, written prior permission. Red +# Hat makes no representations about the suitability of this software +# for any purpose. It is provided "as is" without express or implied +# warranty. +# +# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN +# NO EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/doc/sgml +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DATA = $(noinst_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +SGML_FILES = DESIGN.sgml +@BUILD_LINUXDOC_TRUE@TXT_FILES = $(SGML_FILES:%.sgml=%.txt) +@BUILD_LINUXDOC_TRUE@PS_FILES = $(SGML_FILES:%.sgml=%.ps) +@BUILD_LINUXDOC_TRUE@@BUILD_PDFDOC_TRUE@PDF_FILES = $(SGML_FILES:%.sgml=%.pdf) +@BUILD_LINUXDOC_TRUE@HTML_FILES = $(SGML_FILES:%.sgml=%.html) +@BUILD_LINUXDOC_TRUE@SUFFIXES = .sgml .txt .html .ps .pdf +@BUILD_LINUXDOC_TRUE@noinst_DATA = $(TXT_FILES) $(PS_FILES) $(PDF_FILES) $(HTML_FILES) +@BUILD_LINUXDOC_TRUE@CLEANFILES = $(TXT_FILES) $(PS_FILES) $(PDF_FILES) $(HTML_FILES) +EXTRA_DIST = $(SGML_FILES) +all: all-am + +.SUFFIXES: +.SUFFIXES: .sgml .txt .html .ps .pdf +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/doc/sgml/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/doc/sgml/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + + +@BUILD_LINUXDOC_TRUE@.sgml.txt: +@BUILD_LINUXDOC_TRUE@ @rm -f $@ +@BUILD_LINUXDOC_TRUE@ $(MAKE_TEXT) $< + +@BUILD_LINUXDOC_TRUE@.sgml.ps: +@BUILD_LINUXDOC_TRUE@ @rm -f $@ +@BUILD_LINUXDOC_TRUE@ $(MAKE_PS) $< + +@BUILD_LINUXDOC_TRUE@.ps.pdf: +@BUILD_LINUXDOC_TRUE@ @rm -f $@ +@BUILD_LINUXDOC_TRUE@ $(MAKE_PDF) $< + +@BUILD_LINUXDOC_TRUE@.sgml.html: +@BUILD_LINUXDOC_TRUE@ @rm -f $@ +@BUILD_LINUXDOC_TRUE@ $(MAKE_HTML) $< +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/dri/Makefile.am b/xorg-server/hw/xfree86/dri/Makefile.am new file mode 100644 index 000000000..e17cea7fd --- /dev/null +++ b/xorg-server/hw/xfree86/dri/Makefile.am @@ -0,0 +1,22 @@ +libdri_la_LTLIBRARIES = libdri.la +libdri_la_CFLAGS = -I$(top_srcdir)/hw/xfree86/common \ + -I$(top_srcdir)/hw/xfree86/os-support \ + -I$(top_srcdir)/hw/xfree86/os-support/bus \ + -I$(top_srcdir)/glx \ + -I$(top_srcdir)/GL/include \ + -I$(top_builddir)/GL/include \ + -DHAVE_XORG_CONFIG_H \ + @DIX_CFLAGS@ @XORG_CFLAGS@ @DRIPROTO_CFLAGS@ \ + @LIBDRM_CFLAGS@ \ + @GL_CFLAGS@ +libdri_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@ +libdri_ladir = $(moduledir)/extensions +libdri_la_SOURCES = \ + dri.c \ + dri.h \ + drimodule.c \ + dristruct.h \ + sarea.h \ + xf86dri.c + +sdk_HEADERS = dri.h sarea.h dristruct.h diff --git a/xorg-server/hw/xfree86/dri/Makefile.in b/xorg-server/hw/xfree86/dri/Makefile.in new file mode 100644 index 000000000..fae6a213e --- /dev/null +++ b/xorg-server/hw/xfree86/dri/Makefile.in @@ -0,0 +1,741 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/dri +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdri_ladir)" "$(DESTDIR)$(sdkdir)" +libdri_laLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(libdri_la_LTLIBRARIES) +libdri_la_LIBADD = +am_libdri_la_OBJECTS = libdri_la-dri.lo libdri_la-drimodule.lo \ + libdri_la-xf86dri.lo +libdri_la_OBJECTS = $(am_libdri_la_OBJECTS) +libdri_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libdri_la_CFLAGS) \ + $(CFLAGS) $(libdri_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libdri_la_SOURCES) +DIST_SOURCES = $(libdri_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +libdri_la_LTLIBRARIES = libdri.la +libdri_la_CFLAGS = -I$(top_srcdir)/hw/xfree86/common \ + -I$(top_srcdir)/hw/xfree86/os-support \ + -I$(top_srcdir)/hw/xfree86/os-support/bus \ + -I$(top_srcdir)/glx \ + -I$(top_srcdir)/GL/include \ + -I$(top_builddir)/GL/include \ + -DHAVE_XORG_CONFIG_H \ + @DIX_CFLAGS@ @XORG_CFLAGS@ @DRIPROTO_CFLAGS@ \ + @LIBDRM_CFLAGS@ \ + @GL_CFLAGS@ + +libdri_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@ +libdri_ladir = $(moduledir)/extensions +libdri_la_SOURCES = \ + dri.c \ + dri.h \ + drimodule.c \ + dristruct.h \ + sarea.h \ + xf86dri.c + +sdk_HEADERS = dri.h sarea.h dristruct.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/dri/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/dri/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libdri_laLTLIBRARIES: $(libdri_la_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdri_ladir)" || $(MKDIR_P) "$(DESTDIR)$(libdri_ladir)" + @list='$(libdri_la_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libdri_laLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdri_ladir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libdri_laLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdri_ladir)/$$f"; \ + else :; fi; \ + done + +uninstall-libdri_laLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(libdri_la_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdri_ladir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdri_ladir)/$$p"; \ + done + +clean-libdri_laLTLIBRARIES: + -test -z "$(libdri_la_LTLIBRARIES)" || rm -f $(libdri_la_LTLIBRARIES) + @list='$(libdri_la_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libdri.la: $(libdri_la_OBJECTS) $(libdri_la_DEPENDENCIES) + $(libdri_la_LINK) -rpath $(libdri_ladir) $(libdri_la_OBJECTS) $(libdri_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdri_la-dri.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdri_la-drimodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdri_la-xf86dri.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libdri_la-dri.lo: dri.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri_la_CFLAGS) $(CFLAGS) -MT libdri_la-dri.lo -MD -MP -MF $(DEPDIR)/libdri_la-dri.Tpo -c -o libdri_la-dri.lo `test -f 'dri.c' || echo '$(srcdir)/'`dri.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libdri_la-dri.Tpo $(DEPDIR)/libdri_la-dri.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dri.c' object='libdri_la-dri.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri_la_CFLAGS) $(CFLAGS) -c -o libdri_la-dri.lo `test -f 'dri.c' || echo '$(srcdir)/'`dri.c + +libdri_la-drimodule.lo: drimodule.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri_la_CFLAGS) $(CFLAGS) -MT libdri_la-drimodule.lo -MD -MP -MF $(DEPDIR)/libdri_la-drimodule.Tpo -c -o libdri_la-drimodule.lo `test -f 'drimodule.c' || echo '$(srcdir)/'`drimodule.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libdri_la-drimodule.Tpo $(DEPDIR)/libdri_la-drimodule.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drimodule.c' object='libdri_la-drimodule.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri_la_CFLAGS) $(CFLAGS) -c -o libdri_la-drimodule.lo `test -f 'drimodule.c' || echo '$(srcdir)/'`drimodule.c + +libdri_la-xf86dri.lo: xf86dri.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri_la_CFLAGS) $(CFLAGS) -MT libdri_la-xf86dri.lo -MD -MP -MF $(DEPDIR)/libdri_la-xf86dri.Tpo -c -o libdri_la-xf86dri.lo `test -f 'xf86dri.c' || echo '$(srcdir)/'`xf86dri.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libdri_la-xf86dri.Tpo $(DEPDIR)/libdri_la-xf86dri.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xf86dri.c' object='libdri_la-xf86dri.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri_la_CFLAGS) $(CFLAGS) -c -o libdri_la-xf86dri.lo `test -f 'xf86dri.c' || echo '$(srcdir)/'`xf86dri.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdri_ladir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libdri_laLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-libdri_laLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libdri_laLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libdri_laLTLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-libdri_laLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-sdkHEADERS \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-libdri_laLTLIBRARIES uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c new file mode 100644 index 000000000..79934a1c5 --- /dev/null +++ b/xorg-server/hw/xfree86/dri/dri.c @@ -0,0 +1,2478 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, 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: + * Jens Owen <jens@tungstengraphics.com> + * Rickard E. (Rik) Faith <faith@valinux.com> + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include <sys/time.h> +#include <unistd.h> +#include <string.h> +#include <stdio.h> +#include <sys/ioctl.h> +#include <errno.h> + +#define NEED_REPLIES +#define NEED_EVENTS +#include <X11/X.h> +#include <X11/Xproto.h> +#include "xf86drm.h" +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "servermd.h" +#define _XF86DRI_SERVER_ +#include "xf86dristr.h" +#include "swaprep.h" +#include "xf86str.h" +#include "dri.h" +#include "sarea.h" +#include "dristruct.h" +#include "xf86.h" +#include "xf86drm.h" +#include "mi.h" +#include "mipointer.h" +#include "xf86_OSproc.h" + +#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) + +#if !defined(PANORAMIX) +extern Bool noPanoramiXExtension; +#endif + +static int DRIEntPrivIndex = -1; +static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKey; +static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKey; +static unsigned long DRIGeneration = 0; +static unsigned int DRIDrawableValidationStamp = 0; + +static RESTYPE DRIDrawablePrivResType; +static RESTYPE DRIContextPrivResType; +static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv); + +drmServerInfo DRIDRMServerInfo; + + /* Wrapper just like xf86DrvMsg, but + without the verbosity level checking. + This will make it easy to turn off some + messages later, based on verbosity + level. */ + +/* + * Since we're already referencing things from the XFree86 common layer in + * this file, we'd might as well just call xf86VDrvMsgVerb, and have + * consistent message formatting. The verbosity of these messages can be + * easily changed here. + */ +#define DRI_MSG_VERBOSITY 1 +static void +DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + xf86VDrvMsgVerb(scrnIndex, type, DRI_MSG_VERBOSITY, format, ap); + va_end(ap); +} + + +static void +DRIOpenDRMCleanup(DRIEntPrivPtr pDRIEntPriv) +{ + if (pDRIEntPriv->pLSAREA != NULL) { + drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize); + pDRIEntPriv->pLSAREA = NULL; + } + if (pDRIEntPriv->hLSAREA != 0) { + drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA); + } + if (pDRIEntPriv->drmFD >= 0) { + drmClose(pDRIEntPriv->drmFD); + pDRIEntPriv->drmFD = 0; + } +} + +int +DRIMasterFD(ScrnInfoPtr pScrn) +{ + return DRI_ENT_PRIV(pScrn)->drmFD; +} + +void * +DRIMasterSareaPointer(ScrnInfoPtr pScrn) +{ + return DRI_ENT_PRIV(pScrn)->pLSAREA; +} + +drm_handle_t +DRIMasterSareaHandle(ScrnInfoPtr pScrn) +{ + return DRI_ENT_PRIV(pScrn)->hLSAREA; +} + + +Bool +DRIOpenDRMMaster(ScrnInfoPtr pScrn, + unsigned long sAreaSize, + const char *busID, + const char *drmDriverName) +{ + drmSetVersion saveSv, sv; + Bool drmWasAvailable; + DRIEntPrivPtr pDRIEntPriv; + DRIEntPrivRec tmp; + drmVersionPtr drmlibv; + int drmlibmajor, drmlibminor; + const char *openBusID; + int count; + int err; + + if (DRIEntPrivIndex == -1) + DRIEntPrivIndex = xf86AllocateEntityPrivateIndex(); + + pDRIEntPriv = DRI_ENT_PRIV(pScrn); + + if (pDRIEntPriv && pDRIEntPriv->drmFD != -1) + return TRUE; + + drmWasAvailable = drmAvailable(); + + memset(&tmp, 0, sizeof(tmp)); + + /* Check the DRM lib version. + * drmGetLibVersion was not supported in version 1.0, so check for + * symbol first to avoid possible crash or hang. + */ + + drmlibmajor = 1; + drmlibminor = 0; + if (xf86LoaderCheckSymbol("drmGetLibVersion")) { + drmlibv = drmGetLibVersion(-1); + if (drmlibv != NULL) { + drmlibmajor = drmlibv->version_major; + drmlibminor = drmlibv->version_minor; + drmFreeVersion(drmlibv); + } + } + + /* Check if the libdrm can handle falling back to loading based on name + * if a busid string is passed. + */ + openBusID = (drmlibmajor == 1 && drmlibminor >= 2) ? busID : NULL; + + tmp.drmFD = -1; + sv.drm_di_major = 1; + sv.drm_di_minor = 1; + sv.drm_dd_major = -1; + + saveSv = sv; + count = 10; + while (count--) { + tmp.drmFD = drmOpen(drmDriverName, openBusID); + + if (tmp.drmFD < 0) { + DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n"); + goto out_err; + } + + err = drmSetInterfaceVersion(tmp.drmFD, &sv); + + if (err != -EPERM) + break; + + sv = saveSv; + drmClose(tmp.drmFD); + tmp.drmFD = -1; + usleep(100000); + } + + if (tmp.drmFD <= 0) { + DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n"); + goto out_err; + } + + if (!drmWasAvailable) { + DRIDrvMsg(-1, X_INFO, + "[drm] loaded kernel module for \"%s\" driver.\n", + drmDriverName); + } + + if (err != 0) { + sv.drm_di_major = 1; + sv.drm_di_minor = 0; + } + + DRIDrvMsg(-1, X_INFO, "[drm] DRM interface version %d.%d\n", + sv.drm_di_major, sv.drm_di_minor); + + if (sv.drm_di_major == 1 && sv.drm_di_minor >= 1) + err = 0; + else + err = drmSetBusid(tmp.drmFD, busID); + + if (err) { + DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n"); + goto out_err; + } + + /* + * Create a lock-containing sarea. + */ + + if (drmAddMap( tmp.drmFD, 0, sAreaSize, DRM_SHM, + DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) { + DRIDrvMsg(-1, X_INFO, "[drm] Could not create SAREA for DRM lock.\n"); + tmp.hLSAREA = 0; + goto out_err; + } + + if (drmMap( tmp.drmFD, tmp.hLSAREA, sAreaSize, + (drmAddressPtr)(&tmp.pLSAREA)) < 0) { + DRIDrvMsg(-1, X_INFO, "[drm] Mapping SAREA for DRM lock failed.\n"); + tmp.pLSAREA = NULL; + goto out_err; + } + + memset(tmp.pLSAREA, 0, sAreaSize); + + /* + * Reserved contexts are handled by the first opened screen. + */ + + tmp.resOwner = NULL; + + if (!pDRIEntPriv) + pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1); + + if (!pDRIEntPriv) { + DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for " + "DRM device.\n"); + goto out_err; + } + *pDRIEntPriv = tmp; + xf86GetEntityPrivate((pScrn)->entityList[0],DRIEntPrivIndex)->ptr = + pDRIEntPriv; + + DRIDrvMsg(-1, X_INFO, "[drm] DRM open master succeeded.\n"); + return TRUE; + + out_err: + + DRIOpenDRMCleanup(&tmp); + return FALSE; +} + + +Bool +DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) +{ + DRIScreenPrivPtr pDRIPriv; + drm_context_t * reserved; + int reserved_count; + int i; + Bool xineramaInCore = FALSE; + DRIEntPrivPtr pDRIEntPriv; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DRIContextFlags flags = 0; + DRIContextPrivPtr pDRIContextPriv; + + /* If the DRI extension is disabled, do not initialize the DRI */ + if (noXFree86DRIExtension) { + DRIDrvMsg(pScreen->myNum, X_WARNING, + "Direct rendering has been disabled.\n"); + return FALSE; + } + + /* + * If Xinerama is on, don't allow DRI to initialise. It won't be usable + * anyway. + */ + if (xf86LoaderCheckSymbol("noPanoramiXExtension")) + xineramaInCore = TRUE; + + if (xineramaInCore) { + if (!noPanoramiXExtension) { + DRIDrvMsg(pScreen->myNum, X_WARNING, + "Direct rendering is not supported when Xinerama is enabled\n"); + return FALSE; + } + } + + if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize, + pDRIInfo->busIdString, + pDRIInfo->drmDriverName)) + return FALSE; + + pDRIEntPriv = DRI_ENT_PRIV(pScrn); + + DRIScreenPrivKey = &DRIScreenPrivKey; + if (DRIGeneration != serverGeneration) + DRIGeneration = serverGeneration; + + pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec)); + if (!pDRIPriv) { + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + return FALSE; + } + + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv); + pDRIPriv->drmFD = pDRIEntPriv->drmFD; + pDRIPriv->directRenderingSupport = TRUE; + pDRIPriv->pDriverInfo = pDRIInfo; + pDRIPriv->nrWindows = 0; + pDRIPriv->nrWindowsVisible = 0; + pDRIPriv->fullscreen = NULL; + + pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx; + pDRIPriv->createDummyCtxPriv = pDRIInfo->createDummyCtxPriv; + + pDRIPriv->grabbedDRILock = FALSE; + pDRIPriv->drmSIGIOHandlerInstalled = FALSE; + *pDRMFD = pDRIPriv->drmFD; + + if (pDRIEntPriv->sAreaGrabbed || pDRIInfo->allocSarea) { + + if (drmAddMap( pDRIPriv->drmFD, + 0, + pDRIPriv->pDriverInfo->SAREASize, + DRM_SHM, + 0, + &pDRIPriv->hSAREA) < 0) + { + pDRIPriv->directRenderingSupport = FALSE; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmAddMap failed\n"); + return FALSE; + } + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] added %d byte SAREA at %p\n", + pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA); + + /* Backwards compat. */ + if (drmMap( pDRIPriv->drmFD, + pDRIPriv->hSAREA, + pDRIPriv->pDriverInfo->SAREASize, + (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0) + { + pDRIPriv->directRenderingSupport = FALSE; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmMap failed\n"); + return FALSE; + } + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n", + pDRIPriv->hSAREA, pDRIPriv->pSAREA); + memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize); + } else { + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock " + "SAREA also for drawables.\n"); + pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA; + pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA; + pDRIEntPriv->sAreaGrabbed = TRUE; + } + + pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA; + pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA; + + if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer) + { + if (drmAddMap( pDRIPriv->drmFD, + (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, + pDRIPriv->pDriverInfo->frameBufferSize, + DRM_FRAME_BUFFER, + 0, + &pDRIPriv->pDriverInfo->hFrameBuffer) < 0) + { + pDRIPriv->directRenderingSupport = FALSE; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); + drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmAddMap failed\n"); + return FALSE; + } + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n", + pDRIPriv->pDriverInfo->hFrameBuffer); + } else { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] framebuffer mapped by ddx driver\n"); + } + + if (pDRIEntPriv->resOwner == NULL) { + pDRIEntPriv->resOwner = pScreen; + + /* Add tags for reserved contexts */ + if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD, + &reserved_count))) { + int i; + void *tag; + + for (i = 0; i < reserved_count; i++) { + tag = DRICreateContextPrivFromHandle(pScreen, + reserved[i], + DRI_CONTEXT_RESERVED); + drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag); + } + drmFreeReservedContextList(reserved); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] added %d reserved context%s for kernel\n", + reserved_count, reserved_count > 1 ? "s" : ""); + } + } + + /* validate max drawable table entry set by driver */ + if ((pDRIPriv->pDriverInfo->maxDrawableTableEntry <= 0) || + (pDRIPriv->pDriverInfo->maxDrawableTableEntry > SAREA_MAX_DRAWABLES)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "Invalid max drawable table size set by driver: %d\n", + pDRIPriv->pDriverInfo->maxDrawableTableEntry); + } + + /* Initialize drawable tables (screen private and SAREA) */ + for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { + pDRIPriv->DRIDrawables[i] = NULL; + pDRIPriv->pSAREA->drawableTable[i].stamp = 0; + pDRIPriv->pSAREA->drawableTable[i].flags = 0; + } + + pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount; + pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext; + + if (!pDRIEntPriv->keepFDOpen) + pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen; + + pDRIEntPriv->refCount++; + + /* Set up flags for DRICreateContextPriv */ + switch (pDRIInfo->driverSwapMethod) { + case DRI_KERNEL_SWAP: + flags = DRI_CONTEXT_2DONLY; + break; + case DRI_HIDE_X_CONTEXT: + flags = DRI_CONTEXT_PRESERVED; + break; + } + + if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, + &pDRIPriv->myContext, + flags))) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "failed to create server context\n"); + return FALSE; + } + pDRIPriv->myContextPriv = pDRIContextPriv; + + DRIDrvMsg(pScreen->myNum, X_INFO, + "X context handle = %p\n", pDRIPriv->myContext); + + /* Now that we have created the X server's context, we can grab the + * hardware lock for the X server. + */ + DRILock(pScreen, 0); + pDRIPriv->grabbedDRILock = TRUE; + + /* pointers so that we can prevent memory leaks later */ + pDRIPriv->hiddenContextStore = NULL; + pDRIPriv->partial3DContextStore = NULL; + + switch(pDRIInfo->driverSwapMethod) { + case DRI_HIDE_X_CONTEXT: + /* Server will handle 3D swaps, and hide 2D swaps from kernel. + * Register server context as a preserved context. + */ + + /* allocate memory for hidden context store */ + pDRIPriv->hiddenContextStore + = (void *)xcalloc(1, pDRIInfo->contextSize); + if (!pDRIPriv->hiddenContextStore) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "failed to allocate hidden context\n"); + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } + + /* allocate memory for partial 3D context store */ + pDRIPriv->partial3DContextStore + = (void *)xcalloc(1, pDRIInfo->contextSize); + if (!pDRIPriv->partial3DContextStore) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] failed to allocate partial 3D context\n"); + xfree(pDRIPriv->hiddenContextStore); + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } + + /* save initial context store */ + if (pDRIInfo->SwapContext) { + (*pDRIInfo->SwapContext)( + pScreen, + DRI_NO_SYNC, + DRI_2D_CONTEXT, + pDRIPriv->hiddenContextStore, + DRI_NO_CONTEXT, + NULL); + } + /* fall through */ + + case DRI_SERVER_SWAP: + /* For swap methods of DRI_SERVER_SWAP and DRI_HIDE_X_CONTEXT + * setup signal handler for receiving swap requests from kernel + */ + if (!(pDRIPriv->drmSIGIOHandlerInstalled = + drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to setup DRM signal handler\n"); + if (pDRIPriv->hiddenContextStore) + xfree(pDRIPriv->hiddenContextStore); + if (pDRIPriv->partial3DContextStore) + xfree(pDRIPriv->partial3DContextStore); + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } else { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] installed DRM signal handler\n"); + } + + default: + break; + } + + return TRUE; +} + +Bool +DRIFinishScreenInit(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + + /* Wrap DRI support */ + if (pDRIInfo->wrap.ValidateTree) { + pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; + pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree; + } + if (pDRIInfo->wrap.PostValidateTree) { + pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; + pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree; + } + if (pDRIInfo->wrap.WindowExposures) { + pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; + pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures; + } + + pDRIPriv->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = DRIDestroyWindow; + + if (pDRIInfo->wrap.CopyWindow) { + pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow; + } + if (pDRIInfo->wrap.ClipNotify) { + pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify; + } + if (pDRIInfo->wrap.AdjustFrame) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame; + pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame; + } + pDRIPriv->wrapped = TRUE; + + DRIDrvMsg(pScreen->myNum, X_INFO, "[DRI] installation complete\n"); + + return TRUE; +} + +void +DRICloseScreen(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo; + drm_context_t * reserved; + int reserved_count; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn); + Bool closeMaster; + + if (pDRIPriv) { + + pDRIInfo = pDRIPriv->pDriverInfo; + + if (pDRIPriv->wrapped) { + /* Unwrap DRI Functions */ + if (pDRIInfo->wrap.ValidateTree) { + pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; + pDRIPriv->wrap.ValidateTree = NULL; + } + if (pDRIInfo->wrap.PostValidateTree) { + pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; + pDRIPriv->wrap.PostValidateTree = NULL; + } + if (pDRIInfo->wrap.WindowExposures) { + pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; + pDRIPriv->wrap.WindowExposures = NULL; + } + if (pDRIPriv->DestroyWindow) { + pScreen->DestroyWindow = pDRIPriv->DestroyWindow; + pDRIPriv->DestroyWindow = NULL; + } + if (pDRIInfo->wrap.CopyWindow) { + pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; + pDRIPriv->wrap.CopyWindow = NULL; + } + if (pDRIInfo->wrap.ClipNotify) { + pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; + pDRIPriv->wrap.ClipNotify = NULL; + } + if (pDRIInfo->wrap.AdjustFrame) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame; + pDRIPriv->wrap.AdjustFrame = NULL; + } + pDRIPriv->wrapped = FALSE; + } + + if (pDRIPriv->drmSIGIOHandlerInstalled) { + if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to remove DRM signal handler\n"); + } + } + + if (pDRIPriv->dummyCtxPriv && pDRIPriv->createDummyCtx) { + DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv); + } + + if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "failed to destroy server context\n"); + } + + /* Remove tags for reserved contexts */ + if (pDRIEntPriv->resOwner == pScreen) { + pDRIEntPriv->resOwner = NULL; + + if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD, + &reserved_count))) { + int i; + + for (i = 0; i < reserved_count; i++) { + DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD, + reserved[i])); + } + drmFreeReservedContextList(reserved); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] removed %d reserved context%s for kernel\n", + reserved_count, reserved_count > 1 ? "s" : ""); + } + } + + /* Make sure signals get unblocked etc. */ + drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext); + pDRIPriv->pLockRefCount = NULL; + closeMaster = (--pDRIEntPriv->refCount == 0) && + !pDRIEntPriv->keepFDOpen; + if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] unmapping %d bytes of SAREA %p at %p\n", + pDRIInfo->SAREASize, + pDRIPriv->hSAREA, + pDRIPriv->pSAREA); + if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] unable to unmap %d bytes" + " of SAREA %p at %p\n", + pDRIInfo->SAREASize, + pDRIPriv->hSAREA, + pDRIPriv->pSAREA); + } + } else { + pDRIEntPriv->sAreaGrabbed = FALSE; + } + + if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) { + drmClose(pDRIPriv->drmFD); + if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] Closed DRM master.\n"); + pDRIEntPriv->drmFD = -1; + } + } + + xfree(pDRIPriv); + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + } +} + +#define DRM_MSG_VERBOSITY 3 + +static int dri_drm_debug_print(const char *format, va_list ap) +{ + xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap); + return 0; +} + +static void dri_drm_get_perms(gid_t *group, mode_t *mode) +{ + *group = xf86ConfigDRI.group; + *mode = xf86ConfigDRI.mode; +} + +drmServerInfo DRIDRMServerInfo = { + dri_drm_debug_print, + xf86LoadKernelModule, + dri_drm_get_perms, +}; + +Bool +DRIExtensionInit(void) +{ + if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) { + return FALSE; + } + + DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete); + DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete); + + RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL); + + return TRUE; +} + +void +DRIReset(void) +{ + /* + * This stub routine is called when the X Server recycles, resources + * allocated by DRIExtensionInit need to be managed here. + * + * Currently this routine is a stub because all the interesting resources + * are managed via the screen init process. + */ +} + +Bool +DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv) + *isCapable = pDRIPriv->directRenderingSupport; + else + *isCapable = FALSE; + + return TRUE; +} + +Bool +DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + *hSAREA = pDRIPriv->hSAREA; + *busIdString = pDRIPriv->pDriverInfo->busIdString; + + return TRUE; +} + +Bool +DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE; + return TRUE; +} + +Bool +DRICloseConnection(ScreenPtr pScreen) +{ + return TRUE; +} + +Bool +DRIGetClientDriverName(ScreenPtr pScreen, + int *ddxDriverMajorVersion, + int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, + char **clientDriverName) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + *ddxDriverMajorVersion = pDRIPriv->pDriverInfo->ddxDriverMajorVersion; + *ddxDriverMinorVersion = pDRIPriv->pDriverInfo->ddxDriverMinorVersion; + *ddxDriverPatchVersion = pDRIPriv->pDriverInfo->ddxDriverPatchVersion; + *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName; + + return TRUE; +} + +/* DRICreateContextPriv and DRICreateContextPrivFromHandle are helper + functions that layer on drmCreateContext and drmAddContextTag. + + DRICreateContextPriv always creates a kernel drm_context_t and then calls + DRICreateContextPrivFromHandle to create a DRIContextPriv structure for + DRI tracking. For the SIGIO handler, the drm_context_t is associated with + DRIContextPrivPtr. Any special flags are stored in the DRIContextPriv + area and are passed to the kernel (if necessary). + + DRICreateContextPriv returns a pointer to newly allocated + DRIContextPriv, and returns the kernel drm_context_t in pHWContext. */ + +DRIContextPrivPtr +DRICreateContextPriv(ScreenPtr pScreen, + drm_context_t * pHWContext, + DRIContextFlags flags) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (drmCreateContext(pDRIPriv->drmFD, pHWContext)) { + return NULL; + } + + return DRICreateContextPrivFromHandle(pScreen, *pHWContext, flags); +} + +DRIContextPrivPtr +DRICreateContextPrivFromHandle(ScreenPtr pScreen, + drm_context_t hHWContext, + DRIContextFlags flags) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIContextPrivPtr pDRIContextPriv; + int contextPrivSize; + + contextPrivSize = sizeof(DRIContextPrivRec) + + pDRIPriv->pDriverInfo->contextSize; + if (!(pDRIContextPriv = xcalloc(1, contextPrivSize))) { + return NULL; + } + pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1); + + drmAddContextTag(pDRIPriv->drmFD, hHWContext, pDRIContextPriv); + + pDRIContextPriv->hwContext = hHWContext; + pDRIContextPriv->pScreen = pScreen; + pDRIContextPriv->flags = flags; + pDRIContextPriv->valid3D = FALSE; + + if (flags & DRI_CONTEXT_2DONLY) { + if (drmSetContextFlags(pDRIPriv->drmFD, + hHWContext, + DRM_CONTEXT_2DONLY)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to set 2D context flag\n"); + DRIDestroyContextPriv(pDRIContextPriv); + return NULL; + } + } + if (flags & DRI_CONTEXT_PRESERVED) { + if (drmSetContextFlags(pDRIPriv->drmFD, + hHWContext, + DRM_CONTEXT_PRESERVED)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to set preserved flag\n"); + DRIDestroyContextPriv(pDRIContextPriv); + return NULL; + } + } + return pDRIContextPriv; +} + +Bool +DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv) +{ + DRIScreenPrivPtr pDRIPriv; + + if (!pDRIContextPriv) return TRUE; + + pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen); + + if (!(pDRIContextPriv->flags & DRI_CONTEXT_RESERVED)) { + /* Don't delete reserved contexts from + kernel area -- the kernel manages its + reserved contexts itself. */ + if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext)) + return FALSE; + } + + /* Remove the tag last to prevent a race + condition where the context has pending + buffers. The context can't be re-used + while in this thread, but buffers can be + dispatched asynchronously. */ + drmDelContextTag(pDRIPriv->drmFD, pDRIContextPriv->hwContext); + xfree(pDRIContextPriv); + return TRUE; +} + +static Bool +DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIContextPrivPtr pDRIContextPriv; + void *contextStore; + + if (!(pDRIContextPriv = + DRICreateContextPriv(pScreen, + &pDRIPriv->pSAREA->dummy_context, 0))) { + return FALSE; + } + + contextStore = DRIGetContextStore(pDRIContextPriv); + if (pDRIPriv->pDriverInfo->CreateContext && needCtxPriv) { + if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, NULL, + pDRIPriv->pSAREA->dummy_context, + NULL, + (DRIContextType)(long)contextStore)) { + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } + } + + pDRIPriv->dummyCtxPriv = pDRIContextPriv; + return TRUE; +} + +static void +DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIContextPrivPtr pDRIContextPriv = pDRIPriv->dummyCtxPriv; + void *contextStore; + + if (!pDRIContextPriv) return; + if (pDRIPriv->pDriverInfo->DestroyContext && hasCtxPriv) { + contextStore = DRIGetContextStore(pDRIContextPriv); + pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen, + pDRIContextPriv->hwContext, + (DRIContextType)(long)contextStore); + } + + DRIDestroyContextPriv(pDRIPriv->dummyCtxPriv); + pDRIPriv->dummyCtxPriv = NULL; +} + +Bool +DRICreateContext(ScreenPtr pScreen, VisualPtr visual, + XID context, drm_context_t * pHWContext) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIContextPrivPtr pDRIContextPriv; + void *contextStore; + + if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) { + if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] Could not create dummy context\n"); + return FALSE; + } + } + + if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, pHWContext, 0))) { + return FALSE; + } + + contextStore = DRIGetContextStore(pDRIContextPriv); + if (pDRIPriv->pDriverInfo->CreateContext) { + if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, NULL, + *pHWContext, NULL, + (DRIContextType)(long)contextStore))) { + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } + } + + /* track this in case the client dies before cleanup */ + AddResource(context, DRIContextPrivResType, (pointer)pDRIContextPriv); + + return TRUE; +} + +Bool +DRIDestroyContext(ScreenPtr pScreen, XID context) +{ + FreeResourceByType(context, DRIContextPrivResType, FALSE); + + return TRUE; +} + +/* DRIContextPrivDelete is called by the resource manager. */ +Bool +DRIContextPrivDelete(pointer pResource, XID id) +{ + DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource; + DRIScreenPrivPtr pDRIPriv; + void *contextStore; + + pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen); + if (pDRIPriv->pDriverInfo->DestroyContext) { + contextStore = DRIGetContextStore(pDRIContextPriv); + pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen, + pDRIContextPriv->hwContext, + (DRIContextType)(long)contextStore); + } + return DRIDestroyContextPriv(pDRIContextPriv); +} + + +/* This walks the drawable timestamp array and invalidates all of them + * in the case of transition from private to shared backbuffers. It's + * not necessary for correctness, because DRIClipNotify gets called in + * time to prevent any conflict, but the transition from + * shared->private is sometimes missed if we don't do this. + */ +static void +DRIClipNotifyAllDrawables(ScreenPtr pScreen) +{ + int i; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { + pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++; + } +} + + +static void +DRITransitionToSharedBuffers(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + + DRIClipNotifyAllDrawables( pScreen ); + + if (pDRIInfo->TransitionSingleToMulti3D) + pDRIInfo->TransitionSingleToMulti3D( pScreen ); +} + + +static void +DRITransitionToPrivateBuffers(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + + DRIClipNotifyAllDrawables( pScreen ); + + if (pDRIInfo->TransitionMultiToSingle3D) + pDRIInfo->TransitionMultiToSingle3D( pScreen ); +} + + +static void +DRITransitionTo3d(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + + DRIClipNotifyAllDrawables( pScreen ); + + if (pDRIInfo->TransitionTo3d) + pDRIInfo->TransitionTo3d( pScreen ); +} + +static void +DRITransitionTo2d(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + + DRIClipNotifyAllDrawables( pScreen ); + + if (pDRIInfo->TransitionTo2d) + pDRIInfo->TransitionTo2d( pScreen ); +} + + +static int +DRIDCNTreeTraversal(WindowPtr pWin, pointer data) +{ + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + + if (pDRIDrawablePriv) { + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (REGION_NUM_RECTS(&pWin->clipList) > 0) { + WindowPtr *pDRIWindows = (WindowPtr*)data; + int i = 0; + + while (pDRIWindows[i]) + i++; + + pDRIWindows[i] = pWin; + + pDRIPriv->nrWalked++; + } + + if (pDRIPriv->nrWindows == pDRIPriv->nrWalked) + return WT_STOPWALKING; + } + + return WT_WALKCHILDREN; +} + +static void +DRIDriverClipNotify(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv->pDriverInfo->ClipNotify) { + WindowPtr *pDRIWindows = xcalloc(sizeof(WindowPtr), pDRIPriv->nrWindows); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + + if (pDRIPriv->nrWindows > 0) { + pDRIPriv->nrWalked = 0; + TraverseTree(WindowTable[pScreen->myNum], DRIDCNTreeTraversal, + (pointer)pDRIWindows); + } + + pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows); + + xfree(pDRIWindows); + } +} + +static void +DRIIncreaseNumberVisible(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + switch (++pDRIPriv->nrWindowsVisible) { + case 1: + DRITransitionTo3d( pScreen ); + break; + case 2: + DRITransitionToSharedBuffers( pScreen ); + break; + default: + break; + } + + DRIDriverClipNotify(pScreen); +} + +static void +DRIDecreaseNumberVisible(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + switch (--pDRIPriv->nrWindowsVisible) { + case 0: + DRITransitionTo2d( pScreen ); + break; + case 1: + DRITransitionToPrivateBuffers( pScreen ); + break; + default: + break; + } + + DRIDriverClipNotify(pScreen); +} + +Bool +DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable, + drm_drawable_t * hHWDrawable) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv; + WindowPtr pWin; + + if (pDrawable->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr)pDrawable; + if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { + pDRIDrawablePriv->refCount++; + + if (!pDRIDrawablePriv->hwDrawable) { + drmCreateDrawable(pDRIPriv->drmFD, &pDRIDrawablePriv->hwDrawable); + } + } + else { + /* allocate a DRI Window Private record */ + if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) { + return FALSE; + } + + /* Only create a drm_drawable_t once */ + if (drmCreateDrawable(pDRIPriv->drmFD, + &pDRIDrawablePriv->hwDrawable)) { + xfree(pDRIDrawablePriv); + return FALSE; + } + + /* add it to the list of DRI drawables for this screen */ + pDRIDrawablePriv->pScreen = pScreen; + pDRIDrawablePriv->refCount = 1; + pDRIDrawablePriv->drawableIndex = -1; + pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList); + + /* save private off of preallocated index */ + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, + pDRIDrawablePriv); + pDRIPriv->nrWindows++; + + if (pDRIDrawablePriv->nrects) + DRIIncreaseNumberVisible(pScreen); + } + + /* track this in case the client dies */ + AddResource(FakeClientID(client->index), DRIDrawablePrivResType, + (pointer)pDrawable->id); + + if (pDRIDrawablePriv->hwDrawable) { + drmUpdateDrawableInfo(pDRIPriv->drmFD, + pDRIDrawablePriv->hwDrawable, + DRM_DRAWABLE_CLIPRECTS, + REGION_NUM_RECTS(&pWin->clipList), + REGION_RECTS(&pWin->clipList)); + *hHWDrawable = pDRIDrawablePriv->hwDrawable; + } + } + else { /* pixmap (or for GLX 1.3, a PBuffer) */ + /* NOT_DONE */ + return FALSE; + } + + return TRUE; +} + +static void +DRIDrawablePrivDestroy(WindowPtr pWin) +{ + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + ScreenPtr pScreen; + DRIScreenPrivPtr pDRIPriv; + + if (!pDRIDrawablePriv) + return; + + pScreen = pWin->drawable.pScreen; + pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIDrawablePriv->drawableIndex != -1) { + /* bump stamp to force outstanding 3D requests to resync */ + pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp + = DRIDrawableValidationStamp++; + + /* release drawable table entry */ + pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL; + } + + pDRIPriv->nrWindows--; + + if (pDRIDrawablePriv->nrects) + DRIDecreaseNumberVisible(pScreen); + + drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable); + + xfree(pDRIDrawablePriv); + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); +} + +static Bool +DRIDestroyDrawableCB(pointer value, XID id, pointer data) +{ + if (value == data) { + /* This calls back DRIDrawablePrivDelete which frees private area */ + FreeResourceByType(id, DRIDrawablePrivResType, FALSE); + + return TRUE; + } + + return FALSE; +} + +Bool +DRIDestroyDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable) +{ + if (pDrawable->type == DRAWABLE_WINDOW) { + LookupClientResourceComplex(client, DRIDrawablePrivResType, + DRIDestroyDrawableCB, + (pointer)pDrawable->id); + } + else { /* pixmap (or for GLX 1.3, a PBuffer) */ + /* NOT_DONE */ + return FALSE; + } + + return TRUE; +} + +Bool +DRIDrawablePrivDelete(pointer pResource, XID id) +{ + WindowPtr pWin; + + id = (XID)pResource; + pWin = LookupIDByType(id, RT_WINDOW); + + if (pWin) { + DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + + if (!pDRIDrwPriv) + return FALSE; + + if (--pDRIDrwPriv->refCount == 0) + DRIDrawablePrivDestroy(pWin); + + return TRUE; + } + else { /* pixmap (or for GLX 1.3, a PBuffer) */ + /* NOT_DONE */ + return FALSE; + } +} + +Bool +DRIGetDrawableInfo(ScreenPtr pScreen, + DrawablePtr pDrawable, + unsigned int* index, + unsigned int* stamp, + int* X, + int* Y, + int* W, + int* H, + int* numClipRects, + drm_clip_rect_t ** pClipRects, + int* backX, + int* backY, + int* numBackClipRects, + drm_clip_rect_t ** pBackClipRects) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv; + WindowPtr pWin, pOldWin; + int i; + +#if 0 + printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry); +#endif + + if (pDrawable->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr)pDrawable; + if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { + + /* Manage drawable table */ + if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */ + + /* Search table for empty entry */ + i = 0; + while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) { + if (!(pDRIPriv->DRIDrawables[i])) { + pDRIPriv->DRIDrawables[i] = pDrawable; + pDRIDrawablePriv->drawableIndex = i; + pDRIPriv->pSAREA->drawableTable[i].stamp = + DRIDrawableValidationStamp++; + break; + } + i++; + } + + /* Search table for oldest entry */ + if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) { + unsigned int oldestStamp = ~0; + int oldestIndex = 0; + i = pDRIPriv->pDriverInfo->maxDrawableTableEntry; + while (i--) { + if (pDRIPriv->pSAREA->drawableTable[i].stamp < + oldestStamp) { + oldestIndex = i; + oldestStamp = + pDRIPriv->pSAREA->drawableTable[i].stamp; + } + } + pDRIDrawablePriv->drawableIndex = oldestIndex; + + /* release oldest drawable table entry */ + pOldWin = (WindowPtr)pDRIPriv->DRIDrawables[oldestIndex]; + pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin); + pOldDrawPriv->drawableIndex = -1; + + /* claim drawable table entry */ + pDRIPriv->DRIDrawables[oldestIndex] = pDrawable; + + /* validate SAREA entry */ + pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp = + DRIDrawableValidationStamp++; + + /* check for stamp wrap around */ + if (oldestStamp > DRIDrawableValidationStamp) { + + /* walk SAREA table and invalidate all drawables */ + for( i=0; + i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; + i++) { + pDRIPriv->pSAREA->drawableTable[i].stamp = + DRIDrawableValidationStamp++; + } + } + } + + /* If the driver wants to be notified when the index is + * set for a drawable, let it know now. + */ + if (pDRIPriv->pDriverInfo->SetDrawableIndex) + pDRIPriv->pDriverInfo->SetDrawableIndex(pWin, + pDRIDrawablePriv->drawableIndex); + + /* reinit drawable ID if window is visible */ + if ((pWin->viewable) && + (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS)) + { + (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, + &pWin->clipList, pDRIDrawablePriv->drawableIndex); + } + } + + *index = pDRIDrawablePriv->drawableIndex; + *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp; + *X = (int)(pWin->drawable.x); + *Y = (int)(pWin->drawable.y); +#if 0 + *W = (int)(pWin->winSize.extents.x2 - pWin->winSize.extents.x1); + *H = (int)(pWin->winSize.extents.y2 - pWin->winSize.extents.y1); +#endif + *W = (int)(pWin->drawable.width); + *H = (int)(pWin->drawable.height); + *numClipRects = REGION_NUM_RECTS(&pWin->clipList); + *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList); + + if (!*numClipRects && pDRIPriv->fullscreen) { + /* use fake full-screen clip rect */ + pDRIPriv->fullscreen_rect.x1 = *X; + pDRIPriv->fullscreen_rect.y1 = *Y; + pDRIPriv->fullscreen_rect.x2 = *X + *W; + pDRIPriv->fullscreen_rect.y2 = *Y + *H; + + *numClipRects = 1; + *pClipRects = &pDRIPriv->fullscreen_rect; + } + + *backX = *X; + *backY = *Y; + + if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) { + /* Use a single cliprect. */ + + int x0 = *X; + int y0 = *Y; + int x1 = x0 + *W; + int y1 = y0 + *H; + + if (x0 < 0) x0 = 0; + if (y0 < 0) y0 = 0; + if (x1 > pScreen->width) x1 = pScreen->width; + if (y1 > pScreen->height) y1 = pScreen->height; + + if (y0 >= y1 || x0 >= x1) { + *numBackClipRects = 0; + *pBackClipRects = NULL; + } else { + pDRIPriv->private_buffer_rect.x1 = x0; + pDRIPriv->private_buffer_rect.y1 = y0; + pDRIPriv->private_buffer_rect.x2 = x1; + pDRIPriv->private_buffer_rect.y2 = y1; + + *numBackClipRects = 1; + *pBackClipRects = &(pDRIPriv->private_buffer_rect); + } + } else { + /* Use the frontbuffer cliprects for back buffers. */ + *numBackClipRects = 0; + *pBackClipRects = 0; + } + } + else { + /* Not a DRIDrawable */ + return FALSE; + } + } + else { /* pixmap (or for GLX 1.3, a PBuffer) */ + /* NOT_DONE */ + return FALSE; + } + + return TRUE; +} + +Bool +DRIGetDeviceInfo(ScreenPtr pScreen, + drm_handle_t * hFrameBuffer, + int* fbOrigin, + int* fbSize, + int* fbStride, + int* devPrivateSize, + void** pDevPrivate) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + *hFrameBuffer = pDRIPriv->pDriverInfo->hFrameBuffer; + *fbOrigin = 0; + *fbSize = pDRIPriv->pDriverInfo->frameBufferSize; + *fbStride = pDRIPriv->pDriverInfo->frameBufferStride; + *devPrivateSize = pDRIPriv->pDriverInfo->devPrivateSize; + *pDevPrivate = pDRIPriv->pDriverInfo->devPrivate; + + return TRUE; +} + +DRIInfoPtr +DRICreateInfoRec(void) +{ + DRIInfoPtr inforec = (DRIInfoPtr)xcalloc(1, sizeof(DRIInfoRec)); + if (!inforec) return NULL; + + /* Initialize defaults */ + inforec->busIdString = NULL; + + /* Wrapped function defaults */ + inforec->wrap.WakeupHandler = DRIDoWakeupHandler; + inforec->wrap.BlockHandler = DRIDoBlockHandler; + inforec->wrap.WindowExposures = DRIWindowExposures; + inforec->wrap.CopyWindow = DRICopyWindow; + inforec->wrap.ValidateTree = DRIValidateTree; + inforec->wrap.PostValidateTree = DRIPostValidateTree; + inforec->wrap.ClipNotify = DRIClipNotify; + inforec->wrap.AdjustFrame = DRIAdjustFrame; + + inforec->TransitionTo2d = 0; + inforec->TransitionTo3d = 0; + inforec->SetDrawableIndex = 0; + + return inforec; +} + +void +DRIDestroyInfoRec(DRIInfoPtr DRIInfo) +{ + if (DRIInfo->busIdString) xfree(DRIInfo->busIdString); + xfree((char*)DRIInfo); +} + + +void +DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask) +{ + int i; + + for (i = 0; i < screenInfo.numScreens; i++) { + ScreenPtr pScreen = screenInfo.screens[i]; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv && + pDRIPriv->pDriverInfo->wrap.WakeupHandler) + (*pDRIPriv->pDriverInfo->wrap.WakeupHandler)(i, wakeupData, + result, pReadmask); + } +} + +void +DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) +{ + int i; + + for (i = 0; i < screenInfo.numScreens; i++) { + ScreenPtr pScreen = screenInfo.screens[i]; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv && + pDRIPriv->pDriverInfo->wrap.BlockHandler) + (*pDRIPriv->pDriverInfo->wrap.BlockHandler)(i, blockData, + pTimeout, pReadmask); + } +} + +void +DRIDoWakeupHandler(int screenNum, pointer wakeupData, + unsigned long result, pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[screenNum]; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + DRILock(pScreen, 0); + if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { + /* hide X context by swapping 2D component here */ + (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, + DRI_3D_SYNC, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore, + DRI_2D_CONTEXT, + pDRIPriv->hiddenContextStore); + } +} + +void +DRIDoBlockHandler(int screenNum, pointer blockData, + pointer pTimeout, pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[screenNum]; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { + /* hide X context by swapping 2D component here */ + (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, + DRI_2D_SYNC, + DRI_NO_CONTEXT, + NULL, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore); + } + + if (pDRIPriv->windowsTouched) + DRM_SPINUNLOCK(&pDRIPriv->pSAREA->drawable_lock, 1); + pDRIPriv->windowsTouched = FALSE; + + DRIUnlock(pScreen); +} + +void +DRISwapContext(int drmFD, void *oldctx, void *newctx) +{ + DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx; + DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx; + ScreenPtr pScreen = newContext->pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + void* oldContextStore = NULL; + DRIContextType oldContextType; + void* newContextStore = NULL; + DRIContextType newContextType; + DRISyncType syncType; +#ifdef DEBUG + static int count = 0; + + if (!newContext) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n", + oldContext, newContext); + return; + } + + /* usefull for debugging, just print out after n context switches */ + if (!count || !(count % 1)) { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[DRI] Context switch %5d from %p/0x%08x (%d)\n", + count, + oldContext, + oldContext ? oldContext->flags : 0, + oldContext ? oldContext->hwContext : -1); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[DRI] Context switch %5d to %p/0x%08x (%d)\n", + count, + newContext, + newContext ? newContext->flags : 0, + newContext ? newContext->hwContext : -1); + } + ++count; +#endif + + if (!pDRIPriv->pDriverInfo->SwapContext) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] DDX driver missing context swap call back\n"); + return; + } + + if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { + + /* only 3D contexts are swapped in this case */ + if (oldContext) { + oldContextStore = DRIGetContextStore(oldContext); + oldContext->valid3D = TRUE; + oldContextType = DRI_3D_CONTEXT; + } else { + oldContextType = DRI_NO_CONTEXT; + } + newContextStore = DRIGetContextStore(newContext); + if ((newContext->valid3D) && + (newContext->hwContext != pDRIPriv->myContext)) { + newContextType = DRI_3D_CONTEXT; + } + else { + newContextType = DRI_2D_CONTEXT; + } + syncType = DRI_3D_SYNC; + } + else /* default: driverSwapMethod == DRI_SERVER_SWAP */ { + + /* optimize 2D context swaps */ + + if (newContext->flags & DRI_CONTEXT_2DONLY) { + /* go from 3D context to 2D context and only save 2D + * subset of 3D state + */ + oldContextStore = DRIGetContextStore(oldContext); + oldContextType = DRI_2D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + newContextType = DRI_2D_CONTEXT; + syncType = DRI_3D_SYNC; + pDRIPriv->lastPartial3DContext = oldContext; + } + else if (oldContext->flags & DRI_CONTEXT_2DONLY) { + if (pDRIPriv->lastPartial3DContext == newContext) { + /* go from 2D context back to previous 3D context and + * only restore 2D subset of previous 3D state + */ + oldContextStore = DRIGetContextStore(oldContext); + oldContextType = DRI_2D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + newContextType = DRI_2D_CONTEXT; + syncType = DRI_2D_SYNC; + } + else { + /* go from 2D context to a different 3D context */ + + /* call DDX driver to do partial restore */ + oldContextStore = DRIGetContextStore(oldContext); + newContextStore = + DRIGetContextStore(pDRIPriv->lastPartial3DContext); + (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, + DRI_2D_SYNC, + DRI_2D_CONTEXT, + oldContextStore, + DRI_2D_CONTEXT, + newContextStore); + + /* now setup for a complete 3D swap */ + oldContextStore = newContextStore; + oldContext->valid3D = TRUE; + oldContextType = DRI_3D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + if ((newContext->valid3D) && + (newContext->hwContext != pDRIPriv->myContext)) { + newContextType = DRI_3D_CONTEXT; + } + else { + newContextType = DRI_2D_CONTEXT; + } + syncType = DRI_NO_SYNC; + } + } + else { + /* now setup for a complete 3D swap */ + oldContextStore = newContextStore; + oldContext->valid3D = TRUE; + oldContextType = DRI_3D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + if ((newContext->valid3D) && + (newContext->hwContext != pDRIPriv->myContext)) { + newContextType = DRI_3D_CONTEXT; + } + else { + newContextType = DRI_2D_CONTEXT; + } + syncType = DRI_3D_SYNC; + } + } + + /* call DDX driver to perform the swap */ + (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, + syncType, + oldContextType, + oldContextStore, + newContextType, + newContextStore); +} + +void* +DRIGetContextStore(DRIContextPrivPtr context) +{ + return((void *)context->pContextStore); +} + +void +DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + + if(pDRIDrawablePriv) { + (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, prgn, + pDRIDrawablePriv->drawableIndex); + } + + /* call lower wrapped functions */ + if (pDRIPriv && pDRIPriv->wrap.WindowExposures) { + + /* unwrap */ + pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; + + /* call lower layers */ + (*pScreen->WindowExposures)(pWin, prgn, bsreg); + + /* rewrap */ + pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; + pScreen->WindowExposures = DRIWindowExposures; + } +} + + +static int +DRITreeTraversal(WindowPtr pWin, pointer data) +{ + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + + if(pDRIDrawablePriv) { + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if(REGION_NUM_RECTS(&(pWin->clipList)) > 0) { + RegionPtr reg = (RegionPtr)data; + + REGION_UNION(pScreen, reg, reg, &(pWin->clipList)); + pDRIPriv->nrWalked++; + } + + if(pDRIPriv->nrWindows == pDRIPriv->nrWalked) + return WT_STOPWALKING; + } + return WT_WALKCHILDREN; +} + +Bool +DRIDestroyWindow(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + Bool retval = TRUE; + + DRIDrawablePrivDestroy(pWin); + + /* call lower wrapped functions */ + if(pDRIPriv->DestroyWindow) { + /* unwrap */ + pScreen->DestroyWindow = pDRIPriv->DestroyWindow; + + /* call lower layers */ + retval = (*pScreen->DestroyWindow)(pWin); + + /* rewrap */ + pDRIPriv->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = DRIDestroyWindow; + } + + return retval; +} + +void +DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if(!pDRIPriv) return; + + if(pDRIPriv->nrWindowsVisible > 0) { + RegionRec reg; + + REGION_NULL(pScreen, ®); + pDRIPriv->nrWalked = 0; + TraverseTree(pWin, DRITreeTraversal, (pointer)(®)); + + if(REGION_NOTEMPTY(pScreen, ®)) { + REGION_TRANSLATE(pScreen, ®, ptOldOrg.x - pWin->drawable.x, + ptOldOrg.y - pWin->drawable.y); + REGION_INTERSECT(pScreen, ®, ®, prgnSrc); + + /* The MoveBuffers interface is not ideal */ + (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, ®, + pDRIPriv->pDriverInfo->ddxDrawableTableEntry); + } + + REGION_UNINIT(pScreen, ®); + } + + /* call lower wrapped functions */ + if(pDRIPriv->wrap.CopyWindow) { + /* unwrap */ + pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; + + /* call lower layers */ + (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); + + /* rewrap */ + pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = DRICopyWindow; + } +} + +static void +DRIGetSecs(long *secs, long *usecs) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + *secs = tv.tv_sec; + *usecs = tv.tv_usec; +} + +static unsigned long +DRIComputeMilliSeconds(unsigned long s_secs, unsigned long s_usecs, + unsigned long f_secs, unsigned long f_usecs) +{ + if (f_usecs < s_usecs) { + --f_secs; + f_usecs += 1000000; + } + return (f_secs - s_secs) * 1000 + (f_usecs - s_usecs) / 1000; +} + +static void +DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */) +{ + int count = 10000; +#if !defined(__alpha__) && !defined(__powerpc__) + char ret; +#else + int ret; +#endif + long s_secs, s_usecs; + long f_secs, f_usecs; + long msecs; + long prev = 0; + + DRIGetSecs(&s_secs, &s_usecs); + + do { + DRM_SPINLOCK_COUNT(lock, val, count, ret); + if (!ret) return; /* Got lock */ + DRIGetSecs(&f_secs, &f_usecs); + msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs); + if (msecs - prev < 250) count *= 2; /* Not more than 0.5S */ + } while (msecs < timeout); + + /* Didn't get lock, so take it. The worst + that can happen is that there is some + garbage written to the wrong part of the + framebuffer that a refresh will repair. + That's undesirable, but better than + locking the server. This should be a + very rare event. */ + DRM_SPINLOCK_TAKE(lock, val); +} + +static void +DRILockTree(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if(!pDRIPriv) return; + + /* Restore the last known 3D context if the X context is hidden */ + if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { + (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, + DRI_2D_SYNC, + DRI_NO_CONTEXT, + NULL, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore); + } + + /* Call kernel to release lock */ + DRIUnlock(pScreen); + + /* Grab drawable spin lock: a time out between 10 and 30 seconds is + appropriate, since this should never time out except in the case of + client death while the lock is being held. The timeout must be + greater than any reasonable rendering time. */ + DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs*/ + + /* Call kernel flush outstanding buffers and relock */ + DRILock(pScreen, DRM_LOCK_QUIESCENT|DRM_LOCK_FLUSH_ALL); + + /* Switch back to our 2D context if the X context is hidden */ + if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { + /* hide X context by swapping 2D component here */ + (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, + DRI_3D_SYNC, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore, + DRI_2D_CONTEXT, + pDRIPriv->hiddenContextStore); + } +} + +int +DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) +{ + ScreenPtr pScreen = pParent->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + int returnValue = 1; /* always return 1, not checked by dix/window.c */ + + if(!pDRIPriv) return returnValue; + + /* call lower wrapped functions */ + if(pDRIPriv->wrap.ValidateTree) { + /* unwrap */ + pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; + + /* call lower layers */ + returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind); + + /* rewrap */ + pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; + pScreen->ValidateTree = DRIValidateTree; + } + + return returnValue; +} + +void +DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) +{ + ScreenPtr pScreen; + DRIScreenPrivPtr pDRIPriv; + + if (pParent) { + pScreen = pParent->drawable.pScreen; + } else { + pScreen = pChild->drawable.pScreen; + } + if(!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) return; + + if (pDRIPriv->wrap.PostValidateTree) { + /* unwrap */ + pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; + + /* call lower layers */ + (*pScreen->PostValidateTree)(pParent, pChild, kind); + + /* rewrap */ + pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; + pScreen->PostValidateTree = DRIPostValidateTree; + } +} + +void +DRIClipNotify(WindowPtr pWin, int dx, int dy) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv; + + if(!pDRIPriv) return; + + if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { + int nrects = REGION_NUM_RECTS(&pWin->clipList); + + if(!pDRIPriv->windowsTouched) { + DRILockTree(pScreen); + pDRIPriv->windowsTouched = TRUE; + } + + if (nrects && !pDRIDrawablePriv->nrects) + DRIIncreaseNumberVisible(pScreen); + else if (!nrects && pDRIDrawablePriv->nrects) + DRIDecreaseNumberVisible(pScreen); + else + DRIDriverClipNotify(pScreen); + + pDRIDrawablePriv->nrects = nrects; + + pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp + = DRIDrawableValidationStamp++; + + drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable, + DRM_DRAWABLE_CLIPRECTS, + nrects, REGION_RECTS(&pWin->clipList)); + } + + /* call lower wrapped functions */ + if(pDRIPriv->wrap.ClipNotify) { + + /* unwrap */ + pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; + + /* call lower layers */ + (*pScreen->ClipNotify)(pWin, dx, dy); + + /* rewrap */ + pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = DRIClipNotify; + } +} + +CARD32 +DRIGetDrawableIndex(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + CARD32 index; + + if (pDRIDrawablePriv) { + index = pDRIDrawablePriv->drawableIndex; + } + else { + index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry; + } + + return index; +} + +unsigned int +DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp; +} + + +void +DRIPrintDrawableLock(ScreenPtr pScreen, char *msg) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock); +} + +void +DRILock(ScreenPtr pScreen, int flags) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if(!pDRIPriv || !pDRIPriv->pLockRefCount) return; + + if (!*pDRIPriv->pLockRefCount) { + DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, flags); + *pDRIPriv->pLockingContext = pDRIPriv->myContext; + } else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] Locking deadlock.\n" + "\tAlready locked with context %d,\n" + "\ttrying to lock with context %d.\n", + pDRIPriv->pLockingContext, + pDRIPriv->myContext); + } + (*pDRIPriv->pLockRefCount)++; +} + +void +DRIUnlock(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if(!pDRIPriv || !pDRIPriv->pLockRefCount) return; + + if (*pDRIPriv->pLockRefCount > 0) { + if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] Unlocking inconsistency:\n" + "\tContext %d trying to unlock lock held by context %d\n", + pDRIPriv->pLockingContext, + pDRIPriv->myContext); + } + (*pDRIPriv->pLockRefCount)--; + } else { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "DRIUnlock called when not locked.\n"); + return; + } + if (! *pDRIPriv->pLockRefCount) + DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext); +} + +void * +DRIGetSAREAPrivate(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + if (!pDRIPriv) return 0; + + return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec)); +} + +drm_context_t +DRIGetContext(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + if (!pDRIPriv) return 0; + + return pDRIPriv->myContext; +} + +void +DRIGetTexOffsetFuncs(ScreenPtr pScreen, + DRITexOffsetStartProcPtr *texOffsetStartFunc, + DRITexOffsetFinishProcPtr *texOffsetFinishFunc) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (!pDRIPriv) return; + + *texOffsetStartFunc = pDRIPriv->pDriverInfo->texOffsetStart; + *texOffsetFinishFunc = pDRIPriv->pDriverInfo->texOffsetFinish; +} + +/* This lets get at the unwrapped functions so that they can correctly + * call the lowerlevel functions, and choose whether they will be + * called at every level of recursion (eg in validatetree). + */ +DRIWrappedFuncsRec * +DRIGetWrappedFuncs(ScreenPtr pScreen) +{ + return &(DRI_SCREEN_PRIV(pScreen)->wrap); +} + +/* note that this returns the library version, not the protocol version */ +void +DRIQueryVersion(int *majorVersion, + int *minorVersion, + int *patchVersion) +{ + *majorVersion = DRIINFO_MAJOR_VERSION; + *minorVersion = DRIINFO_MINOR_VERSION; + *patchVersion = DRIINFO_PATCH_VERSION; +} + +static void +_DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y) +{ + pDRIPriv->pSAREA->frame.x = x; + pDRIPriv->pSAREA->frame.y = y; + pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1; + pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1; +} + +void +DRIAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[scrnIndex]; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + int px, py; + + if (!pDRIPriv || !pDRIPriv->pSAREA) { + DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n", + pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL); + return; + } + + if (pDRIPriv->fullscreen) { + /* Fix up frame */ + pScrn->frameX0 = pDRIPriv->pSAREA->frame.x; + pScrn->frameY0 = pDRIPriv->pSAREA->frame.y; + pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1; + pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1; + + /* Fix up cursor */ + miPointerPosition(&px, &py); + if (px < pScrn->frameX0) px = pScrn->frameX0; + if (px > pScrn->frameX1) px = pScrn->frameX1; + if (py < pScrn->frameY0) py = pScrn->frameY0; + if (py > pScrn->frameY1) py = pScrn->frameY1; + pScreen->SetCursorPosition(pScreen, px, py, TRUE); + return; + } + + if (pDRIPriv->wrap.AdjustFrame) { + /* unwrap */ + pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame; + /* call lower layers */ + (*pScrn->AdjustFrame)(scrnIndex, x, y, flags); + /* rewrap */ + pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame; + pScrn->AdjustFrame = DRIAdjustFrame; + } + + _DRIAdjustFrame(pScrn, pDRIPriv, x, y); +} + +/* + * DRIMoveBuffersHelper swaps the regions rects in place leaving you + * a region with the rects in the order that you need to blit them, + * but it is possibly (likely) an invalid region afterwards. If you + * need to use the region again for anything you have to call + * REGION_VALIDATE on it, or better yet, save a copy first. + */ + +void +DRIMoveBuffersHelper( + ScreenPtr pScreen, + int dx, + int dy, + int *xdir, + int *ydir, + RegionPtr reg +) +{ + BoxPtr extents, pbox, firstBox, lastBox; + BoxRec tmpBox; + int y, nbox; + + extents = REGION_EXTENTS(pScreen, reg); + nbox = REGION_NUM_RECTS(reg); + pbox = REGION_RECTS(reg); + + if((dy > 0) && (dy < (extents->y2 - extents->y1))) { + *ydir = -1; + if(nbox > 1) { + firstBox = pbox; + lastBox = pbox + nbox - 1; + while((unsigned long)firstBox < (unsigned long)lastBox) { + tmpBox = *firstBox; + *firstBox = *lastBox; + *lastBox = tmpBox; + firstBox++; + lastBox--; + } + } + } else *ydir = 1; + + if((dx > 0) && (dx < (extents->x2 - extents->x1))) { + *xdir = -1; + if(nbox > 1) { + firstBox = lastBox = pbox; + y = pbox->y1; + while(--nbox) { + pbox++; + if(pbox->y1 == y) lastBox++; + else { + while((unsigned long)firstBox < (unsigned long)lastBox) { + tmpBox = *firstBox; + *firstBox = *lastBox; + *lastBox = tmpBox; + firstBox++; + lastBox--; + } + + firstBox = lastBox = pbox; + y = pbox->y1; + } + } + while((unsigned long)firstBox < (unsigned long)lastBox) { + tmpBox = *firstBox; + *firstBox = *lastBox; + *lastBox = tmpBox; + firstBox++; + lastBox--; + } + } + } else *xdir = 1; + +} + +char * +DRICreatePCIBusID(const struct pci_device * dev) +{ + char *busID; + + busID = xalloc(20); + if (busID == NULL) + return NULL; + + snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", dev->domain, dev->bus, + dev->dev, dev->func); + + return busID; +} + +static void drmSIGIOHandler(int interrupt, void *closure) +{ + unsigned long key; + void *value; + ssize_t count; + drm_ctx_t ctx; + typedef void (*_drmCallback)(int, void *, void *); + char buf[256]; + drm_context_t old; + drm_context_t new; + void *oldctx; + void *newctx; + char *pt; + drmHashEntry *entry; + void *hash_table; + + hash_table = drmGetHashTable(); + + if (!hash_table) return; + if (drmHashFirst(hash_table, &key, &value)) { + entry = value; + do { +#if 0 + fprintf(stderr, "Trying %d\n", entry->fd); +#endif + if ((count = read(entry->fd, buf, sizeof(buf))) > 0) { + buf[count] = '\0'; +#if 0 + fprintf(stderr, "Got %s\n", buf); +#endif + + for (pt = buf; *pt != ' '; ++pt); /* Find first space */ + ++pt; + old = strtol(pt, &pt, 0); + new = strtol(pt, NULL, 0); + oldctx = drmGetContextTag(entry->fd, old); + newctx = drmGetContextTag(entry->fd, new); +#if 0 + fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx); +#endif + ((_drmCallback)entry->f)(entry->fd, oldctx, newctx); + ctx.handle = new; + ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx); + } + } while (drmHashNext(hash_table, &key, &value)); + } +} + + +int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *)) +{ + drmHashEntry *entry; + + entry = drmGetEntry(fd); + entry->f = f; + + return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0); +} + +int drmRemoveSIGIOHandler(int fd) +{ + drmHashEntry *entry = drmGetEntry(fd); + + entry->f = NULL; + + return xf86RemoveSIGIOHandler(fd); +} diff --git a/xorg-server/hw/xfree86/dri/dri.h b/xorg-server/hw/xfree86/dri/dri.h new file mode 100644 index 000000000..516da97a5 --- /dev/null +++ b/xorg-server/hw/xfree86/dri/dri.h @@ -0,0 +1,384 @@ +/************************************************************************** + +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: + * Jens Owen <jens@tungstengraphics.com> + * + */ + +/* Prototypes for DRI functions */ + +#ifndef _DRI_H_ + +#include <pciaccess.h> + +#include "scrnintstr.h" +#include "xf86dri.h" + +typedef int DRISyncType; + +#define DRI_NO_SYNC 0 +#define DRI_2D_SYNC 1 +#define DRI_3D_SYNC 2 + +typedef int DRIContextType; + +typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr; + +typedef enum _DRIContextFlags +{ + DRI_CONTEXT_2DONLY = 0x01, + DRI_CONTEXT_PRESERVED = 0x02, + DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */ +} DRIContextFlags; + +#define DRI_NO_CONTEXT 0 +#define DRI_2D_CONTEXT 1 +#define DRI_3D_CONTEXT 2 + +typedef int DRISwapMethod; + +#define DRI_HIDE_X_CONTEXT 0 +#define DRI_SERVER_SWAP 1 +#define DRI_KERNEL_SWAP 2 + +typedef int DRIWindowRequests; + +#define DRI_NO_WINDOWS 0 +#define DRI_3D_WINDOWS_ONLY 1 +#define DRI_ALL_WINDOWS 2 + + +typedef void (*ClipNotifyPtr)( WindowPtr, int, int ); +typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags); + + +/* + * These functions can be wrapped by the DRI. Each of these have + * generic default funcs (initialized in DRICreateInfoRec) and can be + * overridden by the driver in its [driver]DRIScreenInit function. + */ +typedef struct { + ScreenWakeupHandlerProcPtr WakeupHandler; + ScreenBlockHandlerProcPtr BlockHandler; + WindowExposuresProcPtr WindowExposures; + CopyWindowProcPtr CopyWindow; + ValidateTreeProcPtr ValidateTree; + PostValidateTreeProcPtr PostValidateTree; + ClipNotifyProcPtr ClipNotify; + AdjustFramePtr AdjustFrame; +} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr; + + +/* + * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned + * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also + * being used to version the XFree86-DRI protocol. Bugs #3066 and #3163 + * showed that this was inadequate. The DRIInfoRec structure is now versioned + * by the DRIINFO_*_VERSION defines in this file. - ajax, 2005-05-18. + * + * Revision history: + * 4.1.0 and earlier: DRIQueryVersion returns XF86DRI_*_VERSION. + * 4.2.0: DRIQueryVersion begins returning DRIINFO_*_VERSION. + * 5.0.0: frameBufferPhysicalAddress changed from CARD32 to pointer. + */ + +#define DRIINFO_MAJOR_VERSION 5 +#define DRIINFO_MINOR_VERSION 4 +#define DRIINFO_PATCH_VERSION 0 + +typedef unsigned long long (*DRITexOffsetStartProcPtr)(PixmapPtr pPix); +typedef void (*DRITexOffsetFinishProcPtr)(PixmapPtr pPix); + +typedef struct { + /* driver call back functions + * + * New fields should be added at the end for backwards compatibility. + * Bump the DRIINFO patch number to indicate bugfixes. + * Bump the DRIINFO minor number to indicate new fields. + * Bump the DRIINFO major number to indicate binary-incompatible changes. + */ + Bool (*CreateContext)(ScreenPtr pScreen, + VisualPtr visual, + drm_context_t hHWContext, + void* pVisualConfigPriv, + DRIContextType context); + void (*DestroyContext)(ScreenPtr pScreen, + drm_context_t hHWContext, + DRIContextType context); + void (*SwapContext)(ScreenPtr pScreen, + DRISyncType syncType, + DRIContextType readContextType, + void* readContextStore, + DRIContextType writeContextType, + void* writeContextStore); + void (*InitBuffers)(WindowPtr pWin, + RegionPtr prgn, + CARD32 indx); + void (*MoveBuffers)(WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc, + CARD32 indx); + void (*TransitionTo3d)(ScreenPtr pScreen); + void (*TransitionTo2d)(ScreenPtr pScreen); + + void (*SetDrawableIndex)(WindowPtr pWin, CARD32 indx); + Bool (*OpenFullScreen)(ScreenPtr pScreen); + Bool (*CloseFullScreen)(ScreenPtr pScreen); + + /* wrapped functions */ + DRIWrappedFuncsRec wrap; + + /* device info */ + char* drmDriverName; + char* clientDriverName; + char* busIdString; + int ddxDriverMajorVersion; + int ddxDriverMinorVersion; + int ddxDriverPatchVersion; + pointer frameBufferPhysicalAddress; + long frameBufferSize; + long frameBufferStride; + long SAREASize; + int maxDrawableTableEntry; + int ddxDrawableTableEntry; + long contextSize; + DRISwapMethod driverSwapMethod; + DRIWindowRequests bufferRequests; + int devPrivateSize; + void* devPrivate; + Bool createDummyCtx; + Bool createDummyCtxPriv; + + /* New with DRI version 4.1.0 */ + void (*TransitionSingleToMulti3D)(ScreenPtr pScreen); + void (*TransitionMultiToSingle3D)(ScreenPtr pScreen); + + /* New with DRI version 5.1.0 */ + void (*ClipNotify)(ScreenPtr pScreen, WindowPtr *ppWin, int num); + + /* New with DRI version 5.2.0 */ + Bool allocSarea; + Bool keepFDOpen; + + /* New with DRI version 5.3.0 */ + DRITexOffsetStartProcPtr texOffsetStart; + DRITexOffsetFinishProcPtr texOffsetFinish; + + /* New with DRI version 5.4.0 */ + int dontMapFrameBuffer; + drm_handle_t hFrameBuffer; /* Handle to framebuffer, either + * mapped by DDX driver or DRI */ + +} DRIInfoRec, *DRIInfoPtr; + + +extern Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, unsigned long sAreaSize, + const char *busID, + const char *drmDriverName); + +extern Bool DRIScreenInit(ScreenPtr pScreen, + DRIInfoPtr pDRIInfo, + int *pDRMFD); + +extern void DRICloseScreen(ScreenPtr pScreen); + +extern Bool DRIExtensionInit(void); + +extern void DRIReset(void); + +extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, + Bool *isCapable); + +extern Bool DRIOpenConnection(ScreenPtr pScreen, + drm_handle_t * hSAREA, + char **busIdString); + +extern Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic); + +extern Bool DRICloseConnection(ScreenPtr pScreen); + +extern Bool DRIGetClientDriverName(ScreenPtr pScreen, + int* ddxDriverMajorVersion, + int* ddxDriverMinorVersion, + int* ddxDriverPatchVersion, + char** clientDriverName); + +extern Bool DRICreateContext(ScreenPtr pScreen, + VisualPtr visual, + XID context, + drm_context_t * pHWContext); + +extern Bool DRIDestroyContext(ScreenPtr pScreen, XID context); + +extern Bool DRIContextPrivDelete(pointer pResource, XID id); + +extern Bool DRICreateDrawable(ScreenPtr pScreen, + ClientPtr client, + DrawablePtr pDrawable, + drm_drawable_t * hHWDrawable); + +extern Bool DRIDestroyDrawable(ScreenPtr pScreen, + ClientPtr client, + DrawablePtr pDrawable); + +extern Bool DRIDrawablePrivDelete(pointer pResource, + XID id); + +extern Bool DRIGetDrawableInfo(ScreenPtr pScreen, + DrawablePtr pDrawable, + unsigned int* indx, + unsigned int* stamp, + int* X, + int* Y, + int* W, + int* H, + int* numClipRects, + drm_clip_rect_t ** pClipRects, + int* backX, + int* backY, + int* numBackClipRects, + drm_clip_rect_t ** pBackClipRects); + +extern Bool DRIGetDeviceInfo(ScreenPtr pScreen, + drm_handle_t * hFrameBuffer, + int* fbOrigin, + int* fbSize, + int* fbStride, + int* devPrivateSize, + void** pDevPrivate); + +extern DRIInfoPtr DRICreateInfoRec(void); + +extern void DRIDestroyInfoRec(DRIInfoPtr DRIInfo); + +extern Bool DRIFinishScreenInit(ScreenPtr pScreen); + +extern void DRIWakeupHandler(pointer wakeupData, + int result, + pointer pReadmask); + +extern void DRIBlockHandler(pointer blockData, + OSTimePtr pTimeout, + pointer pReadmask); + +extern void DRIDoWakeupHandler(int screenNum, + pointer wakeupData, + unsigned long result, + pointer pReadmask); + +extern void DRIDoBlockHandler(int screenNum, + pointer blockData, + pointer pTimeout, + pointer pReadmask); + +extern void DRISwapContext(int drmFD, + void *oldctx, + void *newctx); + +extern void *DRIGetContextStore(DRIContextPrivPtr context); + +extern void DRIWindowExposures(WindowPtr pWin, + RegionPtr prgn, + RegionPtr bsreg); + +extern Bool DRIDestroyWindow(WindowPtr pWin); + +extern void DRICopyWindow(WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc); + +extern int DRIValidateTree(WindowPtr pParent, + WindowPtr pChild, + VTKind kind); + +extern void DRIPostValidateTree(WindowPtr pParent, + WindowPtr pChild, + VTKind kind); + +extern void DRIClipNotify(WindowPtr pWin, + int dx, + int dy); + +extern CARD32 DRIGetDrawableIndex(WindowPtr pWin); + +extern void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg); + +extern void DRILock(ScreenPtr pScreen, int flags); + +extern void DRIUnlock(ScreenPtr pScreen); + +extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen); + +extern void *DRIGetSAREAPrivate(ScreenPtr pScreen); + +extern unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, + CARD32 drawable_index); + +extern DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, + drm_context_t * pHWContext, + DRIContextFlags flags); + +extern DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen, + drm_context_t hHWContext, + DRIContextFlags flags); + +extern Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); + +extern drm_context_t DRIGetContext(ScreenPtr pScreen); + +extern void DRIQueryVersion(int *majorVersion, + int *minorVersion, + int *patchVersion); + +extern void DRIAdjustFrame(int scrnIndex, int x, int y, int flags); + +extern void DRIMoveBuffersHelper(ScreenPtr pScreen, + int dx, + int dy, + int *xdir, + int *ydir, + RegionPtr reg); + +extern char *DRICreatePCIBusID(const struct pci_device *PciInfo); + +extern int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *)); +extern int drmRemoveSIGIOHandler(int fd); +extern int DRIMasterFD(ScrnInfoPtr pScrn); + +extern void *DRIMasterSareaPointer(ScrnInfoPtr pScrn); + +extern drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn); + +extern void DRIGetTexOffsetFuncs(ScreenPtr pScreen, + DRITexOffsetStartProcPtr *texOffsetStartFunc, + DRITexOffsetFinishProcPtr *texOffsetFinishFunc); + +#define _DRI_H_ + +#endif diff --git a/xorg-server/hw/xfree86/dri/drimodule.c b/xorg-server/hw/xfree86/dri/drimodule.c new file mode 100644 index 000000000..3aa9245b9 --- /dev/null +++ b/xorg-server/hw/xfree86/dri/drimodule.c @@ -0,0 +1,93 @@ +/************************************************************************** + +Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, 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: + * Kevin E. Martin <kevin@precisioninsight.com> + * Rickard E. Faith <faith@precisioninsight.com> + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" +#include "globals.h" + +#include "xf86drm.h" +static MODULESETUPPROTO(driSetup); + +drmServerInfo DRIDRMServerInfo; + +static XF86ModuleVersionInfo VersRec = +{ + "dri", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +extern void XFree86DRIExtensionInit(INITARGS); +#define _XF86DRI_SERVER_ +#include "xf86dristr.h" + +static ExtensionModule XF86DRIExt = +{ + XFree86DRIExtensionInit, + XF86DRINAME, + &noXFree86DRIExtension, + NULL, + NULL +}; + +_X_EXPORT XF86ModuleData driModuleData = { &VersRec, driSetup, NULL }; + +static pointer +driSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) { + setupDone = TRUE; + LoadExtension(&XF86DRIExt, FALSE); + } else { + if (errmaj) *errmaj = LDR_ONCEONLY; + } + + drmSetServerInfo(&DRIDRMServerInfo); + + /* Need a non-NULL return value to indicate success */ + return (pointer)1; +} + diff --git a/xorg-server/hw/xfree86/dri/dristruct.h b/xorg-server/hw/xfree86/dri/dristruct.h new file mode 100644 index 000000000..ae970d834 --- /dev/null +++ b/xorg-server/hw/xfree86/dri/dristruct.h @@ -0,0 +1,126 @@ +/************************************************************************** + +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: + * Jens Owen <jens@tungstengraphics.com> + * + */ + +#ifndef DRI_STRUCT_H +#define DRI_STRUCT_H + +#include "xf86drm.h" + + +#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey)) +#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey)) + +typedef struct _DRIDrawablePrivRec +{ + drm_drawable_t hwDrawable; + int drawableIndex; + ScreenPtr pScreen; + int refCount; + int nrects; +} DRIDrawablePrivRec, *DRIDrawablePrivPtr; + +struct _DRIContextPrivRec +{ + drm_context_t hwContext; + ScreenPtr pScreen; + Bool valid3D; + DRIContextFlags flags; + void** pContextStore; +}; + +#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey)) + +#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ + dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \ + DRIScreenPrivKey)) + +#define DRI_ENT_PRIV(pScrn) \ + ((DRIEntPrivIndex < 0) ? \ + NULL: \ + ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \ + DRIEntPrivIndex)->ptr))) + +typedef struct _DRIScreenPrivRec +{ + Bool directRenderingSupport; + int drmFD; /* File descriptor for /dev/video/? */ + drm_handle_t hSAREA; /* Handle to SAREA, for mapping */ + XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */ + drm_context_t myContext; /* DDX Driver's context */ + DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */ + DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */ + void** hiddenContextStore; /* hidden X context */ + void** partial3DContextStore; /* parital 3D context */ + DRIInfoPtr pDriverInfo; + int nrWindows; + int nrWindowsVisible; + int nrWalked; + drm_clip_rect_t private_buffer_rect; /* management of private buffers */ + DrawablePtr fullscreen; /* pointer to fullscreen drawable */ + drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */ + DRIWrappedFuncsRec wrap; + DestroyWindowProcPtr DestroyWindow; + DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES]; + DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */ + Bool createDummyCtx; + Bool createDummyCtxPriv; + Bool grabbedDRILock; + Bool drmSIGIOHandlerInstalled; + Bool wrapped; + Bool windowsTouched; + int lockRefCount; + drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */ + XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */ + int* pLockRefCount; + int* pLockingContext; +} DRIScreenPrivRec, *DRIScreenPrivPtr; + + +typedef struct _DRIEntPrivRec { + int drmFD; + Bool drmOpened; + Bool sAreaGrabbed; + drm_handle_t hLSAREA; + XF86DRILSAREAPtr pLSAREA; + unsigned long sAreaSize; + int lockRefCount; + int lockingContext; + ScreenPtr resOwner; + Bool keepFDOpen; + int refCount; +} DRIEntPrivRec, *DRIEntPrivPtr; + +#endif /* DRI_STRUCT_H */ diff --git a/xorg-server/hw/xfree86/dri/sarea.h b/xorg-server/hw/xfree86/dri/sarea.h new file mode 100644 index 000000000..1528cc191 --- /dev/null +++ b/xorg-server/hw/xfree86/dri/sarea.h @@ -0,0 +1,97 @@ +/** + * \file sarea.h + * SAREA definitions. + * + * \author Kevin E. Martin <kevin@precisioninsight.com> + * \author Jens Owen <jens@tungstengraphics.com> + * \author Rickard E. (Rik) Faith <faith@valinux.com> + */ + +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, 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. + */ + + +#ifndef _SAREA_H_ +#define _SAREA_H_ + +#include "xf86drm.h" + +/* SAREA area needs to be at least a page */ +#if defined(__alpha__) +#define SAREA_MAX 0x2000 +#elif defined(__ia64__) +#define SAREA_MAX 0x10000 /* 64kB */ +#else +/* Intel 830M driver needs at least 8k SAREA */ +#define SAREA_MAX 0x2000 +#endif + +#define SAREA_MAX_DRAWABLES 256 + +#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000 + +/** + * SAREA per drawable information. + * + * \sa _XF86DRISAREA. + */ +typedef struct _XF86DRISAREADrawable { + unsigned int stamp; + unsigned int flags; +} XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr; + +/** + * SAREA frame information. + * + * \sa _XF86DRISAREA. + */ +typedef struct _XF86DRISAREAFrame { + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + unsigned int fullscreen; +} XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr; + +/** + * SAREA definition. + */ +typedef struct _XF86DRISAREA { + /** first thing is always the DRM locking structure */ + drmLock lock; + /** \todo Use readers/writer lock for drawable_lock */ + drmLock drawable_lock; + XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES]; + XF86DRISAREAFrameRec frame; + drm_context_t dummy_context; +} XF86DRISAREARec, *XF86DRISAREAPtr; + +typedef struct _XF86DRILSAREA { + drmLock lock; + drmLock otherLocks[31]; +} XF86DRILSAREARec, *XF86DRILSAREAPtr; + +#endif diff --git a/xorg-server/hw/xfree86/dri/xf86dri.c b/xorg-server/hw/xfree86/dri/xf86dri.c new file mode 100644 index 000000000..ea11b38ee --- /dev/null +++ b/xorg-server/hw/xfree86/dri/xf86dri.c @@ -0,0 +1,680 @@ +/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, 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: + * Kevin E. Martin <martin@valinux.com> + * Jens Owen <jens@tungstengraphics.com> + * Rickard E. (Rik) Faith <faith@valinux.com> + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "xf86.h" + +#define NEED_REPLIES +#define NEED_EVENTS +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86DRI_SERVER_ +#include "xf86dristr.h" +#include "swaprep.h" +#include "xf86str.h" +#include "dri.h" +#include "sarea.h" +#include "dristruct.h" +#include "xf86.h" +#include "xf86drm.h" + +static int DRIErrorBase; + +static DISPATCH_PROC(ProcXF86DRIQueryVersion); +static DISPATCH_PROC(ProcXF86DRIQueryDirectRenderingCapable); +static DISPATCH_PROC(ProcXF86DRIOpenConnection); +static DISPATCH_PROC(ProcXF86DRICloseConnection); +static DISPATCH_PROC(ProcXF86DRIGetClientDriverName); +static DISPATCH_PROC(ProcXF86DRICreateContext); +static DISPATCH_PROC(ProcXF86DRIDestroyContext); +static DISPATCH_PROC(ProcXF86DRICreateDrawable); +static DISPATCH_PROC(ProcXF86DRIDestroyDrawable); +static DISPATCH_PROC(ProcXF86DRIGetDrawableInfo); +static DISPATCH_PROC(ProcXF86DRIGetDeviceInfo); +static DISPATCH_PROC(ProcXF86DRIDispatch); +static DISPATCH_PROC(ProcXF86DRIAuthConnection); + +static DISPATCH_PROC(SProcXF86DRIQueryVersion); +static DISPATCH_PROC(SProcXF86DRIQueryDirectRenderingCapable); +static DISPATCH_PROC(SProcXF86DRIDispatch); + +static void XF86DRIResetProc(ExtensionEntry* extEntry); + +static unsigned char DRIReqCode = 0; + +extern void XFree86DRIExtensionInit(void); + +void +XFree86DRIExtensionInit(void) +{ + ExtensionEntry* extEntry; + +#ifdef XF86DRI_EVENTS + EventType = CreateNewResourceType(XF86DRIFreeEvents); +#endif + + if ( + DRIExtensionInit() && +#ifdef XF86DRI_EVENTS + EventType && ScreenPrivateIndex != -1 && +#endif + (extEntry = AddExtension(XF86DRINAME, + XF86DRINumberEvents, + XF86DRINumberErrors, + ProcXF86DRIDispatch, + SProcXF86DRIDispatch, + XF86DRIResetProc, + StandardMinorOpcode))) { + DRIReqCode = (unsigned char)extEntry->base; + DRIErrorBase = extEntry->errorBase; + } +} + +/*ARGSUSED*/ +static void +XF86DRIResetProc ( + ExtensionEntry* extEntry +) +{ + DRIReset(); +} + +static int +ProcXF86DRIQueryVersion( + register ClientPtr client +) +{ + xXF86DRIQueryVersionReply rep; + register int n; + + REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XF86DRI_MAJOR_VERSION; + rep.minorVersion = XF86DRI_MINOR_VERSION; + rep.patchVersion = XF86DRI_PATCH_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + swapl(&rep.patchVersion, n); + } + WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DRIQueryDirectRenderingCapable( + register ClientPtr client +) +{ + xXF86DRIQueryDirectRenderingCapableReply rep; + Bool isCapable; + register int n; + + REQUEST(xXF86DRIQueryDirectRenderingCapableReq); + REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen], + &isCapable)) { + return BadValue; + } + rep.isCapable = isCapable; + + if (!LocalClient(client) || client->swapped) + rep.isCapable = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + } + + WriteToClient(client, + sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DRIOpenConnection( + register ClientPtr client +) +{ + xXF86DRIOpenConnectionReply rep; + drm_handle_t hSAREA; + char* busIdString; + + REQUEST(xXF86DRIOpenConnectionReq); + REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + if (!DRIOpenConnection( screenInfo.screens[stuff->screen], + &hSAREA, + &busIdString)) { + return BadValue; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.busIdStringLength = 0; + if (busIdString) + rep.busIdStringLength = strlen(busIdString); + rep.length = (SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) + + ((rep.busIdStringLength + 3) & ~3)) >> 2; + + rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff); +#if defined(LONG64) && !defined(__linux__) + rep.hSAREAHigh = (CARD32)(hSAREA >> 32); +#else + rep.hSAREAHigh = 0; +#endif + + WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep); + if (rep.busIdStringLength) + WriteToClient(client, rep.busIdStringLength, busIdString); + return (client->noClientException); +} + +static int +ProcXF86DRIAuthConnection( + register ClientPtr client +) +{ + xXF86DRIAuthConnectionReply rep; + + REQUEST(xXF86DRIAuthConnectionReq); + REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.authenticated = 1; + + if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) { + ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic); + rep.authenticated = 0; + } + WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DRICloseConnection( + register ClientPtr client +) +{ + REQUEST(xXF86DRICloseConnectionReq); + REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + DRICloseConnection( screenInfo.screens[stuff->screen]); + + return (client->noClientException); +} + +static int +ProcXF86DRIGetClientDriverName( + register ClientPtr client +) +{ + xXF86DRIGetClientDriverNameReply rep; + char* clientDriverName; + + REQUEST(xXF86DRIGetClientDriverNameReq); + REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + DRIGetClientDriverName( screenInfo.screens[stuff->screen], + (int *)&rep.ddxDriverMajorVersion, + (int *)&rep.ddxDriverMinorVersion, + (int *)&rep.ddxDriverPatchVersion, + &clientDriverName); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.clientDriverNameLength = 0; + if (clientDriverName) + rep.clientDriverNameLength = strlen(clientDriverName); + rep.length = (SIZEOF(xXF86DRIGetClientDriverNameReply) - + SIZEOF(xGenericReply) + + ((rep.clientDriverNameLength + 3) & ~3)) >> 2; + + WriteToClient(client, + sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep); + if (rep.clientDriverNameLength) + WriteToClient(client, + rep.clientDriverNameLength, + clientDriverName); + return (client->noClientException); +} + +static int +ProcXF86DRICreateContext( + register ClientPtr client +) +{ + xXF86DRICreateContextReply rep; + ScreenPtr pScreen; + + REQUEST(xXF86DRICreateContextReq); + REQUEST_SIZE_MATCH(xXF86DRICreateContextReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + pScreen = screenInfo.screens[stuff->screen]; + + if (!DRICreateContext( pScreen, + NULL, + stuff->context, + (drm_context_t *)&rep.hHWContext)) { + return BadValue; + } + + WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DRIDestroyContext( + register ClientPtr client +) +{ + REQUEST(xXF86DRIDestroyContextReq); + REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + if (!DRIDestroyContext( screenInfo.screens[stuff->screen], + stuff->context)) { + return BadValue; + } + + return (client->noClientException); +} + +static int +ProcXF86DRICreateDrawable( + ClientPtr client +) +{ + xXF86DRICreateDrawableReply rep; + DrawablePtr pDrawable; + int rc; + + REQUEST(xXF86DRICreateDrawableReq); + REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client, + pDrawable, (drm_drawable_t *)&rep.hHWDrawable)) { + return BadValue; + } + + WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DRIDestroyDrawable( + register ClientPtr client +) +{ + REQUEST(xXF86DRIDestroyDrawableReq); + DrawablePtr pDrawable; + REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq); + int rc; + + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + if (!DRIDestroyDrawable(screenInfo.screens[stuff->screen], client, + pDrawable)) { + return BadValue; + } + + return (client->noClientException); +} + +static int +ProcXF86DRIGetDrawableInfo( + register ClientPtr client +) +{ + xXF86DRIGetDrawableInfoReply rep; + DrawablePtr pDrawable; + int X, Y, W, H; + drm_clip_rect_t * pClipRects, *pClippedRects; + drm_clip_rect_t * pBackClipRects; + int backX, backY, rc; + + REQUEST(xXF86DRIGetDrawableInfoReq); + REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, + DixReadAccess); + if (rc != Success) + return rc; + + if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen], + pDrawable, + (unsigned int*)&rep.drawableTableIndex, + (unsigned int*)&rep.drawableTableStamp, + (int*)&X, + (int*)&Y, + (int*)&W, + (int*)&H, + (int*)&rep.numClipRects, + &pClipRects, + &backX, + &backY, + (int*)&rep.numBackClipRects, + &pBackClipRects)) { + return BadValue; + } + + rep.drawableX = X; + rep.drawableY = Y; + rep.drawableWidth = W; + rep.drawableHeight = H; + rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - + SIZEOF(xGenericReply)); + + rep.backX = backX; + rep.backY = backY; + + if (rep.numBackClipRects) + rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects; + + pClippedRects = pClipRects; + + if (rep.numClipRects) { + /* Clip cliprects to screen dimensions (redirected windows) */ + pClippedRects = xalloc(rep.numClipRects * sizeof(drm_clip_rect_t)); + + if (pClippedRects) { + ScreenPtr pScreen = screenInfo.screens[stuff->screen]; + int i, j; + + for (i = 0, j = 0; i < rep.numClipRects; i++) { + pClippedRects[j].x1 = max(pClipRects[i].x1, 0); + pClippedRects[j].y1 = max(pClipRects[i].y1, 0); + pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width); + pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height); + + if (pClippedRects[j].x1 < pClippedRects[j].x2 && + pClippedRects[j].y1 < pClippedRects[j].y2) { + j++; + } + } + + rep.numClipRects = j; + } else { + rep.numClipRects = 0; + } + + rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects; + } + + rep.length = ((rep.length + 3) & ~3) >> 2; + + WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep); + + if (rep.numClipRects) { + WriteToClient(client, + sizeof(drm_clip_rect_t) * rep.numClipRects, + (char *)pClippedRects); + xfree(pClippedRects); + } + + if (rep.numBackClipRects) { + WriteToClient(client, + sizeof(drm_clip_rect_t) * rep.numBackClipRects, + (char *)pBackClipRects); + } + + return (client->noClientException); +} + +static int +ProcXF86DRIGetDeviceInfo( + register ClientPtr client +) +{ + xXF86DRIGetDeviceInfoReply rep; + drm_handle_t hFrameBuffer; + void *pDevPrivate; + + REQUEST(xXF86DRIGetDeviceInfoReq); + REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq); + if (stuff->screen >= screenInfo.numScreens) { + client->errorValue = stuff->screen; + return BadValue; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen], + &hFrameBuffer, + (int*)&rep.framebufferOrigin, + (int*)&rep.framebufferSize, + (int*)&rep.framebufferStride, + (int*)&rep.devPrivateSize, + &pDevPrivate)) { + return BadValue; + } + + rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff); +#if defined(LONG64) && !defined(__linux__) + rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32); +#else + rep.hFrameBufferHigh = 0; +#endif + + rep.length = 0; + if (rep.devPrivateSize) { + rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) - + SIZEOF(xGenericReply) + + ((rep.devPrivateSize + 3) & ~3)) >> 2; + } + + WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep); + if (rep.length) { + WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate); + } + return (client->noClientException); +} + +static int +ProcXF86DRIDispatch ( + register ClientPtr client +) +{ + REQUEST(xReq); + + switch (stuff->data) + { + case X_XF86DRIQueryVersion: + return ProcXF86DRIQueryVersion(client); + case X_XF86DRIQueryDirectRenderingCapable: + return ProcXF86DRIQueryDirectRenderingCapable(client); + } + + if (!LocalClient(client)) + return DRIErrorBase + XF86DRIClientNotLocal; + + switch (stuff->data) + { + case X_XF86DRIOpenConnection: + return ProcXF86DRIOpenConnection(client); + case X_XF86DRICloseConnection: + return ProcXF86DRICloseConnection(client); + case X_XF86DRIGetClientDriverName: + return ProcXF86DRIGetClientDriverName(client); + case X_XF86DRICreateContext: + return ProcXF86DRICreateContext(client); + case X_XF86DRIDestroyContext: + return ProcXF86DRIDestroyContext(client); + case X_XF86DRICreateDrawable: + return ProcXF86DRICreateDrawable(client); + case X_XF86DRIDestroyDrawable: + return ProcXF86DRIDestroyDrawable(client); + case X_XF86DRIGetDrawableInfo: + return ProcXF86DRIGetDrawableInfo(client); + case X_XF86DRIGetDeviceInfo: + return ProcXF86DRIGetDeviceInfo(client); + case X_XF86DRIAuthConnection: + return ProcXF86DRIAuthConnection(client); + /* {Open,Close}FullScreen are deprecated now */ + default: + return BadRequest; + } +} + +static int +SProcXF86DRIQueryVersion( + register ClientPtr client +) +{ + register int n; + REQUEST(xXF86DRIQueryVersionReq); + swaps(&stuff->length, n); + return ProcXF86DRIQueryVersion(client); +} + +static int +SProcXF86DRIQueryDirectRenderingCapable( + register ClientPtr client +) +{ + register int n; + REQUEST(xXF86DRIQueryDirectRenderingCapableReq); + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + return ProcXF86DRIQueryDirectRenderingCapable(client); +} + +static int +SProcXF86DRIDispatch ( + register ClientPtr client +) +{ + REQUEST(xReq); + + /* + * Only local clients are allowed DRI access, but remote clients still need + * these requests to find out cleanly. + */ + switch (stuff->data) + { + case X_XF86DRIQueryVersion: + return SProcXF86DRIQueryVersion(client); + case X_XF86DRIQueryDirectRenderingCapable: + return SProcXF86DRIQueryDirectRenderingCapable(client); + default: + return DRIErrorBase + XF86DRIClientNotLocal; + } +} diff --git a/xorg-server/hw/xfree86/dri2/Makefile.am b/xorg-server/hw/xfree86/dri2/Makefile.am new file mode 100644 index 000000000..e5bd16bd2 --- /dev/null +++ b/xorg-server/hw/xfree86/dri2/Makefile.am @@ -0,0 +1,16 @@ +libdri2_la_LTLIBRARIES = libdri2.la +libdri2_la_CFLAGS = \ + -DHAVE_XORG_CONFIG_H \ + @GL_CFLAGS@ \ + @DIX_CFLAGS@ @XORG_CFLAGS@ @DRI2PROTO_CFLAGS@ @LIBDRM_CFLAGS@ \ + -I$(top_srcdir)/hw/xfree86/common \ + -I$(top_srcdir)/hw/xfree86/os-support/bus + +libdri2_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@ +libdri2_ladir = $(moduledir)/extensions +libdri2_la_SOURCES = \ + dri2.c \ + dri2.h \ + dri2ext.c + +sdk_HEADERS = dri2.h diff --git a/xorg-server/hw/xfree86/dri2/Makefile.in b/xorg-server/hw/xfree86/dri2/Makefile.in new file mode 100644 index 000000000..c37499cf3 --- /dev/null +++ b/xorg-server/hw/xfree86/dri2/Makefile.in @@ -0,0 +1,725 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/dri2 +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdri2_ladir)" "$(DESTDIR)$(sdkdir)" +libdri2_laLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(libdri2_la_LTLIBRARIES) +libdri2_la_LIBADD = +am_libdri2_la_OBJECTS = libdri2_la-dri2.lo libdri2_la-dri2ext.lo +libdri2_la_OBJECTS = $(am_libdri2_la_OBJECTS) +libdri2_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libdri2_la_CFLAGS) \ + $(CFLAGS) $(libdri2_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libdri2_la_SOURCES) +DIST_SOURCES = $(libdri2_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +libdri2_la_LTLIBRARIES = libdri2.la +libdri2_la_CFLAGS = \ + -DHAVE_XORG_CONFIG_H \ + @GL_CFLAGS@ \ + @DIX_CFLAGS@ @XORG_CFLAGS@ @DRI2PROTO_CFLAGS@ @LIBDRM_CFLAGS@ \ + -I$(top_srcdir)/hw/xfree86/common \ + -I$(top_srcdir)/hw/xfree86/os-support/bus + +libdri2_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@ +libdri2_ladir = $(moduledir)/extensions +libdri2_la_SOURCES = \ + dri2.c \ + dri2.h \ + dri2ext.c + +sdk_HEADERS = dri2.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/dri2/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/dri2/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libdri2_laLTLIBRARIES: $(libdri2_la_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdri2_ladir)" || $(MKDIR_P) "$(DESTDIR)$(libdri2_ladir)" + @list='$(libdri2_la_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libdri2_laLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdri2_ladir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libdri2_laLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdri2_ladir)/$$f"; \ + else :; fi; \ + done + +uninstall-libdri2_laLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(libdri2_la_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdri2_ladir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdri2_ladir)/$$p"; \ + done + +clean-libdri2_laLTLIBRARIES: + -test -z "$(libdri2_la_LTLIBRARIES)" || rm -f $(libdri2_la_LTLIBRARIES) + @list='$(libdri2_la_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libdri2.la: $(libdri2_la_OBJECTS) $(libdri2_la_DEPENDENCIES) + $(libdri2_la_LINK) -rpath $(libdri2_ladir) $(libdri2_la_OBJECTS) $(libdri2_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdri2_la-dri2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdri2_la-dri2ext.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libdri2_la-dri2.lo: dri2.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri2_la_CFLAGS) $(CFLAGS) -MT libdri2_la-dri2.lo -MD -MP -MF $(DEPDIR)/libdri2_la-dri2.Tpo -c -o libdri2_la-dri2.lo `test -f 'dri2.c' || echo '$(srcdir)/'`dri2.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libdri2_la-dri2.Tpo $(DEPDIR)/libdri2_la-dri2.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dri2.c' object='libdri2_la-dri2.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri2_la_CFLAGS) $(CFLAGS) -c -o libdri2_la-dri2.lo `test -f 'dri2.c' || echo '$(srcdir)/'`dri2.c + +libdri2_la-dri2ext.lo: dri2ext.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri2_la_CFLAGS) $(CFLAGS) -MT libdri2_la-dri2ext.lo -MD -MP -MF $(DEPDIR)/libdri2_la-dri2ext.Tpo -c -o libdri2_la-dri2ext.lo `test -f 'dri2ext.c' || echo '$(srcdir)/'`dri2ext.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libdri2_la-dri2ext.Tpo $(DEPDIR)/libdri2_la-dri2ext.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dri2ext.c' object='libdri2_la-dri2ext.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdri2_la_CFLAGS) $(CFLAGS) -c -o libdri2_la-dri2ext.lo `test -f 'dri2ext.c' || echo '$(srcdir)/'`dri2ext.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdri2_ladir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libdri2_laLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-libdri2_laLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libdri2_laLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libdri2_laLTLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-libdri2_laLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-sdkHEADERS \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-libdri2_laLTLIBRARIES uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c new file mode 100644 index 000000000..74aef7196 --- /dev/null +++ b/xorg-server/hw/xfree86/dri2/dri2.c @@ -0,0 +1,493 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), 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 Soft- + * ware 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 MERCHANTABIL- + * ITY, 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 CONSE- + * QUENTIAL 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 PERFOR- + * MANCE 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. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <xf86drm.h> +#include "xf86Module.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "region.h" +#include "damage.h" +#include "dri2.h" +#include <GL/internal/dri_sarea.h> + +#include "xf86.h" + +static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKey; +static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKey; +static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKey; + +typedef struct _DRI2DrawablePriv { + unsigned int refCount; + unsigned int boHandle; + unsigned int dri2Handle; +} DRI2DrawablePrivRec, *DRI2DrawablePrivPtr; + +typedef struct _DRI2Screen { + int fd; + drmBO sareaBO; + void *sarea; + unsigned int sareaSize; + const char *driverName; + unsigned int nextHandle; + + __DRIEventBuffer *buffer; + int locked; + + DRI2GetPixmapHandleProcPtr getPixmapHandle; + DRI2BeginClipNotifyProcPtr beginClipNotify; + DRI2EndClipNotifyProcPtr endClipNotify; + + ClipNotifyProcPtr ClipNotify; + HandleExposuresProcPtr HandleExposures; +} DRI2ScreenRec, *DRI2ScreenPtr; + +static DRI2ScreenPtr +DRI2GetScreen(ScreenPtr pScreen) +{ + return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey); +} + +static void * +DRI2ScreenAllocEvent(DRI2ScreenPtr ds, size_t size) +{ + unsigned int *pad, mask = ds->buffer->size - 1; + size_t pad_size; + void *p; + + if ((ds->buffer->head & mask) + size > ds->buffer->size) { + /* The requested event size would wrap the buffer, so pad to + * the end and allocate the event from the start. */ + pad_size = ds->buffer->size - (ds->buffer->head & mask); + pad = (unsigned int *) + (ds->buffer->data + (ds->buffer->prealloc & mask)); + *pad = DRI2_EVENT_HEADER(DRI2_EVENT_PAD, pad_size); + ds->buffer->prealloc += pad_size; + } + + p = ds->buffer->data + (ds->buffer->prealloc & mask); + ds->buffer->prealloc += size; + + return p; +} + +static void +DRI2ScreenCommitEvents(DRI2ScreenPtr ds) +{ + ds->buffer->head = ds->buffer->prealloc; +} + +static void +DRI2PostDrawableConfig(DrawablePtr pDraw) +{ + ScreenPtr pScreen = pDraw->pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + DRI2DrawablePrivPtr pPriv; + WindowPtr pWin; + PixmapPtr pPixmap; + BoxPtr pBox; + BoxRec pixmapBox; + int nBox; + int i; + __DRIDrawableConfigEvent *e; + size_t size; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + pPriv = dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); + + nBox = REGION_NUM_RECTS(&pWin->clipList); + pBox = REGION_RECTS(&pWin->clipList); + + pPixmap = pScreen->GetWindowPixmap(pWin); + } else { + pPixmap = (PixmapPtr) pDraw; + pPriv = dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); + + pixmapBox.x1 = 0; + pixmapBox.y1 = 0; + pixmapBox.x2 = pDraw->width; + pixmapBox.y2 = pDraw->height; + nBox = 1; + pBox = &pixmapBox; + } + + if (!pPriv) + return; + + size = sizeof *e + nBox * sizeof e->rects[0]; + + e = DRI2ScreenAllocEvent(ds, size); + e->event_header = DRI2_EVENT_HEADER(DRI2_EVENT_DRAWABLE_CONFIG, size); + e->drawable = pPriv->dri2Handle; + e->x = pDraw->x - pPixmap->screen_x; + e->y = pDraw->y - pPixmap->screen_y; + e->width = pDraw->width; + e->height = pDraw->height; + + e->num_rects = nBox; + for (i = 0; i < nBox; i++) { + e->rects[i].x1 = pBox->x1 - pPixmap->screen_x; + e->rects[i].y1 = pBox->y1 - pPixmap->screen_y; + e->rects[i].x2 = pBox->x2 - pPixmap->screen_x; + e->rects[i].y2 = pBox->y2 - pPixmap->screen_y; + pBox++; + } +} + +static void +DRI2PostBufferAttach(DrawablePtr pDraw, Bool force) +{ + ScreenPtr pScreen = pDraw->pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + DRI2DrawablePrivPtr pPriv; + WindowPtr pWin; + PixmapPtr pPixmap; + __DRIBufferAttachEvent *e; + size_t size; + unsigned int flags; + unsigned int boHandle; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + pPixmap = pScreen->GetWindowPixmap(pWin); + pPriv = dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); + } else { + pPixmap = (PixmapPtr) pDraw; + pPriv = dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); + } + + if (!pPriv) + return; + + boHandle = ds->getPixmapHandle(pPixmap, &flags); + if (boHandle == pPriv->boHandle && !force) + return; + + pPriv->boHandle = boHandle; + size = sizeof *e; + e = DRI2ScreenAllocEvent(ds, size); + e->event_header = DRI2_EVENT_HEADER(DRI2_EVENT_BUFFER_ATTACH, size); + e->drawable = pPriv->dri2Handle; + e->buffer.attachment = DRI_DRAWABLE_BUFFER_FRONT_LEFT; + e->buffer.handle = pPriv->boHandle; + e->buffer.pitch = pPixmap->devKind; + e->buffer.cpp = pPixmap->drawable.bitsPerPixel / 8; + e->buffer.flags = flags; +} + +static void +DRI2ClipNotify(WindowPtr pWin, int dx, int dy) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (!ds->locked) { + ds->beginClipNotify(pScreen); + ds->locked = 1; + } + + if (ds->ClipNotify) { + pScreen->ClipNotify = ds->ClipNotify; + pScreen->ClipNotify(pWin, dx, dy); + pScreen->ClipNotify = DRI2ClipNotify; + } + + DRI2PostDrawableConfig(&pWin->drawable); + DRI2PostBufferAttach(&pWin->drawable, FALSE); +} + +static void +DRI2HandleExposures(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (ds->HandleExposures) { + pScreen->HandleExposures = ds->HandleExposures; + pScreen->HandleExposures(pWin); + pScreen->HandleExposures = DRI2HandleExposures; + } + + DRI2ScreenCommitEvents(ds); + + if (ds->locked) { + ds->endClipNotify(pScreen); + ds->locked = 0; + } +} + +void +DRI2CloseScreen(ScreenPtr pScreen) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + pScreen->ClipNotify = ds->ClipNotify; + pScreen->HandleExposures = ds->HandleExposures; + + drmBOUnmap(ds->fd, &ds->sareaBO); + drmBOUnreference(ds->fd, &ds->sareaBO); + + xfree(ds); + dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL); +} + +Bool +DRI2CreateDrawable(DrawablePtr pDraw, + unsigned int *handle, unsigned int *head) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); + WindowPtr pWin; + PixmapPtr pPixmap; + DRI2DrawablePrivPtr pPriv; + DevPrivateKey key; + PrivateRec **devPrivates; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + devPrivates = &pWin->devPrivates; + key = dri2WindowPrivateKey; + } else { + pPixmap = (PixmapPtr) pDraw; + devPrivates = &pPixmap->devPrivates; + key = dri2PixmapPrivateKey; + } + + pPriv = dixLookupPrivate(devPrivates, key); + if (pPriv != NULL) { + pPriv->refCount++; + } else { + pPriv = xalloc(sizeof *pPriv); + pPriv->refCount = 1; + pPriv->boHandle = 0; + pPriv->dri2Handle = ds->nextHandle++; + dixSetPrivate(devPrivates, key, pPriv); + } + + *handle = pPriv->dri2Handle; + *head = ds->buffer->head; + + DRI2PostDrawableConfig(pDraw); + DRI2PostBufferAttach(pDraw, TRUE); + DRI2ScreenCommitEvents(ds); + + return TRUE; +} + +void +DRI2DestroyDrawable(DrawablePtr pDraw) +{ + PixmapPtr pPixmap; + WindowPtr pWin; + DRI2DrawablePrivPtr pPriv; + DevPrivateKey key; + PrivateRec **devPrivates; + + if (pDraw->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr) pDraw; + devPrivates = &pWin->devPrivates; + key = dri2WindowPrivateKey; + } else { + pPixmap = (PixmapPtr) pDraw; + devPrivates = &pPixmap->devPrivates; + key = dri2PixmapPrivateKey; + } + + pPriv = dixLookupPrivate(devPrivates, key); + if (pPriv == NULL) + return; + + pPriv->refCount--; + if (pPriv->refCount == 0) { + dixSetPrivate(devPrivates, key, NULL); + xfree(pPriv); + } +} + +void +DRI2ReemitDrawableInfo(DrawablePtr pDraw, unsigned int *head) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); + + *head = ds->buffer->head; + + DRI2PostDrawableConfig(pDraw); + DRI2PostBufferAttach(pDraw, TRUE); + DRI2ScreenCommitEvents(ds); +} + +Bool +DRI2Connect(ScreenPtr pScreen, int *fd, const char **driverName, + unsigned int *sareaHandle) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (ds == NULL) + return FALSE; + + *fd = ds->fd; + *driverName = ds->driverName; + *sareaHandle = ds->sareaBO.handle; + + return TRUE; +} + +Bool +DRI2AuthConnection(ScreenPtr pScreen, drm_magic_t magic) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + if (ds == NULL || drmAuthMagic(ds->fd, magic)) + return FALSE; + + return TRUE; +} + +unsigned int +DRI2GetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pPixmap->drawable.pScreen); + + return ds->getPixmapHandle(pPixmap, flags); +} + +static void * +DRI2SetupSAREA(ScreenPtr pScreen, size_t driverSareaSize) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + unsigned long mask; + const size_t event_buffer_size = 32 * 1024; + + ds->sareaSize = + sizeof(*ds->buffer) + event_buffer_size + + driverSareaSize + + sizeof (unsigned int); + + mask = DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MAPPABLE | + DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_SHAREABLE; + + if (drmBOCreate(ds->fd, ds->sareaSize, 1, NULL, mask, 0, &ds->sareaBO)) + return NULL; + + if (drmBOMap(ds->fd, &ds->sareaBO, + DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &ds->sarea)) { + drmBOUnreference(ds->fd, &ds->sareaBO); + return NULL; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, + "[DRI2] Allocated %d byte SAREA, BO handle 0x%08x\n", + ds->sareaSize, ds->sareaBO.handle); + memset(ds->sarea, 0, ds->sareaSize); + + ds->buffer = ds->sarea; + ds->buffer->block_header = + DRI2_SAREA_BLOCK_HEADER(DRI2_SAREA_BLOCK_EVENT_BUFFER, + sizeof *ds->buffer + event_buffer_size); + ds->buffer->size = event_buffer_size; + + return DRI2_SAREA_BLOCK_NEXT(ds->buffer); +} + +void * +DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) +{ + DRI2ScreenPtr ds; + void *p; + + ds = xalloc(sizeof *ds); + if (!ds) + return NULL; + + ds->fd = info->fd; + ds->driverName = info->driverName; + ds->nextHandle = 1; + + ds->getPixmapHandle = info->getPixmapHandle; + ds->beginClipNotify = info->beginClipNotify; + ds->endClipNotify = info->endClipNotify; + + ds->ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = DRI2ClipNotify; + ds->HandleExposures = pScreen->HandleExposures; + pScreen->HandleExposures = DRI2HandleExposures; + + dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds); + + p = DRI2SetupSAREA(pScreen, info->driverSareaSize); + if (p == NULL) { + xfree(ds); + return NULL; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n"); + + return p; +} + +extern ExtensionModule dri2ExtensionModule; + +static pointer +DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) { + setupDone = TRUE; + LoadExtension(&dri2ExtensionModule, FALSE); + } else { + if (errmaj) + *errmaj = LDR_ONCEONLY; + } + + return (pointer) 1; +} + +static XF86ModuleVersionInfo DRI2VersRec = +{ + "dri2", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_NONE, + { 0, 0, 0, 0 } +}; + +_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL }; + diff --git a/xorg-server/hw/xfree86/dri2/dri2.h b/xorg-server/hw/xfree86/dri2/dri2.h new file mode 100644 index 000000000..85b3da41c --- /dev/null +++ b/xorg-server/hw/xfree86/dri2/dri2.h @@ -0,0 +1,81 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), 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 Soft- + * ware 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 MERCHANTABIL- + * ITY, 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 CONSE- + * QUENTIAL 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 PERFOR- + * MANCE 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. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifndef _DRI2_H_ +#define _DRI2_H_ + +typedef unsigned int (*DRI2GetPixmapHandleProcPtr)(PixmapPtr p, + unsigned int *flags); +typedef void (*DRI2BeginClipNotifyProcPtr)(ScreenPtr pScreen); +typedef void (*DRI2EndClipNotifyProcPtr)(ScreenPtr pScreen); + +typedef struct { + unsigned int version; /* Version of this struct */ + int fd; + size_t driverSareaSize; + const char *driverName; + DRI2GetPixmapHandleProcPtr getPixmapHandle; + DRI2BeginClipNotifyProcPtr beginClipNotify; + DRI2EndClipNotifyProcPtr endClipNotify; +} DRI2InfoRec, *DRI2InfoPtr; + +void *DRI2ScreenInit(ScreenPtr pScreen, + DRI2InfoPtr info); + +void DRI2CloseScreen(ScreenPtr pScreen); + +Bool DRI2Connect(ScreenPtr pScreen, + int *fd, + const char **driverName, + unsigned int *sareaHandle); + +Bool DRI2AuthConnection(ScreenPtr pScreen, drm_magic_t magic); + +unsigned int DRI2GetPixmapHandle(PixmapPtr pPixmap, + unsigned int *flags); + +void DRI2Lock(ScreenPtr pScreen); +void DRI2Unlock(ScreenPtr pScreen); + +Bool DRI2CreateDrawable(DrawablePtr pDraw, + unsigned int *handle, + unsigned int *head); + +void DRI2DestroyDrawable(DrawablePtr pDraw); + +void DRI2ReemitDrawableInfo(DrawablePtr pDraw, + unsigned int *head); + +Bool DRI2PostDamage(DrawablePtr pDrawable, + struct drm_clip_rect *rects, int numRects); + +#endif diff --git a/xorg-server/hw/xfree86/dri2/dri2ext.c b/xorg-server/hw/xfree86/dri2/dri2ext.c new file mode 100644 index 000000000..4ae0fda3a --- /dev/null +++ b/xorg-server/hw/xfree86/dri2/dri2ext.c @@ -0,0 +1,361 @@ +/* + * Copyright © 2008 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Soft- + * ware"), 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 Soft- + * ware 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 MERCHANTABIL- + * ITY, 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 CONSE- + * QUENTIAL 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 PERFOR- + * MANCE 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. + * + * Authors: + * Kristian Høgsberg (krh@redhat.com) + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#define NEED_REPLIES +#include <X11/X.h> +#include <X11/Xproto.h> +#include <X11/extensions/dri2proto.h> +#include "dixstruct.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "extnsionst.h" +#include "xf86drm.h" +#include "dri2.h" + +/* The only xf86 include */ +#include "xf86Module.h" + +static ExtensionEntry *dri2Extension; +static RESTYPE dri2DrawableRes; + +static Bool +validScreen(ClientPtr client, int screen, ScreenPtr *pScreen) +{ + if (screen >= screenInfo.numScreens) { + client->errorValue = screen; + return FALSE; + } + + *pScreen = screenInfo.screens[screen]; + + return TRUE; +} + +static Bool +validDrawable(ClientPtr client, XID drawable, + DrawablePtr *pDrawable, int *status) +{ + *status = dixLookupDrawable(pDrawable, drawable, client, 0, DixReadAccess); + if (*status != Success) { + client->errorValue = drawable; + return FALSE; + } + + return TRUE; +} + +static int +ProcDRI2QueryVersion(ClientPtr client) +{ + REQUEST(xDRI2QueryVersionReq); + xDRI2QueryVersionReply rep; + int n; + + if (client->swapped) + swaps(&stuff->length, n); + + REQUEST_SIZE_MATCH(xDRI2QueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = DRI2_MAJOR; + rep.minorVersion = DRI2_MINOR; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.majorVersion, n); + swapl(&rep.minorVersion, n); + } + + WriteToClient(client, sizeof(xDRI2QueryVersionReply), &rep); + + return client->noClientException; +} + +static int +ProcDRI2Connect(ClientPtr client) +{ + REQUEST(xDRI2ConnectReq); + xDRI2ConnectReply rep; + ScreenPtr pScreen; + int fd; + const char *driverName; + char *busId = NULL; + unsigned int sareaHandle; + + REQUEST_SIZE_MATCH(xDRI2ConnectReq); + if (!validScreen(client, stuff->screen, &pScreen)) + return BadValue; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.driverNameLength = 0; + rep.busIdLength = 0; + rep.sareaHandle = 0; + + if (!DRI2Connect(pScreen, &fd, &driverName, &sareaHandle)) + goto fail; + + busId = drmGetBusid(fd); + if (busId == NULL) + goto fail; + + rep.driverNameLength = strlen(driverName); + rep.busIdLength = strlen(busId); + rep.sareaHandle = sareaHandle; + rep.length = (rep.driverNameLength + 3) / 4 + (rep.busIdLength + 3) / 4; + + fail: + WriteToClient(client, sizeof(xDRI2ConnectReply), &rep); + WriteToClient(client, rep.driverNameLength, driverName); + WriteToClient(client, rep.busIdLength, busId); + drmFreeBusid(busId); + + return client->noClientException; +} + +static int +ProcDRI2AuthConnection(ClientPtr client) +{ + REQUEST(xDRI2AuthConnectionReq); + xDRI2AuthConnectionReply rep; + ScreenPtr pScreen; + + REQUEST_SIZE_MATCH(xDRI2AuthConnectionReq); + if (!validScreen(client, stuff->screen, &pScreen)) + return BadValue; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.authenticated = 1; + + if (!DRI2AuthConnection(pScreen, stuff->magic)) { + ErrorF("DRI2: Failed to authenticate %lu\n", + (unsigned long) stuff->magic); + rep.authenticated = 0; + } + + WriteToClient(client, sizeof(xDRI2AuthConnectionReply), &rep); + + return client->noClientException; +} + +static int +ProcDRI2CreateDrawable(ClientPtr client) +{ + REQUEST(xDRI2CreateDrawableReq); + xDRI2CreateDrawableReply rep; + DrawablePtr pDrawable; + unsigned int handle, head; + int status; + + REQUEST_SIZE_MATCH(xDRI2CreateDrawableReq); + + if (!validDrawable(client, stuff->drawable, &pDrawable, &status)) + return status; + + if (!DRI2CreateDrawable(pDrawable, &handle, &head)) + return BadMatch; + + if (!AddResource(stuff->drawable, dri2DrawableRes, pDrawable)) { + DRI2DestroyDrawable(pDrawable); + return BadAlloc; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.handle = handle; + rep.head = head; + + WriteToClient(client, sizeof(xDRI2CreateDrawableReply), &rep); + + return client->noClientException; +} + +static int +ProcDRI2DestroyDrawable(ClientPtr client) +{ + REQUEST(xDRI2DestroyDrawableReq); + DrawablePtr pDrawable; + int status; + + REQUEST_SIZE_MATCH(xDRI2DestroyDrawableReq); + if (!validDrawable(client, stuff->drawable, &pDrawable, &status)) + return status; + + FreeResourceByType(stuff->drawable, dri2DrawableRes, FALSE); + + return client->noClientException; +} + +static int +ProcDRI2ReemitDrawableInfo(ClientPtr client) +{ + REQUEST(xDRI2ReemitDrawableInfoReq); + xDRI2ReemitDrawableInfoReply rep; + DrawablePtr pDrawable; + unsigned int head; + int status; + + REQUEST_SIZE_MATCH(xDRI2ReemitDrawableInfoReq); + if (!validDrawable(client, stuff->drawable, &pDrawable, &status)) + return status; + + DRI2ReemitDrawableInfo(pDrawable, &head); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.head = head; + + WriteToClient(client, sizeof(xDRI2ReemitDrawableInfoReply), &rep); + + return client->noClientException; +} + +static int +ProcDRI2Dispatch (ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) { + case X_DRI2QueryVersion: + return ProcDRI2QueryVersion(client); + } + + if (!LocalClient(client)) + return BadRequest; + + switch (stuff->data) { + case X_DRI2Connect: + return ProcDRI2Connect(client); + case X_DRI2AuthConnection: + return ProcDRI2AuthConnection(client); + case X_DRI2CreateDrawable: + return ProcDRI2CreateDrawable(client); + case X_DRI2DestroyDrawable: + return ProcDRI2DestroyDrawable(client); + case X_DRI2ReemitDrawableInfo: + return ProcDRI2ReemitDrawableInfo(client); + default: + return BadRequest; + } +} + +static int +SProcDRI2Connect(ClientPtr client) +{ + REQUEST(xDRI2ConnectReq); + xDRI2ConnectReply rep; + int n; + + /* If the client is swapped, it's not local. Talk to the hand. */ + + swaps(&stuff->length, n); + if (sizeof(*stuff) / 4 != client->req_len) + return BadLength; + + rep.sequenceNumber = client->sequence; + swaps(&rep.sequenceNumber, n); + rep.length = 0; + rep.driverNameLength = 0; + rep.busIdLength = 0; + rep.sareaHandle = 0; + + return client->noClientException; +} + +static int +SProcDRI2Dispatch (ClientPtr client) +{ + REQUEST(xReq); + + /* + * Only local clients are allowed DRI access, but remote clients + * still need these requests to find out cleanly. + */ + switch (stuff->data) + { + case X_DRI2QueryVersion: + return ProcDRI2QueryVersion(client); + case X_DRI2Connect: + return SProcDRI2Connect(client); + default: + return BadRequest; + } +} + +static void +DRI2ResetProc (ExtensionEntry *extEntry) +{ +} + +static int DRI2DrawableGone(pointer p, XID id) +{ + DrawablePtr pDrawable = p; + + DRI2DestroyDrawable(pDrawable); + + return Success; +} + +static void +DRI2ExtensionInit(void) +{ + dri2Extension = AddExtension(DRI2_NAME, + DRI2NumberEvents, + DRI2NumberErrors, + ProcDRI2Dispatch, + SProcDRI2Dispatch, + DRI2ResetProc, + StandardMinorOpcode); + + dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone); +} + +extern Bool noDRI2Extension; + +_X_HIDDEN ExtensionModule dri2ExtensionModule = { + DRI2ExtensionInit, + DRI2_NAME, + &noDRI2Extension, + NULL, + NULL +}; diff --git a/xorg-server/hw/xfree86/dummylib/Makefile.am b/xorg-server/hw/xfree86/dummylib/Makefile.am new file mode 100644 index 000000000..85a1d03dd --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/Makefile.am @@ -0,0 +1,38 @@ +# libdummy.a contains just those bits used in the server itself +# libdummy-nonserver.a contains additional routines normally found in the +# server for use in building the utilities like config tools + +noinst_LIBRARIES = libdummy-nonserver.a + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +if NEED_STRLCAT +STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c +endif + +libdummy_nonserver_a_SOURCES = \ + dixprivates.c \ + fatalerror.c \ + logvwrite.c \ + $(STRL_SRCS) \ + verrorf.c \ + xalloc.c \ + xf86allocscripi.c \ + xf86addrestolist.c \ + xf86drvmsg.c \ + xf86drvmsgverb.c \ + xf86errorf.c \ + xf86errorfverb.c \ + xf86getverb.c \ + xf86info.c \ + xf86msg.c \ + xf86msgverb.c \ + xf86opt.c \ + xf86screens.c \ + xf86servisinit.c \ + xf86verbose.c \ + $(srcdir)/../os-support/shared/sigiostubs.c + +EXTRA_DIST = README dummylib.h diff --git a/xorg-server/hw/xfree86/dummylib/Makefile.in b/xorg-server/hw/xfree86/dummylib/Makefile.in new file mode 100644 index 000000000..3611a3d02 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/Makefile.in @@ -0,0 +1,750 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# libdummy.a contains just those bits used in the server itself +# libdummy-nonserver.a contains additional routines normally found in the +# server for use in building the utilities like config tools + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/dummylib +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libdummy_nonserver_a_AR = $(AR) $(ARFLAGS) +libdummy_nonserver_a_LIBADD = +am__libdummy_nonserver_a_SOURCES_DIST = dixprivates.c fatalerror.c \ + logvwrite.c $(top_srcdir)/os/strlcat.c \ + $(top_srcdir)/os/strlcpy.c verrorf.c xalloc.c \ + xf86allocscripi.c xf86addrestolist.c xf86drvmsg.c \ + xf86drvmsgverb.c xf86errorf.c xf86errorfverb.c xf86getverb.c \ + xf86info.c xf86msg.c xf86msgverb.c xf86opt.c xf86screens.c \ + xf86servisinit.c xf86verbose.c \ + $(srcdir)/../os-support/shared/sigiostubs.c +@NEED_STRLCAT_TRUE@am__objects_1 = strlcat.$(OBJEXT) strlcpy.$(OBJEXT) +am_libdummy_nonserver_a_OBJECTS = dixprivates.$(OBJEXT) \ + fatalerror.$(OBJEXT) logvwrite.$(OBJEXT) $(am__objects_1) \ + verrorf.$(OBJEXT) xalloc.$(OBJEXT) xf86allocscripi.$(OBJEXT) \ + xf86addrestolist.$(OBJEXT) xf86drvmsg.$(OBJEXT) \ + xf86drvmsgverb.$(OBJEXT) xf86errorf.$(OBJEXT) \ + xf86errorfverb.$(OBJEXT) xf86getverb.$(OBJEXT) \ + xf86info.$(OBJEXT) xf86msg.$(OBJEXT) xf86msgverb.$(OBJEXT) \ + xf86opt.$(OBJEXT) xf86screens.$(OBJEXT) \ + xf86servisinit.$(OBJEXT) xf86verbose.$(OBJEXT) \ + sigiostubs.$(OBJEXT) +libdummy_nonserver_a_OBJECTS = $(am_libdummy_nonserver_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libdummy_nonserver_a_SOURCES) +DIST_SOURCES = $(am__libdummy_nonserver_a_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = libdummy-nonserver.a +INCLUDES = $(XORG_INCS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +@NEED_STRLCAT_TRUE@STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c +libdummy_nonserver_a_SOURCES = \ + dixprivates.c \ + fatalerror.c \ + logvwrite.c \ + $(STRL_SRCS) \ + verrorf.c \ + xalloc.c \ + xf86allocscripi.c \ + xf86addrestolist.c \ + xf86drvmsg.c \ + xf86drvmsgverb.c \ + xf86errorf.c \ + xf86errorfverb.c \ + xf86getverb.c \ + xf86info.c \ + xf86msg.c \ + xf86msgverb.c \ + xf86opt.c \ + xf86screens.c \ + xf86servisinit.c \ + xf86verbose.c \ + $(srcdir)/../os-support/shared/sigiostubs.c + +EXTRA_DIST = README dummylib.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/dummylib/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/dummylib/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libdummy-nonserver.a: $(libdummy_nonserver_a_OBJECTS) $(libdummy_nonserver_a_DEPENDENCIES) + -rm -f libdummy-nonserver.a + $(libdummy_nonserver_a_AR) libdummy-nonserver.a $(libdummy_nonserver_a_OBJECTS) $(libdummy_nonserver_a_LIBADD) + $(RANLIB) libdummy-nonserver.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dixprivates.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fatalerror.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logvwrite.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigiostubs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verrorf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xalloc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86addrestolist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86allocscripi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86drvmsg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86drvmsgverb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86errorf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86errorfverb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86getverb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86info.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86msg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86msgverb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86opt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86screens.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86servisinit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86verbose.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +strlcat.o: $(top_srcdir)/os/strlcat.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcat.o -MD -MP -MF $(DEPDIR)/strlcat.Tpo -c -o strlcat.o `test -f '$(top_srcdir)/os/strlcat.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcat.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/strlcat.Tpo $(DEPDIR)/strlcat.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcat.c' object='strlcat.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strlcat.o `test -f '$(top_srcdir)/os/strlcat.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcat.c + +strlcat.obj: $(top_srcdir)/os/strlcat.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcat.obj -MD -MP -MF $(DEPDIR)/strlcat.Tpo -c -o strlcat.obj `if test -f '$(top_srcdir)/os/strlcat.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcat.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcat.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/strlcat.Tpo $(DEPDIR)/strlcat.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcat.c' object='strlcat.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strlcat.obj `if test -f '$(top_srcdir)/os/strlcat.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcat.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcat.c'; fi` + +strlcpy.o: $(top_srcdir)/os/strlcpy.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcpy.o -MD -MP -MF $(DEPDIR)/strlcpy.Tpo -c -o strlcpy.o `test -f '$(top_srcdir)/os/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcpy.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/strlcpy.Tpo $(DEPDIR)/strlcpy.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcpy.c' object='strlcpy.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strlcpy.o `test -f '$(top_srcdir)/os/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcpy.c + +strlcpy.obj: $(top_srcdir)/os/strlcpy.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcpy.obj -MD -MP -MF $(DEPDIR)/strlcpy.Tpo -c -o strlcpy.obj `if test -f '$(top_srcdir)/os/strlcpy.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcpy.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcpy.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/strlcpy.Tpo $(DEPDIR)/strlcpy.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcpy.c' object='strlcpy.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strlcpy.obj `if test -f '$(top_srcdir)/os/strlcpy.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcpy.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcpy.c'; fi` + +sigiostubs.o: $(srcdir)/../os-support/shared/sigiostubs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sigiostubs.o -MD -MP -MF $(DEPDIR)/sigiostubs.Tpo -c -o sigiostubs.o `test -f '$(srcdir)/../os-support/shared/sigiostubs.c' || echo '$(srcdir)/'`$(srcdir)/../os-support/shared/sigiostubs.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sigiostubs.Tpo $(DEPDIR)/sigiostubs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../os-support/shared/sigiostubs.c' object='sigiostubs.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sigiostubs.o `test -f '$(srcdir)/../os-support/shared/sigiostubs.c' || echo '$(srcdir)/'`$(srcdir)/../os-support/shared/sigiostubs.c + +sigiostubs.obj: $(srcdir)/../os-support/shared/sigiostubs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sigiostubs.obj -MD -MP -MF $(DEPDIR)/sigiostubs.Tpo -c -o sigiostubs.obj `if test -f '$(srcdir)/../os-support/shared/sigiostubs.c'; then $(CYGPATH_W) '$(srcdir)/../os-support/shared/sigiostubs.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../os-support/shared/sigiostubs.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sigiostubs.Tpo $(DEPDIR)/sigiostubs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../os-support/shared/sigiostubs.c' object='sigiostubs.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sigiostubs.obj `if test -f '$(srcdir)/../os-support/shared/sigiostubs.c'; then $(CYGPATH_W) '$(srcdir)/../os-support/shared/sigiostubs.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/../os-support/shared/sigiostubs.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/dummylib/README b/xorg-server/hw/xfree86/dummylib/README new file mode 100644 index 000000000..4e270307a --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/README @@ -0,0 +1,7 @@ + +libdummy (dummylib) contains basic utility functions required by libxf86_os.a. +There is one symbol per source/object so that each can be overriden +individually by whatever uses this library. + + +$XFree86$ diff --git a/xorg-server/hw/xfree86/dummylib/dixprivates.c b/xorg-server/hw/xfree86/dummylib/dixprivates.c new file mode 100644 index 000000000..40c173a20 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/dixprivates.c @@ -0,0 +1,19 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT pointer * +dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key) +{ + return NULL; /* not used */ +} + diff --git a/xorg-server/hw/xfree86/dummylib/dummylib.h b/xorg-server/hw/xfree86/dummylib/dummylib.h new file mode 100644 index 000000000..b70b5d0b4 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/dummylib.h @@ -0,0 +1,9 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _DUMMY_LIB_H +#define _DUMMY_LIB_H + +#endif /* _DUMMY_LIB_H */ diff --git a/xorg-server/hw/xfree86/dummylib/fatalerror.c b/xorg-server/hw/xfree86/dummylib/fatalerror.c new file mode 100644 index 000000000..e147c7303 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/fatalerror.c @@ -0,0 +1,25 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +FatalError(const char *f, ...) +{ + va_list args; + + va_start(args, f); + fprintf(stderr, "Fatal Error:\n"); + vfprintf(stderr, f, args); + va_end(args); + exit(1); +} + diff --git a/xorg-server/hw/xfree86/dummylib/logvwrite.c b/xorg-server/hw/xfree86/dummylib/logvwrite.c new file mode 100644 index 000000000..26868e7c8 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/logvwrite.c @@ -0,0 +1,21 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +LogVWrite(int verb, const char *format, va_list ap) +{ + if (xf86Verbose >= verb) + vfprintf(stderr, format, ap); +} + diff --git a/xorg-server/hw/xfree86/dummylib/verrorf.c b/xorg-server/hw/xfree86/dummylib/verrorf.c new file mode 100644 index 000000000..c75d1bc6d --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/verrorf.c @@ -0,0 +1,19 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +VErrorF(const char *f, va_list args) +{ + vfprintf(stderr, f, args); +} + diff --git a/xorg-server/hw/xfree86/dummylib/xalloc.c b/xorg-server/hw/xfree86/dummylib/xalloc.c new file mode 100644 index 000000000..b671d4dde --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xalloc.c @@ -0,0 +1,111 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT pointer +Xalloc(unsigned long n) +{ + if (!n) + n = 1; + return malloc(n); +} + +_X_EXPORT pointer +Xrealloc(pointer p, unsigned long n) +{ + if (!n) + n = 1; + return realloc(p, n); +} + +_X_EXPORT pointer +Xcalloc(unsigned long n) +{ + pointer r; + + r = Xalloc(n); + memset(r, 0, n); + return r; +} + +_X_EXPORT pointer +XNFalloc(unsigned long n) +{ + pointer r; + + r = Xalloc(n); + if (!r) + FatalError("XNFalloc failed\n"); + return r; + +} + +_X_EXPORT pointer +XNFrealloc(pointer p, unsigned long n) +{ + pointer r; + + r = Xrealloc(p, n); + if (!r) + FatalError("XNFrealloc failed\n"); + return r; + +} + +_X_EXPORT pointer +XNFcalloc(unsigned long n) +{ + pointer r; + + r = Xcalloc(n); + if (!r) + FatalError("XNFcalloc failed\n"); + return r; + +} + +_X_EXPORT void +Xfree(pointer p) +{ + free(p); +} + +_X_EXPORT char * +Xstrdup(const char *s) +{ + char *sd; + + if (s == NULL) + return NULL; + + sd = (char *)Xalloc(strlen(s) + 1); + if (sd != NULL) + strcpy(sd, s); + return sd; +} + +char * +XNFstrdup(const char *s) +{ + char *sd; + size_t len; + + if (s == NULL) + return NULL; + + len = strlen(s) + 1; + sd = (char *)XNFalloc(len); + strlcpy(sd, s, len); + return sd; +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86addrestolist.c b/xorg-server/hw/xfree86/dummylib/xf86addrestolist.c new file mode 100644 index 000000000..32789ecbb --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86addrestolist.c @@ -0,0 +1,24 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" + +_X_EXPORT resPtr +xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex) +{ + return rlist; +} + +_X_EXPORT void +xf86FreeResList(resPtr rlist) +{ + return; +} + +_X_EXPORT resPtr +xf86DupResList(const resPtr rlist) +{ + return rlist; +} diff --git a/xorg-server/hw/xfree86/dummylib/xf86allocscripi.c b/xorg-server/hw/xfree86/dummylib/xf86allocscripi.c new file mode 100644 index 000000000..926884884 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86allocscripi.c @@ -0,0 +1,19 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT int +xf86AllocateScrnInfoPrivateIndex() +{ + return -1; +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86drvmsg.c b/xorg-server/hw/xfree86/dummylib/xf86drvmsg.c new file mode 100644 index 000000000..b77948d0c --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86drvmsg.c @@ -0,0 +1,24 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +xf86DrvMsg(int i, MessageType type, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVWrite(1, format, ap); + va_end(ap); +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86drvmsgverb.c b/xorg-server/hw/xfree86/dummylib/xf86drvmsgverb.c new file mode 100644 index 000000000..5ecd99e4d --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86drvmsgverb.c @@ -0,0 +1,24 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +xf86DrvMsgVerb(int i, MessageType type, int verb, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVWrite(verb, format, ap); + va_end(ap); +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86errorf.c b/xorg-server/hw/xfree86/dummylib/xf86errorf.c new file mode 100644 index 000000000..9834c613b --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86errorf.c @@ -0,0 +1,33 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +xf86ErrorF(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVWrite(1, format, ap); + va_end(ap); +} + +_X_EXPORT void +ErrorF(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVWrite(1, format, ap); + va_end(ap); +} diff --git a/xorg-server/hw/xfree86/dummylib/xf86errorfverb.c b/xorg-server/hw/xfree86/dummylib/xf86errorfverb.c new file mode 100644 index 000000000..94f030719 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86errorfverb.c @@ -0,0 +1,24 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +xf86ErrorFVerb(int verb, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVWrite(verb, format, ap); + va_end(ap); +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86getverb.c b/xorg-server/hw/xfree86/dummylib/xf86getverb.c new file mode 100644 index 000000000..a489e9ca3 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86getverb.c @@ -0,0 +1,19 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT int +xf86GetVerbosity() +{ + return xf86Verbose; +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86info.c b/xorg-server/hw/xfree86/dummylib/xf86info.c new file mode 100644 index 000000000..221a9d2bb --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86info.c @@ -0,0 +1,12 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* Dummy variables */ +xf86InfoRec xf86Info = {NULL, }; + diff --git a/xorg-server/hw/xfree86/dummylib/xf86msg.c b/xorg-server/hw/xfree86/dummylib/xf86msg.c new file mode 100644 index 000000000..ea5bb3560 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86msg.c @@ -0,0 +1,24 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +xf86Msg(MessageType type, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVWrite(1, format, ap); + va_end(ap); +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86msgverb.c b/xorg-server/hw/xfree86/dummylib/xf86msgverb.c new file mode 100644 index 000000000..4467af9d5 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86msgverb.c @@ -0,0 +1,24 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +xf86MsgVerb(MessageType type, int verb, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVWrite(verb, format, ap); + va_end(ap); +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86opt.c b/xorg-server/hw/xfree86/dummylib/xf86opt.c new file mode 100644 index 000000000..1b7bca9c6 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86opt.c @@ -0,0 +1,25 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +_X_EXPORT void +xf86ProcessOptions(int i, pointer p, OptionInfoPtr o) +{ +} + +_X_EXPORT Bool +xf86GetOptValBool(const OptionInfoRec *o, int i, Bool *b) +{ + return FALSE; +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86screens.c b/xorg-server/hw/xfree86/dummylib/xf86screens.c new file mode 100644 index 000000000..6288c60dc --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86screens.c @@ -0,0 +1,12 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* Dummy variables */ +_X_EXPORT ScrnInfoPtr *xf86Screens = NULL; + diff --git a/xorg-server/hw/xfree86/dummylib/xf86servisinit.c b/xorg-server/hw/xfree86/dummylib/xf86servisinit.c new file mode 100644 index 000000000..c356a2b88 --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86servisinit.c @@ -0,0 +1,19 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +Bool +xf86ServerIsInitialising() +{ + return FALSE; +} + diff --git a/xorg-server/hw/xfree86/dummylib/xf86verbose.c b/xorg-server/hw/xfree86/dummylib/xf86verbose.c new file mode 100644 index 000000000..c4a45d68e --- /dev/null +++ b/xorg-server/hw/xfree86/dummylib/xf86verbose.c @@ -0,0 +1,12 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* Dummy variables */ +int xf86Verbose = 0; + diff --git a/xorg-server/hw/xfree86/exa/Makefile.am b/xorg-server/hw/xfree86/exa/Makefile.am new file mode 100644 index 000000000..9eb2e1797 --- /dev/null +++ b/xorg-server/hw/xfree86/exa/Makefile.am @@ -0,0 +1,28 @@ +module_LTLIBRARIES = libexa.la + +libexa_la_LDFLAGS = -avoid-version + +INCLUDES = \ + $(XORG_INCS) \ + -I$(srcdir)/../../../exa \ + -I$(srcdir)/../../../miext/cw + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +libexa_la_SOURCES = \ + examodule.c + +libexa_la_LIBADD = \ + ../../../exa/libexa.la + +include $(top_srcdir)/cpprules.in + +drivermandir = $(DRIVER_MAN_DIR) +driverman_DATA = exa.$(DRIVER_MAN_SUFFIX) +CLEANFILES = $(driverman_DATA) exa.man + +exa.$(DRIVER_MAN_SUFFIX): exa.man + -rm -f exa.$(DRIVER_MAN_SUFFIX) + $(LN_S) exa.man exa.$(DRIVER_MAN_SUFFIX) + +EXTRA_DIST = exa.man.pre diff --git a/xorg-server/hw/xfree86/exa/Makefile.in b/xorg-server/hw/xfree86/exa/Makefile.in new file mode 100644 index 000000000..0311735a6 --- /dev/null +++ b/xorg-server/hw/xfree86/exa/Makefile.in @@ -0,0 +1,761 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/cpprules.in +subdir = hw/xfree86/exa +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(drivermandir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libexa_la_DEPENDENCIES = ../../../exa/libexa.la +am_libexa_la_OBJECTS = examodule.lo +libexa_la_OBJECTS = $(am_libexa_la_OBJECTS) +libexa_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libexa_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libexa_la_SOURCES) +DIST_SOURCES = $(libexa_la_SOURCES) +drivermanDATA_INSTALL = $(INSTALL_DATA) +DATA = $(driverman_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libexa.la +libexa_la_LDFLAGS = -avoid-version +INCLUDES = \ + $(XORG_INCS) \ + -I$(srcdir)/../../../exa \ + -I$(srcdir)/../../../miext/cw + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +libexa_la_SOURCES = \ + examodule.c + +libexa_la_LIBADD = \ + ../../../exa/libexa.la + +SUFFIXES = .pre .man .man.pre + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + +drivermandir = $(DRIVER_MAN_DIR) +driverman_DATA = exa.$(DRIVER_MAN_SUFFIX) +CLEANFILES = $(driverman_DATA) exa.man +EXTRA_DIST = exa.man.pre +all: all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/exa/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/exa/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libexa.la: $(libexa_la_OBJECTS) $(libexa_la_DEPENDENCIES) + $(libexa_la_LINK) -rpath $(moduledir) $(libexa_la_OBJECTS) $(libexa_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/examodule.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-drivermanDATA: $(driverman_DATA) + @$(NORMAL_INSTALL) + test -z "$(drivermandir)" || $(MKDIR_P) "$(DESTDIR)$(drivermandir)" + @list='$(driverman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(drivermanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(drivermandir)/$$f'"; \ + $(drivermanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(drivermandir)/$$f"; \ + done + +uninstall-drivermanDATA: + @$(NORMAL_UNINSTALL) + @list='$(driverman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(drivermandir)/$$f'"; \ + rm -f "$(DESTDIR)$(drivermandir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(drivermandir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-drivermanDATA install-moduleLTLIBRARIES + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-drivermanDATA uninstall-moduleLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-drivermanDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-moduleLTLIBRARIES \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-drivermanDATA uninstall-moduleLTLIBRARIES + + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ + +exa.$(DRIVER_MAN_SUFFIX): exa.man + -rm -f exa.$(DRIVER_MAN_SUFFIX) + $(LN_S) exa.man exa.$(DRIVER_MAN_SUFFIX) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/exa/exa.man.pre b/xorg-server/hw/xfree86/exa/exa.man.pre new file mode 100644 index 000000000..14859bc8f --- /dev/null +++ b/xorg-server/hw/xfree86/exa/exa.man.pre @@ -0,0 +1,46 @@ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH EXA __drivermansuffix__ __vendorversion__ +.SH NAME +exa \- new 2D acceleration architecture for X.Org +.SH DESCRIPTION +.B EXA +provides a simple API for video drivers to implement for 2D acceleration. It +is a module loaded by drivers, and is not intended to be loaded on its own. See +your driver's manual page for how to enable +.B EXA +. +.PP +The +.B EXA +architecture is designed to make accelerating the Render extension simple and +efficient, and results in various performance tradeoffs compared to XAA. Some +options are available for debugging performance issues or driver rendering +problems. They are not intended for general use. +.TP +.BI "Option \*qEXANoComposite\*q \*q" boolean \*q +Disables acceleration of the Composite operation, which is at the heart of +the Render extension. Not related to the Composite extension. Default: No. +.TP +.BI "Option \*qEXANoUploadToScreen\*q \*q" boolean \*q +Disables acceleration of uploading pixmap data to the freamebuffer. Default: No. +.TP +.BI "Option \*qEXANoDownloadFromScreen\*q \*q" boolean \*q +Disables acceleration of downloading of pixmap data from the framebuffer. +.B NOTE: +Not usable with drivers which rely on DownloadFromScreen succeeding. +Default: No. +.TP +.BI "Option \*qEXAOptimizeMigration\*q \*q" boolean \*q +Enables an additional optimization for migration of destination pixmaps. This +may improve performance in some cases (e.g. when switching virtual desktops with +no compositing manager) but causes corruption in others (e.g. when starting +compiz). Default: No. +.TP +.BI "Option \*qMigrationHeuristic\*q \*q" anystr \*q +Chooses an alternate pixmap migration heuristic, for debugging purposes. The +default is intended to be the best performing one for general use, though others +may help with specific use cases. Available options include \*qalways\*q, +\*qgreedy\*q, and \*qsmart\*q. Default: always. +.SH AUTHORS +Authors include: Keith Packard, Eric Anholt, Zack Rusin, and Michel D\(:anzer diff --git a/xorg-server/hw/xfree86/exa/examodule.c b/xorg-server/hw/xfree86/exa/examodule.c new file mode 100644 index 000000000..e18da0a37 --- /dev/null +++ b/xorg-server/hw/xfree86/exa/examodule.c @@ -0,0 +1,203 @@ +/* + * Copyright © 2006 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + * Eric Anholt <anholt@FreeBSD.org> + * + */ + +#ifdef HAVE_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "exa_priv.h" + +#include "xf86str.h" +#include "xf86.h" + +typedef struct _ExaXorgScreenPrivRec { + CloseScreenProcPtr SavedCloseScreen; + EnableDisableFBAccessProcPtr SavedEnableDisableFBAccess; + OptionInfoPtr options; +} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr; + +static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKey; + +typedef enum { + EXAOPT_MIGRATION_HEURISTIC, + EXAOPT_NO_COMPOSITE, + EXAOPT_NO_UTS, + EXAOPT_NO_DFS, + EXAOPT_OPTIMIZE_MIGRATION +} EXAOpts; + +static const OptionInfoRec EXAOptions[] = { + { EXAOPT_MIGRATION_HEURISTIC, "MigrationHeuristic", + OPTV_ANYSTR, {0}, FALSE }, + { EXAOPT_NO_COMPOSITE, "EXANoComposite", + OPTV_BOOLEAN, {0}, FALSE }, + { EXAOPT_NO_UTS, "EXANoUploadToScreen", + OPTV_BOOLEAN, {0}, FALSE }, + { EXAOPT_NO_DFS, "EXANoDownloadFromScreen", + OPTV_BOOLEAN, {0}, FALSE }, + { EXAOPT_OPTIMIZE_MIGRATION, "EXAOptimizeMigration", + OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, + OPTV_NONE, {0}, FALSE } +}; + +static Bool +exaXorgCloseScreen (int i, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); + ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey); + + pScreen->CloseScreen = pScreenPriv->SavedCloseScreen; + + pScrn->EnableDisableFBAccess = pScreenPriv->SavedEnableDisableFBAccess; + + xfree (pScreenPriv->options); + xfree (pScreenPriv); + + return pScreen->CloseScreen (i, pScreen); +} + +static void +exaXorgEnableDisableFBAccess (int index, Bool enable) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey); + + if (!enable) + exaEnableDisableFBAccess (index, enable); + + if (pScreenPriv->SavedEnableDisableFBAccess) + pScreenPriv->SavedEnableDisableFBAccess (index, enable); + + if (enable) + exaEnableDisableFBAccess (index, enable); +} + +/** + * This will be called during exaDriverInit, giving us the chance to set options + * and hook in our EnableDisableFBAccess. + */ +void +exaDDXDriverInit(ScreenPtr pScreen) +{ + ExaScreenPriv(pScreen); + /* Do NOT use XF86SCRNINFO macro here!! */ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ExaXorgScreenPrivPtr pScreenPriv; + + pScreenPriv = xcalloc (1, sizeof(ExaXorgScreenPrivRec)); + if (pScreenPriv == NULL) + return; + + pScreenPriv->options = xnfalloc (sizeof(EXAOptions)); + memcpy(pScreenPriv->options, EXAOptions, sizeof(EXAOptions)); + xf86ProcessOptions (pScrn->scrnIndex, pScrn->options, pScreenPriv->options); + + if ((pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) && + pExaScr->info->offScreenBase < pExaScr->info->memorySize) + { + char *heuristicName; + + heuristicName = xf86GetOptValString (pScreenPriv->options, + EXAOPT_MIGRATION_HEURISTIC); + if (heuristicName != NULL) { + if (strcmp(heuristicName, "greedy") == 0) + pExaScr->migration = ExaMigrationGreedy; + else if (strcmp(heuristicName, "always") == 0) + pExaScr->migration = ExaMigrationAlways; + else if (strcmp(heuristicName, "smart") == 0) + pExaScr->migration = ExaMigrationSmart; + else { + xf86DrvMsg (pScreen->myNum, X_WARNING, + "EXA: unknown migration heuristic %s\n", + heuristicName); + } + } + + pExaScr->optimize_migration = + xf86ReturnOptValBool(pScreenPriv->options, + EXAOPT_OPTIMIZE_MIGRATION, + FALSE); + } + + if (xf86ReturnOptValBool(pScreenPriv->options, + EXAOPT_NO_COMPOSITE, FALSE)) { + xf86DrvMsg(pScreen->myNum, X_CONFIG, + "EXA: Disabling Composite operation " + "(RENDER acceleration)\n"); + pExaScr->info->CheckComposite = NULL; + pExaScr->info->PrepareComposite = NULL; + } + + if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_UTS, FALSE)) { + xf86DrvMsg(pScreen->myNum, X_CONFIG, + "EXA: Disabling UploadToScreen\n"); + pExaScr->info->UploadToScreen = NULL; + } + + if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_DFS, FALSE)) { + xf86DrvMsg(pScreen->myNum, X_CONFIG, + "EXA: Disabling DownloadFromScreen\n"); + pExaScr->info->DownloadFromScreen = NULL; + } + + dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv); + + pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess; + pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess; + + pScreenPriv->SavedCloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = exaXorgCloseScreen; + +} + +/*ARGSUSED*/ +static const OptionInfoRec * +EXAAvailableOptions(void *unused) +{ + return (EXAOptions); +} + +static XF86ModuleVersionInfo exaVersRec = +{ + "exa", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + EXA_VERSION_MAJOR, EXA_VERSION_MINOR, EXA_VERSION_RELEASE, + ABI_CLASS_VIDEODRV, /* requires the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData exaModuleData = { &exaVersRec, NULL, NULL }; diff --git a/xorg-server/hw/xfree86/fbdevhw/Makefile.am b/xorg-server/hw/xfree86/fbdevhw/Makefile.am new file mode 100644 index 000000000..6a4a6e4e6 --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/Makefile.am @@ -0,0 +1,28 @@ +linuxmoduledir = $(moduledir)/linux +linuxmodule_LTLIBRARIES = libfbdevhw.la + +libfbdevhw_la_LDFLAGS = -avoid-version + +if FBDEVHW +libfbdevhw_la_SOURCES = fbdevhw.c +else +libfbdevhw_la_SOURCES = fbdevhwstub.c +endif + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +sdk_HEADERS = fbdevhw.h + +include $(top_srcdir)/cpprules.in + +drivermandir = $(DRIVER_MAN_DIR) +driverman_DATA = fbdevhw.$(DRIVER_MAN_SUFFIX) +CLEANFILES = $(driverman_DATA) fbdevhw.man + +fbdevhw.$(DRIVER_MAN_SUFFIX): fbdevhw.man + -rm -f fbdevhw.$(DRIVER_MAN_SUFFIX) + $(LN_S) fbdevhw.man fbdevhw.$(DRIVER_MAN_SUFFIX) + +EXTRA_DIST = fbpriv.h fbdevhw.man.pre README diff --git a/xorg-server/hw/xfree86/fbdevhw/Makefile.in b/xorg-server/hw/xfree86/fbdevhw/Makefile.in new file mode 100644 index 000000000..7de912cbb --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/Makefile.in @@ -0,0 +1,782 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = README $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/cpprules.in +subdir = hw/xfree86/fbdevhw +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(linuxmoduledir)" \ + "$(DESTDIR)$(drivermandir)" "$(DESTDIR)$(sdkdir)" +linuxmoduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(linuxmodule_LTLIBRARIES) +libfbdevhw_la_LIBADD = +am__libfbdevhw_la_SOURCES_DIST = fbdevhwstub.c fbdevhw.c +@FBDEVHW_FALSE@am_libfbdevhw_la_OBJECTS = fbdevhwstub.lo +@FBDEVHW_TRUE@am_libfbdevhw_la_OBJECTS = fbdevhw.lo +libfbdevhw_la_OBJECTS = $(am_libfbdevhw_la_OBJECTS) +libfbdevhw_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libfbdevhw_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libfbdevhw_la_SOURCES) +DIST_SOURCES = $(am__libfbdevhw_la_SOURCES_DIST) +drivermanDATA_INSTALL = $(INSTALL_DATA) +DATA = $(driverman_DATA) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +linuxmoduledir = $(moduledir)/linux +linuxmodule_LTLIBRARIES = libfbdevhw.la +libfbdevhw_la_LDFLAGS = -avoid-version +@FBDEVHW_FALSE@libfbdevhw_la_SOURCES = fbdevhwstub.c +@FBDEVHW_TRUE@libfbdevhw_la_SOURCES = fbdevhw.c +INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +sdk_HEADERS = fbdevhw.h +SUFFIXES = .pre .man .man.pre + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + +drivermandir = $(DRIVER_MAN_DIR) +driverman_DATA = fbdevhw.$(DRIVER_MAN_SUFFIX) +CLEANFILES = $(driverman_DATA) fbdevhw.man +EXTRA_DIST = fbpriv.h fbdevhw.man.pre README +all: all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/fbdevhw/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/fbdevhw/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-linuxmoduleLTLIBRARIES: $(linuxmodule_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(linuxmoduledir)" || $(MKDIR_P) "$(DESTDIR)$(linuxmoduledir)" + @list='$(linuxmodule_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(linuxmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(linuxmoduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(linuxmoduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(linuxmoduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-linuxmoduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(linuxmodule_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(linuxmoduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(linuxmoduledir)/$$p"; \ + done + +clean-linuxmoduleLTLIBRARIES: + -test -z "$(linuxmodule_LTLIBRARIES)" || rm -f $(linuxmodule_LTLIBRARIES) + @list='$(linuxmodule_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libfbdevhw.la: $(libfbdevhw_la_OBJECTS) $(libfbdevhw_la_DEPENDENCIES) + $(libfbdevhw_la_LINK) -rpath $(linuxmoduledir) $(libfbdevhw_la_OBJECTS) $(libfbdevhw_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbdevhw.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbdevhwstub.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-drivermanDATA: $(driverman_DATA) + @$(NORMAL_INSTALL) + test -z "$(drivermandir)" || $(MKDIR_P) "$(DESTDIR)$(drivermandir)" + @list='$(driverman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(drivermanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(drivermandir)/$$f'"; \ + $(drivermanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(drivermandir)/$$f"; \ + done + +uninstall-drivermanDATA: + @$(NORMAL_UNINSTALL) + @list='$(driverman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(drivermandir)/$$f'"; \ + rm -f "$(DESTDIR)$(drivermandir)/$$f"; \ + done +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(linuxmoduledir)" "$(DESTDIR)$(drivermandir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-linuxmoduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-drivermanDATA install-linuxmoduleLTLIBRARIES \ + install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-drivermanDATA uninstall-linuxmoduleLTLIBRARIES \ + uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-linuxmoduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-drivermanDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-linuxmoduleLTLIBRARIES install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-drivermanDATA \ + uninstall-linuxmoduleLTLIBRARIES uninstall-sdkHEADERS + + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ + +fbdevhw.$(DRIVER_MAN_SUFFIX): fbdevhw.man + -rm -f fbdevhw.$(DRIVER_MAN_SUFFIX) + $(LN_S) fbdevhw.man fbdevhw.$(DRIVER_MAN_SUFFIX) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/fbdevhw/README b/xorg-server/hw/xfree86/fbdevhw/README new file mode 100644 index 000000000..27cc337d4 --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/README @@ -0,0 +1,16 @@ + +This is a submodule to access linux framebuffer devices. +It is supported to work as helper module (like vgahw) +for the chipset drivers. There are functions for +saving/restoring/setting video modes, set palette entries, +and a few more helper functions. Some of them can be +hooked directly into ScrnInfoRec. + +In ../drivers/fbdev is a "chipset" driver. It is a simple, +non-accelerated and hardware-independent driver which works +on top of this fbdevhw submodule. + + Gerd + +-- +Gerd Knorr <kraxel@goldbach.in-berlin.de> diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c new file mode 100644 index 000000000..4d514226e --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c @@ -0,0 +1,1017 @@ +/* all driver need this */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "xf86.h" +#include "xf86_OSproc.h" + +/* pci stuff */ +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +#include "xf86cmap.h" + +#include "fbdevhw.h" +#include "fbpriv.h" + +#if 0 +/* kernel header doesn't work with -ansi */ +# include "asm/page.h" /* #define for PAGE_* */ +#else +# define PAGE_MASK (~(getpagesize() - 1)) +#endif + +#include "globals.h" +#define DPMS_SERVER +#include <X11/extensions/dpms.h> + +#define DEBUG 0 + +#define PAGE_MASK (~(getpagesize() - 1)) + +#if DEBUG +# define TRACE_ENTER(str) ErrorF("fbdevHW: " str " %d\n",pScrn->scrnIndex) +#else +# define TRACE_ENTER(str) +#endif + +/* -------------------------------------------------------------------- */ + +static MODULESETUPPROTO(fbdevhwSetup); + +static XF86ModuleVersionInfo fbdevHWVersRec = +{ + "fbdevhw", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 0, 0, 2, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData fbdevhwModuleData = { + &fbdevHWVersRec, + fbdevhwSetup, + NULL +}; + +static pointer +fbdevhwSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + const char *osname; + + /* Check that we're being loaded on a Linux system */ + LoaderGetOS(&osname, NULL, NULL, NULL); + if (!osname || strcmp(osname, "linux") != 0) { + if (errmaj) + *errmaj = LDR_BADOS; + if (errmin) + *errmin = 0; + return NULL; + } else { + /* OK */ + return (pointer)1; + } +} + +#include <fcntl.h> +#include <errno.h> +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +/* -------------------------------------------------------------------- */ +/* our private data, and two functions to allocate/free this */ + +#define FBDEVHWPTRLVAL(p) (p)->privates[fbdevHWPrivateIndex].ptr +#define FBDEVHWPTR(p) ((fbdevHWPtr)(FBDEVHWPTRLVAL(p))) + +static int fbdevHWPrivateIndex = -1; + +typedef struct { + /* framebuffer device: filename (/dev/fb*), handle, more */ + char* device; + int fd; + void* fbmem; + unsigned int fbmem_len; + unsigned int fboff; + char* mmio; + unsigned int mmio_len; + + /* current hardware state */ + struct fb_fix_screeninfo fix; + struct fb_var_screeninfo var; + + /* saved video mode */ + struct fb_var_screeninfo saved_var; + + /* FIXME: unused??? [geert] */ + struct fb_cmap saved_cmap; + unsigned short *saved_red; + unsigned short *saved_green; + unsigned short *saved_blue; + + /* buildin video mode */ + DisplayModeRec buildin; + +} fbdevHWRec, *fbdevHWPtr; + +Bool +fbdevHWGetRec(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr; + + if (fbdevHWPrivateIndex < 0) + fbdevHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + + if (FBDEVHWPTR(pScrn) != NULL) + return TRUE; + + fPtr = FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(fbdevHWRec), 1); + return TRUE; +} + +void +fbdevHWFreeRec(ScrnInfoPtr pScrn) +{ + if (fbdevHWPrivateIndex < 0) + return; + if (FBDEVHWPTR(pScrn) == NULL) + return; + xfree(FBDEVHWPTR(pScrn)); + FBDEVHWPTRLVAL(pScrn) = NULL; +} + +/* -------------------------------------------------------------------- */ +/* some helpers for printing debug informations */ + +#if DEBUG +static void +print_fbdev_mode(char *txt, struct fb_var_screeninfo *var) +{ + ErrorF( "fbdev %s mode:\t%d %d %d %d %d %d %d %d %d %d %d:%d:%d\n", + txt,var->pixclock, + var->xres, var->right_margin, var->hsync_len, var->left_margin, + var->yres, var->lower_margin, var->vsync_len, var->upper_margin, + var->bits_per_pixel, + var->red.length, var->green.length, var->blue.length); +} + +static void +print_xfree_mode(char *txt, DisplayModePtr mode) +{ + ErrorF( "xfree %s mode:\t%d %d %d %d %d %d %d %d %d\n", + txt,mode->Clock, + mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal, + mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal); +} +#endif + +/* -------------------------------------------------------------------- */ +/* Convert timings between the XFree and the Frame Buffer Device */ + +static void +xfree2fbdev_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var) +{ + var->xres_virtual = pScrn->displayWidth ? pScrn->displayWidth : + pScrn->virtualX; + var->yres_virtual = pScrn->virtualY; + var->bits_per_pixel = pScrn->bitsPerPixel; + if (pScrn->defaultVisual == TrueColor || + pScrn->defaultVisual == DirectColor) { + var->red.length = pScrn->weight.red; + var->green.length = pScrn->weight.green; + var->blue.length = pScrn->weight.blue; + } else { + var->red.length = 8; + var->green.length = 8; + var->blue.length = 8; + } +} + +static void +xfree2fbdev_timing(DisplayModePtr mode, struct fb_var_screeninfo *var) +{ + var->xres = mode->HDisplay; + var->yres = mode->VDisplay; + if (var->xres_virtual < var->xres) + var->xres_virtual = var->xres; + if (var->yres_virtual < var->yres) + var->yres_virtual = var->yres; + var->xoffset = var->yoffset = 0; + var->pixclock = mode->Clock ? 1000000000/mode->Clock : 0; + var->right_margin = mode->HSyncStart-mode->HDisplay; + var->hsync_len = mode->HSyncEnd-mode->HSyncStart; + var->left_margin = mode->HTotal-mode->HSyncEnd; + var->lower_margin = mode->VSyncStart-mode->VDisplay; + var->vsync_len = mode->VSyncEnd-mode->VSyncStart; + var->upper_margin = mode->VTotal-mode->VSyncEnd; + var->sync = 0; + if (mode->Flags & V_PHSYNC) + var->sync |= FB_SYNC_HOR_HIGH_ACT; + if (mode->Flags & V_PVSYNC) + var->sync |= FB_SYNC_VERT_HIGH_ACT; + if (mode->Flags & V_PCSYNC) + var->sync |= FB_SYNC_COMP_HIGH_ACT; +#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ + if (mode->Flags & V_BCAST) + var->sync |= FB_SYNC_BROADCAST; +#endif + if (mode->Flags & V_INTERLACE) + var->vmode = FB_VMODE_INTERLACED; + else if (mode->Flags & V_DBLSCAN) + var->vmode = FB_VMODE_DOUBLE; + else + var->vmode = FB_VMODE_NONINTERLACED; +} + +static Bool +fbdev_modes_equal(struct fb_var_screeninfo *set, struct fb_var_screeninfo *req) +{ + return (set->xres_virtual >= req->xres_virtual && + set->yres_virtual >= req->yres_virtual && + set->bits_per_pixel == req->bits_per_pixel && + set->red.length == req->red.length && + set->green.length == req->green.length && + set->blue.length == req->blue.length && + set->xres == req->xres && set->yres == req->yres && + set->pixclock == req->pixclock && + set->right_margin == req->right_margin && + set->hsync_len == req->hsync_len && + set->left_margin == req->left_margin && + set->lower_margin == req->lower_margin && + set->vsync_len == req->vsync_len && + set->upper_margin == req->upper_margin && + set->sync == req->sync && set->vmode == req->vmode); +} + +static void +fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode) +{ + mode->Clock = var->pixclock ? 1000000000/var->pixclock : 0; + mode->HDisplay = var->xres; + mode->HSyncStart = mode->HDisplay+var->right_margin; + mode->HSyncEnd = mode->HSyncStart+var->hsync_len; + mode->HTotal = mode->HSyncEnd+var->left_margin; + mode->VDisplay = var->yres; + mode->VSyncStart = mode->VDisplay+var->lower_margin; + mode->VSyncEnd = mode->VSyncStart+var->vsync_len; + mode->VTotal = mode->VSyncEnd+var->upper_margin; + mode->Flags = 0; + mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC; + mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC; + mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC; +#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ + if (var->sync & FB_SYNC_BROADCAST) + mode->Flags |= V_BCAST; +#endif + if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) + mode->Flags |= V_INTERLACE; + else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) + mode->Flags |= V_DBLSCAN; + mode->SynthClock = mode->Clock; + mode->CrtcHDisplay = mode->HDisplay; + mode->CrtcHSyncStart = mode->HSyncStart; + mode->CrtcHSyncEnd = mode->HSyncEnd; + mode->CrtcHTotal = mode->HTotal; + mode->CrtcVDisplay = mode->VDisplay; + mode->CrtcVSyncStart = mode->VSyncStart; + mode->CrtcVSyncEnd = mode->VSyncEnd; + mode->CrtcVTotal = mode->VTotal; + mode->CrtcHAdjusted = FALSE; + mode->CrtcVAdjusted = FALSE; +} + + +/* -------------------------------------------------------------------- */ +/* open correct framebuffer device */ + +/** + * Try to find the framebuffer device for a given PCI device + */ +static int +fbdev_open_pci(struct pci_device * pPci, char **namep) +{ + struct fb_fix_screeninfo fix; + char filename[256]; + int fd,i,j; + + + /* There are two ways to that we can determine which fb device is + * associated with this PCI device. The more modern way is to look in + * the sysfs directory for the PCI device for a file named + * "graphics/fb*" + */ + + for (i = 0; i < 8; i++) { + sprintf(filename, + "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d", + pPci->domain, pPci->bus, pPci->dev, pPci->func, i); + + fd = open(filename, O_RDONLY, 0); + if (fd != -1) { + close(fd); + sprintf(filename, "/dev/fb%d", i); + + fd = open(filename, O_RDWR, 0); + if (fd != -1) { + if (ioctl(fd, FBIOGET_FSCREENINFO, (void*) & fix) != -1) { + if (namep) { + *namep = xnfalloc(16); + strncpy(*namep,fix.id,16); + } + + return fd; + } + } + } + + close(fd); + } + + + /* The other way is to examine the resources associated with each fb + * device and see if there is a match with the PCI device. This technique + * has some problems on certain mixed 64-bit / 32-bit architectures. + * There is a flaw in the fb_fix_screeninfo structure in that it only + * returns the low 32-bits of the address of the resources associated with + * a device. However, on a mixed architecture the base addresses of PCI + * devices, even for 32-bit applications, may be higher than 0x0f0000000. + */ + + for (i = 0; i < 8; i++) { + sprintf(filename,"/dev/fb%d",i); + if (-1 == (fd = open(filename,O_RDWR,0))) { + xf86DrvMsg(-1, X_WARNING, + "open %s: %s\n", filename, strerror(errno)); + continue; + } + if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)&fix)) { + close(fd); + continue; + } + for (j = 0; j < 6; j++) { + const pciaddr_t res_start = pPci->regions[j].base_addr; + const pciaddr_t res_end = res_start + pPci->regions[j].size; + + if ((0 != fix.smem_len && + (pciaddr_t) fix.smem_start >= res_start && + (pciaddr_t) fix.smem_start < res_end) || + (0 != fix.mmio_len && + (pciaddr_t) fix.mmio_start >= res_start && + (pciaddr_t) fix.mmio_start < res_end)) + break; + } + if (j == 6) { + close(fd); + continue; + } + if (namep) { + *namep = xnfalloc(16); + strncpy(*namep,fix.id,16); + } + return fd; + } + + if (namep) + *namep = NULL; + + xf86DrvMsg(-1, X_ERROR, + "Unable to find a valid framebuffer device\n"); + return -1; +} + +static int +fbdev_open(int scrnIndex, char *dev, char** namep) +{ + struct fb_fix_screeninfo fix; + int fd; + + /* try argument (from XF86Config) first */ + if (dev) { + fd = open(dev,O_RDWR,0); + } else { + /* second: environment variable */ + dev = getenv("FRAMEBUFFER"); + if ((NULL == dev) || ((fd = open(dev,O_RDWR,0)) == -1)) { + /* last try: default device */ + dev = "/dev/fb0"; + fd = open(dev,O_RDWR,0); + } + } + + if (fd == -1) { + xf86DrvMsg(scrnIndex, X_ERROR, + "open %s: %s\n", dev, strerror(errno)); + return -1; + } + + if (namep) { + if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)(&fix))) { + *namep = NULL; + xf86DrvMsg(scrnIndex, X_ERROR, + "FBIOGET_FSCREENINFO: %s\n", strerror(errno)); + return -1; + } else { + *namep = xnfalloc(16); + strncpy(*namep,fix.id,16); + } + } + return fd; +} + +/* -------------------------------------------------------------------- */ + +Bool +fbdevHWProbe(struct pci_device * pPci, char *device,char **namep) +{ + int fd; + + if (pPci) + fd = fbdev_open_pci(pPci,namep); + else + fd = fbdev_open(-1,device,namep); + + if (-1 == fd) + return FALSE; + close(fd); + return TRUE; +} + +Bool +fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device) +{ + fbdevHWPtr fPtr; + + TRACE_ENTER("Init"); + + fbdevHWGetRec(pScrn); + fPtr = FBDEVHWPTR(pScrn); + + /* open device */ + if (pPci) + fPtr->fd = fbdev_open_pci(pPci,NULL); + else + fPtr->fd = fbdev_open(pScrn->scrnIndex,device,NULL); + if (-1 == fPtr->fd) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to open framebuffer device, consult warnings" + " and/or errors above for possible reasons\n" + "\t(you may have to look at the server log to see" + " warnings)\n"); + return FALSE; + } + + /* get current fb device settings */ + if (-1 == ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ioctl FBIOGET_FSCREENINFO: %s\n", + strerror(errno)); + return FALSE; + } + if (-1 == ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ioctl FBIOGET_VSCREENINFO: %s\n", + strerror(errno)); + return FALSE; + } + + /* we can use the current settings as "buildin mode" */ + fbdev2xfree_timing(&fPtr->var, &fPtr->buildin); + fPtr->buildin.name = "current"; + fPtr->buildin.next = &fPtr->buildin; + fPtr->buildin.prev = &fPtr->buildin; + fPtr->buildin.type |= M_T_BUILTIN; + + return TRUE; +} + +char* +fbdevHWGetName(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + return fPtr->fix.id; +} + +int +fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + if (fbbpp) + *fbbpp = fPtr->var.bits_per_pixel; + + if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR || + fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR) + return fPtr->var.red.length+fPtr->var.green.length+ + fPtr->var.blue.length; + else + return fPtr->var.bits_per_pixel; +} + +int +fbdevHWGetLineLength(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + if (fPtr->fix.line_length) + return fPtr->fix.line_length; + else + return fPtr->var.xres_virtual*fPtr->var.bits_per_pixel/8; +} + +int +fbdevHWGetType(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + return fPtr->fix.type; +} + +int +fbdevHWGetVidmem(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + return fPtr->fix.smem_len; +} + +static Bool +fbdevHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + struct fb_var_screeninfo req_var = fPtr->var, set_var; + + TRACE_ENTER("SetMode"); + + xfree2fbdev_fblayout(pScrn, &req_var); + xfree2fbdev_timing(mode, &req_var); + +#if DEBUG + print_xfree_mode("init", mode); + print_fbdev_mode("init", &req_var); +#endif + + set_var = req_var; + + if (check) + set_var.activate = FB_ACTIVATE_TEST; + + if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void*)(&set_var))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); + return FALSE; + } + + if (!fbdev_modes_equal(&set_var, &req_var)) { + if (!check) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOPUT_VSCREENINFO succeeded but modified " + "mode\n"); +#if DEBUG + print_fbdev_mode("returned", &set_var); +#endif + return FALSE; + } + + if (!check) + fPtr->var = set_var; + + return TRUE; +} + +void +fbdevHWSetVideoModes(ScrnInfoPtr pScrn) +{ + char **modename; + DisplayModePtr mode,this,last = pScrn->modes; + + TRACE_ENTER("VerifyModes"); + if (NULL == pScrn->display->modes) + return; + + pScrn->virtualX = pScrn->display->virtualX; + pScrn->virtualY = pScrn->display->virtualY; + + for (modename = pScrn->display->modes; *modename != NULL; modename++) { + for (mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next) + if (0 == strcmp(mode->name,*modename)) + break; + if (NULL == mode) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "\tmode \"%s\" not found\n", *modename); + continue; + } + + if (!fbdevHWSetMode(pScrn, mode, TRUE)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "\tmode \"%s\" test failed\n", *modename); + continue; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "\tmode \"%s\" ok\n", *modename); + + if (pScrn->virtualX < mode->HDisplay) + pScrn->virtualX = mode->HDisplay; + if (pScrn->virtualY < mode->VDisplay) + pScrn->virtualY = mode->VDisplay; + + if (NULL == pScrn->modes) { + this = pScrn->modes = xf86DuplicateMode(mode); + this->next = this; + this->prev = this; + } else { + this = xf86DuplicateMode(mode); + this->next = pScrn->modes; + this->prev = last; + last->next = this; + pScrn->modes->prev = this; + } + last = this; + } +} + +DisplayModePtr +fbdevHWGetBuildinMode(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + return &fPtr->buildin; +} + +void +fbdevHWUseBuildinMode(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("UseBuildinMode"); + pScrn->modes = &fPtr->buildin; + pScrn->virtualX = pScrn->display->virtualX; + pScrn->virtualY = pScrn->display->virtualY; + if (pScrn->virtualX < fPtr->buildin.HDisplay) + pScrn->virtualX = fPtr->buildin.HDisplay; + if (pScrn->virtualY < fPtr->buildin.VDisplay) + pScrn->virtualY = fPtr->buildin.VDisplay; +} + +/* -------------------------------------------------------------------- */ + +static void +calculateFbmem_len(fbdevHWPtr fPtr) +{ + fPtr->fboff = (unsigned long) fPtr->fix.smem_start & ~PAGE_MASK; + fPtr->fbmem_len = (fPtr->fboff+fPtr->fix.smem_len+~PAGE_MASK) & + PAGE_MASK; +} + + +void* +fbdevHWMapVidmem(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("MapVidmem"); + if (NULL == fPtr->fbmem) { + calculateFbmem_len(fPtr); + fPtr->fbmem = mmap(NULL, fPtr->fbmem_len, PROT_READ | PROT_WRITE, + MAP_SHARED, fPtr->fd, 0); + if (-1 == (long)fPtr->fbmem) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "mmap fbmem: %s\n", strerror(errno)); + fPtr->fbmem = NULL; + } else { + /* Perhaps we'd better add fboff to fbmem and return 0 in + fbdevHWLinearOffset()? Of course we then need to mask + fPtr->fbmem with PAGE_MASK in fbdevHWUnmapVidmem() as + well. [geert] */ + } + } + pScrn->memPhysBase = (unsigned long)fPtr->fix.smem_start & (unsigned long)(PAGE_MASK); + pScrn->fbOffset = (unsigned long)fPtr->fix.smem_start & (unsigned long)(~PAGE_MASK); + return fPtr->fbmem; +} + +int +fbdevHWLinearOffset(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("LinearOffset"); + return fPtr->fboff; +} + +Bool +fbdevHWUnmapVidmem(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("UnmapVidmem"); + if (NULL != fPtr->fbmem) { + if (-1 == munmap(fPtr->fbmem, fPtr->fbmem_len)) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "munmap fbmem: %s\n", strerror(errno)); + fPtr->fbmem = NULL; + } + return TRUE; +} + +void* +fbdevHWMapMMIO(ScrnInfoPtr pScrn) +{ + unsigned int mmio_off; + + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("MapMMIO"); + if (NULL == fPtr->mmio) { + /* tell the kernel not to use accels to speed up console scrolling */ + fPtr->var.accel_flags = 0; + if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->var))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); + return FALSE; + } + mmio_off = (unsigned long) fPtr->fix.mmio_start & ~PAGE_MASK; + fPtr->mmio_len = (mmio_off+fPtr->fix.mmio_len+~PAGE_MASK) & + PAGE_MASK; + if (NULL == fPtr->fbmem) + calculateFbmem_len(fPtr); + fPtr->mmio = mmap(NULL, fPtr->mmio_len, PROT_READ | PROT_WRITE, + MAP_SHARED, fPtr->fd, fPtr->fbmem_len); + if (-1 == (long)fPtr->mmio) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "mmap mmio: %s\n", strerror(errno)); + fPtr->mmio = NULL; + } else + fPtr->mmio += mmio_off; + } + return fPtr->mmio; +} + +Bool +fbdevHWUnmapMMIO(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("UnmapMMIO"); + if (NULL != fPtr->mmio) { + if (-1 == munmap((void *)((unsigned long)fPtr->mmio & PAGE_MASK), fPtr->mmio_len)) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "munmap mmio: %s\n", strerror(errno)); + fPtr->mmio = NULL; + /* FIXME: restore var.accel_flags [geert] */ + } + return TRUE; +} + +/* -------------------------------------------------------------------- */ + +Bool +fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + pScrn->vtSema = TRUE; + + /* set */ + if (!fbdevHWSetMode(pScrn, mode, FALSE)) + return FALSE; + + /* read back */ + if (0 != ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOGET_FSCREENINFO: %s\n", strerror(errno)); + return FALSE; + } + if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); + return FALSE; + } + + if (pScrn->defaultVisual == TrueColor || + pScrn->defaultVisual == DirectColor) { + /* XXX: This is a hack, but it should be a NOP for all the setups that + * worked before and actually seems to fix some others... + */ + pScrn->offset.red = fPtr->var.red.offset; + pScrn->offset.green = fPtr->var.green.offset; + pScrn->offset.blue = fPtr->var.blue.offset; + pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset; + pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset; + pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset; + } + + return TRUE; +} + +/* -------------------------------------------------------------------- */ +/* video mode save/restore */ + +/* TODO: colormap */ +void +fbdevHWSave(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("Save"); + if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->saved_var))) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); +} + +void +fbdevHWRestore(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("Restore"); + if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->saved_var))) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); +} + +/* -------------------------------------------------------------------- */ +/* callback for xf86HandleColormaps */ + +void +fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + struct fb_cmap cmap; + unsigned short red,green,blue; + int i; + + TRACE_ENTER("LoadPalette"); + cmap.len = 1; + cmap.red = &red; + cmap.green = &green; + cmap.blue = &blue; + cmap.transp = NULL; + for (i = 0; i < numColors; i++) { + cmap.start = indices[i]; + red = (colors[indices[i]].red << 8) | + colors[indices[i]].red; + green = (colors[indices[i]].green << 8) | + colors[indices[i]].green; + blue = (colors[indices[i]].blue << 8) | + colors[indices[i]].blue; + if (-1 == ioctl(fPtr->fd,FBIOPUTCMAP,(void*)&cmap)) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOPUTCMAP: %s\n", strerror(errno)); + } +} + +/* -------------------------------------------------------------------- */ +/* these can be hooked directly into ScrnInfoRec */ + +ModeStatus +fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE_ENTER("ValidMode"); + + if (!fbdevHWSetMode(pScrn, mode, TRUE)) + return MODE_BAD; + + return MODE_OK; +} + +Bool +fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE_ENTER("SwitchMode"); + + if (!fbdevHWSetMode(pScrn, mode, FALSE)) + return FALSE; + + return TRUE; +} + +void +fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + TRACE_ENTER("AdjustFrame"); + if ( x < 0 || x + fPtr->var.xres > fPtr->var.xres_virtual || + y < 0 || y + fPtr->var.yres > fPtr->var.yres_virtual ) + return; + + fPtr->var.xoffset = x; + fPtr->var.yoffset = y; + if (-1 == ioctl(fPtr->fd,FBIOPAN_DISPLAY,(void*)&fPtr->var)) + xf86DrvMsgVerb(scrnIndex, X_WARNING, 5, + "FBIOPAN_DISPLAY: %s\n", strerror(errno)); +} + +Bool +fbdevHWEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE_ENTER("EnterVT"); + if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) + return FALSE; + fbdevHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + return TRUE; +} + +void +fbdevHWLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE_ENTER("LeaveVT"); + fbdevHWRestore(pScrn); +} + +void +fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + unsigned long fbmode; + + TRACE_ENTER("DPMSSet"); + if (!pScrn->vtSema) + return; + + switch (mode) { + case DPMSModeOn: + fbmode = 0; + break; + case DPMSModeStandby: + fbmode = 2; + break; + case DPMSModeSuspend: + fbmode = 3; + break; + case DPMSModeOff: + fbmode = 4; + break; + default: + return; + } + + if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode)) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOBLANK: %s\n", strerror(errno)); +} + +Bool +fbdevHWSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + unsigned long unblank; + + TRACE_ENTER("HWSaveScreen"); + if (!pScrn->vtSema) + return TRUE; + + unblank = xf86IsUnblank(mode); + + if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1-unblank))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOBLANK: %s\n", strerror(errno)); + return FALSE; + } + + return TRUE; +} + +xf86SwitchModeProc * +fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; } + +xf86AdjustFrameProc * +fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; } + +xf86EnterVTProc * +fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; } + +xf86LeaveVTProc * +fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; } + +xf86ValidModeProc * +fbdevHWValidModeWeak(void) { return fbdevHWValidMode; } + +xf86DPMSSetProc * +fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; } + +xf86LoadPaletteProc * +fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; } + +SaveScreenProcPtr +fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; } diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h new file mode 100644 index 000000000..614dc6fed --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.h @@ -0,0 +1,62 @@ + +#ifndef _FBDEVHW_H_ +#define _FBDEVHW_H_ + +#include "xf86str.h" +#include "colormapst.h" + +#include <pciaccess.h> + +#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ +#define FBDEVHW_PLANES 1 /* Non interleaved planes */ +#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ +#define FBDEVHW_TEXT 3 /* Text/attributes */ +#define FBDEVHW_VGA_PLANES 4 /* EGA/VGA planes */ + +Bool fbdevHWGetRec(ScrnInfoPtr pScrn); +void fbdevHWFreeRec(ScrnInfoPtr pScrn); + +Bool fbdevHWProbe(struct pci_device * pPci, char *device, char **namep); +Bool fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device); + +char* fbdevHWGetName(ScrnInfoPtr pScrn); +int fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp); +int fbdevHWGetLineLength(ScrnInfoPtr pScrn); +int fbdevHWGetType(ScrnInfoPtr pScrn); +int fbdevHWGetVidmem(ScrnInfoPtr pScrn); + +void* fbdevHWMapVidmem(ScrnInfoPtr pScrn); +int fbdevHWLinearOffset(ScrnInfoPtr pScrn); +Bool fbdevHWUnmapVidmem(ScrnInfoPtr pScrn); +void* fbdevHWMapMMIO(ScrnInfoPtr pScrn); +Bool fbdevHWUnmapMMIO(ScrnInfoPtr pScrn); + +void fbdevHWSetVideoModes(ScrnInfoPtr pScrn); +DisplayModePtr fbdevHWGetBuildinMode(ScrnInfoPtr pScrn); +void fbdevHWUseBuildinMode(ScrnInfoPtr pScrn); +Bool fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +void fbdevHWSave(ScrnInfoPtr pScrn); +void fbdevHWRestore(ScrnInfoPtr pScrn); + +void fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual); + +ModeStatus fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags); +Bool fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +void fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags); +Bool fbdevHWEnterVT(int scrnIndex, int flags); +void fbdevHWLeaveVT(int scrnIndex, int flags); +void fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); + +Bool fbdevHWSaveScreen(ScreenPtr pScreen, int mode); + +xf86SwitchModeProc *fbdevHWSwitchModeWeak(void); +xf86AdjustFrameProc *fbdevHWAdjustFrameWeak(void); +xf86EnterVTProc *fbdevHWEnterVTWeak(void); +xf86LeaveVTProc *fbdevHWLeaveVTWeak(void); +xf86ValidModeProc *fbdevHWValidModeWeak(void); +xf86DPMSSetProc *fbdevHWDPMSSetWeak(void); +xf86LoadPaletteProc *fbdevHWLoadPaletteWeak(void); +SaveScreenProcPtr fbdevHWSaveScreenWeak(void); + +#endif diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.man.pre b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.man.pre new file mode 100644 index 000000000..deeced860 --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.man.pre @@ -0,0 +1,22 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.man,v 1.1 2001/01/24 00:06:34 dawes Exp $ +.TH FBDEVHW __drivermansuffix__ __vendorversion__ +.SH NAME +fbdevhw \- os-specific submodule for framebuffer device access +.SH DESCRIPTION +.B fbdevhw +provides functions for talking to a framebuffer device. It is +os-specific. It is a submodule used by other video drivers. +A +.B fbdevhw +module is currently available for linux framebuffer devices. +.PP +fbdev(__drivermansuffix__) is a non-accelerated driver which runs on top of the +fbdevhw module. fbdevhw can be used by other drivers too, this +is usually activated with `Option "UseFBDev"' in the device section. +.SH "SEE ALSO" +__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), +xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__), +fbdev(__drivermansuffix__) +.SH AUTHORS +Authors include: Gerd Knorr, based on the XF68_FBDev Server code +(Martin Schaller, Geert Uytterhoeven). diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c b/xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c new file mode 100644 index 000000000..191a6d33d --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhwstub.c @@ -0,0 +1,196 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86cmap.h" +#include "fbdevhw.h" + +/* Stubs for the static server on platforms that don't support fbdev */ + + +Bool +fbdevHWGetRec(ScrnInfoPtr pScrn) +{ + return FALSE; +} + +void +fbdevHWFreeRec(ScrnInfoPtr pScrn) +{ +} + + +Bool +fbdevHWProbe(struct pci_device *pPci, char *device, char **namep) +{ + return FALSE; +} + +Bool +fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device) +{ + xf86Msg(X_ERROR, "fbdevhw is not available on this platform\n"); + return FALSE; +} + +char* +fbdevHWGetName(ScrnInfoPtr pScrn) +{ + return NULL; +} + +int +fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp) +{ + return -1; +} + +int +fbdevHWGetLineLength(ScrnInfoPtr pScrn) +{ + return -1; /* Should cause something spectacular... */ +} + +int +fbdevHWGetType(ScrnInfoPtr pScrn) +{ + return -1; +} + +int +fbdevHWGetVidmem(ScrnInfoPtr pScrn) +{ + return -1; +} + +void +fbdevHWSetVideoModes(ScrnInfoPtr pScrn) +{ +} + +DisplayModePtr +fbdevHWGetBuildinMode(ScrnInfoPtr pScrn) +{ + return NULL; +} + +void +fbdevHWUseBuildinMode(ScrnInfoPtr pScrn) +{ +} + +void* +fbdevHWMapVidmem(ScrnInfoPtr pScrn) +{ + return NULL; +} + +int +fbdevHWLinearOffset(ScrnInfoPtr pScrn) +{ + return 0; +} + +Bool +fbdevHWUnmapVidmem(ScrnInfoPtr pScrn) +{ + return FALSE; +} + +void* +fbdevHWMapMMIO(ScrnInfoPtr pScrn) +{ + return NULL; +} + +Bool +fbdevHWUnmapMMIO(ScrnInfoPtr pScrn) +{ + return FALSE; +} + +Bool +fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + return FALSE; +} + +void +fbdevHWSave(ScrnInfoPtr pScrn) +{ +} + +void +fbdevHWRestore(ScrnInfoPtr pScrn) +{ +} + +void +fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual) +{ +} + +ModeStatus +fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + return MODE_ERROR; +} + +Bool +fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return FALSE; +} + +void +fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags) +{ +} + +Bool +fbdevHWEnterVT(int scrnIndex, int flags) +{ + return FALSE; +} + +void +fbdevHWLeaveVT(int scrnIndex, int flags) +{ +} + +void +fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ +} + +Bool +fbdevHWSaveScreen(ScreenPtr pScreen, int mode) +{ + return FALSE; +} + +xf86SwitchModeProc * +fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; } + +xf86AdjustFrameProc * +fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; } + +xf86EnterVTProc * +fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; } + +xf86LeaveVTProc * +fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; } + +xf86ValidModeProc * +fbdevHWValidModeWeak(void) { return fbdevHWValidMode; } + +xf86DPMSSetProc * +fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; } + +xf86LoadPaletteProc * +fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; } + +SaveScreenProcPtr +fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; } diff --git a/xorg-server/hw/xfree86/fbdevhw/fbpriv.h b/xorg-server/hw/xfree86/fbdevhw/fbpriv.h new file mode 100644 index 000000000..4c08ec15d --- /dev/null +++ b/xorg-server/hw/xfree86/fbdevhw/fbpriv.h @@ -0,0 +1,265 @@ +/* + * copyed from from linux kernel 2.2.4 + * removed internal stuff (#ifdef __KERNEL__) + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _LINUX_FB_H +#define _LINUX_FB_H + +#include <asm/types.h> + +/* Definitions of frame buffers */ + +#define FB_MAJOR 29 + +#define FB_MODES_SHIFT 5 /* 32 modes per framebuffer */ +#define FB_NUM_MINORS 256 /* 256 Minors */ +#define FB_MAX (FB_NUM_MINORS / (1 << FB_MODES_SHIFT)) +#define GET_FB_IDX(node) (MINOR(node) >> FB_MODES_SHIFT) + +/* ioctls + 0x46 is 'F' */ +#define FBIOGET_VSCREENINFO 0x4600 +#define FBIOPUT_VSCREENINFO 0x4601 +#define FBIOGET_FSCREENINFO 0x4602 +#define FBIOGETCMAP 0x4604 +#define FBIOPUTCMAP 0x4605 +#define FBIOPAN_DISPLAY 0x4606 +/* 0x4607-0x460B are defined below */ +/* #define FBIOGET_MONITORSPEC 0x460C */ +/* #define FBIOPUT_MONITORSPEC 0x460D */ +/* #define FBIOSWITCH_MONIBIT 0x460E */ +#define FBIOGET_CON2FBMAP 0x460F +#define FBIOPUT_CON2FBMAP 0x4610 +#define FBIOBLANK 0x4611 + +#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ +#define FB_TYPE_PLANES 1 /* Non interleaved planes */ +#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */ +#define FB_TYPE_TEXT 3 /* Text/attributes */ + +#define FB_AUX_TEXT_MDA 0 /* Monochrome text */ +#define FB_AUX_TEXT_CGA 1 /* CGA/EGA/VGA Color text */ +#define FB_AUX_TEXT_S3_MMIO 2 /* S3 MMIO fasttext */ +#define FB_AUX_TEXT_MGA_STEP16 3 /* MGA Millenium I: text, attr, 14 reserved bytes */ +#define FB_AUX_TEXT_MGA_STEP8 4 /* other MGAs: text, attr, 6 reserved bytes */ + +#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */ +#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */ +#define FB_VISUAL_TRUECOLOR 2 /* True color */ +#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */ +#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */ +#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */ + +#define FB_ACCEL_NONE 0 /* no hardware accelerator */ +#define FB_ACCEL_ATARIBLITT 1 /* Atari Blitter */ +#define FB_ACCEL_AMIGABLITT 2 /* Amiga Blitter */ +#define FB_ACCEL_S3_TRIO64 3 /* Cybervision64 (S3 Trio64) */ +#define FB_ACCEL_NCR_77C32BLT 4 /* RetinaZ3 (NCR 77C32BLT) */ +#define FB_ACCEL_S3_VIRGE 5 /* Cybervision64/3D (S3 ViRGE) */ +#define FB_ACCEL_ATI_MACH64GX 6 /* ATI Mach 64GX family */ +#define FB_ACCEL_DEC_TGA 7 /* DEC 21030 TGA */ +#define FB_ACCEL_ATI_MACH64CT 8 /* ATI Mach 64CT family */ +#define FB_ACCEL_ATI_MACH64VT 9 /* ATI Mach 64CT family VT class */ +#define FB_ACCEL_ATI_MACH64GT 10 /* ATI Mach 64CT family GT class */ +#define FB_ACCEL_SUN_CREATOR 11 /* Sun Creator/Creator3D */ +#define FB_ACCEL_SUN_CGSIX 12 /* Sun cg6 */ +#define FB_ACCEL_SUN_LEO 13 /* Sun leo/zx */ +#define FB_ACCEL_IMS_TWINTURBO 14 /* IMS Twin Turbo */ +#define FB_ACCEL_3DLABS_PERMEDIA2 15 /* 3Dlabs Permedia 2 */ +#define FB_ACCEL_MATROX_MGA2064W 16 /* Matrox MGA2064W (Millenium) */ +#define FB_ACCEL_MATROX_MGA1064SG 17 /* Matrox MGA1064SG (Mystique) */ +#define FB_ACCEL_MATROX_MGA2164W 18 /* Matrox MGA2164W (Millenium II) */ +#define FB_ACCEL_MATROX_MGA2164W_AGP 19 /* Matrox MGA2164W (Millenium II) */ +#define FB_ACCEL_MATROX_MGAG100 20 /* Matrox G100 (Productiva G100) */ +#define FB_ACCEL_MATROX_MGAG200 21 /* Matrox G200 (Myst, Mill, ...) */ +#define FB_ACCEL_SUN_CG14 22 /* Sun cgfourteen */ +#define FB_ACCEL_SUN_BWTWO 23 /* Sun bwtwo */ +#define FB_ACCEL_SUN_CGTHREE 24 /* Sun cgthree */ +#define FB_ACCEL_SUN_TCX 25 /* Sun tcx */ +#define FB_ACCEL_MATROX_MGAG400 26 /* Matrox G400 */ +#define FB_ACCEL_NV3 27 /* nVidia RIVA 128 */ +#define FB_ACCEL_NV4 28 /* nVidia RIVA TNT */ +#define FB_ACCEL_NV5 29 /* nVidia RIVA TNT2 */ +#define FB_ACCEL_CT_6555x 30 /* C&T 6555x */ +#define FB_ACCEL_3DFX_BANSHEE 31 /* 3Dfx Banshee */ +#define FB_ACCEL_ATI_RAGE128 32 /* ATI Rage128 family */ + +struct fb_fix_screeninfo { + char id[16]; /* identification string eg "TT Builtin" */ + char *smem_start; /* Start of frame buffer mem */ + /* (physical address) */ + __u32 smem_len; /* Length of frame buffer mem */ + __u32 type; /* see FB_TYPE_* */ + __u32 type_aux; /* Interleave for interleaved Planes */ + __u32 visual; /* see FB_VISUAL_* */ + __u16 xpanstep; /* zero if no hardware panning */ + __u16 ypanstep; /* zero if no hardware panning */ + __u16 ywrapstep; /* zero if no hardware ywrap */ + __u32 line_length; /* length of a line in bytes */ + char *mmio_start; /* Start of Memory Mapped I/O */ + /* (physical address) */ + __u32 mmio_len; /* Length of Memory Mapped I/O */ + __u32 accel; /* Type of acceleration available */ + __u16 reserved[3]; /* Reserved for future compatibility */ +}; + +/* Interpretation of offset for color fields: All offsets are from the right, + * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you + * can use the offset as right argument to <<). A pixel afterwards is a bit + * stream and is written to video memory as that unmodified. This implies + * big-endian byte order if bits_per_pixel is greater than 8. + */ +struct fb_bitfield { + __u32 offset; /* beginning of bitfield */ + __u32 length; /* length of bitfield */ + __u32 msb_right; /* != 0 : Most significant bit is */ + /* right */ +}; + +#define FB_NONSTD_HAM 1 /* Hold-And-Modify (HAM) */ + +#define FB_ACTIVATE_NOW 0 /* set values immediately (or vbl)*/ +#define FB_ACTIVATE_NXTOPEN 1 /* activate on next open */ +#define FB_ACTIVATE_TEST 2 /* don't set, round up impossible */ +#define FB_ACTIVATE_MASK 15 + /* values */ +#define FB_ACTIVATE_VBL 16 /* activate values on next vbl */ +#define FB_CHANGE_CMAP_VBL 32 /* change colormap on vbl */ +#define FB_ACTIVATE_ALL 64 /* change all VCs on this fb */ + +#define FB_ACCELF_TEXT 1 /* text mode acceleration */ + +#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */ +#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */ +#define FB_SYNC_EXT 4 /* external sync */ +#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */ +#define FB_SYNC_BROADCAST 16 /* broadcast video timings */ + /* vtotal = 144d/288n/576i => PAL */ + /* vtotal = 121d/242n/484i => NTSC */ +#define FB_SYNC_ON_GREEN 32 /* sync on green */ + +#define FB_VMODE_NONINTERLACED 0 /* non interlaced */ +#define FB_VMODE_INTERLACED 1 /* interlaced */ +#define FB_VMODE_DOUBLE 2 /* double scan */ +#define FB_VMODE_MASK 255 + +#define FB_VMODE_YWRAP 256 /* ywrap instead of panning */ +#define FB_VMODE_SMOOTH_XPAN 512 /* smooth xpan possible (internally used) */ +#define FB_VMODE_CONUPDATE 512 /* don't update x/yoffset */ + +struct fb_var_screeninfo { + __u32 xres; /* visible resolution */ + __u32 yres; + __u32 xres_virtual; /* virtual resolution */ + __u32 yres_virtual; + __u32 xoffset; /* offset from virtual to visible */ + __u32 yoffset; /* resolution */ + + __u32 bits_per_pixel; /* guess what */ + __u32 grayscale; /* != 0 Graylevels instead of colors */ + + struct fb_bitfield red; /* bitfield in fb mem if true color, */ + struct fb_bitfield green; /* else only length is significant */ + struct fb_bitfield blue; + struct fb_bitfield transp; /* transparency */ + + __u32 nonstd; /* != 0 Non standard pixel format */ + + __u32 activate; /* see FB_ACTIVATE_* */ + + __u32 height; /* height of picture in mm */ + __u32 width; /* width of picture in mm */ + + __u32 accel_flags; /* acceleration flags (hints) */ + + /* Timing: All values in pixclocks, except pixclock (of course) */ + __u32 pixclock; /* pixel clock in ps (pico seconds) */ + __u32 left_margin; /* time from sync to picture */ + __u32 right_margin; /* time from picture to sync */ + __u32 upper_margin; /* time from sync to picture */ + __u32 lower_margin; + __u32 hsync_len; /* length of horizontal sync */ + __u32 vsync_len; /* length of vertical sync */ + __u32 sync; /* see FB_SYNC_* */ + __u32 vmode; /* see FB_VMODE_* */ + __u32 reserved[6]; /* Reserved for future compatibility */ +}; + +struct fb_cmap { + __u32 start; /* First entry */ + __u32 len; /* Number of entries */ + __u16 *red; /* Red values */ + __u16 *green; + __u16 *blue; + __u16 *transp; /* transparency, can be NULL */ +}; + +struct fb_con2fbmap { + __u32 console; + __u32 framebuffer; +}; + +struct fb_monspecs { + __u32 hfmin; /* hfreq lower limit (Hz) */ + __u32 hfmax; /* hfreq upper limit (Hz) */ + __u16 vfmin; /* vfreq lower limit (Hz) */ + __u16 vfmax; /* vfreq upper limit (Hz) */ + unsigned dpms : 1; /* supports DPMS */ +}; + +#if 1 + +#define FBCMD_GET_CURRENTPAR 0xDEAD0005 +#define FBCMD_SET_CURRENTPAR 0xDEAD8005 + +#endif + + +#if 1 /* Preliminary */ + + /* + * Hardware Cursor + */ + +#define FBIOGET_FCURSORINFO 0x4607 +#define FBIOGET_VCURSORINFO 0x4608 +#define FBIOPUT_VCURSORINFO 0x4609 +#define FBIOGET_CURSORSTATE 0x460A +#define FBIOPUT_CURSORSTATE 0x460B + + +struct fb_fix_cursorinfo { + __u16 crsr_width; /* width and height of the cursor in */ + __u16 crsr_height; /* pixels (zero if no cursor) */ + __u16 crsr_xsize; /* cursor size in display pixels */ + __u16 crsr_ysize; + __u16 crsr_color1; /* colormap entry for cursor color1 */ + __u16 crsr_color2; /* colormap entry for cursor color2 */ +}; + +struct fb_var_cursorinfo { + __u16 width; + __u16 height; + __u16 xspot; + __u16 yspot; + __u8 data[1]; /* field with [height][width] */ +}; + +struct fb_cursorstate { + __s16 xoffset; + __s16 yoffset; + __u16 mode; +}; + +#define FB_CURSOR_OFF 0 +#define FB_CURSOR_ON 1 +#define FB_CURSOR_FLASH 2 + +#endif /* Preliminary */ + +#endif /* _LINUX_FB_H */ diff --git a/xorg-server/hw/xfree86/i2c/Makefile.am b/xorg-server/hw/xfree86/i2c/Makefile.am new file mode 100644 index 000000000..a16d88071 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/Makefile.am @@ -0,0 +1,43 @@ +noinst_LIBRARIES = libi2c.a + +multimediadir = $(moduledir)/multimedia +multimedia_LTLIBRARIES = \ + bt829_drv.la \ + fi1236_drv.la \ + msp3430_drv.la \ + tda8425_drv.la \ + tda9850_drv.la \ + tda9885_drv.la \ + uda1380_drv.la + +libi2c_a_SOURCES = xf86i2c.c + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +sdk_HEADERS = xf86i2c.h bt829.h fi1236.h msp3430.h tda8425.h tda9850.h tda9885.h uda1380.h i2c_def.h + +# +# i2c drivers +# +bt829_drv_la_LDFLAGS = -module -avoid-version +bt829_drv_la_SOURCES = bt829.c bt829.h bt829_module.c + +fi1236_drv_la_LDFLAGS = -module -avoid-version +fi1236_drv_la_SOURCES = fi1236.c fi1236.h fi1236_module.c + +msp3430_drv_la_LDFLAGS = -module -avoid-version +msp3430_drv_la_SOURCES = msp3430.c msp3430.h msp3430_module.c + +tda8425_drv_la_LDFLAGS = -module -avoid-version +tda8425_drv_la_SOURCES = tda8425.c tda8425.h tda8425_module.c + +tda9850_drv_la_LDFLAGS = -module -avoid-version +tda9850_drv_la_SOURCES = tda9850.c tda9850.h tda9850_module.c + +tda9885_drv_la_LDFLAGS = -module -avoid-version +tda9885_drv_la_SOURCES = tda9885.c tda9885.h tda9885_module.c + +uda1380_drv_la_LDFLAGS = -module -avoid-version +uda1380_drv_la_SOURCES = uda1380.c uda1380.h uda1380_module.c diff --git a/xorg-server/hw/xfree86/i2c/Makefile.in b/xorg-server/hw/xfree86/i2c/Makefile.in new file mode 100644 index 000000000..dec6218fd --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/Makefile.in @@ -0,0 +1,810 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/i2c +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libi2c_a_AR = $(AR) $(ARFLAGS) +libi2c_a_LIBADD = +am_libi2c_a_OBJECTS = xf86i2c.$(OBJEXT) +libi2c_a_OBJECTS = $(am_libi2c_a_OBJECTS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(multimediadir)" "$(DESTDIR)$(sdkdir)" +multimediaLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(multimedia_LTLIBRARIES) +bt829_drv_la_LIBADD = +am_bt829_drv_la_OBJECTS = bt829.lo bt829_module.lo +bt829_drv_la_OBJECTS = $(am_bt829_drv_la_OBJECTS) +bt829_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(bt829_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +fi1236_drv_la_LIBADD = +am_fi1236_drv_la_OBJECTS = fi1236.lo fi1236_module.lo +fi1236_drv_la_OBJECTS = $(am_fi1236_drv_la_OBJECTS) +fi1236_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(fi1236_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +msp3430_drv_la_LIBADD = +am_msp3430_drv_la_OBJECTS = msp3430.lo msp3430_module.lo +msp3430_drv_la_OBJECTS = $(am_msp3430_drv_la_OBJECTS) +msp3430_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(msp3430_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +tda8425_drv_la_LIBADD = +am_tda8425_drv_la_OBJECTS = tda8425.lo tda8425_module.lo +tda8425_drv_la_OBJECTS = $(am_tda8425_drv_la_OBJECTS) +tda8425_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(tda8425_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +tda9850_drv_la_LIBADD = +am_tda9850_drv_la_OBJECTS = tda9850.lo tda9850_module.lo +tda9850_drv_la_OBJECTS = $(am_tda9850_drv_la_OBJECTS) +tda9850_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(tda9850_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +tda9885_drv_la_LIBADD = +am_tda9885_drv_la_OBJECTS = tda9885.lo tda9885_module.lo +tda9885_drv_la_OBJECTS = $(am_tda9885_drv_la_OBJECTS) +tda9885_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(tda9885_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +uda1380_drv_la_LIBADD = +am_uda1380_drv_la_OBJECTS = uda1380.lo uda1380_module.lo +uda1380_drv_la_OBJECTS = $(am_uda1380_drv_la_OBJECTS) +uda1380_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(uda1380_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libi2c_a_SOURCES) $(bt829_drv_la_SOURCES) \ + $(fi1236_drv_la_SOURCES) $(msp3430_drv_la_SOURCES) \ + $(tda8425_drv_la_SOURCES) $(tda9850_drv_la_SOURCES) \ + $(tda9885_drv_la_SOURCES) $(uda1380_drv_la_SOURCES) +DIST_SOURCES = $(libi2c_a_SOURCES) $(bt829_drv_la_SOURCES) \ + $(fi1236_drv_la_SOURCES) $(msp3430_drv_la_SOURCES) \ + $(tda8425_drv_la_SOURCES) $(tda9850_drv_la_SOURCES) \ + $(tda9885_drv_la_SOURCES) $(uda1380_drv_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = libi2c.a +multimediadir = $(moduledir)/multimedia +multimedia_LTLIBRARIES = \ + bt829_drv.la \ + fi1236_drv.la \ + msp3430_drv.la \ + tda8425_drv.la \ + tda9850_drv.la \ + tda9885_drv.la \ + uda1380_drv.la + +libi2c_a_SOURCES = xf86i2c.c +INCLUDES = $(XORG_INCS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +sdk_HEADERS = xf86i2c.h bt829.h fi1236.h msp3430.h tda8425.h tda9850.h tda9885.h uda1380.h i2c_def.h + +# +# i2c drivers +# +bt829_drv_la_LDFLAGS = -module -avoid-version +bt829_drv_la_SOURCES = bt829.c bt829.h bt829_module.c +fi1236_drv_la_LDFLAGS = -module -avoid-version +fi1236_drv_la_SOURCES = fi1236.c fi1236.h fi1236_module.c +msp3430_drv_la_LDFLAGS = -module -avoid-version +msp3430_drv_la_SOURCES = msp3430.c msp3430.h msp3430_module.c +tda8425_drv_la_LDFLAGS = -module -avoid-version +tda8425_drv_la_SOURCES = tda8425.c tda8425.h tda8425_module.c +tda9850_drv_la_LDFLAGS = -module -avoid-version +tda9850_drv_la_SOURCES = tda9850.c tda9850.h tda9850_module.c +tda9885_drv_la_LDFLAGS = -module -avoid-version +tda9885_drv_la_SOURCES = tda9885.c tda9885.h tda9885_module.c +uda1380_drv_la_LDFLAGS = -module -avoid-version +uda1380_drv_la_SOURCES = uda1380.c uda1380.h uda1380_module.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/i2c/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/i2c/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libi2c.a: $(libi2c_a_OBJECTS) $(libi2c_a_DEPENDENCIES) + -rm -f libi2c.a + $(libi2c_a_AR) libi2c.a $(libi2c_a_OBJECTS) $(libi2c_a_LIBADD) + $(RANLIB) libi2c.a +install-multimediaLTLIBRARIES: $(multimedia_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(multimediadir)" || $(MKDIR_P) "$(DESTDIR)$(multimediadir)" + @list='$(multimedia_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(multimediaLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(multimediadir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(multimediaLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(multimediadir)/$$f"; \ + else :; fi; \ + done + +uninstall-multimediaLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(multimedia_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(multimediadir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(multimediadir)/$$p"; \ + done + +clean-multimediaLTLIBRARIES: + -test -z "$(multimedia_LTLIBRARIES)" || rm -f $(multimedia_LTLIBRARIES) + @list='$(multimedia_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +bt829_drv.la: $(bt829_drv_la_OBJECTS) $(bt829_drv_la_DEPENDENCIES) + $(bt829_drv_la_LINK) -rpath $(multimediadir) $(bt829_drv_la_OBJECTS) $(bt829_drv_la_LIBADD) $(LIBS) +fi1236_drv.la: $(fi1236_drv_la_OBJECTS) $(fi1236_drv_la_DEPENDENCIES) + $(fi1236_drv_la_LINK) -rpath $(multimediadir) $(fi1236_drv_la_OBJECTS) $(fi1236_drv_la_LIBADD) $(LIBS) +msp3430_drv.la: $(msp3430_drv_la_OBJECTS) $(msp3430_drv_la_DEPENDENCIES) + $(msp3430_drv_la_LINK) -rpath $(multimediadir) $(msp3430_drv_la_OBJECTS) $(msp3430_drv_la_LIBADD) $(LIBS) +tda8425_drv.la: $(tda8425_drv_la_OBJECTS) $(tda8425_drv_la_DEPENDENCIES) + $(tda8425_drv_la_LINK) -rpath $(multimediadir) $(tda8425_drv_la_OBJECTS) $(tda8425_drv_la_LIBADD) $(LIBS) +tda9850_drv.la: $(tda9850_drv_la_OBJECTS) $(tda9850_drv_la_DEPENDENCIES) + $(tda9850_drv_la_LINK) -rpath $(multimediadir) $(tda9850_drv_la_OBJECTS) $(tda9850_drv_la_LIBADD) $(LIBS) +tda9885_drv.la: $(tda9885_drv_la_OBJECTS) $(tda9885_drv_la_DEPENDENCIES) + $(tda9885_drv_la_LINK) -rpath $(multimediadir) $(tda9885_drv_la_OBJECTS) $(tda9885_drv_la_LIBADD) $(LIBS) +uda1380_drv.la: $(uda1380_drv_la_OBJECTS) $(uda1380_drv_la_DEPENDENCIES) + $(uda1380_drv_la_LINK) -rpath $(multimediadir) $(uda1380_drv_la_OBJECTS) $(uda1380_drv_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bt829.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bt829_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fi1236.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fi1236_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msp3430.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msp3430_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tda8425.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tda8425_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tda9850.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tda9850_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tda9885.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tda9885_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uda1380.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uda1380_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86i2c.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(multimediadir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-multimediaLTLIBRARIES \ + clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-multimediaLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-multimediaLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-multimediaLTLIBRARIES \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man \ + install-multimediaLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-multimediaLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/i2c/bt829.c b/xorg-server/hw/xfree86/i2c/bt829.c new file mode 100644 index 000000000..3963ecf47 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/bt829.c @@ -0,0 +1,745 @@ +/* TODO: clean up/fix CC code */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +#include "xf86.h" +#include "xf86i2c.h" +#include "bt829.h" +#include "i2c_def.h" + +/* Changing the following settings (especially VCROP) may */ +/* require modifying code that calls this driver. */ +#define HCROP 0 /* amount to crop from the left and right edges */ +#define VCROP 0 /* amount to crop from the top and bottom edges */ + +#define BTVERSION (bt->id>>4) + +#define H(X) ( ((X)>>8) & 0xFF ) +#define L(X) ( (X) & 0xFF ) + +#define LIMIT(X,A,B) (((X)<(A)) ? (A) : ((X)>(B)) ? (B) : (X) ) + +/* Bt829 family chip ID's */ +#define BT815 0x02 +#define BT817 0x06 +#define BT819 0x07 +#define BT827 0x0C +#define BT829 0x0E + +/* Bt829 registers */ +#define STATUS 0x00 /* Device Status */ +#define IFORM 0x01 /* Input Format */ +#define TDEC 0x02 /* Temporal Decimation */ +#define CROP 0x03 /* MSB Cropping */ +#define VDELAY_LO 0x04 /* Vertical Delay */ +#define VACTIVE_LO 0x05 /* Vertical Active */ +#define HDELAY_LO 0x06 /* Horizontal Delay */ +#define HACTIVE_LO 0x07 /* Horizontal Active */ +#define HSCALE_HI 0x08 /* Horizontal Scaling */ +#define HSCALE_LO 0x09 /* Horizontal Scaling */ +#define BRIGHT 0x0A /* Brightness Control */ +#define CONTROL 0x0B /* Miscellaneous Control */ +#define CONTRAST_LO 0x0C /* Luma Gain (Contrast) */ +#define SAT_U_LO 0x0D /* Chroma (U) Gain (Saturation) */ +#define SAT_V_LO 0x0E /* Chroma (V) Gain (Saturation) */ +#define HUE 0x0F /* Hue Control */ +#define SCLOOP 0x10 /* SC Loop Control */ +#define WC_UP 0x11 /* White Crush Up Count */ +#define OFORM 0x12 /* Output Format */ +#define VSCALE_HI 0x13 /* Vertical Scaling */ +#define VSCALE_LO 0x14 /* Vertical Scaling */ +#define TEST 0x15 /* Test Control */ +#define VPOLE 0x16 /* Video Timing Polarity */ +#define IDCODE 0x17 /* ID Code */ +#define ADELAY 0x18 /* AGC Delay */ +#define BDELAY 0x19 /* Burst Gate Delay */ +#define ADC 0x1A /* ADC Interface */ +#define VTC 0x1B /* Video Timing Control */ +#define CC_STATUS 0x1C /* Extended Data Services/Closed Capt Status */ +#define CC_DATA 0x1D /* Extended Data Services/Closed Capt Data */ +#define WC_DN 0x1E /* White Crush Down Count */ +#define SRESET 0x1F /* Software Reset */ +#define P_IO 0x3F /* Programmable I/O */ + +static CARD8 btread(BT829Ptr bt, CARD8 reg) +{ + CARD8 v; + + I2C_WriteRead(&(bt->d), ®, 1, &v, 1); + + return v; +} + +static void btwrite(BT829Ptr bt, CARD8 reg, CARD8 val) +{ + CARD8 data[2]; + + data[0] = reg; + data[1] = val; + I2C_WriteRead(&(bt->d), data, 2, NULL, 0); +} + +/* + * Register access + */ +static void btwrite_status(BT829Ptr bt) /* STATUS */ +{ + btwrite(bt, STATUS, 0x00); /* clear */ +} + +static void btwrite_iform(BT829Ptr bt) /* IFORM */ +{ + int xtsel; + + switch (bt->format) { + case BT829_NTSC: + case BT829_NTSC_JAPAN: + case BT829_PAL_M: + case BT829_PAL_N_COMB: /* gatos says xtsel = 2 */ + xtsel = 1; + break; + case BT829_PAL: + case BT829_PAL_N: + case BT829_SECAM: + xtsel = 2; + break; + default: /* shouldn't get here */ + xtsel = 3; /* hardware default */ + break; + } + + btwrite(bt, IFORM, (bt->mux<<5) | (xtsel<<3) | bt->format); +} + +static void btwrite_tdec(BT829Ptr bt) /* TDEC */ +{ + /* use default */ +} + +static void btwrite_crop(BT829Ptr bt) /* CROP */ +{ + btwrite(bt, CROP, (H(bt->vdelay)<<6) | (H(bt->vactive)<<4) | + (H(bt->hdelay)<<2) | H(bt->width)); +} + +static void btwrite_vdelay_lo(BT829Ptr bt) /* VDELAY_LO */ +{ + btwrite(bt, VDELAY_LO, L(bt->vdelay)); +} + +static void btwrite_vactive_lo(BT829Ptr bt) /* VACTIVE_LO */ +{ + btwrite(bt, VACTIVE_LO, L(bt->vactive)); +} + +static void btwrite_hdelay_lo(BT829Ptr bt) /* HDELAY_LO */ +{ + btwrite(bt, HDELAY_LO, L(bt->hdelay)); +} + +static void btwrite_hactive_lo(BT829Ptr bt) /* HACTIVE_LO */ +{ + btwrite(bt, HACTIVE_LO, L(bt->width)); +} + +static void btwrite_hscale_hi(BT829Ptr bt) /* HSCALE_HI */ +{ + btwrite(bt, HSCALE_HI, H(bt->hscale)); +} + +static void btwrite_hscale_lo(BT829Ptr bt) /* HSCALE_LO */ +{ + btwrite(bt, HSCALE_LO, L(bt->hscale)); +} + +static void btwrite_bright(BT829Ptr bt) /* BRIGHT */ +{ + btwrite(bt, BRIGHT, bt->brightness); +} + +static void btwrite_control(BT829Ptr bt) /* CONTROL */ +{ + int ldec; + + /* The data sheet says ldec should always be 0 for SECAM */ + /* but the picture quality is better with ldec = 1 */ + ldec = (bt->width > 360); /* gatos says 384 */ + + btwrite(bt, CONTROL, + ((bt->mux==bt->svideo_mux) ? 0xC0:0x00) | /* LNOTCH and COMP */ + (ldec<<5) | (H(bt->contrast)<<2) | (H(bt->sat_u)<<1) | H(bt->sat_v)); +} + +static void btwrite_contrast_lo(BT829Ptr bt) /* CONTRAST_LO */ +{ + btwrite(bt, CONTRAST_LO, L(bt->contrast)); +} + +static void btwrite_sat_u_lo(BT829Ptr bt) /* SAT_U_LO */ +{ + btwrite(bt, SAT_U_LO, L(bt->sat_u)); +} + +static void btwrite_sat_v_lo(BT829Ptr bt) /* SAT_V_LO */ +{ + btwrite(bt, SAT_V_LO, L(bt->sat_v)); +} + +static void btwrite_hue(BT829Ptr bt) /* HUE */ +{ + btwrite(bt, HUE, bt->hue); +} + +static void btwrite_scloop(BT829Ptr bt) /* SCLOOP */ +{ + if (BTVERSION >= BT827) { + btwrite(bt, SCLOOP, + (bt->format==BT829_SECAM) ? 0x10:0x00 /* QCIF or AUTO */ + ); + } +} + +static void btwrite_wc_up(BT829Ptr bt) /* WC_UP */ +{ + if (BTVERSION >= BT827) { + /* use default */ + } +} + +static void btwrite_oform(BT829Ptr bt) /* OFORM */ +{ + btwrite(bt, OFORM, (bt->code<<3) | (bt->len<<2) | + 0x02 /* RANGE = 0, CORE = 0, VBI_FRAME = 0, OES = 2 (default) */ + ); +} + +static void btwrite_vscale_hi(BT829Ptr bt) /* VSCALE_HI */ +{ + btwrite(bt, VSCALE_HI, H(bt->vscale) | + 0x60 /* YCOMB = 0, COMB = 1, INT = 1 (default) */ + ); +} + +static void btwrite_vscale_lo(BT829Ptr bt) /* VSCALE_LO */ +{ + btwrite(bt, VSCALE_LO, L(bt->vscale)); +} + +/* TEST should not be written to */ + +static void btwrite_vpole(BT829Ptr bt) /* VPOLE */ +{ + btwrite(bt, VPOLE, (bt->out_en<<7)); +} + +/* IDCODE is read only */ + +static void btwrite_adelay(BT829Ptr bt) /* ADELAY */ +{ + switch (bt->format) { + case BT829_NTSC: + case BT829_NTSC_JAPAN: + case BT829_PAL_M: + btwrite(bt, ADELAY, 104); + break; + case BT829_PAL: + case BT829_PAL_N: + case BT829_SECAM: + case BT829_PAL_N_COMB: + btwrite(bt, ADELAY, 127); + break; + default: /* shouldn't get here */ + btwrite(bt, ADELAY, 104); /* hardware default */ + break; + } +} + +static void btwrite_bdelay(BT829Ptr bt) /* BDELAY */ +{ + switch (bt->format) { + case BT829_NTSC: + case BT829_NTSC_JAPAN: + case BT829_PAL_M: + btwrite(bt, BDELAY, 93); + break; + case BT829_PAL: + case BT829_PAL_N: + case BT829_PAL_N_COMB: + btwrite(bt, BDELAY, 114); + break; + case BT829_SECAM: + btwrite(bt, BDELAY, 160); + break; + default: /* shouldn't get here */ + btwrite(bt, BDELAY, 93); /* hardware default */ + break; + } +} + +static void btwrite_adc(BT829Ptr bt) /* ADC */ +{ + btwrite(bt, ADC, bt->mux==bt->svideo_mux ? 0x80:0x82); /* CSLEEP = 0 or 1 */ +} + +static void btwrite_vtc(BT829Ptr bt) /* VTC */ +{ + int vfilt = 0; /* hardware default */ + + if (BTVERSION > BT827) { /* gatos says >= BT827 */ + switch (bt->format) { + case BT829_NTSC: + case BT829_NTSC_JAPAN: + case BT829_PAL_M: + case BT829_PAL_N_COMB: /* gatos groups with BT829_PAL */ + if (bt->width <= 360) vfilt = 1; /* gatos says <= 240 */ + if (bt->width <= 180) vfilt = 2; /* gatos says <= 120 */ + if (bt->width <= 90) vfilt = 3; /* gatos says <= 60 */ + break; + case BT829_PAL: + case BT829_PAL_N: + case BT829_SECAM: + if (bt->width <= 384) vfilt = 1; + if (bt->width <= 192) vfilt = 2; + if (bt->width<= 96) vfilt = 3; + break; + default: /* shouldn't get here */ + break; /* use hardware default */ + } + btwrite(bt, VTC, (bt->vbien<<4) | (bt->vbifmt<<3) | vfilt); + } +} + +static void btwrite_cc_status(BT829Ptr bt) /* CC_STATUS */ +{ /* FIXME: ATI specific */ + if (BTVERSION >= BT827) { + if (bt->ccmode == 0) btwrite(bt, CC_STATUS, 0x00); + /* 0x40 is activate to set the CCVALID line. Not required yet */ + else btwrite(bt, CC_STATUS, (bt->ccmode<<4) | 0x40); + } +} + +/* CC_DATA is read only */ + +static void btwrite_wc_dn(BT829Ptr bt) /* WC_DN */ +{ + if (BTVERSION >= BT827) { + /* use default */ + } +} + +static void bt_reset(BT829Ptr bt) { /* SRESET */ + btwrite(bt, SRESET, 0x0); /* Reset all registers */ +} + +static void btwrite_p_io(BT829Ptr bt) /* P_IO */ +{ + if (BTVERSION >= BT827) { + btwrite(bt, P_IO, bt->p_io); + } +} + +/* + * Deal with dependencies + */ +static void propagate_changes(BT829Ptr bt) +{ + CARD16 hdelay, unscaled_hdelay, vdelay, hscale, vscale; + int htotal, vactive; + + switch (bt->format) { + case BT829_NTSC: + case BT829_NTSC_JAPAN: + case BT829_PAL_M: + vdelay = 22; + htotal = 754; + vactive = 480; + unscaled_hdelay = 135; + break; + case BT829_PAL: + case BT829_PAL_N: + vdelay = (bt->tunertype==5) ? 34 : 22; + htotal = 922; + vactive = 576; + unscaled_hdelay = 186; + break; + case BT829_SECAM: + vdelay = 34; + htotal = 922; + vactive = 576; + unscaled_hdelay = 186; + break; + case BT829_PAL_N_COMB: + vdelay = (bt->tunertype==5) ? 34 : 22; /* windows says 22 */ + htotal = 754; /* gatos and windows say 922 */ + vactive = 576; + unscaled_hdelay = 135; /* gatos and windows say 186 */ + break; + default: /* shouldn't get here */ + vdelay = 22; /* hardware default */ + htotal = 754; + vactive = 480; /* hardware default */ + unscaled_hdelay = 135; + break; + } + + bt->htotal = htotal; /* Used for error checking in bt829_SetCaptSize */ + + hscale = 4096 * htotal / (bt->width + 2 * HCROP)-4096; + hdelay = ( + HCROP + (bt->width + 2 * HCROP) * unscaled_hdelay / htotal + ) & 0x3FE; + + vactive = vactive - 2 * VCROP; + vdelay = vdelay + VCROP; + vscale = (0x10000 - (512*vactive/bt->height-512)) & 0x1FFF; + + if ((hdelay != bt->hdelay) || (vdelay != bt->vdelay) || + (vactive != bt->vactive) || (hscale != bt->hscale) || + (vscale != bt->vscale)) { + bt->hdelay = hdelay; + bt->vdelay = vdelay; + bt->vactive = vactive; + bt->hscale = hscale; + bt->vscale = vscale; + btwrite_crop(bt); + btwrite_vdelay_lo(bt); + btwrite_vactive_lo(bt); + btwrite_hdelay_lo(bt); + btwrite_hscale_hi(bt); + btwrite_hscale_lo(bt); + btwrite_control(bt); + btwrite_vscale_hi(bt); + btwrite_vscale_lo(bt); + } +} + +static void write_all(BT829Ptr bt) +{ + bt_reset(bt); + propagate_changes(bt); /* ensure consistency */ + btwrite_iform(bt); + btwrite_tdec(bt); + btwrite_crop(bt); + btwrite_vdelay_lo(bt); + btwrite_vactive_lo(bt); + btwrite_hdelay_lo(bt); + btwrite_hactive_lo(bt); + btwrite_hscale_hi(bt); + btwrite_hscale_lo(bt); + btwrite_bright(bt); + btwrite_control(bt); + btwrite_contrast_lo(bt); + btwrite_sat_u_lo(bt); + btwrite_sat_v_lo(bt); + btwrite_hue(bt); + btwrite_scloop(bt); + btwrite_wc_up(bt); + btwrite_oform(bt); + btwrite_vscale_hi(bt); + btwrite_vscale_lo(bt); + btwrite_vpole(bt); + btwrite_adelay(bt); + btwrite_bdelay(bt); + btwrite_adc(bt); + btwrite_vtc(bt); +/* btwrite_cc_status(bt); */ /* FIXME: CC code needs cleaning */ + btwrite_wc_dn(bt); + btwrite_p_io(bt); +} + +/* + * Public functions + */ +BT829Ptr bt829_Detect(I2CBusPtr b, I2CSlaveAddr addr) +{ + BT829Ptr bt; + I2CByte a; + + bt = xcalloc(1, sizeof(BT829Rec)); + if(bt == NULL) return NULL; + bt->d.DevName = strdup("BT829 video decoder"); + bt->d.SlaveAddr = addr; + bt->d.pI2CBus = b; + bt->d.NextDev = NULL; + bt->d.StartTimeout = b->StartTimeout; + bt->d.BitTimeout = b->BitTimeout; + bt->d.AcknTimeout = b->AcknTimeout; + bt->d.ByteTimeout = b->ByteTimeout; + + + if(!I2C_WriteRead(&(bt->d), NULL, 0, &a, 1)) + { + free(bt); + return NULL; + } + + bt->id = btread(bt,IDCODE); + + free(bt->d.DevName); + bt->d.DevName = xcalloc(200, sizeof(char)); + switch(BTVERSION){ + case BT815: + sprintf(bt->d.DevName, "bt815a video decoder, revision %d",bt->id & 0xf); + break; + case BT817: + sprintf(bt->d.DevName, "bt817a video decoder, revision %d",bt->id & 0xf); + break; + case BT819: + sprintf(bt->d.DevName, "bt819a video decoder, revision %d",bt->id & 0xf); + break; + case BT827: + sprintf(bt->d.DevName, "bt827a/b video decoder, revision %d",bt->id & 0xf); + break; + case BT829: + sprintf(bt->d.DevName, "bt829a/b video decoder, revision %d",bt->id & 0xf); + break; + default: + sprintf(bt->d.DevName, "bt8xx/unknown video decoder version %d, revision %d",bt->id >> 4,bt->id & 0xf); + break; + } + + /* set default parameters */ + if(!I2CDevInit(&(bt->d))) + { + free(bt); + return NULL; + } + + bt->tunertype = 1; + + bt->brightness = 0; /* hardware default */ + bt->ccmode = 0; + bt->code = 0; /* hardware default */ + bt->contrast = 216; /* hardware default */ + bt->format = BT829_NTSC; + bt->height = 480; /* hardware default for vactive */ + bt->hue = 0; /* hardware default */ + bt->len = 1; /* hardware default */ + bt->mux = BT829_MUX0; /* hardware default */ + bt->out_en = 0; /* hardware default */ + bt->p_io = 0; /* hardware default */ + bt->sat_u = 254; /* hardware default */ + bt->sat_v = 180; /* hardware default */ + bt->vbien = 0; /* hardware default */ + bt->vbifmt = 0; /* hardware default */ + bt->width = 640; /* hardware default for hactive */ + + bt->hdelay = 120; /* hardware default */ + bt->hscale = 684; /* hardware default */ + bt->vactive = 480; /* hardware default */ + bt->vdelay = 22; /* hardware default */ + bt->vscale = 0; /* hardware default */ + + bt->htotal = 754; /* NTSC */ + bt->svideo_mux = 0; /* no s-video */ + + return bt; +} + +int bt829_ATIInit(BT829Ptr bt) +{ + bt->code = 1; + bt->len = 0; + bt->vbien = 1; + bt->vbifmt = 1; + bt->svideo_mux = BT829_MUX1; + + write_all (bt); + + return 0; +} + +int bt829_SetFormat(BT829Ptr bt, CARD8 format) +{ + if ((format < 1) || (format > 7)) return -1; + if ((BTVERSION <= BT819) && + (format != BT829_NTSC) && (format != BT829_PAL)) return -1; + if (format == bt->format) return 0; + bt->format = format; + propagate_changes(bt); + btwrite_iform(bt); + btwrite_scloop(bt); + btwrite_adelay(bt); + btwrite_bdelay(bt); + btwrite_vtc(bt); + return 0; +} + +int bt829_SetMux(BT829Ptr bt, CARD8 mux) +{ + if ((mux < 1) || (mux > 3)) return -1; + if (mux == bt->mux) return 0; + bt->mux = mux; + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_iform(bt); + btwrite_control(bt); + btwrite_adc(bt); + return 0; +} + +void bt829_SetBrightness(BT829Ptr bt, int brightness) +{ + brightness = LIMIT(brightness,-1000,999); /* ensure -128 <= brightness <= 127 below */ + brightness = (128*brightness)/1000; + if (brightness == bt->brightness) return; + bt->brightness = brightness; + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_bright(bt); +} + +void bt829_SetContrast(BT829Ptr bt, int contrast) +{ + contrast = LIMIT(contrast,-1000,1000); + contrast = (216*(contrast+1000))/1000; + if (contrast == bt->contrast) return; + bt->contrast = contrast; + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_control(bt); + btwrite_contrast_lo(bt); +} + +void bt829_SetSaturation(BT829Ptr bt, int saturation) +{ + CARD16 sat_u, sat_v; + + saturation = LIMIT(saturation,-1000,1000); + sat_u = (254*(saturation+1000))/1000; + sat_v = (180*(saturation+1000))/1000; + if ((sat_u == bt->sat_u) && (sat_v == bt->sat_v)) return; + bt->sat_u = sat_u; + bt->sat_v = sat_v; + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_control(bt); + btwrite_sat_u_lo(bt); + btwrite_sat_v_lo(bt); +} + +void bt829_SetTint(BT829Ptr bt, int hue) +{ + hue = LIMIT(hue,-1000,999); /* ensure -128 <= hue <= 127 below */ + hue = (128*hue)/1000; + if (hue == bt->hue) return; + bt->hue = hue; + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_hue(bt); +} + +int bt829_SetCaptSize(BT829Ptr bt, int width, int height) +{ + if ((width > bt->htotal - 2 * HCROP) || + (16 * width < bt->htotal - 32 * HCROP)) return -1; + if ((height > bt->vactive) || (16 * height < bt->vactive)) return -1; + if ((width == bt->width) && (height == bt->height)) return 0; + bt->width = width; + bt->height = height; + propagate_changes(bt); + btwrite_crop(bt); + btwrite_hactive_lo(bt); + btwrite_control(bt); + btwrite_vtc(bt); + return 0; +} + +int bt829_SetCC(BT829Ptr bt) /* FIXME: should take ccmode as a parameter */ +{ + if (BTVERSION < BT827) return -1; /* can't do it */ + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_cc_status(bt); + /* we write to STATUS to reset the CCVALID flag */ + if (bt->ccmode != 0) btwrite_status(bt); + return 0; +} + +void bt829_SetOUT_EN(BT829Ptr bt, BOOL out_en) +{ + out_en = (out_en != 0); + if (out_en == bt->out_en) return; + bt->out_en = out_en; + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_vpole(bt); +} + +void bt829_SetP_IO(BT829Ptr bt, CARD8 p_io) +{ + if (p_io == bt->p_io) return; + bt->p_io = p_io; + /* propagate_changes(bt); */ /* no dependencies */ + btwrite_p_io(bt); +} + +#define BTREAD(R) btread(bt,(R)) + +#if 0 + +void bt829_getCCdata(BT829Ptr bt,struct CCdata *data) +{ + CARD8 status; + data->num_valid=0; + /* wait for buffer to be half full (means 8/16 bytes) + * either 4 (one of CC/EDS) or 2 (both CC/EDS) frames */ + if(!(BTREAD(STATUS)&0x04)) return; /* could comment this line */ + for(;data->num_valid<CC_FIFO_SIZE;data->num_valid++) { + status=BTREAD(CC_STATUS); + if(!(status&0x04)) break; + data->data[data->num_valid]= BTREAD(CC_DATA)&0x7f; + /* stripped high bit (parity) */ + data->status[data->num_valid]= (CCS_EDS*((status&0x02)>>1)) | + (CCS_HIGH*(status&0x01)) | + (CCS_OVER*((status&0x08)>>3)) | + (CCS_PAR*((status&0x80)>>7)) ; } + btwrite(bt,STATUS,0x00); /* Reset CCVALID status bit */ + return; +} + +#endif + +/* ------------------------------------------------------------------------ */ +/* Debug and report routines */ + +#define DUMPREG(REG) \ + xf86DrvMsg(bt->d.pI2CBus->scrnIndex,X_INFO," %-12s (0x%02X) = 0x%02X\n", \ + #REG,REG,BTREAD(REG)) + +/*static void bt829_dumpregs(BT829Ptr bt) +{ + DUMPREG(STATUS); + DUMPREG(IFORM); + DUMPREG(TDEC); + DUMPREG(CROP); + DUMPREG(VDELAY_LO); + DUMPREG(VACTIVE_LO); + DUMPREG(HDELAY_LO); + DUMPREG(HACTIVE_LO); + DUMPREG(HSCALE_HI); + DUMPREG(HSCALE_LO); + DUMPREG(BRIGHT); + DUMPREG(CONTROL); + DUMPREG(CONTRAST_LO); + DUMPREG(SAT_U_LO); + DUMPREG(SAT_V_LO); + DUMPREG(HUE); + if (BTVERSION >= BT827) { + DUMPREG(SCLOOP); + DUMPREG(WC_UP) ; } + DUMPREG(OFORM); + DUMPREG(VSCALE_HI); + DUMPREG(VSCALE_LO); + DUMPREG(TEST); + DUMPREG(VPOLE); + DUMPREG(IDCODE); + DUMPREG(ADELAY); + DUMPREG(BDELAY); + DUMPREG(ADC); + if (BTVERSION >= BT827) { + DUMPREG(VTC); + DUMPREG(CC_STATUS); + DUMPREG(CC_DATA); + DUMPREG(WC_DN); + DUMPREG(P_IO) ; } +}*/ diff --git a/xorg-server/hw/xfree86/i2c/bt829.h b/xorg-server/hw/xfree86/i2c/bt829.h new file mode 100644 index 000000000..bca9d37de --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/bt829.h @@ -0,0 +1,97 @@ +#ifndef __BT829_H__ +#define __BT829_H__ + +#include "xf86i2c.h" + +typedef struct { + int tunertype; /* Must be set before init */ + /* Private variables */ + I2CDevRec d; + + CARD8 brightness; + CARD8 ccmode; + CARD8 code; + CARD16 contrast; + CARD8 format; + int height; + CARD8 hue; + CARD8 len; + CARD8 mux; + CARD8 out_en; + CARD8 p_io; + CARD16 sat_u; + CARD16 sat_v; + CARD8 vbien; + CARD8 vbifmt; + int width; + + CARD16 hdelay; + CARD16 hscale; + CARD16 vactive; + CARD16 vdelay; + CARD16 vscale; + + CARD16 htotal; + CARD8 id; + CARD8 svideo_mux; +} BT829Rec, *BT829Ptr; + +BT829Ptr bt829_Detect(I2CBusPtr b, I2CSlaveAddr addr); + +/* ATI card specific initialization */ +#define BT829_ATI_ADDR_1 0x8A +#define BT829_ATI_ADDR_2 0x88 +int bt829_ATIInit(BT829Ptr bt); + +#define BT829_NTSC 1 /* NTSC-M */ +#define BT829_NTSC_JAPAN 2 /* NTSC-Japan */ +#define BT829_PAL 3 /* PAL-B,D,G,H,I */ +#define BT829_PAL_M 4 /* PAL-M */ +#define BT829_PAL_N 5 /* PAL-N */ +#define BT829_SECAM 6 /* SECAM */ +#define BT829_PAL_N_COMB 7 /* PAL-N combination */ +int bt829_SetFormat(BT829Ptr bt, CARD8 format); + +#define BT829_MUX2 1 /* ATI -> composite video */ +#define BT829_MUX0 2 /* ATI -> tv tuner */ +#define BT829_MUX1 3 /* ATI -> s-video */ +int bt829_SetMux(BT829Ptr bt, CARD8 mux); + +int bt829_SetCaptSize(BT829Ptr bt, int width, int height); + +void bt829_SetBrightness(BT829Ptr bt, int brightness); +void bt829_SetContrast(BT829Ptr bt, int contrast); +void bt829_SetSaturation(BT829Ptr bt, int saturation); +void bt829_SetTint(BT829Ptr bt, int hue); /* Hue */ + +void bt829_SetOUT_EN(BT829Ptr bt, BOOL out_en); /* VPOLE register */ +void bt829_SetP_IO(BT829Ptr bt, CARD8 p_io); /* P_IO register */ + +int bt829_SetCC(BT829Ptr bt); + +#define BT829SymbolsList \ + "bt829_Detect", \ + "bt829_ATIInit", \ + "bt829_SetFormat", \ + "bt829_SetMux", \ + "bt829_SetBrightness", \ + "bt829_SetContrast", \ + "bt829_SetSaturation", \ + "bt829_SetTint", \ + "bt829_SetCaptSize", \ + "bt829_SetOUT_EN", \ + "bt829_SetP_IO" + +#define xf86_bt829_Detect ((BT829Ptr (*)(I2CBusPtr, I2CSlaveAddr))LoaderSymbol("bt829_Detect")) +#define xf86_bt829_ATIInit ((int (*)(BT829Ptr))LoaderSymbol("bt829_ATIInit")) +#define xf86_bt829_SetFormat ((int (*)(BT829Ptr, CARD8))LoaderSymbol("bt829_SetFormat")) +#define xf86_bt829_SetMux ((int (*)(BT829Ptr, CARD8))LoaderSymbol("bt829_SetMux")) +#define xf86_bt829_SetCaptSize ((int (*)(BT829Ptr, int, int))LoaderSymbol("bt829_SetCaptSize")) +#define xf86_bt829_SetBrightness ((void (*)(BT829Ptr, int))LoaderSymbol("bt829_SetBrightness")) +#define xf86_bt829_SetContrast ((void (*)(BT829Ptr, int))LoaderSymbol("bt829_SetContrast")) +#define xf86_bt829_SetSaturation ((void (*)(BT829Ptr, int))LoaderSymbol("bt829_SetSaturation")) +#define xf86_bt829_SetTint ((void (*)(BT829Ptr, int))LoaderSymbol("bt829_SetTint")) +#define xf86_bt829_SetOUT_EN ((void (*)(BT829Ptr, Bool))LoaderSymbol("bt829_SetOUT_EN")) +#define xf86_bt829_SetP_IO ((void (*)(BT829Ptr, CARD8))LoaderSymbol("bt829_SetP_IO")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/bt829_module.c b/xorg-server/hw/xfree86/i2c/bt829_module.c new file mode 100644 index 000000000..c885b8e10 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/bt829_module.c @@ -0,0 +1,28 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(bt829Setup); + +static XF86ModuleVersionInfo bt829VersRec = +{ + "bt829", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData bt829ModuleData = { &bt829VersRec, bt829Setup, NULL }; + +static pointer +bt829Setup(pointer module, pointer opts, int *errmaj, int *errmin) { + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/i2c/fi1236.c b/xorg-server/hw/xfree86/i2c/fi1236.c new file mode 100644 index 000000000..110563ed9 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/fi1236.c @@ -0,0 +1,609 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include "xf86.h" +#include "xf86i2c.h" +#include "fi1236.h" +#include "tda9885.h" +#include "i2c_def.h" + +#define NUM_TUNERS 8 + +const FI1236_parameters tuner_parms[NUM_TUNERS] = +{ + /* 0 - FI1236 */ + { 733 ,884 ,12820 ,2516 ,7220 ,0xA2 ,0x94, 0x34, 0x8e }, + /* !!!based on documentation - it should be: + {733 ,16*55.25 ,16*801.25 ,16*160 ,16*454 ,0xA0 ,0x90, 0x30, 0x8e},*/ + + /* 1 - FI1216 */ + { 623 ,16*48.75 ,16*855.25 ,16*170 ,16*450 ,0xA0 ,0x90, 0x30, 0x8e }, + /* 2 - TEMIC FN5AL */ + { 623 ,16*45.75 ,16*855.25 ,16*169 ,16*454 ,0xA0 ,0x90, 0x30, 0x8e }, + /* 3 - MT2032.. */ + { 733 ,768 ,13760 , 0 , 0 , 0 , 0, 0, 0 }, + /* 4 - FI1246 */ + { 623 ,16*45.75 ,16*855.25 ,16*170 ,16*450 ,0xA0 ,0x90, 0x30, 0x8e }, + /* 5 - FI1256 */ + { 623 ,16*49.75 ,16*863.25 ,16*170 ,16*450 ,0xA0 ,0x90, 0x30, 0x8e }, + /* 6 - FI1236W */ + /*{ 733 ,884 ,12820 ,2516 ,7220 ,0x1 ,0x2, 0x4, 0x8e },*/ + { 732, 16*55.25, 16*801.25, 16*160, 16*442, 0x1, 0x2, 0x4, 0x8e }, + /* 7 - FM1216ME */ + { 623 ,16*48.25 ,16*863.25 ,16*158.00 ,16*442.00 ,0x1 ,0x2, 0x4, 0x8e } +}; + + +FI1236Ptr Detect_FI1236(I2CBusPtr b, I2CSlaveAddr addr) +{ + FI1236Ptr f; + I2CByte a; + + f = xcalloc(1,sizeof(FI1236Rec)); + if(f == NULL) return NULL; + f->d.DevName = strdup("FI12xx Tuner"); + f->d.SlaveAddr = addr; + f->d.pI2CBus = b; + f->d.NextDev = NULL; + f->d.StartTimeout = b->StartTimeout; + f->d.BitTimeout = b->BitTimeout; + f->d.AcknTimeout = b->AcknTimeout; + f->d.ByteTimeout = b->ByteTimeout; + f->type=TUNER_TYPE_FI1236; + f->afc_timer_installed=FALSE; + f->last_afc_hint=TUNER_OFF; + f->video_if=45.7812; + + if(!I2C_WriteRead(&(f->d), NULL, 0, &a, 1)) + { + free(f); + return NULL; + } + FI1236_set_tuner_type(f, TUNER_TYPE_FI1236); + if(!I2CDevInit(&(f->d))) + { + free(f); + return NULL; + } + return f; +} + +static void MT2032_dump_parameters(FI1236Ptr f, MT2032_parameters *m) +{ +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: input f_rf=%g f_if1=%g f_if2=%g f_ref=%g f_ifbw=%g f_step=%g\n", + m->f_rf, m->f_if1, m->f_if2, m->f_ref, m->f_ifbw, m->f_step); + +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: computed f_lo1=%g f_lo2=%g LO1I=%d LO2I=%d SEL=%d STEP=%d NUM=%d\n", + m->f_lo1, m->f_lo2, m->LO1I, m->LO2I, m->SEL, m->STEP, m->NUM); +} + + +static void MT2032_getid(FI1236Ptr f) +{ +CARD8 out[4]; +CARD8 in; + +in=0x11; +I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 4); +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: Company code 0x%02x%02x, part code 0x%02x, revision code 0x%02x\n", + out[0], out[1], out[2], out[3]); + +} + +/* might be buggy */ +#if 0 +static void MT2032_shutdown(FI1236Ptr f) +{ +CARD8 data[10]; + +data[0]=0x00; /* start with register 0x00 */ +data[1]=0x1A; +data[2]=0x44; +data[3]=0x20; + +I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0); + +data[0]=0x05; /* now start with register 0x05 */ +data[1]=0xD7; +data[2]=0x14; +data[3]=0x05; +I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0); + +data[0]=0x0B; /* now start with register 0x05 */ +data[1]=0x8F; +data[2]=0x07; +data[3]=0x43; +I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0); + +usleep(15000); +} +#endif + +static void MT2032_dump_status(FI1236Ptr f); + +static void MT2032_init(FI1236Ptr f) +{ +CARD8 data[10]; +CARD8 value; +CARD8 xogc = 0x00; + +MT2032_getid(f); + +data[0]=0x02; /* start with register 0x02 */ +data[1]=0xFF; +data[2]=0x0F; +data[3]=0x1F; + +I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0); + +data[0]=0x06; /* now start with register 0x06 */ +data[1]=0xE4; +data[2]=0x8F; +data[3]=0xC3; +data[4]=0x4E; +data[5]=0xEC; +I2C_WriteRead(&(f->d), (I2CByte *)data, 6, NULL, 0); + +data[0]=0x0d; /* now start with register 0x0d */ +data[1]=0x32; +I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0); + +while(1) { + usleep(15000); /* wait 15 milliseconds */ + + data[0]=0x0e; /* register number 7, status */ + value=0xFF; + if(!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1)) + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to read XOK\n"); + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: XOK=%d\n", value & 0x01); + if(value & 1) break; + + data[0]=0x07; + if(!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1)) + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to read XOGC\n"); + + xogc=value & 0x7; + if(xogc==4){ + break; /* XOGC has reached 4.. stop */ + } + xogc--; + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: try XOGC=%d\n", xogc); + usleep(15000); + data[0]=0x07; /* register number 7, control byte 2 */ + data[1]=0x08 | xogc; + I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0); + } +f->xogc=xogc; +/* wait before continuing */ +usleep(15000); /* wait 50 milliseconds */ +MT2032_dump_status(f); +} + +static int MT2032_no_spur_in_band(MT2032_parameters *m) +{ +int n_max, n1, n2; +double f_test; +n_max=5; +n1=1; +while(1){ + n2=-n1; + f_test=n1*(m->f_lo1-m->f_lo2); + while(1){ + n2--; + f_test=f_test-m->f_lo2; + xf86DrvMsg(0, X_INFO, "testing f_test=%g n1=%d n2=%d f_lo1=%g f_lo2=%g f_if2=%g\n", f_test, n1, n2, m->f_lo1, m->f_lo2, m->f_if2); + xf86DrvMsg(0, X_INFO, "d_f=%g f_ifbw=%g\n",fabs(fabs(f_test)-m->f_if2), m->f_ifbw); + if((fabs(fabs(f_test)-m->f_if2)*2.0)<=m->f_ifbw)return 0; + if(n2<=-n_max)break; + /* this line in the manual is bogus. I say it is faster + and more correct to go over all harmonics.. */ + #if 0 + if(f_test<(m->f_lo2-m->f_if2-m->f_ifbw))break; + #endif + } + n1++; + if(n1>=n_max)return 1; + } + +} + +static void MT2032_calculate_register_settings(MT2032_parameters *m, double f_rf, double f_if1, double f_if2, double f_ref, double f_ifbw, double f_step) +{ +int n; +m->f_rf=f_rf; +m->f_if1=f_if1; +m->f_if2=f_if2; +m->f_ref=f_ref; +m->f_ifbw=f_ifbw; +m->f_step=f_step; + +m->f_lo1=f_rf+f_if1; +m->LO1I=(int)floor((m->f_lo1/f_ref)+0.5); +m->f_lo1=f_ref*m->LO1I; + +m->f_lo2=m->f_lo1-f_rf-f_if2; + +/* check for spurs */ +n=1; +while(n<3){ + if(MT2032_no_spur_in_band(m))break; + if(m->f_lo1<(f_rf+f_if1)){ + m->LO1I+=n; + } else { + m->LO1I-=n; + } + m->f_lo1=m->LO1I*f_ref; + m->f_lo2=m->f_lo1-f_rf-f_if2; + n++; + } +/* xf86DrvMsg(0, X_INFO, "MT2032: n=%d\n", n); */ +/* select VCO */ + +/* m->f_lo1>1100.0 */ +if(m->f_lo1<1370.0)m->SEL=4; + else +if(m->f_lo1<1530.0)m->SEL=3; + else +if(m->f_lo1<1720.0)m->SEL=2; + else +if(m->f_lo1<1890.0)m->SEL=1; + else /* m->f_lo1 < 1958.0 */ + m->SEL=0; + +/* calculate the rest of the registers */ +m->LO2I=(int)floor(m->f_lo2/f_ref); +m->STEP=(int)floor(3780.0*f_step/f_ref); +m->NUM=(int)floor(3780.0*(m->f_lo2/f_ref-m->LO2I)); +m->NUM=m->STEP*(int)floor((1.0*m->NUM)/(1.0*m->STEP)+0.5); +} + +static int MT2032_wait_for_lock(FI1236Ptr f) +{ +int n; +CARD8 data[10]; +CARD8 value; + +n=12; +while(1){ + data[0]=0x0e; /* register number 7, status */ + I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1); +/* xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: LO1LK=%d LO2LK=%d\n", (value & 0x04)>>2, (value & 0x02)>>1); */ + if((value & 6)==6) break; + usleep(1500); + n--; + if(n<0)break; + } +if(n<0){ + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to set frequency\n"); + return 0; + } +return 1; +} + +static void MT2032_implement_settings(FI1236Ptr f, MT2032_parameters *m) +{ +CARD8 data[10]; +CARD8 value; + +data[0]=0x00; /* start with register 0x00 */ +data[1]=(m->LO1I>>3)-1; +data[2]=(m->SEL<<4)|(m->LO1I & 0x7); +data[3]=0x86; +I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0); + +data[0]=0x05; /* start with register 0x05 */ +data[1]=((m->LO2I & 0x7)<<5)|((m->LO2I>>3)-1); +if(m->f_rf<400.0)data[2]=0xe4; + else data[2]=0xf4; +I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0); + +data[0]=0x07; /* register number 7, control byte 2 */ +I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1); +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: using XOGC=%d\n", (value & 0x07)); +data[1]=8 | (value & 0x7); +I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0); + +data[0]=0x0b; /* start with register 0x0b */ +data[1]=m->NUM & 0xff; +data[2]=(1<<7)|((m->NUM >> 8) & 0x0f); +I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0); + +MT2032_wait_for_lock(f); +} + +static void MT2032_optimize_VCO(FI1236Ptr f, MT2032_parameters *m) +{ +CARD8 data[10]; +CARD8 value; +CARD8 TAD1; + +data[0]=0x0f; /* register number 7, status */ +I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1); +TAD1=value & 0x07; +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: TAD1=%d SEL=%d\n", TAD1, m->SEL); +if(TAD1 < 2)return; +if(TAD1==2){ + if(m->SEL==0)return; + m->SEL--; + } else { + if(m->SEL>=4)return; + m->SEL++; + } +data[0]=0x01; /* start with register 1 */ +data[1]=(m->SEL<<4)|(m->LO1I & 0x7); +I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0); + +} + +static int FI1236_get_afc_hint(FI1236Ptr f) +{ + CARD8 out; + CARD8 AFC; + + if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) + { + TDA9885Ptr t = (TDA9885Ptr)f->afc_source; + if (t == NULL) + return TUNER_OFF; + + tda9885_getstatus(t); + tda9885_dumpstatus(t); + AFC = t->afc_status & 0x0f; + + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: FI1236_get_afc_hint: %i\n", AFC); + if (AFC == 0) return TUNER_TUNED; + else if (AFC <= 0x07)return TUNER_JUST_BELOW; + else if (AFC < 0x0f )return TUNER_JUST_ABOVE; + else if (AFC == 0x0f)return TUNER_TUNED; + } + else + { + I2C_WriteRead(&(f->d), NULL, 0, &out, 1); + AFC=out & 0x7; + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: FI1236_get_afc_hint: %i\n", AFC); + if(AFC==2)return TUNER_TUNED; + if(AFC==3)return TUNER_JUST_BELOW; + if(AFC==1)return TUNER_JUST_ABOVE; + return TUNER_OFF; + } + return TUNER_OFF; +} + +static int MT2032_get_afc_hint(FI1236Ptr f) +{ +CARD8 in; +CARD8 out[2]; +CARD8 AFC; +in=0x0e; +I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2); +AFC=(out[0]>>4) & 0x7; +#if 0 +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC=%d TAD1=%d TAD2=%d\n", AFC, out[1] & 0x7, (out[1]>>4)& 0x07); +#endif +if(AFC==2)return TUNER_TUNED; +if(AFC==3)return TUNER_JUST_BELOW; +if(AFC==1)return TUNER_JUST_ABOVE; +return TUNER_OFF; +} + +/* this function is for external use only */ +int TUNER_get_afc_hint(FI1236Ptr f) +{ +if(f->afc_timer_installed)return TUNER_STILL_TUNING; +return f->last_afc_hint; +if(f->type==TUNER_TYPE_MT2032) + return MT2032_get_afc_hint(f); + else + return FI1236_get_afc_hint(f); +} + +static void MT2032_dump_status(FI1236Ptr f) +{ +CARD8 in; +CARD8 out[2]; +CARD8 AFC; +CARD8 LDONrb; +CARD8 LO1LK, LO2LK, XOK; +CARD8 TAD2, TAD1; + +in=0x0e; +I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2); +XOK=out[0] & 1; +LO1LK=(out[0]>>2) &1; +LO2LK=(out[0]>>1) &1; +LDONrb=(out[0]>>3) &1; + +AFC=(out[0]>>4) & 0x7; + +TAD1=(out[1] & 0x7); +TAD2=(out[1]>>4) & 0x7; + +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: status: XOK=%d LO1LK=%d LO2LK=%d LDONrb=%d AFC=%d TAD1=%d TAD2=%d\n", + XOK, LO1LK, LO2LK, LDONrb, AFC, TAD1, TAD2); +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: status: OSCILLATOR:%s PLL1:%s PLL2:%s\n", + XOK ? "ok":"off", LO1LK ? "locked" : "off" , LO2LK ? "locked" : "off"); + +} + +static void MT2032_tune(FI1236Ptr f, double freq, double step) +{ +MT2032_parameters m; +CARD8 data[10]; +int i; +/* NTSC IF is 44mhz.. but 733/16=45.8125 and all TDAXXXX docs mention + 45.75, 39, 58.75 and 30. */ +#if 0 +MT2032_calculate_register_settings(&m, freq, 1090.0, 45.125, 5.25, 6.0, step); +MT2032_calculate_register_settings(&m, freq, 1090.0, 45.74, 5.25, 6.0, step); +#endif +MT2032_calculate_register_settings(&m, freq, 1090.0, f->video_if, 5.25, 3.0, step); +MT2032_dump_parameters(f, &m); +MT2032_implement_settings(f, &m); +/* MT2032_dump_parameters(f, &m); */ +for(i=0;i<3;i++){ + MT2032_optimize_VCO(f, &m); + if(MT2032_wait_for_lock(f)){ + data[0]=0x02; /* LO Gain control register 0x02 */ + data[1]=0x20; + I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0); + return; + } + data[0]=0x07; + data[1]=0x88|f->xogc; + I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0); + usleep(15000); + data[1]=0x08|f->xogc; + I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0); + } +xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to set frequency\n"); +} + +void FI1236_set_tuner_type(FI1236Ptr f, int type) +{ +f->type=type; +if(type>=NUM_TUNERS)type = NUM_TUNERS-1; +if(type<0)type = 0; +memcpy(&(f->parm), &(tuner_parms[type]), sizeof(FI1236_parameters)); +f->original_frequency=f->parm.min_freq; +f->afc_delta=0; +if(type==TUNER_TYPE_MT2032){ + MT2032_init(f); + return; + } +} + + +static CARD32 AFC_TimerCallback(OsTimerPtr timer, CARD32 time, pointer data){ +FI1236Ptr f=(FI1236Ptr)data; +if(FI1236_AFC(f))return 150; + else { + f->afc_timer_installed=FALSE; + f->afc_count=0; + return 0; + } +} + +void FI1236_tune(FI1236Ptr f, CARD32 frequency) +{ + CARD16 divider; + CARD8 data; + + if(frequency < f->parm.min_freq) frequency = f->parm.min_freq; + if(frequency > f->parm.max_freq) frequency = f->parm.max_freq; + + divider = (f->parm.fcar+(CARD16)frequency) & 0x7fff; + f->tuner_data.div1 = (CARD8)((divider>>8)&0x7f); + f->tuner_data.div2 = (CARD8)(divider & 0xff); + f->tuner_data.control = f->parm.control; + + if(frequency < f->parm.threshold1) + { + f->tuner_data.band = f->parm.band_low; + } + else if (frequency < f->parm.threshold2) + { + f->tuner_data.band = f->parm.band_mid; + } + else + { + f->tuner_data.band = f->parm.band_high; + } + + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Setting tuner band to %d\n", f->tuner_data.band); + + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Setting tuner frequency to %d\n", (int)frequency); + + if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) + { + f->tuner_data.aux = 0x20; + I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 5, NULL, 0); + I2C_WriteRead(&(f->d), NULL, 0, &data, 1); + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Tuner status %x\n", data); + + } + else + I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 4, NULL, 0); +} + +void TUNER_set_frequency(FI1236Ptr f, CARD32 frequency) +{ + if(frequency < f->parm.min_freq) frequency = f->parm.min_freq; + if(frequency > f->parm.max_freq) frequency = f->parm.max_freq; + + f->afc_delta=0; + f->original_frequency=frequency; + + if(f->type==TUNER_TYPE_MT2032) + { + MT2032_tune(f, (1.0*frequency)/16.0, 0.0625); + } else + { + FI1236_tune(f, frequency); + } + + if(!f->afc_timer_installed) + { + f->afc_timer_installed=TRUE; +/* RegisterBlockAndWakeupHandlers(FI1236_BlockHandler, AFCWakeup, f); */ + TimerSet(NULL, 0, 300, AFC_TimerCallback, f); + } + +} + + +int FI1236_AFC(FI1236Ptr f) +{ + #if 0 + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: f=%p f->count=%d f->original_frequency=%d f->afc_delta=%d\n", f, f->afc_count, f->original_frequency, f->afc_delta); + #endif + f->afc_count++; + if(f->type==TUNER_TYPE_MT2032) + { + f->last_afc_hint=MT2032_get_afc_hint(f); + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: afc_hint=%d\n", f->last_afc_hint); + if(f->last_afc_hint==TUNER_TUNED)return 0; + if(f->afc_count>3)f->last_afc_hint=TUNER_OFF; + if(f->last_afc_hint==TUNER_OFF) + { + f->afc_delta=0; + } else + f->afc_delta+=f->last_afc_hint; + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: Setting tuner frequency to %g\n", (0.5*(2*f->original_frequency+f->afc_delta))/16.0); + MT2032_tune(f, (1.0*f->original_frequency+0.5*f->afc_delta)/16.0, 0.03125); + if(f->last_afc_hint==TUNER_OFF)return 0; + return 1; /* call me again */ + } else + { + f->last_afc_hint=FI1236_get_afc_hint(f); + if(f->last_afc_hint==TUNER_TUNED) + { + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: TUNER_TUNNED\n"); + return 0; + } + if(f->afc_count>3)f->last_afc_hint=TUNER_OFF; + if(f->last_afc_hint==TUNER_OFF) + { + f->afc_delta=0; + } else + f->afc_delta+=f->last_afc_hint; + xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: Setting tuner frequency to %g\n", (0.5*(2*f->original_frequency+f->afc_delta))/16.0); + FI1236_tune(f, f->original_frequency+f->afc_delta); + if(f->last_afc_hint==TUNER_OFF)return 0; + return 1; /* call me again */ + } + return 0; /* done */ +} + +void fi1236_dump_status(FI1236Ptr f) +{ +if(f->type==TUNER_TYPE_MT2032){ + MT2032_dump_status(f); + } +} diff --git a/xorg-server/hw/xfree86/i2c/fi1236.h b/xorg-server/hw/xfree86/i2c/fi1236.h new file mode 100644 index 000000000..eda1c781c --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/fi1236.h @@ -0,0 +1,110 @@ +#ifndef __FI1236_H__ +#define __FI1236_H__ + +#include "xf86i2c.h" + +/* why someone has defined NUM someplace else is beyoung me.. */ +#undef NUM + +typedef struct { + CARD32 fcar; /* 16 * fcar_Mhz */ + CARD32 min_freq; /* 16 * min_freq_Mhz */ + CARD32 max_freq; /* 16 * max_freq_Mhz */ + + CARD32 threshold1; /* 16 * Value_Mhz */ + CARD32 threshold2; /* 16 * Value_Mhz */ + + CARD8 band_low; + CARD8 band_mid; + CARD8 band_high; + CARD8 control; + } FI1236_parameters; + + +typedef struct { + /* what we want */ + /* all frequencies are in Mhz */ + double f_rf; /* frequency to tune to */ + double f_if1; /* first intermediate frequency */ + double f_if2; /* second intermediate frequency */ + double f_ref; /* reference frequency */ + double f_ifbw; /* bandwidth */ + double f_step; /* step */ + + /* what we compute */ + double f_lo1; + double f_lo2; + int LO1I; + int LO2I; + int SEL; + int STEP; + int NUM; + } MT2032_parameters; + +typedef struct { + I2CDevRec d; + int type; + + void* afc_source; /* The AFC source may be another chip like TDA988x */ + + int afc_delta; + CARD32 original_frequency; + Bool afc_timer_installed; + int afc_count; + int last_afc_hint; + + double video_if; + FI1236_parameters parm; + int xogc; /* for MT2032 */ + + struct { + CARD8 div1; + CARD8 div2; + CARD8 control; + CARD8 band; + CARD8 aux; /* this is for MK3 tuners */ + } tuner_data; + } FI1236Rec, *FI1236Ptr; + +#define TUNER_TYPE_FI1236 0 +#define TUNER_TYPE_FI1216 1 +#define TUNER_TYPE_TEMIC_FN5AL 2 +#define TUNER_TYPE_MT2032 3 +#define TUNER_TYPE_FI1246 4 +#define TUNER_TYPE_FI1256 5 +#define TUNER_TYPE_FI1236W 6 +#define TUNER_TYPE_FM1216ME 7 + +#define FI1236_ADDR(a) ((a)->d.SlaveAddr) + +#define FI1236_ADDR_1 0xC6 +#define FI1236_ADDR_2 0xC0 + +#define TUNER_TUNED 0 +#define TUNER_JUST_BELOW 1 +#define TUNER_JUST_ABOVE -1 +#define TUNER_OFF 4 +#define TUNER_STILL_TUNING 5 + + +FI1236Ptr Detect_FI1236(I2CBusPtr b, I2CSlaveAddr addr); +void FI1236_set_tuner_type(FI1236Ptr f, int type); +void TUNER_set_frequency(FI1236Ptr f, CARD32 frequency); +void FI1236_tune(FI1236Ptr f, CARD32 frequency); +int FI1236_AFC(FI1236Ptr f); +int TUNER_get_afc_hint(FI1236Ptr f); +void fi1236_dump_status(FI1236Ptr f); + +#define FI1236SymbolsList \ + "Detect_FI1236", \ + "FI1236_set_tuner_type", \ + "TUNER_set_frequency" + +#define xf86_Detect_FI1236 ((FI1236Ptr (*)(I2CBusPtr, I2CSlaveAddr))LoaderSymbol("Detect_FI1236")) +#define xf86_FI1236_set_tuner_type ((void (*)(FI1236Ptr, int))LoaderSymbol("FI1236_set_tuner_type")) +#define xf86_TUNER_set_frequency ((void (*)(FI1236Ptr, CARD32))LoaderSymbol("TUNER_set_frequency")) +#define xf86_FI1236_AFC ((int (*)(FI1236Ptr))LoaderSymbol("FI1236_AFC")) +#define xf86_TUNER_get_afc_hint ((int (*)(FI1236Ptr))LoaderSymbol("TUNER_get_afc_hint")) +#define xf86_fi1236_dump_status ((void (*)(FI1236Ptr))LoaderSymbol("fi1236_dump_status")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/fi1236_module.c b/xorg-server/hw/xfree86/i2c/fi1236_module.c new file mode 100644 index 000000000..4016ad0d4 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/fi1236_module.c @@ -0,0 +1,32 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(fi1236Setup); + +static XF86ModuleVersionInfo fi1236VersRec = +{ + "fi1236", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData fi1236ModuleData = { + &fi1236VersRec, + fi1236Setup, + NULL +}; + +static pointer +fi1236Setup(pointer module, pointer opts, int *errmaj, int *errmin) { + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/i2c/i2c_def.h b/xorg-server/hw/xfree86/i2c/i2c_def.h new file mode 100644 index 000000000..6e119e478 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/i2c_def.h @@ -0,0 +1,14 @@ +#ifndef __I2C_DEF_H__ +#define __I2C_DEF_H__ + +/* the following are a workaround for possible loader bug.. + WATCH function types ! */ +#define CreateI2CBusRec ((pointer (*)(void))LoaderSymbol("xf86CreateI2CBusRec")) +#define DestroyI2CBusRec ((pointer (*)(I2CBusPtr, Bool, Bool))LoaderSymbol("xf86DestroyI2CBusRec")) +#define I2CBusInit ((Bool (*)(pointer))LoaderSymbol("xf86I2CBusInit")) +#define I2C_WriteRead ((Bool (*)(I2CDevPtr, I2CByte *, int, I2CByte *, int))LoaderSymbol("xf86I2CWriteRead")) +#define CreateI2CDevRec ((pointer (*)(void))LoaderSymbol("xf86CreateI2CDevRec")) +#define I2CDevInit ((Bool (*)(I2CDevPtr))LoaderSymbol("xf86I2CDevInit")) +#define I2CProbeAddress ((Bool (*)(I2CBusPtr,I2CSlaveAddr))LoaderSymbol("xf86I2CProbeAddress")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/msp3430.c b/xorg-server/hw/xfree86/i2c/msp3430.c new file mode 100644 index 000000000..4bd3a7187 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/msp3430.c @@ -0,0 +1,726 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> +#include <unistd.h> + +#include "xf86.h" +#include "xf86i2c.h" +#include "msp3430.h" +#include "i2c_def.h" + +#define CONTROL 0x00 +#define WR_DEM 0x10 +#define RD_DEM 0x11 +#define WR_DSP 0x12 +#define RD_DSP 0x13 + + +void InitMSP34xxG(MSP3430Ptr m); +void InitMSP34x5D(MSP3430Ptr m); +void CheckModeMSP34x5D(MSP3430Ptr m); +char *MSP_getProductName (CARD16 product_id); +void mpause(int milliseconds); + +#define __MSPDEBUG__ 0 + +#if __MSPDEBUG__ > 3 + +void MSPBeep(MSP3430Ptr m, CARD8 freq); +#define __MSPBEEP MSPBeep(m,0x14); + +#else + +#define __MSPBEEP +#endif + +static void SetMSP3430Control(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegValueHigh, CARD8 RegValueLow) +{ + I2CByte data[3]; + + data[0]=RegAddress; + data[1]=RegValueHigh; + data[2]=RegValueLow; + + I2C_WriteRead(&(m->d),data,3,NULL,0); +} + +static void SetMSP3430Data(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegSubAddressHigh, CARD8 RegSubAddressLow, + CARD8 RegValueHigh, CARD8 RegValueLow) +{ + I2CByte data[5]; +#ifdef MSP_DEBUG + if(!m->registers_present[RegSubAddressLow]){ + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_ERROR, "Attempt to access non-existent register in MSP34xxX: 0x%02x 0x%02x 0x%02x <- 0x%02x 0x%02x\n", + RegAddress, RegSubAddressHigh, RegSubAddressLow, RegValueHigh, RegValueLow); + } +#endif + + data[0] = RegAddress; + data[1] = RegSubAddressHigh; + data[2] = RegSubAddressLow; + data[3] = RegValueHigh; + data[4] = RegValueLow; + + I2C_WriteRead(&(m->d),data,5,NULL,0); +} + +static void GetMSP3430Data(MSP3430Ptr m, CARD8 RegAddress, CARD8 RegSubAddressHigh, CARD8 RegSubAddressLow, + CARD8 *RegValueHigh, CARD8 *RegValueLow) +{ + I2CByte send[3]; + I2CByte receive[2]; + + send[0] = RegAddress; + send[1] = RegSubAddressHigh; + send[2] = RegSubAddressLow; + + I2C_WriteRead(&(m->d), send, 3, receive, 2); + + *RegValueHigh = receive[0]; + *RegValueLow = receive[1]; +} + +#if __MSPDEBUG__ > 2 +static void MSP3430DumpStatus(MSP3430Ptr m) +{ +CARD8 status_hi, status_lo; +CARD8 subaddr, data[2]; + +GetMSP3430Data(m, RD_DEM, 0x02, 0x00, &status_hi, &status_lo); +xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP34xx: SAP(8)=%d mono/NICAM(7)=%d stereo=%d %s O_1=%d O_0=%d 2nd car=%d 1st car=%d\n", + status_hi & 1, (status_lo>>7) & 1, (status_lo>>6)&1, + (status_lo>>5)? ( (status_hi>>1)&1? "bad NICAM reception" : "NICAM" ) : + ((status_hi>>1)&1 ? "bogus" : "ANALOG FM/AM") , + (status_lo>>4)&1, (status_lo>>3)&1,!( (status_lo>>2)&1), !((status_lo>>1)&1)); + +GetMSP3430Data(m, RD_DEM, 0x00, 0x7E, &status_hi, &status_lo); +xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP34xx: standard result=0x%02x%02x\n", + status_hi, status_lo); +subaddr=0x0; +I2C_WriteRead(&(m->d), &subaddr, 1, data, 2); +xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP34xx: control=0x%02x%02x\n", + data[1], data[0]); +} +#endif + +/* wrapper */ +void InitMSP3430(MSP3430Ptr m) +{ + #if __MSPDEBUG__ > 1 + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"InitMSP3430(m->connector=%d, m->standard=%d, m->chip_family=%d)\n", + m->connector, m->standard, m->chip_family); + #endif + switch (m->chip_family) { + case MSPFAMILY_34x0G: + InitMSP34xxG(m); + break; + case MSPFAMILY_34x5G: + InitMSP34xxG(m); + break; + case MSPFAMILY_34x5D: + InitMSP34x5D(m); + break; + } +} + +/*----------------------------------------------------------------- +| common functions for all MSP34xx chips +|----------------------------------------------------------------*/ + +MSP3430Ptr DetectMSP3430(I2CBusPtr b, I2CSlaveAddr addr) +{ + MSP3430Ptr m; + I2CByte a; + CARD8 hardware_version, major_revision, product_code, rom_version; + Bool supported; + + m = xcalloc(1,sizeof(MSP3430Rec)); + if(m == NULL)return NULL; + m->d.DevName = strdup("MSP34xx"); + m->d.SlaveAddr = addr; + m->d.pI2CBus = b; + m->d.NextDev = NULL; + m->d.StartTimeout = b->StartTimeout; + m->d.BitTimeout = b->BitTimeout; + m->d.AcknTimeout = b->AcknTimeout; + m->d.ByteTimeout = b->ByteTimeout; + + if(!I2C_WriteRead(&(m->d), NULL, 0, &a, 1)) + { + xfree(m->d.DevName); + xfree(m); + return NULL; + } + + + m->standard=MSP3430_NTSC; + m->connector=MSP3430_CONNECTOR_1; + m->mode=MSPMODE_STEREO_A; /*stereo or chanel A if avail. */ + m->c_format=MSPFORMAT_UNKNOWN; + m->c_standard=MSPSTANDARD_UNKNOWN; + m->c_matrix=m->c_fmmatrix=m->c_source=0; + m->volume=0; + m->recheck=FALSE; + + GetMSP3430Data(m, RD_DSP, 0x00, 0x1E, &hardware_version, &major_revision); + GetMSP3430Data(m, RD_DSP, 0x00, 0x1F, &product_code, &rom_version); + m->hardware_version=hardware_version; + m->major_revision=major_revision; + m->product_code=product_code; + m->rom_version=rom_version; + + m->chip_id=((major_revision << 8) | product_code); + + supported=FALSE; + switch (major_revision) { + case 4: /* 34xxD */ + switch (product_code) { + case 0x05: /* 3405D */ + case 0x0A: /* 3410D */ + case 0x0F: /* 3415D */ + m->chip_family=MSPFAMILY_34x5D; + m->recheck=TRUE; + supported=TRUE; + break; + default: + m->chip_family=MSPFAMILY_34x0D; + } + break; + case 7: /* 34xxG */ + switch(product_code){ + case 0x00: + case 0x0A: + case 0x1E: + case 0x28: + case 0x32: + m->chip_family=MSPFAMILY_34x0G; + supported=TRUE; + break; + case 0x0f: + case 0x19: + case 0x2d: + case 0x37: + case 0x41: + m->chip_family=MSPFAMILY_34x5G; + supported=TRUE; + #ifdef MSP_DEBUG + memset(m->registers_present, 0, 256); + #define A(num) m->registers_present[(num)]=1; + #define B(num1, num2) memset(&(m->registers_present[num1]), 1, num2-num1); + A(0x20) + A(0x30) + A(0x40) + A(0x00) + B(0x01, 0x08) + B(0x0B, 0x0E) + A(0x10) + B(0x12,0x14) + A(0x16) + A(0x29) + #undef B + #undef A + #endif + break; + default: + m->chip_family=MSPFAMILY_UNKNOWN; + } + break; + default: + m->chip_family=MSPFAMILY_UNKNOWN; + } + + xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "Found %s%s, rom version 0x%02x, chip_id=0x%04x\n", + MSP_getProductName(m->chip_id), supported?"":" (unsupported)", rom_version, m->chip_id); + + if (!supported) { + xfree(m->d.DevName); + xfree(m); + return NULL; + } + if(!I2CDevInit(&(m->d))) + { + xfree(m->d.DevName); + xfree(m); + return NULL; + } + + return m; +} + +void ResetMSP3430(MSP3430Ptr m) +{ + /* Reset the MSP3430 */ + SetMSP3430Control(m, 0x00, 0x80, 0x00); + /* Set it back to normal operation */ + SetMSP3430Control(m, 0x00, 0x00, 0x00); + + m->c_format=MSPFORMAT_UNKNOWN; + m->c_standard=MSPSTANDARD_UNKNOWN; + m->c_matrix=m->c_fmmatrix=m->c_source=0; + m->volume=0; +} + +void MSP3430SetVolume (MSP3430Ptr m, CARD8 value) +{ + CARD8 result; +#if 0 + CARD8 old_volume; + GetMSP3430Data(m, RD_DSP, 0x00, 0x00, &old_volume, &result); + xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP3430 result 0x%02x\n", result); +#endif + /* save an extra Get call */ + result=0; + + SetMSP3430Data(m, WR_DSP, 0x00, 0x00, value, result); + + SetMSP3430Data(m, WR_DSP, 0x00, 0x07, value, 0); + m->volume=value; + +#if __MSPDEBUG__ > 2 + MSP3430DumpStatus(m); + __MSPBEEP + GetMSP3430Data(m, RD_DSP, 0x00, 0x00, &old_volume, &result); + xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "MSP3430 volume 0x%02x\n",value); +#endif +} + + +void MSP3430SetSAP (MSP3430Ptr m, int mode) +{ + xf86DrvMsg(m->d.pI2CBus->scrnIndex, X_INFO, "Put actual code to change SAP here\n"); + + SetMSP3430Data(m, WR_DSP, 0x00, 0x08, mode & 0xff, 0x20); +} + + +#if 0 +void MSP3430SetSource(MSP3430Ptr m, CARD8 value) +{ + /* Write to DSP, register 0x0008, (loudspeaker channel source/matrix) */ + /* This sets the source to the TV tuner, for stereo operation */ + SetMSP3430Data(m, WR_DSP, 0x00, 0x08, value, 0x20); +} +#endif + + +char *MSP_getProductName (CARD16 product_id) +{ + switch (product_id) { + case 0x0400: return "MSP3400D"; + case 0x040a: return "MSP3410D"; + case 0x0405: return "MSP3405D"; + case 0x040f: return "MSP3415D"; + case 0x0700: return "MSP3400G"; + case 0x070a: return "MSP3410G"; + case 0x071e: return "MSP3430G"; + case 0x0728: return "MSP3440G"; + case 0x0732: return "MSP3450G"; + case 0x070f: return "MSP3415G"; + case 0x0719: return "MSP3425G"; + case 0x072d: return "MSP3445G"; + case 0x0737: return "MSP3455G"; + case 0x0741: return "MSP3465G"; + } + return "MSP - unknown type"; +} + +#if __MSPDEBUG__ > 2 +/*puts beep in MSP output + freq = 0x01 - 16Hz ... 0x40 - 1kHz ... 0xff - 4kHz +*/ +void MSPBeep(MSP3430Ptr m, CARD8 freq) { + SetMSP3430Data (m, WR_DSP, 0x00, freq, 0x7f, 0x40); + mpause(100); + SetMSP3430Data (m, WR_DSP, 0x00, 0x14, 0x00, 0x00); +} +#endif + +void mpause(int milliseconds) { + int i,m; + m=milliseconds/20; + for (i=0;i<m;i++) usleep(20000); +} + +/*----------------------------------------------------------------- +| specific functions for all MSP34xxG chips +|----------------------------------------------------------------*/ + +void InitMSP34xxG(MSP3430Ptr m) +{ + + #if __MSPDEBUG__ > 1 + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"InitMSP34xxG(m->connector=%d, m->standard=%d, m->chip_family=%d)\n", + m->connector, m->standard, m->chip_family); + #endif + /* Reset MSP3430 */ + SetMSP3430Control(m, 0x00, 0x80, 0x00); + /* Set it back to normal operation */ + SetMSP3430Control(m, 0x00, 0x00, 0x00); + + /*set MODUS register */ + /* bits: 0 - automatic sound detection */ + /* 1 - enable STATUS change */ + /* 12 - detect 6.5 Mhz carrier as D/K1, D/K2 or D/K NICAM (does not seem to work ) */ + /* 13 - detect 4.5 Mhz carrier as BTSC */ + if ( (m->standard & 0xff) == MSP3430_PAL ) + { + SetMSP3430Data(m, WR_DEM, 0x00, 0x30, 0x30, 0x03|0x08); /* make O_ pins tristate */ + /* PAL standard */ + SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x01); /* possibly wrong */ + } else { + SetMSP3430Data(m, WR_DEM, 0x00, 0x30, 0x20, 0x03|0x08); + /* standard selection is M-BTSC-Stereo */ + SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x20); + } + + switch(m->connector){ + case MSP3430_CONNECTOR_1: + SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x03, 0x20); + break; + case MSP3430_CONNECTOR_2: + /* this has not been checked yet.. could be bogus */ + /* SCART Input Prescale: 0 dB gain */ + SetMSP3430Data(m, WR_DSP, 0x00, 0x0d, 0x19, 0x00); + SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x02, 0x20); + break; + case MSP3430_CONNECTOR_3: + default: + /* SCART Input Prescale: 0 dB gain */ + SetMSP3430Data(m, WR_DSP, 0x00, 0x0d, 0x19, 0x00); + + SetMSP3430Data(m, WR_DSP, 0x00, 0x08, 0x02, 0x20); + break; + } + + switch(m->standard){ + case MSP3430_PAL: + SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03); + SetMSP3430Data(m, WR_DSP, 0x00, 0x10, 0x00, 0x5a); + SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x03); + /* Set volume to FAST_MUTE. */ + SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00); + break; + case MSP3430_PAL_DK1: + SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03); + SetMSP3430Data(m, WR_DSP, 0x00, 0x10, 0x00, 0x5a); + SetMSP3430Data(m, WR_DEM, 0x00, 0x20, 0x00, 0x04); + /* Set volume to FAST_MUTE. */ + SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00); + break; + case MSP3430_SECAM: /* is this right ? */ + case MSP3430_NTSC: + /* Write to DSP, register 0x000E, (prescale FM/FM matrix) */ + SetMSP3430Data(m, WR_DSP, 0x00, 0x0e, 0x24, 0x03); + + /* Set volume to FAST_MUTE. */ + SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00); + break; + } + +} + +/*----------------------------------------------------------------- +| specific functions for all MSP34x5D chips +|----------------------------------------------------------------*/ + +void InitMSP34x5D(MSP3430Ptr m) +{ +int count; +CARD8 high,low; +CARD16 result,standard; +CARD16 peak; + + +if (m->c_format==MSPFORMAT_UNKNOWN) ResetMSP3430(m); +else { + /*mute volume*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x00, 0x00, 0x00); +} + + + + switch(m->connector){ + case MSP3430_CONNECTOR_2: + case MSP3430_CONNECTOR_3: + if (m->c_format!=MSPFORMAT_SCART) { + /* SCART Input Prescale: 0 dB gain */ + SetMSP3430Data (m, WR_DSP, 0x00, 0x0d, 0x19, 0x00); + /* this has not been checked yet.. could be bogus */ + m->c_format=MSPFORMAT_SCART; /*stereo*/ + } + break; + case MSP3430_CONNECTOR_1: + default: + + switch ( m->standard & 0x00ff ) { + case MSP3430_PAL: + switch( m->standard ) { + case MSP3430_PAL_DK1: + standard=MSPSTANDARD_FM_DK1; + break; +/* case MSP3430_PAL_DK2: + standard=MSPSTANDARD_FM_DK2; + break; + case MSP3430_PAL_BG: + may be FM stereo (Germany) or FM NICAM (Scandinavia,spain) + standard=MSPSTANDARD_AUTO; + break; +*/ + default: + standard=MSPSTANDARD_AUTO; + } + break; + case MSP3430_SECAM: + standard=MSPSTANDARD_AUTO; + case MSP3430_NTSC: + /* Only MSP34x5 supported format - Korean NTSC-M*/ + standard=MSPSTANDARD_FM_M; + default: + standard=MSPSTANDARD_AUTO; + } + + /*no NICAM support in MSP3410D - force to autodetect*/ + if ((m->chip_id==0x405) && (standard>=MSPSTANDARD_NICAM_BG)) + standard=MSPSTANDARD_AUTO; + + if (m->c_standard != standard) { + + SetMSP3430Data (m, WR_DEM, 0x00, 0x20, standard>>8, standard & 0xFF); + if (standard==MSPSTANDARD_AUTO) { + count = 50; /* time shouldn't exceed 1s, just in case */ + do { + usleep(20000); + GetMSP3430Data (m, RD_DEM, 0x00, 0x7e, &high, &low); + result = ( high << 8 ) | low; + --count; + } while( result > 0x07ff && count > 0 ); + + if ((result > MSPSTANDARD_AUTO)) + standard=result; + else standard=MSPSTANDARD_UNKNOWN; +#if __MSPDEBUG__ > 1 + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Detected audio standard: %d\n",result); +#endif + /* result = MSPSTANDARD_NICAM_L can be one of: + SECAM_L - MSPSTANDARD_NICAM_L + D/K1 - MSPSTANDARD_FM_DK1 + D/K2 - MSPSTANDARD_FM_DK2 + D/K-NICAM - MSPSTANDARD_NICAM_DK*/ + if( standard == MSPSTANDARD_NICAM_L ) { + if ((m->standard & 0x00ff)==MSP3430_PAL) { + /* force PAL D/K */ + standard=MSPSTANDARD_FM_DK1; + SetMSP3430Data (m, WR_DEM, 0x00, 0x20, standard>>8, standard & 0xFF); +#if __MSPDEBUG__ > 1 + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO, "Detected 6.5MHz carrier - forced to D/K1 !!!\n" ); +#endif + } + } + } + m->c_standard=standard; + } /*end - standard changed*/ + else { + if (standard<MSPSTANDARD_NICAM_BG) { + /* get old value of ident. mode register*/ + GetMSP3430Data (m, RD_DSP, 0x00, 0x15, &high, &low); + /* reset Ident-Filter */ + SetMSP3430Data (m, WR_DSP, 0x00, 0x14, 0x00, 0x3F); + /* put back old value to ident. mode register*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x14, 0x00, low); + } + } + + if (standard<=MSPSTANDARD_AUTO) { + m->c_format=MSPFORMAT_1xFM; + } + else if (standard<MSPSTANDARD_NICAM_BG) { + /* set FM prescale */ + SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, 0x30, 0); + /* set FM deemphasis*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x0f, ((standard==MSPSTANDARD_FM_M)?0:1), 0); + + /* check if FM2 carrier is present */ + /*turn off FM DC Notch*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x17, 0x00, 0x3f); + /*matrix source for Quasi-Peak Detector - stereo: ch2->L ch1->R*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x0c, 0x00, 0x20); + + mpause(250); + GetMSP3430Data (m, RD_DSP, 0x00, 0x1A, &high, &low); + peak = (high << 8) | low; +#if __MSPDEBUG__ > 1 + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Second carrier Quasi-Peak detection: %d\n",peak); +#endif + /*turn on FM DC Notch*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x17, 0x00, 0x00); + + if (peak<5) { + /* if second carrier not detected - only mono from first carrier*/ + m->c_format=MSPFORMAT_1xFM; + } + else { + m->c_format=MSPFORMAT_2xFM; + /*start of FM identification process - FM_WAIT + wait at least 0.5s - used 1s - gives beter resolution*/ + mpause(1000); + } + } + else { + if (standard==MSPSTANDARD_NICAM_L) { + m->c_format=MSPFORMAT_NICAM_AM; + /* set AM prescale */ + SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, 0x7C, 0); + } + else { + m->c_format=MSPFORMAT_NICAM_FM; + /* set FM prescale */ + SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, 0x30, 0); + } + /* set FM deemphasis*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x0f, 0x00, 0); + /* set NICAM prescale to 0dB */ + SetMSP3430Data (m, WR_DSP, 0x00, 0x10, 0x20, 0); + } + + break; + } /*end - case conector*/ + + CheckModeMSP34x5D(m); + + /* Set volume to FAST_MUTE. */ + /*SetMSP3430Data(m, WR_DSP, 0x00, 0x00, 0xFF, 0x00);*/ + /*set volume*/ + MSP3430SetVolume(m,m->volume); + + __MSPBEEP + + +} /* EnableMSP34x5D ()... */ + + + + +void CheckModeMSP34x5D(MSP3430Ptr m) { + const char stereo_on=25; + const char stereo_off=20; + const char dual_on=-stereo_on; + const char dual_off=-stereo_off; + char detect; + CARD8 matrix, fmmatrix, source, high, low; + + fmmatrix=0; /*no matrix*/ + source=0; /*FM*/ + switch (m->c_format) { + case MSPFORMAT_NICAM_FM: + case MSPFORMAT_NICAM_AM: + case MSPFORMAT_SCART: + source=( (m->c_format == MSPFORMAT_SCART)?2:1 ); + switch (m->mode) { + case MSPMODE_MONO: + matrix=0x30; /*MONO*/ + break; + case MSPMODE_A: + matrix=0x00; /*A*/ + break; + case MSPMODE_B: + matrix=0x10; /*B*/ + break; + default: + matrix=0x20; /*STEREO*/ + break; + } + break; + default: + case MSPFORMAT_1xFM: + matrix=0x00; /*A*/ + break; + case MSPFORMAT_2xFM: + switch (m->mode) { + case MSPMODE_MONO: + matrix=0x30; /*MONO*/ + break; + case MSPMODE_STEREO: + matrix=0x20; /*STEREO*/ + fmmatrix=((m->c_standard==MSPSTANDARD_FM_M)?2:1); + break; + case MSPMODE_AB: + matrix=0x20; /*STEREO*/ + break; + case MSPMODE_A: + matrix=0x00; /*A*/ + break; + case MSPMODE_B: + matrix=0x10; /*B*/ + break; + default: + /*FM_IDENT_CHECK*/ + GetMSP3430Data (m, RD_DSP, 0x00, 0x18, &high, &low); + detect=(char)high; +#if __MSPDEBUG__ > 1 + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Stereo Detection Register: %d\n",detect); +#endif + if (detect>=((m->c_mode==MSPMODE_STEREO)?stereo_off:stereo_on)) { + m->c_mode=MSPMODE_STEREO; + matrix=0x20; /*STEREO*/ + fmmatrix=((m->c_standard==MSPSTANDARD_FM_M)?2:1); + } + else if (detect<=((m->c_mode==MSPMODE_AB)?dual_off:dual_on)) { + m->c_mode=MSPMODE_AB; + switch (m->mode) { + case MSPMODE_STEREO_AB: matrix=0x20; break; + case MSPMODE_STEREO_B: matrix=0x10; break; + default: + case MSPMODE_A: matrix=0x00; break; + } + } + else { + m->c_mode=MSPMODE_MONO; + matrix=0x30; /*MONO*/ + } + break; + } /* end - case mode*/ + break; + } + + if (m->c_fmmatrix != fmmatrix) { + GetMSP3430Data (m, RD_DSP, 0x00, 0x0e, &high, &low); + SetMSP3430Data (m, WR_DSP, 0x00, 0x0e, high, fmmatrix); + m->c_fmmatrix = fmmatrix; + } + + if ((m->c_matrix != matrix) || (m->c_source != source)) { + /*set chanel source and matrix for loudspeaker*/ + SetMSP3430Data (m, WR_DSP, 0x00, 0x08, source, matrix); + + m->c_matrix = matrix; + m->c_source = source; + } + + if ( ((m->c_format) & 0xF0) == MSPFORMAT_NICAM) + SetMSP3430Data (m, WR_DEM, 0x00, 0x21, 0, 1); + +#if __MSPDEBUG__ > 0 + char *msg; + switch (matrix) { + case 0x30: /*MONO*/ + msg="MONO"; + break; + case 0x00: /*LEFT*/ + msg="MONO/CHANNEL_1"; + break; + case 0x10: /*RIGHT*/ + msg="MONO/CHANNEL_2"; + break; + case 0x20: /*LEFT*/ + msg="STEREO"; + break; + default: + msg="unknown"; + break; + } + xf86DrvMsg(m->d.pI2CBus->scrnIndex,X_INFO,"Audio mode set to: %s\n",msg); +#endif +} + diff --git a/xorg-server/hw/xfree86/i2c/msp3430.h b/xorg-server/hw/xfree86/i2c/msp3430.h new file mode 100644 index 000000000..1cb9b869d --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/msp3430.h @@ -0,0 +1,114 @@ +#ifndef __MSP3430_H__ +#define __MSP3430_H__ + +#include "xf86i2c.h" + +typedef struct { + I2CDevRec d; + + int standard; + int connector; + int mode; + + CARD8 hardware_version, major_revision, product_code, rom_version; +#ifdef MSP_DEBUG + CARD8 registers_present[256]; +#endif + + CARD16 chip_id; + CARD8 chip_family; + Bool recheck; /*reinitialization needed after channel change */ + CARD8 c_format; /*current state of audio format */ + CARD16 c_standard; /*current state of standard register */ + CARD8 c_source; /*current state of source register */ + CARD8 c_matrix; /*current state of matrix register */ + CARD8 c_fmmatrix; /*current state of fmmatrix register */ + int c_mode; /* current state of mode for autoswitchimg */ + CARD8 volume; + } MSP3430Rec, * MSP3430Ptr; + + +#define MSP3430_ADDR_1 0x80 +#define MSP3430_ADDR_2 0x84 +#define MSP3430_ADDR_3 0x88 + +#define MSP3430_PAL 1 +#define MSP3430_NTSC 2 +#define MSP3430_PAL_DK1 (0x100 | MSP3430_PAL) +#define MSP3430_SECAM 3 + +#define MSP3430_CONNECTOR_1 1 /* tuner on AIW cards */ +#define MSP3430_CONNECTOR_2 2 /* SVideo on AIW cards */ +#define MSP3430_CONNECTOR_3 3 /* composite on AIW cards */ + +#define MSP3430_ADDR(a) ((a)->d.SlaveAddr) + +#define MSP3430_FAST_MUTE 0xFF +/* a handy volume transform function, -1000..1000 -> 0x01..0x7F */ +#define MSP3430_VOLUME(value) (0x01+(0x7F-0x01)*log(value+1001)/log(2001)) + +/*----------------------------------------------------------*/ + +/* MSP chip families */ +#define MSPFAMILY_UNKNOWN 0 +#define MSPFAMILY_34x0D 1 +#define MSPFAMILY_34x5D 2 +#define MSPFAMILY_34x0G 3 +#define MSPFAMILY_34x5G 4 + +/* values for MSP standard */ +#define MSPSTANDARD_UNKNOWN 0x00 +#define MSPSTANDARD_AUTO 0x01 +#define MSPSTANDARD_FM_M 0x02 +#define MSPSTANDARD_FM_BG 0x03 +#define MSPSTANDARD_FM_DK1 0x04 +#define MSPSTANDARD_FM_DK2 0x04 +#define MSPSTANDARD_NICAM_BG 0x08 +#define MSPSTANDARD_NICAM_L 0x09 +#define MSPSTANDARD_NICAM_I 0x0A +#define MSPSTANDARD_NICAM_DK 0x0B + +/* values for MSP format */ +#define MSPFORMAT_UNKNOWN 0x00 +#define MSPFORMAT_FM 0x10 +#define MSPFORMAT_1xFM 0x00|MSPFORMAT_FM +#define MSPFORMAT_2xFM 0x01|MSPFORMAT_FM +#define MSPFORMAT_NICAM 0x20 +#define MSPFORMAT_NICAM_FM 0x00|MSPFORMAT_NICAM +#define MSPFORMAT_NICAM_AM 0x01|MSPFORMAT_NICAM +#define MSPFORMAT_SCART 0x30 + +/* values for MSP mode */ +#define MSPMODE_UNKNOWN 0 +/* automatic modes */ +#define MSPMODE_STEREO_AB 1 +#define MSPMODE_STEREO_A 2 +#define MSPMODE_STEREO_B 3 +/* forced modes */ +#define MSPMODE_MONO 4 +#define MSPMODE_STEREO 5 +#define MSPMODE_AB 6 +#define MSPMODE_A 7 +#define MSPMODE_B 8 +/*----------------------------------------------------------*/ + +void InitMSP3430(MSP3430Ptr m); +MSP3430Ptr DetectMSP3430(I2CBusPtr b, I2CSlaveAddr addr); +void ResetMSP3430(MSP3430Ptr m); +void MSP3430SetVolume (MSP3430Ptr m, CARD8 value); +void MSP3430SetSAP (MSP3430Ptr m, int mode); + +#define MSP3430SymbolsList \ + "InitMSP3430", \ + "DetectMSP3430", \ + "ResetMSP3430", \ + "MSP3430SetVolume", \ + "MSP3430SetSAP" + +#define xf86_DetectMSP3430 ((MSP3430Ptr (*)(I2CBusPtr, I2CSlaveAddr))LoaderSymbol("DetectMSP3430")) +#define xf86_ResetMSP3430 ((void (*)(MSP3430Ptr))LoaderSymbol("ResetMSP3430")) +#define xf86_MSP3430SetVolume ((void (*)(MSP3430Ptr, CARD8))LoaderSymbol("MSP3430SetVolume")) +#define xf86_MSP3430SetSAP ((void (*)(MSP3430Ptr, int))LoaderSymbol("MSP3430SetSAP")) +#define xf86_InitMSP3430 ((void (*)(MSP3430Ptr))LoaderSymbol("InitMSP3430")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/msp3430_module.c b/xorg-server/hw/xfree86/i2c/msp3430_module.c new file mode 100644 index 000000000..66b14a277 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/msp3430_module.c @@ -0,0 +1,32 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(msp3430Setup); + +static XF86ModuleVersionInfo msp3430VersRec = +{ + "msp3430", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData msp3430ModuleData = { + &msp3430VersRec, + msp3430Setup, + NULL +}; + +static pointer +msp3430Setup(pointer module, pointer opts, int *errmaj, int *errmin) { + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/i2c/tda8425.c b/xorg-server/hw/xfree86/i2c/tda8425.c new file mode 100644 index 000000000..7631a0863 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda8425.c @@ -0,0 +1,78 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86i2c.h" +#include "tda8425.h" +#include "i2c_def.h" + +#define TDA8425(a,b) { \ + data[0]=a; \ + data[1]=b; \ + I2C_WriteRead(&(t->d), data, 2, NULL, 0); \ + } + +TDA8425Ptr Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr, Bool force) +{ + TDA8425Ptr t; + + t = xcalloc(1, sizeof(TDA8425Rec)); + if(t == NULL) return NULL; + t->d.DevName = "TDA8425 BTSC Stereo Audio Processor"; + t->d.SlaveAddr = addr; + t->d.pI2CBus = b; + t->d.NextDev = NULL; + t->d.StartTimeout = b->StartTimeout; + t->d.BitTimeout = b->BitTimeout; + t->d.AcknTimeout = b->AcknTimeout; + t->d.ByteTimeout = b->ByteTimeout; + + if(!force && !I2CProbeAddress(b, addr)) + { + xfree(t); + return NULL; + } + + /* set default parameters */ + if(!I2CDevInit(&(t->d))) + { + xfree(t); + return NULL; + } + + return t; +} + +Bool tda8425_init(TDA8425Ptr t) +{ + t->stereo = 3; /* 3 = Spacial 2 = Linear 1 = Pseudo 0 = Forced mono */ + t->v_left = 0xFF; /* FF - C0 */ + t->v_right = 0xFF; /* FF - C0 */ + t->bass = 0xF6; /* 0xFF - 0xF0 */ + t->treble = 0xF6; /* 0xFF - 0xF0 */ + t->src_sel = 3; /* 3 - stereo */ + t->mute = TRUE; + t->mux = 0; /* 0 - source one, 1 -source 2 */ + + tda8425_setaudio(t); + return TRUE; +} + +void tda8425_setaudio(TDA8425Ptr t) +{ + I2CByte data[2]; + + TDA8425(0x00, t->v_left ); + TDA8425(0x01, t->v_right ); + TDA8425(0x02, t->bass ); + TDA8425(0x03, t->treble ); + TDA8425(0x08, 0xC0 | (t->mute ? 0x20 : 0x0) | (t->stereo << 3) | (t->src_sel << 1) | + t->mux); +} + +void tda8425_mute(TDA8425Ptr t, Bool mute) +{ + t->mute = mute; + tda8425_setaudio(t); +} diff --git a/xorg-server/hw/xfree86/i2c/tda8425.h b/xorg-server/hw/xfree86/i2c/tda8425.h new file mode 100644 index 000000000..4abb4175f --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda8425.h @@ -0,0 +1,42 @@ +#ifndef __TDA8425_H__ +#define __TDA8425_H__ + +#include "xf86i2c.h" + +typedef struct { + I2CDevRec d; + + int mux; + int stereo; + int v_left; + int v_right; + int bass; + int treble; + int src_sel; + Bool mute; + } TDA8425Rec, *TDA8425Ptr; + +#define TDA8425_ADDR_1 0x82 + +/* the third parameter is meant to force detection of tda8425. + This is because tda8425 is write-only and complete implementation + of I2C protocol is not always available. Besides address there is no good + way to autodetect it so we have to _know_ it is there anyway */ + +TDA8425Ptr Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr,Bool force); +Bool tda8425_init(TDA8425Ptr t); +void tda8425_setaudio(TDA8425Ptr t); +void tda8425_mute(TDA8425Ptr t, Bool mute); + +#define TDA8425SymbolsList \ + "Detect_tda8425", \ + "tda8425_init", \ + "tda8425_setaudio", \ + "tda8425_mute" + +#define xf86_Detect_tda8425 ((TDA8425Ptr (*)(I2CBusPtr, I2CSlaveAddr,Bool))LoaderSymbol("Detect_tda8425")) +#define xf86_tda8425_init ((Bool (*)(TDA8425Ptr))LoaderSymbol("tda8425_init")) +#define xf86_tda8425_setaudio ((void (*)(TDA8425Ptr))LoaderSymbol("tda8425_setaudio")) +#define xf86_tda8425_mute ((void (*)(TDA8425Ptr, Bool))LoaderSymbol("tda8425_mute")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/tda8425_module.c b/xorg-server/hw/xfree86/i2c/tda8425_module.c new file mode 100644 index 000000000..7906e5ea5 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda8425_module.c @@ -0,0 +1,32 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(tda8425Setup); + +static XF86ModuleVersionInfo tda8425VersRec = +{ + "tda8425", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData tda8425ModuleData = { + &tda8425VersRec, + tda8425Setup, + NULL +}; + +static pointer +tda8425Setup(pointer module, pointer opts, int *errmaj, int *errmin) { + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/i2c/tda9850.c b/xorg-server/hw/xfree86/i2c/tda9850.c new file mode 100644 index 000000000..5b0c581ed --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda9850.c @@ -0,0 +1,112 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86i2c.h" +#include "tda9850.h" +#include "i2c_def.h" + +#define TDA9850(a,b) { \ + data[0]=a; \ + data[1]=b; \ + I2C_WriteRead(&(t->d), data, 2, NULL, 0); \ + } + +TDA9850Ptr Detect_tda9850(I2CBusPtr b, I2CSlaveAddr addr) +{ + TDA9850Ptr t; + I2CByte a; + + t = xcalloc(1, sizeof(TDA9850Rec)); + if(t == NULL) return NULL; + switch(addr) + { + case TDA9850_ADDR_1: + t->d.DevName = "TDA9850 BTSC Stereo+SAP Audio Processor"; + break; + default: + t->d.DevName = "Generic TDAxxxx"; + break; + } + t->d.SlaveAddr = addr; + t->d.pI2CBus = b; + t->d.NextDev = NULL; + t->d.StartTimeout = b->StartTimeout; + t->d.BitTimeout = b->BitTimeout; + t->d.AcknTimeout = b->AcknTimeout; + t->d.ByteTimeout = b->ByteTimeout; + + if(!I2C_WriteRead(&(t->d), NULL, 0, &a, 1)) + { + xfree(t); + return NULL; + } + + /* set default parameters */ + if(!I2CDevInit(&(t->d))) + { + xfree(t); + return NULL; + } + + return t; +} + +Bool tda9850_init(TDA9850Ptr t) +{ + t->stereo = 1; + t->sap = 0; + t->mute = TRUE; + t->sap_mute = TRUE; + tda9850_setaudio(t); + return TRUE; +} + +void tda9850_setaudio(TDA9850Ptr t) +{ +CARD8 data[2]; + +if(t->mux==2) +{ + TDA9850(0x04,0x0F); TDA9850(0x05,0x0F); TDA9850(0x06, 0x58); + TDA9850(0x07,0x07); TDA9850(0x08,0x00); + TDA9850(0x09,0x00); TDA9850(0x0A,0x03); +} else +{ + TDA9850(0x04,0x07); TDA9850(0x05,0x07); + TDA9850(0x06,0x58); TDA9850(0x07,0x07); + TDA9850(0x08,0x10); TDA9850(0x09,0x10); + TDA9850(0x0A,0x03); +} + +TDA9850(0x06,(t->stereo<<6)|(t->sap<<7)|(t->mute?0x8:0)|(t->sap_mute?0x10:0x0)); +} + +void tda9850_mute(TDA9850Ptr t, Bool mute) +{ +CARD8 data[2]; + +xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO, "tda9850_mute %s\n", mute ? "on" : "off"); +t->mute = mute; + +TDA9850(0x06,(t->stereo<<6)|(t->sap<<7)|(t->mute?0x8:0x0)|(t->sap_mute?0x10:0x0)); +} + +void tda9850_sap_mute(TDA9850Ptr t, Bool sap_mute) +{ +CARD8 data[2]; + +xf86DrvMsg(t->d.pI2CBus->scrnIndex, X_INFO, "tda9850_sap_mute %s\n", sap_mute ? "on" : "off"); +t->sap_mute = sap_mute; + +TDA9850(0x06,(t->stereo<<6)|(t->sap<<7)|(t->mute?0x8:0x0)|(t->sap_mute?0x10:0x0)); +} + +CARD16 tda9850_getstatus(TDA9850Ptr t) +{ +CARD16 status; + +I2C_WriteRead(&(t->d), NULL, 0, (I2CByte *)&status, 2); +return status; +} diff --git a/xorg-server/hw/xfree86/i2c/tda9850.h b/xorg-server/hw/xfree86/i2c/tda9850.h new file mode 100644 index 000000000..d5dec36fe --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda9850.h @@ -0,0 +1,39 @@ +#ifndef __TDA9850_H__ +#define __TDA9850_H__ + +#include "xf86i2c.h" + +typedef struct { + I2CDevRec d; + + int mux; + int stereo; + int sap; + Bool mute; + Bool sap_mute; + } TDA9850Rec, *TDA9850Ptr; + +#define TDA9850_ADDR_1 0xB4 + +TDA9850Ptr Detect_tda9850(I2CBusPtr b, I2CSlaveAddr addr); +Bool tda9850_init(TDA9850Ptr t); +void tda9850_setaudio(TDA9850Ptr t); +void tda9850_mute(TDA9850Ptr t, Bool mute); +void tda9850_sap_mute(TDA9850Ptr t, Bool sap_mute); +CARD16 tda9850_getstatus(TDA9850Ptr t); + +#define TDA9850SymbolsList \ + "Detect_tda9850", \ + "tda9850_init", \ + "tda9850_setaudio", \ + "tda9850_mute", \ + "tda9850_sap_mute" + +#define xf86_Detect_tda9850 ((TDA9850Ptr (*)(I2CBusPtr, I2CSlaveAddr))LoaderSymbol("Detect_tda9850")) +#define xf86_tda9850_init ((Bool (*)(TDA9850Ptr))LoaderSymbol("tda9850_init")) +#define xf86_tda9850_setaudio ((void (*)(TDA9850Ptr))LoaderSymbol("tda9850_setaudio")) +#define xf86_tda9850_mute ((void (*)(TDA9850Ptr, Bool))LoaderSymbol("tda9850_mute")) +#define xf86_tda9850_sap_mute ((void (*)(TDA9850Ptr, Bool))LoaderSymbol("tda9850_sap_mute")) +#define xf86_tda9850_getstatus ((CARD16 (*)(TDA9850Ptr))LoaderSymbol("tda9850_getstatus")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/tda9850_module.c b/xorg-server/hw/xfree86/i2c/tda9850_module.c new file mode 100644 index 000000000..84f7e861e --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda9850_module.c @@ -0,0 +1,32 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(tda9850Setup); + +static XF86ModuleVersionInfo tda9850VersRec = +{ + "tda9850", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData tda9850ModuleData = { + &tda9850VersRec, + tda9850Setup, + NULL +}; + +static pointer +tda9850Setup(pointer module, pointer opts, int *errmaj, int *errmin) { + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/i2c/tda9885.c b/xorg-server/hw/xfree86/i2c/tda9885.c new file mode 100644 index 000000000..4147dfdd7 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda9885.c @@ -0,0 +1,104 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86i2c.h" +#include "tda9885.h" +#include "i2c_def.h" + + +TDA9885Ptr Detect_tda9885(I2CBusPtr b, I2CSlaveAddr addr) +{ + TDA9885Ptr t; + I2CByte a; + + t = xcalloc(1, sizeof(TDA9885Rec)); + if(t == NULL) return NULL; + switch(addr) + { + case TDA9885_ADDR_1: + case TDA9885_ADDR_2: + case TDA9885_ADDR_3: + case TDA9885_ADDR_4: + t->d.DevName = "TDA9885 Alignment-free IF-PLL"; + break; + default: + t->d.DevName = "Generic TDAxxxx"; + break; + } + t->d.SlaveAddr = addr; + t->d.pI2CBus = b; + t->d.NextDev = NULL; + t->d.StartTimeout = b->StartTimeout; + t->d.BitTimeout = b->BitTimeout; + t->d.AcknTimeout = b->AcknTimeout; + t->d.ByteTimeout = b->ByteTimeout; + + if(!I2C_WriteRead(&(t->d), NULL, 0, &a, 1)) + { + xfree(t); + return NULL; + } + + /* set default parameters */ + if(!I2CDevInit(&(t->d))) + { + xfree(t); + return NULL; + } + + return t; +} + +Bool tda9885_init(TDA9885Ptr t) +{ + t->forced_mute_audio=1; + return TRUE; +} + +void tda9885_getstatus(TDA9885Ptr t) +{ +CARD8 value; + +I2C_WriteRead(&(t->d), NULL, 0, &value, 1); +t->after_reset=value & 1; +t->afc_status=(value >> 1) & 0xf; +t->fm_carrier=(value>>5)& 1; +t->vif_level=(value >>6) & 1; +t->afc_win=(value >> 7)&1; +} + +void tda9885_setparameters(TDA9885Ptr t) +{ +CARD8 data[4]; + +data[0]=0; /* start with subaddress 0 */ +data[1]=(t->sound_trap & 1) | + ((t->auto_mute_fm &1)<<1) | + ((t->carrier_mode &1)<<2) | + ((t->modulation &3)<<3) | + ((t->forced_mute_audio &1)<<5) | + ((t->port1 & 1)<<6) | + ((t->port2 &1)<<7); /* B data */ +data[2]=(t->top_adjustment & 0x1f) | + ((t->deemphasis & 0x3)<<5) | + ((t->audio_gain & 1) << 7); /* C data */ +data[3]=(t->standard_sound_carrier & 0x3) | + ((t->standard_video_if & 0x07)<<2) | + ((t->minimum_gain & 0x01)<<5) | + ((t->gating & 0x01)<<6) | + ((t->vif_agc & 0x01)<<7); /* E data */ + +I2C_WriteRead(&(t->d), data, 4, NULL, 0); + +xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"TDA9885 setparam: B data: %x, C data: %x, E data: %x\n", data[1], data[2], data[3]); +} + +void tda9885_dumpstatus(TDA9885Ptr t) +{ +xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"TDA9885 status: after_reset=%d afc_status=%d (%3.1f kHz off) fm_carrier=%d vif_level=%d afc_win=%d %s\n", + t->after_reset, t->afc_status, + (t->afc_status<8)?-12.5-t->afc_status*25.0:-12.5+(16-t->afc_status)*25.0, + t->fm_carrier, t->vif_level, t->afc_win, t->afc_win?"VCO in": "VCO out"); +} diff --git a/xorg-server/hw/xfree86/i2c/tda9885.h b/xorg-server/hw/xfree86/i2c/tda9885.h new file mode 100644 index 000000000..46ae9fc0d --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda9885.h @@ -0,0 +1,60 @@ +#ifndef __TDA9885_H__ +#define __TDA9885_H__ + +#include "xf86i2c.h" + +typedef struct { + I2CDevRec d; + + /* write-only parameters */ + /* B DATA */ + CARD8 sound_trap; + CARD8 auto_mute_fm; + CARD8 carrier_mode; + CARD8 modulation; + CARD8 forced_mute_audio; + CARD8 port1; + CARD8 port2; + /* C DATA */ + CARD8 top_adjustment; + CARD8 deemphasis; + CARD8 audio_gain; + /* E DATA */ + CARD8 standard_sound_carrier; + CARD8 standard_video_if; + CARD8 minimum_gain; + CARD8 gating; + CARD8 vif_agc; + /* read-only values */ + + CARD8 after_reset; + CARD8 afc_status; + CARD8 vif_level; + CARD8 afc_win; + CARD8 fm_carrier; + } TDA9885Rec, *TDA9885Ptr; + +#define TDA9885_ADDR_1 0x86 +#define TDA9885_ADDR_2 0x84 +#define TDA9885_ADDR_3 0x96 +#define TDA9885_ADDR_4 0x94 + +TDA9885Ptr Detect_tda9885(I2CBusPtr b, I2CSlaveAddr addr); +Bool tda9885_init(TDA9885Ptr t); +void tda9885_setparameters(TDA9885Ptr t); +void tda9885_getstatus(TDA9885Ptr t); +void tda9885_dumpstatus(TDA9885Ptr t); + +#define TDA9885SymbolsList \ + "Detect_tda9885", \ + "tda9885_init", \ + "tda9885_setaudio", \ + "tda9885_mute" + +#define xf86_Detect_tda9885 ((TDA9885Ptr (*)(I2CBusPtr, I2CSlaveAddr))LoaderSymbol("Detect_tda9885")) +#define xf86_tda9885_init ((Bool (*)(TDA9885Ptr))LoaderSymbol("tda9885_init")) +#define xf86_tda9885_setparameters ((void (*)(TDA9885Ptr))LoaderSymbol("tda9885_setparameters")) +#define xf86_tda9885_getstatus ((void (*)(TDA9885Ptr))LoaderSymbol("tda9885_getstatus")) +#define xf86_tda9885_dumpstatus ((void (*)(TDA9885Ptr))LoaderSymbol("tda9885_dumpstatus")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/tda9885_module.c b/xorg-server/hw/xfree86/i2c/tda9885_module.c new file mode 100644 index 000000000..0ce85bba3 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/tda9885_module.c @@ -0,0 +1,32 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(tda9885Setup); + +static XF86ModuleVersionInfo tda9885VersRec = +{ + "tda9885", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData tda9885ModuleData = { + &tda9885VersRec, + tda9885Setup, + NULL +}; + +static pointer +tda9885Setup(pointer module, pointer opts, int *errmaj, int *errmin) { + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/i2c/uda1380.c b/xorg-server/hw/xfree86/i2c/uda1380.c new file mode 100644 index 000000000..defda3cdc --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/uda1380.c @@ -0,0 +1,183 @@ +/************************************************************************************* + * Copyright (C) 2005 Bogdan D. bogdand@users.sourceforge.net + * + * 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 AUTHOR BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the author shall not be used in advertising or + * otherwise to promote the sale, use or other dealings in this Software without prior written + * authorization from the author. + * + ************************************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86i2c.h" +#include "uda1380.h" +#include "i2c_def.h" + +UDA1380Ptr Detect_uda1380(I2CBusPtr b, I2CSlaveAddr addr) +{ + UDA1380Ptr t; + I2CByte a; + + t = xcalloc(1, sizeof(UDA1380Rec)); + if(t == NULL) return NULL; + switch(addr) + { + case UDA1380_ADDR_1: + case UDA1380_ADDR_2: + t->d.DevName = "UDA1380 Stereo audion coder-decoder"; + break; + default: + t->d.DevName = "Generic UDAxxxx"; + break; + } + t->d.SlaveAddr = addr; + t->d.pI2CBus = b; + t->d.NextDev = NULL; + t->d.StartTimeout = b->StartTimeout; + t->d.BitTimeout = b->BitTimeout; + t->d.AcknTimeout = b->AcknTimeout; + t->d.ByteTimeout = b->ByteTimeout; + + if(!I2C_WriteRead(&(t->d), NULL, 0, &a, 1)) + { + xfree(t); + return NULL; + } + + /* set default parameters */ + if(!I2CDevInit(&(t->d))) + { + xfree(t); + return NULL; + } + + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 stereo coder-decoder detected\n"); + + return t; +} + +Bool uda1380_init(UDA1380Ptr t) +{ + CARD8 data[3]; + CARD16 tmp; + Bool ret; + + /* Power control */ + data[0] = 0x02; + tmp = (1 << 13) | (1 << 10) | ( 1 << 8) | (1 << 7) | (1 << 6) | (1 << 3) | (1 << 1); + data[1] = (CARD8)((tmp >> 8) & 0xff); + data[2] = (CARD8)(tmp & 0xff); + ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0); + if (ret == FALSE) + { + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to initialize\n"); + return FALSE; + } + + /* Analog mixer (AVC) */ + data[0] = 0x03; + /* the analog mixer is muted initially */ + data[1] = 0x3f; + data[2] = 0x3f; + ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0); + if (ret == FALSE) + { + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to initialize\n"); + return FALSE; + } + + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 initialized\n"); + + return TRUE; +} + +void uda1380_shutdown(UDA1380Ptr t) +{ + CARD8 data[3]; + Bool ret; + + /* Power control */ + data[0] = 0x02; + data[1] = 0; + data[2] = 0; + ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0); + if (ret == FALSE) + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to shutdown\n"); +} + +void uda1380_setvolume(UDA1380Ptr t, INT32 value) +{ + CARD8 data[3]; + /* + * We have to scale the value ranging from -1000 to 1000 to 0x2c to 0 + */ + CARD8 volume = 47 - (CARD8)((value + 1000) * 47 / 2000); + Bool ret; + + t->analog_mixer_settings = ((volume << 8) & 0x3f00) | (volume & 0x3f); + + /* Analog mixer (AVC) */ + data[0] = 0x03; + data[1] = volume & 0x3f; + data[2] = volume & 0x3f; + ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0); + if (ret == FALSE) + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to set volume\n"); +} + +void uda1380_mute(UDA1380Ptr t, Bool mute) +{ + CARD8 data[3]; + Bool ret; + + if (mute == TRUE) + { + /* Analog mixer (AVC) */ + data[0] = 0x03; + data[1] = 0xff; + data[2] = 0xff; + ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0); + if (ret == FALSE) + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to mute\n"); + } + else + { + /* Analog mixer (AVC) */ + data[0] = 0x03; + data[1] = (CARD8)((t->analog_mixer_settings >> 8) & 0x3f); + data[2] = (CARD8)(t->analog_mixer_settings & 0x3f); + ret = I2C_WriteRead(&(t->d), data, 3, NULL, 0); + if (ret == FALSE) + xf86DrvMsg(t->d.pI2CBus->scrnIndex,X_INFO,"UDA1380 failed to unmute\n"); + } +} + +void uda1380_getstatus(UDA1380Ptr t) +{ +} + +void uda1380_setparameters(UDA1380Ptr t) +{ +} + +void uda1380_dumpstatus(UDA1380Ptr t) +{ +} diff --git a/xorg-server/hw/xfree86/i2c/uda1380.h b/xorg-server/hw/xfree86/i2c/uda1380.h new file mode 100644 index 000000000..e671d66f8 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/uda1380.h @@ -0,0 +1,75 @@ +/************************************************************************************* + * Copyright (C) 2005 Bogdan D. bogdand@users.sourceforge.net + * + * 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 AUTHOR BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the author shall not be used in advertising or + * otherwise to promote the sale, use or other dealings in this Software without prior written + * authorization from the author. + * + * Revision 1.3 2005/09/24 21:56:00 bogdand + * Changed the license to a X/MIT one + * + * Revision 1.2 2005/07/01 22:43:11 daniels + * Change all misc.h and os.h references to <X11/foo.h>. + * + * + ************************************************************************************/ + +#ifndef __UDA1380_H__ +#define __UDA1380_H__ + +#include "xf86i2c.h" + +typedef struct { + I2CDevRec d; + + CARD16 analog_mixer_settings; /* register 0x03 */ + + } UDA1380Rec, *UDA1380Ptr; + +#define UDA1380_ADDR_1 0x30 +#define UDA1380_ADDR_2 0x34 + +UDA1380Ptr Detect_uda1380(I2CBusPtr b, I2CSlaveAddr addr); +Bool uda1380_init(UDA1380Ptr t); +void uda1380_shutdown(UDA1380Ptr t); +void uda1380_setvolume(UDA1380Ptr t, INT32); +void uda1380_mute(UDA1380Ptr t, Bool); +void uda1380_setparameters(UDA1380Ptr t); +void uda1380_getstatus(UDA1380Ptr t); +void uda1380_dumpstatus(UDA1380Ptr t); + +#define UDA1380SymbolsList \ + "Detect_uda1380", \ + "uda1380_init", \ + "uda1380_shutdown", \ + "uda1380_setvolume", \ + "uda1380_mute", \ + "uda1380_setparameters", \ + "uda1380_getstatus", \ + "uda1380_dumpstatus" + +#define xf86_Detect_uda1380 ((UDA1380Ptr (*)(I2CBusPtr, I2CSlaveAddr))LoaderSymbol("Detect_uda1380")) +#define xf86_uda1380_init ((Bool (*)(UDA1380Ptr))LoaderSymbol("uda1380_init")) +#define xf86_uda1380_shutdown ((void (*)(UDA1380Ptr))LoaderSymbol("uda1380_shutdown")) +#define xf86_uda1380_setvolume ((void (*)(UDA1380Ptr, CARD16))LoaderSymbol("uda1380_setvolume")) +#define xf86_uda1380_mute ((void (*)(UDA1380Ptr, Bool))LoaderSymbol("uda1380_mute")) +#define xf86_uda1380_setparameters ((void (*)(UDA1380Ptr))LoaderSymbol("uda1380_setparameters")) +#define xf86_uda1380_getstatus ((void (*)(UDA1380Ptr))LoaderSymbol("uda1380_getstatus")) +#define xf86_uda1380_dumpstatus ((void (*)(UDA1380Ptr))LoaderSymbol("uda1380_dumpstatus")) + +#endif diff --git a/xorg-server/hw/xfree86/i2c/uda1380_module.c b/xorg-server/hw/xfree86/i2c/uda1380_module.c new file mode 100644 index 000000000..895f8c6f2 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/uda1380_module.c @@ -0,0 +1,32 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(uda1380Setup); + +static XF86ModuleVersionInfo uda1380VersRec = +{ + "uda1380", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData uda1380ModuleData = { + &uda1380VersRec, + uda1380Setup, + NULL +}; + +static pointer +uda1380Setup(pointer module, pointer opts, int *errmaj, int *errmin) { + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.c b/xorg-server/hw/xfree86/i2c/xf86i2c.c new file mode 100644 index 000000000..5cc83faa3 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/xf86i2c.c @@ -0,0 +1,890 @@ +/* + * Copyright (C) 1998 Itai Nahshon, Michael Schimek + * + * The original code was derived from and inspired by + * the I2C driver from the Linux kernel. + * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/time.h> +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include <X11/Xos.h> +#include <X11/Xproto.h> +#include "scrnintstr.h" +#include "regionstr.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "validate.h" +#include "resource.h" +#include "gcstruct.h" +#include "dixstruct.h" + +#include "xf86i2c.h" + +#define I2C_TIMEOUT(x) /*(x)*/ /* Report timeouts */ +#define I2C_TRACE(x) /*(x)*/ /* Report progress */ + +/* Set which OSs have bad gettimeofday resolution. */ +#if defined(SVR4) && !defined(sun) +#define BAD_GETTIMEOFDAY_RESOLUTION +#endif + + +/* This is the default I2CUDelay function if not supplied by the driver. + * High level I2C interfaces implementing the bus protocol in hardware + * should supply this function too. + * + * Delay execution at least usec microseconds. + * All values 0 to 1e6 inclusive must be expected. + */ + +#ifdef BAD_GETTIMEOFDAY_RESOLUTION +/* + * This is temporary until a better, portable + * way is found. Adjust bogo_usec to match CPU speed. + */ +static int bogo_usec = 500; + +static void +I2CUDelay(I2CBusPtr b, int usec) +{ + volatile long i; + + if (usec > 0) + for (i = usec * bogo_usec; i > 0; i--) + /* (perhaps hw delay action) */; +} +#else +static void +I2CUDelay(I2CBusPtr b, int usec) +{ + struct timeval begin, cur; + long d_secs, d_usecs; + long diff; + + if (usec > 0) { + X_GETTIMEOFDAY(&begin); + do { + /* It would be nice to use {xf86}usleep, + * but usleep (1) takes >10000 usec ! + */ + X_GETTIMEOFDAY(&cur); + d_secs = (cur.tv_sec - begin.tv_sec); + d_usecs = (cur.tv_usec - begin.tv_usec); + diff = d_secs*1000000 + d_usecs; + } while (diff>=0 && diff< (usec + 1)); + } +} +#endif + +/* Most drivers will register just with GetBits/PutBits functions. + * The following functions implement a software I2C protocol + * by using the promitive functions given by the driver. + * ================================================================ + * + * It is assumed that there is just one master on the I2C bus, therefore + * there is no explicit test for conflits. + */ + +#define RISEFALLTIME 2 /* usec, actually 300 to 1000 ns according to the i2c specs */ + +/* Some devices will hold SCL low to slow down the bus or until + * ready for transmission. + * + * This condition will be noticed when the master tries to raise + * the SCL line. You can set the timeout to zero if the slave device + * does not support this clock synchronization. + */ + +static Bool +I2CRaiseSCL(I2CBusPtr b, int sda, int timeout) +{ + int i, scl; + + b->I2CPutBits(b, 1, sda); + b->I2CUDelay(b, b->RiseFallTime); + + for (i = timeout; i > 0; i -= b->RiseFallTime) { + b->I2CGetBits(b, &scl, &sda); + if (scl) break; + b->I2CUDelay(b, b->RiseFallTime); + } + + if (i <= 0) { + I2C_TIMEOUT(ErrorF("[I2CRaiseSCL(<%s>, %d, %d) timeout]", b->BusName, sda, timeout)); + return FALSE; + } + + return TRUE; +} + +/* Send a start signal on the I2C bus. The start signal notifies + * devices that a new transaction is initiated by the bus master. + * + * The start signal is always followed by a slave address. + * Slave addresses are 8+ bits. The first 7 bits identify the + * device and the last bit signals if this is a read (1) or + * write (0) operation. + * + * There may be more than one start signal on one transaction. + * This happens for example on some devices that allow reading + * of registers. First send a start bit followed by the device + * address (with the last bit 0) and the register number. Then send + * a new start bit with the device address (with the last bit 1) + * and then read the value from the device. + * + * Note this is function does not implement a multiple master + * arbitration procedure. + */ + +static Bool +I2CStart(I2CBusPtr b, int timeout) +{ + if (!I2CRaiseSCL(b, 1, timeout)) + return FALSE; + + b->I2CPutBits(b, 1, 0); + b->I2CUDelay(b, b->HoldTime); + b->I2CPutBits(b, 0, 0); + b->I2CUDelay(b, b->HoldTime); + + I2C_TRACE(ErrorF("\ni2c: <")); + + return TRUE; +} + +/* This is the default I2CStop function if not supplied by the driver. + * + * Signal devices on the I2C bus that a transaction on the + * bus has finished. There may be more than one start signal + * on a transaction but only one stop signal. + */ + +static void +I2CStop(I2CDevPtr d) +{ + I2CBusPtr b = d->pI2CBus; + + b->I2CPutBits(b, 0, 0); + b->I2CUDelay(b, b->RiseFallTime); + + b->I2CPutBits(b, 1, 0); + b->I2CUDelay(b, b->HoldTime); + b->I2CPutBits(b, 1, 1); + b->I2CUDelay(b, b->HoldTime); + + I2C_TRACE(ErrorF(">\n")); +} + +/* Write/Read a single bit to/from a device. + * Return FALSE if a timeout occurs. + */ + +static Bool +I2CWriteBit(I2CBusPtr b, int sda, int timeout) +{ + Bool r; + + b->I2CPutBits(b, 0, sda); + b->I2CUDelay(b, b->RiseFallTime); + + r = I2CRaiseSCL(b, sda, timeout); + b->I2CUDelay(b, b->HoldTime); + + b->I2CPutBits(b, 0, sda); + b->I2CUDelay(b, b->HoldTime); + + return r; +} + +static Bool +I2CReadBit(I2CBusPtr b, int *psda, int timeout) +{ + Bool r; + int scl; + + r = I2CRaiseSCL(b, 1, timeout); + b->I2CUDelay(b, b->HoldTime); + + b->I2CGetBits(b, &scl, psda); + + b->I2CPutBits(b, 0, 1); + b->I2CUDelay(b, b->HoldTime); + + return r; +} + +/* This is the default I2CPutByte function if not supplied by the driver. + * + * A single byte is sent to the device. + * The function returns FALSE if a timeout occurs, you should send + * a stop condition afterwards to reset the bus. + * + * A timeout occurs, + * if the slave pulls SCL to slow down the bus more than ByteTimeout usecs, + * or slows down the bus for more than BitTimeout usecs for each bit, + * or does not send an ACK bit (0) to acknowledge the transmission within + * AcknTimeout usecs, but a NACK (1) bit. + * + * AcknTimeout must be at least b->HoldTime, the other timeouts can be + * zero according to the comment on I2CRaiseSCL. + */ + +static Bool +I2CPutByte(I2CDevPtr d, I2CByte data) +{ + Bool r; + int i, scl, sda; + I2CBusPtr b = d->pI2CBus; + + if (!I2CWriteBit(b, (data >> 7) & 1, d->ByteTimeout)) + return FALSE; + + for (i = 6; i >= 0; i--) + if (!I2CWriteBit(b, (data >> i) & 1, d->BitTimeout)) + return FALSE; + + b->I2CPutBits(b, 0, 1); + b->I2CUDelay(b, b->RiseFallTime); + + r = I2CRaiseSCL(b, 1, b->HoldTime); + + if (r) { + for (i = d->AcknTimeout; i > 0; i -= b->HoldTime) { + b->I2CUDelay(b, b->HoldTime); + b->I2CGetBits(b, &scl, &sda); + if (sda == 0) break; + } + + if (i <= 0) { + I2C_TIMEOUT(ErrorF("[I2CPutByte(<%s>, 0x%02x, %d, %d, %d) timeout]", + b->BusName, data, d->BitTimeout, + d->ByteTimeout, d->AcknTimeout)); + r = FALSE; + } + + I2C_TRACE(ErrorF("W%02x%c ", (int) data, sda ? '-' : '+')); + } + + b->I2CPutBits(b, 0, 1); + b->I2CUDelay(b, b->HoldTime); + + return r; +} + +/* This is the default I2CGetByte function if not supplied by the driver. + * + * A single byte is read from the device. + * The function returns FALSE if a timeout occurs, you should send + * a stop condition afterwards to reset the bus. + * + * A timeout occurs, + * if the slave pulls SCL to slow down the bus more than ByteTimeout usecs, + * or slows down the bus for more than b->BitTimeout usecs for each bit. + * + * ByteTimeout must be at least b->HoldTime, the other timeouts can be + * zero according to the comment on I2CRaiseSCL. + * + * For the <last> byte in a sequence the acknowledge bit NACK (1), + * otherwise ACK (0) will be sent. + */ + +static Bool +I2CGetByte(I2CDevPtr d, I2CByte *data, Bool last) +{ + int i, sda; + I2CBusPtr b = d->pI2CBus; + + b->I2CPutBits(b, 0, 1); + b->I2CUDelay(b, b->RiseFallTime); + + if (!I2CReadBit(b, &sda, d->ByteTimeout)) + return FALSE; + + *data = (sda > 0) << 7; + + for (i = 6; i >= 0; i--) + if (!I2CReadBit(b, &sda, d->BitTimeout)) + return FALSE; + else + *data |= (sda > 0) << i; + + if (!I2CWriteBit(b, last ? 1 : 0, d->BitTimeout)) + return FALSE; + + I2C_TRACE(ErrorF("R%02x%c ", (int) *data, last ? '+' : '-')); + + return TRUE; +} + +/* This is the default I2CAddress function if not supplied by the driver. + * + * It creates the start condition, followed by the d->SlaveAddr. + * Higher level functions must call this routine rather than + * I2CStart/PutByte because a hardware I2C master may not be able + * to send a slave address without a start condition. + * + * The same timeouts apply as with I2CPutByte and additional a + * StartTimeout, similar to the ByteTimeout but for the start + * condition. + * + * In case of a timeout, the bus is left in a clean idle condition. + * I. e. you *must not* send a Stop. If this function succeeds, you *must*. + * + * The slave address format is 16 bit, with the legacy _8_bit_ slave address + * in the least significant byte. This is, the slave address must include the + * R/_W flag as least significant bit. + * + * The most significant byte of the address will be sent _after_ the LSB, + * but only if the LSB indicates: + * a) an 11 bit address, this is LSB = 1111 0xxx. + * b) a 'general call address', this is LSB = 0000 000x - see the I2C specs + * for more. + */ + +static Bool +I2CAddress(I2CDevPtr d, I2CSlaveAddr addr) +{ + if (I2CStart(d->pI2CBus, d->StartTimeout)) { + if (I2CPutByte(d, addr & 0xFF)) { + if ((addr & 0xF8) != 0xF0 && + (addr & 0xFE) != 0x00) + return TRUE; + + if (I2CPutByte(d, (addr >> 8) & 0xFF)) + return TRUE; + } + + I2CStop(d); + } + + return FALSE; +} + +/* These are the hardware independent I2C helper functions. + * ======================================================== + */ + +/* Function for probing. Just send the slave address + * and return true if the device responds. The slave address + * must have the lsb set to reflect a read (1) or write (0) access. + * Don't expect a read- or write-only device will respond otherwise. + */ + +Bool +xf86I2CProbeAddress(I2CBusPtr b, I2CSlaveAddr addr) +{ + int r; + I2CDevRec d; + + d.DevName = "Probing"; + d.BitTimeout = b->BitTimeout; + d.ByteTimeout = b->ByteTimeout; + d.AcknTimeout = b->AcknTimeout; + d.StartTimeout = b->StartTimeout; + d.SlaveAddr = addr; + d.pI2CBus = b; + d.NextDev = NULL; + + r = b->I2CAddress(&d, addr); + + if (r) b->I2CStop(&d); + + return r; +} + +/* All functions below are related to devices and take the + * slave address and timeout values from an I2CDevRec. They + * return FALSE in case of an error (presumably a timeout). + */ + +/* General purpose read and write function. + * + * 1st, if nWrite > 0 + * Send a start condition + * Send the slave address (1 or 2 bytes) with write flag + * Write n bytes from WriteBuffer + * 2nd, if nRead > 0 + * Send a start condition [again] + * Send the slave address (1 or 2 bytes) with read flag + * Read n bytes to ReadBuffer + * 3rd, if a Start condition has been successfully sent, + * Send a Stop condition. + * + * The functions exits immediately when an error occures, + * not proceeding any data left. However, step 3 will + * be executed anyway to leave the bus in clean idle state. + */ + +static Bool +I2CWriteRead(I2CDevPtr d, + I2CByte *WriteBuffer, int nWrite, + I2CByte *ReadBuffer, int nRead) +{ + Bool r = TRUE; + I2CBusPtr b = d->pI2CBus; + int s = 0; + + if (r && nWrite > 0) { + r = b->I2CAddress(d, d->SlaveAddr & ~1); + if (r) { + for (; nWrite > 0; WriteBuffer++, nWrite--) + if (!(r = b->I2CPutByte(d, *WriteBuffer))) + break; + s++; + } + } + + if (r && nRead > 0) { + r = b->I2CAddress(d, d->SlaveAddr | 1); + if (r) { + for (; nRead > 0; ReadBuffer++, nRead--) + if (!(r = b->I2CGetByte(d, ReadBuffer, nRead == 1))) + break; + s++; + } + } + + if (s) b->I2CStop(d); + + return r; +} + +/* wrapper - for compatibility and convinience */ + +Bool +xf86I2CWriteRead(I2CDevPtr d, + I2CByte *WriteBuffer, int nWrite, + I2CByte *ReadBuffer, int nRead) +{ + I2CBusPtr b = d->pI2CBus; + return b->I2CWriteRead(d,WriteBuffer,nWrite,ReadBuffer,nRead); +} + +/* Read a byte, the only readable register of a device. + */ + +Bool +xf86I2CReadStatus(I2CDevPtr d, I2CByte *pbyte) +{ + return xf86I2CWriteRead(d, NULL, 0, pbyte, 1); +} + +/* Read a byte from one of the registers determined by its sub-address. + */ + +Bool +xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte) +{ + return xf86I2CWriteRead(d, &subaddr, 1, pbyte, 1); +} + +/* Read bytes from subsequent registers determined by the + * sub-address of the first register. + */ + +Bool +xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte, int n) +{ + return xf86I2CWriteRead(d, &subaddr, 1, pbyte, n); +} + +/* Read a word (high byte, then low byte) from one of the registers + * determined by its sub-address. + */ + +Bool +xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword) +{ + I2CByte rb[2]; + + if (!xf86I2CWriteRead(d, &subaddr, 1, rb, 2)) return FALSE; + + *pword = (rb[0] << 8) | rb[1]; + + return TRUE; +} + +/* Write a byte to one of the registers determined by its sub-address. + */ + +Bool +xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte) +{ + I2CByte wb[2]; + + wb[0] = subaddr; + wb[1] = byte; + + return xf86I2CWriteRead(d, wb, 2, NULL, 0); +} + +/* Write bytes to subsequent registers determined by the + * sub-address of the first register. + */ + +Bool +xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr, + I2CByte *WriteBuffer, int nWrite) +{ + I2CBusPtr b = d->pI2CBus; + Bool r = TRUE; + + if (nWrite > 0) { + r = b->I2CAddress(d, d->SlaveAddr & ~1); + if (r){ + if ((r = b->I2CPutByte(d, subaddr))) + for (; nWrite > 0; WriteBuffer++, nWrite--) + if (!(r = b->I2CPutByte(d, *WriteBuffer))) + break; + + b->I2CStop(d); + } + } + + return r; +} + +/* Write a word (high byte, then low byte) to one of the registers + * determined by its sub-address. + */ + +Bool +xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word) +{ + I2CByte wb[3]; + + wb[0] = subaddr; + wb[1] = word >> 8; + wb[2] = word & 0xFF; + + return xf86I2CWriteRead(d, wb, 3, NULL, 0); +} + +/* Write a vector of bytes to not adjacent registers. This vector is, + * 1st byte sub-address, 2nd byte value, 3rd byte sub-address asf. + * This function is intended to initialize devices. Note this function + * exits immediately when an error occurs, some registers may + * remain uninitialized. + */ + +Bool +xf86I2CWriteVec(I2CDevPtr d, I2CByte *vec, int nValues) +{ + I2CBusPtr b = d->pI2CBus; + Bool r = TRUE; + int s = 0; + + if (nValues > 0) { + for (; nValues > 0; nValues--, vec += 2) { + if (!(r = b->I2CAddress(d, d->SlaveAddr & ~1))) + break; + + s++; + + if (!(r = b->I2CPutByte(d, vec[0]))) + break; + + if (!(r = b->I2CPutByte(d, vec[1]))) + break; + } + + if (s > 0) b->I2CStop(d); + } + + return r; +} + +/* Administrative functions. + * ========================= + */ + +/* Allocates an I2CDevRec for you and initializes with propper defaults + * you may modify before calling xf86I2CDevInit. Your I2CDevRec must + * contain at least a SlaveAddr, and a pI2CBus pointer to the bus this + * device shall be linked to. + * + * See function I2CAddress for the slave address format. Always set + * the least significant bit, indicating a read or write access, to zero. + */ + +I2CDevPtr +xf86CreateI2CDevRec(void) +{ + return xcalloc(1, sizeof(I2CDevRec)); +} + +/* Unlink an I2C device. If you got the I2CDevRec from xf86CreateI2CDevRec + * you should set <unalloc> to free it. + */ + +void +xf86DestroyI2CDevRec(I2CDevPtr d, Bool unalloc) +{ + if (d) { + I2CDevPtr *p; + + /* Remove this from the list of active I2C devices. */ + + for (p = &d->pI2CBus->FirstDev; *p != NULL; p = &(*p)->NextDev) + if (*p == d) { + *p = (*p)->NextDev; + break; + } + + xf86DrvMsg(d->pI2CBus->scrnIndex, X_INFO, + "I2C device \"%s:%s\" removed.\n", + d->pI2CBus->BusName, d->DevName); + + if (unalloc) xfree(d); + } +} + +/* I2C transmissions are related to an I2CDevRec you must link to a + * previously registered bus (see xf86I2CBusInit) before attempting + * to read and write data. You may call xf86I2CProbeAddress first to + * see if the device in question is present on this bus. + * + * xf86I2CDevInit will not allocate an I2CBusRec for you, instead you + * may enter a pointer to a statically allocated I2CDevRec or the (modified) + * result of xf86CreateI2CDevRec. + * + * If you don't specify timeouts for the device (n <= 0), it will inherit + * the bus-wide defaults. The function returns TRUE on success. + */ + +Bool +xf86I2CDevInit(I2CDevPtr d) +{ + I2CBusPtr b; + + if (d == NULL || + (b = d->pI2CBus) == NULL || + (d->SlaveAddr & 1) || + xf86I2CFindDev(b, d->SlaveAddr) != NULL) + return FALSE; + + if (d->BitTimeout <= 0) d->BitTimeout = b->BitTimeout; + if (d->ByteTimeout <= 0) d->ByteTimeout = b->ByteTimeout; + if (d->AcknTimeout <= 0) d->AcknTimeout = b->AcknTimeout; + if (d->StartTimeout <= 0) d->StartTimeout = b->StartTimeout; + + d->NextDev = b->FirstDev; + b->FirstDev = d; + + xf86DrvMsg(b->scrnIndex, X_INFO, + "I2C device \"%s:%s\" registered at address 0x%02X.\n", + b->BusName, d->DevName, d->SlaveAddr); + + return TRUE; +} + +I2CDevPtr +xf86I2CFindDev(I2CBusPtr b, I2CSlaveAddr addr) +{ + I2CDevPtr d; + + if (b) { + for (d = b->FirstDev; d != NULL; d = d->NextDev) + if (d->SlaveAddr == addr) + return d; + } + + return NULL; +} + +static I2CBusPtr I2CBusList; + +/* Allocates an I2CBusRec for you and initializes with propper defaults + * you may modify before calling xf86I2CBusInit. Your I2CBusRec must + * contain at least a BusName, a scrnIndex (or -1), and a complete set + * of either high or low level I2C function pointers. You may pass + * bus-wide timeouts, otherwise inplausible values will be replaced + * with safe defaults. + */ + +I2CBusPtr +xf86CreateI2CBusRec(void) +{ + I2CBusPtr b; + + b = (I2CBusPtr) xcalloc(1, sizeof(I2CBusRec)); + + if (b != NULL) { + b->scrnIndex = -1; + b->HoldTime = 5; /* 100 kHz bus */ + b->BitTimeout = 5; + b->ByteTimeout = 5; + b->AcknTimeout = 5; + b->StartTimeout = 5; + b->RiseFallTime = RISEFALLTIME; + } + + return b; +} + +/* Unregister an I2C bus. If you got the I2CBusRec from xf86CreateI2CBusRec + * you should set <unalloc> to free it. If you set <devs_too>, the function + * xf86DestroyI2CDevRec will be called for all devices linked to the bus + * first, passing down the <unalloc> option. + */ + +void +xf86DestroyI2CBusRec(I2CBusPtr b, Bool unalloc, Bool devs_too) +{ + if (b) { + I2CBusPtr *p; + + /* Remove this from the list of active I2C buses */ + + for (p = &I2CBusList; *p != NULL; p = &(*p)->NextBus) + if (*p == b) { + *p = (*p)->NextBus; + break; + } + + if (b->FirstDev != NULL) { + if (devs_too) { + I2CDevPtr d; + + while ((d = b->FirstDev) != NULL) { + b->FirstDev = d->NextDev; + xf86DestroyI2CDevRec(d, unalloc); + } + } else { + if (unalloc) { + xf86Msg(X_ERROR, "i2c bug: Attempt to remove I2C bus \"%s\", " + "but device list is not empty.\n", + b->BusName); + return; + } + } + } + + xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" removed.\n", + b->BusName); + + if (unalloc) xfree(b); + } +} + +/* I2C masters have to register themselves using this function. + * It will not allocate an I2CBusRec for you, instead you may enter + * a pointer to a statically allocated I2CBusRec or the (modified) + * result of xf86CreateI2CBusRec. Returns TRUE on success. + * + * At this point there won't be any traffic on the I2C bus. + */ + +Bool +xf86I2CBusInit(I2CBusPtr b) +{ + /* I2C buses must be identified by a unique scrnIndex + * and name. If scrnIndex is unspecified (a negative value), + * then the name must be unique throughout the server. + */ + + if (b->BusName == NULL || + xf86I2CFindBus(b->scrnIndex, b->BusName) != NULL) + return FALSE; + + /* If the high level functions are not + * supplied, use the generic functions. + * In this case we need the low-level + * function. + */ + if (b->I2CWriteRead == NULL) + { + b->I2CWriteRead=I2CWriteRead; + + if (b->I2CPutBits == NULL || + b->I2CGetBits == NULL) + { + if (b->I2CPutByte == NULL || + b->I2CGetByte == NULL || + b->I2CAddress == NULL || + b->I2CStart == NULL || + b->I2CStop == NULL) + return FALSE; + } else { + b->I2CPutByte = I2CPutByte; + b->I2CGetByte = I2CGetByte; + b->I2CAddress = I2CAddress; + b->I2CStop = I2CStop; + b->I2CStart = I2CStart; + } + } + + if (b->I2CUDelay == NULL) + b->I2CUDelay = I2CUDelay; + + if (b->HoldTime < 2) b->HoldTime = 5; + if (b->BitTimeout <= 0) b->BitTimeout = b->HoldTime; + if (b->ByteTimeout <= 0) b->ByteTimeout = b->HoldTime; + if (b->AcknTimeout <= 0) b->AcknTimeout = b->HoldTime; + if (b->StartTimeout <= 0) b->StartTimeout = b->HoldTime; + + /* Put new bus on list. */ + + b->NextBus = I2CBusList; + I2CBusList = b; + + xf86DrvMsg(b->scrnIndex, X_INFO, "I2C bus \"%s\" initialized.\n", + b->BusName); + + return TRUE; +} + +I2CBusPtr +xf86I2CFindBus(int scrnIndex, char *name) +{ + I2CBusPtr p; + + if (name != NULL) + for (p = I2CBusList; p != NULL; p = p->NextBus) + if (scrnIndex < 0 || p->scrnIndex == scrnIndex) + if (!strcmp(p->BusName, name)) + return p; + + return NULL; +} + +/* + * Return an array of I2CBusPtr's related to a screen. The caller is + * responsible for freeing the array. + */ +int +xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr **pppI2CBus) +{ + I2CBusPtr pI2CBus; + int n = 0; + + if (pppI2CBus) + *pppI2CBus = NULL; + + for (pI2CBus = I2CBusList; pI2CBus; pI2CBus = pI2CBus->NextBus) { + if ((pI2CBus->scrnIndex >= 0) && (pI2CBus->scrnIndex != scrnIndex)) + continue; + + n++; + + if (!pppI2CBus) + continue; + + *pppI2CBus = xnfrealloc(*pppI2CBus, n * sizeof(I2CBusPtr)); + (*pppI2CBus)[n - 1] = pI2CBus; + } + + return n; +} diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.h b/xorg-server/hw/xfree86/i2c/xf86i2c.h new file mode 100644 index 000000000..76d2ebf92 --- /dev/null +++ b/xorg-server/hw/xfree86/i2c/xf86i2c.h @@ -0,0 +1,96 @@ +/* + * Copyright (C) 1998 Itai Nahshon, Michael Schimek + */ + + +#ifndef _XF86I2C_H +#define _XF86I2C_H + +#include "regionstr.h" + +typedef unsigned char I2CByte; +typedef unsigned short I2CSlaveAddr; + +typedef struct _I2CBusRec *I2CBusPtr; +typedef struct _I2CDevRec *I2CDevPtr; + +/* I2C masters have to register themselves */ + +typedef struct _I2CBusRec { + char * BusName; + int scrnIndex; + + void (*I2CUDelay) (I2CBusPtr b, int usec); + + void (*I2CPutBits)(I2CBusPtr b, int scl, int sda); + void (*I2CGetBits)(I2CBusPtr b, int *scl, int *sda); + + /* Look at the generic routines to see how these functions should behave. */ + + Bool (*I2CStart) (I2CBusPtr b, int timeout); + Bool (*I2CAddress)(I2CDevPtr d, I2CSlaveAddr); + void (*I2CStop) (I2CDevPtr d); + Bool (*I2CPutByte)(I2CDevPtr d, I2CByte data); + Bool (*I2CGetByte)(I2CDevPtr d, I2CByte *data, Bool); + + DevUnion DriverPrivate; + + int HoldTime; /* 1 / bus clock frequency, 5 or 2 usec */ + + int BitTimeout; /* usec */ + int ByteTimeout; /* usec */ + int AcknTimeout; /* usec */ + int StartTimeout; /* usec */ + int RiseFallTime; /* usec */ + + I2CDevPtr FirstDev; + I2CBusPtr NextBus; + Bool (*I2CWriteRead)(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite, + I2CByte *ReadBuffer, int nRead); +} I2CBusRec; + +I2CBusPtr xf86CreateI2CBusRec(void); +void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc, Bool devs_too); +Bool xf86I2CBusInit(I2CBusPtr pI2CBus); +I2CBusPtr xf86I2CFindBus(int scrnIndex, char *name); +int xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr **pppI2CBus); + + +/* I2C slave devices */ + +typedef struct _I2CDevRec { + char * DevName; + + int BitTimeout; /* usec */ + int ByteTimeout; /* usec */ + int AcknTimeout; /* usec */ + int StartTimeout; /* usec */ + + I2CSlaveAddr SlaveAddr; + I2CBusPtr pI2CBus; + I2CDevPtr NextDev; + DevUnion DriverPrivate; +} I2CDevRec; + +I2CDevPtr xf86CreateI2CDevRec(void); +void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev, Bool unalloc); +Bool xf86I2CDevInit(I2CDevPtr pI2CDev); +I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr); + +/* See descriptions of these functions in xf86i2c.c */ + +Bool xf86I2CProbeAddress(I2CBusPtr pI2CBus, I2CSlaveAddr); +Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite, + I2CByte *ReadBuffer, int nRead); +#define xf86I2CRead(d, rb, nr) xf86I2CWriteRead(d, NULL, 0, rb, nr) +Bool xf86I2CReadStatus(I2CDevPtr d, I2CByte *pbyte); +Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte); +Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte, int n); +Bool xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword); +#define xf86I2CWrite(d, wb, nw) xf86I2CWriteRead(d, wb, nw, NULL, 0) +Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte); +Bool xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *WriteBuffer, int nWrite); +Bool xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word); +Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte *vec, int nValues); + +#endif /*_XF86I2C_H */ diff --git a/xorg-server/hw/xfree86/int10/INT10.HOWTO b/xorg-server/hw/xfree86/int10/INT10.HOWTO new file mode 100644 index 000000000..e2154c1c3 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/INT10.HOWTO @@ -0,0 +1,344 @@ + + INT10 X86 Real Mode executor + ============================= + + PRELIMINARY + +INT10 is a XFree86 module for soft-booting and executing real mode +int10 BIOS calls. The BIOS call code is largely untested, yet. + +1. Usage +======== + +To use the int10 module in a driver the header file +xfree86/os-support/int10/xf86int10.h must be included. + + a. Initialization + ----------------- + +The int10-executer gets initialized by calling: + + xf86Int10InfoPtr xf86InitInt10(int entityIndex); + +The function will soft-boot any non-primary device and return a +pointer to a xf86Int10InfoRec on success. If anything fails or if +int10 execution is disabled by an option in the device section NULL +will be returned. The driver should store this pointer for later +calls to other int10 module functions. + + b. Memory allocation + -------------------- + +To allocate memory in the real mode execution environment + + void * xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off); + +can be called. It allocates num consecutive pagesize chunks. It +returns the address of the allocated area. off is set to its offset in +the real mode memory space. + + void xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num); + +Is used to free num pages beginning at pbase. + + c. Doing int10 BIOS calls + ------------------------- + +The BIOS call is executed by calling: + + void xf86ExecX86int10(xf86Int10InfoPtr pInt); + +The number of the interrupt (normally 10) and the initial values of +the ax, bx, cx, dx, si, di and es x86-CPU registers can be set in the +xf86Int10InfoRec passed to the function. On return this structure +contains the exit values of the registers listed above and the CPU +flag register. + + d. De-initializing + ----------------- + +If no further int10 calls are required for a certain chipset +the driver should call: + + void xf86FreeInt10(xf86Int10InfoPtr pInt); + +to free the memory allocated for real mode int10 calls. + + +2. Porting issues +================= + +The int10 real mode executor is designed to run on top of various x86 +CPU emulators as well as in vm86 mode of a real x86 CPU. If used with +a CPU emulator the emulator and CPU specific interfaces can be held +separate thus requiring minimal efforts to port the int10 module to +new platforms. Currently an interface to the x86emu real mode +emulator is provided. Since details of setting up and running the +vm86 mode is platform dependent both the platform dependent +environment and the emulation layer have to be ported. Several helper +functions are provided for that. + +A CPU emulator should meet certain requirements to be usable +for the INT10 executor: + +1. It must trap calls to intXX instructions and pass execution to an + external function which is allowed to modify CPU registers + including the instruction pointer (IP) before returning to the + emulator for continuing execution. When the external function is + called the IP must point to the instruction past the intXX call. + +2. The emulator should use externally provided functions to handle + PIO. + +3. The emulator should be able to use externally provided functions + to access memory from the real mode memory environment. Note, that + the vm86 mode usually requires one hunk of consecutive memory + starting at address 0 in the process virtual memory space. Thus if + this mode is to be used, the OS environment has to be able to provide + that, ie. it must be able to remap the processes virtual memory space + onto itself. If the emulator is able to handle memory access thru + externally provided functions the real mode process memory can be + located anywhere in the processes virtual memory. It does not even + have to be consecutive. + +4. The executor should terminate on encountering a 'hlt' instruction. + + +Functions to implement: + +To simplify development the code has been split into a general setup +part and an emulator specific one. A generic setup code is provided in +generic.c. It should be usable with any emulator satisfying the +conditions mentioned above. Therefore the following section on int10 +setup may be skipped when porting int10 to new emulator. + +If the vm86() is to be used no memory access functions can be used. +Therefore the layout of the real mode memory image has to meet certain +requirements. Therefore when porting to other platforms a new setup +code may have to be designed, too. The following section will give +guidelines how this may be done. A sample implementation using SysV +IPC to map the appropriate real mode memory image to address 0 in +virtual address space just prior to execution may be found in +xfree86/os-support/linux/int10/linux.c. + +On non-PC like platforms emulation of certain PC features such as +initialization of BIOS int vectors, sys_BIOS constants or PCI config +method 1 can be turned on by defining _PC. + +I. Setup Code +------------- + +This sets up the real mode memory image, calls the emulator to POST +the chipset if required and maintains memory allocations in real mode +address space. + +1. xf86Int10InfoPtr xf86InitInt10(int entityIndex); + +This function should first find the screen assigned to the entity +carrying entitiyIndex and then call + + Bool int10skip(ScrnInfoPtr pScrn) + +to find out if the user has requested not to initialize int10. If so +xf86InitInt10() should return NULL. Otherwise an xf86Int10InfoRec +should be allocated. This structure contains the following fields: + + a. int entityIndex - index of the entity whose BIOS is to be + executed. + b. int scrnIndex - index of the screen assigned the entity. + c. pointer cpuRegs - pointer to a emulator/vm86-mode private + structure. May hold cpu register values + for the emulator. + d. CARD16 BIOSseg - Video BIOS segment address. + e. pointer private - pointer to a os specific data structure. + f. struct _int10Mem* - pointer to a structure to hold the memory + access functions for use by an emulator. + g. int num - number of the int to be called. + h. int ax..es,flags - CPU register values to pass to int-call. + +The Init function should initialize a-f. To initialize the emulator +specific execute environment the function + + Bool xf86Int10ExecSetup(xf86Int10InfoPtr pInt) + +should be called. If this function returns FALSE any already allocated +memory should be freed and xf86Int10Init(0 should exit returning NULL. + +If the platform has a PC like system BIOS it may be copied to or +mapped into memory locations SYS_BIOS to SYS_SIZE-1 of the real mode +memory environment of this process. Otherwise the helper function: + +int setup_system_bios(CARD32 base_addr); + +may be called to set up a rudimentary system BIOS sufficient to be +used to boot video BIOSes. base_addr specifies the virtual address +corresponding to SYS_BIOS in the real mode environment. If a PC-like +int vector and BIOS data area is available it should be copied to 0 to +LOW_PAGE_SIZE of the entities real mode environment. In this case the +video interrupt related entries should be reset for all non-primary +cards by calling: + +void reset_int_vect(xf86Int10InfoPtr pInt); To initialize the + +correct video BIOS entry points the BIOS must be warm-booted. If no +PC-like int vector is available one can be set up by calling + +void setup_int_vect(xf86Int10InfoPtr pInt); + +In this case the video BIOS has to be warm-booted always. If the +video BIOS for this entity has been installed during boot it may be +mapped (or copied) directly to the correct address in the real mode +memory environment. Otherwise + +int mapPciRom(xf86Int10InfoPtr pInt, unsigned char * address); + +should be called to copy the BIOS image from PCI ROM. 'address' +specifies the address this image should be copied to. Sufficient space +to hold an entire BIOS image should be allocated prior to calling +mapPciRom(). This function will return the size of the BIOS image in +bytes if it was able to successfully copy the image and 0 +otherwise. To create a well defined point to exit the softbooter + +void set_return_trap(xf86Int10Ptr pInt); + +may be called. It sets up a 'hlt' instruction in the emulator memory +just above the BIOS variable area. Before entering real mode execution +this address will be pushed onto the return stack. If the BIOS needs +to be warm-booted this should be done before leaving xf86InitInt10() +by setting num in the xf86Int10InfoRec to 0xe6 and calling + +void xf86ExecX86int10(xf86Int10IfoPtr pInt); + +The implementation of this function will be discussed below. This +function should be wrapped by calls to void LockLegacyVGA(screen, +legacyVGAPtr vga); and void UnlockLegacyVGA(screen, legacyVGAPtr vga); +The struct vga is used to hold the state of the legacy VGA access +registers if a legacy VGA device exists. xf86InitInt10() should +return a pointer to the xf86Int10InfoRec allocated. + +2. Bool MapCurrentInt10(xf86Int10InfoPtr pInt); + +In case a platform specific mapping has to be performed to map the +memory allocated for the real mode memory environment into a specific +location prior to executing the x86 real mode code a function + + Bool MapCurrentInt10(xf86Int10InfoPtr pInt); + +has to be provided. It will be called by a helper function whenever +the active entity changes. If the vm86 mode is used it is most likely +that the 1MB real mode memory space located somewhere in the processes +virtual memory will have to be remapped to address 0 of the virtual +memory space. + +3. void xf86FreeInt10(xf86Int10InfoPtr pInt); + +To free all memory allocated for video BIOS calls of a specific entity +the function + + void xf86FreeInt10(xf86Int10InfoPtr pInt); + +should be provided. If the entity to be freed was mapped by +MapCurrentInt10() this mapping needs to be undone also. + +4. + void * xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off) + void xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num) + +xf86Int10AllocPages() should allocate 'num' consecutive page-size +chunks of memory. In real mode memory space this range needs to occupy +consecutive addresses, too. The function must return the address of +this memory. The offset in real mode memory needs to be returned in +'off'. If no block of 'num' pages are available the function should +return NULL. + +xf86Int10FreePages() will free the 'num' pages starting at 'pbase'. +'num' is equal to the number of pages allocated by a single +xf86Int10AllocatePages() call. 'pbase' is the address of the range +previously returned by xf86Int10AllocatePages(). + +II. Emulator specific functions +------------------------------- + +1. Bool xf86Int10ExecSetup(xf86Int10InfoPtr pInt); + +This function will be called from xf86InitInt10(). It may be used to +set up the static emulator specific part of the real mode +environment. On success it should return TRUE. + +2. xf86ExecX86int10(xf86Int10InfoPtr pInt); + +This function gets called to execute an int call. It may call the +helper function: + + void setup_int(xf86Int10InfoPrt pInt); + +to copy the register values to the emulator specific locations and to +set up the non-static real mode execution environment. On return from +setup_int() 'Int10Current' holds a pointer to the current +xf86Int10InfoRec. + +It should start execution by calling + + Bool int_handler(xf86Int10InfoPtr pInt); + +and if this function returns TRUE it should call whatever necessary to +continue execution until a 'hlt' instruction is encountered. To copy +the resulting register values back to the xf86Int10InfoRec structure + + void finish_int(xf86Int10InfoPtr pInt); + +should be called. + +Helper functions are provided to aid the implementation of a vm86 +call: + + Bool vm86_GP_fault(xf86Int10InfoPtr pInt); + +This function handles instructions which cause a vm86 call to +trap. PIO access is handled by the in/out calls as defined in +compiler.h. Optionally the PIO instructions can be logged by defining +PRINT_PORT in xf86int10.h. This is meant for debugging purposes. + +Unknown instructions and 'hlt' cause vm86_GP_fault() to return +FALSE. Otherwise TRUE is returned. + +Note: This function is currently based on the Linux vm86 call. It +might have to be modified or even rewritten for other OS. So your +milage may vary. + +Functions to dump memory, code, xf86 CPU register values and stack are +also provided. Take a look at helper.c To view a memory range the +function + + void dprint(unsigned long start, unsigned long size) + +is provided. The use should be self explanatory. + +Register and memory access functions are provided in helper_mem.c. +The PIO register access functions can trap access to PCI config space +access register (config method 1) if _PC is not defined. + +A header file 'defines.h' is required to define OS/emulator specific +ways to access memory and xf86 CPU registers: Defines need to be +provided for memory byte/work/long read/write access +(MEM_RB(name,addr),MEM_RW(name,addr),MEM_RL(name,addr), +MEM_WB(name,addr,val),MEM_WL(name,addr,val),MEM_WL(name,addr,val)) of +the real mode memory environment. 'name' will contain a pointer to the +current xf86Int10InfoRec. Currently defines are available for +vm86-mode under Linux and x86emu. They may be activated by defining +_X86EMU or _VM86_LINUX respectively. + +Note: Emulators usually are not able to pass this pointer when calling +memory access functions. In this case a global variable should be +defined which can hold this pointer. This variable can be set in +MapCurrentInt10(). It also must be set in xf86InitInt10() if this +function calls the memory access functions either directly or by +calling xf86ExecX86int10(pInt). Defines to access the emulator +specific xf86 CPU register locations are also required: +X86_EAX,...,X86_EFLAGS for access of the full 32 bit registers, +X86_AX...X86_FLAGS for access of the 16 bit registers and +XF86_AL,XF86_BL,XF86_CL,XF86_DL to access the lower byte of the +AX,BX,CX and DX register. + + +$XFree86: xc/programs/Xserver/hw/xfree86/int10/INT10.HOWTO,v 1.2 2000/02/08 13:13:22 eich Exp $ diff --git a/xorg-server/hw/xfree86/int10/Makefile.am b/xorg-server/hw/xfree86/int10/Makefile.am new file mode 100644 index 000000000..78bef2515 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/Makefile.am @@ -0,0 +1,44 @@ +module_LTLIBRARIES = libint10.la + +sdk_HEADERS = xf86int10.h + +EXTRA_CFLAGS = + +libint10_la_LDFLAGS = -avoid-version + +COMMON_SOURCES = \ + helper_exec.c \ + helper_mem.c \ + xf86int10.c \ + xf86int10module.c + +if I386_VIDEO +I386_VIDEO_CFLAGS = -D_PC +endif + +if INT10_VM86 +AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) +INCLUDES = $(XORG_INCS) +libint10_la_SOURCES = \ + $(COMMON_SOURCES) \ + $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c \ + $(srcdir)/../os-support/linux/int10/linux.c +endif + +if INT10_X86EMU +AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_X86EMU -DNO_SYS_HEADERS \ + $(XORG_CFLAGS) $(EXTRA_CFLAGS) $(DIX_CFLAGS) +INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu +libint10_la_SOURCES = \ + $(COMMON_SOURCES) \ + xf86x86emu.c \ + generic.c \ + x86emu.c +endif + +if INT10_STUB +AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) +libint10_la_SOURCES = stub.c xf86int10module.c +endif + +EXTRA_DIST = xf86x86emu.h INT10.HOWTO diff --git a/xorg-server/hw/xfree86/int10/Makefile.in b/xorg-server/hw/xfree86/int10/Makefile.in new file mode 100644 index 000000000..c0f829260 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/Makefile.in @@ -0,0 +1,762 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/int10 +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libint10_la_LIBADD = +am__libint10_la_SOURCES_DIST = stub.c xf86int10module.c helper_exec.c \ + helper_mem.c xf86int10.c \ + $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c \ + $(srcdir)/../os-support/linux/int10/linux.c xf86x86emu.c \ + generic.c x86emu.c +am__objects_1 = helper_exec.lo helper_mem.lo xf86int10.lo \ + xf86int10module.lo +@INT10_STUB_FALSE@@INT10_VM86_FALSE@@INT10_X86EMU_TRUE@am_libint10_la_OBJECTS = $(am__objects_1) \ +@INT10_STUB_FALSE@@INT10_VM86_FALSE@@INT10_X86EMU_TRUE@ xf86x86emu.lo \ +@INT10_STUB_FALSE@@INT10_VM86_FALSE@@INT10_X86EMU_TRUE@ generic.lo \ +@INT10_STUB_FALSE@@INT10_VM86_FALSE@@INT10_X86EMU_TRUE@ x86emu.lo +@INT10_STUB_FALSE@@INT10_VM86_TRUE@am_libint10_la_OBJECTS = \ +@INT10_STUB_FALSE@@INT10_VM86_TRUE@ $(am__objects_1) \ +@INT10_STUB_FALSE@@INT10_VM86_TRUE@ linux_vm86.lo linux.lo +@INT10_STUB_TRUE@am_libint10_la_OBJECTS = stub.lo xf86int10module.lo +libint10_la_OBJECTS = $(am_libint10_la_OBJECTS) +libint10_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libint10_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libint10_la_SOURCES) +DIST_SOURCES = $(am__libint10_la_SOURCES_DIST) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libint10.la +sdk_HEADERS = xf86int10.h +EXTRA_CFLAGS = +libint10_la_LDFLAGS = -avoid-version +COMMON_SOURCES = \ + helper_exec.c \ + helper_mem.c \ + xf86int10.c \ + xf86int10module.c + +@I386_VIDEO_TRUE@I386_VIDEO_CFLAGS = -D_PC +@INT10_STUB_TRUE@AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) +@INT10_VM86_TRUE@AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS) +@INT10_X86EMU_TRUE@AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_X86EMU -DNO_SYS_HEADERS \ +@INT10_X86EMU_TRUE@ $(XORG_CFLAGS) $(EXTRA_CFLAGS) $(DIX_CFLAGS) + +@INT10_VM86_TRUE@INCLUDES = $(XORG_INCS) +@INT10_X86EMU_TRUE@INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu +@INT10_STUB_TRUE@libint10_la_SOURCES = stub.c xf86int10module.c +@INT10_VM86_TRUE@libint10_la_SOURCES = \ +@INT10_VM86_TRUE@ $(COMMON_SOURCES) \ +@INT10_VM86_TRUE@ $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c \ +@INT10_VM86_TRUE@ $(srcdir)/../os-support/linux/int10/linux.c + +@INT10_X86EMU_TRUE@libint10_la_SOURCES = \ +@INT10_X86EMU_TRUE@ $(COMMON_SOURCES) \ +@INT10_X86EMU_TRUE@ xf86x86emu.c \ +@INT10_X86EMU_TRUE@ generic.c \ +@INT10_X86EMU_TRUE@ x86emu.c + +EXTRA_DIST = xf86x86emu.h INT10.HOWTO +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/int10/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/int10/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libint10.la: $(libint10_la_OBJECTS) $(libint10_la_DEPENDENCIES) + $(libint10_la_LINK) -rpath $(moduledir) $(libint10_la_OBJECTS) $(libint10_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/generic.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helper_exec.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helper_mem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux_vm86.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stub.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86emu.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86int10.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86int10module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86x86emu.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +linux_vm86.lo: $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT linux_vm86.lo -MD -MP -MF $(DEPDIR)/linux_vm86.Tpo -c -o linux_vm86.lo `test -f '$(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c' || echo '$(srcdir)/'`$(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/linux_vm86.Tpo $(DEPDIR)/linux_vm86.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c' object='linux_vm86.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o linux_vm86.lo `test -f '$(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c' || echo '$(srcdir)/'`$(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c + +linux.lo: $(srcdir)/../os-support/linux/int10/linux.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT linux.lo -MD -MP -MF $(DEPDIR)/linux.Tpo -c -o linux.lo `test -f '$(srcdir)/../os-support/linux/int10/linux.c' || echo '$(srcdir)/'`$(srcdir)/../os-support/linux/int10/linux.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/linux.Tpo $(DEPDIR)/linux.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../os-support/linux/int10/linux.c' object='linux.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o linux.lo `test -f '$(srcdir)/../os-support/linux/int10/linux.c' || echo '$(srcdir)/'`$(srcdir)/../os-support/linux/int10/linux.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/int10/generic.c b/xorg-server/hw/xfree86/int10/generic.c new file mode 100644 index 000000000..a30dee103 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/generic.c @@ -0,0 +1,506 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> +#include <unistd.h> + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "xf86int10.h" +#include "int10Defines.h" +#include "Pci.h" + +#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1) + +static CARD8 read_b(xf86Int10InfoPtr pInt,int addr); +static CARD16 read_w(xf86Int10InfoPtr pInt,int addr); +static CARD32 read_l(xf86Int10InfoPtr pInt,int addr); +static void write_b(xf86Int10InfoPtr pInt,int addr, CARD8 val); +static void write_w(xf86Int10InfoPtr pInt,int addr, CARD16 val); +static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val); + +/* + * the emulator cannot pass a pointer to the current xf86Int10InfoRec + * to the memory access functions therefore store it here. + */ + +typedef struct { + int shift; + int entries; + void* base; + void* vRam; + int highMemory; + void* sysMem; + char* alloc; +} genericInt10Priv; + +#define INTPriv(x) ((genericInt10Priv*)x->private) + +int10MemRec genericMem = { + read_b, + read_w, + read_l, + write_b, + write_w, + write_l +}; + +static void MapVRam(xf86Int10InfoPtr pInt); +static void UnmapVRam(xf86Int10InfoPtr pInt); +#ifdef _PC +#define GET_HIGH_BASE(x) (((V_BIOS + (x) + getpagesize() - 1)/getpagesize()) \ + * getpagesize()) +#endif + +static void *sysMem = NULL; + +/** + * Read legacy VGA video BIOS associated with specified domain. + * + * Attempts to read up to 128KiB of legacy VGA video BIOS. + * + * \return + * The number of bytes read on success or -1 on failure. + * + * \bug + * PCI ROMs can contain multiple BIOS images (e.g., OpenFirmware, x86 VGA, + * etc.). How do we know that \c pci_device_read_rom will return the + * legacy VGA BIOS image? + */ +static int +read_legacy_video_BIOS(struct pci_device *dev, unsigned char *Buf) +{ + const ADDRESS Base = 0xC0000; + const int Len = 0x10000 * 2; + const int pagemask = getpagesize() - 1; + const ADDRESS offset = Base & ~pagemask; + const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset; + unsigned char *ptr, *src; + int len; + + + /* Try to use the civilized PCI interface first. + */ + if (pci_device_read_rom(dev, Buf) == 0) { + return dev->rom_size; + } + + ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, dev, offset, size); + + if (!ptr) + return -1; + + /* Using memcpy() here can hang the system */ + src = ptr + (Base - offset); + for (len = 0; len < (Len / 2); len++) { + Buf[len] = src[len]; + } + + if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) { + for ( /* empty */ ; len < Len; len++) { + Buf[len] = src[len]; + } + } + + xf86UnMapVidMem(-1, ptr, size); + + return Len; +} + + +xf86Int10InfoPtr +xf86ExtendedInitInt10(int entityIndex, int Flags) +{ + xf86Int10InfoPtr pInt; + void* base = 0; + void* vbiosMem = 0; + void* options = NULL; + int screen; + legacyVGARec vga; + +#ifdef _PC + int size; + CARD32 cs; +#endif + + screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex; + + options = xf86HandleInt10Options(xf86Screens[screen],entityIndex); + + if (int10skip(options)) { + xfree(options); + return NULL; + } + + pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec)); + pInt->entityIndex = entityIndex; + if (!xf86Int10ExecSetup(pInt)) + goto error0; + pInt->mem = &genericMem; + pInt->private = (pointer)xnfcalloc(1, sizeof(genericInt10Priv)); + INTPriv(pInt)->alloc = (pointer)xnfcalloc(1, ALLOC_ENTRIES(getpagesize())); + pInt->scrnIndex = screen; + base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS); + + /* FIXME: Shouldn't this be a failure case? Leaving dev as NULL seems like + * FIXME: an error + */ + pInt->dev = xf86GetPciInfoForEntity(entityIndex); + + /* + * we need to map video RAM MMIO as some chipsets map mmio + * registers into this range. + */ + MapVRam(pInt); +#ifdef _PC + if (!sysMem) + sysMem = xf86MapVidMem(screen, VIDMEM_MMIO, V_BIOS, + BIOS_SIZE + SYS_BIOS - V_BIOS); + INTPriv(pInt)->sysMem = sysMem; + + if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) { + xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n"); + goto error1; + } + + /* + * Retrieve everything between V_BIOS and SYS_BIOS as some system BIOSes + * have executable code there. Note that xf86ReadBIOS() can only read in + * 64kB at a time. + */ + (void)memset((char *)base + V_BIOS, 0, SYS_BIOS - V_BIOS); +#if 0 + for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE) + if (xf86ReadBIOS(cs, 0, (unsigned char *)base + cs, V_BIOS_SIZE) < + V_BIOS_SIZE) + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x%06X.\n", cs); +#endif + INTPriv(pInt)->highMemory = V_BIOS; + + if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) { + if (!xf86int10GetBiosSegment(pInt, (unsigned char *)sysMem - V_BIOS)) + goto error1; + + set_return_trap(pInt); + + pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH); + if (! (pInt->Flags & SET_BIOS_SCRATCH)) + pInt->Flags &= ~RESTORE_BIOS_SCRATCH; + xf86Int10SaveRestoreBIOSVars(pInt, TRUE); + + } else { + const BusType location_type = xf86int10GetBiosLocationType(pInt); + int bios_location = V_BIOS; + + reset_int_vect(pInt); + set_return_trap(pInt); + + switch (location_type) { + case BUS_PCI: { + int err; + struct pci_device *rom_device = + xf86GetPciInfoForEntity(pInt->entityIndex); + + vbiosMem = (unsigned char *)base + bios_location; + err = pci_device_read_rom(rom_device, vbiosMem); + if (err) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3) %s\n", + strerror(err)); + goto error1; + } + INTPriv(pInt)->highMemory = GET_HIGH_BASE(rom_device->rom_size); + break; + } + case BUS_ISA: + vbiosMem = (unsigned char *)sysMem + bios_location; +#if 0 + (void)memset(vbiosMem, 0, V_BIOS_SIZE); + if (xf86ReadBIOS(bios_location, 0, vbiosMem, V_BIOS_SIZE) + < V_BIOS_SIZE) + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x%x.\n",bios_location); +#endif + if (!int10_check_bios(screen, bios_location >> 4, vbiosMem)) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (4)\n"); + goto error1; + } + default: + goto error1; + } + pInt->BIOSseg = V_BIOS >> 4; + pInt->num = 0xe6; + LockLegacyVGA(pInt, &vga); + xf86ExecX86int10(pInt); + UnlockLegacyVGA(pInt, &vga); + } +#else + if (!sysMem) { + sysMem = xnfalloc(BIOS_SIZE); + setup_system_bios(sysMem); + } + INTPriv(pInt)->sysMem = sysMem; + setup_int_vect(pInt); + set_return_trap(pInt); + + /* Retrieve the entire legacy video BIOS segment. This can be upto + * 128KiB. + */ + vbiosMem = (char *)base + V_BIOS; + (void)memset(vbiosMem, 0, 2 * V_BIOS_SIZE); + if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) { + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x0C0000.\n"); + } + + /* + * If this adapter is the primary, use its post-init BIOS (if we can find + * it). + */ + { + int bios_location = V_BIOS; + Bool done = FALSE; + vbiosMem = (unsigned char *)base + bios_location; + + if (xf86IsEntityPrimary(entityIndex)) { + if (int10_check_bios(screen, bios_location >> 4, vbiosMem)) + done = TRUE; + else + xf86DrvMsg(screen,X_INFO, + "No legacy BIOS found -- trying PCI\n"); + } + if (!done) { + int err; + struct pci_device *rom_device = + xf86GetPciInfoForEntity(pInt->entityIndex); + + err = pci_device_read_rom(rom_device, vbiosMem); + if (err) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (5) %s\n", + strerror(err)); + goto error1; + } + } + } + + pInt->BIOSseg = V_BIOS >> 4; + pInt->num = 0xe6; + LockLegacyVGA(pInt, &vga); + xf86ExecX86int10(pInt); + UnlockLegacyVGA(pInt, &vga); +#endif + xfree(options); + return pInt; + + error1: + xfree(base); + UnmapVRam(pInt); + xfree(INTPriv(pInt)->alloc); + xfree(pInt->private); + error0: + xfree(pInt); + xfree(options); + + return NULL; +} + +static void +MapVRam(xf86Int10InfoPtr pInt) +{ + int pagesize = getpagesize(); + int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize; + + INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO, + pInt->dev, V_RAM, size); + + pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase; +} + +static void +UnmapVRam(xf86Int10InfoPtr pInt) +{ + int screen = pInt->scrnIndex; + int pagesize = getpagesize(); + int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize; + + xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size); +} + +Bool +MapCurrentInt10(xf86Int10InfoPtr pInt) +{ + /* nothing to do here */ + return TRUE; +} + +void +xf86FreeInt10(xf86Int10InfoPtr pInt) +{ + if (!pInt) + return; +#if defined (_PC) + xf86Int10SaveRestoreBIOSVars(pInt, FALSE); +#endif + if (Int10Current == pInt) + Int10Current = NULL; + xfree(INTPriv(pInt)->base); + UnmapVRam(pInt); + xfree(INTPriv(pInt)->alloc); + xfree(pInt->private); + xfree(pInt); +} + +void * +xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off) +{ + int pagesize = getpagesize(); + int num_pages = ALLOC_ENTRIES(pagesize); + int i,j; + + for (i = 0; i < (num_pages - num); i++) { + if (INTPriv(pInt)->alloc[i] == 0) { + for (j = i; j < (num + i); j++) + if (INTPriv(pInt)->alloc[j] != 0) + break; + if (j == (num + i)) + break; + i += num; + } + } + if (i == (num_pages - num)) + return NULL; + + for (j = i; j < (i + num); j++) + INTPriv(pInt)->alloc[j] = 1; + + *off = (i + 1) * pagesize; + + return (char *)INTPriv(pInt)->base + *off; +} + +void +xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num) +{ + int pagesize = getpagesize(); + int first = (((char *)pbase - (char *)INTPriv(pInt)->base) / pagesize) - 1; + int i; + + for (i = first; i < (first + num); i++) + INTPriv(pInt)->alloc[i] = 0; +} + +#define OFF(addr) ((addr) & 0xffff) +#if defined _PC +# define HIGH_OFFSET (INTPriv(pInt)->highMemory) +# define HIGH_BASE V_BIOS +#else +# define HIGH_OFFSET SYS_BIOS +# define HIGH_BASE SYS_BIOS +#endif +# define SYS(addr) ((addr) >= HIGH_OFFSET) +#define V_ADDR(addr) \ + (SYS(addr) ? ((char*)INTPriv(pInt)->sysMem) + (addr - HIGH_BASE) \ + : (((char*)(INTPriv(pInt)->base) + addr))) +#define VRAM_ADDR(addr) (addr - V_RAM) +#define VRAM_BASE (INTPriv(pInt)->vRam) + +#define VRAM(addr) ((addr >= V_RAM) && (addr < (V_RAM + VRAM_SIZE))) +#define V_ADDR_RB(addr) \ + (VRAM(addr)) ? MMIO_IN8((CARD8*)VRAM_BASE,VRAM_ADDR(addr)) \ + : *(CARD8*) V_ADDR(addr) +#define V_ADDR_RW(addr) \ + (VRAM(addr)) ? MMIO_IN16((CARD16*)VRAM_BASE,VRAM_ADDR(addr)) \ + : ldw_u((pointer)V_ADDR(addr)) +#define V_ADDR_RL(addr) \ + (VRAM(addr)) ? MMIO_IN32((CARD32*)VRAM_BASE,VRAM_ADDR(addr)) \ + : ldl_u((pointer)V_ADDR(addr)) + +#define V_ADDR_WB(addr,val) \ + if(VRAM(addr)) \ + MMIO_OUT8((CARD8*)VRAM_BASE,VRAM_ADDR(addr),val); \ + else \ + *(CARD8*) V_ADDR(addr) = val; +#define V_ADDR_WW(addr,val) \ + if(VRAM(addr)) \ + MMIO_OUT16((CARD16*)VRAM_BASE,VRAM_ADDR(addr),val); \ + else \ + stw_u((val),(pointer)(V_ADDR(addr))); + +#define V_ADDR_WL(addr,val) \ + if (VRAM(addr)) \ + MMIO_OUT32((CARD32*)VRAM_BASE,VRAM_ADDR(addr),val); \ + else \ + stl_u(val,(pointer)(V_ADDR(addr))); + +static CARD8 +read_b(xf86Int10InfoPtr pInt, int addr) +{ + return V_ADDR_RB(addr); +} + +static CARD16 +read_w(xf86Int10InfoPtr pInt, int addr) +{ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + if (OFF(addr + 1) > 0) + return V_ADDR_RW(addr); +#endif + return V_ADDR_RB(addr) | (V_ADDR_RB(addr + 1) << 8); +} + +static CARD32 +read_l(xf86Int10InfoPtr pInt, int addr) +{ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + if (OFF(addr + 3) > 2) + return V_ADDR_RL(addr); +#endif + return V_ADDR_RB(addr) | + (V_ADDR_RB(addr + 1) << 8) | + (V_ADDR_RB(addr + 2) << 16) | + (V_ADDR_RB(addr + 3) << 24); +} + +static void +write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val) +{ + V_ADDR_WB(addr,val); +} + +static void +write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val) +{ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + if (OFF(addr + 1) > 0) + { V_ADDR_WW(addr, val); } +#endif + V_ADDR_WB(addr, val); + V_ADDR_WB(addr + 1, val >> 8); +} + +static void +write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val) +{ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + if (OFF(addr + 3) > 2) + { V_ADDR_WL(addr, val); } +#endif + V_ADDR_WB(addr, val); + V_ADDR_WB(addr + 1, val >> 8); + V_ADDR_WB(addr + 2, val >> 16); + V_ADDR_WB(addr + 3, val >> 24); +} + +pointer +xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr) +{ + return V_ADDR(addr); +} diff --git a/xorg-server/hw/xfree86/int10/helper_exec.c b/xorg-server/hw/xfree86/int10/helper_exec.c new file mode 100644 index 000000000..15eba4928 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/helper_exec.c @@ -0,0 +1,729 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + * + * Part of this code was inspired by the VBIOS POSTing code in DOSEMU + * developed by the "DOSEMU-Development-Team" + */ + +/* + * To debug port accesses define PRINT_PORT to 1. + * Note! You also have to comment out ioperm() + * in xf86EnableIO(). Otherwise we won't trap + * on PIO. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#define PRINT_PORT 0 + +#include <unistd.h> + +#include <X11/Xos.h> +#include "xf86.h" +#include "xf86_OSproc.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "int10Defines.h" +#include "xf86int10.h" +#include "Pci.h" +#ifdef _X86EMU +#include "x86emu/x86emui.h" +#endif +#include <pciaccess.h> + +static int pciCfg1in(CARD16 addr, CARD32 *val); +static int pciCfg1out(CARD16 addr, CARD32 val); +static int pciCfg1inw(CARD16 addr, CARD16 *val); +static int pciCfg1outw(CARD16 addr, CARD16 val); +static int pciCfg1inb(CARD16 addr, CARD8 *val); +static int pciCfg1outb(CARD16 addr, CARD8 val); +#if defined (_PC) +static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set); +#endif + +#define REG pInt + +int +setup_int(xf86Int10InfoPtr pInt) +{ + if (pInt != Int10Current) { + if (!MapCurrentInt10(pInt)) + return -1; + Int10Current = pInt; + } + X86_EAX = (CARD32) pInt->ax; + X86_EBX = (CARD32) pInt->bx; + X86_ECX = (CARD32) pInt->cx; + X86_EDX = (CARD32) pInt->dx; + X86_ESI = (CARD32) pInt->si; + X86_EDI = (CARD32) pInt->di; + X86_EBP = (CARD32) pInt->bp; + X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4; + X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */ + X86_DS = 0x40; /* standard pc ds */ + X86_ES = pInt->es; + X86_FS = 0; + X86_GS = 0; + X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK; +#if defined (_PC) + if (pInt->Flags & SET_BIOS_SCRATCH) + SetResetBIOSVars(pInt, TRUE); +#endif + return xf86BlockSIGIO(); +} + +void +finish_int(xf86Int10InfoPtr pInt, int sig) +{ + xf86UnblockSIGIO(sig); + pInt->ax = (CARD32) X86_EAX; + pInt->bx = (CARD32) X86_EBX; + pInt->cx = (CARD32) X86_ECX; + pInt->dx = (CARD32) X86_EDX; + pInt->si = (CARD32) X86_ESI; + pInt->di = (CARD32) X86_EDI; + pInt->es = (CARD16) X86_ES; + pInt->bp = (CARD32) X86_EBP; + pInt->flags = (CARD32) X86_FLAGS; +#if defined (_PC) + if (pInt->Flags & RESTORE_BIOS_SCRATCH) + SetResetBIOSVars(pInt, FALSE); +#endif +} + +/* general software interrupt handler */ +CARD32 +getIntVect(xf86Int10InfoPtr pInt,int num) +{ + return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4); +} + +void +pushw(xf86Int10InfoPtr pInt, CARD16 val) +{ + X86_ESP -= 2; + MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val); +} + +int +run_bios_int(int num, xf86Int10InfoPtr pInt) +{ + CARD32 eflags; +#ifndef _PC + /* check if bios vector is initialized */ + if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/ + + if (num == 21 && X86_AH == 0x4e) { + xf86DrvMsg(pInt->scrnIndex, X_NOTICE, + "Failing Find-Matching-File on non-PC" + " (int 21, func 4e)\n"); + X86_AX = 2; + SET_FLAG(F_CF); + return 1; + } else { + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "Ignoring int 0x%02x call\n", num); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + return 1; + } + } +#endif +#ifdef PRINT_INT + ErrorF("calling card BIOS at: "); +#endif + eflags = X86_EFLAGS; +#if 0 + eflags = eflags | IF_MASK; + X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK); +#endif + pushw(pInt, eflags); + pushw(pInt, X86_CS); + pushw(pInt, X86_IP); + X86_CS = MEM_RW(pInt, (num << 2) + 2); + X86_IP = MEM_RW(pInt, num << 2); +#ifdef PRINT_INT + ErrorF("0x%x:%lx\n", X86_CS, X86_EIP); +#endif + return 1; +} + +/* Debugging stuff */ +void +dump_code(xf86Int10InfoPtr pInt) +{ + int i; + unsigned long lina = SEG_ADR((CARD32), X86_CS, IP); + + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, "code at 0x%8.8lx:\n", lina); + for (i=0; i<0x10; i++) + xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i)); + xf86ErrorFVerb(3, "\n"); + for (; i<0x20; i++) + xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i)); + xf86ErrorFVerb(3, "\n"); +} + +void +dump_registers(xf86Int10InfoPtr pInt) +{ + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "EAX=0x%8.8lx, EBX=0x%8.8lx, ECX=0x%8.8lx, EDX=0x%8.8lx\n", + (unsigned long)X86_EAX, (unsigned long)X86_EBX, + (unsigned long)X86_ECX, (unsigned long)X86_EDX); + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "ESP=0x%8.8lx, EBP=0x%8.8lx, ESI=0x%8.8lx, EDI=0x%8.8lx\n", + (unsigned long)X86_ESP, (unsigned long)X86_EBP, + (unsigned long)X86_ESI, (unsigned long)X86_EDI); + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "CS=0x%4.4x, SS=0x%4.4x," + " DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n", + X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS); + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "EIP=0x%8.8lx, EFLAGS=0x%8.8lx\n", + (unsigned long)X86_EIP, (unsigned long)X86_EFLAGS); +} + +void +stack_trace(xf86Int10InfoPtr pInt) +{ + int i = 0; + unsigned long stack = SEG_ADR((CARD32), X86_SS, SP); + unsigned long tail = (CARD32)((X86_SS << 4) + 0x1000); + + if (stack >= tail) return; + + xf86MsgVerb(X_INFO, 3, "stack at 0x%8.8lx:\n", stack); + for (; stack < tail; stack++) { + xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, stack)); + i = (i + 1) % 0x10; + if (!i) + xf86ErrorFVerb(3, "\n"); + } + if (i) + xf86ErrorFVerb(3, "\n"); +} + +int +port_rep_inb(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -1 : 1; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_insb(%#x) %d bytes at %8.8x %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + MEM_WB(pInt, dst, x_inb(port)); + dst += inc; + } + return dst - base; +} + +int +port_rep_inw(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -2 : 2; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_insw(%#x) %d bytes at %8.8x %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + MEM_WW(pInt, dst, x_inw(port)); + dst += inc; + } + return dst - base; +} + +int +port_rep_inl(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -4 : 4; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_insl(%#x) %d bytes at %8.8x %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + MEM_WL(pInt, dst, x_inl(port)); + dst += inc; + } + return dst - base; +} + +int +port_rep_outb(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -1 : 1; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_outb(%#x) %d bytes at %8.8x %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + x_outb(port, MEM_RB(pInt, dst)); + dst += inc; + } + return dst - base; +} + +int +port_rep_outw(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -2 : 2; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_outw(%#x) %d bytes at %8.8x %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + x_outw(port, MEM_RW(pInt, dst)); + dst += inc; + } + return dst - base; +} + +int +port_rep_outl(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -4 : 4; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_outl(%#x) %d bytes at %8.8x %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + x_outl(port, MEM_RL(pInt, dst)); + dst += inc; + } + return dst - base; +} + +CARD8 +x_inb(CARD16 port) +{ + CARD8 val; + + if (port == 0x40) { + Int10Current->inb40time++; + val = (CARD8)(Int10Current->inb40time >> + ((Int10Current->inb40time & 1) << 3)); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inb(%#x) = %2.2x\n", port, val); +#ifdef __NOT_YET__ + } else if (port < 0x0100) { /* Don't interfere with mainboard */ + val = 0; + xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2, + "inb 0x%4.4x\n", port); + if (xf86GetVerbosity() > 3) { + dump_registers(Int10Current); + stack_trace(Int10Current); + } +#endif /* __NOT_YET__ */ + } else if (!pciCfg1inb(port, &val)) { + val = inb(Int10Current->ioBase + port); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inb(%#x) = %2.2x\n", port, val); + } + return val; +} + +CARD16 +x_inw(CARD16 port) +{ + CARD16 val; + + if (port == 0x5c) { + struct timeval tv; + + /* + * Emulate a PC98's timer. Typical resolution is 3.26 usec. + * Approximate this by dividing by 3. + */ + X_GETTIMEOFDAY(&tv); + val = (CARD16)(tv.tv_usec / 3); + } else if (!pciCfg1inw(port, &val)) { + val = inw(Int10Current->ioBase + port); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inw(%#x) = %4.4x\n", port, val); + } + return val; +} + +void +x_outb(CARD16 port, CARD8 val) +{ + if ((port == 0x43) && (val == 0)) { + struct timeval tv; + /* + * Emulate a PC's timer 0. Such timers typically have a resolution of + * some .838 usec per tick, but this can only provide 1 usec per tick. + * (Not that this matters much, given inherent emulation delays.) Use + * the bottom bit as a byte select. See inb(0x40) above. + */ + X_GETTIMEOFDAY(&tv); + Int10Current->inb40time = (CARD16)(tv.tv_usec | 1); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outb(%#x, %2.2x)\n", port, val); +#ifdef __NOT_YET__ + } else if (port < 0x0100) { /* Don't interfere with mainboard */ + xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2, + "outb 0x%4.4x,0x%2.2x\n", port, val); + if (xf86GetVerbosity() > 3) { + dump_registers(Int10Current); + stack_trace(Int10Current); + } +#endif /* __NOT_YET__ */ + } else if (!pciCfg1outb(port, val)) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outb(%#x, %2.2x)\n", port, val); + outb(Int10Current->ioBase + port, val); + } +} + +void +x_outw(CARD16 port, CARD16 val) +{ + + if (!pciCfg1outw(port, val)) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outw(%#x, %4.4x)\n", port, val); + outw(Int10Current->ioBase + port, val); + } +} + +CARD32 +x_inl(CARD16 port) +{ + CARD32 val; + + if (!pciCfg1in(port, &val)) { + val = inl(Int10Current->ioBase + port); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inl(%#x) = %8.8x\n", port, val); + } + return val; +} + +void +x_outl(CARD16 port, CARD32 val) +{ + if (!pciCfg1out(port, val)) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outl(%#x, %8.8x)\n", port, val); + outl(Int10Current->ioBase + port, val); + } +} + +CARD8 +Mem_rb(CARD32 addr) +{ + return (*Int10Current->mem->rb)(Int10Current, addr); +} + +CARD16 +Mem_rw(CARD32 addr) +{ + return (*Int10Current->mem->rw)(Int10Current, addr); +} + +CARD32 +Mem_rl(CARD32 addr) +{ + return (*Int10Current->mem->rl)(Int10Current, addr); +} + +void +Mem_wb(CARD32 addr, CARD8 val) +{ + (*Int10Current->mem->wb)(Int10Current, addr, val); +} + +void +Mem_ww(CARD32 addr, CARD16 val) +{ + (*Int10Current->mem->ww)(Int10Current, addr, val); +} + +void +Mem_wl(CARD32 addr, CARD32 val) +{ + (*Int10Current->mem->wl)(Int10Current, addr, val); +} + +static CARD32 PciCfg1Addr = 0; + +#define PCI_OFFSET(x) ((x) & 0x000000ff) +#define PCI_TAG(x) ((x) & 0x7fffff00) + +static struct pci_device* +pci_device_for_cfg_address (CARD32 addr) +{ + struct pci_device *dev = NULL; + PCITAG tag = PCI_TAG(addr); + struct pci_slot_match slot_match = { + .domain = PCI_DOM_FROM_TAG(tag), + .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)), + .dev = PCI_DEV_FROM_TAG(tag), + .func = PCI_FUNC_FROM_TAG(tag), + .match_data = 0 + }; + + struct pci_device_iterator *iter = + pci_slot_match_iterator_create (&slot_match); + + if (iter) + dev = pci_device_next(iter); + + pci_iterator_destroy(iter); + + return dev; +} + +static int +pciCfg1in(CARD16 addr, CARD32 *val) +{ + if (addr == 0xCF8) { + *val = PciCfg1Addr; + return 1; + } + if (addr == 0xCFC) { + pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr)); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_inl(%#x) = %8.8x\n", PciCfg1Addr, *val); + return 1; + } + return 0; +} + +static int +pciCfg1out(CARD16 addr, CARD32 val) +{ + if (addr == 0xCF8) { + PciCfg1Addr = val; + return 1; + } + if (addr == 0xCFC) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_outl(%#x, %8.8x)\n", PciCfg1Addr, val); + pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr)); + return 1; + } + return 0; +} + +static int +pciCfg1inw(CARD16 addr, CARD16 *val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + *val = (PciCfg1Addr >> shift) & 0xffff; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_inw(%#x) = %4.4x\n", PciCfg1Addr + offset, *val); + return 1; + } + return 0; +} + +static int +pciCfg1outw(CARD16 addr, CARD16 val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + PciCfg1Addr &= ~(0xffff << shift); + PciCfg1Addr |= ((CARD32) val) << shift; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_outw(%#x, %4.4x)\n", PciCfg1Addr + offset, val); + pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + return 1; + } + return 0; +} + +static int +pciCfg1inb(CARD16 addr, CARD8 *val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + *val = (PciCfg1Addr >> shift) & 0xff; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_inb(%#x) = %2.2x\n", PciCfg1Addr + offset, *val); + return 1; + } + return 0; +} + +static int +pciCfg1outb(CARD16 addr, CARD8 val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + PciCfg1Addr &= ~(0xff << shift); + PciCfg1Addr |= ((CARD32) val) << shift; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_outb(%#x, %2.2x)\n", PciCfg1Addr + offset, val); + pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + return 1; + } + return 0; +} + +CARD8 +bios_checksum(const CARD8 *start, int size) +{ + CARD8 sum = 0; + + while (size-- > 0) + sum += *start++; + return sum; +} + +/* + * Lock/Unlock legacy VGA. Some Bioses try to be very clever and make + * an attempt to detect a legacy ISA card. If they find one they might + * act very strange: for example they might configure the card as a + * monochrome card. This might cause some drivers to choke. + * To avoid this we attempt legacy VGA by writing to all know VGA + * disable registers before we call the BIOS initialization and + * restore the original values afterwards. In beween we hold our + * breath. To get to a (possibly exising) ISA card need to disable + * our current PCI card. + */ +/* + * This is just for booting: we just want to catch pure + * legacy vga therefore we don't worry about mmio etc. + * This stuff should really go into vgaHW.c. However then + * the driver would have to load the vga-module prior to + * doing int10. + */ +void +LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) +{ + xf86SetCurrentAccess(FALSE, xf86Screens[pInt->scrnIndex]); + vga->save_msr = inb(pInt->ioBase + 0x03CC); + vga->save_vse = inb(pInt->ioBase + 0x03C3); +#ifndef __ia64__ + vga->save_46e8 = inb(pInt->ioBase + 0x46E8); +#endif + vga->save_pos102 = inb(pInt->ioBase + 0x0102); + outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr); + outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse); +#ifndef __ia64__ + outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8); +#endif + outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102); + xf86SetCurrentAccess(TRUE, xf86Screens[pInt->scrnIndex]); +} + +void +UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) +{ + xf86SetCurrentAccess(FALSE, xf86Screens[pInt->scrnIndex]); + outb(pInt->ioBase + 0x0102, vga->save_pos102); +#ifndef __ia64__ + outb(pInt->ioBase + 0x46E8, vga->save_46e8); +#endif + outb(pInt->ioBase + 0x03C3, vga->save_vse); + outb(pInt->ioBase + 0x03C2, vga->save_msr); + xf86SetCurrentAccess(TRUE, xf86Screens[pInt->scrnIndex]); +} + +#if defined (_PC) +static void +SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set) +{ + int pagesize = getpagesize(); + unsigned char* base = xf86MapVidMem(pInt->scrnIndex, + VIDMEM_MMIO, 0, pagesize); + int i; + + if (set) { + for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++) + MEM_WW(pInt, i, *(base + i)); + } else { + for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++) + *(base + i) = MEM_RW(pInt, i); + } + + xf86UnMapVidMem(pInt->scrnIndex,base,pagesize); +} + +void +xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save) +{ + int pagesize = getpagesize(); + unsigned char* base; + int i; + + if (!xf86IsEntityPrimary(pInt->entityIndex) + || (!save && !pInt->BIOSScratch)) + return; + + base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize); + base += BIOS_SCRATCH_OFF; + if (save) { + if ((pInt->BIOSScratch + = xnfalloc(BIOS_SCRATCH_LEN))) + for (i = 0; i < BIOS_SCRATCH_LEN; i++) + *(((char*)pInt->BIOSScratch + i)) = *(base + i); + } else { + if (pInt->BIOSScratch) { + for (i = 0; i < BIOS_SCRATCH_LEN; i++) + *(base + i) = *(pInt->BIOSScratch + i); + xfree(pInt->BIOSScratch); + pInt->BIOSScratch = NULL; + } + } + + xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize); +} +#endif + +xf86Int10InfoPtr +xf86InitInt10(int entityIndex) +{ + return xf86ExtendedInitInt10(entityIndex, 0); +} diff --git a/xorg-server/hw/xfree86/int10/helper_mem.c b/xorg-server/hw/xfree86/int10/helper_mem.c new file mode 100644 index 000000000..b59f47358 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/helper_mem.c @@ -0,0 +1,330 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> +#include <stdlib.h> + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "compiler.h" +#include "xf86Pci.h" +#define _INT10_PRIVATE +#if 0 +#include "int10Defines.h" +#endif +#include "xf86int10.h" + +#define REG pInt + +typedef enum { + OPT_NOINT10, + OPT_INIT_PRIMARY, +} INT10Opts; + +static const OptionInfoRec INT10Options[] = { + {OPT_NOINT10, "NoINT10", OPTV_BOOLEAN, {0}, FALSE }, + {OPT_INIT_PRIMARY, "InitPrimary", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE }, +}; + +#ifdef DEBUG +void +dprint(unsigned long start, unsigned long size) +{ + int i,j; + char *c = (char *)start; + + for (j = 0; j < (size >> 4); j++) { + char *d = c; + ErrorF("\n0x%lx: ",(unsigned long)c); + for (i = 0; i<16; i++) + ErrorF("%2.2x ",(unsigned char) (*(c++))); + c = d; + for (i = 0; i<16; i++) { + ErrorF("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ? + (unsigned char) (*(c)): '.'); + c++; + } + } + ErrorF("\n"); +} +#endif + +#ifndef _PC +/* + * here we are really paranoid about faking a "real" + * BIOS. Most of this information was pulled from + * dosemu. + */ +void +setup_int_vect(xf86Int10InfoPtr pInt) +{ + int i; + + /* let the int vects point to the SYS_BIOS seg */ + for (i = 0; i < 0x80; i++) { + MEM_WW(pInt, i << 2, 0); + MEM_WW(pInt, (i << 2) + 2, SYS_BIOS >> 4); + } + + reset_int_vect(pInt); + /* font tables default location (int 1F) */ + MEM_WW(pInt,0x1f<<2,0xfa6e); + + /* int 11 default location (Get Equipment Configuration) */ + MEM_WW(pInt, 0x11 << 2, 0xf84d); + /* int 12 default location (Get Conventional Memory Size) */ + MEM_WW(pInt, 0x12 << 2, 0xf841); + /* int 15 default location (I/O System Extensions) */ + MEM_WW(pInt, 0x15 << 2, 0xf859); + /* int 1A default location (RTC, PCI and others) */ + MEM_WW(pInt, 0x1a << 2, 0xff6e); + /* int 05 default location (Bound Exceeded) */ + MEM_WW(pInt, 0x05 << 2, 0xff54); + /* int 08 default location (Double Fault) */ + MEM_WW(pInt, 0x08 << 2, 0xfea5); + /* int 13 default location (Disk) */ + MEM_WW(pInt, 0x13 << 2, 0xec59); + /* int 0E default location (Page Fault) */ + MEM_WW(pInt, 0x0e << 2, 0xef57); + /* int 17 default location (Parallel Port) */ + MEM_WW(pInt, 0x17 << 2, 0xefd2); + /* fdd table default location (int 1e) */ + MEM_WW(pInt, 0x1e << 2, 0xefc7); + + /* Set Equipment flag to VGA */ + i = MEM_RB(pInt, 0x0410) & 0xCF; + MEM_WB(pInt, 0x0410, i); + /* XXX Perhaps setup more of the BDA here. See also int42(0x00). */ +} +#endif + +int +setup_system_bios(void *base_addr) +{ + char *base = (char *) base_addr; + + /* + * we trap the "industry standard entry points" to the BIOS + * and all other locations by filling them with "hlt" + * TODO: implement hlt-handler for these + */ + memset(base, 0xf4, 0x10000); + + /* set bios date */ + strcpy(base + 0x0FFF5, "06/11/99"); + /* set up eisa ident string */ + strcpy(base + 0x0FFD9, "PCI_ISA"); + /* write system model id for IBM-AT */ + *((unsigned char *)(base + 0x0FFFE)) = 0xfc; + + return 1; +} + +void +reset_int_vect(xf86Int10InfoPtr pInt) +{ + /* + * This table is normally located at 0xF000:0xF0A4. However, int 0x42, + * function 0 (Mode Set) expects it (or a copy) somewhere in the bottom + * 64kB. Note that because this data doesn't survive POST, int 0x42 should + * only be used during EGA/VGA BIOS initialisation. + */ + static const CARD8 VideoParms[] = { + /* Timing for modes 0x00 & 0x01 */ + 0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c, + 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, + /* Timing for modes 0x02 & 0x03 */ + 0x71, 0x50, 0x5a, 0x0a, 0x1f, 0x06, 0x19, 0x1c, + 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, + /* Timing for modes 0x04, 0x05 & 0x06 */ + 0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70, + 0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, + /* Timing for mode 0x07 */ + 0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19, + 0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00, + /* Display page lengths in little endian order */ + 0x00, 0x08, /* Modes 0x00 and 0x01 */ + 0x00, 0x10, /* Modes 0x02 and 0x03 */ + 0x00, 0x40, /* Modes 0x04 and 0x05 */ + 0x00, 0x40, /* Modes 0x06 and 0x07 */ + /* Number of columns for each mode */ + 40, 40, 80, 80, 40, 40, 80, 80, + /* CGA Mode register value for each mode */ + 0x2c, 0x28, 0x2d, 0x29, 0x2a, 0x2e, 0x1e, 0x29, + /* Padding */ + 0x00, 0x00, 0x00, 0x00 + }; + int i; + + for (i = 0; i < sizeof(VideoParms); i++) + MEM_WB(pInt, i + (0x1000 - sizeof(VideoParms)), VideoParms[i]); + MEM_WW(pInt, 0x1d << 2, 0x1000 - sizeof(VideoParms)); + MEM_WW(pInt, (0x1d << 2) + 2, 0); + + MEM_WW(pInt, 0x10 << 2, 0xf065); + MEM_WW(pInt, (0x10 << 2) + 2, SYS_BIOS >> 4); + MEM_WW(pInt, 0x42 << 2, 0xf065); + MEM_WW(pInt, (0x42 << 2) + 2, SYS_BIOS >> 4); + MEM_WW(pInt, 0x6D << 2, 0xf065); + MEM_WW(pInt, (0x6D << 2) + 2, SYS_BIOS >> 4); +} + +void +set_return_trap(xf86Int10InfoPtr pInt) +{ + /* + * Here we set the exit condition: We return when we encounter + * 'hlt' (=0xf4), which we locate at address 0x600 in x86 memory. + */ + MEM_WB(pInt, 0x0600, 0xf4); + + /* + * Allocate a segment for the stack + */ + xf86Int10AllocPages(pInt, 1, &pInt->stackseg); +} + +void * +xf86HandleInt10Options(ScrnInfoPtr pScrn, int entityIndex) +{ + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + OptionInfoPtr options = NULL; + + if (pEnt->device) { + pointer configOptions = NULL; + + /* Check if xf86CollectOptions() has already been called */ + if (((pEnt->index < 0) || + !pScrn || + !(configOptions = pScrn->options)) && + pEnt->device) + configOptions = pEnt->device->options; + + if (configOptions) { + if (!(options = (OptionInfoPtr) xalloc(sizeof(INT10Options)))) + return NULL; + + (void)memcpy(options, INT10Options, sizeof(INT10Options)); + xf86ProcessOptions(pScrn->scrnIndex, configOptions, options); + } + } + xfree(pEnt); + + return options; +} + +Bool +int10skip(const void* options) +{ + Bool noint10 = FALSE; + + if (!options) return FALSE; + + xf86GetOptValBool(options, OPT_NOINT10, &noint10); + return noint10; +} + +Bool +int10_check_bios(int scrnIndex, int codeSeg, const unsigned char* vbiosMem) +{ + int size; + + if ((codeSeg & 0x1f) || /* Not 512-byte aligned otherwise */ + ((codeSeg << 4) < V_BIOS) || + ((codeSeg << 4) >= SYS_SIZE)) + return FALSE; + + if (xf86IsPc98()) + return FALSE; + + if ((*vbiosMem != 0x55) || (*(vbiosMem+1) != 0xAA) || !*(vbiosMem+2)) + return FALSE; + + size = *(vbiosMem + 2) * 512; + + if ((size + (codeSeg << 4)) > SYS_SIZE) + return FALSE; + + if (bios_checksum(vbiosMem, size)) + xf86DrvMsg(scrnIndex, X_WARNING, "Bad V_BIOS checksum\n"); + + return TRUE; +} + +Bool +initPrimary(const void* options) +{ + Bool initPrimary = FALSE; + + if (!options) return FALSE; + + xf86GetOptValBool(options, OPT_INIT_PRIMARY, &initPrimary); + return initPrimary; +} + +BusType +xf86int10GetBiosLocationType(const xf86Int10InfoPtr pInt) +{ + BusType location_type; + + EntityInfoPtr pEnt = xf86GetEntityInfo(pInt->entityIndex); + location_type = pEnt->location.type; + xfree(pEnt); + + return location_type; +} + + +#define CHECK_V_SEGMENT_RANGE(x) \ + if (((x) << 4) < V_BIOS) { \ + xf86DrvMsg(pInt->scrnIndex, X_ERROR, \ + "V_BIOS address 0x%lx out of range\n", \ + (unsigned long)(x) << 4); \ + return FALSE; \ + } + +Bool +xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base) +{ + unsigned i; + int cs = ~0; + int segments[4]; + const char * format; + + segments[0] = MEM_RW(pInt, (0x10 << 2) + 2); + segments[1] = MEM_RW(pInt, (0x42 << 2) + 2); + segments[2] = V_BIOS >> 4; + segments[3] = ~0; + + format = "No V_BIOS found\n"; + + for (i = 0; segments[i] != ~0; i++) { + unsigned char * vbiosMem; + + cs = segments[i]; + + CHECK_V_SEGMENT_RANGE(cs); + vbiosMem = (unsigned char *)base + (cs << 4); + if (int10_check_bios(pInt->scrnIndex, cs, vbiosMem)) { + break; + } + } + + if (segments[i] == ~0) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, format, (unsigned long)cs << 4); + return FALSE; + } + + xf86DrvMsg(pInt->scrnIndex, X_INFO, "Primary V_BIOS segment is: 0x%lx\n", + (unsigned long)cs); + + pInt->BIOSseg = cs; + return TRUE; +} diff --git a/xorg-server/hw/xfree86/int10/stub.c b/xorg-server/hw/xfree86/int10/stub.c new file mode 100644 index 000000000..58b65782c --- /dev/null +++ b/xorg-server/hw/xfree86/int10/stub.c @@ -0,0 +1,69 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86str.h" +#include "xf86_OSproc.h" +#define _INT10_PRIVATE +#include "xf86int10.h" + +xf86Int10InfoPtr +xf86InitInt10(int entityIndex) +{ + return xf86ExtendedInitInt10(entityIndex, 0); +} + +xf86Int10InfoPtr +xf86ExtendedInitInt10(int entityIndex, int Flags) +{ + return NULL; +} + +Bool +MapCurrentInt10(xf86Int10InfoPtr pInt) +{ + return FALSE; +} + +void +xf86FreeInt10(xf86Int10InfoPtr pInt) +{ + return; +} + +void * +xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off) +{ + *off = 0; + return NULL; +} + +void +xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num) +{ + return; +} + +Bool +xf86Int10ExecSetup(xf86Int10InfoPtr pInt) +{ + return FALSE; +} + +void +xf86ExecX86int10(xf86Int10InfoPtr pInt) +{ + return; +} + +pointer +xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr) +{ + return 0; +} diff --git a/xorg-server/hw/xfree86/int10/x86emu.c b/xorg-server/hw/xfree86/int10/x86emu.c new file mode 100644 index 000000000..b3320e5b9 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/x86emu.c @@ -0,0 +1,12 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "debug.c" +#include "decode.c" +#include "fpu.c" +#include "ops.c" +#include "ops2.c" +#include "prim_ops.c" +#include "sys.c" diff --git a/xorg-server/hw/xfree86/int10/xf86int10.c b/xorg-server/hw/xfree86/int10/xf86int10.c new file mode 100644 index 000000000..f50607cfc --- /dev/null +++ b/xorg-server/hw/xfree86/int10/xf86int10.c @@ -0,0 +1,851 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "xf86int10.h" +#include "int10Defines.h" +#include "Pci.h" + +#define REG pInt + +xf86Int10InfoPtr Int10Current = NULL; + +static int int1A_handler(xf86Int10InfoPtr pInt); +#ifndef _PC +static int int42_handler(xf86Int10InfoPtr pInt); +#endif +static int intE6_handler(xf86Int10InfoPtr pInt); +static struct pci_device *findPci(xf86Int10InfoPtr pInt, unsigned short bx); +static CARD32 pciSlotBX( const struct pci_device * pvp ); + +int +int_handler(xf86Int10InfoPtr pInt) +{ + int num = pInt->num; + int ret = 0; + + switch (num) { +#ifndef _PC + case 0x10: + case 0x42: + case 0x6D: + if (getIntVect(pInt, num) == I_S_DEFAULT_INT_VECT) + ret = int42_handler(pInt); + break; +#endif + case 0x1A: + ret = int1A_handler(pInt); + break; + case 0xe6: + ret = intE6_handler(pInt); + break; + default: + break; + } + + if (!ret) + ret = run_bios_int(num, pInt); + + if (!ret) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "Halting on int 0x%2.2x!\n", num); + dump_registers(pInt); + stack_trace(pInt); + } + + return ret; +} + +#ifndef _PC +/* + * This is derived from a number of PC system BIOS'es. The intent here is to + * provide very primitive video support, before an EGA/VGA BIOS installs its + * own interrupt vector. Here, "Ignored" calls should remain so. "Not + * Implemented" denotes functionality that can be implemented should the need + * arise. What are "Not Implemented" throughout are video memory accesses. + * Also, very little input validity checking is done here. + */ +static int +int42_handler(xf86Int10InfoPtr pInt) +{ + switch (X86_AH) { + case 0x00: + /* Set Video Mode */ + /* Enter: AL = video mode number */ + /* Leave: Nothing */ + /* Implemented (except for clearing the screen) */ + { /* Localise */ + IOADDRESS ioport; + int i; + CARD16 int1d, regvals, tmp; + CARD8 mode, cgamode, cgacolour; + + /* + * Ignore all mode numbers but 0x00-0x13. Some systems also ignore + * 0x0B and 0x0C, but don't do that here. + */ + if (X86_AL > 0x13) + break; + + /* + * You didn't think that was really the mode set, did you? There + * are only so many slots in the video parameter table... + */ + mode = X86_AL; + ioport = 0x03D4; + switch (MEM_RB(pInt, 0x0410) & 0x30) { + case 0x30: /* MDA */ + mode = 0x07; /* Force mode to 0x07 */ + ioport = 0x03B4; + break; + case 0x10: /* CGA 40x25 */ + if (mode >= 0x07) + mode = 0x01; + break; + case 0x20: /* CGA 80x25 (MCGA?) */ + if (mode >= 0x07) + mode = 0x03; + break; + case 0x00: /* EGA/VGA */ + if (mode >= 0x07) /* Don't try MDA timings */ + mode = 0x01; /* !?!?! */ + break; + } + + /* Locate data in video parameter table */ + int1d = MEM_RW(pInt, 0x1d << 2); + regvals = ((mode >> 1) << 4) + int1d; + cgacolour = 0x30; + if (mode == 0x06) { + regvals -= 0x10; + cgacolour = 0x3F; + } + + /** Update BIOS Data Area **/ + + /* Video mode */ + MEM_WB(pInt, 0x0449, mode); + + /* Columns */ + tmp = MEM_RB(pInt, mode + int1d + 0x48); + MEM_WW(pInt, 0x044A, tmp); + + /* Page length */ + tmp = MEM_RW(pInt, (mode & 0x06) + int1d + 0x40); + MEM_WW(pInt, 0x044C, tmp); + + /* Start Address */ + MEM_WW(pInt, 0x044E, 0); + + /* Cursor positions, one for each display page */ + for (i = 0x0450; i < 0x0460; i += 2) + MEM_WW(pInt, i, 0); + + /* Cursor start & end scanlines */ + tmp = MEM_RB(pInt, regvals + 0x0B); + MEM_WB(pInt, 0x0460, tmp); + tmp = MEM_RB(pInt, regvals + 0x0A); + MEM_WB(pInt, 0x0461, tmp); + + /* Current display page number */ + MEM_WB(pInt, 0x0462, 0); + + /* CRTC I/O address */ + MEM_WW(pInt, 0x0463, ioport); + + /* CGA Mode register value */ + cgamode = MEM_RB(pInt, mode + int1d + 0x50); + MEM_WB(pInt, 0x0465, cgamode); + + /* CGA Colour register value */ + MEM_WB(pInt, 0x0466, cgacolour); + + /* Rows */ + MEM_WB(pInt, 0x0484, (25 - 1)); + + /* Remap I/O port number into its domain */ + ioport += pInt->ioBase; + + /* Programme the mode */ + outb(ioport + 4, cgamode & 0x37); /* Turn off screen */ + for (i = 0; i < 0x10; i++) { + tmp = MEM_RB(pInt, regvals + i); + outb(ioport, i); + outb(ioport + 1, tmp); + } + outb(ioport + 5, cgacolour); /* Select colour mode */ + outb(ioport + 4, cgamode); /* Turn on screen */ + } + break; + + case 0x01: + /* Set Cursor Type */ + /* Enter: CH = starting line for cursor */ + /* CL = ending line for cursor */ + /* Leave: Nothing */ + /* Implemented */ + { /* Localise */ + IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; + + MEM_WB(pInt, 0x0460, X86_CL); + MEM_WB(pInt, 0x0461, X86_CH); + + outb(ioport, 0x0A); + outb(ioport + 1, X86_CH); + outb(ioport, 0x0B); + outb(ioport + 1, X86_CL); + } + break; + + case 0x02: + /* Set Cursor Position */ + /* Enter: BH = display page number */ + /* DH = row */ + /* DL = column */ + /* Leave: Nothing */ + /* Implemented */ + { /* Localise */ + IOADDRESS ioport; + CARD16 offset; + + MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL); + MEM_WB(pInt, (X86_BH << 1) + 0x0451, X86_DH); + + if (X86_BH != MEM_RB(pInt, 0x0462)) + break; + + offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL; + offset += MEM_RW(pInt, 0x044E) << 1; + + ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; + outb(ioport, 0x0E); + outb(ioport + 1, offset >> 8); + outb(ioport, 0x0F); + outb(ioport + 1, offset & 0xFF); + } + break; + + case 0x03: + /* Get Cursor Position */ + /* Enter: BH = display page number */ + /* Leave: CH = starting line for cursor */ + /* CL = ending line for cursor */ + /* DH = row */ + /* DL = column */ + /* Implemented */ + { /* Localise */ + X86_CL = MEM_RB(pInt, 0x0460); + X86_CH = MEM_RB(pInt, 0x0461); + X86_DL = MEM_RB(pInt, (X86_BH << 1) + 0x0450); + X86_DH = MEM_RB(pInt, (X86_BH << 1) + 0x0451); + } + break; + + case 0x04: + /* Get Light Pen Position */ + /* Enter: Nothing */ + /* Leave: AH = 0x01 (down/triggered) or 0x00 (not) */ + /* BX = pixel column */ + /* CX = pixel row */ + /* DH = character row */ + /* DL = character column */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x04) -- Get Light Pen Position\n", pInt->num); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + X86_AH = X86_BX = X86_CX = X86_DX = 0; + } + break; + + case 0x05: + /* Set Display Page */ + /* Enter: AL = display page number */ + /* Leave: Nothing */ + /* Implemented */ + { /* Localise */ + IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase; + CARD16 start; + CARD8 x, y; + + /* Calculate new start address */ + MEM_WB(pInt, 0x0462, X86_AL); + start = X86_AL * MEM_RW(pInt, 0x044C); + MEM_WW(pInt, 0x044E, start); + start <<= 1; + + /* Update start address */ + outb(ioport, 0x0C); + outb(ioport + 1, start >> 8); + outb(ioport, 0x0D); + outb(ioport + 1, start & 0xFF); + + /* Switch cursor position */ + y = MEM_RB(pInt, (X86_AL << 1) + 0x0450); + x = MEM_RB(pInt, (X86_AL << 1) + 0x0451); + start += (y * MEM_RW(pInt, 0x044A)) + x; + + /* Update cursor position */ + outb(ioport, 0x0E); + outb(ioport + 1, start >> 8); + outb(ioport, 0x0F); + outb(ioport + 1, start & 0xFF); + } + break; + + case 0x06: + /* Initialise or Scroll Window Up */ + /* Enter: AL = lines to scroll up */ + /* BH = attribute for blank */ + /* CH = upper y of window */ + /* CL = left x of window */ + /* DH = lower y of window */ + /* DL = right x of window */ + /* Leave: Nothing */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x06) -- Initialise or Scroll Window Up\n", + pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + " AL=0x%2.2x, BH=0x%2.2x," + " CH=0x%2.2x, CL=0x%2.2x, DH=0x%2.2x, DL=0x%2.2x\n", + X86_AL, X86_BH, X86_CH, X86_CL, X86_DH, X86_DL); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + } + break; + + case 0x07: + /* Initialise or Scroll Window Down */ + /* Enter: AL = lines to scroll down */ + /* BH = attribute for blank */ + /* CH = upper y of window */ + /* CL = left x of window */ + /* DH = lower y of window */ + /* DL = right x of window */ + /* Leave: Nothing */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x07) -- Initialise or Scroll Window Down\n", + pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + " AL=0x%2.2x, BH=0x%2.2x," + " CH=0x%2.2x, CL=0x%2.2x, DH=0x%2.2x, DL=0x%2.2x\n", + X86_AL, X86_BH, X86_CH, X86_CL, X86_DH, X86_DL); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + } + break; + + case 0x08: + /* Read Character and Attribute at Cursor */ + /* Enter: BH = display page number */ + /* Leave: AH = attribute */ + /* AL = character */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x08) -- Read Character and Attribute at" + " Cursor\n", pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + "BH=0x%2.2x\n", X86_BH); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + X86_AX = 0; + } + break; + + case 0x09: + /* Write Character and Attribute at Cursor */ + /* Enter: AL = character */ + /* BH = display page number */ + /* BL = attribute (text) or colour (graphics) */ + /* CX = replication count */ + /* Leave: Nothing */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x09) -- Write Character and Attribute at" + " Cursor\n", pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x\n", + X86_AL, X86_BH, X86_BL, X86_CX); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + } + break; + + case 0x0a: + /* Write Character at Cursor */ + /* Enter: AL = character */ + /* BH = display page number */ + /* BL = colour */ + /* CX = replication count */ + /* Leave: Nothing */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x0A) -- Write Character at Cursor\n", + pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x\n", + X86_AL, X86_BH, X86_BL, X86_CX); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + } + break; + + case 0x0b: + /* Set Palette, Background or Border */ + /* Enter: BH = 0x00 or 0x01 */ + /* BL = colour or palette (respectively) */ + /* Leave: Nothing */ + /* Implemented */ + { /* Localise */ + IOADDRESS ioport = MEM_RW(pInt, 0x0463) + 5 + pInt->ioBase; + CARD8 cgacolour = MEM_RB(pInt, 0x0466); + + if (X86_BH) { + cgacolour &= 0xDF; + cgacolour |= (X86_BL & 0x01) << 5; + } else { + cgacolour &= 0xE0; + cgacolour |= X86_BL & 0x1F; + } + + MEM_WB(pInt, 0x0466, cgacolour); + outb(ioport, cgacolour); + } + break; + + case 0x0c: + /* Write Graphics Pixel */ + /* Enter: AL = pixel value */ + /* BH = display page number */ + /* CX = column */ + /* DX = row */ + /* Leave: Nothing */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x0C) -- Write Graphics Pixel\n", pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + "AL=0x%2.2x, BH=0x%2.2x, CX=0x%4.4x, DX=0x%4.4x\n", + X86_AL, X86_BH, X86_CX, X86_DX); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + } + break; + + case 0x0d: + /* Read Graphics Pixel */ + /* Enter: BH = display page number */ + /* CX = column */ + /* DX = row */ + /* Leave: AL = pixel value */ + /* Not Implemented */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x0D) -- Read Graphics Pixel\n", pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + "BH=0x%2.2x, CX=0x%4.4x, DX=0x%4.4x\n", + X86_BH, X86_CX, X86_DX); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + X86_AL = 0; + } + break; + + case 0x0e: + /* Write Character in Teletype Mode */ + /* Enter: AL = character */ + /* BH = display page number */ + /* BL = foreground colour */ + /* Leave: Nothing */ + /* Not Implemented */ + /* WARNING: Emulation of BEL characters will require */ + /* emulation of RTC and PC speaker I/O. */ + /* Also, this recurses through int 0x10 */ + /* which might or might not have been */ + /* installed yet. */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x0E) -- Write Character in Teletype Mode\n", + pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + "AL=0x%2.2x, BH=0x%2.2x, BL=0x%2.2x\n", + X86_AL, X86_BH, X86_BL); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + } + break; + + case 0x0f: + /* Get Video Mode */ + /* Enter: Nothing */ + /* Leave: AH = number of columns */ + /* AL = video mode number */ + /* BH = display page number */ + /* Implemented */ + { /* Localise */ + X86_AH = MEM_RW(pInt, 0x044A); + X86_AL = MEM_RB(pInt, 0x0449); + X86_BH = MEM_RB(pInt, 0x0462); + } + break; + + case 0x10: + /* Colour Control (subfunction in AL) */ + /* Enter: Various */ + /* Leave: Various */ + /* Ignored */ + break; + + case 0x11: + /* Font Control (subfunction in AL) */ + /* Enter: Various */ + /* Leave: Various */ + /* Ignored */ + break; + + case 0x12: + /* Miscellaneous (subfunction in BL) */ + /* Enter: Various */ + /* Leave: Various */ + /* Ignored. Previous code here optionally allowed */ + /* the enabling and disabling of VGA, but no system */ + /* BIOS I've come across actually implements it. */ + break; + + case 0x13: + /* Write String in Teletype Mode */ + /* Enter: AL = write mode */ + /* BL = attribute (if (AL & 0x02) == 0) */ + /* CX = string length */ + /* DH = row */ + /* DL = column */ + /* ES:BP = string segment:offset */ + /* Leave: Nothing */ + /* Not Implemented */ + /* WARNING: Emulation of BEL characters will require */ + /* emulation of RTC and PC speaker I/O. */ + /* Also, this recurses through int 0x10 */ + /* which might or might not have been */ + /* installed yet. */ + { /* Localise */ + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x%2.2x(AH=0x13) -- Write String in Teletype Mode\n", + pInt->num); + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 3, + "AL=0x%2.2x, BL=0x%2.2x, CX=0x%4.4x," + " DH=0x%2.2x, DL=0x%2.2x, ES:BP=0x%4.4x:0x%4.4x\n", + X86_AL, X86_BL, X86_CX, X86_DH, X86_DL, X86_ES, X86_BP); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + } + break; + + default: + /* Various extensions */ + /* Enter: Various */ + /* Leave: Various */ + /* Ignored */ + break; + } + + return 1; +} +#endif + +#define SUCCESSFUL 0x00 +#define DEVICE_NOT_FOUND 0x86 +#define BAD_REGISTER_NUMBER 0x87 + +#ifdef SHOW_ALL_DEVICES +/** + * These functions are meant to be used by the PCI BIOS emulation. Some + * BIOSes need to see if there are \b other chips of the same type around so + * by setting \c exclude one PCI device can be explicitely excluded, if + * required. + */ +static struct pci_device * +do_find(const struct pci_id_match *m, char n, const struct pci_device * exclude) +{ + struct pci_device *dev; + struct pci_device_iterator *iter; + + n++; + + iter = pci_id_match_iterator_create(m); + while ((dev = pci_device_next(iter)) != NULL) { + if ((dev != exclude) && !(--n)) { + break; + } + } + + pci_iterator_destroy(iter); + + return dev; +} + + +static struct pci_device * +find_pci_device_vendor(CARD16 vendorID, CARD16 deviceID, + char n, const struct pci_device * exclude) +{ + struct pci_id_match m; + + m.vendor_id = vendorID; + m.device_id = deviceID; + m.subvendor_id = PCI_MATCH_ANY; + m.subdevice_id = PCI_MATCH_ANY; + m.device_class = 0; + m.device_class_mask = 0; + + return do_find(& m, n, exclude); +} + +static struct pci_device * +find_pci_class(CARD8 intf, CARD8 subClass, CARD16 _class, + char n, const struct pci_device * exclude) +{ + struct pci_id_match m; + + m.vendor_id = PCI_MATCH_ANY; + m.device_id = PCI_MATCH_ANY; + m.subvendor_id = PCI_MATCH_ANY; + m.subdevice_id = PCI_MATCH_ANY; + m.device_class = (((uint32_t)_class) << 16) + | (((uint32_t)subClass) << 8) | intf; + m.device_class_mask = 0x00ffffff; + + return do_find(& m, n, exclude); +} +#endif + +static int +int1A_handler(xf86Int10InfoPtr pInt) +{ + struct pci_device * const pvp = xf86GetPciInfoForEntity(pInt->entityIndex); + struct pci_device * dev; + + if (pvp == NULL) + return 0; /* oops */ + +#ifdef PRINT_INT + ErrorF("int 0x1a: ax=0x%x bx=0x%x cx=0x%x dx=0x%x di=0x%x es=0x%x\n", + X86_EAX, X86_EBX, X86_ECX, X86_EDX, X86_EDI, X86_ESI); +#endif + switch (X86_AX) { + case 0xb101: + X86_EAX &= 0xFF00; /* no config space/special cycle support */ + X86_EDX = 0x20494350; /* " ICP" */ + X86_EBX = 0x0210; /* Version 2.10 */ + X86_ECX &= 0xFF00; + X86_ECX |= (pciNumBuses & 0xFF); /* Max bus number in system */ + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ +#ifdef PRINT_INT + ErrorF("ax=0x%x dx=0x%x bx=0x%x cx=0x%x flags=0x%x\n", + X86_EAX, X86_EDX, X86_EBX, X86_ECX, X86_EFLAGS); +#endif + return 1; + case 0xb102: + if ( (X86_DX == pvp->vendor_id) + && (X86_CX == pvp->device_id) + && (X86_ESI == 0) ) { + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + X86_EBX = pciSlotBX(pvp); + } +#ifdef SHOW_ALL_DEVICES + else + if ((dev = find_pci_device_vendor(X86_EDX, X86_ECX, X86_ESI, pvp))) { + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + X86_EBX = pciSlotBX(dev); + } +#endif + else { + X86_EAX = X86_AL | (DEVICE_NOT_FOUND << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x bx=0x%x flags=0x%x\n", X86_EAX, X86_EBX, X86_EFLAGS); +#endif + return 1; + case 0xb103: + if ( (X86_ECX & 0x00FFFFFF) == pvp->device_class ) { + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EBX = pciSlotBX(pvp); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + } +#ifdef SHOW_ALL_DEVICES + else if ((dev = find_pci_class(X86_CL, X86_CH, + (X86_ECX & 0xffff0000) >> 16, + X86_ESI, pvp))) { + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + X86_EBX = pciSlotBX(dev); + } +#endif + else { + X86_EAX = X86_AL | (DEVICE_NOT_FOUND << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS); +#endif + return 1; + case 0xb108: + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_read_u8(dev, & X86_CL, X86_DI); + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS); +#endif + return 1; + case 0xb109: + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_read_u16(dev, & X86_CX, X86_DI); + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS); +#endif + return 1; + case 0xb10a: + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_read_u32(dev, & X86_ECX, X86_DI); + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x cx=0x%x flags=0x%x\n", X86_EAX, X86_ECX, X86_EFLAGS); +#endif + return 1; + case 0xb10b: + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_write_u8(dev, X86_CL, X86_DI); + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS); +#endif + return 1; + case 0xb10c: + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_write_u16(dev, X86_CX, X86_DI); + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS); +#endif + return 1; + case 0xb10d: + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_write_u32(dev, X86_ECX, X86_DI); + X86_EAX = X86_AL | (SUCCESSFUL << 8); + X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + X86_EAX = X86_AL | (BAD_REGISTER_NUMBER << 8); + X86_EFLAGS |= ((unsigned long)0x01); /* set carry flag */ + } +#ifdef PRINT_INT + ErrorF("ax=0x%x flags=0x%x\n", X86_EAX, X86_EFLAGS); +#endif + return 1; + default: + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "int 0x1a subfunction\n"); + dump_registers(pInt); + if (xf86GetVerbosity() > 3) + stack_trace(pInt); + return 0; + } +} + +static struct pci_device * +findPci(xf86Int10InfoPtr pInt, unsigned short bx) +{ + const unsigned bus = (bx >> 8) & 0x00FF; + const unsigned dev = (bx >> 3) & 0x001F; + const unsigned func = (bx ) & 0x0007; + + return pci_device_find_by_slot(pInt->dev->domain, bus, dev, func); +} + +static CARD32 +pciSlotBX(const struct pci_device * pvp) +{ + return ((pvp->bus << 8) & 0x00FF00) | (pvp->dev << 3) | (pvp->func); +} + +/* + * handle initialization + */ +static int +intE6_handler(xf86Int10InfoPtr pInt) +{ + struct pci_device * pvp; + + if ((pvp = xf86GetPciInfoForEntity(pInt->entityIndex))) + X86_AX = (pvp->bus << 8) | (pvp->dev << 3) | (pvp->func & 0x7); + pushw(pInt, X86_CS); + pushw(pInt, X86_IP); + X86_CS = pInt->BIOSseg; + X86_EIP = 0x0003; + X86_ES = 0; /* standard pc es */ + return 1; +} diff --git a/xorg-server/hw/xfree86/int10/xf86int10.h b/xorg-server/hw/xfree86/int10/xf86int10.h new file mode 100644 index 000000000..0e6669d8f --- /dev/null +++ b/xorg-server/hw/xfree86/int10/xf86int10.h @@ -0,0 +1,183 @@ + +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ + +#ifndef _XF86INT10_H +#define _XF86INT10_H + +#include <X11/Xmd.h> +#include <X11/Xdefs.h> +#include "xf86Pci.h" + +#define SEG_ADDR(x) (((x) >> 4) & 0x00F000) +#define SEG_OFF(x) ((x) & 0x0FFFF) + +#define SET_BIOS_SCRATCH 0x1 +#define RESTORE_BIOS_SCRATCH 0x2 + +/* int10 info structure */ +typedef struct { + int entityIndex; + int scrnIndex; + pointer cpuRegs; + CARD16 BIOSseg; + CARD16 inb40time; + char * BIOSScratch; + int Flags; + pointer private; + struct _int10Mem* mem; + int num; + int ax; + int bx; + int cx; + int dx; + int si; + int di; + int es; + int bp; + int flags; + int stackseg; + struct pci_device *dev; + IOADDRESS ioBase; +} xf86Int10InfoRec, *xf86Int10InfoPtr; + +typedef struct _int10Mem { + CARD8(*rb)(xf86Int10InfoPtr, int); + CARD16(*rw)(xf86Int10InfoPtr, int); + CARD32(*rl)(xf86Int10InfoPtr, int); + void(*wb)(xf86Int10InfoPtr, int, CARD8); + void(*ww)(xf86Int10InfoPtr, int, CARD16); + void(*wl)(xf86Int10InfoPtr, int, CARD32); +} int10MemRec, *int10MemPtr; + +typedef struct { + CARD8 save_msr; + CARD8 save_pos102; + CARD8 save_vse; + CARD8 save_46e8; +} legacyVGARec, *legacyVGAPtr; + +/* OS dependent functions */ +xf86Int10InfoPtr xf86InitInt10(int entityIndex); +xf86Int10InfoPtr xf86ExtendedInitInt10(int entityIndex, int Flags); +void xf86FreeInt10(xf86Int10InfoPtr pInt); +void *xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off); +void xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num); +pointer xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr); + +/* x86 executor related functions */ +void xf86ExecX86int10(xf86Int10InfoPtr pInt); + +#ifdef _INT10_PRIVATE + +#define I_S_DEFAULT_INT_VECT 0xFF065 +#define SYS_SIZE 0x100000 +#define SYS_BIOS 0xF0000 +#if 1 +#define BIOS_SIZE 0x10000 +#else /* a bug in DGUX requires this - let's try it */ +#define BIOS_SIZE (0x10000 - 1) +#endif +#define LOW_PAGE_SIZE 0x600 +#define V_RAM 0xA0000 +#define VRAM_SIZE 0x20000 +#define V_BIOS_SIZE 0x10000 +#define V_BIOS 0xC0000 +#define BIOS_SCRATCH_OFF 0x449 +#define BIOS_SCRATCH_END 0x466 +#define BIOS_SCRATCH_LEN (BIOS_SCRATCH_END - BIOS_SCRATCH_OFF + 1) +#define HIGH_MEM V_BIOS +#define HIGH_MEM_SIZE (SYS_BIOS - HIGH_MEM) +#define SEG_ADR(type, seg, reg) type((seg << 4) + (X86_##reg)) +#define SEG_EADR(type, seg, reg) type((seg << 4) + (X86_E##reg)) + +#define X86_TF_MASK 0x00000100 +#define X86_IF_MASK 0x00000200 +#define X86_IOPL_MASK 0x00003000 +#define X86_NT_MASK 0x00004000 +#define X86_VM_MASK 0x00020000 +#define X86_AC_MASK 0x00040000 +#define X86_VIF_MASK 0x00080000 /* virtual interrupt flag */ +#define X86_VIP_MASK 0x00100000 /* virtual interrupt pending */ +#define X86_ID_MASK 0x00200000 + +#define MEM_RB(name, addr) (*name->mem->rb)(name, addr) +#define MEM_RW(name, addr) (*name->mem->rw)(name, addr) +#define MEM_RL(name, addr) (*name->mem->rl)(name, addr) +#define MEM_WB(name, addr, val) (*name->mem->wb)(name, addr, val) +#define MEM_WW(name, addr, val) (*name->mem->ww)(name, addr, val) +#define MEM_WL(name, addr, val) (*name->mem->wl)(name, addr, val) + +/* OS dependent functions */ +Bool MapCurrentInt10(xf86Int10InfoPtr pInt); +/* x86 executor related functions */ +Bool xf86Int10ExecSetup(xf86Int10InfoPtr pInt); + +/* int.c */ +extern xf86Int10InfoPtr Int10Current; +int int_handler(xf86Int10InfoPtr pInt); + +/* helper_exec.c */ +int setup_int(xf86Int10InfoPtr pInt); +void finish_int(xf86Int10InfoPtr, int sig); +CARD32 getIntVect(xf86Int10InfoPtr pInt, int num); +void pushw(xf86Int10InfoPtr pInt, CARD16 val); +int run_bios_int(int num, xf86Int10InfoPtr pInt); +void dump_code(xf86Int10InfoPtr pInt); +void dump_registers(xf86Int10InfoPtr pInt); +void stack_trace(xf86Int10InfoPtr pInt); +xf86Int10InfoPtr getInt10Rec(int entityIndex); +CARD8 bios_checksum(const CARD8 *start, int size); +void LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga); +void UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga); +#if defined (_PC) +void xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save); +#endif +int port_rep_inb(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count); +int port_rep_inw(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count); +int port_rep_inl(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count); +int port_rep_outb(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count); +int port_rep_outw(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count); +int port_rep_outl(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count); + +CARD8 x_inb(CARD16 port); +CARD16 x_inw(CARD16 port); +void x_outb(CARD16 port, CARD8 val); +void x_outw(CARD16 port, CARD16 val); +CARD32 x_inl(CARD16 port); +void x_outl(CARD16 port, CARD32 val); + +CARD8 Mem_rb(CARD32 addr); +CARD16 Mem_rw(CARD32 addr); +CARD32 Mem_rl(CARD32 addr); +void Mem_wb(CARD32 addr, CARD8 val); +void Mem_ww(CARD32 addr, CARD16 val); +void Mem_wl(CARD32 addr, CARD32 val); + +/* helper_mem.c */ +void setup_int_vect(xf86Int10InfoPtr pInt); +int setup_system_bios(void *base_addr); +void reset_int_vect(xf86Int10InfoPtr pInt); +void set_return_trap(xf86Int10InfoPtr pInt); +void * xf86HandleInt10Options(ScrnInfoPtr pScrn, int entityIndex); +Bool int10skip(const void* options); +Bool int10_check_bios(int scrnIndex, int codeSeg, + const unsigned char* vbiosMem); +Bool initPrimary(const void* options); +BusType xf86int10GetBiosLocationType(const xf86Int10InfoPtr pInt); +Bool xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base); +#ifdef DEBUG +void dprint(unsigned long start, unsigned long size); +#endif + +#endif /* _INT10_PRIVATE */ +#endif /* _XF86INT10_H */ diff --git a/xorg-server/hw/xfree86/int10/xf86int10module.c b/xorg-server/hw/xfree86/int10/xf86int10module.c new file mode 100644 index 000000000..b4e5865da --- /dev/null +++ b/xorg-server/hw/xfree86/int10/xf86int10module.c @@ -0,0 +1,64 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86str.h" +#include "xf86Pci.h" +#include "xf86int10.h" + +#ifndef MOD_NAME +# define MOD_NAME int10 +#endif + +#define stringify(x) #x +#define STRING(x) stringify(x) +#define concat(x,y) x ## y +#define combine(a,b) concat(a,b) +#define NAME(x) combine(MOD_NAME,x) + +static MODULESETUPPROTO(NAME(Setup)); + +static XF86ModuleVersionInfo NAME(VersRec) = +{ + STRING(NAME( )), + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_VIDEODRV, /* needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData NAME(ModuleData) = { + &NAME(VersRec), + NAME(Setup), + NULL +}; + +static pointer +NAME(Setup)(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) { + setupDone = TRUE; + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + */ + } + /* + * The return value must be non-NULL on success even though there + * is no TearDownProc. + */ + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/int10/xf86x86emu.c b/xorg-server/hw/xfree86/int10/xf86x86emu.c new file mode 100644 index 000000000..83663b0e6 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/xf86x86emu.c @@ -0,0 +1,89 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <x86emu.h> +#include "xf86.h" +#include "compiler.h" +#include "xf86_OSproc.h" +#include "xf86Pci.h" +#define _INT10_PRIVATE +#include "xf86int10.h" +#include "int10Defines.h" + +#define M _X86EMU_env + +static void +x86emu_do_int(int num) +{ + Int10Current->num = num; + + if (!int_handler(Int10Current)) { + X86EMU_halt_sys(); + } +} + +void +xf86ExecX86int10(xf86Int10InfoPtr pInt) +{ + int sig = setup_int(pInt); + + if (sig < 0) + return; + + if (int_handler(pInt)) { + X86EMU_exec(); + } + + finish_int(pInt, sig); +} + +Bool +xf86Int10ExecSetup(xf86Int10InfoPtr pInt) +{ + int i; + X86EMU_intrFuncs intFuncs[256]; + X86EMU_pioFuncs pioFuncs = { + (&x_inb), + (&x_inw), + (&x_inl), + (&x_outb), + (&x_outw), + (&x_outl) + }; + + X86EMU_memFuncs memFuncs = { + (&Mem_rb), + (&Mem_rw), + (&Mem_rl), + (&Mem_wb), + (&Mem_ww), + (&Mem_wl) + }; + + X86EMU_setupMemFuncs(&memFuncs); + + pInt->cpuRegs = &M; + M.mem_base = 0; + M.mem_size = 1024*1024 + 1024; + X86EMU_setupPioFuncs(&pioFuncs); + + for (i=0;i<256;i++) + intFuncs[i] = x86emu_do_int; + X86EMU_setupIntrFuncs(intFuncs); + return TRUE; +} + +void +printk(const char *fmt, ...) +{ + va_list argptr; + va_start(argptr, fmt); + VErrorF(fmt, argptr); + va_end(argptr); +} diff --git a/xorg-server/hw/xfree86/int10/xf86x86emu.h b/xorg-server/hw/xfree86/int10/xf86x86emu.h new file mode 100644 index 000000000..4af2dafb7 --- /dev/null +++ b/xorg-server/hw/xfree86/int10/xf86x86emu.h @@ -0,0 +1,54 @@ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef XF86X86EMU_H_ +#define XF86X86EMU_H_ +#include <x86emu.h> + +#define M _X86EMU_env + +#define X86_EAX M.x86.R_EAX +#define X86_EBX M.x86.R_EBX +#define X86_ECX M.x86.R_ECX +#define X86_EDX M.x86.R_EDX +#define X86_ESI M.x86.R_ESI +#define X86_EDI M.x86.R_EDI +#define X86_EBP M.x86.R_EBP +#define X86_EIP M.x86.R_EIP +#define X86_ESP M.x86.R_ESP +#define X86_EFLAGS M.x86.R_EFLG + +#define X86_FLAGS M.x86.R_FLG +#define X86_AX M.x86.R_AX +#define X86_BX M.x86.R_BX +#define X86_CX M.x86.R_CX +#define X86_DX M.x86.R_DX +#define X86_SI M.x86.R_SI +#define X86_DI M.x86.R_DI +#define X86_BP M.x86.R_BP +#define X86_IP M.x86.R_IP +#define X86_SP M.x86.R_SP +#define X86_CS M.x86.R_CS +#define X86_DS M.x86.R_DS +#define X86_ES M.x86.R_ES +#define X86_SS M.x86.R_SS +#define X86_FS M.x86.R_FS +#define X86_GS M.x86.R_GS + +#define X86_AL M.x86.R_AL +#define X86_BL M.x86.R_BL +#define X86_CL M.x86.R_CL +#define X86_DL M.x86.R_DL + +#define X86_AH M.x86.R_AH +#define X86_BH M.x86.R_BH +#define X86_CH M.x86.R_CH +#define X86_DH M.x86.R_DH + +#endif diff --git a/xorg-server/hw/xfree86/loader/Makefile.am b/xorg-server/hw/xfree86/loader/Makefile.am new file mode 100644 index 000000000..ef9ab9ab3 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/Makefile.am @@ -0,0 +1,35 @@ +noinst_LIBRARIES = libloader.a + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \ + -I$(srcdir)/../vbe -I$(top_srcdir)/miext/cw -I$(srcdir)/../int10 \ + -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \ + -I$(srcdir)/../ramdac + +#AM_LDFLAGS = -r +AM_CFLAGS = -DIN_LOADER $(DIX_CFLAGS) $(XORG_CFLAGS) + +if XORG_LOADER_SPARC +SPARC_SOURCES = SparcMulDiv.S +endif + +EXTRA_DIST = \ + dlloader.h \ + loader.h \ + loaderProcs.h \ + SparcMulDiv.S + +libloader_a_SOURCES = \ + loader.c \ + loaderProcs.h \ + loadext.c \ + loadmod.c \ + loadfont.c \ + dlloader.c \ + os.c \ + dixsym.c \ + extsym.c \ + fontsym.c \ + misym.c \ + xf86sym.c \ + sym.h \ + $(SPARC_SOURCES) diff --git a/xorg-server/hw/xfree86/loader/Makefile.in b/xorg-server/hw/xfree86/loader/Makefile.in new file mode 100644 index 000000000..82161d088 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/Makefile.in @@ -0,0 +1,714 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/loader +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libloader_a_AR = $(AR) $(ARFLAGS) +libloader_a_LIBADD = +am__libloader_a_SOURCES_DIST = loader.c loaderProcs.h loadext.c \ + loadmod.c loadfont.c dlloader.c os.c dixsym.c extsym.c \ + fontsym.c misym.c xf86sym.c sym.h SparcMulDiv.S +@XORG_LOADER_SPARC_TRUE@am__objects_1 = SparcMulDiv.$(OBJEXT) +am_libloader_a_OBJECTS = loader.$(OBJEXT) loadext.$(OBJEXT) \ + loadmod.$(OBJEXT) loadfont.$(OBJEXT) dlloader.$(OBJEXT) \ + os.$(OBJEXT) dixsym.$(OBJEXT) extsym.$(OBJEXT) \ + fontsym.$(OBJEXT) misym.$(OBJEXT) xf86sym.$(OBJEXT) \ + $(am__objects_1) +libloader_a_OBJECTS = $(am_libloader_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) +LTCPPASCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libloader_a_SOURCES) +DIST_SOURCES = $(am__libloader_a_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = libloader.a +INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \ + -I$(srcdir)/../vbe -I$(top_srcdir)/miext/cw -I$(srcdir)/../int10 \ + -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \ + -I$(srcdir)/../ramdac + + +#AM_LDFLAGS = -r +AM_CFLAGS = -DIN_LOADER $(DIX_CFLAGS) $(XORG_CFLAGS) +@XORG_LOADER_SPARC_TRUE@SPARC_SOURCES = SparcMulDiv.S +EXTRA_DIST = \ + dlloader.h \ + loader.h \ + loaderProcs.h \ + SparcMulDiv.S + +libloader_a_SOURCES = \ + loader.c \ + loaderProcs.h \ + loadext.c \ + loadmod.c \ + loadfont.c \ + dlloader.c \ + os.c \ + dixsym.c \ + extsym.c \ + fontsym.c \ + misym.c \ + xf86sym.c \ + sym.h \ + $(SPARC_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/loader/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/loader/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libloader.a: $(libloader_a_OBJECTS) $(libloader_a_DEPENDENCIES) + -rm -f libloader.a + $(libloader_a_AR) libloader.a $(libloader_a_OBJECTS) $(libloader_a_LIBADD) + $(RANLIB) libloader.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SparcMulDiv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dixsym.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlloader.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extsym.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontsym.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loader.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loadext.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loadfont.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loadmod.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misym.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86sym.Po@am__quote@ + +.S.o: +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCCAS_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(CPPASCOMPILE) -c -o $@ $< + +.S.obj: +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCCAS_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.S.lo: +@am__fastdepCCAS_TRUE@ $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCCAS_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(LTCPPASCOMPILE) -c -o $@ $< + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/loader/SparcMulDiv.S b/xorg-server/hw/xfree86/loader/SparcMulDiv.S new file mode 100644 index 000000000..11139d192 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/SparcMulDiv.S @@ -0,0 +1,87 @@ +/* + * Hardware integer division and multiplication routines for SPARC v8 and higher. + * + * Copyright (C) 1996 David S. Miller (davem@redhat.com) + * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz) + * + * 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 + * JAKUB JELINEK OR DAVID MILLER 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. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S,v 1.1 1999/07/10 07:24:51 dawes Exp $ */ + + .globl urem_sparcv89, umul_sparcv89, udiv_sparcv89 + .globl rem_sparcv89, mul_sparcv89, div_sparcv89 + + .align 32 +urem_sparcv89: + wr %g0, 0x0, %y + nop + nop + nop + udiv %o0, %o1, %o2 + umul %o2, %o1, %o2 + retl + sub %o0, %o2, %o0 + + .align 32 +umul_sparcv89: + umul %o0, %o1, %o0 + retl + rd %y, %o1 + + .align 32 +udiv_sparcv89: + wr %g0, 0x0, %y + nop + nop + retl + udiv %o0, %o1, %o0 + + .align 32 +rem_sparcv89: + sra %o0, 0x1f, %o4 + wr %o4, 0x0, %y + nop + nop + nop + sdivcc %o0, %o1, %o2 + bvs,a 1f + xnor %o2, %g0, %o2 +1: smul %o2, %o1, %o2 + retl + sub %o0, %o2, %o0 + + .align 32 +mul_sparcv89: + smul %o0, %o1, %o0 + retl + rd %y, %o1 + nop + + .align 32 +div_sparcv89: + sra %o0, 0x1f, %o2 + wr %o2, 0x0, %y + nop + nop + nop + sdivcc %o0, %o1, %o0 + bvs,a 1f + xnor %o0, %g0, %o0 +1: retl + nop diff --git a/xorg-server/hw/xfree86/loader/dixsym.c b/xorg-server/hw/xfree86/loader/dixsym.c new file mode 100644 index 000000000..a8bde756b --- /dev/null +++ b/xorg-server/hw/xfree86/loader/dixsym.c @@ -0,0 +1,538 @@ +/* + * Copyright 1995-1998 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#undef DBMALLOC +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "sym.h" +#include "colormap.h" +#include "cursor.h" +#include "cursorstr.h" +#include "dix.h" +#include "dixevents.h" +#include "dixfont.h" +#include "dixstruct.h" +#include "misc.h" +#include "globals.h" +#include "os.h" +#include "osdep.h" +#include "privates.h" +#include "resource.h" +#include "registry.h" +#include "servermd.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "extension.h" +#define EXTENSION_PROC_ARGS void * +#include "extnsionst.h" +#include "swaprep.h" +#include "swapreq.h" +#include "inputstr.h" +#include <X11/extensions/XIproto.h> +#include "exevents.h" +#include "extinit.h" +#ifdef XV +#include "xvmodproc.h" +#endif +#include "dgaproc.h" +#ifdef RENDER +#include "mipict.h" +#include "renderedge.h" +#endif +#include "selection.h" +#ifdef XKB +#include <xkbsrv.h> +extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval; +#endif + +/* DIX things */ + +_X_HIDDEN void *dixLookupTab[] = { + + /* dix */ + /* atom.c */ + SYMFUNC(MakeAtom) + SYMFUNC(ValidAtom) + /* colormap.c */ + SYMFUNC(AllocColor) + SYMFUNC(CreateColormap) + SYMFUNC(FakeAllocColor) + SYMFUNC(FakeFreeColor) + SYMFUNC(FreeColors) + SYMFUNC(StoreColors) + SYMFUNC(TellLostMap) + SYMFUNC(TellGainedMap) + SYMFUNC(QueryColors) + /* cursor.c */ + SYMFUNC(FreeCursor) + /* deprecated.c */ + SYMFUNC(LookupClient) + SYMFUNC(LookupDrawable) + SYMFUNC(LookupWindow) + SYMFUNC(SecurityLookupDrawable) + SYMFUNC(SecurityLookupWindow) + SYMFUNC(LookupIDByType) + SYMFUNC(LookupIDByClass) + SYMFUNC(SecurityLookupIDByClass) + SYMFUNC(SecurityLookupIDByType) + /* devices.c */ + SYMFUNC(Ones) + SYMFUNC(InitButtonClassDeviceStruct) + SYMFUNC(InitFocusClassDeviceStruct) + SYMFUNC(InitLedFeedbackClassDeviceStruct) + SYMFUNC(InitPtrFeedbackClassDeviceStruct) + SYMFUNC(InitKbdFeedbackClassDeviceStruct) + SYMFUNC(InitIntegerFeedbackClassDeviceStruct) + SYMFUNC(InitStringFeedbackClassDeviceStruct) + SYMFUNC(InitBellFeedbackClassDeviceStruct) + SYMFUNC(InitValuatorClassDeviceStruct) + SYMFUNC(InitKeyClassDeviceStruct) + SYMFUNC(InitKeyboardDeviceStruct) + SYMFUNC(SendMappingNotify) + SYMFUNC(InitPointerDeviceStruct) + /* dispatch.c */ + SYMFUNC(SetInputCheck) + SYMFUNC(SendErrorToClient) + SYMFUNC(UpdateCurrentTime) + SYMFUNC(UpdateCurrentTimeIf) + SYMFUNC(ProcBadRequest) + SYMVAR(dispatchException) + SYMVAR(isItTimeToYield) + SYMVAR(ClientStateCallback) + SYMVAR(ServerGrabCallback) + /* dixfonts.c */ + SYMFUNC(CloseFont) + SYMFUNC(FontToXError) + SYMFUNC(LoadGlyphs) + SYMVAR(fpe_functions) + /* dixutils.c */ + SYMFUNC(AddCallback) + SYMFUNC(ClientSleep) + SYMFUNC(ClientTimeToServerTime) + SYMFUNC(ClientWakeup) + SYMFUNC(CompareTimeStamps) + SYMFUNC(CopyISOLatin1Lowered) + SYMFUNC(DeleteCallback) + SYMFUNC(dixLookupDrawable) + SYMFUNC(dixLookupWindow) + SYMFUNC(dixLookupClient) + SYMFUNC(dixLookupGC) + SYMFUNC(NoopDDA) + SYMFUNC(QueueWorkProc) + SYMFUNC(RegisterBlockAndWakeupHandlers) + SYMFUNC(RemoveBlockAndWakeupHandlers) + /* events.c */ + SYMFUNC(CheckCursorConfinement) + SYMFUNC(DeliverEvents) + SYMFUNC(NewCurrentScreen) + SYMFUNC(PointerConfinedToScreen) + SYMFUNC(TryClientEvents) + SYMFUNC(WriteEventsToClient) + SYMFUNC(GetCurrentRootWindow) + SYMFUNC(GetSpritePosition) + SYMFUNC(GetSpriteWindow) + SYMFUNC(GetSpriteCursor) + SYMFUNC(WindowsRestructured) + SYMVAR(DeviceEventCallback) + SYMVAR(EventCallback) + SYMVAR(inputInfo) + SYMFUNC(SetCriticalEvent) +#ifdef PANORAMIX + SYMFUNC(XineramaGetCursorScreen) +#endif + /* property.c */ + SYMFUNC(dixLookupProperty) + SYMFUNC(ChangeWindowProperty) + SYMFUNC(dixChangeWindowProperty) + /* selection.c */ + SYMFUNC(dixLookupSelection) + SYMVAR(CurrentSelections) + /* extension.c */ + SYMFUNC(AddExtension) + SYMFUNC(AddExtensionAlias) + SYMFUNC(CheckExtension) + SYMFUNC(MinorOpcodeOfRequest) + SYMFUNC(StandardMinorOpcode) +#ifdef XEVIE + SYMVAR(xeviehot) + SYMVAR(xeviewin) +#endif + /* gc.c */ + SYMFUNC(CopyGC) + SYMFUNC(CreateGC) + SYMFUNC(CreateScratchGC) + SYMFUNC(ChangeGC) + SYMFUNC(dixChangeGC) + SYMFUNC(DoChangeGC) + SYMFUNC(FreeGC) + SYMFUNC(FreeScratchGC) + SYMFUNC(GetScratchGC) + SYMFUNC(SetClipRects) + SYMFUNC(ValidateGC) + SYMFUNC(VerifyRectOrder) + SYMFUNC(SetDashes) + /* globals.c */ + SYMVAR(ScreenSaverTime) +#ifdef DPMSExtension + SYMVAR(DPMSEnabled) + SYMVAR(DPMSCapableFlag) + SYMVAR(DPMSOffTime) + SYMVAR(DPMSPowerLevel) + SYMVAR(DPMSStandbyTime) + SYMVAR(DPMSSuspendTime) + SYMVAR(DPMSEnabledSwitch) + SYMVAR(DPMSDisabledSwitch) + SYMVAR(defaultDPMSEnabled) +#endif + /* bigreq */ + SYMVAR(maxBigRequestSize) +#ifdef XV + /* XXX These are exported from the DDX, not DIX. */ + SYMVAR(XvScreenInitProc) + SYMVAR(XvGetScreenKeyProc) + SYMVAR(XvGetRTPortProc) + SYMVAR(XvMCScreenInitProc) +#endif + SYMVAR(ScreenSaverBlanking) + SYMVAR(WindowTable) + SYMVAR(clients) + SYMVAR(currentMaxClients) + SYMVAR(currentTime) + SYMVAR(defaultColorVisualClass) + SYMVAR(display) + SYMVAR(globalSerialNumber) + SYMVAR(lastDeviceEventTime) + SYMVAR(monitorResolution) + SYMVAR(screenInfo) + SYMVAR(serverClient) + SYMVAR(serverGeneration) + /* main.c */ + SYMFUNC(NotImplemented) + SYMVAR(PixmapWidthPaddingInfo) + /* pixmap.c */ + SYMFUNC(AllocatePixmap) + SYMFUNC(GetScratchPixmapHeader) + SYMFUNC(FreeScratchPixmapHeader) + /* privates.c */ + SYMFUNC(dixRequestPrivate) + SYMFUNC(dixRegisterPrivateInitFunc) + SYMFUNC(dixRegisterPrivateDeleteFunc) + SYMFUNC(dixAllocatePrivate) + SYMFUNC(dixLookupPrivate) + SYMFUNC(dixLookupPrivateAddr) + SYMFUNC(dixSetPrivate) + SYMFUNC(dixFreePrivates) + SYMFUNC(dixRegisterPrivateOffset) + SYMFUNC(dixLookupPrivateOffset) + /* resource.c */ + SYMFUNC(AddResource) + SYMFUNC(ChangeResourceValue) + SYMFUNC(CreateNewResourceClass) + SYMFUNC(CreateNewResourceType) + SYMFUNC(dixLookupResource) + SYMFUNC(FakeClientID) + SYMFUNC(FreeResource) + SYMFUNC(FreeResourceByType) + SYMFUNC(GetXIDList) + SYMFUNC(GetXIDRange) + SYMFUNC(LegalNewID) + SYMFUNC(FindClientResourcesByType) + SYMFUNC(FindAllClientResources) + SYMVAR(lastResourceType) + SYMVAR(TypeMask) + SYMVAR(ResourceStateCallback) + /* registry.c */ +#ifdef XREGISTRY + SYMFUNC(RegisterResourceName) + SYMFUNC(LookupMajorName) + SYMFUNC(LookupRequestName) + SYMFUNC(LookupEventName) + SYMFUNC(LookupErrorName) + SYMFUNC(LookupResourceName) +#endif + /* swaprep.c */ + SYMFUNC(CopySwap32Write) + SYMFUNC(Swap32Write) + SYMFUNC(SwapConnSetupInfo) + SYMFUNC(SwapConnSetupPrefix) + /* swapreq.c */ + SYMFUNC(SwapShorts) + SYMFUNC(SwapLongs) + SYMFUNC(SwapColorItem) + /* tables.c */ + SYMVAR(EventSwapVector) + SYMVAR(ReplySwapVector) + SYMVAR(ProcVector) + /* window.c */ + SYMFUNC(ChangeWindowAttributes) + SYMFUNC(CheckWindowOptionalNeed) + SYMFUNC(CreateUnclippedWinSize) + SYMFUNC(CreateWindow) + SYMFUNC(FindWindowWithOptional) + SYMFUNC(GravityTranslate) + SYMFUNC(MakeWindowOptional) + SYMFUNC(MapWindow) + SYMFUNC(MoveWindowInStack) + SYMFUNC(NotClippedByChildren) + SYMFUNC(ResizeChildrenWinSize) + SYMFUNC(SaveScreens) + SYMFUNC(dixSaveScreens) + SYMFUNC(SendVisibilityNotify) + SYMFUNC(SetWinSize) + SYMFUNC(SetBorderSize) + SYMFUNC(TraverseTree) + SYMFUNC(UnmapWindow) + SYMFUNC(WalkTree) + SYMVAR(deltaSaveUndersViewable) + SYMVAR(numSaveUndersViewable) + SYMVAR(savedScreenInfo) + SYMVAR(screenIsSaved) + + /*os/ */ + /* access.c */ + SYMFUNC(LocalClient) + /* utils.c */ + SYMFUNC(Xstrdup) + SYMFUNC(XNFstrdup) + SYMVAR(Must_have_memory) + SYMFUNC(AdjustWaitForDelay) + SYMVAR(noTestExtensions) + SYMFUNC(GiveUp) + +#ifdef BIGREQS + SYMVAR(noBigReqExtension) +#endif +#ifdef COMPOSITE + SYMVAR(noCompositeExtension) +#endif +#ifdef DAMAGE + SYMVAR(noDamageExtension) +#endif +#ifdef DBE + SYMVAR(noDbeExtension) +#endif +#ifdef DPMSExtension + SYMVAR(noDPMSExtension) +#endif +#ifdef EVI + SYMVAR(noEVIExtension) +#endif +#ifdef FONTCACHE + SYMVAR(noFontCacheExtension) +#endif +#ifdef GLXEXT + SYMVAR(noGlxExtension) +#endif +#ifdef SCREENSAVER + SYMVAR(noScreenSaverExtension) +#endif +#ifdef MITSHM + SYMVAR(noMITShmExtension) +#endif +#ifdef MITMISC + SYMVAR(noMITMiscExtension) +#endif +#ifdef MULTIBUFFER + SYMVAR(noMultibufferExtension) +#endif +#ifdef RANDR + SYMVAR(noRRExtension) +#endif +#ifdef RENDER + SYMVAR(noRenderExtension) +#endif +#ifdef SHAPE + SYMVAR(noShapeExtension) +#endif +#ifdef XCSECURITY + SYMVAR(noSecurityExtension) +#endif +#ifdef XSYNC + SYMVAR(noSyncExtension) +#endif +#ifdef TOGCUP + SYMVAR(noXcupExtension) +#endif +#ifdef RES + SYMVAR(noResExtension) +#endif +#ifdef XAPPGROUP + SYMVAR(noXagExtension) +#endif +#ifdef XCMISC + SYMVAR(noXCMiscExtension) +#endif +#ifdef XEVIE + SYMVAR(noXevieExtension) +#endif +#ifdef XF86BIGFONT + SYMVAR(noXFree86BigfontExtension) +#endif +#ifdef XFreeXDGA + SYMVAR(noXFree86DGAExtension) +#endif +#ifdef XF86DRI + SYMVAR(noXFree86DRIExtension) +#endif +#ifdef XF86MISC + SYMVAR(noXFree86MiscExtension) +#endif +#ifdef XF86VIDMODE + SYMVAR(noXFree86VidModeExtension) +#endif +#ifdef XFIXES + SYMVAR(noXFixesExtension) +#endif +#ifdef XKB +/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */ + SYMVAR(noXkbExtension) +#endif +#ifdef PANORAMIX + SYMVAR(noPanoramiXExtension) +#endif +#ifdef XINPUT + SYMVAR(noXInputExtension) +#endif +#ifdef XIDLE + SYMVAR(noXIdleExtension) +#endif +#ifdef XSELINUX + SYMVAR(noSELinuxExtension) +#endif +#ifdef XV + SYMVAR(noXvExtension) +#endif + + /* log.c */ + SYMFUNC(LogVWrite) + SYMFUNC(LogWrite) + SYMFUNC(LogVMessageVerb) + SYMFUNC(LogMessageVerb) + SYMFUNC(LogMessage) + SYMFUNC(FatalError) + SYMFUNC(VErrorF) + SYMFUNC(ErrorF) + SYMFUNC(Error) + /* xalloc.c */ + SYMFUNC(XNFalloc) + SYMFUNC(XNFcalloc) + SYMFUNC(XNFrealloc) + SYMFUNC(Xalloc) + SYMFUNC(Xcalloc) + SYMFUNC(Xfree) + SYMFUNC(Xrealloc) + /* WaitFor.c */ + SYMFUNC(TimerFree) + SYMFUNC(TimerSet) + SYMFUNC(TimerCancel) + /* io.c */ + SYMFUNC(WriteToClient) + SYMFUNC(SetCriticalOutputPending) + SYMVAR(FlushCallback) + SYMVAR(ReplyCallback) + SYMVAR(SkippedRequestsCallback) + SYMFUNC(ResetCurrentRequest) + /* connection.c */ + SYMFUNC(IgnoreClient) + SYMFUNC(AttendClient) + SYMFUNC(AddEnabledDevice) + SYMFUNC(RemoveEnabledDevice) + SYMFUNC(MakeClientGrabPervious) + SYMFUNC(MakeClientGrabImpervious) + SYMVAR(GrabInProgress) + +#ifdef XKB + /* xkb/xkbInit.c */ + SYMFUNC(XkbInitKeyboardDeviceStruct) + SYMFUNC(XkbSetRulesDflts) + SYMVAR(XkbDfltRepeatDelay) + SYMVAR(XkbDfltRepeatInterval) +#endif + +#ifdef XINPUT + /* Xi */ + /* exevents.c */ + SYMFUNC(InitValuatorAxisStruct) + SYMFUNC(InitProximityClassDeviceStruct) + /* extinit.c */ + SYMFUNC(AssignTypeAndName) +#endif + + /* xf86DGA.c */ + /* XXX This is exported from the DDX, not DIX. */ + SYMVAR(XDGAEventBase) + + /* librender.a */ +#ifdef RENDER + /* picture.c */ + SYMFUNC(PictureInit) + SYMFUNC(PictureTransformPoint) + SYMFUNC(PictureTransformPoint3d) + SYMFUNC(PictureGetSubpixelOrder) + SYMFUNC(PictureSetSubpixelOrder) + SYMVAR(PictureScreenPrivateKey) + /* mipict.c */ + SYMFUNC(miPictureInit) + SYMFUNC(miComputeCompositeRegion) + /* miglyph.c */ + SYMFUNC(miGlyphs) + /* mirect.c */ + SYMFUNC(miCompositeRects) + /* filter.c */ + SYMFUNC(PictureAddFilter) + SYMFUNC(PictureSetFilterAlias) + /* renderedge.c */ + SYMFUNC(RenderSampleCeilY) + SYMFUNC(RenderSampleFloorY) + SYMFUNC(RenderEdgeStep) + SYMFUNC(RenderEdgeInit) + SYMFUNC(RenderLineFixedEdgeInit) +#endif +}; diff --git a/xorg-server/hw/xfree86/loader/dlloader.c b/xorg-server/hw/xfree86/loader/dlloader.c new file mode 100644 index 000000000..4caefd071 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/dlloader.c @@ -0,0 +1,179 @@ +/* + * Copyright (c) 1997 The XFree86 Project, 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 the + * XFree86 Project, Inc. not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. The Xfree86 Project, Inc. makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THE XFREE86 PROJECT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE XFREE86 PROJECT, INC. 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. + */ + +/* + * Once upon a time, X had multiple loader backends, three of which were + * essentially libdl reimplementations. This was nonsense so we chucked + * it, but we still retain the factorization between loader API and + * platform implementation. This file is the libdl implementation, and + * currently the only backend. If you find yourself porting to a platform + * without working libdl - hpux, win32, some forsaken a.out host, etc. - + * make a new backend rather than hacking up this file. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <dlfcn.h> + +#include <X11/Xos.h> +#include "os.h" + +#include "loader.h" +#include "dlloader.h" + +#if defined(DL_LAZY) +#define DLOPEN_LAZY DL_LAZY +#elif defined(RTLD_LAZY) +#define DLOPEN_LAZY RTLD_LAZY +#elif defined(__FreeBSD__) +#define DLOPEN_LAZY 1 +#else +#define DLOPEN_LAZY 0 +#endif + +#if defined(LD_GLOBAL) +#define DLOPEN_GLOBAL LD_GLOBAL +#elif defined(RTLD_GLOBAL) +#define DLOPEN_GLOBAL RTLD_GLOBAL +#else +#define DLOPEN_GLOBAL 0 +#endif + +#if defined(CSRG_BASED) && !defined(__ELF__) +#define DLSYM_PREFIX "_" +#else +#define DLSYM_PREFIX "" +#endif + +/* Hooray, yet another open coded linked list! FIXME */ +typedef struct DLModuleList { + void *module; + struct DLModuleList *next; +} DLModuleList; + +static DLModuleList *dlModuleList = NULL; + +static void * +DLFindSymbolLocal(pointer module, const char *name) +{ + void *p; + char *n; + + static const char symPrefix[] = DLSYM_PREFIX; + + if (strlen(symPrefix)) { + n = malloc(strlen(symPrefix) + strlen(name) + 1); + sprintf(n, "%s%s", symPrefix, name); + } else { + n = name; + } + + p = dlsym(module, n); + + if (strlen(symPrefix)) + free(n); + + return p; +} + +static void *global_scope = NULL; + +void * +DLFindSymbol(const char *name) +{ + DLModuleList *l; + void *p; + + p = dlsym(RTLD_DEFAULT, name); + if (p != NULL) + return p; + + for (l = dlModuleList; l != NULL; l = l->next) { + p = DLFindSymbolLocal(l->module, name); + if (p) + return p; + } + + if (!global_scope) + global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL); + + if (global_scope) + return DLFindSymbolLocal(global_scope, name); + + return NULL; +} + +void * +DLLoadModule(loaderPtr modrec, int flags) +{ + void * dlfile; + DLModuleList *l; + int dlopen_flags; + + if (flags & LD_FLAG_GLOBAL) + dlopen_flags = DLOPEN_LAZY | DLOPEN_GLOBAL; + else + dlopen_flags = DLOPEN_LAZY; + dlfile = dlopen(modrec->name, dlopen_flags); + if (dlfile == NULL) { + ErrorF("dlopen: %s\n", dlerror()); + return NULL; + } + + l = malloc(sizeof(DLModuleList)); + l->module = dlfile; + l->next = dlModuleList; + dlModuleList = l; + + return (void *)dlfile; +} + +void +DLUnloadModule(void *modptr) +{ + DLModuleList *l, *p; + + /* remove it from dlModuleList. */ + if (dlModuleList->module == modptr) { + l = dlModuleList; + dlModuleList = l->next; + free(l); + } else { + p = dlModuleList; + for (l = dlModuleList->next; l != NULL; l = l->next) { + if (l->module == modptr) { + p->next = l->next; + free(l); + break; + } + p = l; + } + } + dlclose(modptr); +} diff --git a/xorg-server/hw/xfree86/loader/dlloader.h b/xorg-server/hw/xfree86/loader/dlloader.h new file mode 100644 index 000000000..8ae610f02 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/dlloader.h @@ -0,0 +1,33 @@ +/* + * Copyright 1997 Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _DLLOADER_H +#define _DLLOADER_H + +extern void *DLLoadModule(loaderPtr, int flags); +extern void DLUnloadModule(void *); +extern void *DLFindSymbol(const char *name); + +#endif diff --git a/xorg-server/hw/xfree86/loader/extsym.c b/xorg-server/hw/xfree86/loader/extsym.c new file mode 100644 index 000000000..1bdff9482 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/extsym.c @@ -0,0 +1,77 @@ +/* + * + * Copyright 1999-2003 by The XFree86 Project, 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 The XFree86 Project, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The XFree86 Project, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * THE XFREE86 PROJECT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE XFREE86 PROJECT, INC. BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "resource.h" +#include "sym.h" +#include "misc.h" +#ifdef PANORAMIX +#include "panoramiX.h" +#endif +#include "sleepuntil.h" + +#ifdef HAS_SHM +extern int ShmCompletionCode; +extern int BadShmSegCode; +extern RESTYPE ShmSegType, ShmPixType; +#endif + +#ifdef PANORAMIX +extern Bool noPanoramiXExtension; +extern int PanoramiXNumScreens; +extern PanoramiXData *panoramiXdataPtr; +extern unsigned long XRT_WINDOW; +extern unsigned long XRT_PIXMAP; +extern unsigned long XRT_GC; +extern unsigned long XRT_COLORMAP; +extern unsigned long XRC_DRAWABLE; +extern Bool XineramaRegisterConnectionBlockCallback(void (*func) (void)); +extern int XineramaDeleteResource(pointer, XID); +#endif + +_X_HIDDEN void *extLookupTab[] = { + + SYMFUNC(ClientSleepUntil) + +#ifdef HAS_SHM + SYMVAR(ShmCompletionCode) + SYMVAR(BadShmSegCode) + SYMVAR(ShmSegType) +#endif + +#ifdef PANORAMIX + SYMFUNC(XineramaRegisterConnectionBlockCallback) + SYMFUNC(XineramaDeleteResource) + SYMVAR(PanoramiXNumScreens) + SYMVAR(panoramiXdataPtr) + SYMVAR(XRT_WINDOW) + SYMVAR(XRT_PIXMAP) + SYMVAR(XRT_GC) + SYMVAR(XRT_COLORMAP) + SYMVAR(XRC_DRAWABLE) +#endif +}; diff --git a/xorg-server/hw/xfree86/loader/fontsym.c b/xorg-server/hw/xfree86/loader/fontsym.c new file mode 100644 index 000000000..82d4b1cf8 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/fontsym.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 1998-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/fonts/font.h> +#include "sym.h" +#include <X11/fonts/fntfilst.h> +#include <X11/fonts/fontenc.h> +#ifdef FONTENC_COMPATIBILITY +#include <X11/fonts/fontencc.h> +#endif +#include <X11/fonts/fntfilio.h> +#include <X11/fonts/fntfil.h> +#include <X11/fonts/fontutil.h> +#include <X11/fonts/fontxlfd.h> +#ifdef FONTCACHE +#define _FONTCACHE_SERVER_ +#include "fontcache.h" +#endif + +_X_HIDDEN void *fontLookupTab[] = { + + SYMFUNC(TwoByteSwap) + SYMFUNC(FourByteSwap) + SYMFUNC(FontCouldBeTerminal) + SYMFUNC(BufFileRead) + SYMFUNC(BufFileWrite) + SYMFUNC(CheckFSFormat) + SYMFUNC(FontFileOpen) + SYMFUNC(FontFilePriorityRegisterRenderer) + SYMFUNC(FontFileRegisterRenderer) + SYMFUNC(FontParseXLFDName) + SYMFUNC(FontFileCloseFont) + SYMFUNC(FontFileOpenBitmap) + SYMFUNC(FontFileCompleteXLFD) + SYMFUNC(FontFileCountDashes) + SYMFUNC(FontFileFindNameInDir) + SYMFUNC(FontFileClose) + SYMFUNC(FontComputeInfoAccelerators) + SYMFUNC(FontDefaultFormat) + SYMFUNC(NameForAtom) + SYMFUNC(BitOrderInvert) + SYMFUNC(FontFileMatchRenderer) + SYMFUNC(RepadBitmap) + SYMFUNC(FontEncName) + SYMFUNC(FontEncRecode) + SYMFUNC(FontEncFind) + SYMFUNC(FontMapFind) + SYMFUNC(FontEncMapFind) + SYMFUNC(FontEncFromXLFD) + SYMFUNC(FontEncDirectory) + SYMFUNC(FontMapReverse) + SYMFUNC(FontMapReverseFree) + SYMFUNC(CreateFontRec) + SYMFUNC(DestroyFontRec) + SYMFUNC(GetGlyphs) + SYMFUNC(QueryGlyphExtents) + + SYMVAR(FontFileBitmapSources) + +#ifdef FONTENC_COMPATIBILITY + /* Obsolete backwards compatibility symbols -- fontencc.c */ + SYMFUNC(font_encoding_from_xlfd) + SYMFUNC(font_encoding_find) + SYMFUNC(font_encoding_recode) + SYMFUNC(font_encoding_name) + SYMFUNC(identifyEncodingFile) +#endif + +#ifdef FONTCACHE + /* fontcache.c */ + SYMFUNC(FontCacheGetSettings) + SYMFUNC(FontCacheGetStatistics) + SYMFUNC(FontCacheChangeSettings) + SYMFUNC(FontCacheOpenCache) + SYMFUNC(FontCacheCloseCache) + SYMFUNC(FontCacheSearchEntry) + SYMFUNC(FontCacheGetEntry) + SYMFUNC(FontCacheInsertEntry) + SYMFUNC(FontCacheGetBitmap) +#endif +}; diff --git a/xorg-server/hw/xfree86/loader/loader.c b/xorg-server/hw/xfree86/loader/loader.c new file mode 100644 index 000000000..a00269b70 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/loader.c @@ -0,0 +1,389 @@ +/* + * Copyright 1995-1998 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#if defined(UseMMAP) || (defined(linux) && defined(__ia64__)) +#include <sys/mman.h> +#endif +#include <unistd.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#if defined(linux) && \ + (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \ + || defined(__amd64__) || defined(__x86_64__)) +#include <malloc.h> +#endif +#include <stdarg.h> + +#include "os.h" +#include "loader.h" +#include "loaderProcs.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "compiler.h" +#include "sym.h" + +#if defined(Lynx) && defined(sun) +/* Cross build machine doesn;t have strerror() */ +#define strerror(err) "strerror unsupported" +#endif + +/* + * handles are used to identify files that are loaded. Even archives + * are counted as a single file. + */ +#define MAX_HANDLE 256 +#define HANDLE_FREE 0 +#define HANDLE_USED 1 +static char freeHandles[MAX_HANDLE]; +static int refCount[MAX_HANDLE]; + +/* + * modules are used to identify compilation units (ie object modules). + * Archives contain multiple modules, each of which is treated seperately. + */ +static int moduleseq = 0; + +/* Prototypes for static functions. */ +static loaderPtr _LoaderListPush(void); +static loaderPtr _LoaderListPop(int); + +void +LoaderInit(void) +{ + const char *osname = NULL; + + char *ld_bind_now = getenv("LD_BIND_NOW"); + if (ld_bind_now && *ld_bind_now) { + xf86Msg(X_ERROR, "LD_BIND_NOW is set, dlloader will NOT work!\n"); + } + + xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *) + ((long)dixLookupTab ^ (long)extLookupTab + ^ (long)fontLookupTab ^ (long)miLookupTab + ^ (long)xfree86LookupTab)); + xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n"); + xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC, + GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion), + GET_ABI_MINOR(LoaderVersionInfo.ansicVersion)); + xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV, + GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion), + GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion)); + xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT, + GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion), + GET_ABI_MINOR(LoaderVersionInfo.xinputVersion)); + xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION, + GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion), + GET_ABI_MINOR(LoaderVersionInfo.extensionVersion)); + xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_FONT, + GET_ABI_MAJOR(LoaderVersionInfo.fontVersion), + GET_ABI_MINOR(LoaderVersionInfo.fontVersion)); + + LoaderGetOS(&osname, NULL, NULL, NULL); + if (osname) + xf86MsgVerb(X_INFO, 2, "Loader running on %s\n", osname); + +#if defined(__UNIXWARE__) && !defined(__GNUC__) + /* For UnixWare we need to load the C Runtime libraries which are + * normally auto-linked by the compiler. Otherwise we are bound to + * see unresolved symbols when trying to use the type "long long". + * Obviously, this does not apply if the GNU C compiler is used. + */ + { + int errmaj, errmin, wasLoaded; /* place holders */ + char *xcrtpath = DEFAULT_MODULE_PATH "/libcrt.a"; + char *uwcrtpath = "/usr/ccs/lib/libcrt.a"; + char *path; + struct stat st; + + if(stat(xcrtpath, &st) < 0) + path = uwcrtpath; /* fallback: try to get libcrt.a from the uccs */ + else + path = xcrtpath; /* get the libcrt.a we compiled with */ + LoaderOpen (path, "libcrt", 0, &errmaj, &errmin, &wasLoaded); + } +#endif +} + +static loaderPtr listHead = (loaderPtr) 0; + +static loaderPtr +_LoaderListPush() +{ + loaderPtr item = calloc(1, sizeof(struct _loader)); + + item->next = listHead; + listHead = item; + + return item; +} + +static loaderPtr +_LoaderListPop(int handle) +{ + loaderPtr item = listHead; + loaderPtr *bptr = &listHead; /* pointer to previous node */ + + while (item) { + if (item->handle == handle) { + *bptr = item->next; /* remove this from the list */ + return item; + } + bptr = &(item->next); + item = item->next; + } + + return 0; +} + +/* These four are just ABI stubs */ +_X_EXPORT void +LoaderRefSymbols(const char *sym0, ...) +{ +} + +_X_EXPORT void +LoaderRefSymLists(const char **list0, ...) +{ +} + +_X_EXPORT void +LoaderReqSymLists(const char **list0, ...) +{ +} + +_X_EXPORT void +LoaderReqSymbols(const char *sym0, ...) +{ +} + +/* Public Interface to the loader. */ + +int +LoaderOpen(const char *module, const char *cname, int handle, + int *errmaj, int *errmin, int *wasLoaded, int flags) +{ + loaderPtr tmp; + int new_handle; + +#if defined(DEBUG) + ErrorF("LoaderOpen(%s)\n", module); +#endif + + /* + * Check to see if the module is already loaded. + * Only if we are loading it into an existing namespace. + * If it is to be loaded into a new namespace, don't check. + * Note: We only have one namespace. + */ + if (handle >= 0) { + tmp = listHead; + while (tmp) { +#ifdef DEBUGLIST + ErrorF("strcmp(%x(%s),{%x} %x(%s))\n", module, module, + &(tmp->name), tmp->name, tmp->name); +#endif + if (!strcmp(module, tmp->name)) { + refCount[tmp->handle]++; + if (wasLoaded) + *wasLoaded = 1; + xf86MsgVerb(X_INFO, 2, "Reloading %s\n", module); + return tmp->handle; + } + tmp = tmp->next; + } + } + + /* + * OK, it's a new one. Add it. + */ + xf86Msg(X_INFO, "Loading %s\n", module); + if (wasLoaded) + *wasLoaded = 0; + + /* + * Find a free handle. + */ + new_handle = 1; + while (freeHandles[new_handle] && new_handle < MAX_HANDLE) + new_handle++; + + if (new_handle == MAX_HANDLE) { + xf86Msg(X_ERROR, "Out of loader space\n"); /* XXX */ + if (errmaj) + *errmaj = LDR_NOSPACE; + if (errmin) + *errmin = LDR_NOSPACE; + return -1; + } + + freeHandles[new_handle] = HANDLE_USED; + refCount[new_handle] = 1; + + tmp = _LoaderListPush(); + tmp->name = malloc(strlen(module) + 1); + strcpy(tmp->name, module); + tmp->cname = malloc(strlen(cname) + 1); + strcpy(tmp->cname, cname); + tmp->handle = new_handle; + tmp->module = moduleseq++; + + if ((tmp->private = DLLoadModule(tmp, flags)) == NULL) { + xf86Msg(X_ERROR, "Failed to load %s\n", module); + _LoaderListPop(new_handle); + freeHandles[new_handle] = HANDLE_FREE; + if (errmaj) + *errmaj = LDR_NOLOAD; + if (errmin) + *errmin = LDR_NOLOAD; + return -1; + } + + return new_handle; +} + +int +LoaderHandleOpen(int handle) +{ + if (handle < 0 || handle >= MAX_HANDLE) + return -1; + + if (freeHandles[handle] != HANDLE_USED) + return -1; + + refCount[handle]++; + return handle; +} + +_X_EXPORT void * +LoaderSymbol(const char *sym) +{ + return (DLFindSymbol(sym)); +} + +/* more stub */ +_X_EXPORT int +LoaderCheckUnresolved(int delay_flag) +{ + return 0; +} + +int +LoaderUnload(int handle) +{ + loaderRec fakeHead; + loaderPtr tmp = &fakeHead; + + if (handle < 0 || handle >= MAX_HANDLE) + return -1; + + /* + * check the reference count, only free it if it goes to zero + */ + if (--refCount[handle]) + return 0; + /* + * find the loaderRecs associated with this handle. + */ + + while ((tmp = _LoaderListPop(handle)) != NULL) { + if (strchr(tmp->name, ':') == NULL) { + /* It is not a member of an archive */ + xf86Msg(X_INFO, "Unloading %s\n", tmp->name); + } + DLUnloadModule(tmp->private); + free(tmp->name); + free(tmp->cname); + free(tmp); + } + + freeHandles[handle] = HANDLE_FREE; + + return 0; +} + +unsigned long LoaderOptions = 0; + +void +LoaderSetOptions(unsigned long opts) +{ + LoaderOptions |= opts; +} + +_X_EXPORT int +LoaderGetABIVersion(const char *abiclass) +{ + struct { + const char *name; + int version; + } classes[] = { + { ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion }, + { ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion }, + { ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion }, + { ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion }, + { ABI_CLASS_FONT, LoaderVersionInfo.fontVersion }, + { NULL, 0 } + }; + int i; + + for(i = 0; classes[i].name; i++) { + if(!strcmp(classes[i].name, abiclass)) { + return classes[i].version; + } + } + + return 0; +} diff --git a/xorg-server/hw/xfree86/loader/loader.h b/xorg-server/hw/xfree86/loader/loader.h new file mode 100644 index 000000000..46d4c3ed3 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/loader.h @@ -0,0 +1,106 @@ +/* + * Copyright 1995-1998 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1997-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _LOADER_H +#define _LOADER_H + +#if defined(Lynx) && defined(sun) +#define const /**/ +#endif +#include <X11/Xosdefs.h> +#include <X11/Xfuncproto.h> +#include <X11/Xmd.h> + +/* LoadModule proc flags; LD_FLAG_GLOBAL adds symbols to global + * namespace, default is to keep symbols local to module. */ +#define LD_FLAG_GLOBAL 1 + +typedef struct _loader *loaderPtr; + +/* Each module loaded has a loaderRec */ +typedef struct _loader { + int handle; /* Unique id used to remove symbols from + * this module when it is unloaded */ + int module; /* Unique id to identify compilation units */ + char *name; + char *cname; + void *private; /* format specific data */ + loaderPtr next; +} loaderRec; + +/* Compiled-in version information */ +typedef struct { + int xf86Version; + int ansicVersion; + int videodrvVersion; + int xinputVersion; + int extensionVersion; + int fontVersion; +} ModuleVersions; +extern const ModuleVersions LoaderVersionInfo; + +extern unsigned long LoaderOptions; + +/* Internal Functions */ +void LoaderDuplicateSymbol(const char *, const int); +char *_LoaderModuleToName(int); +int LoaderOpen(const char *, const char *, int, int *, int *, int *, int); +int LoaderHandleOpen(int); + +/* object to name lookup routines */ +char *_LoaderHandleToName(int handle); +char *_LoaderHandleToCanonicalName(int handle); + +/* Loader backends. */ +#include "dlloader.h" + +#endif /* _LOADER_H */ diff --git a/xorg-server/hw/xfree86/loader/loaderProcs.h b/xorg-server/hw/xfree86/loader/loaderProcs.h new file mode 100644 index 000000000..9c73db3a6 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/loaderProcs.h @@ -0,0 +1,106 @@ +/* + * Copyright 1995-1998 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _LOADERPROCS_H +#define _LOADERPROCS_H + +#undef IN_LOADER +#define IN_LOADER +#include "xf86Module.h" +#include <X11/fonts/fontmod.h> + +typedef struct module_desc { + struct module_desc *child; + struct module_desc *sib; + struct module_desc *parent; + char *name; + int handle; + ModuleSetupProc SetupProc; + ModuleTearDownProc TearDownProc; + void *TearDownData; /* returned from SetupProc */ + const XF86ModuleVersionInfo *VersionInfo; +} ModuleDesc, *ModuleDescPtr; + +/* External API for the loader */ + +void LoaderInit(void); + +ModuleDescPtr LoadDriver(const char *, const char *, int, pointer, int *, + int *); +ModuleDescPtr LoadModule(const char *, const char *, const char **, + const char **, pointer, const XF86ModReqInfo *, + int *, int *); +ModuleDescPtr LoadSubModule(ModuleDescPtr, const char *, + const char **, const char **, pointer, + const XF86ModReqInfo *, int *, int *); +ModuleDescPtr LoadSubModuleLocal(ModuleDescPtr, const char *, + const char **, const char **, + pointer, const XF86ModReqInfo *, + int *, int *); +ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent); +void LoadFont(FontModule *); +void UnloadModule(ModuleDescPtr); +void UnloadSubModule(ModuleDescPtr); +void UnloadDriver(ModuleDescPtr); +void LoaderSetPath(const char *path); +void LoaderSortExtensions(void); + +int LoaderUnload(int); +unsigned long LoaderGetModuleVersion(ModuleDescPtr mod); + +void LoaderResetOptions(void); +void LoaderSetOptions(unsigned long); + +/* Options for LoaderSetOptions */ +#define LDR_OPT_ABI_MISMATCH_NONFATAL 0x0001 + +#endif /* _LOADERPROCS_H */ diff --git a/xorg-server/hw/xfree86/loader/loadext.c b/xorg-server/hw/xfree86/loader/loadext.c new file mode 100644 index 000000000..b7523289c --- /dev/null +++ b/xorg-server/hw/xfree86/loader/loadext.c @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Maybe this file belongs elsewhere? */ + +#define LOADERDECLARATIONS +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "loaderProcs.h" +#include "misc.h" +#include "xf86.h" + +/* + * This should be static, but miinitext wants it. FIXME: make extension + * initialization not completely terrible. + */ +ExtensionModule *ExtensionModuleList = NULL; +static int numExtensionModules = 0; + +static ExtensionModule * +NewExtensionModule(void) +{ + ExtensionModule *save = ExtensionModuleList; + int n; + + /* Sanity check */ + if (!ExtensionModuleList) + numExtensionModules = 0; + + n = numExtensionModules + 1; + ExtensionModuleList = xrealloc(ExtensionModuleList, + (n + 1) * sizeof(ExtensionModule)); + if (ExtensionModuleList == NULL) { + ExtensionModuleList = save; + return NULL; + } else { + numExtensionModules++; + ExtensionModuleList[numExtensionModules].name = NULL; + return ExtensionModuleList + (numExtensionModules - 1); + } +} + +_X_EXPORT void +LoadExtension(ExtensionModule * e, Bool builtin) +{ + ExtensionModule *newext; + + if (e == NULL || e->name == NULL) + return; + + if (!(newext = NewExtensionModule())) + return; + + if (builtin) + xf86MsgVerb(X_INFO, 2, "Initializing built-in extension %s\n", + e->name); + else + xf86MsgVerb(X_INFO, 2, "Loading extension %s\n", e->name); + + newext->name = e->name; + newext->initFunc = e->initFunc; + newext->disablePtr = e->disablePtr; + newext->setupFunc = e->setupFunc; + newext->initDependencies = e->initDependencies; + + if (e->setupFunc != NULL) + e->setupFunc(); +} + +/* + * Sort ExtensionModuleList according to the initialisation order + * dependencies. The code for this is taken from BSD's tsort, + * and carries the following copyright/license: + * + * + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Michael Rendell of Memorial University of Newfoundland. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define NF_MARK 0x1 /* marker for cycle detection */ +#define NF_ACYCLIC 0x2 /* this node is cycle free */ +#define NF_NODEST 0x4 /* Unreachable */ + +typedef struct node_str NODE; +struct node_str { + NODE **n_prevp; /* pointer to previous node's n_next */ + NODE *n_next; /* next node in graph */ + NODE **n_arcs; /* array of arcs to other nodes */ + int n_narcs; /* number of arcs in n_arcs[] */ + int n_arcsize; /* size of n_arcs[] array */ + int n_refcnt; /* # of arcs pointing to this node */ + int n_flags; /* NF_* */ + const char *n_name; /* name of this node */ +}; + +static NODE *graph = NULL, **cycle_buf = NULL, **longest_cycle = NULL; +static int longest = 0; +static NODE *sorted = NULL, *last = NULL; + +/* Find a node in the graph (insert if not found) and return a pointer to it. */ +static NODE * +get_node(const char *name) +{ + NODE *n; + + for (n = graph; n && n->n_name && strcmp(n->n_name, name); + n = n->n_next) ; + if (n) + return (n); + + n = xnfalloc(sizeof(NODE)); + + n->n_narcs = 0; + n->n_arcsize = 0; + n->n_arcs = NULL; + n->n_refcnt = 0; + n->n_flags = 0; + n->n_name = name; + + /* Add to linked list. */ + if ((n->n_next = graph) != NULL) + graph->n_prevp = &n->n_next; + n->n_prevp = &graph; + graph = n; + + return (n); +} + +/* + * add an arc from node s1 to node s2 in the graph. If s1 or s2 are not in + * the graph, then add them. + */ +static void +add_arc(const char *s1, const char *s2) +{ + NODE *n1; + NODE *n2; + int bsize, i; + + n1 = get_node(s1); + + if (!strcmp(s1, s2)) + return; + + n2 = get_node(s2); + + /* + * Check if this arc is already here. + */ + for (i = 0; i < n1->n_narcs; i++) + if (n1->n_arcs[i] == n2) + return; + /* + * Add it. + */ + if (n1->n_narcs == n1->n_arcsize) { + if (!n1->n_arcsize) + n1->n_arcsize = 10; + bsize = n1->n_arcsize * sizeof(*n1->n_arcs) * 2; + n1->n_arcs = xnfrealloc(n1->n_arcs, bsize); + n1->n_arcsize = bsize / sizeof(*n1->n_arcs); + } + n1->n_arcs[n1->n_narcs++] = n2; + ++n2->n_refcnt; +} + +/* + * Clear the NODEST flag from all nodes. + */ +static void +clear_cycle(void) +{ + NODE *n; + + for (n = graph; n != NULL; n = n->n_next) + n->n_flags &= ~NF_NODEST; +} + +/* print node and remove from graph (does not actually free node) */ +static void +remove_node(NODE * n) +{ + NODE **np; + NODE *newnode; + int i; + +#ifdef DEBUG + ErrorF("%s\n", n->n_name); +#endif + newnode = xnfalloc(sizeof(NODE)); + memcpy(newnode, n, sizeof(NODE)); + if (last) + last->n_next = newnode; + else + sorted = newnode; + last = newnode; + newnode->n_next = NULL; + + for (np = n->n_arcs, i = n->n_narcs; --i >= 0; np++) + --(*np)->n_refcnt; + n->n_narcs = 0; + *n->n_prevp = n->n_next; + if (n->n_next) + n->n_next->n_prevp = n->n_prevp; +} + +static void +free_nodes(NODE * nodelist) +{ + NODE *n, *nextnode; + + for (n = nodelist; n;) { + nextnode = n->n_next; + xfree(n); + n = nextnode; + } +} + +/* look for the longest? cycle from node from to node to. */ +static int +find_cycle(NODE * from, NODE * to, int longest_len, int depth) +{ + NODE **np; + int i, len; + + /* + * avoid infinite loops and ignore portions of the graph known + * to be acyclic + */ + if (from->n_flags & (NF_NODEST | NF_MARK | NF_ACYCLIC)) + return (0); + from->n_flags |= NF_MARK; + + for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) { + cycle_buf[depth] = *np; + if (*np == to) { + if (depth + 1 > longest_len) { + longest_len = depth + 1; + memcpy((char *)longest_cycle, + (char *)cycle_buf, longest_len * sizeof(NODE *)); + } + } else { + if ((*np)->n_flags & (NF_MARK | NF_ACYCLIC | NF_NODEST)) + continue; + len = find_cycle(*np, to, longest_len, depth + 1); + +#ifdef DEBUG + ErrorF("%*s %s->%s %d\n", depth, "", + from->n_name, to->n_name, len); +#endif + + if (len == 0) + (*np)->n_flags |= NF_NODEST; + + if (len > longest_len) + longest_len = len; + + if (len > 0 && !longest) + break; + } + } + from->n_flags &= ~NF_MARK; + return (longest_len); +} + +/* do topological sort on graph */ +static void +tsort(void) +{ + NODE *n, *next; + int cnt, i; + + while (graph != NULL) { + /* + * Keep getting rid of simple cases until there are none left, + * if there are any nodes still in the graph, then there is + * a cycle in it. + */ + do { + for (cnt = 0, n = graph; n != NULL; n = next) { + next = n->n_next; + if (n->n_refcnt == 0) { + remove_node(n); + ++cnt; + } + } + } while (graph != NULL && cnt); + + if (graph == NULL) + break; + + if (!cycle_buf) { + /* + * Allocate space for two cycle logs - one to be used + * as scratch space, the other to save the longest + * cycle. + */ + for (cnt = 0, n = graph; n != NULL; n = n->n_next) + ++cnt; + cycle_buf = xnfalloc(sizeof(NODE *) * cnt); + longest_cycle = xnfalloc(sizeof(NODE *) * cnt); + if (cycle_buf == NULL || longest_cycle == NULL) + return; + } + for (n = graph; n != NULL; n = n->n_next) + if (!(n->n_flags & NF_ACYCLIC)) { + if ((cnt = find_cycle(n, n, 0, 0))) { + ErrorF("tsort: cycle in data"); + for (i = 0; i < cnt; i++) + ErrorF("%s", longest_cycle[i]->n_name); + remove_node(n); + clear_cycle(); + break; + } else { + /* to avoid further checks */ + n->n_flags |= NF_ACYCLIC; + clear_cycle(); + } + } + + if (n == NULL) + ErrorF("tsort: internal error -- could not find cycle"); + } + if (cycle_buf) + xfree(cycle_buf); + if (longest_cycle) + xfree(longest_cycle); + if (graph) + free_nodes(graph); +} + +void +LoaderSortExtensions() +{ + int i, j; + ExtensionModule *ext, *newList; + NODE *node; + + graph = NULL; + longest = 0; + sorted = NULL; + last = NULL; + cycle_buf = NULL; + longest_cycle = NULL; + + /* + * Parse list and build the graph. Enter them in reverse order + * because tsort() will reverse those that have no depedencies. + */ + for (i = numExtensionModules - 1; i >= 0; i--) { + ext = &ExtensionModuleList[i]; + add_arc(ext->name, ext->name); +#ifdef DEBUG + ErrorF("Extension %s:\n", ext->name); +#endif + if (ext->initDependencies) + for (j = 0; ext->initDependencies[j]; j++) { + add_arc(ext->initDependencies[j], ext->name); +#ifdef DEBUG + ErrorF("\t%s\n", ext->initDependencies[j]); +#endif + } + } + tsort(); + newList = xnfalloc((numExtensionModules + 1) * sizeof(ExtensionModule)); + i = 0; + for (node = sorted; node; node = node->n_next) { + for (j = 0; j < numExtensionModules; j++) + if (!strcmp(node->n_name, ExtensionModuleList[j].name)) + break; + if (j != numExtensionModules) + newList[i++] = ExtensionModuleList[j]; + } + if (sorted) + free_nodes(sorted); + newList[i].name = NULL; + xfree(ExtensionModuleList); + ExtensionModuleList = newList; +#ifdef DEBUG + for (i = 0; ExtensionModuleList[i].name; i++) + ErrorF("Extension %s\n", ExtensionModuleList[i].name); +#endif +} diff --git a/xorg-server/hw/xfree86/loader/loadfont.c b/xorg-server/hw/xfree86/loader/loadfont.c new file mode 100644 index 000000000..94d31d6c1 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/loadfont.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1998 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Maybe this file belongs in lib/font/fontfile/module/ ? */ + +#define LOADERDECLARATIONS +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "loaderProcs.h" +#include "misc.h" +#include "xf86.h" + +/* XXX this should be static, but xorgcfg needs it, nngh */ +FontModule *FontModuleList = NULL; +static int numFontModules = 0; + +static FontModule * +NewFontModule(void) +{ + FontModule *save = FontModuleList; + int n; + + /* Sanity check */ + if (!FontModuleList) + numFontModules = 0; + + n = numFontModules + 1; + FontModuleList = xrealloc(FontModuleList, (n + 1) * sizeof(FontModule)); + if (FontModuleList == NULL) { + FontModuleList = save; + return NULL; + } else { + numFontModules++; + FontModuleList[numFontModules].name = NULL; + return FontModuleList + (numFontModules - 1); + } +} + +_X_EXPORT void +LoadFont(FontModule * f) +{ + FontModule *newfont; + + if (f == NULL) + return; + + if (!(newfont = NewFontModule())) + return; + + xf86MsgVerb(X_INFO, 2, "Loading font %s\n", f->name); + + newfont->name = f->name; + newfont->initFunc = f->initFunc; + newfont->module = f->module; +} diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c new file mode 100644 index 000000000..7f3bbe49c --- /dev/null +++ b/xorg-server/hw/xfree86/loader/loadmod.c @@ -0,0 +1,1295 @@ +/* + * Copyright 1995-1998 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "os.h" +/* For stat() and related stuff */ +#define NO_OSLIB_PROTOTYPES +#include "xf86_OSlib.h" +#define LOADERDECLARATIONS +#include "loaderProcs.h" +#include "misc.h" +#include "xf86.h" +#include "xf86Priv.h" +#ifdef XINPUT +#include "xf86Xinput.h" +#endif +#include "loader.h" +#include "xf86Optrec.h" + +#include <sys/types.h> +#include <regex.h> +#include <dirent.h> +#include <limits.h> + +#define TestFree(a) if (a) { xfree (a); a = NULL; } + +typedef struct _pattern { + const char *pattern; + regex_t rex; +} PatternRec, *PatternPtr; + +/* Prototypes for static functions */ +static char *FindModule(const char *, const char *, const char **, + PatternPtr); +static Bool CheckVersion(const char *, XF86ModuleVersionInfo *, + const XF86ModReqInfo *); +static void UnloadModuleOrDriver(ModuleDescPtr mod); +static char *LoaderGetCanonicalName(const char *, PatternPtr); +static void RemoveChild(ModuleDescPtr); +static ModuleDescPtr doLoadModule(const char *, const char *, const char **, + const char **, pointer, + const XF86ModReqInfo *, int *, int *, + int flags); + +const ModuleVersions LoaderVersionInfo = { + XORG_VERSION_CURRENT, + ABI_ANSIC_VERSION, + ABI_VIDEODRV_VERSION, + ABI_XINPUT_VERSION, + ABI_EXTENSION_VERSION, + ABI_FONT_VERSION +}; + +static void +FreeStringList(char **paths) +{ + char **p; + + if (!paths) + return; + + for (p = paths; *p; p++) + xfree(*p); + + xfree(paths); +} + +static char **defaultPathList = NULL; + +static Bool +PathIsAbsolute(const char *path) +{ + return (*path == '/'); +} + +/* + * Convert a comma-separated path into a NULL-terminated array of path + * elements, rejecting any that are not full absolute paths, and appending + * a '/' when it isn't already present. + */ +static char ** +InitPathList(const char *path) +{ + char *fullpath = NULL; + char *elem = NULL; + char **list = NULL, **save = NULL; + int len; + int addslash; + int n = 0; + + if (!path) + return defaultPathList; + + fullpath = xstrdup(path); + if (!fullpath) + return NULL; + elem = strtok(fullpath, ","); + while (elem) { + if (PathIsAbsolute(elem)) + { + len = strlen(elem); + addslash = (elem[len - 1] != '/'); + if (addslash) + len++; + save = list; + list = xrealloc(list, (n + 2) * sizeof(char *)); + if (!list) { + if (save) { + save[n] = NULL; + FreeStringList(save); + } + xfree(fullpath); + return NULL; + } + list[n] = xalloc(len + 1); + if (!list[n]) { + FreeStringList(list); + xfree(fullpath); + return NULL; + } + strcpy(list[n], elem); + if (addslash) { + list[n][len - 1] = '/'; + list[n][len] = '\0'; + } + n++; + } + elem = strtok(NULL, ","); + } + if (list) + list[n] = NULL; + xfree(fullpath); + return list; +} + +static void +FreePathList(char **pathlist) +{ + if (pathlist && pathlist != defaultPathList) + FreeStringList(pathlist); +} + +void +LoaderSetPath(const char *path) +{ + if (!path) + return; + + defaultPathList = InitPathList(path); +} + +/* Standard set of module subdirectories to search, in order of preference */ +static const char *stdSubdirs[] = { + "", + "fonts/", + "input/", + "drivers/", + "multimedia/", + "extensions/", + "internal/", + NULL +}; + +/* + * Standard set of module name patterns to check, in order of preference + * These are regular expressions (suitable for use with POSIX regex(3)). + * + * This list assumes that you're an ELFish platform and therefore your + * shared libraries are named something.so. If we're ever nuts enough + * to port this DDX to, say, Darwin, we'll need to fix this. + */ +static PatternRec stdPatterns[] = { + {"^lib(.*)\\.so$",}, + {"(.*)_drv\\.so$",}, + {"(.*)\\.so$",}, + {NULL,} +}; + +static PatternPtr +InitPatterns(const char **patternlist) +{ + char errmsg[80]; + int i, e; + PatternPtr patterns = NULL; + PatternPtr p = NULL; + static int firstTime = 1; + const char **s; + + if (firstTime) { + /* precompile stdPatterns */ + firstTime = 0; + for (p = stdPatterns; p->pattern; p++) + if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) { + regerror(e, &p->rex, errmsg, sizeof(errmsg)); + FatalError("InitPatterns: regcomp error for `%s': %s\n", + p->pattern, errmsg); + } + } + + if (patternlist) { + for (i = 0, s = patternlist; *s; i++, s++) + if (*s == DEFAULT_LIST) + i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1; + patterns = xalloc((i + 1) * sizeof(PatternRec)); + if (!patterns) { + return NULL; + } + for (i = 0, s = patternlist; *s; i++, s++) + if (*s != DEFAULT_LIST) { + p = patterns + i; + p->pattern = *s; + if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) { + regerror(e, &p->rex, errmsg, sizeof(errmsg)); + ErrorF("InitPatterns: regcomp error for `%s': %s\n", + p->pattern, errmsg); + i--; + } + } else { + for (p = stdPatterns; p->pattern; p++, i++) + patterns[i] = *p; + if (p != stdPatterns) + i--; + } + patterns[i].pattern = NULL; + } else + patterns = stdPatterns; + return patterns; +} + +static void +FreePatterns(PatternPtr patterns) +{ + if (patterns && patterns != stdPatterns) + xfree(patterns); +} + +static const char ** +InitSubdirs(const char **subdirlist) +{ + int i; + const char **tmp_subdirlist = NULL; + char **subdirs = NULL; + const char **s, **stmp = NULL; + const char *osname; + const char *slash; + int oslen = 0, len; + Bool indefault; + + if (subdirlist == NULL) { + subdirlist = tmp_subdirlist = xalloc(2 * sizeof(char *)); + if (subdirlist == NULL) + return NULL; + subdirlist[0] = DEFAULT_LIST; + subdirlist[1] = NULL; + } + + LoaderGetOS(&osname, NULL, NULL, NULL); + oslen = strlen(osname); + + { + /* Count number of entries and check for invalid paths */ + for (i = 0, s = subdirlist; *s; i++, s++) { + if (*s == DEFAULT_LIST) { + i += sizeof(stdSubdirs) / sizeof(stdSubdirs[0]) - 1 - 1; + } else { + /* + * Path validity check. Don't allow absolute paths, or + * paths containing "..". To catch absolute paths on + * platforms that use driver letters, don't allow the ':' + * character to appear at all. + */ + if (**s == '/' || **s == '\\' || strchr(*s, ':') || + strstr(*s, "..")) { + xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s); + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return NULL; + } + } + } + subdirs = xalloc((i * 2 + 1) * sizeof(char *)); + if (!subdirs) { + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return NULL; + } + i = 0; + s = subdirlist; + indefault = FALSE; + while (*s) { + if (*s == DEFAULT_LIST) { + /* Divert to the default list */ + indefault = TRUE; + stmp = ++s; + s = stdSubdirs; + } + len = strlen(*s); + if (**s && (*s)[len - 1] != '/') { + slash = "/"; + len++; + } else + slash = ""; + len += oslen + 2; + if (!(subdirs[i] = xalloc(len))) { + while (--i >= 0) + xfree(subdirs[i]); + xfree(subdirs); + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return NULL; + } + /* tack on the OS name */ + sprintf(subdirs[i], "%s%s%s/", *s, slash, osname); + i++; + /* path as given */ + subdirs[i] = xstrdup(*s); + i++; + s++; + if (indefault && !s) { + /* revert back to the main list */ + indefault = FALSE; + s = stmp; + } + } + subdirs[i] = NULL; + } + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return (const char **)subdirs; +} + +static void +FreeSubdirs(const char **subdirs) +{ + const char **s; + + if (subdirs) { + for (s = subdirs; *s; s++) + xfree(*s); + xfree(subdirs); + } +} + +static char * +FindModuleInSubdir(const char *dirpath, const char *module) +{ + struct dirent *direntry = NULL; + DIR *dir = NULL; + char *ret = NULL, tmpBuf[PATH_MAX]; + struct stat stat_buf; + + dir = opendir(dirpath); + if (!dir) + return NULL; + + while ((direntry = readdir(dir))) { + if (direntry->d_name[0] == '.') + continue; + if ((stat(direntry->d_name, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) { + snprintf(tmpBuf, PATH_MAX, "%s/%s", dirpath, direntry->d_name); + if ((ret = FindModuleInSubdir(tmpBuf, module))) + break; + continue; + } + + snprintf(tmpBuf, PATH_MAX, "lib%s.so", module); + if (strcmp(direntry->d_name, tmpBuf) == 0) { + ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2); + sprintf(ret, "%s/%s", dirpath, tmpBuf); + break; + } + + snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module); + if (strcmp(direntry->d_name, tmpBuf) == 0) { + ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2); + sprintf(ret, "%s/%s", dirpath, tmpBuf); + break; + } + + snprintf(tmpBuf, PATH_MAX, "%s.so", module); + if (strcmp(direntry->d_name, tmpBuf) == 0) { + ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2); + sprintf(ret, "%s/%s", dirpath, tmpBuf); + break; + } + } + + closedir(dir); + return ret; +} + +static char * +FindModule(const char *module, const char *dirname, const char **subdirlist, + PatternPtr patterns) +{ + char buf[PATH_MAX + 1]; + char *dirpath = NULL; + char *name = NULL; + int dirlen; + const char **subdirs = NULL; + const char **s; + + dirpath = (char *)dirname; + if (strlen(dirpath) > PATH_MAX) + return NULL; + + subdirs = InitSubdirs(subdirlist); + if (!subdirs) + return NULL; + + for (s = subdirs; *s; s++) { + if ((dirlen = strlen(dirpath) + strlen(*s)) > PATH_MAX) + continue; + strcpy(buf, dirpath); + strcat(buf, *s); + if ((name = FindModuleInSubdir(buf, module))) + break; + } + + FreeSubdirs(subdirs); + if (dirpath != dirname) + xfree(dirpath); + + return name; +} + +_X_EXPORT char ** +LoaderListDirs(const char **subdirlist, const char **patternlist) +{ + char buf[PATH_MAX + 1]; + char **pathlist; + char **elem; + const char **subdirs; + const char **s; + PatternPtr patterns; + PatternPtr p; + DIR *d; + struct dirent *dp; + regmatch_t match[2]; + struct stat stat_buf; + int len, dirlen; + char *fp; + char **listing = NULL; + char **save; + int n = 0; + + if (!(pathlist = InitPathList(NULL))) + return NULL; + if (!(subdirs = InitSubdirs(subdirlist))) { + FreePathList(pathlist); + return NULL; + } + if (!(patterns = InitPatterns(patternlist))) { + FreePathList(pathlist); + FreeSubdirs(subdirs); + return NULL; + } + + for (elem = pathlist; *elem; elem++) { + for (s = subdirs; *s; s++) { + if ((dirlen = strlen(*elem) + strlen(*s)) > PATH_MAX) + continue; + strcpy(buf, *elem); + strcat(buf, *s); + fp = buf + dirlen; + if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && + (d = opendir(buf))) { + if (buf[dirlen - 1] != '/') { + buf[dirlen++] = '/'; + fp++; + } + while ((dp = readdir(d))) { + if (dirlen + strlen(dp->d_name) > PATH_MAX) + continue; + strcpy(fp, dp->d_name); + if (!(stat(buf, &stat_buf) == 0 && + S_ISREG(stat_buf.st_mode))) + continue; + for (p = patterns; p->pattern; p++) { + if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 && + match[1].rm_so != -1) { + len = match[1].rm_eo - match[1].rm_so; + save = listing; + listing = xrealloc(listing, + (n + 2) * sizeof(char *)); + if (!listing) { + if (save) { + save[n] = NULL; + FreeStringList(save); + } + FreePathList(pathlist); + FreeSubdirs(subdirs); + FreePatterns(patterns); + return NULL; + } + listing[n] = xalloc(len + 1); + if (!listing[n]) { + FreeStringList(listing); + FreePathList(pathlist); + FreeSubdirs(subdirs); + FreePatterns(patterns); + return NULL; + } + strncpy(listing[n], dp->d_name + match[1].rm_so, + len); + listing[n][len] = '\0'; + n++; + break; + } + } + } + closedir(d); + } + } + } + if (listing) + listing[n] = NULL; + return listing; +} + +_X_EXPORT void +LoaderFreeDirList(char **list) +{ + FreeStringList(list); +} + +static Bool +CheckVersion(const char *module, XF86ModuleVersionInfo * data, + const XF86ModReqInfo * req) +{ + int vercode[4]; + char verstr[4]; + long ver = data->xf86version; + MessageType errtype; + + xf86Msg(X_INFO, "Module %s: vendor=\"%s\"\n", + data->modname ? data->modname : "UNKNOWN!", + data->vendor ? data->vendor : "UNKNOWN!"); + + /* Check for the different scheme used in XFree86 4.0.x releases: + * ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha) + * Since it wasn't used in 4.1.0 or later, limit to versions in the 4.0.x + * range, which limits the overlap with the new version scheme to conflicts + * with 6.71.8.764 through 6.72.39.934. + */ + if ((ver > (4 << 24)) && (ver < ( (4 << 24) + (1 << 17)))) { + /* 4.0.x and earlier */ + verstr[1] = verstr[3] = 0; + verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0; + ver >>= 5; + verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0; + ver >>= 5; + vercode[2] = ver & 0x7f; + ver >>= 7; + vercode[1] = ver & 0x7f; + ver >>= 7; + vercode[0] = ver; + xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]); + if (vercode[2] != 0) + xf86ErrorF(".%d", vercode[2]); + xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2, + data->majorversion, data->minorversion, data->patchlevel); + } else { + vercode[0] = ver / 10000000; + vercode[1] = (ver / 100000) % 100; + vercode[2] = (ver / 1000) % 100; + vercode[3] = ver % 1000; + xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1], + vercode[2]); + if (vercode[3] != 0) + xf86ErrorF(".%d", vercode[3]); + xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion, + data->minorversion, data->patchlevel); + } + + if (data->moduleclass) + xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass); + + ver = -1; + if (data->abiclass) { + int abimaj, abimin; + int vermaj, vermin; + + if (!strcmp(data->abiclass, ABI_CLASS_ANSIC)) + ver = LoaderVersionInfo.ansicVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV)) + ver = LoaderVersionInfo.videodrvVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT)) + ver = LoaderVersionInfo.xinputVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION)) + ver = LoaderVersionInfo.extensionVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_FONT)) + ver = LoaderVersionInfo.fontVersion; + + abimaj = GET_ABI_MAJOR(data->abiversion); + abimin = GET_ABI_MINOR(data->abiversion); + xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n", + data->abiclass, abimaj, abimin); + if (ver != -1) { + vermaj = GET_ABI_MAJOR(ver); + vermin = GET_ABI_MINOR(ver); + if (abimaj != vermaj) { + if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) + errtype = X_WARNING; + else + errtype = X_ERROR; + xf86MsgVerb(errtype, 0, + "module ABI major version (%d) doesn't" + " match the server's version (%d)\n", + abimaj, vermaj); + if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) + return FALSE; + } else if (abimin > vermin) { + if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) + errtype = X_WARNING; + else + errtype = X_ERROR; + xf86MsgVerb(errtype, 0, + "module ABI minor version (%d) is " + "newer than the server's version " + "(%d)\n", abimin, vermin); + if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) + return FALSE; + } + } + } + + /* Check against requirements that the caller has specified */ + if (req) { + if (req->majorversion != MAJOR_UNSPEC) { + if (data->majorversion != req->majorversion) { + xf86MsgVerb(X_WARNING, 2, "module major version (%d) " + "doesn't match required major version (%d)\n", + data->majorversion, req->majorversion); + return FALSE; + } else if (req->minorversion != MINOR_UNSPEC) { + if (data->minorversion < req->minorversion) { + xf86MsgVerb(X_WARNING, 2, "module minor version (%d) " + "is less than the required minor version (%d)\n", + data->minorversion, req->minorversion); + return FALSE; + } else if (data->minorversion == req->minorversion && + req->patchlevel != PATCH_UNSPEC) { + if (data->patchlevel < req->patchlevel) { + xf86MsgVerb(X_WARNING, 2, "module patch level (%d) " + "is less than the required patch level (%d)\n", + data->patchlevel, req->patchlevel); + return FALSE; + } + } + } + } + if (req->moduleclass) { + if (!data->moduleclass || + strcmp(req->moduleclass, data->moduleclass)) { + xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match " + "the required class (%s)\n", + data->moduleclass ? data->moduleclass : "<NONE>", + req->moduleclass); + return FALSE; + } + } else if (req->abiclass != ABI_CLASS_NONE) { + if (!data->abiclass || strcmp(req->abiclass, data->abiclass)) { + xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the " + "required ABI class (%s)\n", + data->abiclass ? data->abiclass : "<NONE>", + req->abiclass); + return FALSE; + } + } + if ((req->abiclass != ABI_CLASS_NONE) && + req->abiversion != ABI_VERS_UNSPEC) { + int reqmaj, reqmin, maj, min; + + reqmaj = GET_ABI_MAJOR(req->abiversion); + reqmin = GET_ABI_MINOR(req->abiversion); + maj = GET_ABI_MAJOR(data->abiversion); + min = GET_ABI_MINOR(data->abiversion); + if (maj != reqmaj) { + xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't " + "match the required ABI major version (%d)\n", + maj, reqmaj); + return FALSE; + } + /* XXX Maybe this should be the other way around? */ + if (min > reqmin) { + xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) " + "is newer than that available (%d)\n", min, reqmin); + return FALSE; + } + } + } + return TRUE; +} + +static ModuleDescPtr +AddSibling(ModuleDescPtr head, ModuleDescPtr new) +{ + new->sib = head; + return (new); +} + +_X_EXPORT ModuleDescPtr +LoadSubModule(ModuleDescPtr parent, const char *module, + const char **subdirlist, const char **patternlist, + pointer options, const XF86ModReqInfo * modreq, + int *errmaj, int *errmin) +{ + ModuleDescPtr submod; + + xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module); + + if (PathIsAbsolute(module)) { + xf86Msg(X_ERROR, + "LoadSubModule: Absolute module path not permitted: \"%s\"\n", + module); + if (errmaj) + *errmaj = LDR_BADUSAGE; + if (errmin) + *errmin = 0; + return NULL; + } + + submod = doLoadModule(module, NULL, subdirlist, patternlist, options, + modreq, errmaj, errmin, LD_FLAG_GLOBAL); + if (submod && submod != (ModuleDescPtr) 1) { + parent->child = AddSibling(parent->child, submod); + submod->parent = parent; + } + return submod; +} + +static ModuleDescPtr +NewModuleDesc(const char *name) +{ + ModuleDescPtr mdp = xalloc(sizeof(ModuleDesc)); + + if (mdp) { + mdp->child = NULL; + mdp->sib = NULL; + mdp->parent = NULL; + mdp->name = xstrdup(name); + mdp->handle = -1; + mdp->SetupProc = NULL; + mdp->TearDownProc = NULL; + mdp->TearDownData = NULL; + } + + return (mdp); +} + +_X_EXPORT ModuleDescPtr +DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) +{ + ModuleDescPtr ret; + + if (!mod) + return NULL; + + ret = NewModuleDesc(mod->name); + if (ret == NULL) + return NULL; + + if (LoaderHandleOpen(mod->handle) == -1) + return NULL; + + ret->handle = mod->handle; + ret->SetupProc = mod->SetupProc; + ret->TearDownProc = mod->TearDownProc; + ret->TearDownData = NULL; + ret->child = DuplicateModule(mod->child, ret); + ret->sib = DuplicateModule(mod->sib, parent); + ret->parent = parent; + ret->VersionInfo = mod->VersionInfo; + + return ret; +} + +static const char *compiled_in_modules[] = { + "ddc", + "i2c", + "ramdac", + NULL +}; + +static ModuleDescPtr +doLoadModule(const char *module, const char *path, const char **subdirlist, + const char **patternlist, pointer options, + const XF86ModReqInfo * modreq, + int *errmaj, int *errmin, int flags) +{ + XF86ModuleData *initdata = NULL; + char **pathlist = NULL; + char *found = NULL; + char *name = NULL; + char **path_elem = NULL; + char *p = NULL; + ModuleDescPtr ret = NULL; + int wasLoaded = 0; + PatternPtr patterns = NULL; + int noncanonical = 0; + char *m = NULL; + const char **cim; + + xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"\n", module); + + for (cim = compiled_in_modules; *cim; cim++) + if (!strcmp (module, *cim)) + { + xf86MsgVerb(X_INFO, 3, "Module \"%s\" already built-in\n", module); + return (ModuleDescPtr) 1; + } + + patterns = InitPatterns(patternlist); + name = LoaderGetCanonicalName(module, patterns); + noncanonical = (name && strcmp(module, name) != 0); + if (noncanonical) { + xf86ErrorFVerb(3, " (%s)\n", name); + xf86MsgVerb(X_WARNING, 1, + "LoadModule: given non-canonical module name \"%s\"\n", + module); + m = name; + } else { + xf86ErrorFVerb(3, "\n"); + m = (char *)module; + } + if (!name) { + if (errmaj) + *errmaj = LDR_BADUSAGE; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + ret = NewModuleDesc(name); + if (!ret) { + if (errmaj) + *errmaj = LDR_NOMEM; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + + pathlist = InitPathList(path); + if (!pathlist) { + /* This could be a malloc failure too */ + if (errmaj) + *errmaj = LDR_BADUSAGE; + if (errmin) + *errmin = 1; + goto LoadModule_fail; + } + + /* + * if the module name is not a full pathname, we need to + * check the elements in the path + */ + if (PathIsAbsolute(module)) + found = xstrdup(module); + path_elem = pathlist; + while (!found && *path_elem != NULL) { + found = FindModule(m, *path_elem, subdirlist, patterns); + path_elem++; + /* + * When the module name isn't the canonical name, search for the + * former if no match was found for the latter. + */ + if (!*path_elem && m == name) { + path_elem = pathlist; + m = (char *)module; + } + } + + /* + * did we find the module? + */ + if (!found) { + xf86Msg(X_WARNING, "Warning, couldn't open module %s\n", module); + if (errmaj) + *errmaj = LDR_NOENT; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + ret->handle = LoaderOpen(found, name, 0, + errmaj, errmin, &wasLoaded, flags); + if (ret->handle < 0) + goto LoadModule_fail; + + /* drop any explicit suffix from the module name */ + p = strchr(name, '.'); + if (p) + *p = '\0'; + + /* + * now check if the special data object <modulename>ModuleData is + * present. + */ + p = xalloc(strlen(name) + strlen("ModuleData") + 1); + if (!p) { + if (errmaj) + *errmaj = LDR_NOMEM; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + strcpy(p, name); + strcat(p, "ModuleData"); + initdata = LoaderSymbol(p); + if (initdata) { + ModuleSetupProc setup; + ModuleTearDownProc teardown; + XF86ModuleVersionInfo *vers; + + vers = initdata->vers; + setup = initdata->setup; + teardown = initdata->teardown; + + if (!wasLoaded) { + if (vers) { + if (!CheckVersion(module, vers, modreq)) { + if (errmaj) + *errmaj = LDR_MISMATCH; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + } else { + xf86Msg(X_ERROR, + "LoadModule: Module %s does not supply" + " version information\n", module); + if (errmaj) + *errmaj = LDR_INVALID; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + } + if (setup) + ret->SetupProc = setup; + if (teardown) + ret->TearDownProc = teardown; + ret->VersionInfo = vers; + } else { + /* No initdata is OK for external modules */ + if (options == EXTERN_MODULE) + goto LoadModule_exit; + + /* no initdata, fail the load */ + xf86Msg(X_ERROR, "LoadModule: Module %s does not have a %s " + "data object.\n", module, p); + if (errmaj) + *errmaj = LDR_INVALID; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + if (ret->SetupProc) { + ret->TearDownData = ret->SetupProc(ret, options, errmaj, errmin); + if (!ret->TearDownData) { + goto LoadModule_fail; + } + } else if (options) { + xf86Msg(X_WARNING, "Module Options present, but no SetupProc " + "available for %s\n", module); + } + goto LoadModule_exit; + + LoadModule_fail: + UnloadModule(ret); + ret = NULL; + + LoadModule_exit: + FreePathList(pathlist); + FreePatterns(patterns); + TestFree(found); + TestFree(name); + TestFree(p); + + /* + * If you need to do something to keep the + * instruction cache in sync with the main + * memory before jumping to that code, you may + * do it here. + */ +#ifdef __alpha__ + istream_mem_barrier(); +#endif + return ret; +} + +/* + * LoadModule: load a module + * + * module The module name. Normally this is not a filename but the + * module's "canonical name. A full pathname is, however, + * also accepted. + * path A comma separated list of module directories. + * subdirlist A NULL terminated list of subdirectories to search. When + * NULL, the default "stdSubdirs" list is used. The default + * list is also substituted for entries with value DEFAULT_LIST. + * patternlist A NULL terminated list of regular expressions used to find + * module filenames. Each regex should contain exactly one + * subexpression that corresponds to the canonical module name. + * When NULL, the default "stdPatterns" list is used. The + * default list is also substituted for entries with value + * DEFAULT_LIST. + * options A NULL terminated list of Options that are passed to the + * module's SetupProc function. + * modreq An optional XF86ModReqInfo* containing + * version/ABI/vendor-ABI requirements to check for when + * loading the module. The following fields of the + * XF86ModReqInfo struct are checked: + * majorversion - must match the module's majorversion exactly + * minorversion - the module's minorversion must be >= this + * patchlevel - the module's minorversion.patchlevel must be + * >= this. Patchlevel is ignored when + * minorversion is not set. + * abiclass - (string) must match the module's abiclass + * abiversion - must be consistent with the module's + * abiversion (major equal, minor no older) + * moduleclass - string must match the module's moduleclass + * string + * "don't care" values are ~0 for numbers, and NULL for strings + * errmaj Major error return. + * errmin Minor error return. + * + */ +ModuleDescPtr +LoadModule(const char *module, const char *path, const char **subdirlist, + const char **patternlist, pointer options, + const XF86ModReqInfo * modreq, int *errmaj, int *errmin) +{ + return doLoadModule(module, path, subdirlist, patternlist, options, + modreq, errmaj, errmin, LD_FLAG_GLOBAL); +} + +void +UnloadModule(ModuleDescPtr mod) +{ + UnloadModuleOrDriver(mod); +} + +static void +UnloadModuleOrDriver(ModuleDescPtr mod) +{ + if (mod == (ModuleDescPtr) 1) + return; + + if (mod == NULL || mod->name == NULL) + return; + + xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name); + + if ((mod->TearDownProc) && (mod->TearDownData)) + mod->TearDownProc(mod->TearDownData); + LoaderUnload(mod->handle); + + if (mod->child) + UnloadModuleOrDriver(mod->child); + if (mod->sib) + UnloadModuleOrDriver(mod->sib); + TestFree(mod->name); + xfree(mod); +#ifdef __alpha__ + istream_mem_barrier(); +#endif +} + +_X_EXPORT void +UnloadSubModule(ModuleDescPtr mod) +{ + if (mod == NULL || mod->name == NULL) + return; + + xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name); + + if ((mod->TearDownProc) && (mod->TearDownData)) + mod->TearDownProc(mod->TearDownData); + LoaderUnload(mod->handle); + + RemoveChild(mod); + + if (mod->child) + UnloadModuleOrDriver(mod->child); + + TestFree(mod->name); + xfree(mod); +} + +static void +FreeModuleDesc(ModuleDescPtr head) +{ + ModuleDescPtr sibs, prev; + + if (head == (ModuleDescPtr) 1) + return; + if (head->child) + FreeModuleDesc(head->child); + sibs = head; + while (sibs) { + prev = sibs; + sibs = sibs->sib; + TestFree(prev->name); + xfree(prev); + } +} + +static void +RemoveChild(ModuleDescPtr child) +{ + ModuleDescPtr mdp; + ModuleDescPtr prevsib; + ModuleDescPtr parent; + + if (!child->parent) + return; + + parent = child->parent; + if (parent->child == child) { + parent->child = child->sib; + return; + } + + prevsib = parent->child; + mdp = prevsib->sib; + while (mdp && mdp != child) { + prevsib = mdp; + mdp = mdp->sib; + } + if (mdp == child) + prevsib->sib = child->sib; + return; +} + +_X_EXPORT void +LoaderErrorMsg(const char *name, const char *modname, int errmaj, int errmin) +{ + const char *msg; + MessageType type = X_ERROR; + + switch (errmaj) { + case LDR_NOERROR: + msg = "no error"; + break; + case LDR_NOMEM: + msg = "out of memory"; + break; + case LDR_NOENT: + msg = "module does not exist"; + break; + case LDR_NOSUBENT: + msg = "a required submodule could not be loaded"; + break; + case LDR_NOSPACE: + msg = "too many modules"; + break; + case LDR_NOMODOPEN: + msg = "open failed"; + break; + case LDR_UNKTYPE: + msg = "unknown module type"; + break; + case LDR_NOLOAD: + msg = "loader failed"; + break; + case LDR_ONCEONLY: + msg = "already loaded"; + type = X_INFO; + break; + case LDR_NOPORTOPEN: + msg = "port open failed"; + break; + case LDR_NOHARDWARE: + msg = "no hardware found"; + break; + case LDR_MISMATCH: + msg = "module requirement mismatch"; + break; + case LDR_BADUSAGE: + msg = "invalid argument(s) to LoadModule()"; + break; + case LDR_INVALID: + msg = "invalid module"; + break; + case LDR_BADOS: + msg = "module doesn't support this OS"; + break; + case LDR_MODSPECIFIC: + msg = "module-specific error"; + break; + default: + msg = "unknown error"; + } + if (name) + xf86Msg(type, "%s: Failed to load module \"%s\" (%s, %d)\n", + name, modname, msg, errmin); + else + xf86Msg(type, "Failed to load module \"%s\" (%s, %d)\n", + modname, msg, errmin); +} + +/* Given a module path or file name, return the module's canonical name */ +static char * +LoaderGetCanonicalName(const char *modname, PatternPtr patterns) +{ + char *str; + const char *s; + int len; + PatternPtr p; + regmatch_t match[2]; + + /* Strip off any leading path */ + s = strrchr(modname, '/'); + if (s == NULL) + s = modname; + else + s++; + + /* Find the first regex that is matched */ + for (p = patterns; p->pattern; p++) + if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) { + len = match[1].rm_eo - match[1].rm_so; + str = xalloc(len + 1); + if (!str) + return NULL; + strncpy(str, s + match[1].rm_so, len); + str[len] = '\0'; + return str; + } + + /* If there is no match, return the whole name minus the leading path */ + return xstrdup(s); +} + +/* + * Return the module version information. + */ +unsigned long +LoaderGetModuleVersion(ModuleDescPtr mod) +{ + if (!mod || mod == (ModuleDescPtr) 1 || !mod->VersionInfo) + return 0; + + return MODULE_VERSION_NUMERIC(mod->VersionInfo->majorversion, + mod->VersionInfo->minorversion, + mod->VersionInfo->patchlevel); +} diff --git a/xorg-server/hw/xfree86/loader/misym.c b/xorg-server/hw/xfree86/loader/misym.c new file mode 100644 index 000000000..aa712c03a --- /dev/null +++ b/xorg-server/hw/xfree86/loader/misym.c @@ -0,0 +1,211 @@ +/* + * + * Copyright 1995,96 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "sym.h" +#include "misc.h" +#include "mi.h" +#include "mibank.h" +#include "miwideline.h" +#include "mibstore.h" +#include "cursor.h" +#include "mipointer.h" +#include "migc.h" +#include "miline.h" +#include "mizerarc.h" +#include "mifillarc.h" +#include "micmap.h" +#include "mioverlay.h" +#ifdef PANORAMIX +#include "resource.h" +#include "panoramiX.h" +#endif +#ifdef RENDER +#include "mipict.h" +#endif +#ifdef COMPOSITE +#include "cw.h" +#endif +#ifdef DAMAGE +#include "damage.h" +#endif + +/* mi things */ + +extern miPointerSpriteFuncRec miSpritePointerFuncs; + +_X_HIDDEN void *miLookupTab[] = { + SYMFUNC(miClearToBackground) + SYMFUNC(miSendGraphicsExpose) + SYMFUNC(miModifyPixmapHeader) + SYMFUNC(miHandleValidateExposures) + SYMFUNC(miSetShape) + SYMFUNC(miChangeBorderWidth) + SYMFUNC(miShapedWindowIn) + SYMFUNC(miRectIn) + SYMFUNC(miZeroClipLine) + SYMFUNC(miZeroDashLine) + SYMFUNC(miClearDrawable) + SYMFUNC(miPolyPoint) + SYMFUNC(miStepDash) + SYMFUNC(miIntersect) + SYMFUNC(miRegionAppend) + SYMFUNC(miRegionCopy) + SYMFUNC(miRegionDestroy) + SYMFUNC(miRegionEmpty) + SYMFUNC(miRegionExtents) + SYMFUNC(miRegionInit) + SYMFUNC(miRegionNotEmpty) + SYMFUNC(miRegionEqual) + SYMFUNC(miRegionReset) + SYMFUNC(miRegionUninit) + SYMFUNC(miRegionValidate) + SYMFUNC(miTranslateRegion) + SYMFUNC(miHandleExposures) + SYMFUNC(miPolyFillRect) + SYMFUNC(miPolyFillArc) + SYMFUNC(miImageGlyphBlt) + SYMFUNC(miPolyGlyphBlt) + SYMFUNC(miFillPolygon) + SYMFUNC(miFillConvexPoly) + SYMFUNC(miPolySegment) + SYMFUNC(miZeroLine) + SYMFUNC(miWideLine) + SYMFUNC(miWideDash) + SYMFUNC(miZeroPolyArc) + SYMFUNC(miPolyArc) + SYMFUNC(miCreateGCOps) + SYMFUNC(miDestroyGCOps) + SYMFUNC(miComputeCompositeClip) + SYMFUNC(miChangeGC) + SYMFUNC(miCopyGC) + SYMFUNC(miDestroyGC) + SYMFUNC(miChangeClip) + SYMFUNC(miDestroyClip) + SYMFUNC(miCopyClip) + SYMFUNC(miPolyRectangle) + SYMFUNC(miPolyText8) + SYMFUNC(miPolyText16) + SYMFUNC(miImageText8) + SYMFUNC(miImageText16) + SYMFUNC(miRegionCreate) + SYMFUNC(miPaintWindow) + SYMFUNC(miZeroArcSetup) + SYMFUNC(miFillArcSetup) + SYMFUNC(miFillArcSliceSetup) + SYMFUNC(miFindMaxBand) + SYMFUNC(miClipSpans) + SYMFUNC(miAllocateGCPrivateIndex) + SYMFUNC(miScreenInit) + SYMFUNC(miGetScreenPixmap) + SYMFUNC(miSetScreenPixmap) + SYMFUNC(miPointerCurrentScreen) + SYMFUNC(miRectAlloc) + SYMFUNC(miInitializeBackingStore) + SYMFUNC(miInitializeBanking) + SYMFUNC(miModifyBanking) + SYMFUNC(miCopyPlane) + SYMFUNC(miCopyArea) + SYMFUNC(miCreateScreenResources) + SYMFUNC(miGetImage) + SYMFUNC(miPutImage) + SYMFUNC(miPushPixels) + SYMFUNC(miPointerInitialize) + SYMFUNC(miPointerPosition) + SYMFUNC(miRecolorCursor) + SYMFUNC(miPointerWarpCursor) + SYMFUNC(miDCInitialize) + SYMFUNC(miRectsToRegion) + SYMFUNC(miPointInRegion) + SYMFUNC(miInverse) + SYMFUNC(miSubtract) + SYMFUNC(miUnion) + SYMFUNC(miPolyBuildEdge) + SYMFUNC(miPolyBuildPoly) + SYMFUNC(miRoundJoinClip) + SYMFUNC(miRoundCapClip) + SYMFUNC(miSetZeroLineBias) + SYMFUNC(miResolveColor) + SYMFUNC(miInitializeColormap) + SYMFUNC(miInstallColormap) + SYMFUNC(miUninstallColormap) + SYMFUNC(miListInstalledColormaps) + SYMFUNC(miExpandDirectColors) + SYMFUNC(miCreateDefColormap) + SYMFUNC(miClearVisualTypes) + SYMFUNC(miSetVisualTypes) + SYMFUNC(miSetVisualTypesAndMasks) + SYMFUNC(miGetDefaultVisualMask) + SYMFUNC(miSetPixmapDepths) + SYMFUNC(miInitVisuals) + SYMFUNC(miWindowExposures) + SYMFUNC(miSegregateChildren) + SYMFUNC(miHookInitVisuals) + SYMFUNC(miPointerAbsoluteCursor) + SYMFUNC(miOverlayCopyUnderlay) + SYMFUNC(miOverlaySetTransFunction) + SYMFUNC(miOverlayCollectUnderlayRegions) + SYMFUNC(miInitOverlay) + SYMFUNC(miOverlayComputeCompositeClip) + SYMFUNC(miOverlayGetPrivateClips) + SYMFUNC(miOverlaySetRootClip) + SYMVAR(miEmptyBox) + SYMVAR(miEmptyData) + SYMVAR(miZeroLineScreenKey) + SYMVAR(miSpritePointerFuncs) + SYMVAR(miPointerScreenKey) + SYMVAR(miInstalledMaps) + SYMVAR(miInitVisualsProc) +#ifdef DAMAGE + SYMFUNC(DamageDamageRegion) +#endif +}; diff --git a/xorg-server/hw/xfree86/loader/os.c b/xorg-server/hw/xfree86/loader/os.c new file mode 100644 index 000000000..12cf3d859 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/os.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1999-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "loaderProcs.h" + +/* + * OSNAME is a standard form of the OS name that may be used by the + * loader and by OS-specific modules. OSNAME here is different from what's in + * dix-config.h + */ + +#undef OSNAME +#if defined(__linux__) +#define OSNAME "linux" +#elif defined(__FreeBSD__) +#define OSNAME "freebsd" +#elif defined(__DragonFly__) +#define OSNAME "dragonfly" +#elif defined(__NetBSD__) +#define OSNAME "netbsd" +#elif defined(__OpenBSD__) +#define OSNAME "openbsd" +#elif defined(Lynx) +#define OSNAME "lynxos" +#elif defined(__GNU__) +#define OSNAME "hurd" +#elif defined(__SCO__) +#define OSNAME "sco" +#elif defined(DGUX) +#define OSNAME "dgux" +#elif defined(ISC) +#define OSNAME "isc" +#elif defined(SVR4) && defined(sun) +#define OSNAME "solaris" +#elif defined(SVR5) +#define OSNAME "svr5" +#elif defined(SVR4) +#define OSNAME "svr4" +#else +#define OSNAME "unknown" +#endif + +/* Return the OS name, and run-time OS version */ + +_X_EXPORT void +LoaderGetOS(const char **name, int *major, int *minor, int *teeny) +{ + if (name) + *name = OSNAME; + + /* reporting runtime versions isn't supported yet */ +} diff --git a/xorg-server/hw/xfree86/loader/sym.h b/xorg-server/hw/xfree86/loader/sym.h new file mode 100644 index 000000000..e708a92f9 --- /dev/null +++ b/xorg-server/hw/xfree86/loader/sym.h @@ -0,0 +1,41 @@ +/* + * Copyright 1995,96 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _SYM_H +#define _SYM_H + +extern void *dixLookupTab[]; +extern void *extLookupTab[]; +extern void *fontLookupTab[]; +extern void *miLookupTab[]; +extern void *xfree86LookupTab[]; + +#define SYMFUNC( func ) &func, +#define SYMFUNCALIAS( name, func ) &func, +#define SYMVAR( var ) &var, +#define SYMVARALIAS( name, var ) &var, + +#endif /* _SYM_H */ diff --git a/xorg-server/hw/xfree86/loader/xf86sym.c b/xorg-server/hw/xfree86/loader/xf86sym.c new file mode 100644 index 000000000..24fc44c1b --- /dev/null +++ b/xorg-server/hw/xfree86/loader/xf86sym.c @@ -0,0 +1,1080 @@ +/* + * Copyright 1995,96 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <fcntl.h> +#include <setjmp.h> +#include "sym.h" +#include "misc.h" +#include "mi.h" +#include "cursor.h" +#include "mipointer.h" +#include "loaderProcs.h" +#include "xf86Pci.h" +#include "xf86.h" +#include "xf86Resources.h" +#include "xf86_OSproc.h" +#include "xf86Parser.h" +#include "xf86Config.h" +#ifdef XINPUT +# include "xf86Xinput.h" +#endif +#include "xf86OSmouse.h" +#ifdef XV +#include "xf86xv.h" +#include "xf86xvmc.h" +#endif +#include "xf86cmap.h" +#include "xf86fbman.h" +#include "dgaproc.h" +#ifdef DPMSExtension +#include "dpmsproc.h" +#endif +#include "vidmodeproc.h" +#include "xf86miscproc.h" +#include "loader.h" +#include "xisb.h" +#include "vbe.h" +#ifndef __OpenBSD__ +#include "xf86sbusBus.h" +#endif +#include "compiler.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#ifdef RANDR +#include "xf86RandR12.h" +#endif +#include "xf86DDC.h" +#include "edid.h" +#include "xf86Cursor.h" +#include "xf86RamDac.h" +#include "BT.h" +#include "IBM.h" +#include "TI.h" + +#ifndef HAS_GLIBC_SIGSETJMP +#if defined(setjmp) && defined(__GNU_LIBRARY__) && \ + (!defined(__GLIBC__) || (__GLIBC__ < 2) || \ + ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 3))) +#define HAS_GLIBC_SIGSETJMP 1 +#endif +#endif + +#if defined(__alpha__) +# ifdef linux +extern unsigned long _bus_base(void); +extern void _outb(char val, unsigned short port); +extern void _outw(short val, unsigned short port); +extern void _outl(int val, unsigned short port); +extern unsigned int _inb(unsigned short port); +extern unsigned int _inw(unsigned short port); +extern unsigned int _inl(unsigned short port); +# endif + +# ifdef __FreeBSD__ +# include <sys/types.h> +extern void outb(u_int32_t port, u_int8_t val); +extern void outw(u_int32_t port, u_int16_t val); +extern void outl(u_int32_t port, u_int32_t val); +extern u_int8_t inb(u_int32_t port); +extern u_int16_t inw(u_int32_t port); +extern u_int32_t inl(u_int32_t port); +# endif + +extern void *__divl(long, long); +extern void *__reml(long, long); +extern void *__divlu(long, long); +extern void *__remlu(long, long); +extern void *__divq(long, long); +extern void *__divqu(long, long); +extern void *__remq(long, long); +extern void *__remqu(long, long); +#endif + +#if defined(__sparc__) && defined(__FreeBSD__) +extern float _Qp_qtos(unsigned int *); +extern double _Qp_qtod(unsigned int *); +extern unsigned long long _Qp_qtoux(unsigned int *); +extern void _Qp_dtoq(unsigned int *, double); +extern void _Qp_uitoq(unsigned int *, unsigned int); +#endif + +#if defined(__GNUC__) +extern long __div64(long, long); +extern long __divdf3(long, long); +extern long __divdi3(long, long); +extern long __divsf3(long, long); +extern long __divsi3(long, long); +extern long __moddi3(long, long); +extern long __modsi3(long, long); + +extern long __mul64(long, long); +extern long __muldf3(long, long); +extern long __muldi3(long, long); +extern long __mulsf3(long, long); +extern long __mulsi3(long, long); +extern long __udivdi3(long, long); +extern long __udivsi3(long, long); +extern long __umoddi3(long, long); +extern long __umodsi3(long, long); + +#pragma weak __div64 +#pragma weak __divdf3 +#pragma weak __divdi3 +#pragma weak __divsf3 +#pragma weak __divsi3 +#pragma weak __moddi3 +#pragma weak __modsi3 +#pragma weak __mul64 +#pragma weak __muldf3 +#pragma weak __muldi3 +#pragma weak __mulsf3 +#pragma weak __mulsi3 +#pragma weak __udivdi3 +#pragma weak __udivsi3 +#pragma weak __umoddi3 +#pragma weak __umodsi3 +#endif + +#if defined(__arm__) && defined(__linux__) +#include <sys/io.h> +#endif + +#if defined(__powerpc__) && (defined(Lynx) || defined(linux)) +void _restf14(); +void _restf17(); +void _restf18(); +void _restf19(); +void _restf20(); +void _restf22(); +void _restf23(); +void _restf24(); +void _restf25(); +void _restf26(); +void _restf27(); +void _restf28(); +void _restf29(); +void _savef14(); +void _savef17(); +void _savef18(); +void _savef19(); +void _savef20(); +void _savef22(); +void _savef23(); +void _savef24(); +void _savef25(); +void _savef26(); +void _savef27(); +void _savef28(); +void _savef29(); + +/* even if we compile without -DNO_INLINE we still provide + * the usual port i/o functions for module use + */ + +extern volatile unsigned char *ioBase; + +/* XXX Should get all of these from elsewhere */ +#ifndef linux +extern void outb(IOADDRESS, unsigned char); +extern void outw(IOADDRESS, unsigned short); +extern void outl(IOADDRESS, unsigned int); +extern unsigned int inb(IOADDRESS); +extern unsigned int inw(IOADDRESS); +extern unsigned int inl(IOADDRESS); +#endif +extern void stl_brx(unsigned long, volatile unsigned char *, int); +extern void stw_brx(unsigned short, volatile unsigned char *, int); +extern unsigned long ldl_brx(volatile unsigned char *, int); +extern unsigned short ldw_brx(volatile unsigned char *, int); +#endif + +/* XFree86 things */ + +_X_HIDDEN void *xfree86LookupTab[] = { + + /* Public OSlib functions */ + SYMFUNC(xf86ReadBIOS) + SYMFUNC(xf86EnableIO) + SYMFUNC(xf86DisableIO) + SYMFUNC(xf86DisableInterrupts) + SYMFUNC(xf86EnableInterrupts) + SYMFUNC(xf86LinearVidMem) + SYMFUNC(xf86CheckMTRR) + SYMFUNC(xf86MapVidMem) + SYMFUNC(xf86UnMapVidMem) + SYMFUNC(xf86MapReadSideEffects) + SYMFUNC(xf86MapDomainMemory) + SYMFUNC(xf86UDelay) + SYMFUNC(xf86IODelay) + SYMFUNC(xf86SlowBcopy) + SYMFUNC(xf86SetReallySlowBcopy) +#ifdef __alpha__ + SYMFUNC(xf86SlowBCopyToBus) + SYMFUNC(xf86SlowBCopyFromBus) +#endif + SYMFUNC(xf86BusToMem) + SYMFUNC(xf86MemToBus) + SYMFUNC(xf86OpenSerial) + SYMFUNC(xf86SetSerial) + SYMFUNC(xf86SetSerialSpeed) + SYMFUNC(xf86ReadSerial) + SYMFUNC(xf86WriteSerial) + SYMFUNC(xf86CloseSerial) + SYMFUNC(xf86WaitForInput) + SYMFUNC(xf86SerialSendBreak) + SYMFUNC(xf86FlushInput) + SYMFUNC(xf86SetSerialModemState) + SYMFUNC(xf86GetSerialModemState) + SYMFUNC(xf86SerialModemSetBits) + SYMFUNC(xf86SerialModemClearBits) + SYMFUNC(xf86LoadKernelModule) + SYMFUNC(xf86OSMouseInit) + SYMFUNC(xf86AgpGARTSupported) + SYMFUNC(xf86GetAGPInfo) + SYMFUNC(xf86AcquireGART) + SYMFUNC(xf86ReleaseGART) + SYMFUNC(xf86AllocateGARTMemory) + SYMFUNC(xf86DeallocateGARTMemory) + SYMFUNC(xf86BindGARTMemory) + SYMFUNC(xf86UnbindGARTMemory) + SYMFUNC(xf86EnableAGP) + SYMFUNC(xf86GARTCloseScreen) +#ifdef XINPUT + SYMFUNC(XisbNew) + SYMFUNC(XisbFree) + SYMFUNC(XisbRead) + SYMFUNC(XisbWrite) + SYMFUNC(XisbTrace) + SYMFUNC(XisbBlockDuration) +#endif + + /* xf86Bus.c */ + SYMFUNC(xf86CheckPciSlot) + SYMFUNC(xf86ClaimPciSlot) + SYMFUNC(xf86ClaimIsaSlot) + SYMFUNC(xf86ClaimFbSlot) + SYMFUNC(xf86ClaimNoSlot) + SYMFUNC(xf86ParsePciBusString) + SYMFUNC(xf86ComparePciBusString) + SYMFUNC(xf86FormatPciBusNumber) + SYMFUNC(xf86ParseIsaBusString) + SYMFUNC(xf86EnableAccess) + SYMFUNC(xf86SetCurrentAccess) + SYMFUNC(xf86IsPrimaryPci) + SYMFUNC(xf86IsPrimaryIsa) + SYMFUNC(xf86PrintResList) + SYMFUNC(xf86AddResToList) + SYMFUNC(xf86JoinResLists) + SYMFUNC(xf86DupResList) + SYMFUNC(xf86FreeResList) + SYMFUNC(xf86ClaimFixedResources) + SYMFUNC(xf86AddEntityToScreen) + SYMFUNC(xf86SetEntityInstanceForScreen) + SYMFUNC(xf86RemoveEntityFromScreen) + SYMFUNC(xf86GetEntityInfo) + SYMFUNC(xf86GetNumEntityInstances) + SYMFUNC(xf86GetDevFromEntity) + SYMFUNC(xf86GetPciInfoForEntity) + SYMFUNC(xf86SetEntityFuncs) + SYMFUNC(xf86DeallocateResourcesForEntity) + SYMFUNC(xf86RegisterResources) + SYMFUNC(xf86CheckPciMemBase) + SYMFUNC(xf86SetAccessFuncs) + SYMFUNC(xf86IsEntityPrimary) + SYMFUNC(xf86SetOperatingState) + SYMFUNC(xf86EnterServerState) + SYMFUNC(xf86ChkConflict) + SYMFUNC(xf86FindScreenForEntity) + SYMFUNC(xf86RegisterStateChangeNotificationCallback) + SYMFUNC(xf86DeregisterStateChangeNotificationCallback) + SYMFUNC(xf86NoSharedResources) + /* Shared Accel Accessor Functions */ + SYMFUNC(xf86GetLastScrnFlag) + SYMFUNC(xf86SetLastScrnFlag) + SYMFUNC(xf86IsEntityShared) + SYMFUNC(xf86SetEntityShared) + SYMFUNC(xf86IsEntitySharable) + SYMFUNC(xf86SetEntitySharable) + SYMFUNC(xf86IsPrimInitDone) + SYMFUNC(xf86SetPrimInitDone) + SYMFUNC(xf86ClearPrimInitDone) + SYMFUNC(xf86AllocateEntityPrivateIndex) + SYMFUNC(xf86GetEntityPrivate) + + /* xf86Configure.c */ + SYMFUNC(xf86AddDeviceToConfigure) + + /* xf86Cursor.c */ + SYMFUNC(xf86GetPointerScreenFuncs) + + /* xf86DGA.c */ + /* For drivers */ + SYMFUNC(DGAInit) + SYMFUNC(DGAReInitModes) + /* For extmod */ + SYMFUNC(DGAAvailable) + SYMFUNC(DGAActive) + SYMFUNC(DGASetMode) + SYMFUNC(DGASetInputMode) + SYMFUNC(DGASelectInput) + SYMFUNC(DGAGetViewportStatus) + SYMFUNC(DGASetViewport) + SYMFUNC(DGAInstallCmap) + SYMFUNC(DGASync) + SYMFUNC(DGAFillRect) + SYMFUNC(DGABlitRect) + SYMFUNC(DGABlitTransRect) + SYMFUNC(DGAGetModes) + SYMFUNC(DGAGetOldDGAMode) + SYMFUNC(DGAGetModeInfo) + SYMFUNC(DGAChangePixmapMode) + SYMFUNC(DGACreateColormap) + SYMFUNC(DGAOpenFramebuffer) + SYMFUNC(DGACloseFramebuffer) + + /* xf86DPMS.c */ + SYMFUNC(xf86DPMSInit) + + /* xf86Events.c */ + SYMFUNC(SetTimeSinceLastInputEvent) + SYMFUNC(xf86AddInputHandler) + SYMFUNC(xf86RemoveInputHandler) + SYMFUNC(xf86DisableInputHandler) + SYMFUNC(xf86EnableInputHandler) + SYMFUNC(xf86AddEnabledDevice) + SYMFUNC(xf86RemoveEnabledDevice) + SYMFUNC(xf86InterceptSignals) + SYMFUNC(xf86InterceptSigIll) + SYMFUNC(xf86EnableVTSwitch) + + /* xf86Helper.c */ + SYMFUNC(xf86AddDriver) + SYMFUNC(xf86AddInputDriver) + SYMFUNC(xf86DeleteDriver) + SYMFUNC(xf86DeleteInput) + SYMFUNC(xf86AllocateInput) + SYMFUNC(xf86AllocateScreen) + SYMFUNC(xf86DeleteScreen) + SYMFUNC(xf86AllocateScrnInfoPrivateIndex) + SYMFUNC(xf86AddPixFormat) + SYMFUNC(xf86SetDepthBpp) + SYMFUNC(xf86PrintDepthBpp) + SYMFUNC(xf86SetWeight) + SYMFUNC(xf86SetDefaultVisual) + SYMFUNC(xf86SetGamma) + SYMFUNC(xf86SetDpi) + SYMFUNC(xf86SetBlackWhitePixels) + SYMFUNC(xf86EnableDisableFBAccess) + SYMFUNC(xf86VDrvMsgVerb) + SYMFUNC(xf86DrvMsgVerb) + SYMFUNC(xf86DrvMsg) + SYMFUNC(xf86MsgVerb) + SYMFUNC(xf86Msg) + SYMFUNC(xf86ErrorFVerb) + SYMFUNC(xf86ErrorF) + SYMFUNC(xf86TokenToString) + SYMFUNC(xf86StringToToken) + SYMFUNC(xf86ShowClocks) + SYMFUNC(xf86PrintChipsets) + SYMFUNC(xf86MatchDevice) + SYMFUNC(xf86MatchPciInstances) + SYMFUNC(xf86MatchIsaInstances) + SYMFUNC(xf86GetVerbosity) + SYMFUNC(xf86GetVisualName) + SYMFUNC(xf86GetPix24) + SYMFUNC(xf86GetDepth) + SYMFUNC(xf86GetWeight) + SYMFUNC(xf86GetGamma) + SYMFUNC(xf86GetFlipPixels) + SYMFUNC(xf86GetServerName) + SYMFUNC(xf86ServerIsExiting) + SYMFUNC(xf86ServerIsOnlyDetecting) + SYMFUNC(xf86ServerIsOnlyProbing) + SYMFUNC(xf86ServerIsResetting) + SYMFUNC(xf86CaughtSignal) + SYMFUNC(xf86GetVidModeAllowNonLocal) + SYMFUNC(xf86GetVidModeEnabled) + SYMFUNC(xf86GetModInDevAllowNonLocal) + SYMFUNC(xf86GetModInDevEnabled) + SYMFUNC(xf86GetAllowMouseOpenFail) + SYMFUNC(xf86CommonSpecialKey) + SYMFUNC(xf86IsPc98) + SYMFUNC(xf86DisableRandR) + SYMFUNC(xf86GetRotation) + SYMFUNC(xf86GetVersion) + SYMFUNC(xf86GetModuleVersion) + SYMFUNC(xf86GetClocks) + SYMFUNC(xf86SetPriority) + SYMFUNC(xf86LoadDrvSubModule) + SYMFUNC(xf86LoadSubModule) + SYMFUNC(xf86LoadOneModule) + SYMFUNC(xf86UnloadSubModule) + SYMFUNC(xf86LoaderCheckSymbol) + SYMFUNC(xf86LoaderRefSymLists) + SYMFUNC(xf86LoaderRefSymbols) + SYMFUNC(xf86LoaderReqSymLists) + SYMFUNC(xf86LoaderReqSymbols) + SYMFUNC(xf86SetBackingStore) + SYMFUNC(xf86SetSilkenMouse) + /* SYMFUNC(xf86NewSerialNumber) */ + SYMFUNC(xf86FindXvOptions) + SYMFUNC(xf86GetOS) + SYMFUNC(xf86ConfigPciEntity) + SYMFUNC(xf86ConfigIsaEntity) + SYMFUNC(xf86ConfigFbEntity) + SYMFUNC(xf86ConfigActivePciEntity) + SYMFUNC(xf86ConfigActiveIsaEntity) + SYMFUNC(xf86ConfigPciEntityInactive) + SYMFUNC(xf86ConfigIsaEntityInactive) + SYMFUNC(xf86IsScreenPrimary) + SYMFUNC(xf86RegisterRootWindowProperty) + SYMFUNC(xf86IsUnblank) + +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + /* xf86sbusBus.c */ + SYMFUNC(xf86MatchSbusInstances) + SYMFUNC(xf86GetSbusInfoForEntity) + SYMFUNC(xf86GetEntityForSbusInfo) + SYMFUNC(xf86SbusUseBuiltinMode) + SYMFUNC(xf86MapSbusMem) + SYMFUNC(xf86UnmapSbusMem) + SYMFUNC(xf86SbusHideOsHwCursor) + SYMFUNC(xf86SbusSetOsHwCursorCmap) + SYMFUNC(xf86SbusHandleColormaps) + SYMFUNC(sparcPromInit) + SYMFUNC(sparcPromClose) + SYMFUNC(sparcPromGetProperty) + SYMFUNC(sparcPromGetBool) +#endif + + /* xf86Init.c */ + SYMFUNC(xf86GetPixFormat) + SYMFUNC(xf86GetBppFromDepth) + + /* xf86Mode.c */ + SYMFUNC(xf86GetNearestClock) + SYMFUNC(xf86ModeStatusToString) + SYMFUNC(xf86LookupMode) + SYMFUNC(xf86CheckModeForMonitor) + SYMFUNC(xf86InitialCheckModeForDriver) + SYMFUNC(xf86CheckModeForDriver) + SYMFUNC(xf86ValidateModes) + SYMFUNC(xf86DeleteMode) + SYMFUNC(xf86PruneDriverModes) + SYMFUNC(xf86SetCrtcForModes) + SYMFUNC(xf86PrintModes) + SYMFUNC(xf86ShowClockRanges) + + /* xf86Option.c */ + SYMFUNC(xf86CollectOptions) + SYMFUNC(xf86CollectInputOptions) + /* Merging of XInput stuff */ + SYMFUNC(xf86AddNewOption) + SYMFUNC(xf86NewOption) + SYMFUNC(xf86NextOption) + SYMFUNC(xf86OptionListCreate) + SYMFUNC(xf86OptionListMerge) + SYMFUNC(xf86OptionListFree) + SYMFUNC(xf86OptionName) + SYMFUNC(xf86OptionValue) + SYMFUNC(xf86OptionListReport) + SYMFUNC(xf86SetIntOption) + SYMFUNC(xf86SetRealOption) + SYMFUNC(xf86SetStrOption) + SYMFUNC(xf86SetBoolOption) + SYMFUNC(xf86CheckIntOption) + SYMFUNC(xf86CheckRealOption) + SYMFUNC(xf86CheckStrOption) + SYMFUNC(xf86CheckBoolOption) + SYMFUNC(xf86ReplaceIntOption) + SYMFUNC(xf86ReplaceRealOption) + SYMFUNC(xf86ReplaceStrOption) + SYMFUNC(xf86ReplaceBoolOption) + SYMFUNC(xf86FindOption) + SYMFUNC(xf86FindOptionValue) + SYMFUNC(xf86MarkOptionUsed) + SYMFUNC(xf86MarkOptionUsedByName) + SYMFUNC(xf86CheckIfOptionUsed) + SYMFUNC(xf86CheckIfOptionUsedByName) + SYMFUNC(xf86ShowUnusedOptions) + SYMFUNC(xf86ProcessOptions) + SYMFUNC(xf86TokenToOptinfo) + SYMFUNC(xf86TokenToOptName) + SYMFUNC(xf86IsOptionSet) + SYMFUNC(xf86GetOptValString) + SYMFUNC(xf86GetOptValInteger) + SYMFUNC(xf86GetOptValULong) + SYMFUNC(xf86GetOptValReal) + SYMFUNC(xf86GetOptValFreq) + SYMFUNC(xf86GetOptValBool) + SYMFUNC(xf86ReturnOptValBool) + SYMFUNC(xf86NameCmp) + SYMFUNC(xf86InitValuatorAxisStruct) + SYMFUNC(xf86InitValuatorDefaults) + + /* xf86fbman.c */ + SYMFUNC(xf86InitFBManager) + SYMFUNC(xf86InitFBManagerArea) + SYMFUNC(xf86InitFBManagerRegion) + SYMFUNC(xf86InitFBManagerLinear) + SYMFUNC(xf86RegisterFreeBoxCallback) + SYMFUNC(xf86FreeOffscreenArea) + SYMFUNC(xf86AllocateOffscreenArea) + SYMFUNC(xf86AllocateLinearOffscreenArea) + SYMFUNC(xf86ResizeOffscreenArea) + SYMFUNC(xf86FBManagerRunning) + SYMFUNC(xf86QueryLargestOffscreenArea) + SYMFUNC(xf86PurgeUnlockedOffscreenAreas) + SYMFUNC(xf86RegisterOffscreenManager) + SYMFUNC(xf86AllocateOffscreenLinear) + SYMFUNC(xf86ResizeOffscreenLinear) + SYMFUNC(xf86QueryLargestOffscreenLinear) + SYMFUNC(xf86FreeOffscreenLinear) + + /* xf86cmap.c */ + SYMFUNC(xf86HandleColormaps) + SYMFUNC(xf86GetGammaRampSize) + SYMFUNC(xf86GetGammaRamp) + SYMFUNC(xf86ChangeGammaRamp) + + /* xf86RandR.c */ +#ifdef RANDR + SYMFUNC(xf86RandRSetNewVirtualAndDimensions) +#endif + + /* xf86xv.c */ +#ifdef XV + SYMFUNC(xf86XVScreenInit) + SYMFUNC(xf86XVRegisterGenericAdaptorDriver) + SYMFUNC(xf86XVListGenericAdaptors) + SYMFUNC(xf86XVRegisterOffscreenImages) + SYMFUNC(xf86XVQueryOffscreenImages) + SYMFUNC(xf86XVAllocateVideoAdaptorRec) + SYMFUNC(xf86XVFreeVideoAdaptorRec) + SYMFUNC(xf86XVFillKeyHelper) + SYMFUNC(xf86XVFillKeyHelperDrawable) + SYMFUNC(xf86XVClipVideoHelper) + SYMFUNC(xf86XVCopyYUV12ToPacked) + SYMFUNC(xf86XVCopyPacked) + + /* xf86xvmc.c */ + SYMFUNC(xf86XvMCScreenInit) + SYMFUNC(xf86XvMCCreateAdaptorRec) + SYMFUNC(xf86XvMCDestroyAdaptorRec) +#endif + + /* xf86VidMode.c */ + SYMFUNC(VidModeExtensionInit) +#ifdef XF86VIDMODE + SYMFUNC(VidModeGetCurrentModeline) + SYMFUNC(VidModeGetFirstModeline) + SYMFUNC(VidModeGetNextModeline) + SYMFUNC(VidModeDeleteModeline) + SYMFUNC(VidModeZoomViewport) + SYMFUNC(VidModeGetViewPort) + SYMFUNC(VidModeSetViewPort) + SYMFUNC(VidModeSwitchMode) + SYMFUNC(VidModeLockZoom) + SYMFUNC(VidModeGetMonitor) + SYMFUNC(VidModeGetNumOfClocks) + SYMFUNC(VidModeGetClocks) + SYMFUNC(VidModeCheckModeForMonitor) + SYMFUNC(VidModeCheckModeForDriver) + SYMFUNC(VidModeSetCrtcForMode) + SYMFUNC(VidModeAddModeline) + SYMFUNC(VidModeGetDotClock) + SYMFUNC(VidModeGetNumOfModes) + SYMFUNC(VidModeSetGamma) + SYMFUNC(VidModeGetGamma) + SYMFUNC(VidModeCreateMode) + SYMFUNC(VidModeCopyMode) + SYMFUNC(VidModeGetModeValue) + SYMFUNC(VidModeSetModeValue) + SYMFUNC(VidModeGetMonitorValue) + SYMFUNC(VidModeSetGammaRamp) + SYMFUNC(VidModeGetGammaRamp) + SYMFUNC(VidModeGetGammaRampSize) +#endif + + /* xf86Versions.c */ + SYMFUNC(xf86GetBuiltinInterfaceVersion) + SYMFUNC(xf86RegisterBuiltinInterfaceVersion) + + /* xf86MiscExt.c */ +#ifdef XF86MISC + SYMFUNC(MiscExtGetMouseSettings) + SYMFUNC(MiscExtGetMouseValue) + SYMFUNC(MiscExtSetMouseValue) + SYMFUNC(MiscExtSetMouseDevice) + SYMFUNC(MiscExtGetKbdSettings) + SYMFUNC(MiscExtGetKbdValue) + SYMFUNC(MiscExtSetKbdValue) + SYMFUNC(MiscExtSetGrabKeysState) + SYMFUNC(MiscExtCreateStruct) + SYMFUNC(MiscExtDestroyStruct) + SYMFUNC(MiscExtApply) + SYMFUNC(MiscExtGetFilePaths) + SYMFUNC(MiscExtPassMessage) +#endif + + /* Misc */ + SYMFUNC(GetTimeInMillis) + + /* xf86Xinput.c */ +#ifdef XINPUT + SYMFUNC(xf86ProcessCommonOptions) + SYMFUNC(xf86PostMotionEvent) + SYMFUNC(xf86PostProximityEvent) + SYMFUNC(xf86PostButtonEvent) + SYMFUNC(xf86PostKeyEvent) + SYMFUNC(xf86PostKeyboardEvent) + SYMFUNC(xf86FirstLocalDevice) + SYMFUNC(xf86ActivateDevice) + SYMFUNC(xf86XInputSetScreen) + SYMFUNC(xf86ScaleAxis) +#endif +#ifdef DPMSExtension + SYMFUNC(DPMSGet) + SYMFUNC(DPMSSet) + SYMFUNC(DPMSSupported) +#endif +/* xf86Debug.c */ +#ifdef BUILDDEBUG + SYMFUNC(xf86Break1) + SYMFUNC(xf86Break2) + SYMFUNC(xf86Break3) + SYMFUNC(xf86SPTimestamp) + SYMFUNC(xf86STimestamp) +#endif + + SYMFUNC(pciTag) + SYMFUNC(pciBusAddrToHostAddr) + SYMFUNC(xf86scanpci) + + /* Loader functions */ + SYMFUNC(LoadSubModule) + SYMFUNC(DuplicateModule) + SYMFUNC(LoaderErrorMsg) + SYMFUNC(LoaderCheckUnresolved) + SYMFUNC(LoadExtension) + SYMFUNC(LoadFont) + SYMFUNC(LoaderReqSymbols) + SYMFUNC(LoaderReqSymLists) + SYMFUNC(LoaderRefSymbols) + SYMFUNC(LoaderRefSymLists) + SYMFUNC(UnloadSubModule) + SYMFUNC(LoaderSymbol) + SYMFUNC(LoaderListDirs) + SYMFUNC(LoaderFreeDirList) + SYMFUNC(LoaderGetOS) + SYMFUNC(LoaderGetABIVersion) + +#ifdef XF86DRI + /* + * These may have more general uses, but for now, they are only used + * by the DRI. Loading them only when the DRI is built may make porting + * (the non-DRI portions of the X server) easier. + */ + SYMFUNC(xf86InstallSIGIOHandler) + SYMFUNC(xf86RemoveSIGIOHandler) +# if defined(__alpha__) && defined(linux) + SYMFUNC(_bus_base) +# endif +#endif + SYMFUNC(xf86BlockSIGIO) + SYMFUNC(xf86UnblockSIGIO) + +#if defined(__alpha__) + SYMFUNC(__divl) + SYMFUNC(__reml) + SYMFUNC(__divlu) + SYMFUNC(__remlu) + SYMFUNC(__divq) + SYMFUNC(__divqu) + SYMFUNC(__remq) + SYMFUNC(__remqu) + +# ifdef linux + SYMFUNC(_outw) + SYMFUNC(_outb) + SYMFUNC(_outl) + SYMFUNC(_inb) + SYMFUNC(_inw) + SYMFUNC(_inl) + SYMFUNC(_alpha_outw) + SYMFUNC(_alpha_outb) + SYMFUNC(_alpha_outl) + SYMFUNC(_alpha_inb) + SYMFUNC(_alpha_inw) + SYMFUNC(_alpha_inl) +# else + SYMFUNC(outw) + SYMFUNC(outb) + SYMFUNC(outl) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) +# endif + SYMFUNC(xf86ReadMmio32) + SYMFUNC(xf86ReadMmio16) + SYMFUNC(xf86ReadMmio8) + SYMFUNC(xf86WriteMmio32) + SYMFUNC(xf86WriteMmio16) + SYMFUNC(xf86WriteMmio8) + SYMFUNC(xf86WriteMmioNB32) + SYMFUNC(xf86WriteMmioNB16) + SYMFUNC(xf86WriteMmioNB8) +#endif +#if defined(sun) && defined(SVR4) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) + SYMFUNC(outb) + SYMFUNC(outw) + SYMFUNC(outl) +#endif +#if defined(__powerpc__) && !defined(__OpenBSD__) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) + SYMFUNC(outb) + SYMFUNC(outw) + SYMFUNC(outl) +# if defined(NO_INLINE) || defined(Lynx) + SYMFUNC(mem_barrier) + SYMFUNC(ldl_u) + SYMFUNC(eieio) + SYMFUNC(ldl_brx) + SYMFUNC(ldw_brx) + SYMFUNC(stl_brx) + SYMFUNC(stw_brx) + SYMFUNC(ldq_u) + SYMFUNC(ldw_u) + SYMFUNC(stl_u) + SYMFUNC(stq_u) + SYMFUNC(stw_u) + SYMFUNC(write_mem_barrier) +# endif +# if defined(Lynx) + SYMFUNC(_restf14) + SYMFUNC(_restf17) + SYMFUNC(_restf18) + SYMFUNC(_restf19) + SYMFUNC(_restf20) + SYMFUNC(_restf22) + SYMFUNC(_restf23) + SYMFUNC(_restf24) + SYMFUNC(_restf25) + SYMFUNC(_restf26) + SYMFUNC(_restf27) + SYMFUNC(_restf28) + SYMFUNC(_restf29) + SYMFUNC(_savef14) + SYMFUNC(_savef17) + SYMFUNC(_savef18) + SYMFUNC(_savef19) + SYMFUNC(_savef20) + SYMFUNC(_savef22) + SYMFUNC(_savef23) + SYMFUNC(_savef24) + SYMFUNC(_savef25) + SYMFUNC(_savef26) + SYMFUNC(_savef27) + SYMFUNC(_savef28) + SYMFUNC(_savef29) +# endif +# if PPCIO_DEBUG + SYMFUNC(debug_inb) + SYMFUNC(debug_inw) + SYMFUNC(debug_inl) + SYMFUNC(debug_outb) + SYMFUNC(debug_outw) + SYMFUNC(debug_outl) +# endif +#endif +#if defined(__GNUC__) +#if !defined(Lynx) + SYMFUNC(__div64) +#endif +#if !defined(Lynx) /* FIXME: test on others than x86 and !3.1.0a/x86 */ + SYMFUNC(__divdf3) +#endif + SYMFUNC(__divdi3) +#if !defined(Lynx) + SYMFUNC(__divsf3) + SYMFUNC(__divsi3) +#endif + SYMFUNC(__moddi3) +#if !defined(Lynx) + SYMFUNC(__modsi3) +#endif +#if !defined(Lynx) + SYMFUNC(__mul64) +#endif +#if !defined(Lynx) + SYMFUNC(__muldf3) +#endif + SYMFUNC(__muldi3) +#if !defined(Lynx) + SYMFUNC(__mulsf3) + SYMFUNC(__mulsi3) + SYMFUNC(__udivdi3) + SYMFUNC(__udivsi3) +#endif + SYMFUNC(__umoddi3) +#if !defined(Lynx) + SYMFUNC(__umodsi3) +#endif +#endif +#if defined(__ia64__) + SYMFUNC(outw) + SYMFUNC(outb) + SYMFUNC(outl) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) +#endif +#if defined(__arm__) + SYMFUNC(outw) + SYMFUNC(outb) + SYMFUNC(outl) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) +#endif + +#ifdef __FreeBSD__ +#if defined(__sparc__) + SYMFUNC(_Qp_qtos) + SYMFUNC(_Qp_qtod) + SYMFUNC(_Qp_qtoux) + SYMFUNC(_Qp_uitoq) + SYMFUNC(_Qp_dtoq) +#endif +#endif + + /* General variables (from xf86.h) */ + SYMVAR(xf86ScreenKey) + SYMVAR(xf86PixmapKey) + SYMVAR(xf86Screens) + SYMVAR(byte_reversed) + SYMVAR(xf86inSuspend) + + /* predefined resource lists from xf86Bus.h */ + SYMVAR(resVgaExclusive) + SYMVAR(resVgaShared) + SYMVAR(resVgaMemShared) + SYMVAR(resVgaIoShared) + SYMVAR(resVgaUnusedExclusive) + SYMVAR(resVgaUnusedShared) + SYMVAR(resVgaSparseExclusive) + SYMVAR(resVgaSparseShared) + SYMVAR(res8514Exclusive) + SYMVAR(res8514Shared) + +#if defined(__powerpc__) && (!defined(NO_INLINE) || defined(Lynx)) + SYMVAR(ioBase) +#endif + + /* Globals from xf86Globals.c and xf86Priv.h */ + SYMVAR(xf86ConfigDRI) + + /* Globals from xf86Configure.c */ + SYMVAR(ConfiguredMonitor) + + /* Pci.c */ + SYMVAR(pciNumBuses) + + /* modes */ + SYMVAR(xf86CrtcConfigPrivateIndex) + SYMFUNC(xf86CrtcConfigInit) + SYMFUNC(xf86CrtcConfigPrivateIndex) + SYMFUNC(xf86CrtcCreate) + SYMFUNC(xf86CrtcDestroy) + SYMFUNC(xf86CrtcInUse) + SYMFUNC(xf86CrtcSetScreenSubpixelOrder) + SYMFUNC(xf86RotateCloseScreen) + SYMFUNC(xf86CrtcRotate) + SYMFUNC(xf86CrtcSetMode) + SYMFUNC(xf86CrtcSetSizeRange) + SYMFUNC(xf86CrtcScreenInit) + SYMFUNC(xf86CVTMode) + SYMFUNC(xf86GTFMode) + SYMFUNC(xf86DisableUnusedFunctions) + SYMFUNC(xf86DPMSSet) + SYMFUNC(xf86DuplicateMode) + SYMFUNC(xf86DuplicateModes) + SYMFUNC(xf86GetDefaultModes) + SYMFUNC(xf86GetMonitorModes) + SYMFUNC(xf86InitialConfiguration) + SYMFUNC(xf86ModeHSync) + SYMFUNC(xf86ModesAdd) + SYMFUNC(xf86ModesEqual) + SYMFUNC(xf86ModeVRefresh) + SYMFUNC(xf86ModeWidth) + SYMFUNC(xf86ModeHeight) + SYMFUNC(xf86OutputCreate) + SYMFUNC(xf86OutputDestroy) + SYMFUNC(xf86OutputGetEDID) + SYMFUNC(xf86ConnectorGetName) + SYMFUNC(xf86OutputGetEDIDModes) + SYMFUNC(xf86OutputRename) + SYMFUNC(xf86OutputUseScreenMonitor) + SYMFUNC(xf86OutputSetEDID) + SYMFUNC(xf86OutputFindClosestMode) + SYMFUNC(xf86PrintModeline) + SYMFUNC(xf86ProbeOutputModes) + SYMFUNC(xf86PruneInvalidModes) + SYMFUNC(xf86SetModeCrtc) + SYMFUNC(xf86SetModeDefaultName) + SYMFUNC(xf86SetScrnInfoModes) + SYMFUNC(xf86SetDesiredModes) + SYMFUNC(xf86SetSingleMode) + SYMFUNC(xf86ValidateModesClocks) + SYMFUNC(xf86ValidateModesFlags) + SYMFUNC(xf86ValidateModesSize) + SYMFUNC(xf86ValidateModesSync) + SYMFUNC(xf86ValidateModesUserConfig) + SYMFUNC(xf86DiDGAInit) + SYMFUNC(xf86DiDGAReInit) + SYMFUNC(xf86DDCGetModes) + SYMFUNC(xf86SaveScreen) +#ifdef RANDR + SYMFUNC(xf86RandR12CreateScreenResources) + SYMFUNC(xf86RandR12GetOriginalVirtualSize) + SYMFUNC(xf86RandR12GetRotation) + SYMFUNC(xf86RandR12Init) + SYMFUNC(xf86RandR12PreInit) + SYMFUNC(xf86RandR12SetConfig) + SYMFUNC(xf86RandR12SetRotations) + SYMFUNC(xf86RandR12TellChanged) +#endif + SYMFUNC(xf86_cursors_init) + SYMFUNC(xf86_reload_cursors) + SYMFUNC(xf86_show_cursors) + SYMFUNC(xf86_hide_cursors) + SYMFUNC(xf86_cursors_fini) + SYMFUNC(xf86_crtc_clip_video_helper) + + SYMFUNC(xf86DoEDID_DDC1) + SYMFUNC(xf86DoEDID_DDC2) + SYMFUNC(xf86InterpretEDID) + SYMFUNC(xf86PrintEDID) + SYMFUNC(xf86DDCMonitorSet) + SYMFUNC(xf86SetDDCproperties) + + SYMFUNC(xf86CreateI2CBusRec) + SYMFUNC(xf86CreateI2CDevRec) + SYMFUNC(xf86DestroyI2CBusRec) + SYMFUNC(xf86DestroyI2CDevRec) + SYMFUNC(xf86I2CBusInit) + SYMFUNC(xf86I2CDevInit) + SYMFUNC(xf86I2CFindBus) + SYMFUNC(xf86I2CFindDev) + SYMFUNC(xf86I2CGetScreenBuses) + SYMFUNC(xf86I2CProbeAddress) + SYMFUNC(xf86I2CReadByte) + SYMFUNC(xf86I2CReadBytes) + SYMFUNC(xf86I2CReadStatus) + SYMFUNC(xf86I2CReadWord) + SYMFUNC(xf86I2CWriteByte) + SYMFUNC(xf86I2CWriteBytes) + SYMFUNC(xf86I2CWriteRead) + SYMFUNC(xf86I2CWriteVec) + SYMFUNC(xf86I2CWriteWord) + + /* ramdac/xf86RamDac.c */ + SYMFUNC(RamDacCreateInfoRec) + SYMFUNC(RamDacHelperCreateInfoRec) + SYMFUNC(RamDacDestroyInfoRec) + SYMFUNC(RamDacHelperDestroyInfoRec) + SYMFUNC(RamDacInit) + SYMFUNC(RamDacHandleColormaps) + SYMFUNC(RamDacFreeRec) + SYMFUNC(RamDacGetHWIndex) + SYMVAR(RamDacHWPrivateIndex) + SYMVAR(RamDacScreenPrivateIndex) + + /* ramdac/xf86Cursor.c */ + SYMFUNC(xf86InitCursor) + SYMFUNC(xf86CreateCursorInfoRec) + SYMFUNC(xf86DestroyCursorInfoRec) + SYMFUNC(xf86ForceHWCursor) + + /* ramdac/BT.c */ + SYMFUNC(BTramdacProbe) + SYMFUNC(BTramdacSave) + SYMFUNC(BTramdacRestore) + SYMFUNC(BTramdacSetBpp) + + /* ramdac/IBM.c */ + SYMFUNC(IBMramdacProbe) + SYMFUNC(IBMramdacSave) + SYMFUNC(IBMramdacRestore) + SYMFUNC(IBMramdac526SetBpp) + SYMFUNC(IBMramdac640SetBpp) + SYMFUNC(IBMramdac526CalculateMNPCForClock) + SYMFUNC(IBMramdac640CalculateMNPCForClock) + SYMFUNC(IBMramdac526HWCursorInit) + SYMFUNC(IBMramdac640HWCursorInit) + SYMFUNC(IBMramdac526SetBppWeak) + + /* ramdac/TI.c */ + SYMFUNC(TIramdacCalculateMNPForClock) + SYMFUNC(TIramdacProbe) + SYMFUNC(TIramdacSave) + SYMFUNC(TIramdacRestore) + SYMFUNC(TIramdac3026SetBpp) + SYMFUNC(TIramdac3030SetBpp) + SYMFUNC(TIramdacHWCursorInit) + SYMFUNC(TIramdacLoadPalette) +}; diff --git a/xorg-server/hw/xfree86/modes/Makefile.am b/xorg-server/hw/xfree86/modes/Makefile.am new file mode 100644 index 000000000..331e4061c --- /dev/null +++ b/xorg-server/hw/xfree86/modes/Makefile.am @@ -0,0 +1,30 @@ +noinst_LIBRARIES = libxf86modes.a + +libxf86modes_a_SOURCES = \ + xf86Crtc.c \ + xf86Crtc.h \ + xf86Cursors.c \ + xf86cvt.c \ + xf86gtf.c \ + xf86DiDGA.c \ + xf86EdidModes.c \ + xf86Modes.c \ + xf86Modes.h \ + xf86RandR12.c \ + xf86RandR12.h \ + xf86Rename.h \ + xf86Rotate.c + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ + -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vgahw -I$(srcdir)/../ramdac \ + -I$(srcdir)/../dixmods/extmod + +sdk_HEADERS = \ + xf86Crtc.h \ + xf86Modes.h \ + xf86RandR12.h \ + xf86Rename.h + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xfree86/modes/Makefile.in b/xorg-server/hw/xfree86/modes/Makefile.in new file mode 100644 index 000000000..ff0a94f9f --- /dev/null +++ b/xorg-server/hw/xfree86/modes/Makefile.in @@ -0,0 +1,709 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/modes +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libxf86modes_a_AR = $(AR) $(ARFLAGS) +libxf86modes_a_LIBADD = +am_libxf86modes_a_OBJECTS = xf86Crtc.$(OBJEXT) xf86Cursors.$(OBJEXT) \ + xf86cvt.$(OBJEXT) xf86gtf.$(OBJEXT) xf86DiDGA.$(OBJEXT) \ + xf86EdidModes.$(OBJEXT) xf86Modes.$(OBJEXT) \ + xf86RandR12.$(OBJEXT) xf86Rotate.$(OBJEXT) +libxf86modes_a_OBJECTS = $(am_libxf86modes_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxf86modes_a_SOURCES) +DIST_SOURCES = $(libxf86modes_a_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = libxf86modes.a +libxf86modes_a_SOURCES = \ + xf86Crtc.c \ + xf86Crtc.h \ + xf86Cursors.c \ + xf86cvt.c \ + xf86gtf.c \ + xf86DiDGA.c \ + xf86EdidModes.c \ + xf86Modes.c \ + xf86Modes.h \ + xf86RandR12.c \ + xf86RandR12.h \ + xf86Rename.h \ + xf86Rotate.c + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ + -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vgahw -I$(srcdir)/../ramdac \ + -I$(srcdir)/../dixmods/extmod + +sdk_HEADERS = \ + xf86Crtc.h \ + xf86Modes.h \ + xf86RandR12.h \ + xf86Rename.h + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/modes/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/modes/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libxf86modes.a: $(libxf86modes_a_OBJECTS) $(libxf86modes_a_DEPENDENCIES) + -rm -f libxf86modes.a + $(libxf86modes_a_AR) libxf86modes.a $(libxf86modes_a_OBJECTS) $(libxf86modes_a_LIBADD) + $(RANLIB) libxf86modes.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Crtc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Cursors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86DiDGA.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86EdidModes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Modes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86RandR12.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Rotate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86cvt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86gtf.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c new file mode 100644 index 000000000..1facf86e9 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -0,0 +1,2768 @@ +/* + * Copyright © 2006 Keith Packard + * Copyright © 2008 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include <stddef.h> +#include <string.h> +#include <stdio.h> + +#include "xf86.h" +#include "xf86DDC.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "xf86Priv.h" +#include "xf86RandR12.h" +#include "X11/extensions/render.h" +#define DPMS_SERVER +#include "X11/extensions/dpms.h" +#include "X11/Xatom.h" +#ifdef RENDER +#include "picturestr.h" +#endif + +#include "xf86xv.h" + +/* + * Initialize xf86CrtcConfig structure + */ + +int xf86CrtcConfigPrivateIndex = -1; + +_X_EXPORT void +xf86CrtcConfigInit (ScrnInfoPtr scrn, + const xf86CrtcConfigFuncsRec *funcs) +{ + xf86CrtcConfigPtr config; + + if (xf86CrtcConfigPrivateIndex == -1) + xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + config = xnfcalloc (1, sizeof (xf86CrtcConfigRec)); + + config->funcs = funcs; + + scrn->privates[xf86CrtcConfigPrivateIndex].ptr = config; +} + +_X_EXPORT void +xf86CrtcSetSizeRange (ScrnInfoPtr scrn, + int minWidth, int minHeight, + int maxWidth, int maxHeight) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + + config->minWidth = minWidth; + config->minHeight = minHeight; + config->maxWidth = maxWidth; + config->maxHeight = maxHeight; +} + +/* + * Crtc functions + */ +_X_EXPORT xf86CrtcPtr +xf86CrtcCreate (ScrnInfoPtr scrn, + const xf86CrtcFuncsRec *funcs) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CrtcPtr crtc, *crtcs; + + crtc = xcalloc (sizeof (xf86CrtcRec), 1); + if (!crtc) + return NULL; + crtc->scrn = scrn; + crtc->funcs = funcs; +#ifdef RANDR_12_INTERFACE + crtc->randr_crtc = NULL; +#endif + crtc->rotation = RR_Rotate_0; + crtc->desiredRotation = RR_Rotate_0; + if (xf86_config->crtc) + crtcs = xrealloc (xf86_config->crtc, + (xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); + else + crtcs = xalloc ((xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr)); + if (!crtcs) + { + xfree (crtc); + return NULL; + } + xf86_config->crtc = crtcs; + xf86_config->crtc[xf86_config->num_crtc++] = crtc; + return crtc; +} + +_X_EXPORT void +xf86CrtcDestroy (xf86CrtcPtr crtc) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); + int c; + + (*crtc->funcs->destroy) (crtc); + for (c = 0; c < xf86_config->num_crtc; c++) + if (xf86_config->crtc[c] == crtc) + { + memmove (&xf86_config->crtc[c], + &xf86_config->crtc[c+1], + ((xf86_config->num_crtc - (c + 1)) * sizeof(void*))); + xf86_config->num_crtc--; + break; + } + xfree (crtc); +} + + +/** + * Return whether any outputs are connected to the specified pipe + */ + +_X_EXPORT Bool +xf86CrtcInUse (xf86CrtcPtr crtc) +{ + ScrnInfoPtr pScrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int o; + + for (o = 0; o < xf86_config->num_output; o++) + if (xf86_config->output[o]->crtc == crtc) + return TRUE; + return FALSE; +} + +_X_EXPORT void +xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen) +{ +#ifdef RENDER + int subpixel_order = SubPixelUnknown; + Bool has_none = FALSE; + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c, o; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + for (o = 0; o < xf86_config->num_output; o++) + { + xf86OutputPtr output = xf86_config->output[o]; + + if (output->crtc == crtc) + { + switch (output->subpixel_order) { + case SubPixelNone: + has_none = TRUE; + break; + case SubPixelUnknown: + break; + default: + subpixel_order = output->subpixel_order; + break; + } + } + if (subpixel_order != SubPixelUnknown) + break; + } + if (subpixel_order != SubPixelUnknown) + { + static const int circle[4] = { + SubPixelHorizontalRGB, + SubPixelVerticalRGB, + SubPixelHorizontalBGR, + SubPixelVerticalBGR, + }; + int rotate; + int c; + for (rotate = 0; rotate < 4; rotate++) + if (crtc->rotation & (1 << rotate)) + break; + for (c = 0; c < 4; c++) + if (circle[c] == subpixel_order) + break; + c = (c + rotate) & 0x3; + if ((crtc->rotation & RR_Reflect_X) && !(c & 1)) + c ^= 2; + if ((crtc->rotation & RR_Reflect_Y) && (c & 1)) + c ^= 2; + subpixel_order = circle[c]; + break; + } + } + if (subpixel_order == SubPixelUnknown && has_none) + subpixel_order = SubPixelNone; + PictureSetSubpixelOrder (pScreen, subpixel_order); +#endif +} + +/** + * Sets the given video mode on the given crtc + */ +_X_EXPORT Bool +xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, + int x, int y) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int i; + Bool ret = FALSE; + Bool didLock = FALSE; + DisplayModePtr adjusted_mode; + DisplayModeRec saved_mode; + int saved_x, saved_y; + Rotation saved_rotation; + + if (crtc->funcs->set_mode_major) + return crtc->funcs->set_mode_major(crtc, mode, rotation, x, y); + + crtc->enabled = xf86CrtcInUse (crtc); + + if (!crtc->enabled) + { + /* XXX disable crtc? */ + return TRUE; + } + + adjusted_mode = xf86DuplicateMode(mode); + + didLock = crtc->funcs->lock (crtc); + + saved_mode = crtc->mode; + saved_x = crtc->x; + saved_y = crtc->y; + saved_rotation = crtc->rotation; + /* Update crtc values up front so the driver can rely on them for mode + * setting. + */ + crtc->mode = *mode; + crtc->x = x; + crtc->y = y; + crtc->rotation = rotation; + + /* Shift offsets that move us out of virtual size */ + if (x + mode->HDisplay > xf86_config->maxWidth || + y + mode->VDisplay > xf86_config->maxHeight) + { + if (x + mode->HDisplay > xf86_config->maxWidth) + crtc->x = xf86_config->maxWidth - mode->HDisplay; + if (y + mode->VDisplay > xf86_config->maxHeight) + crtc->y = xf86_config->maxHeight - mode->VDisplay; + if (crtc->x < 0 || crtc->y < 0) + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Mode %dx%d does not fit virtual size %dx%d - " + "internal error\n", mode->HDisplay, mode->VDisplay, + xf86_config->maxWidth, xf86_config->maxHeight); + goto done; + } + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Mode %dx%d+%d+%d does not fit virtual size %dx%d - " + "offset updated to +%d+%d\n", + mode->HDisplay, mode->VDisplay, x, y, + xf86_config->maxWidth, xf86_config->maxHeight, + crtc->x, crtc->y); + } + + /* XXX short-circuit changes to base location only */ + + /* Pass our mode to the outputs and the CRTC to give them a chance to + * adjust it according to limitations or output properties, and also + * a chance to reject the mode entirely. + */ + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + + if (output->crtc != crtc) + continue; + + if (!output->funcs->mode_fixup(output, mode, adjusted_mode)) { + goto done; + } + } + + if (!crtc->funcs->mode_fixup(crtc, mode, adjusted_mode)) { + goto done; + } + + if (!xf86CrtcRotate (crtc, mode, rotation)) { + goto done; + } + + /* Prepare the outputs and CRTCs before setting the mode. */ + for (i = 0; i < xf86_config->num_output; i++) { + xf86OutputPtr output = xf86_config->output[i]; + + if (output->crtc != crtc) + continue; + + /* Disable the output as the first thing we do. */ + output->funcs->prepare(output); + } + + crtc->funcs->prepare(crtc); + + /* Set up the DPLL and any output state that needs to adjust or depend + * on the DPLL. + */ + crtc->funcs->mode_set(crtc, mode, adjusted_mode, crtc->x, crtc->y); + for (i = 0; i < xf86_config->num_output; i++) + { + xf86OutputPtr output = xf86_config->output[i]; + if (output->crtc == crtc) + output->funcs->mode_set(output, mode, adjusted_mode); + } + + /* Now, enable the clocks, plane, pipe, and outputs that we set up. */ + crtc->funcs->commit(crtc); + for (i = 0; i < xf86_config->num_output; i++) + { + xf86OutputPtr output = xf86_config->output[i]; + if (output->crtc == crtc) + { + output->funcs->commit(output); +#ifdef RANDR_12_INTERFACE + if (output->randr_output) + RRPostPendingProperties (output->randr_output); +#endif + } + } + + /* XXX free adjustedmode */ + ret = TRUE; + if (scrn->pScreen) + xf86CrtcSetScreenSubpixelOrder (scrn->pScreen); + +done: + if (!ret) { + crtc->x = saved_x; + crtc->y = saved_y; + crtc->rotation = saved_rotation; + crtc->mode = saved_mode; + } + + if (didLock) + crtc->funcs->unlock (crtc); + + return ret; +} + +/* + * Output functions + */ + +extern XF86ConfigPtr xf86configptr; + +typedef enum { + OPTION_PREFERRED_MODE, + OPTION_POSITION, + OPTION_BELOW, + OPTION_RIGHT_OF, + OPTION_ABOVE, + OPTION_LEFT_OF, + OPTION_ENABLE, + OPTION_DISABLE, + OPTION_MIN_CLOCK, + OPTION_MAX_CLOCK, + OPTION_IGNORE, + OPTION_ROTATE, +} OutputOpts; + +static OptionInfoRec xf86OutputOptions[] = { + {OPTION_PREFERRED_MODE, "PreferredMode", OPTV_STRING, {0}, FALSE }, + {OPTION_POSITION, "Position", OPTV_STRING, {0}, FALSE }, + {OPTION_BELOW, "Below", OPTV_STRING, {0}, FALSE }, + {OPTION_RIGHT_OF, "RightOf", OPTV_STRING, {0}, FALSE }, + {OPTION_ABOVE, "Above", OPTV_STRING, {0}, FALSE }, + {OPTION_LEFT_OF, "LeftOf", OPTV_STRING, {0}, FALSE }, + {OPTION_ENABLE, "Enable", OPTV_BOOLEAN, {0}, FALSE }, + {OPTION_DISABLE, "Disable", OPTV_BOOLEAN, {0}, FALSE }, + {OPTION_MIN_CLOCK, "MinClock", OPTV_FREQ, {0}, FALSE }, + {OPTION_MAX_CLOCK, "MaxClock", OPTV_FREQ, {0}, FALSE }, + {OPTION_IGNORE, "Ignore", OPTV_BOOLEAN, {0}, FALSE }, + {OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE }, + {-1, NULL, OPTV_NONE, {0}, FALSE }, +}; + +enum { + OPTION_MODEDEBUG, +}; + +static OptionInfoRec xf86DeviceOptions[] = { + {OPTION_MODEDEBUG, "ModeDebug", OPTV_STRING, {0}, FALSE }, + {-1, NULL, OPTV_NONE, {0}, FALSE }, +}; + +static void +xf86OutputSetMonitor (xf86OutputPtr output) +{ + char *option_name; + static const char monitor_prefix[] = "monitor-"; + char *monitor; + + if (!output->name) + return; + + if (output->options) + xfree (output->options); + + output->options = xnfalloc (sizeof (xf86OutputOptions)); + memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions)); + + option_name = xnfalloc (strlen (monitor_prefix) + + strlen (output->name) + 1); + strcpy (option_name, monitor_prefix); + strcat (option_name, output->name); + monitor = xf86findOptionValue (output->scrn->options, option_name); + if (!monitor) + monitor = output->name; + else + xf86MarkOptionUsedByName (output->scrn->options, option_name); + xfree (option_name); + output->conf_monitor = xf86findMonitor (monitor, + xf86configptr->conf_monitor_lst); + /* + * Find the monitor section of the screen and use that + */ + if (!output->conf_monitor && output->use_screen_monitor) + output->conf_monitor = xf86findMonitor (output->scrn->monitor->id, + xf86configptr->conf_monitor_lst); + if (output->conf_monitor) + { + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s using monitor section %s\n", + output->name, output->conf_monitor->mon_identifier); + xf86ProcessOptions (output->scrn->scrnIndex, + output->conf_monitor->mon_option_lst, + output->options); + } + else + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s has no monitor section\n", + output->name); +} + +static Bool +xf86OutputEnabled (xf86OutputPtr output, Bool strict) +{ + Bool enable, disable; + + /* check to see if this output was enabled in the config file */ + if (xf86GetOptValBool (output->options, OPTION_ENABLE, &enable) && enable) + { + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s enabled by config file\n", output->name); + return TRUE; + } + /* or if this output was disabled in the config file */ + if (xf86GetOptValBool (output->options, OPTION_DISABLE, &disable) && disable) + { + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s disabled by config file\n", output->name); + return FALSE; + } + + /* If not, try to only light up the ones we know are connected */ + if (strict) { + enable = output->status == XF86OutputStatusConnected; + } + /* But if that fails, try to light up even outputs we're unsure of */ + else { + enable = output->status != XF86OutputStatusDisconnected; + } + + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s %sconnected\n", output->name, enable ? "" : "dis"); + return enable; +} + +static Bool +xf86OutputIgnored (xf86OutputPtr output) +{ + return xf86ReturnOptValBool (output->options, OPTION_IGNORE, FALSE); +} + +static char *direction[4] = { + "normal", + "left", + "inverted", + "right" +}; + +static Rotation +xf86OutputInitialRotation (xf86OutputPtr output) +{ + char *rotate_name = xf86GetOptValString (output->options, + OPTION_ROTATE); + int i; + + if (!rotate_name) + return RR_Rotate_0; + + for (i = 0; i < 4; i++) + if (xf86nameCompare (direction[i], rotate_name) == 0) + return (1 << i); + return RR_Rotate_0; +} + +_X_EXPORT xf86OutputPtr +xf86OutputCreate (ScrnInfoPtr scrn, + const xf86OutputFuncsRec *funcs, + const char *name) +{ + xf86OutputPtr output, *outputs; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int len; + + if (name) + len = strlen (name) + 1; + else + len = 0; + + output = xcalloc (sizeof (xf86OutputRec) + len, 1); + if (!output) + return NULL; + output->scrn = scrn; + output->funcs = funcs; + if (name) + { + output->name = (char *) (output + 1); + strcpy (output->name, name); + } + output->subpixel_order = SubPixelUnknown; + /* + * Use the old per-screen monitor section for the first output + */ + output->use_screen_monitor = (xf86_config->num_output == 0); +#ifdef RANDR_12_INTERFACE + output->randr_output = NULL; +#endif + if (name) + { + xf86OutputSetMonitor (output); + if (xf86OutputIgnored (output)) + { + xfree (output); + return FALSE; + } + } + + + if (xf86_config->output) + outputs = xrealloc (xf86_config->output, + (xf86_config->num_output + 1) * sizeof (xf86OutputPtr)); + else + outputs = xalloc ((xf86_config->num_output + 1) * sizeof (xf86OutputPtr)); + if (!outputs) + { + xfree (output); + return NULL; + } + + xf86_config->output = outputs; + xf86_config->output[xf86_config->num_output++] = output; + + return output; +} + +_X_EXPORT Bool +xf86OutputRename (xf86OutputPtr output, const char *name) +{ + int len = strlen(name) + 1; + char *newname = xalloc (len); + + if (!newname) + return FALSE; /* so sorry... */ + + strcpy (newname, name); + if (output->name && output->name != (char *) (output + 1)) + xfree (output->name); + output->name = newname; + xf86OutputSetMonitor (output); + if (xf86OutputIgnored (output)) + return FALSE; + return TRUE; +} + +_X_EXPORT void +xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor) +{ + if (use_screen_monitor != output->use_screen_monitor) + { + output->use_screen_monitor = use_screen_monitor; + xf86OutputSetMonitor (output); + } +} + +_X_EXPORT void +xf86OutputDestroy (xf86OutputPtr output) +{ + ScrnInfoPtr scrn = output->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + + (*output->funcs->destroy) (output); + while (output->probed_modes) + xf86DeleteMode (&output->probed_modes, output->probed_modes); + for (o = 0; o < xf86_config->num_output; o++) + if (xf86_config->output[o] == output) + { + memmove (&xf86_config->output[o], + &xf86_config->output[o+1], + ((xf86_config->num_output - (o + 1)) * sizeof(void*))); + xf86_config->num_output--; + break; + } + if (output->name && output->name != (char *) (output + 1)) + xfree (output->name); + xfree (output); +} + +/* + * Called during CreateScreenResources to hook up RandR + */ +static Bool +xf86CrtcCreateScreenResources (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + + screen->CreateScreenResources = config->CreateScreenResources; + + if (!(*screen->CreateScreenResources)(screen)) + return FALSE; + + if (!xf86RandR12CreateScreenResources (screen)) + return FALSE; + + return TRUE; +} + +/* + * Clean up config on server reset + */ +static Bool +xf86CrtcCloseScreen (int index, ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o, c; + + screen->CloseScreen = config->CloseScreen; + + xf86RotateCloseScreen (screen); + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->randr_output = NULL; + } + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + + crtc->randr_crtc = NULL; + } + return screen->CloseScreen (index, screen); +} + +/* + * Called at ScreenInit time to set up + */ +_X_EXPORT Bool +xf86CrtcScreenInit (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + /* Rotation */ + xf86DrvMsg(scrn->scrnIndex, X_INFO, "RandR 1.2 enabled, ignore the following RandR disabled message.\n"); + xf86DisableRandR(); /* Disable old RandR extension support */ + xf86RandR12Init (screen); + + /* support all rotations if every crtc has the shadow alloc funcs */ + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + if (!crtc->funcs->shadow_allocate || !crtc->funcs->shadow_create) + break; + } + if (c == config->num_crtc) + xf86RandR12SetRotations (screen, RR_Rotate_0 | RR_Rotate_90 | + RR_Rotate_180 | RR_Rotate_270 | + RR_Reflect_X | RR_Reflect_Y); + else + xf86RandR12SetRotations (screen, RR_Rotate_0); + + /* Wrap CreateScreenResources so we can initialize the RandR code */ + config->CreateScreenResources = screen->CreateScreenResources; + screen->CreateScreenResources = xf86CrtcCreateScreenResources; + + config->CloseScreen = screen->CloseScreen; + screen->CloseScreen = xf86CrtcCloseScreen; + + return TRUE; +} + +static DisplayModePtr +xf86DefaultMode (xf86OutputPtr output, int width, int height) +{ + DisplayModePtr target_mode = NULL; + DisplayModePtr mode; + int target_diff = 0; + int target_preferred = 0; + int mm_height; + + mm_height = output->mm_height; + if (!mm_height) + mm_height = (768 * 25.4) / DEFAULT_DPI; + /* + * Pick a mode closest to DEFAULT_DPI + */ + for (mode = output->probed_modes; mode; mode = mode->next) + { + int dpi; + int preferred = (((mode->type & M_T_PREFERRED) != 0) + + ((mode->type & M_T_USERPREF) != 0)); + int diff; + + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + + /* yes, use VDisplay here, not xf86ModeHeight */ + dpi = (mode->VDisplay * 254) / (mm_height * 10); + diff = dpi - DEFAULT_DPI; + diff = diff < 0 ? -diff : diff; + if (target_mode == NULL || (preferred > target_preferred) || + (preferred == target_preferred && diff < target_diff)) + { + target_mode = mode; + target_diff = diff; + target_preferred = preferred; + } + } + return target_mode; +} + +static DisplayModePtr +xf86ClosestMode (xf86OutputPtr output, + DisplayModePtr match, Rotation match_rotation, + int width, int height) +{ + DisplayModePtr target_mode = NULL; + DisplayModePtr mode; + int target_diff = 0; + + /* + * Pick a mode closest to the specified mode + */ + for (mode = output->probed_modes; mode; mode = mode->next) + { + int dx, dy; + int diff; + + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + + /* exact matches are preferred */ + if (output->initial_rotation == match_rotation && + xf86ModesEqual (mode, match)) + return mode; + + dx = xf86ModeWidth (match, match_rotation) - xf86ModeWidth (mode, output->initial_rotation); + dy = xf86ModeHeight (match, match_rotation) - xf86ModeHeight (mode, output->initial_rotation); + diff = dx * dx + dy * dy; + if (target_mode == NULL || diff < target_diff) + { + target_mode = mode; + target_diff = diff; + } + } + return target_mode; +} + +static DisplayModePtr +xf86OutputHasPreferredMode (xf86OutputPtr output, int width, int height) +{ + DisplayModePtr mode; + + for (mode = output->probed_modes; mode; mode = mode->next) + { + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + + if (mode->type & M_T_PREFERRED) + return mode; + } + return NULL; +} + +static DisplayModePtr +xf86OutputHasUserPreferredMode (xf86OutputPtr output) +{ + DisplayModePtr mode, first = output->probed_modes; + + for (mode = first; mode && mode->next != first; mode = mode->next) + if (mode->type & M_T_USERPREF) + return mode; + + return NULL; +} + +static int +xf86PickCrtcs (ScrnInfoPtr scrn, + xf86CrtcPtr *best_crtcs, + DisplayModePtr *modes, + int n, + int width, + int height) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c, o; + xf86OutputPtr output; + xf86CrtcPtr crtc; + xf86CrtcPtr *crtcs; + xf86CrtcPtr best_crtc; + int best_score; + int score; + int my_score; + + if (n == config->num_output) + return 0; + output = config->output[n]; + + /* + * Compute score with this output disabled + */ + best_crtcs[n] = NULL; + best_crtc = NULL; + best_score = xf86PickCrtcs (scrn, best_crtcs, modes, n+1, width, height); + if (modes[n] == NULL) + return best_score; + + crtcs = xalloc (config->num_output * sizeof (xf86CrtcPtr)); + if (!crtcs) + return best_score; + + my_score = 1; + /* Score outputs that are known to be connected higher */ + if (output->status == XF86OutputStatusConnected) + my_score++; + /* Score outputs with preferred modes higher */ + if (xf86OutputHasPreferredMode (output, width, height)) + my_score++; + /* + * Select a crtc for this output and + * then attempt to configure the remaining + * outputs + */ + for (c = 0; c < config->num_crtc; c++) + { + if ((output->possible_crtcs & (1 << c)) == 0) + continue; + + crtc = config->crtc[c]; + /* + * Check to see if some other output is + * using this crtc + */ + for (o = 0; o < n; o++) + if (best_crtcs[o] == crtc) + break; + if (o < n) + { + /* + * If the two outputs desire the same mode, + * see if they can be cloned + */ + if (xf86ModesEqual (modes[o], modes[n]) && + config->output[0]->initial_rotation == config->output[n]->initial_rotation && + config->output[o]->initial_x == config->output[n]->initial_x && + config->output[o]->initial_y == config->output[n]->initial_y) + { + if ((output->possible_clones & (1 << o)) == 0) + continue; /* nope, try next CRTC */ + } + else + continue; /* different modes, can't clone */ + } + crtcs[n] = crtc; + memcpy (crtcs, best_crtcs, n * sizeof (xf86CrtcPtr)); + score = my_score + xf86PickCrtcs (scrn, crtcs, modes, n+1, width, height); + if (score > best_score) + { + best_crtc = crtc; + best_score = score; + memcpy (best_crtcs, crtcs, config->num_output * sizeof (xf86CrtcPtr)); + } + } + xfree (crtcs); + return best_score; +} + + +/* + * Compute the virtual size necessary to place all of the available + * crtcs in the specified configuration. + * + * canGrow indicates that the driver can make the screen larger than its initial + * configuration. If FALSE, this function will enlarge the screen to include + * the largest available mode. + */ + +static void +xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp, + Bool canGrow) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int width = 0, height = 0; + int o; + int c; + int s; + + for (c = 0; c < config->num_crtc; c++) + { + int crtc_width = 0, crtc_height = 0; + xf86CrtcPtr crtc = config->crtc[c]; + + if (crtc->enabled) + { + crtc_width = crtc->x + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation); + crtc_height = crtc->y + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation); + } + if (!canGrow) { + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + for (s = 0; s < config->num_crtc; s++) + if (output->possible_crtcs & (1 << s)) + { + DisplayModePtr mode; + for (mode = output->probed_modes; mode; mode = mode->next) + { + if (mode->HDisplay > crtc_width) + crtc_width = mode->HDisplay; + if (mode->VDisplay > crtc_width) + crtc_width = mode->VDisplay; + if (mode->VDisplay > crtc_height) + crtc_height = mode->VDisplay; + if (mode->HDisplay > crtc_height) + crtc_height = mode->HDisplay; + } + } + } + } + if (crtc_width > width) + width = crtc_width; + if (crtc_height > height) + height = crtc_height; + } + if (config->maxWidth && width > config->maxWidth) width = config->maxWidth; + if (config->maxHeight && height > config->maxHeight) height = config->maxHeight; + if (config->minWidth && width < config->minWidth) width = config->minWidth; + if (config->minHeight && height < config->minHeight) height = config->minHeight; + *widthp = width; + *heightp = height; +} + +#define POSITION_UNSET -100000 + +/* + * check if the user configured any outputs at all + * with either a position or a relative setting or a mode. + */ +static Bool +xf86UserConfiguredOutputs(ScrnInfoPtr scrn, DisplayModePtr *modes) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + Bool user_conf = FALSE; + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + char *position; + char *relative_name; + OutputOpts relation; + int r; + static const OutputOpts relations[] = { + OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF + }; + + position = xf86GetOptValString (output->options, + OPTION_POSITION); + if (position) + user_conf = TRUE; + + relation = 0; + relative_name = NULL; + for (r = 0; r < 4; r++) + { + relation = relations[r]; + relative_name = xf86GetOptValString (output->options, + relation); + if (relative_name) + break; + } + if (relative_name) + user_conf = TRUE; + + modes[o] = xf86OutputHasUserPreferredMode(output); + if (modes[o]) + user_conf = TRUE; + } + + return user_conf; +} + +static Bool +xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + int min_x, min_y; + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->initial_x = output->initial_y = POSITION_UNSET; + } + + /* + * Loop until all outputs are set + */ + for (;;) + { + Bool any_set = FALSE; + Bool keep_going = FALSE; + + for (o = 0; o < config->num_output; o++) + { + static const OutputOpts relations[] = { + OPTION_BELOW, OPTION_RIGHT_OF, OPTION_ABOVE, OPTION_LEFT_OF + }; + xf86OutputPtr output = config->output[o]; + xf86OutputPtr relative; + char *relative_name; + char *position; + OutputOpts relation; + int r; + + if (output->initial_x != POSITION_UNSET) + continue; + position = xf86GetOptValString (output->options, + OPTION_POSITION); + /* + * Absolute position wins + */ + if (position) + { + int x, y; + if (sscanf (position, "%d %d", &x, &y) == 2) + { + output->initial_x = x; + output->initial_y = y; + } + else + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Output %s position not of form \"x y\"\n", + output->name); + output->initial_x = output->initial_y = 0; + } + any_set = TRUE; + continue; + } + /* + * Next comes relative positions + */ + relation = 0; + relative_name = NULL; + for (r = 0; r < 4; r++) + { + relation = relations[r]; + relative_name = xf86GetOptValString (output->options, + relation); + if (relative_name) + break; + } + if (relative_name) + { + int or; + relative = NULL; + for (or = 0; or < config->num_output; or++) + { + xf86OutputPtr out_rel = config->output[or]; + XF86ConfMonitorPtr rel_mon = out_rel->conf_monitor; + + if (rel_mon) + { + if (xf86nameCompare (rel_mon->mon_identifier, + relative_name) == 0) + { + relative = config->output[or]; + break; + } + } + if (strcmp (out_rel->name, relative_name) == 0) + { + relative = config->output[or]; + break; + } + } + if (!relative) + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Cannot position output %s relative to unknown output %s\n", + output->name, relative_name); + output->initial_x = 0; + output->initial_y = 0; + any_set = TRUE; + continue; + } + if (!modes[or]) + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Cannot position output %s relative to output %s without modes\n", + output->name, relative_name); + output->initial_x = 0; + output->initial_y = 0; + any_set = TRUE; + continue; + } + if (relative->initial_x == POSITION_UNSET) + { + keep_going = TRUE; + continue; + } + output->initial_x = relative->initial_x; + output->initial_y = relative->initial_y; + switch (relation) { + case OPTION_BELOW: + output->initial_y += xf86ModeHeight (modes[or], relative->initial_rotation); + break; + case OPTION_RIGHT_OF: + output->initial_x += xf86ModeWidth (modes[or], relative->initial_rotation); + break; + case OPTION_ABOVE: + output->initial_y -= xf86ModeHeight (modes[o], relative->initial_rotation); + break; + case OPTION_LEFT_OF: + output->initial_x -= xf86ModeWidth (modes[o], relative->initial_rotation); + break; + default: + break; + } + any_set = TRUE; + continue; + } + + /* Nothing set, just stick them at 0,0 */ + output->initial_x = 0; + output->initial_y = 0; + any_set = TRUE; + } + if (!keep_going) + break; + if (!any_set) + { + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + if (output->initial_x == POSITION_UNSET) + { + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Output position loop. Moving %s to 0,0\n", + output->name); + output->initial_x = output->initial_y = 0; + break; + } + } + } + } + + /* + * normalize positions + */ + min_x = 1000000; + min_y = 1000000; + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + if (output->initial_x < min_x) + min_x = output->initial_x; + if (output->initial_y < min_y) + min_y = output->initial_y; + } + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->initial_x -= min_x; + output->initial_y -= min_y; + } + return TRUE; +} + +/* + * XXX walk the monitor mode list and prune out duplicates that + * are inserted by xf86DDCMonitorSet. In an ideal world, that + * function would do this work by itself. + */ + +static void +xf86PruneDuplicateMonitorModes (MonPtr Monitor) +{ + DisplayModePtr master, clone, next; + + for (master = Monitor->Modes; + master && master != Monitor->Last; + master = master->next) + { + for (clone = master->next; clone && clone != Monitor->Modes; clone = next) + { + next = clone->next; + if (xf86ModesEqual (master, clone)) + { + if (Monitor->Last == clone) + Monitor->Last = clone->prev; + xf86DeleteMode (&Monitor->Modes, clone); + } + } + } +} + +/** Return - 0 + if a should be earlier, same or later than b in list + */ +static int +xf86ModeCompare (DisplayModePtr a, DisplayModePtr b) +{ + int diff; + + diff = ((b->type & M_T_PREFERRED) != 0) - ((a->type & M_T_PREFERRED) != 0); + if (diff) + return diff; + diff = b->HDisplay * b->VDisplay - a->HDisplay * a->VDisplay; + if (diff) + return diff; + diff = b->Clock - a->Clock; + return diff; +} + +/** + * Insertion sort input in-place and return the resulting head + */ +static DisplayModePtr +xf86SortModes (DisplayModePtr input) +{ + DisplayModePtr output = NULL, i, o, n, *op, prev; + + /* sort by preferred status and pixel area */ + while (input) + { + i = input; + input = input->next; + for (op = &output; (o = *op); op = &o->next) + if (xf86ModeCompare (o, i) > 0) + break; + i->next = *op; + *op = i; + } + /* prune identical modes */ + for (o = output; o && (n = o->next); o = n) + { + if (!strcmp (o->name, n->name) && xf86ModesEqual (o, n)) + { + o->next = n->next; + xfree (n->name); + xfree (n); + n = o; + } + } + /* hook up backward links */ + prev = NULL; + for (o = output; o; o = o->next) + { + o->prev = prev; + prev = o; + } + return output; +} + +static char * +preferredMode(ScrnInfoPtr pScrn, xf86OutputPtr output) +{ + char *preferred_mode = NULL; + + /* Check for a configured preference for a particular mode */ + preferred_mode = xf86GetOptValString (output->options, + OPTION_PREFERRED_MODE); + if (preferred_mode) + return preferred_mode; + + if (pScrn->display->modes && *pScrn->display->modes) + preferred_mode = *pScrn->display->modes; + + 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@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) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + + /* When canGrow was TRUE in the initial configuration we have to + * compare against the maximum values so that we don't drop modes. + * When canGrow was FALSE, the maximum values would have been clamped + * anyway. + */ + if (maxX == 0 || maxY == 0) { + maxX = config->maxWidth; + maxY = config->maxHeight; + } + + /* Elide duplicate modes before defaulting code uses them */ + xf86PruneDuplicateMonitorModes (scrn->monitor); + + /* Probe the list of modes for each output. */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + DisplayModePtr mode; + DisplayModePtr config_modes = NULL, output_modes, default_modes; + char *preferred_mode; + xf86MonPtr edid_monitor; + XF86ConfMonitorPtr conf_monitor; + MonRec mon_rec; + int min_clock = 0; + int max_clock = 0; + double clock; + enum { sync_config, sync_edid, sync_default } sync_source = sync_default; + + while (output->probed_modes != NULL) + xf86DeleteMode(&output->probed_modes, output->probed_modes); + + /* + * Check connection status + */ + output->status = (*output->funcs->detect)(output); + + if (output->status == XF86OutputStatusDisconnected) + { + xf86OutputSetEDID (output, NULL); + continue; + } + + memset (&mon_rec, '\0', sizeof (mon_rec)); + + conf_monitor = output->conf_monitor; + + if (conf_monitor) + { + int i; + + for (i = 0; i < conf_monitor->mon_n_hsync; i++) + { + mon_rec.hsync[mon_rec.nHsync].lo = conf_monitor->mon_hsync[i].lo; + mon_rec.hsync[mon_rec.nHsync].hi = conf_monitor->mon_hsync[i].hi; + mon_rec.nHsync++; + sync_source = sync_config; + } + for (i = 0; i < conf_monitor->mon_n_vrefresh; i++) + { + mon_rec.vrefresh[mon_rec.nVrefresh].lo = conf_monitor->mon_vrefresh[i].lo; + mon_rec.vrefresh[mon_rec.nVrefresh].hi = conf_monitor->mon_vrefresh[i].hi; + mon_rec.nVrefresh++; + sync_source = sync_config; + } + config_modes = xf86GetMonitorModes (scrn, conf_monitor); + } + + output_modes = (*output->funcs->get_modes) (output); + + edid_monitor = output->MonInfo; + + if (edid_monitor) + { + int i; + Bool set_hsync = mon_rec.nHsync == 0; + Bool set_vrefresh = mon_rec.nVrefresh == 0; + + for (i = 0; i < sizeof (edid_monitor->det_mon) / sizeof (edid_monitor->det_mon[0]); i++) + { + if (edid_monitor->det_mon[i].type == DS_RANGES) + { + struct monitor_ranges *ranges = &edid_monitor->det_mon[i].section.ranges; + if (set_hsync && ranges->max_h) + { + mon_rec.hsync[mon_rec.nHsync].lo = ranges->min_h; + mon_rec.hsync[mon_rec.nHsync].hi = ranges->max_h; + mon_rec.nHsync++; + if (sync_source == sync_default) + sync_source = sync_edid; + } + if (set_vrefresh && ranges->max_v) + { + mon_rec.vrefresh[mon_rec.nVrefresh].lo = ranges->min_v; + mon_rec.vrefresh[mon_rec.nVrefresh].hi = ranges->max_v; + mon_rec.nVrefresh++; + if (sync_source == sync_default) + sync_source = sync_edid; + } + if (ranges->max_clock * 1000 > max_clock) + max_clock = ranges->max_clock * 1000; + } + } + } + + if (xf86GetOptValFreq (output->options, OPTION_MIN_CLOCK, + OPTUNITS_KHZ, &clock)) + min_clock = (int) clock; + if (xf86GetOptValFreq (output->options, OPTION_MAX_CLOCK, + 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@60Hz mode by default, + * which seems like a fairly good mode to use when nothing else is + * specified + */ + if (mon_rec.nHsync == 0) + { + mon_rec.hsync[0].lo = 31.0; + mon_rec.hsync[0].hi = 55.0; + mon_rec.nHsync = 1; + } + if (mon_rec.nVrefresh == 0) + { + mon_rec.vrefresh[0].lo = 58.0; + mon_rec.vrefresh[0].hi = 62.0; + mon_rec.nVrefresh = 1; + } + 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) + { + /* + * Check output and config modes against sync range from config file + */ + xf86ValidateModesSync (scrn, output_modes, &mon_rec); + xf86ValidateModesSync (scrn, config_modes, &mon_rec); + } + /* + * Check default modes against sync range + */ + xf86ValidateModesSync (scrn, default_modes, &mon_rec); + /* + * Check default modes against monitor max clock + */ + if (max_clock) { + xf86ValidateModesClocks(scrn, default_modes, + &min_clock, &max_clock, 1); + xf86ValidateModesClocks(scrn, output_modes, + &min_clock, &max_clock, 1); + } + + output->probed_modes = NULL; + output->probed_modes = xf86ModesAdd (output->probed_modes, config_modes); + output->probed_modes = xf86ModesAdd (output->probed_modes, output_modes); + output->probed_modes = xf86ModesAdd (output->probed_modes, default_modes); + + /* + * Check all modes against max size + */ + if (maxX && maxY) + xf86ValidateModesSize (scrn, output->probed_modes, + maxX, maxY, 0); + + /* + * Check all modes against output + */ + for (mode = output->probed_modes; mode != NULL; mode = mode->next) + if (mode->status == MODE_OK) + mode->status = (*output->funcs->mode_valid)(output, mode); + + xf86PruneInvalidModes(scrn, &output->probed_modes, + config->debug_modes); + + output->probed_modes = xf86SortModes (output->probed_modes); + + /* Check for a configured preference for a particular mode */ + preferred_mode = preferredMode(scrn, output); + + if (preferred_mode) + { + for (mode = output->probed_modes; mode; mode = mode->next) + { + if (!strcmp (preferred_mode, mode->name)) + { + if (mode != output->probed_modes) + { + if (mode->prev) + mode->prev->next = mode->next; + if (mode->next) + mode->next->prev = mode->prev; + mode->next = output->probed_modes; + output->probed_modes->prev = mode; + mode->prev = NULL; + output->probed_modes = mode; + } + mode->type |= (M_T_PREFERRED|M_T_USERPREF); + break; + } + } + } + + output->initial_rotation = xf86OutputInitialRotation (output); + + if (config->debug_modes) { + if (output->probed_modes != NULL) { + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "Printing probed modes for output %s\n", + output->name); + } else { + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "No remaining probed modes for output %s\n", + output->name); + } + } + for (mode = output->probed_modes; mode != NULL; mode = mode->next) + { + /* The code to choose the best mode per pipe later on will require + * VRefresh to be set. + */ + mode->VRefresh = xf86ModeVRefresh(mode); + xf86SetModeCrtc(mode, INTERLACE_HALVE_V); + + if (config->debug_modes) + xf86PrintModeline(scrn->scrnIndex, mode); + } + } +} + + +/** + * Copy one of the output mode lists to the ScrnInfo record + */ + +/* XXX where does this function belong? Here? */ +_X_EXPORT void +xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr scrn, int *x, int *y); + +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; +} + +_X_EXPORT void +xf86SetScrnInfoModes (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + xf86OutputPtr output; + xf86CrtcPtr crtc; + DisplayModePtr last, mode = NULL; + + output = SetCompatOutput(config); + + if (!output) + return; /* punt */ + + crtc = output->crtc; + + /* Clear any existing modes from scrn->modes */ + while (scrn->modes != NULL) + xf86DeleteMode(&scrn->modes, scrn->modes); + + /* Set scrn->modes to the mode list for the 'compat' output */ + scrn->modes = xf86DuplicateModes(scrn, output->probed_modes); + + if (crtc) { + for (mode = scrn->modes; mode; mode = mode->next) + if (xf86ModesEqual (mode, &crtc->desiredMode)) + break; + } + + if (scrn->modes != NULL) { + /* For some reason, scrn->modes is circular, unlike the other mode + * lists. How great is that? + */ + for (last = scrn->modes; last && last->next; last = last->next) + ; + last->next = scrn->modes; + scrn->modes->prev = last; + if (mode) { + while (scrn->modes != mode) + scrn->modes = scrn->modes->next; + } + } + scrn->currentMode = scrn->modes; +} + +static void +xf86EnableOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, Bool *enabled) +{ + Bool any_enabled = FALSE; + int o; + + for (o = 0; o < config->num_output; o++) + any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], TRUE); + + if (!any_enabled) { + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "No outputs definitely connected, trying again...\n"); + + for (o = 0; o < config->num_output; o++) + enabled[o] = xf86OutputEnabled(config->output[o], FALSE); + } +} + +static Bool +nextEnabledOutput(xf86CrtcConfigPtr config, Bool *enabled, int *index) +{ + int o = *index; + + for (o++; o < config->num_output; o++) { + if (enabled[o]) { + *index = o; + return TRUE; + } + } + + return FALSE; +} + +static Bool +xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, + DisplayModePtr *modes, Bool *enabled, + int width, int height) +{ + 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; + + 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; + } + } + + all_match &= match; + } + + 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; + } + } + } + + if (ret) { + /* oh good, there is a match. stash the selected modes and return. */ + memcpy(modes, preferred_match, + config->num_output * sizeof(DisplayModePtr)); + } + + xfree(preferred); + xfree(preferred_match); + return ret; +} + +static Bool +aspectMatch(float a, float b) +{ + return fabs(1 - (a / b)) < 0.05; +} + +static DisplayModePtr +nextAspectMode(xf86OutputPtr o, DisplayModePtr last, float aspect) +{ + DisplayModePtr m = NULL; + + if (!o) + return NULL; + + if (!last) + m = o->probed_modes; + else + m = last->next; + + for (; m; m = m->next) + if (aspectMatch(aspect, (float)m->HDisplay / (float)m->VDisplay)) + return m; + + return NULL; +} + +static DisplayModePtr +bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect) +{ + int o = -1, p; + DisplayModePtr mode = NULL, test = NULL, match = NULL; + + if (!nextEnabledOutput(config, enabled, &o)) + return NULL; + while ((mode = nextAspectMode(config->output[o], mode, aspect))) { + test = mode; + for (p = o; nextEnabledOutput(config, enabled, &p); ) { + test = xf86OutputFindClosestMode(config->output[p], mode); + if (!test) + break; + if (test->HDisplay != mode->HDisplay || + test->VDisplay != mode->VDisplay) { + test = NULL; + break; + } + } + + /* if we didn't match it on all outputs, try the next one */ + if (!test) + continue; + + /* if it's bigger than the last one, save it */ + if (!match || (test->HDisplay > match->HDisplay)) + match = test; + } + + /* return the biggest one found */ + return match; +} + +static Bool +xf86TargetAspect(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, + DisplayModePtr *modes, Bool *enabled, + int width, int height) +{ + int o; + float aspect = 0.0, *aspects; + xf86OutputPtr output; + Bool ret = FALSE; + DisplayModePtr guess = NULL, aspect_guess = NULL, base_guess = NULL; + + aspects = xnfcalloc(config->num_output, sizeof(float)); + + /* collect the aspect ratios */ + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + output = config->output[o]; + if (output->mm_height) + aspects[o] = (float)output->mm_width / (float)output->mm_height; + else + aspects[o] = 4.0 / 3.0; + } + + /* check that they're all the same */ + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + output = config->output[o]; + if (!aspect) { + aspect = aspects[o]; + } else if (!aspectMatch(aspect, aspects[o])) { + goto no_aspect_match; + } + } + + /* if they're all 4:3, just skip ahead and save effort */ + if (!aspectMatch(aspect, 4.0/3.0)) + aspect_guess = bestModeForAspect(config, enabled, aspect); + +no_aspect_match: + base_guess = bestModeForAspect(config, enabled, 4.0/3.0); + + guess = biggestMode(base_guess, aspect_guess); + + if (!guess) + goto out; + + /* found a mode that works everywhere, now apply it */ + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + modes[o] = xf86OutputFindClosestMode(config->output[o], guess); + } + ret = TRUE; + +out: + xfree(aspects); + return ret; +} + +static Bool +xf86TargetFallback(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, + DisplayModePtr *modes, Bool *enabled, + int width, int height) +{ + DisplayModePtr target_mode = NULL; + Rotation target_rotation = RR_Rotate_0; + DisplayModePtr default_mode; + int default_preferred, target_preferred = 0, o; + + /* User preferred > preferred > other modes */ + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + default_mode = xf86DefaultMode (config->output[o], width, height); + if (!default_mode) + continue; + + default_preferred = (((default_mode->type & M_T_PREFERRED) != 0) + + ((default_mode->type & M_T_USERPREF) != 0)); + + if (default_preferred > target_preferred || !target_mode) { + target_mode = default_mode; + target_preferred = default_preferred; + target_rotation = config->output[o]->initial_rotation; + config->compat_output = o; + } + } + + if (target_mode) + modes[config->compat_output] = target_mode; + + /* Fill in other output modes */ + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + if (!modes[o]) + modes[o] = xf86ClosestMode(config->output[o], target_mode, + target_rotation, width, height); + } + + return (target_mode != NULL); +} + +static Bool +xf86TargetUserpref(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, + DisplayModePtr *modes, Bool *enabled, + int width, int height) +{ + int o; + + if (xf86UserConfiguredOutputs(scrn, modes)) + return xf86TargetFallback(scrn, config, modes, enabled, width, height); + + for (o = -1; nextEnabledOutput(config, enabled, &o); ) + if (xf86OutputHasUserPreferredMode(config->output[o])) + return + xf86TargetFallback(scrn, config, modes, enabled, width, height); + + return FALSE; +} + + +/** + * Construct default screen configuration + * + * Given auto-detected (and, eventually, configured) values, + * construct a usable configuration for the system + * + * canGrow indicates that the driver can resize the screen to larger than its + * initially configured size via the config->funcs->resize hook. If TRUE, this + * function will set virtualX and virtualY to match the initial configuration + * and leave config->max{Width,Height} alone. If FALSE, it will bloat + * virtual[XY] to include the largest modes and set config->max{Width,Height} + * accordingly. + */ + +_X_EXPORT Bool +xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o, c; + xf86CrtcPtr *crtcs; + DisplayModePtr *modes; + Bool *enabled; + int width, height; + int i = scrn->scrnIndex; + + /* Set up the device options */ + config->options = xnfalloc (sizeof (xf86DeviceOptions)); + memcpy (config->options, xf86DeviceOptions, sizeof (xf86DeviceOptions)); + xf86ProcessOptions (scrn->scrnIndex, + scrn->options, + config->options); + config->debug_modes = xf86ReturnOptValBool (config->options, + OPTION_MODEDEBUG, FALSE); + + if (scrn->display->virtualX) + width = scrn->display->virtualX; + else + width = config->maxWidth; + if (scrn->display->virtualY) + height = scrn->display->virtualY; + else + height = config->maxHeight; + + xf86ProbeOutputModes (scrn, width, height); + + crtcs = xnfcalloc (config->num_output, sizeof (xf86CrtcPtr)); + modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr)); + enabled = xnfcalloc (config->num_output, sizeof (Bool)); + + xf86EnableOutputs(scrn, config, enabled); + + if (xf86TargetUserpref(scrn, config, modes, enabled, width, height)) + xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n"); + 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"); + else if (xf86TargetFallback(scrn, config, modes, enabled, width, height)) + xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n"); + else + xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n"); + + for (o = -1; nextEnabledOutput(config, enabled, &o); ) { + if (!modes[o]) + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Output %s enabled but has no modes\n", + config->output[o]->name); + else + xf86DrvMsg (scrn->scrnIndex, X_INFO, + "Output %s using initial mode %s\n", + config->output[o]->name, modes[o]->name); + } + + /* + * Set the position of each output + */ + if (!xf86InitialOutputPositions (scrn, modes)) + { + xfree (crtcs); + xfree (modes); + return FALSE; + } + + /* + * Assign CRTCs to fit output configuration + */ + if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height)) + { + xfree (crtcs); + xfree (modes); + return FALSE; + } + + /* XXX override xf86 common frame computation code */ + + scrn->display->frameX0 = 0; + scrn->display->frameY0 = 0; + + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + + crtc->enabled = FALSE; + memset (&crtc->desiredMode, '\0', sizeof (crtc->desiredMode)); + } + + /* + * Set initial configuration + */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + DisplayModePtr mode = modes[o]; + xf86CrtcPtr crtc = crtcs[o]; + + if (mode && crtc) + { + crtc->desiredMode = *mode; + crtc->desiredRotation = output->initial_rotation; + crtc->desiredX = output->initial_x; + crtc->desiredY = output->initial_y; + crtc->enabled = TRUE; + crtc->x = output->initial_x; + crtc->y = output->initial_y; + output->crtc = crtc; + } else { + output->crtc = NULL; + } + } + + if (scrn->display->virtualX == 0) + { + /* + * Expand virtual size to cover the current config and potential mode + * switches, if the driver can't enlarge the screen later. + */ + xf86DefaultScreenLimits (scrn, &width, &height, canGrow); + + scrn->display->virtualX = width; + scrn->display->virtualY = height; + } + + if (width > scrn->virtualX) + scrn->virtualX = width; + if (height > scrn->virtualY) + scrn->virtualY = height; + + /* + * Make sure the configuration isn't too small. + */ + if (width < config->minWidth || height < config->minHeight) + return FALSE; + + /* + * Limit the crtc config to virtual[XY] if the driver can't grow the + * desktop. + */ + if (!canGrow) + { + xf86CrtcSetSizeRange (scrn, config->minWidth, config->minHeight, + width, height); + } + + /* Mirror output modes to scrn mode list */ + xf86SetScrnInfoModes (scrn); + + xfree (crtcs); + xfree (modes); + return TRUE; +} + +/* + * Using the desired mode information in each crtc, set + * modes (used in EnterVT functions, or at server startup) + */ + +_X_EXPORT Bool +xf86SetDesiredModes (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c, o; + + /* + * Turn off everything so mode setting is done + * with hardware in a consistent state + */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + (*output->funcs->dpms)(output, DPMSModeOff); + } + + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + + crtc->funcs->dpms(crtc, DPMSModeOff); + memset(&crtc->mode, 0, sizeof(crtc->mode)); + } + + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + 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 + { + for (o = 0; o < config->num_output; o++) + if (config->output[o]->crtc == crtc) + { + output = config->output[o]; + break; + } + } + /* paranoia */ + if (!output) + continue; + + /* Mark that we'll need to re-set the mode for sure */ + memset(&crtc->mode, 0, sizeof(crtc->mode)); + if (!crtc->desiredMode.CrtcHDisplay) + { + DisplayModePtr mode = xf86OutputFindClosestMode (output, scrn->currentMode); + + if (!mode) + return FALSE; + crtc->desiredMode = *mode; + crtc->desiredRotation = RR_Rotate_0; + crtc->desiredX = 0; + crtc->desiredY = 0; + } + + if (!xf86CrtcSetMode (crtc, &crtc->desiredMode, crtc->desiredRotation, + crtc->desiredX, crtc->desiredY)) + return FALSE; + } + + xf86DisableUnusedFunctions(scrn); + return TRUE; +} + +/** + * In the current world order, there are lists of modes per output, which may + * or may not include the mode that was asked to be set by XFree86's mode + * selection. Find the closest one, in the following preference order: + * + * - Equality + * - Closer in size to the requested mode, but no larger + * - Closer in refresh rate to the requested mode. + */ + +_X_EXPORT DisplayModePtr +xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired) +{ + DisplayModePtr best = NULL, scan = NULL; + + for (scan = output->probed_modes; scan != NULL; scan = scan->next) + { + /* If there's an exact match, we're done. */ + if (xf86ModesEqual(scan, desired)) { + best = desired; + break; + } + + /* Reject if it's larger than the desired mode. */ + if (scan->HDisplay > desired->HDisplay || + scan->VDisplay > desired->VDisplay) + { + continue; + } + + /* + * If we haven't picked a best mode yet, use the first + * one in the size range + */ + if (best == NULL) + { + best = scan; + continue; + } + + /* Find if it's closer to the right size than the current best + * option. + */ + if ((scan->HDisplay > best->HDisplay && + scan->VDisplay >= best->VDisplay) || + (scan->HDisplay >= best->HDisplay && + scan->VDisplay > best->VDisplay)) + { + best = scan; + continue; + } + + /* Find if it's still closer to the right refresh than the current + * best resolution. + */ + if (scan->HDisplay == best->HDisplay && + scan->VDisplay == best->VDisplay && + (fabs(scan->VRefresh - desired->VRefresh) < + fabs(best->VRefresh - desired->VRefresh))) { + best = scan; + } + } + return best; +} + +/** + * When setting a mode through XFree86-VidModeExtension or XFree86-DGA, + * take the specified mode and apply it to the crtc connected to the compat + * output. Then, find similar modes for the other outputs, as with the + * InitialConfiguration code above. The goal is to clone the desired + * mode across all outputs that are currently active. + */ + +_X_EXPORT Bool +xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + Bool ok = TRUE; + xf86OutputPtr compat_output = config->output[config->compat_output]; + DisplayModePtr compat_mode; + int c; + + /* + * Let the compat output drive the final mode selection + */ + compat_mode = xf86OutputFindClosestMode (compat_output, desired); + if (compat_mode) + desired = compat_mode; + + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + DisplayModePtr crtc_mode = NULL; + int o; + + if (!crtc->enabled) + continue; + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + DisplayModePtr output_mode; + + /* skip outputs not on this crtc */ + if (output->crtc != crtc) + continue; + + if (crtc_mode) + { + output_mode = xf86OutputFindClosestMode (output, crtc_mode); + if (output_mode != crtc_mode) + output->crtc = NULL; + } + else + crtc_mode = xf86OutputFindClosestMode (output, desired); + } + if (!crtc_mode) + { + crtc->enabled = FALSE; + continue; + } + if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0)) + ok = FALSE; + else + { + crtc->desiredMode = *crtc_mode; + crtc->desiredRotation = rotation; + crtc->desiredX = 0; + crtc->desiredY = 0; + } + } + xf86DisableUnusedFunctions(pScrn); +#if RANDR_12_INTERFACE + xf86RandR12TellChanged (pScrn->pScreen); +#endif + return ok; +} + + +/** + * Set the DPMS power mode of all outputs and CRTCs. + * + * If the new mode is off, it will turn off outputs and then CRTCs. + * Otherwise, it will affect CRTCs before outputs. + */ +_X_EXPORT void +xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i; + + if (!scrn->vtSema) + return; + + if (mode == DPMSModeOff) { + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + if (output->crtc != NULL) + (*output->funcs->dpms) (output, mode); + } + } + + for (i = 0; i < config->num_crtc; i++) { + xf86CrtcPtr crtc = config->crtc[i]; + if (crtc->enabled) + (*crtc->funcs->dpms) (crtc, mode); + } + + if (mode != DPMSModeOff) { + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + if (output->crtc != NULL) + (*output->funcs->dpms) (output, mode); + } + } +} + +/** + * Implement the screensaver by just calling down into the driver DPMS hooks. + * + * Even for monitors with no DPMS support, by the definition of our DPMS hooks, + * the outputs will still get disabled (blanked). + */ +_X_EXPORT Bool +xf86SaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (xf86IsUnblank(mode)) + xf86DPMSSet(pScrn, DPMSModeOn, 0); + else + xf86DPMSSet(pScrn, DPMSModeOff, 0); + + return TRUE; +} + +/** + * Disable all inactive crtcs and outputs + */ +_X_EXPORT void +xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int o, c; + + for (o = 0; o < xf86_config->num_output; o++) + { + xf86OutputPtr output = xf86_config->output[o]; + if (!output->crtc) + (*output->funcs->dpms)(output, DPMSModeOff); + } + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (!crtc->enabled) + { + crtc->funcs->dpms(crtc, DPMSModeOff); + memset(&crtc->mode, 0, sizeof(crtc->mode)); + } + } +} + +#ifdef RANDR_12_INTERFACE + +#define EDID_ATOM_NAME "EDID_DATA" + +/** + * Set the RandR EDID property + */ +static void +xf86OutputSetEDIDProperty (xf86OutputPtr output, void *data, int data_len) +{ + Atom edid_atom = MakeAtom(EDID_ATOM_NAME, sizeof(EDID_ATOM_NAME) - 1, TRUE); + + /* This may get called before the RandR resources have been created */ + if (output->randr_output == NULL) + return; + + if (data_len != 0) { + RRChangeOutputProperty(output->randr_output, edid_atom, XA_INTEGER, 8, + PropModeReplace, data_len, data, FALSE, TRUE); + } else { + RRDeleteOutputProperty(output->randr_output, edid_atom); + } +} + +#endif + +/** + * Set the EDID information for the specified output + */ +_X_EXPORT void +xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon) +{ + ScrnInfoPtr scrn = output->scrn; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i; +#ifdef RANDR_12_INTERFACE + int size; +#endif + + if (output->MonInfo != NULL) + xfree(output->MonInfo); + + output->MonInfo = edid_mon; + + if (config->debug_modes) { + xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n", + output->name); + xf86PrintEDID(edid_mon); + } + + /* Set the DDC properties for the 'compat' output */ + if (output == config->output[config->compat_output]) + xf86SetDDCproperties(scrn, edid_mon); + +#ifdef RANDR_12_INTERFACE + /* Set the RandR output properties */ + size = 0; + if (edid_mon) + { + if (edid_mon->ver.version == 1) + size = 128; + else if (edid_mon->ver.version == 2) + size = 256; + } + xf86OutputSetEDIDProperty (output, edid_mon ? edid_mon->rawData : NULL, size); +#endif + + if (edid_mon) + { + /* Pull out a phyiscal size from a detailed timing if available. */ + for (i = 0; i < 4; i++) { + if (edid_mon->det_mon[i].type == DT && + edid_mon->det_mon[i].section.d_timings.h_size != 0 && + edid_mon->det_mon[i].section.d_timings.v_size != 0) + { + output->mm_width = edid_mon->det_mon[i].section.d_timings.h_size; + output->mm_height = edid_mon->det_mon[i].section.d_timings.v_size; + break; + } + } + + /* if no mm size is available from a detailed timing, check the max size field */ + if ((!output->mm_width || !output->mm_height) && + (edid_mon->features.hsize && edid_mon->features.vsize)) + { + output->mm_width = edid_mon->features.hsize * 10; + output->mm_height = edid_mon->features.vsize * 10; + } + } +} + +/** + * Return the list of modes supported by the EDID information + * stored in 'output' + */ +_X_EXPORT DisplayModePtr +xf86OutputGetEDIDModes (xf86OutputPtr output) +{ + ScrnInfoPtr scrn = output->scrn; + xf86MonPtr edid_mon = output->MonInfo; + + if (!edid_mon) + return NULL; + return xf86DDCGetModes(scrn->scrnIndex, edid_mon); +} + +_X_EXPORT xf86MonPtr +xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) +{ + ScrnInfoPtr scrn = output->scrn; + xf86MonPtr mon; + + mon = xf86DoEDID_DDC2 (scrn->scrnIndex, pDDCBus); + if (mon) + xf86DDCApplyQuirks (scrn->scrnIndex, mon); + + return mon; +} + +static char *_xf86ConnectorNames[] = { + "None", "VGA", "DVI-I", "DVI-D", + "DVI-A", "Composite", "S-Video", + "Component", "LFP", "Proprietary", + "HDMI", "DisplayPort", + }; +_X_EXPORT char * +xf86ConnectorGetName(xf86ConnectorType connector) +{ + return _xf86ConnectorNames[connector]; +} + +static void +x86_crtc_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b) +{ + dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1; + dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2; + dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1; + dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2; + + if (dest->x1 >= dest->x2 || dest->y1 >= dest->y2) + dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0; +} + +static void +x86_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box) +{ + if (crtc->enabled) { + crtc_box->x1 = crtc->x; + crtc_box->x2 = crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation); + crtc_box->y1 = crtc->y; + crtc_box->y2 = crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation); + } else + crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0; +} + +static int +xf86_crtc_box_area(BoxPtr box) +{ + return (int) (box->x2 - box->x1) * (int) (box->y2 - box->y1); +} + +/* + * Return the crtc covering 'box'. If two crtcs cover a portion of + * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc + * with greater coverage + */ + +static xf86CrtcPtr +xf86_covering_crtc(ScrnInfoPtr pScrn, + BoxPtr box, + xf86CrtcPtr desired, + BoxPtr crtc_box_ret) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcPtr crtc, best_crtc; + int coverage, best_coverage; + int c; + BoxRec crtc_box, cover_box; + + best_crtc = NULL; + best_coverage = 0; + crtc_box_ret->x1 = 0; + crtc_box_ret->x2 = 0; + crtc_box_ret->y1 = 0; + crtc_box_ret->y2 = 0; + for (c = 0; c < xf86_config->num_crtc; c++) { + crtc = xf86_config->crtc[c]; + x86_crtc_box(crtc, &crtc_box); + x86_crtc_box_intersect(&cover_box, &crtc_box, box); + coverage = xf86_crtc_box_area(&cover_box); + if (coverage && crtc == desired) { + *crtc_box_ret = crtc_box; + return crtc; + } else if (coverage > best_coverage) { + *crtc_box_ret = crtc_box; + best_crtc = crtc; + best_coverage = coverage; + } + } + return best_crtc; +} + +/* + * For overlay video, compute the relevant CRTC and + * clip video to that. + * + * returning FALSE means there was a memory failure of some kind, + * not that the video shouldn't be displayed + */ + +_X_EXPORT Bool +xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, + xf86CrtcPtr *crtc_ret, + xf86CrtcPtr desired_crtc, + BoxPtr dst, + INT32 *xa, + INT32 *xb, + INT32 *ya, + INT32 *yb, + RegionPtr reg, + INT32 width, + INT32 height) +{ + Bool ret; + RegionRec crtc_region_local; + RegionPtr crtc_region = reg; + + if (crtc_ret) { + BoxRec crtc_box; + xf86CrtcPtr crtc = xf86_covering_crtc(pScrn, dst, + desired_crtc, + &crtc_box); + + if (crtc) { + REGION_INIT (pScreen, &crtc_region_local, &crtc_box, 1); + crtc_region = &crtc_region_local; + REGION_INTERSECT (pScreen, crtc_region, crtc_region, reg); + } + *crtc_ret = crtc; + } + + ret = xf86XVClipVideoHelper(dst, xa, xb, ya, yb, + crtc_region, width, height); + + if (crtc_region != reg) + REGION_UNINIT (pScreen, &crtc_region_local); + + return ret; +} diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h new file mode 100644 index 000000000..cc045b229 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h @@ -0,0 +1,801 @@ +/* + * Copyright © 2006 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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 _XF86CRTC_H_ +#define _XF86CRTC_H_ + +#include <edid.h> +#include "randrstr.h" +#if XF86_MODES_RENAME +#include "xf86Rename.h" +#endif +#include "xf86Modes.h" +#include "xf86Cursor.h" +#include "xf86i2c.h" +#include "damage.h" +#include "picturestr.h" + +/* Compat definitions for older X Servers. */ +#ifndef M_T_PREFERRED +#define M_T_PREFERRED 0x08 +#endif +#ifndef M_T_DRIVER +#define M_T_DRIVER 0x40 +#endif +#ifndef M_T_USERPREF +#define M_T_USERPREF 0x80 +#endif +#ifndef HARDWARE_CURSOR_ARGB +#define HARDWARE_CURSOR_ARGB 0x00004000 +#endif + +typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr; +typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr; + +/* define a standard for connector types */ +typedef enum _xf86ConnectorType { + XF86ConnectorNone, + XF86ConnectorVGA, + XF86ConnectorDVI_I, + XF86ConnectorDVI_D, + XF86ConnectorDVI_A, + XF86ConnectorComposite, + XF86ConnectorSvideo, + XF86ConnectorComponent, + XF86ConnectorLFP, + XF86ConnectorProprietary, + XF86ConnectorHDMI, + XF86ConnectorDisplayPort, +} xf86ConnectorType; + +typedef enum _xf86OutputStatus { + XF86OutputStatusConnected, + XF86OutputStatusDisconnected, + XF86OutputStatusUnknown +} xf86OutputStatus; + +typedef struct _xf86CrtcFuncs { + /** + * Turns the crtc on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to + * be safe to call mode_set. + */ + void + (*dpms)(xf86CrtcPtr crtc, + int mode); + + /** + * Saves the crtc's state for restoration on VT switch. + */ + void + (*save)(xf86CrtcPtr crtc); + + /** + * Restore's the crtc's state at VT switch. + */ + void + (*restore)(xf86CrtcPtr crtc); + + /** + * Lock CRTC prior to mode setting, mostly for DRI. + * Returns whether unlock is needed + */ + Bool + (*lock) (xf86CrtcPtr crtc); + + /** + * Unlock CRTC after mode setting, mostly for DRI + */ + void + (*unlock) (xf86CrtcPtr crtc); + + /** + * Callback to adjust the mode to be set in the CRTC. + * + * This allows a CRTC to adjust the clock or even the entire set of + * timings, which is used for panels with fixed timings or for + * buses with clock limitations. + */ + Bool + (*mode_fixup)(xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode); + + /** + * Prepare CRTC for an upcoming mode set. + */ + void + (*prepare)(xf86CrtcPtr crtc); + + /** + * Callback for setting up a video mode after fixups have been made. + */ + void + (*mode_set)(xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode, + int x, int y); + + /** + * Commit mode changes to a CRTC + */ + void + (*commit)(xf86CrtcPtr crtc); + + /* Set the color ramps for the CRTC to the given values. */ + void + (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, + int size); + + /** + * Allocate the shadow area, delay the pixmap creation until needed + */ + void * + (*shadow_allocate) (xf86CrtcPtr crtc, int width, int height); + + /** + * Create shadow pixmap for rotation support + */ + PixmapPtr + (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height); + + /** + * Destroy shadow pixmap + */ + void + (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data); + + /** + * Set cursor colors + */ + void + (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg); + + /** + * Set cursor position + */ + void + (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y); + + /** + * Show cursor + */ + void + (*show_cursor) (xf86CrtcPtr crtc); + + /** + * Hide cursor + */ + void + (*hide_cursor) (xf86CrtcPtr crtc); + + /** + * Load monochrome image + */ + void + (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image); + + /** + * Load ARGB image + */ + void + (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image); + + /** + * Clean up driver-specific bits of the crtc + */ + void + (*destroy) (xf86CrtcPtr crtc); + + /** + * Less fine-grained mode setting entry point for kernel modesetting + */ + Bool + (*set_mode_major)(xf86CrtcPtr crtc, DisplayModePtr mode, + Rotation rotation, int x, int y); +} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; + +struct _xf86Crtc { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Active state of this CRTC + * + * Set when this CRTC is driving one or more outputs + */ + Bool enabled; + + /** + * Active mode + * + * This reflects the mode as set in the CRTC currently + * It will be cleared when the VT is not active or + * during server startup + */ + DisplayModeRec mode; + Rotation rotation; + PixmapPtr rotatedPixmap; + void *rotatedData; + + /** + * Position on screen + * + * Locates this CRTC within the frame buffer + */ + int x, y; + + /** + * Desired mode + * + * This is set to the requested mode, independent of + * whether the VT is active. In particular, it receives + * the startup configured mode and saves the active mode + * on VT switch. + */ + DisplayModeRec desiredMode; + Rotation desiredRotation; + int desiredX, desiredY; + + /** crtc-specific functions */ + const xf86CrtcFuncsRec *funcs; + + /** + * Driver private + * + * Holds driver-private information + */ + void *driver_private; + +#ifdef RANDR_12_INTERFACE + /** + * RandR crtc + * + * When RandR 1.2 is available, this + * points at the associated crtc object + */ + RRCrtcPtr randr_crtc; +#else + void *randr_crtc; +#endif + + /** + * Current cursor is ARGB + */ + Bool cursor_argb; + /** + * Track whether cursor is within CRTC range + */ + Bool cursor_in_range; + /** + * Track state of cursor associated with this CRTC + */ + Bool cursor_shown; + + /** + * Current transformation matrix + */ + PictTransform crtc_to_framebuffer; + PictTransform framebuffer_to_crtc; + Bool transform_in_use; + /** + * Bounding box in screen space + */ + BoxRec bounds; +}; + +typedef struct _xf86OutputFuncs { + /** + * Called to allow the output a chance to create properties after the + * RandR objects have been created. + */ + void + (*create_resources)(xf86OutputPtr output); + + /** + * Turns the output on/off, or sets intermediate power levels if available. + * + * Unsupported intermediate modes drop to the lower power setting. If the + * mode is DPMSModeOff, the output must be disabled, as the DPLL may be + * disabled afterwards. + */ + void + (*dpms)(xf86OutputPtr output, + int mode); + + /** + * Saves the output's state for restoration on VT switch. + */ + void + (*save)(xf86OutputPtr output); + + /** + * Restore's the output's state at VT switch. + */ + void + (*restore)(xf86OutputPtr output); + + /** + * Callback for testing a video mode for a given output. + * + * This function should only check for cases where a mode can't be supported + * on the output specifically, and not represent generic CRTC limitations. + * + * \return MODE_OK if the mode is valid, or another MODE_* otherwise. + */ + int + (*mode_valid)(xf86OutputPtr output, + DisplayModePtr pMode); + + /** + * Callback to adjust the mode to be set in the CRTC. + * + * This allows an output to adjust the clock or even the entire set of + * timings, which is used for panels with fixed timings or for + * buses with clock limitations. + */ + Bool + (*mode_fixup)(xf86OutputPtr output, + DisplayModePtr mode, + DisplayModePtr adjusted_mode); + + /** + * Callback for preparing mode changes on an output + */ + void + (*prepare)(xf86OutputPtr output); + + /** + * Callback for committing mode changes on an output + */ + void + (*commit)(xf86OutputPtr output); + + /** + * Callback for setting up a video mode after fixups have been made. + * + * This is only called while the output is disabled. The dpms callback + * must be all that's necessary for the output, to turn the output on + * after this function is called. + */ + void + (*mode_set)(xf86OutputPtr output, + DisplayModePtr mode, + DisplayModePtr adjusted_mode); + + /** + * Probe for a connected output, and return detect_status. + */ + xf86OutputStatus + (*detect)(xf86OutputPtr output); + + /** + * Query the device for the modes it provides. + * + * This function may also update MonInfo, mm_width, and mm_height. + * + * \return singly-linked list of modes or NULL if no modes found. + */ + DisplayModePtr + (*get_modes)(xf86OutputPtr output); + +#ifdef RANDR_12_INTERFACE + /** + * Callback when an output's property has changed. + */ + Bool + (*set_property)(xf86OutputPtr output, + Atom property, + RRPropertyValuePtr value); +#endif + /** + * Clean up driver-specific bits of the output + */ + void + (*destroy) (xf86OutputPtr output); +} xf86OutputFuncsRec, *xf86OutputFuncsPtr; + +struct _xf86Output { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Currently connected crtc (if any) + * + * If this output is not in use, this field will be NULL. + */ + xf86CrtcPtr crtc; + + /** + * Possible CRTCs for this output as a mask of crtc indices + */ + CARD32 possible_crtcs; + + /** + * Possible outputs to share the same CRTC as a mask of output indices + */ + CARD32 possible_clones; + + /** + * Whether this output can support interlaced modes + */ + Bool interlaceAllowed; + + /** + * Whether this output can support double scan modes + */ + Bool doubleScanAllowed; + + /** + * List of available modes on this output. + * + * This should be the list from get_modes(), plus perhaps additional + * compatible modes added later. + */ + DisplayModePtr probed_modes; + + /** + * Options parsed from the related monitor section + */ + OptionInfoPtr options; + + /** + * Configured monitor section + */ + XF86ConfMonitorPtr conf_monitor; + + /** + * Desired initial position + */ + int initial_x, initial_y; + + /** + * Desired initial rotation + */ + Rotation initial_rotation; + + /** + * Current connection status + * + * This indicates whether a monitor is known to be connected + * to this output or not, or whether there is no way to tell + */ + xf86OutputStatus status; + + /** EDID monitor information */ + xf86MonPtr MonInfo; + + /** subpixel order */ + int subpixel_order; + + /** Physical size of the currently attached output device. */ + int mm_width, mm_height; + + /** Output name */ + char *name; + + /** output-specific functions */ + const xf86OutputFuncsRec *funcs; + + /** driver private information */ + void *driver_private; + + /** Whether to use the old per-screen Monitor config section */ + Bool use_screen_monitor; + +#ifdef RANDR_12_INTERFACE + /** + * RandR 1.2 output structure. + * + * When RandR 1.2 is available, this points at the associated + * RandR output structure and is created when this output is created + */ + RROutputPtr randr_output; +#else + void *randr_output; +#endif +}; + +typedef struct _xf86CrtcConfigFuncs { + /** + * Requests that the driver resize the screen. + * + * The driver is responsible for updating scrn->virtualX and scrn->virtualY. + * If the requested size cannot be set, the driver should leave those values + * alone and return FALSE. + * + * A naive driver that cannot reallocate the screen may simply change + * virtual[XY]. A more advanced driver will want to also change the + * devPrivate.ptr and devKind of the screen pixmap, update any offscreen + * pixmaps it may have moved, and change pScrn->displayWidth. + */ + Bool + (*resize)(ScrnInfoPtr scrn, + int width, + int height); +} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr; + +typedef struct _xf86CrtcConfig { + int num_output; + xf86OutputPtr *output; + /** + * compat_output is used whenever we deal + * with legacy code that only understands a single + * output. pScrn->modes will be loaded from this output, + * adjust frame will whack this output, etc. + */ + int compat_output; + + int num_crtc; + xf86CrtcPtr *crtc; + + int minWidth, minHeight; + int maxWidth, maxHeight; + + /* For crtc-based rotation */ + DamagePtr rotation_damage; + Bool rotation_damage_registered; + + /* DGA */ + unsigned int dga_flags; + unsigned long dga_address; + DGAModePtr dga_modes; + int dga_nmode; + int dga_width, dga_height, dga_stride; + DisplayModePtr dga_save_mode; + + const xf86CrtcConfigFuncsRec *funcs; + + CreateScreenResourcesProcPtr CreateScreenResources; + + CloseScreenProcPtr CloseScreen; + + /* Cursor information */ + xf86CursorInfoPtr cursor_info; + CursorPtr cursor; + CARD8 *cursor_image; + Bool cursor_on; + CARD32 cursor_fg, cursor_bg; + + /** + * Options parsed from the related device section + */ + OptionInfoPtr options; + + Bool debug_modes; + + /* wrap screen BlockHandler for rotation */ + ScreenBlockHandlerProcPtr BlockHandler; + +} xf86CrtcConfigRec, *xf86CrtcConfigPtr; + +extern int xf86CrtcConfigPrivateIndex; + +#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr)) + +/* + * Initialize xf86CrtcConfig structure + */ + +void +xf86CrtcConfigInit (ScrnInfoPtr scrn, + const xf86CrtcConfigFuncsRec *funcs); + +void +xf86CrtcSetSizeRange (ScrnInfoPtr scrn, + int minWidth, int minHeight, + int maxWidth, int maxHeight); + +/* + * Crtc functions + */ +xf86CrtcPtr +xf86CrtcCreate (ScrnInfoPtr scrn, + const xf86CrtcFuncsRec *funcs); + +void +xf86CrtcDestroy (xf86CrtcPtr crtc); + + +/** + * Sets the given video mode on the given crtc + */ +Bool +xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, + int x, int y); + +/* + * Assign crtc rotation during mode set + */ +Bool +xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation); + +/* + * Clean up rotation during CloseScreen + */ +void +xf86RotateCloseScreen (ScreenPtr pScreen); + +/** + * Return whether any output is assigned to the crtc + */ +Bool +xf86CrtcInUse (xf86CrtcPtr crtc); + +/* + * Output functions + */ +xf86OutputPtr +xf86OutputCreate (ScrnInfoPtr scrn, + const xf86OutputFuncsRec *funcs, + const char *name); + +void +xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor); + +Bool +xf86OutputRename (xf86OutputPtr output, const char *name); + +void +xf86OutputDestroy (xf86OutputPtr output); + +void +xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY); + +void +xf86SetScrnInfoModes (ScrnInfoPtr pScrn); + +Bool +xf86CrtcScreenInit (ScreenPtr pScreen); + +Bool +xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow); + +void +xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); + +Bool +xf86SaveScreen(ScreenPtr pScreen, int mode); + +void +xf86DisableUnusedFunctions(ScrnInfoPtr pScrn); + +DisplayModePtr +xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired); + +Bool +xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation); + +/** + * Set the EDID information for the specified output + */ +void +xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon); + +/** + * Return the list of modes supported by the EDID information + * stored in 'output' + */ +DisplayModePtr +xf86OutputGetEDIDModes (xf86OutputPtr output); + +xf86MonPtr +xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus); + +/** + * Initialize dga for this screen + */ + +Bool +xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address); + +/** + * Re-initialize dga for this screen (as when the set of modes changes) + */ + +Bool +xf86DiDGAReInit (ScreenPtr pScreen); + +/* + * Set the subpixel order reported for the screen using + * the information from the outputs + */ + +void +xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen); + +/* + * Get a standard string name for a connector type + */ +char * +xf86ConnectorGetName(xf86ConnectorType connector); + +/* + * Using the desired mode information in each crtc, set + * modes (used in EnterVT functions, or at server startup) + */ + +Bool +xf86SetDesiredModes (ScrnInfoPtr pScrn); + +/** + * Initialize the CRTC-based cursor code. CRTC function vectors must + * contain relevant cursor setting functions. + * + * Driver should call this from ScreenInit function + */ +Bool +xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags); + +/** + * Called when anything on the screen is reconfigured. + * + * Reloads cursor images as needed, then adjusts cursor positions. + * + * Driver should call this from crtc commit function. + */ +void +xf86_reload_cursors (ScreenPtr screen); + +/** + * Called from EnterVT to turn the cursors back on + */ +void +xf86_show_cursors (ScrnInfoPtr scrn); + +/** + * Called by the driver to turn cursors off + */ +void +xf86_hide_cursors (ScrnInfoPtr scrn); + +/** + * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time. + */ +void +xf86_cursors_fini (ScreenPtr screen); + +/* + * For overlay video, compute the relevant CRTC and + * clip video to that. + * wraps xf86XVClipVideoHelper() + */ + +Bool +xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn, + xf86CrtcPtr *crtc_ret, + xf86CrtcPtr desired_crtc, + BoxPtr dst, + INT32 *xa, + INT32 *xb, + INT32 *ya, + INT32 *yb, + RegionPtr reg, + INT32 width, + INT32 height); + +#endif /* _XF86CRTC_H_ */ diff --git a/xorg-server/hw/xfree86/modes/xf86Cursors.c b/xorg-server/hw/xfree86/modes/xf86Cursors.c new file mode 100644 index 000000000..fee02df38 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86Cursors.c @@ -0,0 +1,652 @@ +/* + * Copyright © 2007 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include <stddef.h> +#include <string.h> +#include <stdio.h> + +#include "xf86.h" +#include "xf86DDC.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "xf86RandR12.h" +#include "X11/extensions/render.h" +#define DPMS_SERVER +#include "X11/extensions/dpms.h" +#include "X11/Xatom.h" +#ifdef RENDER +#include "picturestr.h" +#endif +#include "cursorstr.h" + +/* + * Given a screen coordinate, rotate back to a cursor source coordinate + */ +static void +xf86_crtc_rotate_coord (Rotation rotation, + int width, + int height, + int x_dst, + int y_dst, + int *x_src, + int *y_src) +{ + int t; + + switch (rotation & 0xf) { + case RR_Rotate_0: + break; + case RR_Rotate_90: + t = x_dst; + x_dst = height - y_dst - 1; + y_dst = t; + break; + case RR_Rotate_180: + x_dst = width - x_dst - 1; + y_dst = height - y_dst - 1; + break; + case RR_Rotate_270: + t = x_dst; + x_dst = y_dst; + y_dst = width - t - 1; + break; + } + if (rotation & RR_Reflect_X) + x_dst = width - x_dst - 1; + if (rotation & RR_Reflect_Y) + y_dst = height - y_dst - 1; + *x_src = x_dst; + *y_src = y_dst; +} + +/* + * Given a cursor source coordinate, rotate to a screen coordinate + */ +static void +xf86_crtc_rotate_coord_back (Rotation rotation, + int width, + int height, + int x_dst, + int y_dst, + int *x_src, + int *y_src) +{ + int t; + + if (rotation & RR_Reflect_X) + x_dst = width - x_dst - 1; + if (rotation & RR_Reflect_Y) + y_dst = height - y_dst - 1; + + switch (rotation & 0xf) { + case RR_Rotate_0: + break; + case RR_Rotate_90: + t = x_dst; + x_dst = y_dst; + y_dst = width - t - 1; + break; + case RR_Rotate_180: + x_dst = width - x_dst - 1; + y_dst = height - y_dst - 1; + break; + case RR_Rotate_270: + t = x_dst; + x_dst = height - y_dst - 1; + y_dst = t; + break; + } + *x_src = x_dst; + *y_src = y_dst; +} + +/* + * Convert an x coordinate to a position within the cursor bitmap + */ +static int +cursor_bitpos (int flags, int x, Bool mask) +{ + if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK) + mask = !mask; + if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED) + x = (x & ~3) | (3 - (x & 3)); + if (((flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) == 0) == + (X_BYTE_ORDER == X_BIG_ENDIAN)) + x = (x & ~7) | (7 - (x & 7)); + if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1) + x = (x << 1) + mask; + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8) + x = ((x & ~7) << 1) | (mask << 3) | (x & 7); + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16) + x = ((x & ~15) << 1) | (mask << 4) | (x & 15); + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32) + x = ((x & ~31) << 1) | (mask << 5) | (x & 31); + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64) + x = ((x & ~63) << 1) | (mask << 6) | (x & 63); + return x; +} + +/* + * Fetch one bit from a cursor bitmap + */ +static CARD8 +get_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask) +{ + x = cursor_bitpos (flags, x, mask); + image += y * stride; + return (image[(x >> 3)] >> (x & 7)) & 1; +} + +/* + * Set one bit in a cursor bitmap + */ +static void +set_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask) +{ + x = cursor_bitpos (flags, x, mask); + image += y * stride; + image[(x >> 3)] |= 1 << (x & 7); +} + +/* + * Load a two color cursor into a driver that supports only ARGB cursors + */ +static void +xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image; + int x, y; + int xin, yin; + int stride = cursor_info->MaxWidth >> 2; + int flags = cursor_info->Flags; + CARD32 bits; + +#ifdef ARGB_CURSOR + crtc->cursor_argb = FALSE; +#endif + + for (y = 0; y < cursor_info->MaxHeight; y++) + for (x = 0; x < cursor_info->MaxWidth; x++) + { + xf86_crtc_rotate_coord (crtc->rotation, + cursor_info->MaxWidth, + cursor_info->MaxHeight, + x, y, &xin, &yin); + if (get_bit (src, stride, flags, xin, yin, TRUE) == + ((flags & HARDWARE_CURSOR_INVERT_MASK) == 0)) + { + if (get_bit (src, stride, flags, xin, yin, FALSE)) + bits = xf86_config->cursor_fg; + else + bits = xf86_config->cursor_bg; + } + else + bits = 0; + cursor_image[y * cursor_info->MaxWidth + x] = bits; + } + crtc->funcs->load_cursor_argb (crtc, cursor_image); +} + +/* + * Set the colors for a two-color cursor (ignore for ARGB cursors) + */ +static void +xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg) +{ + ScreenPtr screen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + CursorPtr cursor = xf86_config->cursor; + int c; + CARD8 *bits = cursor ? dixLookupPrivate(&cursor->devPrivates, + screen) : NULL; + + /* Save ARGB versions of these colors */ + xf86_config->cursor_fg = (CARD32) fg | 0xff000000; + xf86_config->cursor_bg = (CARD32) bg | 0xff000000; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled && !crtc->cursor_argb) + { + if (crtc->funcs->load_cursor_image) + crtc->funcs->set_cursor_colors (crtc, bg, fg); + else if (bits) + xf86_crtc_convert_cursor_to_argb (crtc, bits); + } + } +} + +static void +xf86_crtc_hide_cursor (xf86CrtcPtr crtc) +{ + if (crtc->cursor_shown) + { + crtc->funcs->hide_cursor (crtc); + crtc->cursor_shown = FALSE; + } +} + +_X_EXPORT void +xf86_hide_cursors (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + xf86_config->cursor_on = FALSE; + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_hide_cursor (crtc); + } +} + +static void +xf86_crtc_show_cursor (xf86CrtcPtr crtc) +{ + if (!crtc->cursor_shown && crtc->cursor_in_range) + { + crtc->funcs->show_cursor (crtc); + crtc->cursor_shown = TRUE; + } +} + +_X_EXPORT void +xf86_show_cursors (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + xf86_config->cursor_on = TRUE; + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_show_cursor (crtc); + } +} + +static void +xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + DisplayModePtr mode = &crtc->mode; + Bool in_range; + int dx, dy; + + /* + * Transform position of cursor on screen + */ + if (crtc->transform_in_use) + { + PictVector v; + v.vector[0] = IntToxFixed (x); v.vector[1] = IntToxFixed (y); v.vector[2] = IntToxFixed(1); + PictureTransformPoint (&crtc->framebuffer_to_crtc, &v); + x = xFixedToInt (v.vector[0]); y = xFixedToInt (v.vector[1]); + } + else + { + x -= crtc->x; + y -= crtc->y; + } + /* + * Transform position of cursor upper left corner + */ + xf86_crtc_rotate_coord_back (crtc->rotation, + cursor_info->MaxWidth, + cursor_info->MaxHeight, + 0, 0, &dx, &dy); + x -= dx; + y -= dy; + + /* + * Disable the cursor when it is outside the viewport + */ + in_range = TRUE; + if (x >= mode->HDisplay || y >= mode->VDisplay || + x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight) + { + in_range = FALSE; + x = 0; + y = 0; + } + + crtc->cursor_in_range = in_range; + + if (in_range) + { + crtc->funcs->set_cursor_position (crtc, x, y); + xf86_crtc_show_cursor (crtc); + } + else + xf86_crtc_hide_cursor (crtc); +} + +static void +xf86_set_cursor_position (ScrnInfoPtr scrn, int x, int y) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + /* undo what xf86HWCurs did to the coordinates */ + x += scrn->frameX0; + y += scrn->frameY0; + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_set_cursor_position (crtc, x, y); + } +} + +/* + * Load a two-color cursor into a crtc, performing rotation as needed + */ +static void +xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + CARD8 *cursor_image; + +#ifdef ARGB_CURSOR + crtc->cursor_argb = FALSE; +#endif + + if (crtc->rotation == RR_Rotate_0) + cursor_image = src; + else + { + int x, y; + int xin, yin; + int stride = cursor_info->MaxWidth >> 2; + int flags = cursor_info->Flags; + + cursor_image = xf86_config->cursor_image; + memset(cursor_image, 0, cursor_info->MaxHeight * stride); + + for (y = 0; y < cursor_info->MaxHeight; y++) + for (x = 0; x < cursor_info->MaxWidth; x++) + { + xf86_crtc_rotate_coord (crtc->rotation, + cursor_info->MaxWidth, + cursor_info->MaxHeight, + x, y, &xin, &yin); + if (get_bit(src, stride, flags, xin, yin, FALSE)) + set_bit(cursor_image, stride, flags, x, y, FALSE); + if (get_bit(src, stride, flags, xin, yin, TRUE)) + set_bit(cursor_image, stride, flags, x, y, TRUE); + } + } + crtc->funcs->load_cursor_image (crtc, cursor_image); +} + +/* + * Load a cursor image into all active CRTCs + */ +static void +xf86_load_cursor_image (ScrnInfoPtr scrn, unsigned char *src) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + { + if (crtc->funcs->load_cursor_image) + xf86_crtc_load_cursor_image (crtc, src); + else if (crtc->funcs->load_cursor_argb) + xf86_crtc_convert_cursor_to_argb (crtc, src); + } + } +} + +static Bool +xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + + if (xf86_config->cursor) + FreeCursor (xf86_config->cursor, None); + xf86_config->cursor = cursor; + ++cursor->refcnt; + + if (cursor->bits->width > cursor_info->MaxWidth || + cursor->bits->height> cursor_info->MaxHeight) + return FALSE; + + return TRUE; +} + +static Bool +xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + + if (xf86_config->cursor) + FreeCursor (xf86_config->cursor, None); + xf86_config->cursor = cursor; + ++cursor->refcnt; + + /* Make sure ARGB support is available */ + if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0) + return FALSE; + + if (cursor->bits->width > cursor_info->MaxWidth || + cursor->bits->height> cursor_info->MaxHeight) + return FALSE; + + return TRUE; +} + +static void +xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image; + CARD32 *cursor_source = (CARD32 *) cursor->bits->argb; + int x, y; + int xin, yin; + CARD32 bits; + int source_width = cursor->bits->width; + int source_height = cursor->bits->height; + int image_width = cursor_info->MaxWidth; + int image_height = cursor_info->MaxHeight; + + for (y = 0; y < image_height; y++) + for (x = 0; x < image_width; x++) + { + xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height, + x, y, &xin, &yin); + if (xin < source_width && yin < source_height) + bits = cursor_source[yin * source_width + xin]; + else + bits = 0; + cursor_image[y * image_width + x] = bits; + } + + crtc->funcs->load_cursor_argb (crtc, cursor_image); +} + +static void +xf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_load_cursor_argb (crtc, cursor); + } +} + +_X_EXPORT Bool +xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info; + + cursor_info = xf86CreateCursorInfoRec(); + if (!cursor_info) + return FALSE; + + xf86_config->cursor_image = xalloc (max_width * max_height * 4); + + if (!xf86_config->cursor_image) + { + xf86DestroyCursorInfoRec (cursor_info); + return FALSE; + } + + xf86_config->cursor_info = cursor_info; + + cursor_info->MaxWidth = max_width; + cursor_info->MaxHeight = max_height; + cursor_info->Flags = flags; + + cursor_info->SetCursorColors = xf86_set_cursor_colors; + cursor_info->SetCursorPosition = xf86_set_cursor_position; + cursor_info->LoadCursorImage = xf86_load_cursor_image; + cursor_info->HideCursor = xf86_hide_cursors; + cursor_info->ShowCursor = xf86_show_cursors; + cursor_info->UseHWCursor = xf86_use_hw_cursor; +#ifdef ARGB_CURSOR + if (flags & HARDWARE_CURSOR_ARGB) + { + cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb; + cursor_info->LoadCursorARGB = xf86_load_cursor_argb; + } +#endif + + xf86_config->cursor = NULL; + xf86_hide_cursors (scrn); + + return xf86InitCursor (screen, cursor_info); +} + +/** + * Called when anything on the screen is reconfigured. + * + * Reloads cursor images as needed, then adjusts cursor positions + */ + +_X_EXPORT void +xf86_reload_cursors (ScreenPtr screen) +{ + ScrnInfoPtr scrn; + xf86CrtcConfigPtr xf86_config; + xf86CursorInfoPtr cursor_info; + CursorPtr cursor; + int x, y; + + /* initial mode setting will not have set a screen yet */ + if (!screen) + return; + scrn = xf86Screens[screen->myNum]; + xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + /* make sure the cursor code has been initialized */ + cursor_info = xf86_config->cursor_info; + if (!cursor_info) + return; + + cursor = xf86_config->cursor; + GetSpritePosition (&x, &y); + if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) + (*cursor_info->HideCursor)(scrn); + + 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 if (src) +#endif + (*cursor_info->LoadCursorImage)(cursor_info->pScrn, src); + + (*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y); + (*cursor_info->ShowCursor)(cursor_info->pScrn); + } +} + +/** + * Clean up CRTC-based cursor code + */ +_X_EXPORT void +xf86_cursors_fini (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (xf86_config->cursor_info) + { + xf86DestroyCursorInfoRec (xf86_config->cursor_info); + xf86_config->cursor_info = NULL; + } + if (xf86_config->cursor_image) + { + xfree (xf86_config->cursor_image); + xf86_config->cursor_image = NULL; + } + if (xf86_config->cursor) + { + FreeCursor (xf86_config->cursor, None); + xf86_config->cursor = NULL; + } +} diff --git a/xorg-server/hw/xfree86/modes/xf86DiDGA.c b/xorg-server/hw/xfree86/modes/xf86DiDGA.c new file mode 100644 index 000000000..f40d0abef --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86DiDGA.c @@ -0,0 +1,286 @@ +/* + * Copyright © 2006 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include "xf86.h" +#include "xf86DDC.h" +#include "xf86_OSproc.h" +#include "dgaproc.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "windowstr.h" + +static Bool +xf86_dga_get_modes (ScreenPtr pScreen) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + DGAModePtr modes, mode; + DisplayModePtr display_mode; + int bpp = scrn->bitsPerPixel >> 3; + int num; + + num = 0; + display_mode = scrn->modes; + while (display_mode) + { + num++; + display_mode = display_mode->next; + if (display_mode == scrn->modes) + break; + } + + if (!num) + return FALSE; + + modes = xalloc(num * sizeof(DGAModeRec)); + if (!modes) + return FALSE; + + num = 0; + display_mode = scrn->modes; + while (display_mode) + { + mode = modes + num++; + + mode->mode = display_mode; + mode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (display_mode->Flags & V_DBLSCAN) + mode->flags |= DGA_DOUBLESCAN; + if (display_mode->Flags & V_INTERLACE) + mode->flags |= DGA_INTERLACED; + mode->byteOrder = scrn->imageByteOrder; + mode->depth = scrn->depth; + mode->bitsPerPixel = scrn->bitsPerPixel; + mode->red_mask = scrn->mask.red; + mode->green_mask = scrn->mask.green; + mode->blue_mask = scrn->mask.blue; + mode->visualClass = (bpp == 1) ? PseudoColor : TrueColor; + mode->viewportWidth = display_mode->HDisplay; + mode->viewportHeight = display_mode->VDisplay; + mode->xViewportStep = (bpp == 3) ? 2 : 1; + mode->yViewportStep = 1; + mode->viewportFlags = DGA_FLIP_RETRACE; + mode->offset = 0; + mode->address = (unsigned char *) xf86_config->dga_address; + mode->bytesPerScanline = xf86_config->dga_stride; + mode->imageWidth = xf86_config->dga_width; + mode->imageHeight = xf86_config->dga_height; + mode->pixmapWidth = mode->imageWidth; + mode->pixmapHeight = mode->imageHeight; + mode->maxViewportX = mode->imageWidth - mode->viewportWidth; + mode->maxViewportY = mode->imageHeight - mode->viewportHeight; + + display_mode = display_mode->next; + if (display_mode == scrn->modes) + break; + } + if (xf86_config->dga_modes) + xfree (xf86_config->dga_modes); + xf86_config->dga_nmode = num; + xf86_config->dga_modes = modes; + return TRUE; +} + +static Bool +xf86_dga_set_mode(ScrnInfoPtr scrn, DGAModePtr display_mode) +{ + ScreenPtr pScreen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (!display_mode) + { + if (xf86_config->dga_save_mode) + { + xf86SwitchMode(pScreen, xf86_config->dga_save_mode); + xf86_config->dga_save_mode = NULL; + } + } + else + { + if (!xf86_config->dga_save_mode) + { + xf86_config->dga_save_mode = scrn->currentMode; + xf86SwitchMode(pScreen, display_mode->mode); + } + } + return TRUE; +} + +static int +xf86_dga_get_viewport(ScrnInfoPtr scrn) +{ + return 0; +} + +static void +xf86_dga_set_viewport(ScrnInfoPtr scrn, int x, int y, int flags) +{ + scrn->AdjustFrame(scrn->pScreen->myNum, x, y, flags); +} + +static Bool +xf86_dga_get_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr *ppDrawable, GCPtr *ppGC) +{ + ScreenPtr pScreen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + PixmapPtr pPixmap; + GCPtr pGC; + + pPixmap = GetScratchPixmapHeader (pScreen, xf86_config->dga_width, xf86_config->dga_height, + scrn->depth, scrn->bitsPerPixel, xf86_config->dga_stride, + (char *) scrn->memPhysBase + scrn->fbOffset); + if (!pPixmap) + return FALSE; + pGC = GetScratchGC (scrn->depth, pScreen); + if (!pGC) + { + FreeScratchPixmapHeader (pPixmap); + return FALSE; + } + *ppDrawable = &pPixmap->drawable; + *ppGC = pGC; + return TRUE; +} + +static void +xf86_dga_release_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr pDrawable, GCPtr pGC) +{ + FreeScratchGC (pGC); + FreeScratchPixmapHeader ((PixmapPtr) pDrawable); +} + +static void +xf86_dga_fill_rect(ScrnInfoPtr scrn, int x, int y, int w, int h, unsigned long color) +{ + GCPtr pGC; + DrawablePtr pDrawable; + XID vals[1]; + xRectangle r; + + if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) + return; + vals[0] = color; + ChangeGC (pGC, GCForeground, vals); + ValidateGC (pDrawable, pGC); + r.x = x; + r.y = y; + r.width = w; + r.height = h; + pGC->ops->PolyFillRect (pDrawable, pGC, 1, &r); + xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); +} + +static void +xf86_dga_sync(ScrnInfoPtr scrn) +{ + ScreenPtr pScreen = scrn->pScreen; + WindowPtr pRoot = WindowTable [pScreen->myNum]; + char buffer[4]; + + pScreen->GetImage (&pRoot->drawable, 0, 0, 1, 1, ZPixmap, ~0L, buffer); +} + +static void +xf86_dga_blit_rect(ScrnInfoPtr scrn, int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + DrawablePtr pDrawable; + GCPtr pGC; + + if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC)) + return; + ValidateGC (pDrawable, pGC); + pGC->ops->CopyArea (pDrawable, pDrawable, pGC, srcx, srcy, w, h, dstx, dsty); + xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC); +} + +static Bool +xf86_dga_open_framebuffer(ScrnInfoPtr scrn, + char **name, + unsigned char **mem, int *size, int *offset, int *flags) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + *size = xf86_config->dga_stride * xf86_config->dga_height; + *mem = (unsigned char *) (xf86_config->dga_address); + *offset = 0; + *flags = DGA_NEED_ROOT; + + return TRUE; +} + +static void +xf86_dga_close_framebuffer(ScrnInfoPtr scrn) +{ +} + +static DGAFunctionRec xf86_dga_funcs = { + xf86_dga_open_framebuffer, + xf86_dga_close_framebuffer, + xf86_dga_set_mode, + xf86_dga_set_viewport, + xf86_dga_get_viewport, + xf86_dga_sync, + xf86_dga_fill_rect, + xf86_dga_blit_rect, + NULL +}; + +_X_EXPORT Bool +xf86DiDGAReInit (ScreenPtr pScreen) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (!xf86_dga_get_modes (pScreen)) + return FALSE; + + return DGAReInitModes (pScreen, xf86_config->dga_modes, xf86_config->dga_nmode); +} + +_X_EXPORT Bool +xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address) +{ + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + xf86_config->dga_flags = 0; + xf86_config->dga_address = dga_address; + xf86_config->dga_width = scrn->virtualX; + xf86_config->dga_height = scrn->virtualY; + xf86_config->dga_stride = scrn->displayWidth * scrn->bitsPerPixel >> 3; + + if (!xf86_dga_get_modes (pScreen)) + return FALSE; + + return DGAInit(pScreen, &xf86_dga_funcs, xf86_config->dga_modes, xf86_config->dga_nmode); +} diff --git a/xorg-server/hw/xfree86/modes/xf86EdidModes.c b/xorg-server/hw/xfree86/modes/xf86EdidModes.c new file mode 100644 index 000000000..bf0ea3f64 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86EdidModes.c @@ -0,0 +1,765 @@ +/* + * Copyright 2006 Luc Verhaegen. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * @file This file covers code to convert a xf86MonPtr containing EDID-probed + * information into a list of modes, including applying monitor-specific + * quirks to fix broken EDID data. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include "xf86.h" +#include "xf86DDC.h" +#include <X11/Xatom.h> +#include "property.h" +#include "propertyst.h" +#include "xf86DDC.h" +#include "xf86Crtc.h" +#include <string.h> +#include <math.h> + +/* + * Quirks to work around broken EDID data from various monitors. + */ + +typedef enum { + DDC_QUIRK_NONE = 0, + /* First detailed mode is bogus, prefer largest mode at 60hz */ + DDC_QUIRK_PREFER_LARGE_60 = 1 << 0, + /* 135MHz clock is too high, drop a bit */ + DDC_QUIRK_135_CLOCK_TOO_HIGH = 1 << 1, + /* Prefer the largest mode at 75 Hz */ + DDC_QUIRK_PREFER_LARGE_75 = 1 << 2, + /* Convert detailed timing's horizontal from units of cm to mm */ + DDC_QUIRK_DETAILED_H_IN_CM = 1 << 3, + /* Convert detailed timing's vertical from units of cm to mm */ + DDC_QUIRK_DETAILED_V_IN_CM = 1 << 4, + /* Detailed timing descriptors have bogus size values, so just take the + * maximum size and use that. + */ + DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE = 1 << 5, + /* Monitor forgot to set the first detailed is preferred bit. */ + DDC_QUIRK_FIRST_DETAILED_PREFERRED = 1 << 6, + /* use +hsync +vsync for detailed mode */ + DDC_QUIRK_DETAILED_SYNC_PP = 1 << 7, +} ddc_quirk_t; + +static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) +{ + /* Belinea 10 15 55 */ + if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && + ((DDC->vendor.prod_id == 1516) || + (DDC->vendor.prod_id == 0x77e))) + return TRUE; + + /* Acer AL1706 */ + if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && + DDC->vendor.prod_id == 44358) + return TRUE; + + /* Bug #10814: Samsung SyncMaster 225BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 596) + return TRUE; + + /* Bug #10545: Samsung SyncMaster 226BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 638) + return TRUE; + + /* Acer F51 */ + if (memcmp (DDC->vendor.name, "API", 4) == 0 && + DDC->vendor.prod_id == 0x7602) + return TRUE; + + + return FALSE; +} + +static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #10304: LGPhilipsLCD LP154W01-A5 */ + if (memcmp (DDC->vendor.name, "LPL", 4) == 0 && + (DDC->vendor.prod_id == 0 || DDC->vendor.prod_id == 0x2a00)) + return TRUE; + + return FALSE; +} + +static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC) +{ + /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */ + if (memcmp (DDC->vendor.name, "EPI", 4) == 0 && + DDC->vendor.prod_id == 59264) + return TRUE; + + return FALSE; +} + +static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC) +{ + /* Philips 107p5 CRT. Reported on xorg@ with pastebin. */ + if (memcmp (DDC->vendor.name, "PHL", 4) == 0 && + DDC->vendor.prod_id == 57364) + return TRUE; + + /* Proview AY765C 17" LCD. See bug #15160*/ + if (memcmp (DDC->vendor.name, "PTS", 4) == 0 && + DDC->vendor.prod_id == 765) + return TRUE; + + /* ACR of some sort RH #284231 */ + if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && + DDC->vendor.prod_id == 2423) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #12439: Samsung SyncMaster 205BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 541) + return TRUE; + return FALSE; +} + +typedef struct { + Bool (*detect) (int scrnIndex, xf86MonPtr DDC); + ddc_quirk_t quirk; + char *description; +} ddc_quirk_map_t; + +static const ddc_quirk_map_t ddc_quirks[] = { + { + quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60, + "Detailed timing is not preferred, use largest mode at 60Hz" + }, + { + quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH, + "Recommended 135MHz pixel clock is too high" + }, + { + quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75, + "Detailed timing is not preferred, use largest mode at 75Hz" + }, + { + quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM, + "Detailed timings give horizontal size in cm." + }, + { + quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM, + "Detailed timings give vertical size in cm." + }, + { + quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE, + "Detailed timings give sizes in cm." + }, + { + quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED, + "First detailed timing was not marked as preferred." + }, + { + quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP, + "Use +hsync +vsync for detailed timing." + }, + { + NULL, DDC_QUIRK_NONE, + "No known quirks" + }, +}; + +/* + * TODO: + * - for those with access to the VESA DMT standard; review please. + */ +#define MODEPREFIX NULL, NULL, NULL, 0, M_T_DRIVER +#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 + +static const DisplayModeRec DDCEstablishedModes[17] = { + { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ + { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ + { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ + { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 491, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ + { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ + { MODEPREFIX, 25200, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ + { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ + { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ + { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ + { MODEPREFIX, 78800, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ + { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ + { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ + { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 776, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ + { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ + { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ + { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ + { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ +}; + +static DisplayModePtr +DDCModesFromEstablished(int scrnIndex, struct established_timings *timing, + ddc_quirk_t quirks) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + CARD32 bits = (timing->t1) | (timing->t2 << 8) | + ((timing->t_manu & 0x80) << 9); + int i; + + for (i = 0; i < 17; i++) { + if (bits & (0x01 << i)) { + Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); + Modes = xf86ModesAdd(Modes, Mode); + } + } + + return Modes; +} + +#define LEVEL_DMT 0 +#define LEVEL_GTF 1 +#define LEVEL_CVT 2 + +static int +MonitorStandardTimingLevel(xf86MonPtr DDC) +{ + if (DDC->ver.revision >= 2) { + if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) { + return LEVEL_CVT; + } + return LEVEL_GTF; + } + return LEVEL_DMT; +} + +/* + * This is not really correct. Appendix B of the EDID 1.4 spec defines + * the right thing to do here. If the timing given here matches a mode + * defined in the VESA DMT standard, we _must_ use that. If the device + * supports CVT modes, then we should generate a CVT timing. If both + * of the above fail, use GTF. + * + * There are some wrinkles here. EDID 1.1 and 1.0 sinks can't really + * "support" GTF, since it wasn't a standard yet; so if they ask for a + * timing in this section that isn't defined in DMT, returning a GTF mode + * may not actually be valid. EDID 1.3 sinks often report support for + * some CVT modes, but they are not required to support CVT timings for + * modes in the standard timing descriptor, so we should _not_ treat them + * as CVT-compliant (unless specified in an extension block I suppose). + * + * EDID 1.4 requires that all sink devices support both GTF and CVT timings + * for modes in this section, but does say that CVT is preferred. + */ +static DisplayModePtr +DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks, + int timing_level) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + int i; + + for (i = 0; i < STD_TIMINGS; i++) { + if (timing[i].hsize && timing[i].vsize && timing[i].refresh) { + /* XXX check for DMT first, else... */ + if (timing_level == LEVEL_CVT) + Mode = xf86CVTMode(timing[i].hsize, timing[i].vsize, + timing[i].refresh, FALSE, FALSE); + else + Mode = xf86GTFMode(timing[i].hsize, timing[i].vsize, + timing[i].refresh, FALSE, FALSE); + + Mode->type = M_T_DRIVER; + Modes = xf86ModesAdd(Modes, Mode); + } + } + + return Modes; +} + +/* + * + */ +static DisplayModePtr +DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, + Bool preferred, ddc_quirk_t quirks) +{ + DisplayModePtr Mode; + + /* + * Refuse to create modes that are insufficiently large. 64 is a random + * number, maybe the spec says something about what the minimum is. In + * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe + * our parser is just being too aggresive there. + */ + if (timing->h_active < 64 || timing->v_active < 64) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring tiny %dx%d mode\n", __func__, + timing->h_active, timing->v_active); + return NULL; + } + + /* We don't do stereo */ + if (timing->stereo) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring: We don't handle stereo.\n", __func__); + return NULL; + } + + /* We only do seperate sync currently */ + if (timing->sync != 0x03) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: %dx%d Warning: We only handle seperate" + " sync.\n", __func__, timing->h_active, timing->v_active); + } + + Mode = xnfcalloc(1, sizeof(DisplayModeRec)); + + Mode->type = M_T_DRIVER; + if (preferred) + Mode->type |= M_T_PREFERRED; + + if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) && + timing->clock == 135000000 ) + Mode->Clock = 108880; + else + Mode->Clock = timing->clock / 1000.0; + + Mode->HDisplay = timing->h_active; + Mode->HSyncStart = timing->h_active + timing->h_sync_off; + Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; + Mode->HTotal = timing->h_active + timing->h_blanking; + + Mode->VDisplay = timing->v_active; + Mode->VSyncStart = timing->v_active + timing->v_sync_off; + Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; + Mode->VTotal = timing->v_active + timing->v_blanking; + + /* perform basic check on the detail timing */ + if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) { + xfree(Mode); + return NULL; + } + + xf86SetModeDefaultName(Mode); + + /* We ignore h/v_size and h/v_border for now. */ + + if (timing->interlaced) + Mode->Flags |= V_INTERLACE; + + if (quirks & DDC_QUIRK_DETAILED_SYNC_PP) + Mode->Flags |= V_PVSYNC | V_PHSYNC; + else { + if (timing->misc & 0x02) + Mode->Flags |= V_PVSYNC; + else + Mode->Flags |= V_NVSYNC; + + if (timing->misc & 0x01) + Mode->Flags |= V_PHSYNC; + else + Mode->Flags |= V_NHSYNC; + } + + return Mode; +} + +static DisplayModePtr +DDCModesFromCVT(int scrnIndex, struct cvt_timings *t) +{ + DisplayModePtr modes = NULL; + int i; + + for (i = 0; i < 4; i++) { + if (t[i].height) { + if (t[i].rates & 0x10) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 50, 0, 0)); + if (t[i].rates & 0x08) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 0, 0)); + if (t[i].rates & 0x04) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 75, 0, 0)); + if (t[i].rates & 0x02) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 85, 0, 0)); + if (t[i].rates & 0x01) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 1, 0)); + } else break; + } + + return modes; +} + + +/* + * This is only valid when the sink claims to be continuous-frequency + * but does not supply a detailed range descriptor. Such sinks are + * arguably broken. Currently the mode validation code isn't aware of + * this; the non-RANDR code even punts the decision of optional sync + * range checking to the driver. Loss. + */ +static void +DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) +{ + DisplayModePtr Mode = Modes; + + if (!Monitor || !Modes) + return; + + /* set up the ranges for scanning through the modes */ + Monitor->nHsync = 1; + Monitor->hsync[0].lo = 1024.0; + Monitor->hsync[0].hi = 0.0; + + Monitor->nVrefresh = 1; + Monitor->vrefresh[0].lo = 1024.0; + Monitor->vrefresh[0].hi = 0.0; + + while (Mode) { + if (!Mode->HSync) + Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal); + + if (!Mode->VRefresh) + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + if (Mode->HSync < Monitor->hsync[0].lo) + Monitor->hsync[0].lo = Mode->HSync; + + if (Mode->HSync > Monitor->hsync[0].hi) + Monitor->hsync[0].hi = Mode->HSync; + + if (Mode->VRefresh < Monitor->vrefresh[0].lo) + Monitor->vrefresh[0].lo = Mode->VRefresh; + + if (Mode->VRefresh > Monitor->vrefresh[0].hi) + Monitor->vrefresh[0].hi = Mode->VRefresh; + + Mode = Mode->next; + } +} + +static ddc_quirk_t +xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose) +{ + ddc_quirk_t quirks; + int i; + + quirks = DDC_QUIRK_NONE; + for (i = 0; ddc_quirks[i].detect; i++) { + if (ddc_quirks[i].detect (scrnIndex, DDC)) { + if (verbose) { + xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n", + ddc_quirks[i].description); + } + quirks |= ddc_quirks[i].quirk; + } + } + + return quirks; +} + +/** + * Applies monitor-specific quirks to the decoded EDID information. + * + * Note that some quirks applying to the mode list are still implemented in + * xf86DDCGetModes. + */ +void +xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC) +{ + ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE); + int i; + + for (i = 0; i < DET_TIMINGS; i++) { + struct detailed_monitor_section *det_mon = &DDC->det_mon[i]; + + if (det_mon->type != DT) + continue; + + if (quirks & DDC_QUIRK_DETAILED_H_IN_CM) + det_mon->section.d_timings.h_size *= 10; + + if (quirks & DDC_QUIRK_DETAILED_V_IN_CM) + det_mon->section.d_timings.v_size *= 10; + + if (quirks & DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE) { + det_mon->section.d_timings.h_size = 10 * DDC->features.hsize; + det_mon->section.d_timings.v_size = 10 * DDC->features.vsize; + } + } +} + +/** + * Walks the modes list, finding the mode with the largest area which is + * closest to the target refresh rate, and marks it as the only preferred mode. +*/ +static void +xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes, + float target_refresh) +{ + DisplayModePtr mode, best = modes; + + for (mode = modes; mode; mode = mode->next) + { + mode->type &= ~M_T_PREFERRED; + + if (mode == best) continue; + + if (mode->HDisplay * mode->VDisplay > + best->HDisplay * best->VDisplay) + { + best = mode; + continue; + } + if (mode->HDisplay * mode->VDisplay == + best->HDisplay * best->VDisplay) + { + double mode_refresh = xf86ModeVRefresh (mode); + double best_refresh = xf86ModeVRefresh (best); + double mode_dist = fabs(mode_refresh - target_refresh); + double best_dist = fabs(best_refresh - target_refresh); + + if (mode_dist < best_dist) + { + best = mode; + continue; + } + } + } + if (best) + best->type |= M_T_PREFERRED; +} + +_X_EXPORT DisplayModePtr +xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) +{ + int i; + DisplayModePtr Modes = NULL, Mode; + ddc_quirk_t quirks; + Bool preferred; + int timing_level; + + xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n", + DDC->vendor.name, DDC->vendor.prod_id); + + quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE); + + preferred = PREFERRED_TIMING_MODE(DDC->features.msc); + if (DDC->ver.revision >= 4) + preferred = TRUE; + if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED) + preferred = TRUE; + if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75)) + preferred = FALSE; + + timing_level = MonitorStandardTimingLevel(DDC); + + for (i = 0; i < DET_TIMINGS; i++) { + struct detailed_monitor_section *det_mon = &DDC->det_mon[i]; + + switch (det_mon->type) { + case DT: + Mode = DDCModeFromDetailedTiming(scrnIndex, + &det_mon->section.d_timings, + preferred, + quirks); + preferred = FALSE; + Modes = xf86ModesAdd(Modes, Mode); + break; + case DS_STD_TIMINGS: + Mode = DDCModesFromStandardTiming(det_mon->section.std_t, + quirks, timing_level); + Modes = xf86ModesAdd(Modes, Mode); + break; + case DS_CVT: + Mode = DDCModesFromCVT(scrnIndex, det_mon->section.cvt); + Modes = xf86ModesAdd(Modes, Mode); + break; + default: + break; + } + } + + /* Add established timings */ + Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks); + Modes = xf86ModesAdd(Modes, Mode); + + /* Add standard timings */ + Mode = DDCModesFromStandardTiming(DDC->timings2, quirks, timing_level); + Modes = xf86ModesAdd(Modes, Mode); + + if (quirks & DDC_QUIRK_PREFER_LARGE_60) + xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60); + + if (quirks & DDC_QUIRK_PREFER_LARGE_75) + xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75); + + return Modes; +} + +/* + * Fill out MonPtr with xf86MonPtr information. + */ +_X_EXPORT void +xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + int i, clock; + Bool have_hsync = FALSE, have_vrefresh = FALSE, have_maxpixclock = FALSE; + + if (!Monitor || !DDC) + return; + + Monitor->DDC = DDC; + + if (Monitor->widthmm <= 0 && Monitor->heightmm <= 0) { + Monitor->widthmm = 10 * DDC->features.hsize; + Monitor->heightmm = 10 * DDC->features.vsize; + } + + /* + * If this is a digital display, then we can use reduced blanking. + * XXX This is a 1.3 heuristic. 1.4 explicitly defines rb support. + */ + if (DDC->features.input_type) + Monitor->reducedblanking = TRUE; + + Modes = xf86DDCGetModes(scrnIndex, DDC); + + /* Skip EDID ranges if they were specified in the config file */ + have_hsync = (Monitor->nHsync != 0); + have_vrefresh = (Monitor->nVrefresh != 0); + have_maxpixclock = (Monitor->maxPixClock != 0); + + /* Go through the detailed monitor sections */ + for (i = 0; i < DET_TIMINGS; i++) { + switch (DDC->det_mon[i].type) { + case DS_RANGES: + if (!have_hsync) { + if (!Monitor->nHsync) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for horizontal sync\n"); + Monitor->hsync[Monitor->nHsync].lo = + DDC->det_mon[i].section.ranges.min_h; + Monitor->hsync[Monitor->nHsync].hi = + DDC->det_mon[i].section.ranges.max_h; + Monitor->nHsync++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using hsync ranges from config file\n"); + } + + if (!have_vrefresh) { + if (!Monitor->nVrefresh) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for vertical refresh\n"); + Monitor->vrefresh[Monitor->nVrefresh].lo = + DDC->det_mon[i].section.ranges.min_v; + Monitor->vrefresh[Monitor->nVrefresh].hi = + DDC->det_mon[i].section.ranges.max_v; + Monitor->nVrefresh++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using vrefresh ranges from config file\n"); + } + + clock = DDC->det_mon[i].section.ranges.max_clock * 1000; + if (!have_maxpixclock && clock > Monitor->maxPixClock) + Monitor->maxPixClock = clock; + + break; + default: + break; + } + } + + if (Modes) { + /* Print Modes */ + xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n"); + + Mode = Modes; + while (Mode) { + xf86PrintModeline(scrnIndex, Mode); + Mode = Mode->next; + } + + /* Do we still need ranges to be filled in? */ + if (!Monitor->nHsync || !Monitor->nVrefresh) + DDCGuessRangesFromModes(scrnIndex, Monitor, Modes); + + /* look for last Mode */ + Mode = Modes; + + while (Mode->next) + Mode = Mode->next; + + /* add to MonPtr */ + if (Monitor->Modes) { + Monitor->Last->next = Modes; + Modes->prev = Monitor->Last; + Monitor->Last = Mode; + } else { + Monitor->Modes = Modes; + Monitor->Last = Mode; + } + } +} diff --git a/xorg-server/hw/xfree86/modes/xf86Modes.c b/xorg-server/hw/xfree86/modes/xf86Modes.c new file mode 100644 index 000000000..ea398ad81 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86Modes.c @@ -0,0 +1,697 @@ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include "xf86Modes.h" +#include "xf86Priv.h" + +extern XF86ConfigPtr xf86configptr; + +/* + * This is the version number where we epoched. These files get copied + * into drivers that want to use this setup infrastructure on pre-1.3 + * servers, so when that happens they need to define these symbols + * themselves. However, _in_ the server, we basically always define them now. + */ +#if XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(7,2,99,2,0) + +/** + * Calculates the horizontal sync rate of a mode. + * + * Exact copy of xf86Mode.c's. + */ +_X_EXPORT double +xf86ModeHSync(DisplayModePtr mode) +{ + double hsync = 0.0; + + if (mode->HSync > 0.0) + hsync = mode->HSync; + else if (mode->HTotal > 0) + hsync = (float)mode->Clock / (float)mode->HTotal; + + return hsync; +} + +/** + * Calculates the vertical refresh rate of a mode. + * + * Exact copy of xf86Mode.c's. + */ +_X_EXPORT double +xf86ModeVRefresh(DisplayModePtr mode) +{ + double refresh = 0.0; + + if (mode->VRefresh > 0.0) + refresh = mode->VRefresh; + else if (mode->HTotal > 0 && mode->VTotal > 0) { + refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal; + if (mode->Flags & V_INTERLACE) + refresh *= 2.0; + if (mode->Flags & V_DBLSCAN) + refresh /= 2.0; + if (mode->VScan > 1) + refresh /= (float)(mode->VScan); + } + return refresh; +} + +_X_EXPORT int +xf86ModeWidth (DisplayModePtr mode, Rotation rotation) +{ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_180: + return mode->HDisplay; + case RR_Rotate_90: + case RR_Rotate_270: + return mode->VDisplay; + default: + return 0; + } +} + +_X_EXPORT int +xf86ModeHeight (DisplayModePtr mode, Rotation rotation) +{ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_180: + return mode->VDisplay; + case RR_Rotate_90: + case RR_Rotate_270: + return mode->HDisplay; + default: + return 0; + } +} + +/** Calculates the memory bandwidth (in MiB/sec) of a mode. */ +_X_EXPORT unsigned int +xf86ModeBandwidth(DisplayModePtr mode, int depth) +{ + float a_active, a_total, active_percent, pixels_per_second; + int bytes_per_pixel = (depth + 7) / 8; + + if (!mode->HTotal || !mode->VTotal || !mode->Clock) + return 0; + + a_active = mode->HDisplay * mode->VDisplay; + a_total = mode->HTotal * mode->VTotal; + active_percent = a_active / a_total; + pixels_per_second = active_percent * mode->Clock * 1000.0; + + return (unsigned int)(pixels_per_second * bytes_per_pixel / (1024 * 1024)); +} + +/** Sets a default mode name of <width>x<height> on a mode. */ +_X_EXPORT void +xf86SetModeDefaultName(DisplayModePtr mode) +{ + if (mode->name != NULL) + xfree(mode->name); + + mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay); +} + +/* + * xf86SetModeCrtc + * + * Initialises the Crtc parameters for a mode. The initialisation includes + * adjustments for interlaced and double scan modes. + * + * Exact copy of xf86Mode.c's. + */ +_X_EXPORT void +xf86SetModeCrtc(DisplayModePtr p, int adjustFlags) +{ + if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN)) + return; + + p->CrtcHDisplay = p->HDisplay; + p->CrtcHSyncStart = p->HSyncStart; + p->CrtcHSyncEnd = p->HSyncEnd; + p->CrtcHTotal = p->HTotal; + p->CrtcHSkew = p->HSkew; + p->CrtcVDisplay = p->VDisplay; + p->CrtcVSyncStart = p->VSyncStart; + p->CrtcVSyncEnd = p->VSyncEnd; + p->CrtcVTotal = p->VTotal; + if (p->Flags & V_INTERLACE) { + if (adjustFlags & INTERLACE_HALVE_V) { + p->CrtcVDisplay /= 2; + p->CrtcVSyncStart /= 2; + p->CrtcVSyncEnd /= 2; + p->CrtcVTotal /= 2; + } + /* Force interlaced modes to have an odd VTotal */ + /* maybe we should only do this when INTERLACE_HALVE_V is set? */ + p->CrtcVTotal |= 1; + } + + if (p->Flags & V_DBLSCAN) { + p->CrtcVDisplay *= 2; + p->CrtcVSyncStart *= 2; + p->CrtcVSyncEnd *= 2; + p->CrtcVTotal *= 2; + } + if (p->VScan > 1) { + p->CrtcVDisplay *= p->VScan; + p->CrtcVSyncStart *= p->VScan; + p->CrtcVSyncEnd *= p->VScan; + p->CrtcVTotal *= p->VScan; + } + p->CrtcVBlankStart = min(p->CrtcVSyncStart, p->CrtcVDisplay); + p->CrtcVBlankEnd = max(p->CrtcVSyncEnd, p->CrtcVTotal); + p->CrtcHBlankStart = min(p->CrtcHSyncStart, p->CrtcHDisplay); + p->CrtcHBlankEnd = max(p->CrtcHSyncEnd, p->CrtcHTotal); + + p->CrtcHAdjusted = FALSE; + p->CrtcVAdjusted = FALSE; +} + +/** + * Allocates and returns a copy of pMode, including pointers within pMode. + */ +_X_EXPORT DisplayModePtr +xf86DuplicateMode(DisplayModePtr pMode) +{ + DisplayModePtr pNew; + + pNew = xnfalloc(sizeof(DisplayModeRec)); + *pNew = *pMode; + pNew->next = NULL; + pNew->prev = NULL; + + if (pMode->name == NULL) + xf86SetModeDefaultName(pNew); + else + pNew->name = xnfstrdup(pMode->name); + + return pNew; +} + +/** + * Duplicates every mode in the given list and returns a pointer to the first + * mode. + * + * \param modeList doubly-linked mode list + */ +_X_EXPORT DisplayModePtr +xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList) +{ + DisplayModePtr first = NULL, last = NULL; + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + DisplayModePtr new; + + new = xf86DuplicateMode(mode); + + /* Insert pNew into modeList */ + if (last) { + last->next = new; + new->prev = last; + } else { + first = new; + new->prev = NULL; + } + new->next = NULL; + last = new; + } + + return first; +} + +/** + * Returns true if the given modes should program to the same timings. + * + * This doesn't use Crtc values, as it might be used on ModeRecs without the + * Crtc values set. So, it's assumed that the other numbers are enough. + * + * This isn't in xf86Modes.c, but it might deserve to be there. + */ +_X_EXPORT Bool +xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2) +{ + if (pMode1->Clock == pMode2->Clock && + pMode1->HDisplay == pMode2->HDisplay && + pMode1->HSyncStart == pMode2->HSyncStart && + pMode1->HSyncEnd == pMode2->HSyncEnd && + pMode1->HTotal == pMode2->HTotal && + pMode1->HSkew == pMode2->HSkew && + pMode1->VDisplay == pMode2->VDisplay && + pMode1->VSyncStart == pMode2->VSyncStart && + pMode1->VSyncEnd == pMode2->VSyncEnd && + pMode1->VTotal == pMode2->VTotal && + pMode1->VScan == pMode2->VScan && + pMode1->Flags == pMode2->Flags) + { + return TRUE; + } else { + return FALSE; + } +} + +/* exact copy of xf86Mode.c */ +static void +add(char **p, char *new) +{ + *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2); + strcat(*p, " "); + strcat(*p, new); +} + +/** + * Print out a modeline. + * + * Convenient VRefresh printing was added, though, compared to xf86Mode.c + */ +_X_EXPORT void +xf86PrintModeline(int scrnIndex,DisplayModePtr mode) +{ + char tmp[256]; + char *flags = xnfcalloc(1, 1); + + if (mode->HSkew) { + snprintf(tmp, 256, "hskew %i", mode->HSkew); + add(&flags, tmp); + } + if (mode->VScan) { + snprintf(tmp, 256, "vscan %i", mode->VScan); + add(&flags, tmp); + } + if (mode->Flags & V_INTERLACE) add(&flags, "interlace"); + if (mode->Flags & V_CSYNC) add(&flags, "composite"); + if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan"); + if (mode->Flags & V_BCAST) add(&flags, "bcast"); + if (mode->Flags & V_PHSYNC) add(&flags, "+hsync"); + if (mode->Flags & V_NHSYNC) add(&flags, "-hsync"); + if (mode->Flags & V_PVSYNC) add(&flags, "+vsync"); + if (mode->Flags & V_NVSYNC) add(&flags, "-vsync"); + if (mode->Flags & V_PCSYNC) add(&flags, "+csync"); + if (mode->Flags & V_NCSYNC) add(&flags, "-csync"); +#if 0 + if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2"); +#endif + xf86DrvMsg(scrnIndex, X_INFO, + "Modeline \"%s\"x%.01f %6.2f %i %i %i %i %i %i %i %i%s " + "(%.01f kHz)\n", + mode->name, mode->VRefresh, mode->Clock/1000., mode->HDisplay, + mode->HSyncStart, mode->HSyncEnd, mode->HTotal, + mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, + mode->VTotal, flags, xf86ModeHSync(mode)); + xfree(flags); +} +#endif /* XORG_VERSION_CURRENT <= 7.2.99.2 */ + +/** + * Marks as bad any modes with unsupported flags. + * + * \param modeList doubly-linked list of modes. + * \param flags flags supported by the driver. + * + * \bug only V_INTERLACE and V_DBLSCAN are supported. Is that enough? + */ +_X_EXPORT void +xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int flags) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + if (mode->Flags & V_INTERLACE && !(flags & V_INTERLACE)) + mode->status = MODE_NO_INTERLACE; + if (mode->Flags & V_DBLSCAN && !(flags & V_DBLSCAN)) + mode->status = MODE_NO_DBLESCAN; + } +} + +/** + * Marks as bad any modes extending beyond the given max X, Y, or pitch. + * + * \param modeList doubly-linked list of modes. + */ +_X_EXPORT void +xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int maxX, int maxY, int maxPitch) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + if (maxPitch > 0 && mode->HDisplay > maxPitch) + mode->status = MODE_BAD_WIDTH; + + if (maxX > 0 && mode->HDisplay > maxX) + mode->status = MODE_VIRTUAL_X; + + if (maxY > 0 && mode->VDisplay > maxY) + mode->status = MODE_VIRTUAL_Y; + + if (mode->next == modeList) + break; + } +} + +/** + * Marks as bad any modes that aren't supported by the given monitor's + * hsync and vrefresh ranges. + * + * \param modeList doubly-linked list of modes. + */ +_X_EXPORT void +xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, + MonPtr mon) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + Bool bad; + int i; + + bad = TRUE; + for (i = 0; i < mon->nHsync; i++) { + if (xf86ModeHSync(mode) >= mon->hsync[i].lo * (1-SYNC_TOLERANCE) && + xf86ModeHSync(mode) <= mon->hsync[i].hi * (1+SYNC_TOLERANCE)) + { + bad = FALSE; + } + } + if (bad) + mode->status = MODE_HSYNC; + + bad = TRUE; + for (i = 0; i < mon->nVrefresh; i++) { + if (xf86ModeVRefresh(mode) >= mon->vrefresh[i].lo * (1-SYNC_TOLERANCE) && + xf86ModeVRefresh(mode) <= mon->vrefresh[i].hi * (1+SYNC_TOLERANCE)) + { + bad = FALSE; + } + } + if (bad) + mode->status = MODE_VSYNC; + + if (mode->next == modeList) + break; + } +} + +/** + * Marks as bad any modes extending beyond outside of the given clock ranges. + * + * \param modeList doubly-linked list of modes. + * \param min pointer to minimums of clock ranges + * \param max pointer to maximums of clock ranges + * \param n_ranges number of ranges. + */ +_X_EXPORT void +xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int *min, int *max, int n_ranges) +{ + DisplayModePtr mode; + int i; + + for (mode = modeList; mode != NULL; mode = mode->next) { + Bool good = FALSE; + for (i = 0; i < n_ranges; i++) { + if (mode->Clock >= min[i] * (1-SYNC_TOLERANCE) && + mode->Clock <= max[i] * (1+SYNC_TOLERANCE)) { + good = TRUE; + break; + } + } + if (!good) + mode->status = MODE_CLOCK_RANGE; + } +} + +/** + * If the user has specified a set of mode names to use, mark as bad any modes + * not listed. + * + * The user mode names specified are prefixes to names of modes, so "1024x768" + * will match modes named "1024x768", "1024x768x75", "1024x768-good", but + * "1024x768x75" would only match "1024x768x75" from that list. + * + * MODE_BAD is used as the rejection flag, for lack of a better flag. + * + * \param modeList doubly-linked list of modes. + */ +_X_EXPORT void +xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList) +{ + DisplayModePtr mode; + + if (pScrn->display->modes[0] == NULL) + return; + + for (mode = modeList; mode != NULL; mode = mode->next) { + int i; + Bool good = FALSE; + + for (i = 0; pScrn->display->modes[i] != NULL; i++) { + if (strncmp(pScrn->display->modes[i], mode->name, + strlen(pScrn->display->modes[i])) == 0) { + good = TRUE; + break; + } + } + if (!good) + mode->status = MODE_BAD; + } +} + + +/** + * Marks as bad any modes exceeding the given bandwidth. + * + * \param modeList doubly-linked list of modes. + * \param bandwidth bandwidth in MHz. + * \param depth color depth. + */ +_X_EXPORT void +xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList, + unsigned int bandwidth, int depth) +{ + DisplayModePtr mode; + + for (mode = modeList; mode != NULL; mode = mode->next) { + if (xf86ModeBandwidth(mode, depth) > bandwidth) + mode->status = MODE_BANDWIDTH; + } +} + +/** + * 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. + * \param verbose determines whether the reason for mode invalidation is + * printed. + */ +_X_EXPORT void +xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, + Bool verbose) +{ + DisplayModePtr mode; + + for (mode = *modeList; mode != NULL;) { + DisplayModePtr next = mode->next, first = *modeList; + + if (mode->status != MODE_OK) { + if (verbose) { + char *type = ""; + if (mode->type & M_T_BUILTIN) + type = "built-in "; + else if (mode->type & M_T_DEFAULT) + type = "default "; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Not using %smode \"%s\" (%s)\n", type, mode->name, + xf86ModeStatusToString(mode->status)); + } + xf86DeleteMode(modeList, mode); + } + + if (next == first) + break; + mode = next; + } +} + +/** + * Adds the new mode into the mode list, and returns the new list + * + * \param modes doubly-linked mode list. + */ +_X_EXPORT DisplayModePtr +xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new) +{ + if (modes == NULL) + return new; + + if (new) { + DisplayModePtr mode = modes; + + while (mode->next) + mode = mode->next; + + mode->next = new; + new->prev = mode; + } + + return modes; +} + +/** + * Build a mode list from a list of config file modes + */ +static DisplayModePtr +xf86GetConfigModes (XF86ConfModeLinePtr conf_mode) +{ + DisplayModePtr head = NULL, prev = NULL, mode; + + for (; conf_mode; conf_mode = (XF86ConfModeLinePtr) conf_mode->list.next) + { + mode = xcalloc(1, sizeof(DisplayModeRec)); + if (!mode) + continue; + mode->name = xstrdup(conf_mode->ml_identifier); + if (!mode->name) + { + xfree (mode); + continue; + } + mode->type = 0; + mode->Clock = conf_mode->ml_clock; + mode->HDisplay = conf_mode->ml_hdisplay; + mode->HSyncStart = conf_mode->ml_hsyncstart; + mode->HSyncEnd = conf_mode->ml_hsyncend; + mode->HTotal = conf_mode->ml_htotal; + mode->VDisplay = conf_mode->ml_vdisplay; + mode->VSyncStart = conf_mode->ml_vsyncstart; + mode->VSyncEnd = conf_mode->ml_vsyncend; + mode->VTotal = conf_mode->ml_vtotal; + mode->Flags = conf_mode->ml_flags; + mode->HSkew = conf_mode->ml_hskew; + mode->VScan = conf_mode->ml_vscan; + + mode->prev = prev; + mode->next = NULL; + if (prev) + prev->next = mode; + else + head = mode; + prev = mode; + } + return head; +} + +/** + * Build a mode list from a monitor configuration + */ +_X_EXPORT DisplayModePtr +xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor) +{ + DisplayModePtr modes = NULL; + XF86ConfModesLinkPtr modes_link; + + if (!conf_monitor) + return NULL; + + /* + * first we collect the mode lines from the UseModes directive + */ + for (modes_link = conf_monitor->mon_modes_sect_lst; + modes_link; + modes_link = modes_link->list.next) + { + /* If this modes link hasn't been resolved, go look it up now */ + if (!modes_link->ml_modes) + modes_link->ml_modes = xf86findModes (modes_link->ml_modes_str, + xf86configptr->conf_modes_lst); + if (modes_link->ml_modes) + modes = xf86ModesAdd (modes, + xf86GetConfigModes (modes_link->ml_modes->mon_modeline_lst)); + } + + return xf86ModesAdd (modes, + xf86GetConfigModes (conf_monitor->mon_modeline_lst)); +} + +/** + * Build a mode list containing all of the default modes + */ +_X_EXPORT DisplayModePtr +xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed) +{ + DisplayModePtr head = NULL, prev = NULL, mode; + int i; + + for (i = 0; i < xf86NumDefaultModes; i++) + { + DisplayModePtr defMode = &xf86DefaultModes[i]; + + if (!interlaceAllowed && (defMode->Flags & V_INTERLACE)) + continue; + if (!doubleScanAllowed && (defMode->Flags & V_DBLSCAN)) + continue; + + mode = xf86DuplicateMode(defMode); + + head = xf86ModesAdd(head, mode); + } + return head; +} diff --git a/xorg-server/hw/xfree86/modes/xf86Modes.h b/xorg-server/hw/xfree86/modes/xf86Modes.h new file mode 100644 index 000000000..acdea65d8 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86Modes.h @@ -0,0 +1,110 @@ +/* + * Copyright © 2006 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + * Eric Anholt <eric@anholt.net> + * + */ + +#ifndef _XF86MODES_H_ +#define _XF86MODES_H_ + +#include <stddef.h> +#include <string.h> +#include <stdio.h> + +#include "xf86.h" +#include "xorgVersion.h" +#include "edid.h" +#include "xf86Parser.h" +#if XF86_MODES_RENAME +#include "xf86Rename.h" +#endif + +double xf86ModeHSync(DisplayModePtr mode); +double xf86ModeVRefresh(DisplayModePtr mode); +unsigned int xf86ModeBandwidth(DisplayModePtr mode, int depth); + +int +xf86ModeWidth (DisplayModePtr mode, Rotation rotation); + +int +xf86ModeHeight (DisplayModePtr mode, Rotation rotation); + +DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode); +DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, + DisplayModePtr modeList); +void xf86SetModeDefaultName(DisplayModePtr mode); +void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags); +Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2); +void xf86PrintModeline(int scrnIndex,DisplayModePtr mode); +DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new); + +DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC); +DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, + Bool Reduced, Bool Interlaced); +DisplayModePtr xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins); + +void +xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int flags); + +void +xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int *min, int *max, int n_ranges); + +void +xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int maxX, int maxY, int maxPitch); + +void +xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList, + MonPtr mon); + +void +xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList, + unsigned int bandwidth, int depth); + +void +xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList); + +void +xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList, + Bool verbose); + +void +xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList, + int flags); + +void +xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList); + +DisplayModePtr +xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor); + +DisplayModePtr +xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed); + +void +xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC); + +#endif /* _XF86MODES_H_ */ diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c new file mode 100644 index 000000000..6f8ccdf84 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c @@ -0,0 +1,1133 @@ +/* + * Copyright © 2002 Keith Packard, member of The XFree86 Project, 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include "xf86.h" +#include "os.h" +#include "mibank.h" +#include "globals.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86DDC.h" +#include "mipointer.h" +#include "windowstr.h" +#include <randrstr.h> +#include <X11/extensions/render.h> + +#include "xf86Crtc.h" +#include "xf86RandR12.h" + +typedef struct _xf86RandR12Info { + int virtualX; + int virtualY; + int mmWidth; + int mmHeight; + int maxX; + int maxY; + Rotation rotation; /* current mode */ + Rotation supported_rotations; /* driver supported */ +} XF86RandRInfoRec, *XF86RandRInfoPtr; + +#ifdef RANDR_12_INTERFACE +static Bool xf86RandR12Init12 (ScreenPtr pScreen); +static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); +#endif + +static int xf86RandR12Generation; +static DevPrivateKey xf86RandR12Key; + +#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \ + dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key)) + +static int +xf86RandR12ModeRefresh (DisplayModePtr mode) +{ + if (mode->VRefresh) + return (int) (mode->VRefresh + 0.5); + else + return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5); +} + +static Bool +xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations) +{ + RRScreenSizePtr pSize; + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + DisplayModePtr mode; + int refresh0 = 60; + int maxX = 0, maxY = 0; + + *rotations = randrp->supported_rotations; + + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = scrp->virtualX; + randrp->virtualY = scrp->virtualY; + } + + /* Re-probe the outputs for new monitors or modes */ + if (scrp->vtSema) + { + xf86ProbeOutputModes (scrp, 0, 0); + xf86SetScrnInfoModes (scrp); + xf86DiDGAReInit (pScreen); + } + + for (mode = scrp->modes; ; mode = mode->next) + { + int refresh = xf86RandR12ModeRefresh (mode); + if (randrp->maxX == 0 || randrp->maxY == 0) + { + if (maxX < mode->HDisplay) + maxX = mode->HDisplay; + if (maxY < mode->VDisplay) + maxY = mode->VDisplay; + } + if (mode == scrp->modes) + refresh0 = refresh; + pSize = RRRegisterSize (pScreen, + mode->HDisplay, mode->VDisplay, + randrp->mmWidth, randrp->mmHeight); + if (!pSize) + return FALSE; + RRRegisterRate (pScreen, pSize, refresh); + + if (xf86ModesEqual(mode, scrp->currentMode)) + { + RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize); + } + if (mode->next == scrp->modes) + break; + } + + if (randrp->maxX == 0 || randrp->maxY == 0) + { + randrp->maxX = maxX; + randrp->maxY = maxY; + } + + return TRUE; +} + +static Bool +xf86RandR12SetMode (ScreenPtr pScreen, + DisplayModePtr mode, + Bool useVirtual, + int mmWidth, + int mmHeight) +{ + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + int oldWidth = pScreen->width; + int oldHeight = pScreen->height; + int oldmmWidth = pScreen->mmWidth; + int oldmmHeight = pScreen->mmHeight; + WindowPtr pRoot = WindowTable[pScreen->myNum]; + DisplayModePtr currentMode = NULL; + Bool ret = TRUE; + PixmapPtr pspix = NULL; + + if (pRoot) + (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); + if (useVirtual) + { + scrp->virtualX = randrp->virtualX; + scrp->virtualY = randrp->virtualY; + } + else + { + scrp->virtualX = mode->HDisplay; + scrp->virtualY = mode->VDisplay; + } + + if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) + { + /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ + pScreen->width = scrp->virtualY; + pScreen->height = scrp->virtualX; + pScreen->mmWidth = mmHeight; + pScreen->mmHeight = mmWidth; + } + else + { + pScreen->width = scrp->virtualX; + pScreen->height = scrp->virtualY; + pScreen->mmWidth = mmWidth; + pScreen->mmHeight = mmHeight; + } + if (scrp->currentMode == mode) { + /* Save current mode */ + currentMode = scrp->currentMode; + /* Reset, just so we ensure the drivers SwitchMode is called */ + scrp->currentMode = NULL; + } + /* + * We know that if the driver failed to SwitchMode to the rotated + * version, then it should revert back to it's prior mode. + */ + if (!xf86SwitchMode (pScreen, mode)) + { + ret = FALSE; + scrp->virtualX = pScreen->width = oldWidth; + scrp->virtualY = pScreen->height = oldHeight; + pScreen->mmWidth = oldmmWidth; + pScreen->mmHeight = oldmmHeight; + scrp->currentMode = currentMode; + } + /* + * Get the new Screen pixmap ptr as SwitchMode might have called + * ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back... + * Unfortunately. + */ + pspix = (*pScreen->GetScreenPixmap) (pScreen); + if (pspix->devPrivate.ptr) + scrp->pixmapPrivate = pspix->devPrivate; + + /* + * Make sure the layout is correct + */ + xf86ReconfigureLayout(); + + /* + * Make sure the whole screen is visible + */ + xf86SetViewport (pScreen, pScreen->width, pScreen->height); + xf86SetViewport (pScreen, 0, 0); + if (pRoot) + (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); + return ret; +} + +_X_EXPORT Bool +xf86RandR12SetConfig (ScreenPtr pScreen, + Rotation rotation, + int rate, + RRScreenSizePtr pSize) +{ + ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + DisplayModePtr mode; + int px, py; + Bool useVirtual = FALSE; + int maxX = 0, maxY = 0; + Rotation oldRotation = randrp->rotation; + + randrp->rotation = rotation; + + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = scrp->virtualX; + randrp->virtualY = scrp->virtualY; + } + + miPointerPosition (&px, &py); + for (mode = scrp->modes; ; mode = mode->next) + { + if (randrp->maxX == 0 || randrp->maxY == 0) + { + if (maxX < mode->HDisplay) + maxX = mode->HDisplay; + if (maxY < mode->VDisplay) + maxY = mode->VDisplay; + } + if (mode->HDisplay == pSize->width && + mode->VDisplay == pSize->height && + (rate == 0 || xf86RandR12ModeRefresh (mode) == rate)) + break; + if (mode->next == scrp->modes) + { + if (pSize->width == randrp->virtualX && + pSize->height == randrp->virtualY) + { + mode = scrp->modes; + useVirtual = TRUE; + break; + } + if (randrp->maxX == 0 || randrp->maxY == 0) + { + randrp->maxX = maxX; + randrp->maxY = maxY; + } + return FALSE; + } + } + + if (randrp->maxX == 0 || randrp->maxY == 0) + { + randrp->maxX = maxX; + randrp->maxY = maxY; + } + + if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth, + pSize->mmHeight)) { + randrp->rotation = oldRotation; + return FALSE; + } + + /* + * Move the cursor back where it belongs; SwitchMode repositions it + */ + if (pScreen == miPointerCurrentScreen ()) + { + px = (px >= pScreen->width ? (pScreen->width - 1) : px); + py = (py >= pScreen->height ? (pScreen->height - 1) : py); + + xf86SetViewport(pScreen, px, py); + + (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); + } + + return TRUE; +} + +static Bool +xf86RandR12ScreenSetSize (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD32 mmWidth, + CARD32 mmHeight) +{ + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + WindowPtr pRoot = WindowTable[pScreen->myNum]; + PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); + Bool ret = FALSE; + + if (xf86RandR12Key) { + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = pScrn->virtualX; + randrp->virtualY = pScrn->virtualY; + } + } + if (pRoot && pScrn->vtSema) + (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); + + /* Let the driver update virtualX and virtualY */ + if (!(*config->funcs->resize)(pScrn, width, height)) + goto finish; + + ret = TRUE; + + pScreen->width = pScrnPix->drawable.width = width; + pScreen->height = pScrnPix->drawable.height = height; + randrp->mmWidth = pScreen->mmWidth = mmWidth; + randrp->mmHeight = pScreen->mmHeight = mmHeight; + + xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1); + xf86SetViewport (pScreen, 0, 0); + +finish: + if (pRoot && pScrn->vtSema) + (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); +#if RANDR_12_INTERFACE + if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret) + RRScreenSizeNotify (pScreen); +#endif + return ret; +} + +_X_EXPORT Rotation +xf86RandR12GetRotation(ScreenPtr pScreen) +{ + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + + return randrp->rotation; +} + +_X_EXPORT Bool +xf86RandR12CreateScreenResources (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + int c; + int width, height; + int mmWidth, mmHeight; +#ifdef PANORAMIX + /* XXX disable RandR when using Xinerama */ + if (!noPanoramiXExtension) + return TRUE; +#endif + + /* + * Compute size of screen + */ + width = 0; height = 0; + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + int crtc_width = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); + int crtc_height = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); + + if (crtc->enabled && crtc_width > width) + width = crtc_width; + if (crtc->enabled && crtc_height > height) + height = crtc_height; + } + + if (width && height) + { + /* + * Compute physical size of screen + */ + if (monitorResolution) + { + mmWidth = width * 25.4 / monitorResolution; + mmHeight = height * 25.4 / monitorResolution; + } + else + { + xf86OutputPtr output = config->output[config->compat_output]; + xf86CrtcPtr crtc = output->crtc; + + if (output->conf_monitor && + (output->conf_monitor->mon_width > 0 && + output->conf_monitor->mon_height > 0)) + { + /* + * Prefer user configured DisplaySize + */ + mmWidth = output->conf_monitor->mon_width; + mmHeight = output->conf_monitor->mon_height; + } + else if (crtc && crtc->mode.HDisplay && + output->mm_width && output->mm_height) + { + /* + * If the output has a mode and a declared size, use that + * to scale the screen size + */ + DisplayModePtr mode = &crtc->mode; + mmWidth = output->mm_width * width / mode->HDisplay; + mmHeight = output->mm_height * height / mode->VDisplay; + } + else + { + /* + * Otherwise, just set the screen to DEFAULT_DPI + */ + mmWidth = width * 25.4 / DEFAULT_DPI; + mmHeight = height * 25.4 / DEFAULT_DPI; + } + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Setting screen physical size to %d x %d\n", + mmWidth, mmHeight); + xf86RandR12ScreenSetSize (pScreen, + width, + height, + mmWidth, + mmHeight); + } + + if (xf86RandR12Key == NULL) + return TRUE; + + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = pScrn->virtualX; + randrp->virtualY = pScrn->virtualY; + } + xf86CrtcSetScreenSubpixelOrder (pScreen); +#if RANDR_12_INTERFACE + if (xf86RandR12CreateScreenResources12 (pScreen)) + return TRUE; +#endif + return TRUE; +} + + +_X_EXPORT Bool +xf86RandR12Init (ScreenPtr pScreen) +{ + rrScrPrivPtr rp; + XF86RandRInfoPtr randrp; + +#ifdef PANORAMIX + /* XXX disable RandR when using Xinerama */ + if (!noPanoramiXExtension) + return TRUE; +#endif + + if (xf86RandR12Generation != serverGeneration) + xf86RandR12Generation = serverGeneration; + + xf86RandR12Key = &xf86RandR12Key; + + randrp = xalloc (sizeof (XF86RandRInfoRec)); + if (!randrp) + return FALSE; + + if (!RRScreenInit(pScreen)) + { + xfree (randrp); + return FALSE; + } + rp = rrGetScrPriv(pScreen); + rp->rrGetInfo = xf86RandR12GetInfo; + rp->rrSetConfig = xf86RandR12SetConfig; + + randrp->virtualX = -1; + randrp->virtualY = -1; + randrp->mmWidth = pScreen->mmWidth; + randrp->mmHeight = pScreen->mmHeight; + + randrp->rotation = RR_Rotate_0; /* initial rotated mode */ + + randrp->supported_rotations = RR_Rotate_0; + + randrp->maxX = randrp->maxY = 0; + + dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp); + +#if RANDR_12_INTERFACE + if (!xf86RandR12Init12 (pScreen)) + return FALSE; +#endif + return TRUE; +} + +_X_EXPORT void +xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) +{ + XF86RandRInfoPtr randrp; +#if RANDR_12_INTERFACE + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + int c; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); +#endif + + if (xf86RandR12Key == NULL) + return; + + randrp = XF86RANDRINFO(pScreen); +#if RANDR_12_INTERFACE + for (c = 0; c < config->num_crtc; c++) { + xf86CrtcPtr crtc = config->crtc[c]; + + RRCrtcSetRotations (crtc->randr_crtc, rotations); + } +#endif + randrp->supported_rotations = rotations; +} + +_X_EXPORT void +xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y) +{ + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + + if (xf86RandR12Generation != serverGeneration || + XF86RANDRINFO(pScreen)->virtualX == -1) + { + *x = pScrn->virtualX; + *y = pScrn->virtualY; + } else { + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + + *x = randrp->virtualX; + *y = randrp->virtualY; + } +} + +#if RANDR_12_INTERFACE + +#define FLAG_BITS (RR_HSyncPositive | \ + RR_HSyncNegative | \ + RR_VSyncPositive | \ + RR_VSyncNegative | \ + RR_Interlace | \ + RR_DoubleScan | \ + RR_CSync | \ + RR_CSyncPositive | \ + RR_CSyncNegative | \ + RR_HSkewPresent | \ + RR_BCast | \ + RR_PixelMultiplex | \ + RR_DoubleClock | \ + RR_ClockDivideBy2) + +static Bool +xf86RandRModeMatches (RRModePtr randr_mode, + DisplayModePtr mode) +{ +#if 0 + if (match_name) + { + /* check for same name */ + int len = strlen (mode->name); + if (randr_mode->mode.nameLength != len) return FALSE; + if (memcmp (randr_mode->name, mode->name, len) != 0) return FALSE; + } +#endif + + /* check for same timings */ + if (randr_mode->mode.dotClock / 1000 != mode->Clock) return FALSE; + if (randr_mode->mode.width != mode->HDisplay) return FALSE; + if (randr_mode->mode.hSyncStart != mode->HSyncStart) return FALSE; + if (randr_mode->mode.hSyncEnd != mode->HSyncEnd) return FALSE; + if (randr_mode->mode.hTotal != mode->HTotal) return FALSE; + if (randr_mode->mode.hSkew != mode->HSkew) return FALSE; + if (randr_mode->mode.height != mode->VDisplay) return FALSE; + if (randr_mode->mode.vSyncStart != mode->VSyncStart) return FALSE; + if (randr_mode->mode.vSyncEnd != mode->VSyncEnd) return FALSE; + if (randr_mode->mode.vTotal != mode->VTotal) return FALSE; + + /* check for same flags (using only the XF86 valid flag bits) */ + if ((randr_mode->mode.modeFlags & FLAG_BITS) != (mode->Flags & FLAG_BITS)) + return FALSE; + + /* everything matches */ + return TRUE; +} + +static Bool +xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc) +{ + ScreenPtr pScreen = randr_crtc->pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + RRModePtr randr_mode = NULL; + int x; + int y; + Rotation rotation; + int numOutputs; + RROutputPtr *randr_outputs; + RROutputPtr randr_output; + xf86CrtcPtr crtc = randr_crtc->devPrivate; + xf86OutputPtr output; + int i, j; + DisplayModePtr mode = &crtc->mode; + Bool ret; + + randr_outputs = xalloc(config->num_output * sizeof (RROutputPtr)); + if (!randr_outputs) + return FALSE; + x = crtc->x; + y = crtc->y; + rotation = crtc->rotation; + numOutputs = 0; + randr_mode = NULL; + for (i = 0; i < config->num_output; i++) + { + output = config->output[i]; + if (output->crtc == crtc) + { + randr_output = output->randr_output; + randr_outputs[numOutputs++] = randr_output; + /* + * We make copies of modes, so pointer equality + * isn't sufficient + */ + for (j = 0; j < randr_output->numModes + randr_output->numUserModes; j++) + { + RRModePtr m = (j < randr_output->numModes ? + randr_output->modes[j] : + randr_output->userModes[j-randr_output->numModes]); + + if (xf86RandRModeMatches (m, mode)) + { + randr_mode = m; + break; + } + } + } + } + ret = RRCrtcNotify (randr_crtc, randr_mode, x, y, + rotation, numOutputs, randr_outputs); + xfree(randr_outputs); + return ret; +} + +/* + * Convert a RandR mode to a DisplayMode + */ +static void +xf86RandRModeConvert (ScrnInfoPtr scrn, + RRModePtr randr_mode, + DisplayModePtr mode) +{ + memset(mode, 0, sizeof(DisplayModeRec)); + mode->status = MODE_OK; + + mode->Clock = randr_mode->mode.dotClock / 1000; + + mode->HDisplay = randr_mode->mode.width; + mode->HSyncStart = randr_mode->mode.hSyncStart; + mode->HSyncEnd = randr_mode->mode.hSyncEnd; + mode->HTotal = randr_mode->mode.hTotal; + mode->HSkew = randr_mode->mode.hSkew; + + mode->VDisplay = randr_mode->mode.height; + mode->VSyncStart = randr_mode->mode.vSyncStart; + mode->VSyncEnd = randr_mode->mode.vSyncEnd; + mode->VTotal = randr_mode->mode.vTotal; + mode->VScan = 0; + + mode->Flags = randr_mode->mode.modeFlags & FLAG_BITS; + + xf86SetModeCrtc (mode, scrn->adjustFlags); +} + +static Bool +xf86RandR12CrtcSet (ScreenPtr pScreen, + RRCrtcPtr randr_crtc, + RRModePtr randr_mode, + int x, + int y, + Rotation rotation, + int num_randr_outputs, + RROutputPtr *randr_outputs) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcPtr crtc = randr_crtc->devPrivate; + Bool changed = FALSE; + int o, ro; + xf86CrtcPtr *save_crtcs; + Bool save_enabled = crtc->enabled; + + if (!crtc->scrn->vtSema) + return FALSE; + + save_crtcs = xalloc(config->num_output * sizeof (xf86CrtcPtr)); + if ((randr_mode != NULL) != crtc->enabled) + changed = TRUE; + else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode)) + changed = TRUE; + + if (rotation != crtc->rotation) + changed = TRUE; + + if (x != crtc->x || y != crtc->y) + changed = TRUE; + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + xf86CrtcPtr new_crtc; + + save_crtcs[o] = output->crtc; + + if (output->crtc == crtc) + new_crtc = NULL; + else + new_crtc = output->crtc; + for (ro = 0; ro < num_randr_outputs; ro++) + if (output->randr_output == randr_outputs[ro]) + { + new_crtc = crtc; + break; + } + if (new_crtc != output->crtc) + { + changed = TRUE; + output->crtc = new_crtc; + } + } + for (ro = 0; ro < num_randr_outputs; ro++) + if (randr_outputs[ro]->pendingProperties) + changed = TRUE; + + /* XXX need device-independent mode setting code through an API */ + if (changed) + { + crtc->enabled = randr_mode != NULL; + + if (randr_mode) + { + DisplayModeRec mode; + + xf86RandRModeConvert (pScrn, randr_mode, &mode); + if (!xf86CrtcSetMode (crtc, &mode, rotation, x, y)) + { + crtc->enabled = save_enabled; + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + output->crtc = save_crtcs[o]; + } + xfree(save_crtcs); + return FALSE; + } + /* + * Save the last successful setting for EnterVT + */ + crtc->desiredMode = mode; + crtc->desiredRotation = rotation; + crtc->desiredX = x; + crtc->desiredY = y; + } + xf86DisableUnusedFunctions (pScrn); + } + xfree(save_crtcs); + return xf86RandR12CrtcNotify (randr_crtc); +} + +static Bool +xf86RandR12CrtcSetGamma (ScreenPtr pScreen, + RRCrtcPtr randr_crtc) +{ + xf86CrtcPtr crtc = randr_crtc->devPrivate; + + if (crtc->funcs->gamma_set == NULL) + return FALSE; + + if (!crtc->scrn->vtSema) + return TRUE; + + crtc->funcs->gamma_set(crtc, randr_crtc->gammaRed, randr_crtc->gammaGreen, + randr_crtc->gammaBlue, randr_crtc->gammaSize); + + return TRUE; +} + +static Bool +xf86RandR12OutputSetProperty (ScreenPtr pScreen, + RROutputPtr randr_output, + Atom property, + RRPropertyValuePtr value) +{ + xf86OutputPtr output = randr_output->devPrivate; + + /* If we don't have any property handler, then we don't care what the + * user is setting properties to. + */ + if (output->funcs->set_property == NULL) + return TRUE; + + /* + * This function gets called even when vtSema is FALSE, as + * drivers will need to remember the correct value to apply + * when the VT switch occurs + */ + return output->funcs->set_property(output, property, value); +} + +static Bool +xf86RandR12OutputValidateMode (ScreenPtr pScreen, + RROutputPtr randr_output, + RRModePtr randr_mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86OutputPtr output = randr_output->devPrivate; + DisplayModeRec mode; + + xf86RandRModeConvert (pScrn, randr_mode, &mode); + /* + * This function may be called when vtSema is FALSE, so + * the underlying function must either avoid touching the hardware + * or return FALSE when vtSema is FALSE + */ + if (output->funcs->mode_valid (output, &mode) != MODE_OK) + return FALSE; + return TRUE; +} + +static void +xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode) +{ +} + +/** + * Given a list of xf86 modes and a RandR Output object, construct + * RandR modes and assign them to the output + */ +static Bool +xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes) +{ + DisplayModePtr mode; + RRModePtr *rrmodes = NULL; + int nmode = 0; + int npreferred = 0; + Bool ret = TRUE; + int pref; + + for (mode = modes; mode; mode = mode->next) + nmode++; + + if (nmode) { + rrmodes = xalloc (nmode * sizeof (RRModePtr)); + + if (!rrmodes) + return FALSE; + nmode = 0; + + for (pref = 1; pref >= 0; pref--) { + for (mode = modes; mode; mode = mode->next) { + if ((pref != 0) == ((mode->type & M_T_PREFERRED) != 0)) { + xRRModeInfo modeInfo; + RRModePtr rrmode; + + modeInfo.nameLength = strlen (mode->name); + modeInfo.width = mode->HDisplay; + modeInfo.dotClock = mode->Clock * 1000; + modeInfo.hSyncStart = mode->HSyncStart; + modeInfo.hSyncEnd = mode->HSyncEnd; + modeInfo.hTotal = mode->HTotal; + modeInfo.hSkew = mode->HSkew; + + modeInfo.height = mode->VDisplay; + modeInfo.vSyncStart = mode->VSyncStart; + modeInfo.vSyncEnd = mode->VSyncEnd; + modeInfo.vTotal = mode->VTotal; + modeInfo.modeFlags = mode->Flags; + + rrmode = RRModeGet (&modeInfo, mode->name); + if (rrmode) { + rrmodes[nmode++] = rrmode; + npreferred += pref; + } + } + } + } + } + + ret = RROutputSetModes (randr_output, rrmodes, nmode, npreferred); + xfree (rrmodes); + return ret; +} + +/* + * Mirror the current mode configuration to RandR + */ +static Bool +xf86RandR12SetInfo12 (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + RROutputPtr *clones; + RRCrtcPtr *crtcs; + int ncrtc; + int o, c, l; + RRCrtcPtr randr_crtc; + int nclone; + + clones = xalloc(config->num_output * sizeof (RROutputPtr)); + crtcs = xalloc (config->num_crtc * sizeof (RRCrtcPtr)); + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + ncrtc = 0; + for (c = 0; c < config->num_crtc; c++) + if (output->possible_crtcs & (1 << c)) + crtcs[ncrtc++] = config->crtc[c]->randr_crtc; + + if (output->crtc) + randr_crtc = output->crtc->randr_crtc; + else + randr_crtc = NULL; + + if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc)) + { + xfree (crtcs); + xfree (clones); + return FALSE; + } + + RROutputSetPhysicalSize(output->randr_output, + output->mm_width, + output->mm_height); + xf86RROutputSetModes (output->randr_output, output->probed_modes); + + switch (output->status) { + case XF86OutputStatusConnected: + RROutputSetConnection (output->randr_output, RR_Connected); + break; + case XF86OutputStatusDisconnected: + RROutputSetConnection (output->randr_output, RR_Disconnected); + break; + case XF86OutputStatusUnknown: + RROutputSetConnection (output->randr_output, RR_UnknownConnection); + break; + } + + RROutputSetSubpixelOrder (output->randr_output, output->subpixel_order); + + /* + * Valid clones + */ + nclone = 0; + for (l = 0; l < config->num_output; l++) + { + xf86OutputPtr clone = config->output[l]; + + if (l != o && (output->possible_clones & (1 << l))) + clones[nclone++] = clone->randr_output; + } + if (!RROutputSetClones (output->randr_output, clones, nclone)) + { + xfree (crtcs); + xfree (clones); + return FALSE; + } + } + xfree (crtcs); + xfree (clones); + return TRUE; +} + + + +/* + * Query the hardware for the current state, then mirror + * that to RandR + */ +static Bool +xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (!pScrn->vtSema) + return TRUE; + xf86ProbeOutputModes (pScrn, 0, 0); + xf86SetScrnInfoModes (pScrn); + xf86DiDGAReInit (pScreen); + return xf86RandR12SetInfo12 (pScreen); +} + +static Bool +xf86RandR12CreateObjects12 (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + int o; + + if (!RRInit ()) + return FALSE; + + /* + * Configure crtcs + */ + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + + crtc->randr_crtc = RRCrtcCreate (pScreen, crtc); + RRCrtcGammaSetSize (crtc->randr_crtc, 256); + } + /* + * Configure outputs + */ + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->randr_output = RROutputCreate (pScreen, output->name, + strlen (output->name), + output); + + if (output->funcs->create_resources != NULL) + output->funcs->create_resources(output); + RRPostPendingProperties (output->randr_output); + } + return TRUE; +} + +static Bool +xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) +{ + int c; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + + if (xf86RandR12Key == NULL) + return TRUE; + + for (c = 0; c < config->num_crtc; c++) + xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); + + RRScreenSetSizeRange (pScreen, config->minWidth, config->minHeight, + config->maxWidth, config->maxHeight); + return TRUE; +} + +/* + * Something happened within the screen configuration due + * to DGA, VidMode or hot key. Tell RandR + */ + +_X_EXPORT void +xf86RandR12TellChanged (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + + if (xf86RandR12Key == NULL) + return; + + xf86RandR12SetInfo12 (pScreen); + for (c = 0; c < config->num_crtc; c++) + xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); + + RRTellChanged (pScreen); +} + +static void +xf86RandR12PointerMoved (int scrnIndex, int x, int y) +{ +} + +static Bool +xf86RandR12Init12 (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + rrScrPrivPtr rp = rrGetScrPriv(pScreen); + + rp->rrGetInfo = xf86RandR12GetInfo12; + rp->rrScreenSetSize = xf86RandR12ScreenSetSize; + rp->rrCrtcSet = xf86RandR12CrtcSet; + rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma; + rp->rrOutputSetProperty = xf86RandR12OutputSetProperty; + rp->rrOutputValidateMode = xf86RandR12OutputValidateMode; + rp->rrModeDestroy = xf86RandR12ModeDestroy; + rp->rrSetConfig = NULL; + pScrn->PointerMoved = xf86RandR12PointerMoved; + if (!xf86RandR12CreateObjects12 (pScreen)) + return FALSE; + + /* + * Configure output modes + */ + if (!xf86RandR12SetInfo12 (pScreen)) + return FALSE; + return TRUE; +} + +#endif + +_X_EXPORT Bool +xf86RandR12PreInit (ScrnInfoPtr pScrn) +{ + return TRUE; +} diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.h b/xorg-server/hw/xfree86/modes/xf86RandR12.h new file mode 100644 index 000000000..4fd855cf5 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86RandR12.h @@ -0,0 +1,41 @@ +/* + * Copyright © 2006 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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 _XF86_RANDR_H_ +#define _XF86_RANDR_H_ +#include <randrstr.h> +#include <X11/extensions/render.h> +#if XF86_MODES_RENAME +#include "xf86Rename.h" +#endif + +Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen); +Bool xf86RandR12Init(ScreenPtr pScreen); +void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotation); +Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, int rate, + RRScreenSizePtr pSize); +Rotation xf86RandR12GetRotation(ScreenPtr pScreen); +void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y); +Bool xf86RandR12PreInit (ScrnInfoPtr pScrn); +void xf86RandR12TellChanged (ScreenPtr pScreen); + +#endif /* _XF86_RANDR_H_ */ diff --git a/xorg-server/hw/xfree86/modes/xf86Rename.h b/xorg-server/hw/xfree86/modes/xf86Rename.h new file mode 100644 index 000000000..b8c1d70ef --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86Rename.h @@ -0,0 +1,93 @@ +/* + * Copyright © 2006 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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 _XF86RENAME_H_ +#define _XF86RENAME_H_ + +#include "local_xf86Rename.h" + +#define xf86_cursors_fini XF86NAME(xf86_cursors_fini) +#define xf86_cursors_init XF86NAME(xf86_cursors_init) +#define xf86_hide_cursors XF86NAME(xf86_hide_cursors) +#define xf86_reload_cursors XF86NAME(xf86_reload_cursors) +#define xf86_show_cursors XF86NAME(xf86_show_cursors) +#define xf86ConnectorGetName XF86NAME(xf86ConnectorGetName) +#define xf86CrtcConfigInit XF86NAME(xf86CrtcConfigInit) +#define xf86CrtcConfigPrivateIndex XF86NAME(xf86CrtcConfigPrivateIndex) +#define xf86CrtcCreate XF86NAME(xf86CrtcCreate) +#define xf86CrtcDestroy XF86NAME(xf86CrtcDestroy) +#define xf86CrtcInUse XF86NAME(xf86CrtcInUse) +#define xf86CrtcRotate XF86NAME(xf86CrtcRotate) +#define xf86CrtcScreenInit XF86NAME(xf86CrtcScreenInit) +#define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode) +#define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange) +#define xf86CVTMode XF86NAME(xf86CVTMode) +#define xf86DDCMonitorSet XF86NAME(xf86DDCMonitorSet) +#define xf86DisableUnusedFunctions XF86NAME(xf86DisableUnusedFunctions) +#define xf86DPMSSet XF86NAME(xf86DPMSSet) +#define xf86DuplicateMode XF86NAME(xf86DuplicateMode) +#define xf86DuplicateModes XF86NAME(xf86DuplicateModes) +#define xf86GetDefaultModes XF86NAME(xf86GetDefaultModes) +#define xf86GetMonitorModes XF86NAME(xf86GetMonitorModes) +#define xf86InitialConfiguration XF86NAME(xf86InitialConfiguration) +#define xf86ModeHSync XF86NAME(xf86ModeHSync) +#define xf86ModesAdd XF86NAME(xf86ModesAdd) +#define xf86ModesEqual XF86NAME(xf86ModesEqual) +#define xf86ModeVRefresh XF86NAME(xf86ModeVRefresh) +#define xf86OutputCreate XF86NAME(xf86OutputCreate) +#define xf86OutputDestroy XF86NAME(xf86OutputDestroy) +#define xf86OutputGetEDID XF86NAME(xf86OutputGetEDID) +#define xf86OutputGetEDIDModes XF86NAME(xf86OutputGetEDIDModes) +#define xf86OutputRename XF86NAME(xf86OutputRename) +#define xf86OutputSetEDID XF86NAME(xf86OutputSetEDID) +#define xf86OutputUseScreenMonitor XF86NAME(xf86OutputUseScreenMonitor) +#define xf86PrintModeline XF86NAME(xf86PrintModeline) +#define xf86ProbeOutputModes XF86NAME(xf86ProbeOutputModes) +#define xf86PruneInvalidModes XF86NAME(xf86PruneInvalidModes) +#define xf86RotateCloseScreen XF86NAME(xf86RotateCloseScreen) +#define xf86SetModeCrtc XF86NAME(xf86SetModeCrtc) +#define xf86SetModeDefaultName XF86NAME(xf86SetModeDefaultName) +#define xf86SetScrnInfoModes XF86NAME(xf86SetScrnInfoModes) +#define xf86ValidateModesClocks XF86NAME(xf86ValidateModesClocks) +#define xf86ValidateModesFlags XF86NAME(xf86ValidateModesFlags) +#define xf86ValidateModesSize XF86NAME(xf86ValidateModesSize) +#define xf86ValidateModesSync XF86NAME(xf86ValidateModesSync) +#define xf86ValidateModesUserConfig XF86NAME(xf86ValidateModesUserConfig) +#define xf86DiDGAInit XF86NAME(xf86DiDGAInit) +#define xf86DiDGAReInit XF86NAME(xf86DiDGAReInit) +#define xf86DDCGetModes XF86NAME(xf86DDCGetModes) +#define xf86RandR12CreateScreenResources XF86NAME(xf86RandR12CreateScreenResources) +#define xf86RandR12GetOriginalVirtualSize XF86NAME(xf86RandR12GetOriginalVirtualSize) +#define xf86RandR12GetRotation XF86NAME(xf86RandR12GetRotation) +#define xf86RandR12Init XF86NAME(xf86RandR12Init) +#define xf86RandR12PreInit XF86NAME(xf86RandR12PreInit) +#define xf86RandR12SetConfig XF86NAME(xf86RandR12SetConfig) +#define xf86RandR12SetRotations XF86NAME(xf86RandR12SetRotations) +#define xf86SaveScreen XF86NAME(xf86SaveScreen) +#define xf86CrtcSetScreenSubpixelOrder XF86NAME(xf86CrtcSetScreenSubpixelOrder) +#define xf86ModeWidth XF86NAME(xf86ModeWidth) +#define xf86ModeHeight XF86NAME(xf86ModeHeight) +#define xf86OutputFindClosestMode XF86NAME(xf86OutputFindClosestMode) +#define xf86SetSingleMode XF86NAME(xf86SetSingleMode) +#define xf86SetDesiredModes XF86NAME(xf86SetDesiredModes) + +#endif /* _XF86RENAME_H_ */ diff --git a/xorg-server/hw/xfree86/modes/xf86Rotate.c b/xorg-server/hw/xfree86/modes/xf86Rotate.c new file mode 100644 index 000000000..e2d6295b9 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86Rotate.c @@ -0,0 +1,661 @@ +/* + * Copyright © 2006 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include <stddef.h> +#include <string.h> +#include <stdio.h> + +#include "xf86.h" +#include "xf86DDC.h" +#include "fb.h" +#include "windowstr.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "xf86RandR12.h" +#include "X11/extensions/render.h" +#define DPMS_SERVER +#include "X11/extensions/dpms.h" +#include "X11/Xatom.h" + +/* borrowed from composite extension, move to Render and publish? */ + +static VisualPtr +compGetWindowVisual (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + VisualID vid = wVisual (pWin); + int i; + + for (i = 0; i < pScreen->numVisuals; i++) + if (pScreen->visuals[i].vid == vid) + return &pScreen->visuals[i]; + return 0; +} + +static PictFormatPtr +compWindowFormat (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + return PictureMatchVisual (pScreen, pWin->drawable.depth, + compGetWindowVisual (pWin)); +} + +#define F(x) IntToxFixed(x) + +static void +PictureTransformIdentity (PictTransformPtr matrix) +{ + int i; + memset (matrix, '\0', sizeof (PictTransform)); + for (i = 0; i < 3; i++) + matrix->matrix[i][i] = F(1); +} + +static Bool +PictureTransformMultiply (PictTransformPtr dst, PictTransformPtr l, PictTransformPtr r) +{ + PictTransform d; + int dx, dy; + int o; + + for (dy = 0; dy < 3; dy++) + for (dx = 0; dx < 3; dx++) + { + xFixed_48_16 v; + xFixed_32_32 partial; + v = 0; + for (o = 0; o < 3; o++) + { + partial = (xFixed_32_32) l->matrix[dy][o] * (xFixed_32_32) r->matrix[o][dx]; + v += partial >> 16; + } + if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16) + return FALSE; + d.matrix[dy][dx] = (xFixed) v; + } + *dst = d; + return TRUE; +} + +static void +PictureTransformInitScale (PictTransformPtr t, xFixed sx, xFixed sy) +{ + memset (t, '\0', sizeof (PictTransform)); + t->matrix[0][0] = sx; + t->matrix[1][1] = sy; + t->matrix[2][2] = F (1); +} + +static xFixed +fixed_inverse (xFixed x) +{ + return (xFixed) ((((xFixed_48_16) F(1)) * F(1)) / x); +} + +static Bool +PictureTransformScale (PictTransformPtr forward, + PictTransformPtr reverse, + xFixed sx, xFixed sy) +{ + PictTransform t; + + PictureTransformInitScale (&t, sx, sy); + if (!PictureTransformMultiply (forward, &t, forward)) + return FALSE; + PictureTransformInitScale (&t, fixed_inverse (sx), fixed_inverse (sy)); + if (!PictureTransformMultiply (reverse, reverse, &t)) + return FALSE; + return TRUE; +} + +static void +PictureTransformInitRotate (PictTransformPtr t, xFixed c, xFixed s) +{ + memset (t, '\0', sizeof (PictTransform)); + t->matrix[0][0] = c; + t->matrix[0][1] = -s; + t->matrix[1][0] = s; + t->matrix[1][1] = c; + t->matrix[2][2] = F (1); +} + +static Bool +PictureTransformRotate (PictTransformPtr forward, + PictTransformPtr reverse, + xFixed c, xFixed s) +{ + PictTransform t; + PictureTransformInitRotate (&t, c, s); + if (!PictureTransformMultiply (forward, &t, forward)) + return FALSE; + + PictureTransformInitRotate (&t, c, -s); + if (!PictureTransformMultiply (reverse, reverse, &t)) + return FALSE; + return TRUE; +} + +static void +PictureTransformInitTranslate (PictTransformPtr t, xFixed tx, xFixed ty) +{ + memset (t, '\0', sizeof (PictTransform)); + t->matrix[0][0] = F (1); + t->matrix[0][2] = tx; + t->matrix[1][1] = F (1); + t->matrix[1][2] = ty; + t->matrix[2][2] = F (1); +} + +static Bool +PictureTransformTranslate (PictTransformPtr forward, + PictTransformPtr reverse, + xFixed tx, xFixed ty) +{ + PictTransform t; + PictureTransformInitTranslate (&t, tx, ty); + if (!PictureTransformMultiply (forward, &t, forward)) + return FALSE; + + PictureTransformInitTranslate (&t, -tx, -ty); + if (!PictureTransformMultiply (reverse, reverse, &t)) + return FALSE; + return TRUE; +} + +static void +PictureTransformBounds (BoxPtr b, PictTransformPtr matrix) +{ + PictVector v[4]; + int i; + int x1, y1, x2, y2; + + v[0].vector[0] = F (b->x1); v[0].vector[1] = F (b->y1); v[0].vector[2] = F(1); + v[1].vector[0] = F (b->x2); v[1].vector[1] = F (b->y1); v[1].vector[2] = F(1); + v[2].vector[0] = F (b->x2); v[2].vector[1] = F (b->y2); v[2].vector[2] = F(1); + v[3].vector[0] = F (b->x1); v[3].vector[1] = F (b->y2); v[3].vector[2] = F(1); + for (i = 0; i < 4; i++) + { + PictureTransformPoint (matrix, &v[i]); + x1 = xFixedToInt (v[i].vector[0]); + y1 = xFixedToInt (v[i].vector[1]); + x2 = xFixedToInt (xFixedCeil (v[i].vector[0])); + y2 = xFixedToInt (xFixedCeil (v[i].vector[1])); + if (i == 0) + { + b->x1 = x1; b->y1 = y1; + b->x2 = x2; b->y2 = y2; + } + else + { + if (x1 < b->x1) b->x1 = x1; + if (y1 < b->y1) b->y1 = y1; + if (x2 > b->x2) b->x2 = x2; + if (y2 > b->y2) b->y2 = y2; + } + } +} + +static Bool +PictureTransformIsIdentity(PictTransform *t) +{ + return ((t->matrix[0][0] == t->matrix[1][1]) && + (t->matrix[0][0] == t->matrix[2][2]) && + (t->matrix[0][0] != 0) && + (t->matrix[0][1] == 0) && + (t->matrix[0][2] == 0) && + (t->matrix[1][0] == 0) && + (t->matrix[1][2] == 0) && + (t->matrix[2][0] == 0) && + (t->matrix[2][1] == 0)); +} + +#define toF(x) ((float) (x) / 65536.0f) + +static void +PictureTransformErrorF (PictTransform *t) +{ + ErrorF ("{ { %f %f %f } { %f %f %f } { %f %f %f } }", + toF(t->matrix[0][0]), toF(t->matrix[0][1]), toF(t->matrix[0][2]), + toF(t->matrix[1][0]), toF(t->matrix[1][1]), toF(t->matrix[1][2]), + toF(t->matrix[2][0]), toF(t->matrix[2][1]), toF(t->matrix[2][2])); +} + +static Bool +PictureTransformIsInverse (char *where, PictTransform *a, PictTransform *b) +{ + PictTransform t; + + PictureTransformMultiply (&t, a, b); + if (!PictureTransformIsIdentity (&t)) + { + ErrorF ("%s: ", where); + PictureTransformErrorF (a); + ErrorF (" * "); + PictureTransformErrorF (b); + ErrorF (" = "); + PictureTransformErrorF (a); + ErrorF ("\n"); + return FALSE; + } + return TRUE; +} + +static void +xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) +{ + ScrnInfoPtr scrn = crtc->scrn; + ScreenPtr screen = scrn->pScreen; + WindowPtr root = WindowTable[screen->myNum]; + PixmapPtr dst_pixmap = crtc->rotatedPixmap; + PictFormatPtr format = compWindowFormat (WindowTable[screen->myNum]); + int error; + PicturePtr src, dst; + int n = REGION_NUM_RECTS(region); + BoxPtr b = REGION_RECTS(region); + XID include_inferiors = IncludeInferiors; + + src = CreatePicture (None, + &root->drawable, + format, + CPSubwindowMode, + &include_inferiors, + serverClient, + &error); + if (!src) + return; + + dst = CreatePicture (None, + &dst_pixmap->drawable, + format, + 0L, + NULL, + serverClient, + &error); + if (!dst) + return; + + error = SetPictureTransform (src, &crtc->crtc_to_framebuffer); + if (error) + return; + + while (n--) + { + BoxRec dst_box; + + dst_box = *b; + PictureTransformBounds (&dst_box, &crtc->framebuffer_to_crtc); + CompositePicture (PictOpSrc, + src, NULL, dst, + dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1, + dst_box.x2 - dst_box.x1, + dst_box.y2 - dst_box.y1); + b++; + } + FreePicture (src, None); + FreePicture (dst, None); +} + +static void +xf86CrtcDamageShadow (xf86CrtcPtr crtc) +{ + ScrnInfoPtr pScrn = crtc->scrn; + BoxRec damage_box; + RegionRec damage_region; + ScreenPtr pScreen = pScrn->pScreen; + + damage_box.x1 = crtc->x; + damage_box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); + damage_box.y1 = crtc->y; + damage_box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); + REGION_INIT (pScreen, &damage_region, &damage_box, 1); + DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + &damage_region); + REGION_UNINIT (pScreen, &damage_region); +} + +static void +xf86RotatePrepare (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->rotatedData && !crtc->rotatedPixmap) + { + crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, + crtc->rotatedData, + crtc->mode.HDisplay, + crtc->mode.VDisplay); + if (!xf86_config->rotation_damage_registered) + { + /* Hook damage to screen pixmap */ + DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + xf86_config->rotation_damage); + xf86_config->rotation_damage_registered = TRUE; + } + + xf86CrtcDamageShadow (crtc); + } + } +} + +static Bool +xf86RotateRedisplay(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + DamagePtr damage = xf86_config->rotation_damage; + RegionPtr region; + + if (!damage) + return FALSE; + xf86RotatePrepare (pScreen); + region = DamageRegion(damage); + if (REGION_NOTEMPTY(pScreen, region)) + { + int c; + SourceValidateProcPtr SourceValidate; + + /* + * SourceValidate is used by the software cursor code + * to pull the cursor off of the screen when reading + * bits from the frame buffer. Bypassing this function + * leaves the software cursor in place + */ + SourceValidate = pScreen->SourceValidate; + pScreen->SourceValidate = NULL; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->rotation != RR_Rotate_0 && crtc->enabled) + { + RegionRec crtc_damage; + + /* compute portion of damage that overlaps crtc */ + REGION_INIT(pScreen, &crtc_damage, &crtc->bounds, 1); + REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region); + + /* update damaged region */ + if (REGION_NOTEMPTY(pScreen, &crtc_damage)) + xf86RotateCrtcRedisplay (crtc, &crtc_damage); + + REGION_UNINIT (pScreen, &crtc_damage); + } + } + pScreen->SourceValidate = SourceValidate; + DamageEmpty(damage); + } + return TRUE; +} + +static void +xf86RotateBlockHandler(int screenNum, pointer blockData, + pointer pTimeout, pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[screenNum]; + ScrnInfoPtr pScrn = xf86Screens[screenNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + + pScreen->BlockHandler = xf86_config->BlockHandler; + (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask); + if (xf86RotateRedisplay(pScreen)) + { + /* Re-wrap if rotation is still happening */ + xf86_config->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = xf86RotateBlockHandler; + } +} + +static void +xf86RotateDestroy (xf86CrtcPtr crtc) +{ + ScrnInfoPtr pScrn = crtc->scrn; + ScreenPtr pScreen = pScrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + + /* Free memory from rotation */ + if (crtc->rotatedPixmap || crtc->rotatedData) + { + crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + + for (c = 0; c < xf86_config->num_crtc; c++) + if (xf86_config->crtc[c]->rotatedPixmap || + xf86_config->crtc[c]->rotatedData) + return; + + /* + * Clean up damage structures when no crtcs are rotated + */ + if (xf86_config->rotation_damage) + { + /* Free damage structure */ + if (xf86_config->rotation_damage_registered) + { + DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + xf86_config->rotation_damage); + xf86_config->rotation_damage_registered = FALSE; + } + DamageDestroy (xf86_config->rotation_damage); + xf86_config->rotation_damage = NULL; + } +} + +_X_EXPORT void +xf86RotateCloseScreen (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + xf86RotateDestroy (xf86_config->crtc[c]); +} + +_X_EXPORT Bool +xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) +{ + ScrnInfoPtr pScrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */ + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + PictTransform crtc_to_fb, fb_to_crtc; + + PictureTransformIdentity (&crtc_to_fb); + PictureTransformIdentity (&fb_to_crtc); + PictureTransformIsInverse ("identity", &crtc_to_fb, &fb_to_crtc); + if (rotation != RR_Rotate_0) + { + xFixed rot_cos, rot_sin, rot_dx, rot_dy; + xFixed scale_x, scale_y, scale_dx, scale_dy; + int mode_w = crtc->mode.HDisplay; + int mode_h = crtc->mode.VDisplay; + + /* rotation */ + switch (rotation & 0xf) { + default: + case RR_Rotate_0: + rot_cos = F ( 1); rot_sin = F ( 0); + rot_dx = F ( 0); rot_dy = F ( 0); + break; + case RR_Rotate_90: + rot_cos = F ( 0); rot_sin = F ( 1); + rot_dx = F ( mode_h); rot_dy = F (0); + break; + case RR_Rotate_180: + rot_cos = F (-1); rot_sin = F ( 0); + rot_dx = F (mode_w); rot_dy = F ( mode_h); + break; + case RR_Rotate_270: + rot_cos = F ( 0); rot_sin = F (-1); + rot_dx = F ( 0); rot_dy = F ( mode_w); + break; + } + + PictureTransformRotate (&crtc_to_fb, &fb_to_crtc, rot_cos, rot_sin); + PictureTransformIsInverse ("rotate", &crtc_to_fb, &fb_to_crtc); + + PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, rot_dx, rot_dy); + PictureTransformIsInverse ("rotate translate", &crtc_to_fb, &fb_to_crtc); + + /* reflection */ + scale_x = F (1); + scale_dx = 0; + scale_y = F (1); + scale_dy = 0; + if (rotation & RR_Reflect_X) + { + scale_x = F(-1); + if (rotation & (RR_Rotate_0|RR_Rotate_180)) + scale_dx = F(mode_w); + else + scale_dx = F(mode_h); + } + if (rotation & RR_Reflect_Y) + { + scale_y = F(-1); + if (rotation & (RR_Rotate_0|RR_Rotate_180)) + scale_dy = F(mode_h); + else + scale_dy = F(mode_w); + } + + PictureTransformScale (&crtc_to_fb, &fb_to_crtc, scale_x, scale_y); + PictureTransformIsInverse ("scale", &crtc_to_fb, &fb_to_crtc); + + PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, scale_dx, scale_dy); + PictureTransformIsInverse ("scale translate", &crtc_to_fb, &fb_to_crtc); + + } + + /* + * If the untranslated transformation is the identity, + * disable the shadow buffer + */ + if (PictureTransformIsIdentity (&crtc_to_fb)) + { + crtc->transform_in_use = FALSE; + PictureTransformInitTranslate (&crtc->crtc_to_framebuffer, + F (-crtc->x), F (-crtc->y)); + PictureTransformInitTranslate (&crtc->framebuffer_to_crtc, + F ( crtc->x), F ( crtc->y)); + xf86RotateDestroy (crtc); + } + else + { + PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, F(crtc->x), F(crtc->y)); + PictureTransformIsInverse ("offset", &crtc_to_fb, &fb_to_crtc); + + /* + * these are the size of the shadow pixmap, which + * matches the mode, not the pre-rotated copy in the + * frame buffer + */ + int width = mode->HDisplay; + int height = mode->VDisplay; + void *shadowData = crtc->rotatedData; + PixmapPtr shadow = crtc->rotatedPixmap; + int old_width = shadow ? shadow->drawable.width : 0; + int old_height = shadow ? shadow->drawable.height : 0; + + /* Allocate memory for rotation */ + if (old_width != width || old_height != height) + { + if (shadow || shadowData) + { + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + shadowData = crtc->funcs->shadow_allocate (crtc, width, height); + if (!shadowData) + goto bail1; + crtc->rotatedData = shadowData; + /* shadow will be damaged in xf86RotatePrepare */ + } + else + { + /* mark shadowed area as damaged so it will be repainted */ + xf86CrtcDamageShadow (crtc); + } + + if (!xf86_config->rotation_damage) + { + /* Create damage structure */ + xf86_config->rotation_damage = DamageCreate (NULL, NULL, + DamageReportNone, + TRUE, pScreen, pScreen); + if (!xf86_config->rotation_damage) + goto bail2; + + /* Wrap block handler */ + xf86_config->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = xf86RotateBlockHandler; + } + if (0) + { + bail2: + if (shadow || shadowData) + { + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + bail1: + if (old_width && old_height) + crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, + NULL, + old_width, + old_height); + return FALSE; + } + crtc->transform_in_use = TRUE; + crtc->crtc_to_framebuffer = crtc_to_fb; + crtc->framebuffer_to_crtc = fb_to_crtc; + crtc->bounds.x1 = 0; + crtc->bounds.x2 = crtc->mode.HDisplay; + crtc->bounds.y1 = 0; + crtc->bounds.y2 = crtc->mode.VDisplay; + PictureTransformBounds (&crtc->bounds, &crtc_to_fb); + } + + /* All done */ + return TRUE; +} diff --git a/xorg-server/hw/xfree86/modes/xf86cvt.c b/xorg-server/hw/xfree86/modes/xf86cvt.c new file mode 100644 index 000000000..e9c74aa62 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86cvt.c @@ -0,0 +1,301 @@ +/* + * Copyright 2005-2006 Luc Verhaegen. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The reason for having this function in a file of its own is + * so that ../utils/cvt/cvt can link to it, and that xf86CVTMode + * code is shared directly. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#include "xf86.h" +#include "xf86Modes.h" + +#include <string.h> + +/* + * Generate a CVT standard mode from HDisplay, VDisplay and VRefresh. + * + * These calculations are stolen from the CVT calculation spreadsheet written + * by Graham Loveridge. He seems to be claiming no copyright and there seems to + * be no license attached to this. He apparently just wants to see his name + * mentioned. + * + * This file can be found at http://www.vesa.org/Public/CVT/CVTd6r1.xls + * + * Comments and structure corresponds to the comments and structure of the xls. + * This should ease importing of future changes to the standard (not very + * likely though). + * + * About margins; i'm sure that they are to be the bit between HDisplay and + * HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and + * VTotal, where the overscan colour is shown. FB seems to call _all_ blanking + * outside sync "margin" for some reason. Since we prefer seeing proper + * blanking instead of the overscan colour, and since the Crtc* values will + * probably get altered after us, we will disable margins altogether. With + * these calculations, Margins will plainly expand H/VDisplay, and we don't + * want that. -- libv + * + */ +_X_EXPORT DisplayModePtr +xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, + Bool Interlaced) +{ + DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec)); + + /* 1) top/bottom margin size (% of height) - default: 1.8 */ +#define CVT_MARGIN_PERCENTAGE 1.8 + + /* 2) character cell horizontal granularity (pixels) - default 8 */ +#define CVT_H_GRANULARITY 8 + + /* 4) Minimum vertical porch (lines) - default 3 */ +#define CVT_MIN_V_PORCH 3 + + /* 4) Minimum number of vertical back porch lines - default 6 */ +#define CVT_MIN_V_BPORCH 6 + + /* Pixel Clock step (kHz) */ +#define CVT_CLOCK_STEP 250 + + Bool Margins = FALSE; + float VFieldRate, HPeriod; + int HDisplayRnd, HMargin; + int VDisplayRnd, VMargin, VSync; + float Interlace; /* Please rename this */ + + /* CVT default is 60.0Hz */ + if (!VRefresh) + VRefresh = 60.0; + + /* 1. Required field rate */ + if (Interlaced) + VFieldRate = VRefresh * 2; + else + VFieldRate = VRefresh; + + /* 2. Horizontal pixels */ + HDisplayRnd = HDisplay - (HDisplay % CVT_H_GRANULARITY); + + /* 3. Determine left and right borders */ + if (Margins) { + /* right margin is actually exactly the same as left */ + HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); + HMargin -= HMargin % CVT_H_GRANULARITY; + } else + HMargin = 0; + + /* 4. Find total active pixels */ + Mode->HDisplay = HDisplayRnd + 2*HMargin; + + /* 5. Find number of lines per field */ + if (Interlaced) + VDisplayRnd = VDisplay / 2; + else + VDisplayRnd = VDisplay; + + /* 6. Find top and bottom margins */ + /* nope. */ + if (Margins) + /* top and bottom margins are equal again. */ + VMargin = (((float) VDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0); + else + VMargin = 0; + + Mode->VDisplay = VDisplay + 2*VMargin; + + /* 7. Interlace */ + if (Interlaced) + Interlace = 0.5; + else + Interlace = 0.0; + + /* Determine VSync Width from aspect ratio */ + if (!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) + VSync = 4; + else if (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) + VSync = 5; + else if (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) + VSync = 6; + else if (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) + VSync = 7; + else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)) + VSync = 7; + else /* Custom */ + VSync = 10; + + if (!Reduced) { /* simplified GTF calculation */ + + /* 4) Minimum time of vertical sync + back porch interval (µs) + * default 550.0 */ +#define CVT_MIN_VSYNC_BP 550.0 + + /* 3) Nominal HSync width (% of line period) - default 8 */ +#define CVT_HSYNC_PERCENTAGE 8 + + float HBlankPercentage; + int VSyncAndBackPorch, VBackPorch; + int HBlank; + + /* 8. Estimated Horizontal period */ + HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) / + (VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace); + + /* 9. Find number of lines in sync + backporch */ + if (((int)(CVT_MIN_VSYNC_BP / HPeriod) + 1) < (VSync + CVT_MIN_V_PORCH)) + VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH; + else + VSyncAndBackPorch = (int)(CVT_MIN_VSYNC_BP / HPeriod) + 1; + + /* 10. Find number of lines in back porch */ + VBackPorch = VSyncAndBackPorch - VSync; + + /* 11. Find total number of lines in vertical field */ + Mode->VTotal = VDisplayRnd + 2 * VMargin + VSyncAndBackPorch + Interlace + + CVT_MIN_V_PORCH; + + /* 5) Definition of Horizontal blanking time limitation */ + /* Gradient (%/kHz) - default 600 */ +#define CVT_M_FACTOR 600 + + /* Offset (%) - default 40 */ +#define CVT_C_FACTOR 40 + + /* Blanking time scaling factor - default 128 */ +#define CVT_K_FACTOR 128 + + /* Scaling factor weighting - default 20 */ +#define CVT_J_FACTOR 20 + +#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256 +#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \ + CVT_J_FACTOR + + /* 12. Find ideal blanking duty cycle from formula */ + HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod/1000.0; + + /* 13. Blanking time */ + if (HBlankPercentage < 20) + HBlankPercentage = 20; + + HBlank = Mode->HDisplay * HBlankPercentage/(100.0 - HBlankPercentage); + HBlank -= HBlank % (2*CVT_H_GRANULARITY); + + /* 14. Find total number of pixels in a line. */ + Mode->HTotal = Mode->HDisplay + HBlank; + + /* Fill in HSync values */ + Mode->HSyncEnd = Mode->HDisplay + HBlank / 2; + + Mode->HSyncStart = Mode->HSyncEnd - + (Mode->HTotal * CVT_HSYNC_PERCENTAGE) / 100; + Mode->HSyncStart += CVT_H_GRANULARITY - + Mode->HSyncStart % CVT_H_GRANULARITY; + + /* Fill in VSync values */ + Mode->VSyncStart = Mode->VDisplay + CVT_MIN_V_PORCH; + Mode->VSyncEnd = Mode->VSyncStart + VSync; + + } else { /* Reduced blanking */ + /* Minimum vertical blanking interval time (µs) - default 460 */ +#define CVT_RB_MIN_VBLANK 460.0 + + /* Fixed number of clocks for horizontal sync */ +#define CVT_RB_H_SYNC 32.0 + + /* Fixed number of clocks for horizontal blanking */ +#define CVT_RB_H_BLANK 160.0 + + /* Fixed number of lines for vertical front porch - default 3 */ +#define CVT_RB_VFPORCH 3 + + int VBILines; + + /* 8. Estimate Horizontal period. */ + HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) / + (VDisplayRnd + 2*VMargin); + + /* 9. Find number of lines in vertical blanking */ + VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1; + + /* 10. Check if vertical blanking is sufficient */ + if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH)) + VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH; + + /* 11. Find total number of lines in vertical field */ + Mode->VTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines; + + /* 12. Find total number of pixels in a line */ + Mode->HTotal = Mode->HDisplay + CVT_RB_H_BLANK; + + /* Fill in HSync values */ + Mode->HSyncEnd = Mode->HDisplay + CVT_RB_H_BLANK / 2; + Mode->HSyncStart = Mode->HSyncEnd - CVT_RB_H_SYNC; + + /* Fill in VSync values */ + Mode->VSyncStart = Mode->VDisplay + CVT_RB_VFPORCH; + Mode->VSyncEnd = Mode->VSyncStart + VSync; + } + + /* 15/13. Find pixel clock frequency (kHz for xf86) */ + Mode->Clock = Mode->HTotal * 1000.0 / HPeriod; + Mode->Clock -= Mode->Clock % CVT_CLOCK_STEP; + + /* 16/14. Find actual Horizontal Frequency (kHz) */ + Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal); + + /* 17/15. Find actual Field rate */ + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + /* 18/16. Find actual vertical frame frequency */ + /* ignore - just set the mode flag for interlaced */ + if (Interlaced) + Mode->VTotal *= 2; + + { + char Name[256]; + Name[0] = 0; + + snprintf(Name, 256, "%dx%d", HDisplay, VDisplay); + + Mode->name = xnfalloc(strlen(Name) + 1); + memcpy(Mode->name, Name, strlen(Name) + 1); + } + + if (Reduced) + Mode->Flags |= V_PHSYNC | V_NVSYNC; + else + Mode->Flags |= V_NHSYNC | V_PVSYNC; + + if (Interlaced) + Mode->Flags |= V_INTERLACE; + + return Mode; +} diff --git a/xorg-server/hw/xfree86/modes/xf86gtf.c b/xorg-server/hw/xfree86/modes/xf86gtf.c new file mode 100644 index 000000000..acbac83b6 --- /dev/null +++ b/xorg-server/hw/xfree86/modes/xf86gtf.c @@ -0,0 +1,384 @@ +/* + * gtf.c Generate mode timings using the GTF Timing Standard + * + * gcc gtf.c -o gtf -lm -Wall + * + * Copyright (c) 2001, Andy Ritger aritger@nvidia.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * o Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * o Neither the name of NVIDIA nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * This program is based on the Generalized Timing Formula(GTF TM) + * Standard Version: 1.0, Revision: 1.0 + * + * The GTF Document contains the following Copyright information: + * + * Copyright (c) 1994, 1995, 1996 - Video Electronics Standards + * Association. Duplication of this document within VESA member + * companies for review purposes is permitted. All other rights + * reserved. + * + * While every precaution has been taken in the preparation + * of this standard, the Video Electronics Standards Association and + * its contributors assume no responsibility for errors or omissions, + * and make no warranties, expressed or implied, of functionality + * of suitability for any purpose. The sample code contained within + * this standard may be used without restriction. + * + * + * + * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive) + * implementation of the GTF Timing Standard, is available at: + * + * ftp://ftp.vesa.org/pub/GTF/GTF_V1R1.xls + */ + +/* Ruthlessly converted to server code by Adam Jackson <ajax@redhat.com> */ + +#ifdef HAVE_XORG_CONFIG_H +# include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86Modes.h" +#include <string.h> + +#define MARGIN_PERCENT 1.8 /* % of active vertical image */ +#define CELL_GRAN 8.0 /* assumed character cell granularity */ +#define MIN_PORCH 1 /* minimum front porch */ +#define V_SYNC_RQD 3 /* width of vsync in lines */ +#define H_SYNC_PERCENT 8.0 /* width of hsync as % of total line */ +#define MIN_VSYNC_PLUS_BP 550.0 /* min time of vsync + back porch (microsec) */ +#define M 600.0 /* blanking formula gradient */ +#define C 40.0 /* blanking formula offset */ +#define K 128.0 /* blanking formula scaling factor */ +#define J 20.0 /* blanking formula scaling factor */ + +/* C' and M' are part of the Blanking Duty Cycle computation */ + +#define C_PRIME (((C - J) * K/256.0) + J) +#define M_PRIME (K/256.0 * M) + + +/* + * xf86GTFMode() - as defined by the GTF Timing Standard, compute the + * Stage 1 Parameters using the vertical refresh frequency. In other + * words: input a desired resolution and desired refresh rate, and + * output the GTF mode timings. + * + * XXX All the code is in place to compute interlaced modes, but I don't + * feel like testing it right now. + * + * XXX margin computations are implemented but not tested (nor used by + * XServer of fbset mode descriptions, from what I can tell). + */ + +_X_EXPORT DisplayModePtr +xf86GTFMode(int h_pixels, int v_lines, float freq, int interlaced, int margins) +{ + DisplayModeRec *mode = xnfcalloc(1, sizeof(DisplayModeRec)); + + float h_pixels_rnd; + float v_lines_rnd; + float v_field_rate_rqd; + float top_margin; + float bottom_margin; + float interlace; + float h_period_est; + float vsync_plus_bp; + float v_back_porch; + float total_v_lines; + float v_field_rate_est; + float h_period; + float v_field_rate; + float v_frame_rate; + float left_margin; + float right_margin; + float total_active_pixels; + float ideal_duty_cycle; + float h_blank; + float total_pixels; + float pixel_freq; + float h_freq; + + float h_sync; + float h_front_porch; + float v_odd_front_porch_lines; + + /* 1. In order to give correct results, the number of horizontal + * pixels requested is first processed to ensure that it is divisible + * by the character size, by rounding it to the nearest character + * cell boundary: + * + * [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND]) + */ + + h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN; + + /* 2. If interlace is requested, the number of vertical lines assumed + * by the calculation must be halved, as the computation calculates + * the number of vertical lines per field. In either case, the + * number of lines is rounded to the nearest integer. + * + * [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0), + * ROUND([V LINES],0)) + */ + + v_lines_rnd = interlaced ? + rint((float) v_lines) / 2.0 : + rint((float) v_lines); + + /* 3. Find the frame rate required: + * + * [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2, + * [I/P FREQ RQD]) + */ + + v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq); + + /* 4. Find number of lines in Top margin: + * + * [TOP MARGIN (LINES)] = IF([MARGINS RQD?]="Y", + * ROUND(([MARGIN%]/100*[V LINES RND]),0), + * 0) + */ + + top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0); + + /* 5. Find number of lines in Bottom margin: + * + * [BOT MARGIN (LINES)] = IF([MARGINS RQD?]="Y", + * ROUND(([MARGIN%]/100*[V LINES RND]),0), + * 0) + */ + + bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0); + + /* 6. If interlace is required, then set variable [INTERLACE]=0.5: + * + * [INTERLACE]=(IF([INT RQD?]="y",0.5,0)) + */ + + interlace = interlaced ? 0.5 : 0.0; + + /* 7. Estimate the Horizontal period + * + * [H PERIOD EST] = ((1/[V FIELD RATE RQD]) - [MIN VSYNC+BP]/1000000) / + * ([V LINES RND] + (2*[TOP MARGIN (LINES)]) + + * [MIN PORCH RND]+[INTERLACE]) * 1000000 + */ + + h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0)) + / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace) + * 1000000.0); + + /* 8. Find the number of lines in V sync + back porch: + * + * [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0) + */ + + vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est); + + /* 9. Find the number of lines in V back porch alone: + * + * [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND] + * + * XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]? + */ + + v_back_porch = vsync_plus_bp - V_SYNC_RQD; + + /* 10. Find the total number of lines in Vertical field period: + * + * [TOTAL V LINES] = [V LINES RND] + [TOP MARGIN (LINES)] + + * [BOT MARGIN (LINES)] + [V SYNC+BP] + [INTERLACE] + + * [MIN PORCH RND] + */ + + total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp + + interlace + MIN_PORCH; + + /* 11. Estimate the Vertical field frequency: + * + * [V FIELD RATE EST] = 1 / [H PERIOD EST] / [TOTAL V LINES] * 1000000 + */ + + v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0; + + /* 12. Find the actual horizontal period: + * + * [H PERIOD] = [H PERIOD EST] / ([V FIELD RATE RQD] / [V FIELD RATE EST]) + */ + + h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est); + + /* 13. Find the actual Vertical field frequency: + * + * [V FIELD RATE] = 1 / [H PERIOD] / [TOTAL V LINES] * 1000000 + */ + + v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0; + + /* 14. Find the Vertical frame frequency: + * + * [V FRAME RATE] = (IF([INT RQD?]="y", [V FIELD RATE]/2, [V FIELD RATE])) + */ + + v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate; + + /* 15. Find number of pixels in left margin: + * + * [LEFT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y", + * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 / + * [CELL GRAN RND]),0)) * [CELL GRAN RND], + * 0)) + */ + + left_margin = margins ? + rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN : + 0.0; + + /* 16. Find number of pixels in right margin: + * + * [RIGHT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y", + * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 / + * [CELL GRAN RND]),0)) * [CELL GRAN RND], + * 0)) + */ + + right_margin = margins ? + rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN : + 0.0; + + /* 17. Find total number of active pixels in image and left and right + * margins: + * + * [TOTAL ACTIVE PIXELS] = [H PIXELS RND] + [LEFT MARGIN (PIXELS)] + + * [RIGHT MARGIN (PIXELS)] + */ + + total_active_pixels = h_pixels_rnd + left_margin + right_margin; + + /* 18. Find the ideal blanking duty cycle from the blanking duty cycle + * equation: + * + * [IDEAL DUTY CYCLE] = [C'] - ([M']*[H PERIOD]/1000) + */ + + ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0); + + /* 19. Find the number of pixels in the blanking time to the nearest + * double character cell: + * + * [H BLANK (PIXELS)] = (ROUND(([TOTAL ACTIVE PIXELS] * + * [IDEAL DUTY CYCLE] / + * (100-[IDEAL DUTY CYCLE]) / + * (2*[CELL GRAN RND])), 0)) + * * (2*[CELL GRAN RND]) + */ + + h_blank = rint(total_active_pixels * + ideal_duty_cycle / + (100.0 - ideal_duty_cycle) / + (2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN); + + /* 20. Find total number of pixels: + * + * [TOTAL PIXELS] = [TOTAL ACTIVE PIXELS] + [H BLANK (PIXELS)] + */ + + total_pixels = total_active_pixels + h_blank; + + /* 21. Find pixel clock frequency: + * + * [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD] + */ + + pixel_freq = total_pixels / h_period; + + /* 22. Find horizontal frequency: + * + * [H FREQ] = 1000 / [H PERIOD] + */ + + h_freq = 1000.0 / h_period; + + + /* Stage 1 computations are now complete; I should really pass + the results to another function and do the Stage 2 + computations, but I only need a few more values so I'll just + append the computations here for now */ + + + /* 17. Find the number of pixels in the horizontal sync period: + * + * [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] / + * [CELL GRAN RND]),0))*[CELL GRAN RND] + */ + + h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN; + + /* 18. Find the number of pixels in the horizontal front porch period: + * + * [H FRONT PORCH (PIXELS)] = ([H BLANK (PIXELS)]/2)-[H SYNC (PIXELS)] + */ + + h_front_porch = (h_blank / 2.0) - h_sync; + + /* 36. Find the number of lines in the odd front porch period: + * + * [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE]) + */ + + v_odd_front_porch_lines = MIN_PORCH + interlace; + + /* finally, pack the results in the mode struct */ + + mode->HDisplay = (int) (h_pixels_rnd); + mode->HSyncStart = (int) (h_pixels_rnd + h_front_porch); + mode->HSyncEnd = (int) (h_pixels_rnd + h_front_porch + h_sync); + mode->HTotal = (int) (total_pixels); + mode->VDisplay = (int) (v_lines_rnd); + mode->VSyncStart = (int) (v_lines_rnd + v_odd_front_porch_lines); + mode->VSyncEnd = (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD); + mode->VTotal = (int) (total_v_lines); + + mode->Clock = (int) (pixel_freq * 1000.0); + mode->HSync = h_freq; + mode->VRefresh = freq; + + xf86SetModeDefaultName(mode); + + mode->Flags = V_NHSYNC | V_PVSYNC; + if (interlaced) { + mode->VTotal *= 2; + mode->Flags |= V_INTERLACE; + } + + return mode; +} diff --git a/xorg-server/hw/xfree86/os-support/Makefile.am b/xorg-server/hw/xfree86/os-support/Makefile.am new file mode 100644 index 000000000..f9a82c68d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/Makefile.am @@ -0,0 +1,28 @@ +SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS) +DIST_SUBDIRS = bsd bus misc linux lynxos solaris sysv sco usl hurd + +sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h \ + assyntax.h xf86OSmouse.h + +EXTRA_DIST = int10Defines.h xf86OSpriv.h README.OS-lib + +# to get the grouping semantics right, you have to glom these three together +# as one library, otherwise libtool will actively defeat your attempts to +# list them multiple times on the link line. +noinst_LTLIBRARIES = libxorgos.la +libxorgos_la_SOURCES = xorgos.c +libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \ + bus/libbus.la \ + misc/libmisc.la + +AM_CFLAGS = $(DIX_CFLAGS) + +xorgos.c: + touch $@ + +DISTCLEANFILES = xorgos.c + +# FIXME: These don't seem to be used anywhere +EXTRA_DIST += \ + shared/bios_devmem.c \ + shared/inout.S diff --git a/xorg-server/hw/xfree86/os-support/Makefile.in b/xorg-server/hw/xfree86/os-support/Makefile.in new file mode 100644 index 000000000..6982a4366 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/Makefile.in @@ -0,0 +1,810 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libxorgos_la_DEPENDENCIES = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \ + bus/libbus.la misc/libmisc.la +am_libxorgos_la_OBJECTS = xorgos.lo +libxorgos_la_OBJECTS = $(am_libxorgos_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxorgos_la_SOURCES) +DIST_SOURCES = $(libxorgos_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS) +DIST_SUBDIRS = bsd bus misc linux lynxos solaris sysv sco usl hurd +sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h \ + assyntax.h xf86OSmouse.h + + +# FIXME: These don't seem to be used anywhere +EXTRA_DIST = int10Defines.h xf86OSpriv.h README.OS-lib \ + shared/bios_devmem.c shared/inout.S + +# to get the grouping semantics right, you have to glom these three together +# as one library, otherwise libtool will actively defeat your attempts to +# list them multiple times on the link line. +noinst_LTLIBRARIES = libxorgos.la +libxorgos_la_SOURCES = xorgos.c +libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \ + bus/libbus.la \ + misc/libmisc.la + +AM_CFLAGS = $(DIX_CFLAGS) +DISTCLEANFILES = xorgos.c +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libxorgos.la: $(libxorgos_la_OBJECTS) $(libxorgos_la_DEPENDENCIES) + $(LINK) $(libxorgos_la_OBJECTS) $(libxorgos_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgos.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-sdkHEADERS + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + clean-noinstLTLIBRARIES ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am \ + uninstall-sdkHEADERS + + +xorgos.c: + touch $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/README.OS-lib b/xorg-server/hw/xfree86/os-support/README.OS-lib new file mode 100644 index 000000000..e410906f9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/README.OS-lib @@ -0,0 +1,505 @@ + + README for XFree86 OS-support Layer + ----------------------------------- + +Contents +-------- + 1) Overview + 2) Directory Layout + 3) Adding a new OS + 4) OS Support API + +1 - Overview +------------ + This directory contains the OS support layer functions for the XFree86 +servers. In addition, some miscellaneous server support functions (not +OS-dependent) are included here, to take advantage of the fact that this +library comes last in the linking order. + +Most of the functionality required to support a new OS is encapsulated in +this library. It is hoped that all OS-specific details can be encapsulated, +but that is not likely ever to be completely possible. Hence some minor +changes will wind up being made in other parts of the server. The major +design principles for this library are maintainability, readability, and +portability. Sometimes these goals conflict; some somewhat arbitrary choices +have been made in implementation. + +2 - Directory Layout +-------------------- + os-support/ Contains headers and documentation; no code + misc/ Non-OS-specific miscellaneous functions that + fit best into the link architecture this way. + shared/ Contains files with functions used by more than one + OS. These are symlinked into the OS subdirectories + at build time via Imakefile rules. This is alway + preferable to reproducing functions in more than one + OS library. + bsd/ OS support for the 386BSD/NetBSD/FreeBSD operating + systems. + bsdi/ OS support for the BSD/386 operating system. + linux/ OS support for the Linux operating system. + sco/ OS support for the SCO SVR3.x operating system. + solx86/ OS support for the Solaris x86 operating system. + sysv/ OS support for all SVR4.0 and SVR4.2, and for + ISC and AT&T SVR3.2 operating systems. + +3 - Adding A New OS +------------------- + Adding a support for a new operating system entails implementing all of +the functions described in the API below. Many of these functions are no-ops +for many operating systems, and appropriate files with dummy declarations are +available in the 'shared' subdirectory. + +If your OS is sufficiently similar to an existing OS, you can make use of +the existing subdirectory. One of the reasons for implementing this OS +library was the unmaintainability of the spagetti-#ifdef code that existed +before. You should try to avoid cluttering the code with #ifdef's. If +you find that the subdirectory is getting cluttered, split off into a +seperate subdirectory (e.g. as was done for SCO, rather than cluttering +the 'sysv' subdirectory). You can split functions out of an existing +subdirectory into the 'shared' subdirectory, if that is appropriate. Just +remember to update the Imakefile for the old subdirectory. + +You will still likely have to make some small changes to other parts of +the server. You should not put OS-specific #define's or #include's anywhere +else in the server. These should all go in the "xf86_OSlib.h" header file +in this directory. + +4 - OS Support API +----------------- +void xf86OpenConsole(void) +{ + /* + * Open console device, activate VTs, etc, etc. Fill in requisite + * pieces of xf86Info. Most of this code comes from xf86Init.c + */ +} + +void xf86CloseConsole(void) +{ + /* + * Close console at server exit. + */ +} + +Bool xf86VTSwitchPending(void) +{ + /* + * Returns TRUE iff there is a VT switch operation pending for + * the server. In the USL VT model, this is indicated via a + * signal handler. Should return FALSE always for OSs without + * VTs. + */ +} + +Bool xf86VTSwitchAway(void) +{ + /* + * Handles the OS-specific action for switching away from the active + * VT. Returns FALSE if the switch away fails. Should return + * FALSE always for OSs without VTs (then again, this function + * should never be called in that case). + */ +} + +Bool xf86VTSwitchTo(void) +{ + /* + * Handles the OS-specific action for switching to the active VT. + * Returns FALSE if the switch to fails. Should return TRUE + * always for OSs without VTs (then again, this function should + * never be called in that case). + */ +} + +Bool xf86LinearVidMem(void) +{ + /* + * Returns TRUE if the OS supports mapping linear frame buffers + * (ie memory at addresses above physical memory). + */ +} + +pointer xf86MapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + /* + * Handle mapping the video memory. Returns (pointer *)0 for + * failure; causes server exit. It is allowable to call FatalError() + * from inside this function and exit directly. + */ +} + +void xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + /* + * Handle unmapping the video memory. This should undo what + * xf86MapVidMem() does. Base is a pointer obtained from + * a previous call to xf86MapVidMem(). + */ +} + +void xf86MapDisplay(int ScreenNum, int Region) +{ + /* + * For OSs that require the screen be mapped when entering a VT. + * A dummy function will be defined for OSs that don't require + * this (or don't have VTs at all). + */ +} + +void xf86UnMapDisplay(int ScreenNum, int Region) +{ + /* + * For Os that require that the screen be unmapped when leaving a + * VT. A dummy function will be defined for OSs that don't require + * this (or don't have VTs at all). + */ +} + +int xf86ReadBIOS(unsigned long Base, unsigned long Offset, + unsigned char *Buf, int Len) +{ + /* + * Read Len bytes from the BIOS at address Base, offset Offset, + * into buffer Buf. Returns -1 for failure or if the OS does + * not support reading the BIOS. This causes a driver probe + * to fail, but does not cause the server to abort. + */ +} + + +void xf86EnableIOPorts(int ScreenNum) +{ + /* + * Enables I/O permissions. The OS layer should + * enable all I/O port access. + */ +} + +void xf86DisableIOPorts(int ScreenNum) +{ + /* + * Disables I/O permissions. + */ +} + +Bool xf86DisableInterrupts(void) +{ + /* + * Disable interrupts if allowed for this OS. Returns FALSE if + * this is not allowed or if the attempt fails for some reason. + */ +} + +void xf86EnableInterrupts(void) +{ + /* + * Reenable interrupts + */ +} + +int xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Process OS-specific command-line arguments. See + * ddxProcessArgument() for more info. + */ +} + +void xf86UseMsg(void) +{ + /* + * Print list of OS-specific command-line arguments. See + * ddxUseMsg() for more info. + */ +} + +void xf86SoundKbdBell(int loudness, int pitch, int duration) +{ + /* + * Sound the keyboard bell. pitch is in Hz, duration in ms, + * loudness is in the range 0-100 (0 -> off). For systems + * where the loudness can't be controlled, scale the duration + * by loudness/50. + */ +} + +void xf86SetKbdLeds(int leds) +{ + /* + * Set the keyboard LEDs to the state indicated in leds + */ +} + +int xf86GetKbdLeds(void) +{ + /* + * Return the state of the keyboard LEDs. If the OS doesn't + * support this, return 0. + */ +} + +void xf86SetKbdRepeat(char rad) +{ + /* + * Set the keyboard repeat rate and delay according the + * the rad value. The lower 5 bits determine the repeat + * rate (lower value -> higher rate). The next 2 bits + * determine the delay. + * This should possibly be changed to take separate rate and + * delay parameters. + */ +} + +void xf86KbdInit(void) +{ + /* + * Save initial keyboard state. This is called at the start of + * each server generation. + */ +} + +int xf86KbdOn(void) +{ + /* + * Set the keyboard up for use with X. This is called whenever + * the server becomes active (ie at the start of each generation and + * whenever its VT becomes active). Return the file descriptor + * for keyboard input. Return -1 if there is no file descriptor + * to add as an input device. If there are errors encountered, + * call FatalError(). A return value of -1 is not considered an + * error condition. + */ +} + +int xf86KbdOff(void) +{ + /* + * Return the keyboard to the state saved by xf86KbdInit(). This is + * called at the end of a server generation, and also when the + * server's VT ceases being active. Returns the keyboard file + * descriptor. Returns -1 if there is no file descriptor to be + * removed as an input device. Errors should be handled the same + * way as in xf86KbdOn(). + */ +} + +void xf86KbdEvents(void) +{ + /* + * Read characters from the keyboard device, and post the events + * by calling xf86PostKbdEvent(). Read as much as is available + * without waiting. + */ +} + +void xf86SetMouseSpeed(int old, int new, unsigned cflag) +{ + /* + * Set the speed of the mouse port. old is the previous speed, + * new is the new speed, and cflag is the value of the termio[s] + * c_cflag field. For mice that have programmable speed operation, + * this should send the appropriate commands to the mouse. + */ +} + +void xf86MouseInit(void) +{ + /* + * This is called at the start of each server generation. In most + * cases this is a noop. If the mouse must not be opened/closed + * when VT switching, the open should be done here. + */ +} + +int xf86MousedOn(void) +{ + /* + * Set the mouse up for use with X. This is called whenever + * the server becomes active (ie at the start of each generation and + * whenever its VT becomes active). This function normally opens + * the mouse device, and may call xf86SetupMouse() to initialise + * the mouse parameters. Return the file descriptor for mouse input. + * Return -1 if there is no file descriptor to add as an input + * device. If there are errors encountered, call FatalError(). + * A return value of -1 is not considered an error condition. + */ +} + +int xf86MouseOff(Bool doclose) +{ + /* + * Release the mouse from use with X. This is called at the end + * of a server generation (with doclose==TRUE), and also when the + * server's VT ceases being active (with doclose==FALSE). If the + * mouse should not be opened/closed when VT switching, the close + * should be done here when doclose==TRUE. For other systems, the + * mouse device should be closed regardless of the doclose value. + * Returns the mouse file descriptor. Returns -1 if there is no + * file descriptor to be removed as an input device. Errors + * should be handled the same way as in xf86MouseOn(). + */ +} + +void xf86MouseEvents(void) +{ + /* + * Read characters from the mouse device, and post the events + * by calling xf86PostMseEvent(). Read as much as is available + * without waiting. If the OS doesn't handle the mouse protocol + * translation, xf86MouseProtocol() may be called to do the + * translation and event posting. If the OS does handle the protocol + * translation, MOUSE_PROTOCOL_IN_KERNEL should be #define'd in + * xf86_OSlib.h. + */ +} + +int xf86OsMouseProc(DevicePtr pPointer, int what) +{ + /* + * Implements the device-proc for the pointer device when an + * OS-based mouse driver is being used (as opposed to the + * server's internal mouse driver). Implemented as any other + * device-proc in the server. + * + * This function only needs to be implemented if USE_OSMOUSE is + * defined for the OS. + */ +} + +int xf86OsMouseEvents(void) +{ + /* + * When supporting an OS-based mouse driver (as opposed to the + * server's internal mouse driver), read some events from the device + * and post them to the DIX layer through xf86PostMseEvent(). + * + * This function only needs to be implemented if USE_OSMOUSE is + * defined for the OS. + */ +} + +void xf86OsMouseOption(int token, pointer lex_ptr) +{ + /* + * Used in parsing an OsMouse keyword from the Xconfig file. + * Passed the token type and a pointer to the token value. + * The function should do whatever is appropriate for the OS's + * mouse driver. + * + * This function only needs to be implemented if USE_OSMOUSE is + * defined for the OS. + */ +} + +/* + * The following functions are simply wrappers around the OS specific + * libc functions + */ + +void * +xf86memmove(void * dest, const void * src, INT32 n) +{ + return(memmove(dest,src,n)); +} + +void * +xf86memset(void * s, int c, INT32 n) +{ + return(memset(s,c,n)); +} + +void * +xf86memcpy(void * dest, const void * src, INT32 n) +{ + return(memcpy(dest,src,n)); +} + +int +xf86memcmp(const void * s1, const void * s2, INT32 n) +{ + return(memcmp(s1,s2,n)); +} + +char * +xf86strcat(char * dest, const char * src) +{ + return(strcat(dest,src)); +} + +char * +xf86strcpy(char * dest, const char * src) +{ + return(strcpy(dest,src)); +} + +int +xf86strcmp(const char * s1, const char * s2) +{ + return(strcmp(s1,s2)); +} + +int +xf86strncmp(const char * s1, const char * s2, INT32 n) +{ + return(strncmp(s1,s2,n)); +} + +size_t +xf86strlen(const char * s) +{ + return(strlen(s)); +} + +void +xf86getsecs(INT32 * secs, INT32 * usecs) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + *secs = tv.tv_sec; + *usecs= tv.tv_usec; + + return; +} + +double +xf86exp(double x) +{ + return(exp(x)); +} + +double +xf86log(double x) +{ + return(log(x)); +} + +double +xf86pow(double x, double y) +{ + return(pow(x,y)); +} + +double +xf86sqrt(double x) +{ + return(sqrt(x)); +} + +double +xf86cos(double x) +{ + return(cos(x)); +} + + + + +$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.10 2001/12/17 20:00:45 dawes Exp $ + + + + + +$XConsortium: README.OS-lib /main/5 1996/02/21 17:50:28 kaleb $ diff --git a/xorg-server/hw/xfree86/os-support/assyntax.h b/xorg-server/hw/xfree86/os-support/assyntax.h new file mode 100644 index 000000000..d3e96e5fd --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/assyntax.h @@ -0,0 +1,749 @@ +#ifndef __ASSYNTAX_H__ +#define __ASSYNTAX_H__ + +/* + * Copyright 1992 Vrije Universiteit, The Netherlands + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the Vrije Universiteit not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The Vrije Universiteit makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL The Vrije Universiteit BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* + * Copyright (c) 1993-1999 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + /* + * assyntax.h + * + * Select the syntax appropriate to the 386 assembler being used + * To add support for more assemblers add more columns to the CHOICE + * macro. Note that register names must also have uppercase names + * to avoid macro recursion. e.g., #define ah %ah recurses! + * + * NB 1. Some of the macros for certain assemblers imply that the code is to + * run in protected mode!! Caveat emptor. + * + * NB 2. 486 specific instructions are not included. This is to discourage + * their accidental use in code that is intended to run on 386 and 486 + * systems. + * + * Supported assemblers: + * + * (a) AT&T SysVr4 as(1): default + * (b) GNU Assembler gas: define USE_GAS or GNU_ASSEMBLER + * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER + * + * The following naming conventions have been used to identify the various + * data types: + * _SR = segment register version + * Integer: + * _Q = quadword = 64 bits + * _L = long = 32 bits + * _W = short = 16 bits + * _B = byte = 8 bits + * Floating-point: + * _X = m80real = 80 bits + * _D = double = 64 bits + * _S = single = 32 bits + * + * Author: Gregory J. Sharp, Sept 1992 + * Vrije Universiteit, Amsterdam, The Netherlands + */ + +#if defined(USE_GAS) && !defined(GNU_ASSEMBLER) +#define GNU_ASSEMBLER +#endif + +#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (__i386__) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__)) +#define CONCAT(x, y) x ## y +#else +#define CONCAT(x, y) x/**/y +#endif + +#ifdef ACK_ASSEMBLER + +/* Assume we write code for 32-bit protected mode! */ + +/* Redefine register names for GAS & AT&T assemblers */ +#define AL al +#define AH ah +#define AX ax +#define EAX ax +#define BL bl +#define BH bh +#define BX bx +#define EBX bx +#define CL cl +#define CH ch +#define CX cx +#define ECX cx +#define DL dl +#define DH dh +#define DX dx +#define EDX dx +#define BP bp +#define EBP bp +#define SI si +#define ESI si +#define DI di +#define EDI di +#define SP sp +#define ESP sp +#define CS cs +#define SS ss +#define DS ds +#define ES es +#define FS fs +#define GS gs +/* Control Registers */ +#define CR0 cr0 +#define CR1 cr1 +#define CR2 cr2 +#define CR3 cr3 +/* Debug Registers */ +#define DR0 dr0 +#define DR1 dr1 +#define DR2 dr2 +#define DR3 dr3 +#define DR4 dr4 +#define DR5 dr5 +#define DR6 dr6 +#define DR7 dr7 +/* Floating-point Stack */ +#define ST st + +#define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text + + +#define _WTOG o16 /* word toggle for _W instructions */ +#define _LTOG /* long toggle for _L instructions */ +#define ADDR_TOGGLE a16 +#define OPSZ_TOGGLE o16 +#define USE16 .use16 +#define USE32 .use32 + +#define CHOICE(a,b,c) c + +#else /* AT&T or GAS */ + +/* Redefine register names for GAS & AT&T assemblers */ +#define AL %al +#define AH %ah +#define AX %ax +#define EAX %eax +#define BL %bl +#define BH %bh +#define BX %bx +#define EBX %ebx +#define CL %cl +#define CH %ch +#define CX %cx +#define ECX %ecx +#define DL %dl +#define DH %dh +#define DX %dx +#define EDX %edx +#define BP %bp +#define EBP %ebp +#define SI %si +#define ESI %esi +#define DI %di +#define EDI %edi +#define SP %sp +#define ESP %esp +#define CS %cs +#define SS %ss +#define DS %ds +#define ES %es +#define FS %fs +#define GS %gs +/* Control Registers */ +#define CR0 %cr0 +#define CR1 %cr1 +#define CR2 %cr2 +#define CR3 %cr3 +/* Debug Registers */ +#define DR0 %db0 +#define DR1 %db1 +#define DR2 %db2 +#define DR3 %db3 +#define DR4 %db4 +#define DR5 %db5 +#define DR6 %db6 +#define DR7 %db7 +/* Floating-point Stack */ +#define ST %st + +#define AS_BEGIN +#define USE16 +#define USE32 + +#ifdef GNU_ASSEMBLER + +#define ADDR_TOGGLE aword +#define OPSZ_TOGGLE word + +#define CHOICE(a,b,c) b + +#else +/* + * AT&T ASSEMBLER SYNTAX + * ********************* + */ +#define CHOICE(a,b,c) a + +#define ADDR_TOGGLE addr16 +#define OPSZ_TOGGLE data16 + +#endif /* GNU_ASSEMBLER */ +#endif /* ACK_ASSEMBLER */ + + +#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) +#define GLNAME(a) a +#else +#define GLNAME(a) CONCAT(_,a) +#endif + + + /****************************************/ + /* */ + /* Select the various choices */ + /* */ + /****************************************/ + + +/* Redefine assembler directives */ +/*********************************/ +#define GLOBL CHOICE(.globl, .globl, .extern) +#define ALIGNTEXT4 CHOICE(.align 4, .align ARG2(2,0x90), .align 4) +#define ALIGNTEXT2 CHOICE(.align 2, .align ARG2(1,0x90), .align 2) +/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is + * guaranteed to be filled with NOPs. Otherwise it does nothing. + */ +#define ALIGNTEXT4ifNOP CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/) +#define ALIGNDATA4 CHOICE(.align 4, .align ARG2(2,0x0), .align 4) +#define ALIGNDATA2 CHOICE(.align 2, .align ARG2(1,0x0), .align 2) +#define FILE(s) CHOICE(.file s, .file s, .file s) +#define STRING(s) CHOICE(.string s, .asciz s, .asciz s) +#define D_LONG CHOICE(.long, .long, .data4) +#define D_WORD CHOICE(.value, .short, .data2) +#define D_BYTE CHOICE(.byte, .byte, .data1) +#define SPACE CHOICE(.comm, .space, .space) +#define COMM CHOICE(.comm, .comm, .comm) +#define SEG_DATA CHOICE(.data, .data, .sect .data) +#define SEG_TEXT CHOICE(.text, .text, .sect .text) +#define SEG_BSS CHOICE(.bss, .bss, .sect .bss) + +#ifdef GNU_ASSEMBLER +#define D_SPACE(n) . = . + n +#else +#define D_SPACE(n) .space n +#endif + +/* Addressing Modes */ +/* Immediate Mode */ +#define ADDR(a) CHOICE(CONCAT($,a), CONCAT($,a), a) +#define CONST(a) CHOICE(CONCAT($,a), CONCAT($,a), a) + +/* Indirect Mode */ +#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */ +#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */ +/* Register b indirect plus displacement a */ +#define REGOFF(a, b) CHOICE(a(b), a(b), a(b)) +/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode + * which has no scaling + */ +#define REGBID(b,i,d) CHOICE(d(b,i), d(b,i), d(b)(i)) +/* Reg indirect Base + (Index * Scale) + Displacement */ +#define REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s)) +/* Displaced Scaled Index: */ +#define REGDIS(d,i,s) CHOICE(d(,i,s), d(,i,s), d(i * s)) +/* Indexed Base: */ +#define REGBI(b,i) CHOICE((b,i), (b,i), (b)(i)) +/* Displaced Base: */ +#define REGDB(d,b) CHOICE(d(b), d(b), d(b)) +/* Variable indirect: */ +#define VARINDIRECT(var) CHOICE(*var, *var, (var)) +/* Use register contents as jump/call target: */ +#define CODEPTR(reg) CHOICE(*reg, *reg, reg) + +/* For expressions requiring bracketing + * eg. (CRT0_PM | CRT_EM) + */ + +#define EXPR(a) CHOICE([a], (a), [a]) +#define ENOT(a) CHOICE(0!a, ~a, ~a) +#define EMUL(a,b) CHOICE(a\*b, a*b, a*b) +#define EDIV(a,b) CHOICE(a\/b, a/b, a/b) + +/* + * We have to beat the problem of commas within arguments to choice. + * eg. choice (add a,b, add b,a) will get argument mismatch. Luckily ANSI + * and other known cpp definitions evaluate arguments before substitution + * so the following works. + */ +#define ARG2(a, b) a,b +#define ARG3(a,b,c) a,b,c + +/* Redefine assembler commands */ +#define AAA CHOICE(aaa, aaa, aaa) +#define AAD CHOICE(aad, aad, aad) +#define AAM CHOICE(aam, aam, aam) +#define AAS CHOICE(aas, aas, aas) +#define ADC_L(a, b) CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a)) +#define ADC_W(a, b) CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a)) +#define ADC_B(a, b) CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a)) +#define ADD_L(a, b) CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a)) +#define ADD_W(a, b) CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a)) +#define ADD_B(a, b) CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a)) +#define AND_L(a, b) CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a)) +#define AND_W(a, b) CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a)) +#define AND_B(a, b) CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a)) +#define ARPL(a,b) CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a)) +#define BOUND_L(a, b) CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a)) +#define BOUND_W(a, b) CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a)) +#define BSF_L(a, b) CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a)) +#define BSF_W(a, b) CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a)) +#define BSR_L(a, b) CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a)) +#define BSR_W(a, b) CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a)) +#define BT_L(a, b) CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a)) +#define BT_W(a, b) CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a)) +#define BTC_L(a, b) CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a)) +#define BTC_W(a, b) CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a)) +#define BTR_L(a, b) CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a)) +#define BTR_W(a, b) CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a)) +#define BTS_L(a, b) CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a)) +#define BTS_W(a, b) CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a)) +#define CALL(a) CHOICE(call a, call a, call a) +#define CALLF(s,a) CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a) +#define CBW CHOICE(cbtw, cbw, cbw) +#define CWDE CHOICE(cwtd, cwde, cwde) +#define CLC CHOICE(clc, clc, clc) +#define CLD CHOICE(cld, cld, cld) +#define CLI CHOICE(cli, cli, cli) +#define CLTS CHOICE(clts, clts, clts) +#define CMC CHOICE(cmc, cmc, cmc) +#define CMP_L(a, b) CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a)) +#define CMP_W(a, b) CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a)) +#define CMP_B(a, b) CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a)) +#define CMPS_L CHOICE(cmpsl, cmpsl, _LTOG cmps) +#define CMPS_W CHOICE(cmpsw, cmpsw, _WTOG cmps) +#define CMPS_B CHOICE(cmpsb, cmpsb, cmpsb) +#define CWD CHOICE(cwtl, cwd, cwd) +#define CDQ CHOICE(cltd, cdq, cdq) +#define DAA CHOICE(daa, daa, daa) +#define DAS CHOICE(das, das, das) +#define DEC_L(a) CHOICE(decl a, decl a, _LTOG dec a) +#define DEC_W(a) CHOICE(decw a, decw a, _WTOG dec a) +#define DEC_B(a) CHOICE(decb a, decb a, decb a) +#define DIV_L(a) CHOICE(divl a, divl a, div a) +#define DIV_W(a) CHOICE(divw a, divw a, div a) +#define DIV_B(a) CHOICE(divb a, divb a, divb a) +#define ENTER(a,b) CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a)) +#define HLT CHOICE(hlt, hlt, hlt) +#define IDIV_L(a) CHOICE(idivl a, idivl a, _LTOG idiv a) +#define IDIV_W(a) CHOICE(idivw a, idivw a, _WTOG idiv a) +#define IDIV_B(a) CHOICE(idivb a, idivb a, idivb a) +/* More forms than this for imul!! */ +#define IMUL_L(a, b) CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a)) +#define IMUL_W(a, b) CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a)) +#define IMUL_B(a) CHOICE(imulb a, imulb a, imulb a) +#define IN_L CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX) +#define IN_W CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX) +#define IN_B CHOICE(inb (DX), inb ARG2(DX,AL), inb DX) +/* Please AS code writer: use the following ONLY, if you refer to ports<256 + * directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer + */ +#if defined (sun) +#define IN1_L(a) CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a) +#define IN1_W(a) CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a) +#define IN1_B(a) CHOICE(inb (a), inb ARG2(a,AL), inb a) +#else +#define IN1_L(a) CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a) +#define IN1_W(a) CHOICE(inw a, inw ARG2(a,AX), _WTOG in a) +#define IN1_B(a) CHOICE(inb a, inb ARG2(a,AL), inb a) +#endif +#define INC_L(a) CHOICE(incl a, incl a, _LTOG inc a) +#define INC_W(a) CHOICE(incw a, incw a, _WTOG inc a) +#define INC_B(a) CHOICE(incb a, incb a, incb a) +#define INS_L CHOICE(insl, insl, _LTOG ins) +#define INS_W CHOICE(insw, insw, _WTOG ins) +#define INS_B CHOICE(insb, insb, insb) +#define INT(a) CHOICE(int a, int a, int a) +#define INT3 CHOICE(int CONST(3), int3, int CONST(3)) +#define INTO CHOICE(into, into, into) +#define IRET CHOICE(iret, iret, iret) +#define IRETD CHOICE(iret, iret, iretd) +#define JA(a) CHOICE(ja a, ja a, ja a) +#define JAE(a) CHOICE(jae a, jae a, jae a) +#define JB(a) CHOICE(jb a, jb a, jb a) +#define JBE(a) CHOICE(jbe a, jbe a, jbe a) +#define JC(a) CHOICE(jc a, jc a, jc a) +#define JE(a) CHOICE(je a, je a, je a) +#define JG(a) CHOICE(jg a, jg a, jg a) +#define JGE(a) CHOICE(jge a, jge a, jge a) +#define JL(a) CHOICE(jl a, jl a, jl a) +#define JLE(a) CHOICE(jle a, jle a, jle a) +#define JNA(a) CHOICE(jna a, jna a, jna a) +#define JNAE(a) CHOICE(jnae a, jnae a, jnae a) +#define JNB(a) CHOICE(jnb a, jnb a, jnb a) +#define JNBE(a) CHOICE(jnbe a, jnbe a, jnbe a) +#define JNC(a) CHOICE(jnc a, jnc a, jnc a) +#define JNE(a) CHOICE(jne a, jne a, jne a) +#define JNG(a) CHOICE(jng a, jng a, jng a) +#define JNGE(a) CHOICE(jnge a, jnge a, jnge a) +#define JNL(a) CHOICE(jnl a, jnl a, jnl a) +#define JNLE(a) CHOICE(jnle a, jnle a, jnle a) +#define JNO(a) CHOICE(jno a, jno a, jno a) +#define JNP(a) CHOICE(jnp a, jnp a, jnp a) +#define JNS(a) CHOICE(jns a, jns a, jns a) +#define JNZ(a) CHOICE(jnz a, jnz a, jnz a) +#define JO(a) CHOICE(jo a, jo a, jo a) +#define JP(a) CHOICE(jp a, jp a, jp a) +#define JPE(a) CHOICE(jpe a, jpe a, jpe a) +#define JPO(a) CHOICE(jpo a, jpo a, jpo a) +#define JS(a) CHOICE(js a, js a, js a) +#define JZ(a) CHOICE(jz a, jz a, jz a) +#define JMP(a) CHOICE(jmp a, jmp a, jmp a) +#define JMPF(s,a) CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a) +#define LAHF CHOICE(lahf, lahf, lahf) +#if !defined(_REAL_MODE) && !defined(_V86_MODE) +#define LAR(a, b) CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a)) +#endif +#define LEA_L(a, b) CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a)) +#define LEA_W(a, b) CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a)) +#define LEAVE CHOICE(leave, leave, leave) +#define LGDT(a) CHOICE(lgdt a, lgdt a, lgdt a) +#define LIDT(a) CHOICE(lidt a, lidt a, lidt a) +#define LDS(a, b) CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a)) +#define LES(a, b) CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a)) +#define LFS(a, b) CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a)) +#define LGS(a, b) CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a)) +#define LSS(a, b) CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a)) +#define LLDT(a) CHOICE(lldt a, lldt a, lldt a) +#define LMSW(a) CHOICE(lmsw a, lmsw a, lmsw a) +#define LOCK CHOICE(lock, lock, lock) +#define LODS_L CHOICE(lodsl, lodsl, _LTOG lods) +#define LODS_W CHOICE(lodsw, lodsw, _WTOG lods) +#define LODS_B CHOICE(lodsb, lodsb, lodsb) +#define LOOP(a) CHOICE(loop a, loop a, loop a) +#define LOOPE(a) CHOICE(loope a, loope a, loope a) +#define LOOPZ(a) CHOICE(loopz a, loopz a, loopz a) +#define LOOPNE(a) CHOICE(loopne a, loopne a, loopne a) +#define LOOPNZ(a) CHOICE(loopnz a, loopnz a, loopnz a) +#if !defined(_REAL_MODE) && !defined(_V86_MODE) +#define LSL(a, b) CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a)) +#endif +#define LTR(a) CHOICE(ltr a, ltr a, ltr a) +#define MOV_SR(a, b) CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a)) +#define MOV_L(a, b) CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a)) +#define MOV_W(a, b) CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a)) +#define MOV_B(a, b) CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a)) +#define MOVS_L CHOICE(movsl, movsl, _LTOG movs) +#define MOVS_W CHOICE(movsw, movsw, _WTOG movs) +#define MOVS_B CHOICE(movsb, movsb, movsb) +#define MOVSX_BL(a, b) CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a)) +#define MOVSX_BW(a, b) CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a)) +#define MOVSX_WL(a, b) CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a)) +#define MOVZX_BL(a, b) CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a)) +#define MOVZX_BW(a, b) CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a)) +#define MOVZX_WL(a, b) CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a)) +#define MUL_L(a) CHOICE(mull a, mull a, _LTOG mul a) +#define MUL_W(a) CHOICE(mulw a, mulw a, _WTOG mul a) +#define MUL_B(a) CHOICE(mulb a, mulb a, mulb a) +#define NEG_L(a) CHOICE(negl a, negl a, _LTOG neg a) +#define NEG_W(a) CHOICE(negw a, negw a, _WTOG neg a) +#define NEG_B(a) CHOICE(negb a, negb a, negb a) +#define NOP CHOICE(nop, nop, nop) +#define NOT_L(a) CHOICE(notl a, notl a, _LTOG not a) +#define NOT_W(a) CHOICE(notw a, notw a, _WTOG not a) +#define NOT_B(a) CHOICE(notb a, notb a, notb a) +#define OR_L(a,b) CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a)) +#define OR_W(a,b) CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a)) +#define OR_B(a,b) CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a)) +#define OUT_L CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX) +#define OUT_W CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX) +#define OUT_B CHOICE(outb (DX), outb ARG2(AL,DX), outb DX) +/* Please AS code writer: use the following ONLY, if you refer to ports<256 + * directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer + */ +#define OUT1_L(a) CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a) +#define OUT1_W(a) CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a) +#define OUT1_B(a) CHOICE(outb (a), outb ARG2(AL,a), outb a) +#define OUTS_L CHOICE(outsl, outsl, _LTOG outs) +#define OUTS_W CHOICE(outsw, outsw, _WTOG outs) +#define OUTS_B CHOICE(outsb, outsb, outsb) +#define POP_SR(a) CHOICE(pop a, pop a, pop a) +#define POP_L(a) CHOICE(popl a, popl a, _LTOG pop a) +#define POP_W(a) CHOICE(popw a, popw a, _WTOG pop a) +#define POPA_L CHOICE(popal, popal, _LTOG popa) +#define POPA_W CHOICE(popaw, popaw, _WTOG popa) +#define POPF_L CHOICE(popfl, popfl, _LTOG popf) +#define POPF_W CHOICE(popfw, popfw, _WTOG popf) +#define PUSH_SR(a) CHOICE(push a, push a, push a) +#define PUSH_L(a) CHOICE(pushl a, pushl a, _LTOG push a) +#define PUSH_W(a) CHOICE(pushw a, pushw a, _WTOG push a) +#define PUSH_B(a) CHOICE(push a, pushb a, push a) +#define PUSHA_L CHOICE(pushal, pushal, _LTOG pusha) +#define PUSHA_W CHOICE(pushaw, pushaw, _WTOG pusha) +#define PUSHF_L CHOICE(pushfl, pushfl, _LTOG pushf) +#define PUSHF_W CHOICE(pushfw, pushfw, _WTOG pushf) +#define RCL_L(a, b) CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a)) +#define RCL_W(a, b) CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a)) +#define RCL_B(a, b) CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a)) +#define RCR_L(a, b) CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a)) +#define RCR_W(a, b) CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a)) +#define RCR_B(a, b) CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a)) +#define ROL_L(a, b) CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a)) +#define ROL_W(a, b) CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a)) +#define ROL_B(a, b) CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a)) +#define ROR_L(a, b) CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a)) +#define ROR_W(a, b) CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a)) +#define ROR_B(a, b) CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a)) +#define REP CHOICE(rep ;, rep ;, repe) +#define REPE CHOICE(repz ;, repe ;, repe) +#define REPNE CHOICE(repnz ;, repne ;, repne) +#define REPNZ REPNE +#define REPZ REPE +#define RET CHOICE(ret, ret, ret) +#define SAHF CHOICE(sahf, sahf, sahf) +#define SAL_L(a, b) CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a)) +#define SAL_W(a, b) CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a)) +#define SAL_B(a, b) CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a)) +#define SAR_L(a, b) CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a)) +#define SAR_W(a, b) CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a)) +#define SAR_B(a, b) CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a)) +#define SBB_L(a, b) CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a)) +#define SBB_W(a, b) CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a)) +#define SBB_B(a, b) CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a)) +#define SCAS_L CHOICE(scasl, scasl, _LTOG scas) +#define SCAS_W CHOICE(scasw, scasw, _WTOG scas) +#define SCAS_B CHOICE(scasb, scasb, scasb) +#define SETA(a) CHOICE(seta a, seta a, seta a) +#define SETAE(a) CHOICE(setae a, setae a, setae a) +#define SETB(a) CHOICE(setb a, setb a, setb a) +#define SETBE(a) CHOICE(setbe a, setbe a, setbe a) +#define SETC(a) CHOICE(setc a, setb a, setb a) +#define SETE(a) CHOICE(sete a, sete a, sete a) +#define SETG(a) CHOICE(setg a, setg a, setg a) +#define SETGE(a) CHOICE(setge a, setge a, setge a) +#define SETL(a) CHOICE(setl a, setl a, setl a) +#define SETLE(a) CHOICE(setle a, setle a, setle a) +#define SETNA(a) CHOICE(setna a, setna a, setna a) +#define SETNAE(a) CHOICE(setnae a, setnae a, setnae a) +#define SETNB(a) CHOICE(setnb a, setnb a, setnb a) +#define SETNBE(a) CHOICE(setnbe a, setnbe a, setnbe a) +#define SETNC(a) CHOICE(setnc a, setnb a, setnb a) +#define SETNE(a) CHOICE(setne a, setne a, setne a) +#define SETNG(a) CHOICE(setng a, setng a, setng a) +#define SETNGE(a) CHOICE(setnge a, setnge a, setnge a) +#define SETNL(a) CHOICE(setnl a, setnl a, setnl a) +#define SETNLE(a) CHOICE(setnle a, setnle a, setnle a) +#define SETNO(a) CHOICE(setno a, setno a, setno a) +#define SETNP(a) CHOICE(setnp a, setnp a, setnp a) +#define SETNS(a) CHOICE(setns a, setns a, setna a) +#define SETNZ(a) CHOICE(setnz a, setnz a, setnz a) +#define SETO(a) CHOICE(seto a, seto a, seto a) +#define SETP(a) CHOICE(setp a, setp a, setp a) +#define SETPE(a) CHOICE(setpe a, setpe a, setpe a) +#define SETPO(a) CHOICE(setpo a, setpo a, setpo a) +#define SETS(a) CHOICE(sets a, sets a, seta a) +#define SETZ(a) CHOICE(setz a, setz a, setz a) +#define SGDT(a) CHOICE(sgdt a, sgdt a, sgdt a) +#define SIDT(a) CHOICE(sidt a, sidt a, sidt a) +#define SHL_L(a, b) CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a)) +#define SHL_W(a, b) CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a)) +#define SHL_B(a, b) CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a)) +#define SHLD_L(a,b,c) CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a)) +#define SHLD2_L(a,b) CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL)) +#define SHLD_W(a,b,c) CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a)) +#define SHLD2_W(a,b) CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL)) +#define SHR_L(a, b) CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a)) +#define SHR_W(a, b) CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a)) +#define SHR_B(a, b) CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a)) +#define SHRD_L(a,b,c) CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a)) +#define SHRD2_L(a,b) CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL)) +#define SHRD_W(a,b,c) CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a)) +#define SHRD2_W(a,b) CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL)) +#define SLDT(a) CHOICE(sldt a, sldt a, sldt a) +#define SMSW(a) CHOICE(smsw a, smsw a, smsw a) +#define STC CHOICE(stc, stc, stc) +#define STD CHOICE(std, std, std) +#define STI CHOICE(sti, sti, sti) +#define STOS_L CHOICE(stosl, stosl, _LTOG stos) +#define STOS_W CHOICE(stosw, stosw, _WTOG stos) +#define STOS_B CHOICE(stosb, stosb, stosb) +#define STR(a) CHOICE(str a, str a, str a) +#define SUB_L(a, b) CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a)) +#define SUB_W(a, b) CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a)) +#define SUB_B(a, b) CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a)) +#define TEST_L(a, b) CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a)) +#define TEST_W(a, b) CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a)) +#define TEST_B(a, b) CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a)) +#define VERR(a) CHOICE(verr a, verr a, verr a) +#define VERW(a) CHOICE(verw a, verw a, verw a) +#define WAIT CHOICE(wait, wait, wait) +#define XCHG_L(a, b) CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a)) +#define XCHG_W(a, b) CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a)) +#define XCHG_B(a, b) CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a)) +#define XLAT CHOICE(xlat, xlat, xlat) +#define XOR_L(a, b) CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a)) +#define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a)) +#define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a)) + + +/* Floating Point Instructions */ +#define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1) +#define FABS CHOICE(fabs, fabs, fabs) +#define FADD_D(a) CHOICE(faddl a, faddl a, faddd a) +#define FADD_S(a) CHOICE(fadds a, fadds a, fadds a) +#define FADD2(a, b) CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a)) +#define FADDP(a, b) CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a)) +#define FIADD_L(a) CHOICE(fiaddl a, fiaddl a, fiaddl a) +#define FIADD_W(a) CHOICE(fiadd a, fiadds a, fiadds a) +#define FBLD(a) CHOICE(fbld a, fbld a, fbld a) +#define FBSTP(a) CHOICE(fbstp a, fbstp a, fbstp a) +#define FCHS CHOICE(fchs, fchs, fchs) +#define FCLEX CHOICE(fclex, wait; fnclex, wait; fclex) +#define FNCLEX CHOICE(fnclex, fnclex, fclex) +#define FCOM(a) CHOICE(fcom a, fcom a, fcom a) +#define FCOM_D(a) CHOICE(fcoml a, fcoml a, fcomd a) +#define FCOM_S(a) CHOICE(fcoms a, fcoms a, fcoms a) +#define FCOMP(a) CHOICE(fcomp a, fcomp a, fcomp a) +#define FCOMP_D(a) CHOICE(fcompl a, fcompl a, fcompd a) +#define FCOMP_S(a) CHOICE(fcomps a, fcomps a, fcomps a) +#define FCOMPP CHOICE(fcompp, fcompp, fcompp) +#define FCOS CHOICE(fcos, fcos, fcos) +#define FDECSTP CHOICE(fdecstp, fdecstp, fdecstp) +#define FDIV_D(a) CHOICE(fdivl a, fdivl a, fdivd a) +#define FDIV_S(a) CHOICE(fdivs a, fdivs a, fdivs a) +#define FDIV2(a, b) CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a)) +#define FDIVP(a, b) CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a)) +#define FIDIV_L(a) CHOICE(fidivl a, fidivl a, fidivl a) +#define FIDIV_W(a) CHOICE(fidiv a, fidivs a, fidivs a) +#define FDIVR_D(a) CHOICE(fdivrl a, fdivrl a, fdivrd a) +#define FDIVR_S(a) CHOICE(fdivrs a, fdivrs a, fdivrs a) +#define FDIVR2(a, b) CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a)) +#define FDIVRP(a, b) CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a)) +#define FIDIVR_L(a) CHOICE(fidivrl a, fidivrl a, fidivrl a) +#define FIDIVR_W(a) CHOICE(fidivr a, fidivrs a, fidivrs a) +#define FFREE(a) CHOICE(ffree a, ffree a, ffree a) +#define FICOM_L(a) CHOICE(ficoml a, ficoml a, ficoml a) +#define FICOM_W(a) CHOICE(ficom a, ficoms a, ficoms a) +#define FICOMP_L(a) CHOICE(ficompl a, ficompl a, ficompl a) +#define FICOMP_W(a) CHOICE(ficomp a, ficomps a, ficomps a) +#define FILD_Q(a) CHOICE(fildll a, fildq a, fildq a) +#define FILD_L(a) CHOICE(fildl a, fildl a, fildl a) +#define FILD_W(a) CHOICE(fild a, filds a, filds a) +#define FINCSTP CHOICE(fincstp, fincstp, fincstp) +#define FINIT CHOICE(finit, wait; fninit, wait; finit) +#define FNINIT CHOICE(fninit, fninit, finit) +#define FIST_L(a) CHOICE(fistl a, fistl a, fistl a) +#define FIST_W(a) CHOICE(fist a, fists a, fists a) +#define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a) +#define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a) +#define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a) +#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */ +#define FLD_D(a) CHOICE(fldl a, fldl a, fldd a) +#define FLD_S(a) CHOICE(flds a, flds a, flds a) +#define FLD1 CHOICE(fld1, fld1, fld1) +#define FLDL2T CHOICE(fldl2t, fldl2t, fldl2t) +#define FLDL2E CHOICE(fldl2e, fldl2e, fldl2e) +#define FLDPI CHOICE(fldpi, fldpi, fldpi) +#define FLDLG2 CHOICE(fldlg2, fldlg2, fldlg2) +#define FLDLN2 CHOICE(fldln2, fldln2, fldln2) +#define FLDZ CHOICE(fldz, fldz, fldz) +#define FLDCW(a) CHOICE(fldcw a, fldcw a, fldcw a) +#define FLDENV(a) CHOICE(fldenv a, fldenv a, fldenv a) +#define FMUL_S(a) CHOICE(fmuls a, fmuls a, fmuls a) +#define FMUL_D(a) CHOICE(fmull a, fmull a, fmuld a) +#define FMUL2(a, b) CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a)) +#define FMULP(a, b) CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a)) +#define FIMUL_L(a) CHOICE(fimull a, fimull a, fimull a) +#define FIMUL_W(a) CHOICE(fimul a, fimuls a, fimuls a) +#define FNOP CHOICE(fnop, fnop, fnop) +#define FPATAN CHOICE(fpatan, fpatan, fpatan) +#define FPREM CHOICE(fprem, fprem, fprem) +#define FPREM1 CHOICE(fprem1, fprem1, fprem1) +#define FPTAN CHOICE(fptan, fptan, fptan) +#define FRNDINT CHOICE(frndint, frndint, frndint) +#define FRSTOR(a) CHOICE(frstor a, frstor a, frstor a) +#define FSAVE(a) CHOICE(fsave a, wait; fnsave a, wait; fsave a) +#define FNSAVE(a) CHOICE(fnsave a, fnsave a, fsave a) +#define FSCALE CHOICE(fscale, fscale, fscale) +#define FSIN CHOICE(fsin, fsin, fsin) +#define FSINCOS CHOICE(fsincos, fsincos, fsincos) +#define FSQRT CHOICE(fsqrt, fsqrt, fsqrt) +#define FST_D(a) CHOICE(fstl a, fstl a, fstd a) +#define FST_S(a) CHOICE(fsts a, fsts a, fsts a) +#define FSTP_X(a) CHOICE(fstpt a, fstpt a, fstpx a) +#define FSTP_D(a) CHOICE(fstpl a, fstpl a, fstpd a) +#define FSTP_S(a) CHOICE(fstps a, fstps a, fstps a) +#define FSTCW(a) CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a) +#define FNSTCW(a) CHOICE(fnstcw a, fnstcw a, fstcw a) +#define FSTENV(a) CHOICE(fstenv a, wait; fnstenv a, fstenv a) +#define FNSTENV(a) CHOICE(fnstenv a, fnstenv a, fstenv a) +#define FSTSW(a) CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a) +#define FNSTSW(a) CHOICE(fnstsw a, fnstsw a, fstsw a) +#define FSUB_S(a) CHOICE(fsubs a, fsubs a, fsubs a) +#define FSUB_D(a) CHOICE(fsubl a, fsubl a, fsubd a) +#define FSUB2(a, b) CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a)) +#define FSUBP(a, b) CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a)) +#define FISUB_L(a) CHOICE(fisubl a, fisubl a, fisubl a) +#define FISUB_W(a) CHOICE(fisub a, fisubs a, fisubs a) +#define FSUBR_S(a) CHOICE(fsubrs a, fsubrs a, fsubrs a) +#define FSUBR_D(a) CHOICE(fsubrl a, fsubrl a, fsubrd a) +#define FSUBR2(a, b) CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a)) +#define FSUBRP(a, b) CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a)) +#define FISUBR_L(a) CHOICE(fisubrl a, fisubrl a, fisubrl a) +#define FISUBR_W(a) CHOICE(fisubr a, fisubrs a, fisubrs a) +#define FTST CHOICE(ftst, ftst, ftst) +#define FUCOM(a) CHOICE(fucom a, fucom a, fucom a) +#define FUCOMP(a) CHOICE(fucomp a, fucomp a, fucomp a) +#define FUCOMPP CHOICE(fucompp, fucompp, fucompp) +#define FWAIT CHOICE(wait, wait, wait) +#define FXAM CHOICE(fxam, fxam, fxam) +#define FXCH(a) CHOICE(fxch a, fxch a, fxch a) +#define FXTRACT CHOICE(fxtract, fxtract, fxtract) +#define FYL2X CHOICE(fyl2x, fyl2x, fyl2x) +#define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1) + +#endif /* __ASSYNTAX_H__ */ diff --git a/xorg-server/hw/xfree86/os-support/bsd/Makefile.am b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am new file mode 100644 index 000000000..4fc270aa9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am @@ -0,0 +1,86 @@ +noinst_LTLIBRARIES = libbsd.la + +# FIXME: Add USB mouse support? + +# FIXME: APM support. +APM_SOURCES = $(srcdir)/../shared/pm_noop.c + +if FREEBSD_KLDLOAD +KMOD_SOURCES = bsd_kmod.c +else +KMOD_SOURCES = $(srcdir)/../shared/kmod_noop.c +endif + +# FIXME: Non-i386/ia64 resource support. +RES_SOURCES = $(srcdir)/../shared/stdResource.c + +if AGP +AGP_SOURCES = $(srcdir)/../linux/lnx_agp.c +else +AGP_SOURCES = $(srcdir)/../shared/agp_noop.c +endif + +if ALPHA_VIDEO +# Cheat here and piggyback other alpha bits on ALPHA_VIDEO. +ARCH_SOURCES = \ + alpha_video.c \ + bsd_ev56.c \ + bsd_axp.c \ + $(srcdir)/../shared/xf86Axp.c +endif + +if ARM_VIDEO +ARCH_SOURCES = arm_video.c +endif + +if I386_VIDEO +ARCH_SOURCES = i386_video.c +endif + +if PPC_VIDEO +ARCH_SOURCES = ppc_video.c +endif + +if SPARC64_VIDEO +# Cheat here and piggyback other sparc64 bits on SPARC64_VIDEO. +ARCH_SOURCES = \ + sparc64_video.c \ + $(srcdir)/../shared/ioperm_noop.c +endif + +# FIXME: NetBSD Aperture defines (configure.ac) +AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) $(DIX_CFLAGS) + +INCLUDES = $(XORG_INCS) + +libbsd_la_SOURCES = \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c \ + $(srcdir)/../shared/vidmem.c \ + bsd_VTsw.c \ + bsd_init.c \ + bsd_mouse.c \ + bsd_bell.c \ + $(ARCH_SOURCES) \ + $(AGP_SOURCES) \ + $(APM_SOURCES) \ + $(AXP_SOURCES) \ + $(DRI_SOURCES) \ + $(KMOD_SOURCES) \ + $(RES_SOURCES) + +# FIXME: Add these files to the build as needed +EXTRA_DIST = \ + bsd_apm.c \ + bsd_jstk.c \ + bsd_kqueue_apm.c \ + bsdResource.c \ + memrange.h \ + libusb/data.c \ + libusb/descr.c \ + libusb/parse.c \ + libusb/usage.c \ + libusb/usb.3 \ + libusb/usb.h \ + libusb/usb_hid_usages \ + libusb/usbvar.h diff --git a/xorg-server/hw/xfree86/os-support/bsd/Makefile.in b/xorg-server/hw/xfree86/os-support/bsd/Makefile.in new file mode 100644 index 000000000..d59e73c87 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/Makefile.in @@ -0,0 +1,822 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/bsd +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libbsd_la_LIBADD = +am__libbsd_la_SOURCES_DIST = $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c $(srcdir)/../shared/vidmem.c \ + bsd_VTsw.c bsd_init.c bsd_mouse.c bsd_bell.c alpha_video.c \ + bsd_ev56.c bsd_axp.c $(srcdir)/../shared/xf86Axp.c arm_video.c \ + i386_video.c ppc_video.c sparc64_video.c \ + $(srcdir)/../shared/ioperm_noop.c \ + $(srcdir)/../shared/agp_noop.c $(srcdir)/../linux/lnx_agp.c \ + $(srcdir)/../shared/pm_noop.c $(srcdir)/../shared/kmod_noop.c \ + bsd_kmod.c $(srcdir)/../shared/stdResource.c +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@am__objects_1 = sparc64_video.lo \ +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@ ioperm_noop.lo +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_TRUE@am__objects_1 = ppc_video.lo +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_TRUE@am__objects_1 = i386_video.lo +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_TRUE@am__objects_1 = arm_video.lo +@ALPHA_VIDEO_TRUE@am__objects_1 = alpha_video.lo bsd_ev56.lo \ +@ALPHA_VIDEO_TRUE@ bsd_axp.lo xf86Axp.lo +@AGP_FALSE@am__objects_2 = agp_noop.lo +@AGP_TRUE@am__objects_2 = lnx_agp.lo +am__objects_3 = pm_noop.lo +@FREEBSD_KLDLOAD_FALSE@am__objects_4 = kmod_noop.lo +@FREEBSD_KLDLOAD_TRUE@am__objects_4 = bsd_kmod.lo +am__objects_5 = stdResource.lo +am_libbsd_la_OBJECTS = posix_tty.lo sigio.lo vidmem.lo bsd_VTsw.lo \ + bsd_init.lo bsd_mouse.lo bsd_bell.lo $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) \ + $(am__objects_5) +libbsd_la_OBJECTS = $(am_libbsd_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libbsd_la_SOURCES) +DIST_SOURCES = $(am__libbsd_la_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LTLIBRARIES = libbsd.la + +# FIXME: Add USB mouse support? + +# FIXME: APM support. +APM_SOURCES = $(srcdir)/../shared/pm_noop.c +@FREEBSD_KLDLOAD_FALSE@KMOD_SOURCES = $(srcdir)/../shared/kmod_noop.c +@FREEBSD_KLDLOAD_TRUE@KMOD_SOURCES = bsd_kmod.c + +# FIXME: Non-i386/ia64 resource support. +RES_SOURCES = $(srcdir)/../shared/stdResource.c +@AGP_FALSE@AGP_SOURCES = $(srcdir)/../shared/agp_noop.c +@AGP_TRUE@AGP_SOURCES = $(srcdir)/../linux/lnx_agp.c + +# Cheat here and piggyback other alpha bits on ALPHA_VIDEO. +@ALPHA_VIDEO_TRUE@ARCH_SOURCES = \ +@ALPHA_VIDEO_TRUE@ alpha_video.c \ +@ALPHA_VIDEO_TRUE@ bsd_ev56.c \ +@ALPHA_VIDEO_TRUE@ bsd_axp.c \ +@ALPHA_VIDEO_TRUE@ $(srcdir)/../shared/xf86Axp.c + +@ARM_VIDEO_TRUE@ARCH_SOURCES = arm_video.c +@I386_VIDEO_TRUE@ARCH_SOURCES = i386_video.c +@PPC_VIDEO_TRUE@ARCH_SOURCES = ppc_video.c + +# Cheat here and piggyback other sparc64 bits on SPARC64_VIDEO. +@SPARC64_VIDEO_TRUE@ARCH_SOURCES = \ +@SPARC64_VIDEO_TRUE@ sparc64_video.c \ +@SPARC64_VIDEO_TRUE@ $(srcdir)/../shared/ioperm_noop.c + + +# FIXME: NetBSD Aperture defines (configure.ac) +AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) $(DIX_CFLAGS) +INCLUDES = $(XORG_INCS) +libbsd_la_SOURCES = \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c \ + $(srcdir)/../shared/vidmem.c \ + bsd_VTsw.c \ + bsd_init.c \ + bsd_mouse.c \ + bsd_bell.c \ + $(ARCH_SOURCES) \ + $(AGP_SOURCES) \ + $(APM_SOURCES) \ + $(AXP_SOURCES) \ + $(DRI_SOURCES) \ + $(KMOD_SOURCES) \ + $(RES_SOURCES) + + +# FIXME: Add these files to the build as needed +EXTRA_DIST = \ + bsd_apm.c \ + bsd_jstk.c \ + bsd_kqueue_apm.c \ + bsdResource.c \ + memrange.h \ + libusb/data.c \ + libusb/descr.c \ + libusb/parse.c \ + libusb/usage.c \ + libusb/usb.3 \ + libusb/usb.h \ + libusb/usb_hid_usages \ + libusb/usbvar.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/bsd/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/bsd/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libbsd.la: $(libbsd_la_OBJECTS) $(libbsd_la_DEPENDENCIES) + $(LINK) $(libbsd_la_OBJECTS) $(libbsd_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agp_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_VTsw.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_axp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_bell.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_ev56.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_init.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_kmod.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_mouse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioperm_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kmod_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_agp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pm_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix_tty.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigio.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparc64_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdResource.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vidmem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Axp.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +posix_tty.lo: $(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT posix_tty.lo -MD -MP -MF $(DEPDIR)/posix_tty.Tpo -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/posix_tty.Tpo $(DEPDIR)/posix_tty.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/posix_tty.c' object='posix_tty.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c + +sigio.lo: $(srcdir)/../shared/sigio.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sigio.lo -MD -MP -MF $(DEPDIR)/sigio.Tpo -c -o sigio.lo `test -f '$(srcdir)/../shared/sigio.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigio.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sigio.Tpo $(DEPDIR)/sigio.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/sigio.c' object='sigio.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sigio.lo `test -f '$(srcdir)/../shared/sigio.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigio.c + +vidmem.lo: $(srcdir)/../shared/vidmem.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT vidmem.lo -MD -MP -MF $(DEPDIR)/vidmem.Tpo -c -o vidmem.lo `test -f '$(srcdir)/../shared/vidmem.c' || echo '$(srcdir)/'`$(srcdir)/../shared/vidmem.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/vidmem.Tpo $(DEPDIR)/vidmem.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/vidmem.c' object='vidmem.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o vidmem.lo `test -f '$(srcdir)/../shared/vidmem.c' || echo '$(srcdir)/'`$(srcdir)/../shared/vidmem.c + +xf86Axp.lo: $(srcdir)/../shared/xf86Axp.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xf86Axp.lo -MD -MP -MF $(DEPDIR)/xf86Axp.Tpo -c -o xf86Axp.lo `test -f '$(srcdir)/../shared/xf86Axp.c' || echo '$(srcdir)/'`$(srcdir)/../shared/xf86Axp.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xf86Axp.Tpo $(DEPDIR)/xf86Axp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/xf86Axp.c' object='xf86Axp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xf86Axp.lo `test -f '$(srcdir)/../shared/xf86Axp.c' || echo '$(srcdir)/'`$(srcdir)/../shared/xf86Axp.c + +ioperm_noop.lo: $(srcdir)/../shared/ioperm_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ioperm_noop.lo -MD -MP -MF $(DEPDIR)/ioperm_noop.Tpo -c -o ioperm_noop.lo `test -f '$(srcdir)/../shared/ioperm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/ioperm_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ioperm_noop.Tpo $(DEPDIR)/ioperm_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/ioperm_noop.c' object='ioperm_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ioperm_noop.lo `test -f '$(srcdir)/../shared/ioperm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/ioperm_noop.c + +agp_noop.lo: $(srcdir)/../shared/agp_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT agp_noop.lo -MD -MP -MF $(DEPDIR)/agp_noop.Tpo -c -o agp_noop.lo `test -f '$(srcdir)/../shared/agp_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/agp_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/agp_noop.Tpo $(DEPDIR)/agp_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/agp_noop.c' object='agp_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o agp_noop.lo `test -f '$(srcdir)/../shared/agp_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/agp_noop.c + +lnx_agp.lo: $(srcdir)/../linux/lnx_agp.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lnx_agp.lo -MD -MP -MF $(DEPDIR)/lnx_agp.Tpo -c -o lnx_agp.lo `test -f '$(srcdir)/../linux/lnx_agp.c' || echo '$(srcdir)/'`$(srcdir)/../linux/lnx_agp.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/lnx_agp.Tpo $(DEPDIR)/lnx_agp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../linux/lnx_agp.c' object='lnx_agp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lnx_agp.lo `test -f '$(srcdir)/../linux/lnx_agp.c' || echo '$(srcdir)/'`$(srcdir)/../linux/lnx_agp.c + +pm_noop.lo: $(srcdir)/../shared/pm_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pm_noop.lo -MD -MP -MF $(DEPDIR)/pm_noop.Tpo -c -o pm_noop.lo `test -f '$(srcdir)/../shared/pm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/pm_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/pm_noop.Tpo $(DEPDIR)/pm_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/pm_noop.c' object='pm_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pm_noop.lo `test -f '$(srcdir)/../shared/pm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/pm_noop.c + +kmod_noop.lo: $(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kmod_noop.lo -MD -MP -MF $(DEPDIR)/kmod_noop.Tpo -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kmod_noop.Tpo $(DEPDIR)/kmod_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/kmod_noop.c' object='kmod_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c + +stdResource.lo: $(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdResource.lo -MD -MP -MF $(DEPDIR)/stdResource.Tpo -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/stdResource.Tpo $(DEPDIR)/stdResource.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/stdResource.c' object='stdResource.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c new file mode 100644 index 000000000..523c4488e --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c @@ -0,0 +1,732 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include <sys/param.h> +#ifndef __NetBSD__ +# include <sys/sysctl.h> +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include <machine/sysarch.h> +# endif +# else +# include <machine/sysarch.h> +#endif + +#include "xf86Axp.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#if defined(__NetBSD__) && !defined(MAP_FILE) +#define MAP_FLAGS MAP_SHARED +#else +#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + +axpDevice bsdGetAXP(void); + +#ifndef __NetBSD__ +extern unsigned long dense_base(void); + +static int axpSystem = -1; +static unsigned long hae_thresh; +static unsigned long hae_mask; +static unsigned long bus_base; +static unsigned long sparse_size; + +static unsigned long +memory_base(void) +{ + static unsigned long base = 0; + + if (base == 0) { + size_t len = sizeof(base); + int error; +#ifdef __OpenBSD__ + int mib[3]; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_CHIPSET; + mib[2] = CPU_CHIPSET_MEM; + + if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0) +#else + if ((error = sysctlbyname("hw.chipset.memory", &base, &len, + 0, 0)) < 0) +#endif + FatalError("xf86MapVidMem: can't find memory\n"); + } + + return base; +} + +static int +has_bwx(void) +{ + static int bwx = 0; + size_t len = sizeof(bwx); + int error; +#ifdef __OpenBSD__ + int mib[3]; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_CHIPSET; + mib[2] = CPU_CHIPSET_BWX; + + if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0) + return FALSE; + else + return bwx; +#else + if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0) + return FALSE; + else + return bwx; +#endif +} +#else /* __NetBSD__ */ +static unsigned long hae_thresh = (1UL << 24); +static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */ +static struct alpha_bus_window *abw; +static int abw_count = -1; + +static void +init_abw(void) +{ + if (abw_count < 0) { + abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw); + if (abw_count <= 0) + FatalError("init_abw: alpha_bus_getwindows failed\n"); + } +} + +static int +has_bwx(void) +{ + if (abw_count < 0) + init_abw(); + + xf86Msg(X_INFO, "has_bwx = %d\n", + abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */ + return abw[0].abw_abst.abst_flags & ABST_BWX; +} + +static unsigned long +dense_base(void) +{ + if (abw_count < 0) + init_abw(); + + /* XXX check abst_flags for ABST_DENSE just to be safe? */ + xf86Msg(X_INFO, "dense base = %#lx\n", + abw[0].abw_abst.abst_sys_start); /* XXXX */ + return abw[0].abw_abst.abst_sys_start; +} + +static unsigned long +memory_base(void) +{ + if (abw_count < 0) + init_abw(); + + if (abw_count > 0) { + xf86Msg(X_INFO, "memory base = %#lx\n", + abw[1].abw_abst.abst_sys_start); /* XXXX */ + return abw[1].abw_abst.abst_sys_start; + } else { + xf86Msg(X_INFO, "no memory base\n"); /* XXXX */ + return 0; + } +} +#endif /* __NetBSD__ */ + +#define BUS_BASE dense_base() +#define BUS_BASE_BWX memory_base() + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +#ifdef __OpenBSD__ +#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ + "\tin /etc/sysctl.conf and reboot your machine\n" \ + "\trefer to xf86(4) for details" +#endif + +static Bool useDevMem = FALSE; +static int devMemFd = -1; + +#ifdef HAS_APERTURE_DRV +#define DEV_APERTURE "/dev/xf86" +#endif +#define DEV_MEM "/dev/mem" + +static pointer mapVidMem(int, unsigned long, unsigned long, int); +static void unmapVidMem(int, pointer, unsigned long); +static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); +static void unmapVidMemSparse(int, pointer, unsigned long); + +/* + * Check if /dev/mem can be mmap'd. If it can't print a warning when + * "warn" is TRUE. + */ +static void +checkDevMem(Bool warn) +{ + static Bool devMemChecked = FALSE; + int fd; + pointer base; + + if (devMemChecked) + return; + devMemChecked = TRUE; + +#ifdef HAS_APERTURE_DRV + /* Try the aperture driver first */ + if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); + + if (base != MAP_FAILED) { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", + DEV_APERTURE); + return; + } else { + if (warn) { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_APERTURE, strerror(errno)); + } + } + } +#endif + if ((fd = open(DEV_MEM, O_RDWR)) >= 0) { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); + + if (base != MAP_FAILED) { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + return; + } else { + if (warn) { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + } + } + } + if (warn) { +#ifndef HAS_APERTURE_DRV + xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n", + DEV_MEM, strerror(errno)); +#else +#ifndef __OpenBSD__ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno)); +#else /* __OpenBSD__ */ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno), + SYSCTL_MSG); +#endif /* __OpenBSD__ */ +#endif + xf86ErrorF("\tlinear framebuffer access unavailable\n"); + } + useDevMem = FALSE; + return; +} + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + checkDevMem(TRUE); + pVidMem->linearSupported = useDevMem; + + if (has_bwx()) { + xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n"); + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; + } else { + xf86Msg(X_PROBED,"Machine needs sparse mapping\n"); + pVidMem->mapMem = mapVidMemSparse; + pVidMem->unmapMem = unmapVidMemSparse; +#ifndef __NetBSD__ + if (axpSystem == -1) + axpSystem = bsdGetAXP(); + hae_thresh = xf86AXPParams[axpSystem].hae_thresh; + hae_mask = xf86AXPParams[axpSystem].hae_mask; + sparse_size = xf86AXPParams[axpSystem].size; +#endif /* __NetBSD__ */ + } + pVidMem->initialised = TRUE; +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + + checkDevMem(FALSE); + Base = Base & ((1L<<32) - 1); + + if (useDevMem) + { + if (devMemFd < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); + if (base == MAP_FAILED) + { + FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n", + "xf86MapVidMem", DEV_MEM, Size, Base, + strerror(errno)); + } + return(base); + } + + /* else, mmap /dev/vga */ + if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) + { + FatalError("%s: Address 0x%lx outside allowable range\n", + "xf86MapVidMem", Base); + } + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, xf86Info.screenFd, + (unsigned long)Base + BUS_BASE); + if (base == MAP_FAILED) + { + FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", + strerror(errno)); + } + return(base); +} + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap((caddr_t)Base, Size); +} + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + unsigned char *ptr; + int psize; + int mlen; + + checkDevMem(TRUE); + if (devMemFd == -1) { + return(-1); + } + + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); + if ((long)ptr == -1) + { + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); + return(-1); + } +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", + Base, ptr[0] | (ptr[1] << 8)); +#endif + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); +#endif + return(Len); +} + + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) + +extern int ioperm(unsigned long from, unsigned long num, int on); + +_X_EXPORT Bool +xf86EnableIO() +{ + if (!ioperm(0, 65536, TRUE)) + return TRUE; + return FALSE; +} + +_X_EXPORT void +xf86DisableIO() +{ + return; +} + +#endif /* __FreeBSD_kernel__ || __OpenBSD__ */ + +#ifdef USE_ALPHA_PIO + +Bool +xf86EnableIO() +{ + alpha_pci_io_enable(1); + return TRUE; +} + +void +xf86DisableIO() +{ + alpha_pci_io_enable(0); +} + +#endif /* USE_ALPHA_PIO */ + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + return; +} + + +#define vuip volatile unsigned int * + +static unsigned long msb_set = 0; +static pointer memSBase = 0; +static pointer memBase = 0; + +extern int readDense8(pointer Base, register unsigned long Offset); +extern int readDense16(pointer Base, register unsigned long Offset); +extern int readDense32(pointer Base, register unsigned long Offset); +extern void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset); +extern void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset); +extern void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense8(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense16(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense32(int Value, pointer Base, register unsigned long Offset); + +static int readSparse8(pointer Base, register unsigned long Offset); +static int readSparse16(pointer Base, register unsigned long Offset); +static int readSparse32(pointer Base, register unsigned long Offset); +static void +writeSparseNB8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseNB16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseNB32(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse32(int Value, pointer Base, register unsigned long Offset); + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +extern int sysarch(int, void *); +#endif + +struct parms { + u_int64_t hae; +}; + +#ifndef __NetBSD__ +static int +sethae(u_int64_t hae) +{ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#ifndef ALPHA_SETHAE +#define ALPHA_SETHAE 0 +#endif + struct parms p; + p.hae = hae; + return (sysarch(ALPHA_SETHAE, (char *)&p)); +#endif +#ifdef __OpenBSD__ + return -1; +#endif +} +#endif /* __NetBSD__ */ + +static pointer +mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + static Bool was_here = FALSE; + + if (!was_here) { + was_here = TRUE; + + checkDevMem(FALSE); + + xf86WriteMmio8 = writeSparse8; + xf86WriteMmio16 = writeSparse16; + xf86WriteMmio32 = writeSparse32; + xf86WriteMmioNB8 = writeSparseNB8; + xf86WriteMmioNB16 = writeSparseNB16; + xf86WriteMmioNB32 = writeSparseNB32; + xf86ReadMmio8 = readSparse8; + xf86ReadMmio16 = readSparse16; + xf86ReadMmio32 = readSparse32; + + memBase = mmap((caddr_t)0, 0x100000000, + PROT_READ | PROT_WRITE, + MAP_SHARED, devMemFd, + (off_t) BUS_BASE); + memSBase = mmap((caddr_t)0, 0x100000000, + PROT_READ | PROT_WRITE, + MAP_SHARED, devMemFd, + (off_t) BUS_BASE_BWX); + + if (memSBase == MAP_FAILED || memBase == MAP_FAILED) { + FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n", + strerror(errno)); + } + } + return (pointer)((unsigned long)memBase + Base); +} + +static void +unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size) +{ +} + +static int +readSparse8(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + register unsigned long msb; + mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + shift = (Offset & 0x3) << 3; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + result = *(vuip) ((unsigned long)memSBase + (Offset << 5)); + result >>= shift; + return 0xffUL & result; +} + +static int +readSparse16(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + register unsigned long msb; + + mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + shift = (Offset & 0x2) << 3; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))); + result >>= shift; + return 0xffffUL & result; +} + +static int +readSparse32(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(vuip)((unsigned long)Base+(Offset)); +} + +static void +writeSparse8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int b = Value & 0xffU; + + write_mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; +} + +static void +writeSparse16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int w = Value & 0xffffU; + + write_mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = + w * 0x00010001; + +} + +static void +writeSparse32(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(vuip)((unsigned long)Base + (Offset)) = Value; + return; +} + +static void +writeSparseNB8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int b = Value & 0xffU; + + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; +} + +static void +writeSparseNB16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int w = Value & 0xffffU; + + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask ; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = + w * 0x00010001; +} + +static void +writeSparseNB32(int Value, pointer Base, register unsigned long Offset) +{ + *(vuip)((unsigned long)Base + (Offset)) = Value; + return; +} + +_X_EXPORT void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset) + = writeDense8; +_X_EXPORT void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset) + = writeDense16; +_X_EXPORT void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset) + = writeDense32; +_X_EXPORT void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB8; +_X_EXPORT void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB16; +_X_EXPORT void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB32; +_X_EXPORT int (*xf86ReadMmio8)(pointer Base, unsigned long Offset) + = readDense8; +_X_EXPORT int (*xf86ReadMmio16)(pointer Base, unsigned long Offset) + = readDense16; +_X_EXPORT int (*xf86ReadMmio32)(pointer Base, unsigned long Offset) + = readDense32; + diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c new file mode 100644 index 000000000..23948b5d6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c @@ -0,0 +1,687 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * The ARM32 code here carries the following copyright: + * + * Copyright 1997 + * Digital Equipment Corporation. All rights reserved. + * This software is furnished under license and may be used and copied only in + * accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * this software in source and/or binary form. No title or ownership is + * transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and retain + * this copyright notice and list of conditions as they appear in the + * source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of Digital + * Equipment Corporation. Neither the "Digital Equipment Corporation" + * name nor any trademark or logo of Digital Equipment Corporation may be + * used to endorse or promote products derived from this software without + * the prior written permission of Digital Equipment Corporation. + * + * 3) This software is provided "AS-IS" and any express or implied warranties, + * including but not limited to, any implied warranties of merchantability, + * fitness for a particular purpose, or non-infringement are disclaimed. + * In no event shall DIGITAL be liable for any damages whatsoever, and in + * particular, DIGITAL shall not be liable for special, indirect, + * consequential, or incidental damages or damages for lost profits, loss + * of revenue or loss of use, whether such damages arise in contract, + * negligence, tort, under statute, in equity, at law or otherwise, even + * if advised of the possibility of such damage. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifdef __arm32__ +#include "machine/devmap.h" +struct memAccess +{ + int ioctl; + struct map_info memInfo; + pointer regionVirtBase; + Bool Checked; + Bool OK; +}; + +static pointer xf86MapInfoMap(); +static void xf86MapInfoUnmap(); +static struct memAccess *checkMapInfo(); +extern int vgaPhysLinearBase; + +/* A memAccess structure is needed for each possible region */ +struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, + FALSE, FALSE }; +struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL, + FALSE, FALSE }; +struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, + FALSE, FALSE }; +#endif /* __arm32__ */ + +#if defined(__NetBSD__) && !defined(MAP_FILE) +#define MAP_FLAGS MAP_SHARED +#else +#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + + +#define BUS_BASE 0L +#define BUS_BASE_BWX 0L + + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static Bool useDevMem = FALSE; +static int devMemFd = -1; + +#define DEV_MEM "/dev/mem" + +static pointer mapVidMem(int, unsigned long, unsigned long, int); +static void unmapVidMem(int, pointer, unsigned long); + +/* + * Check if /dev/mem can be mmap'd. If it can't print a warning when + * "warn" is TRUE. + */ +static void +checkDevMem(Bool warn) +{ + static Bool devMemChecked = FALSE; + int fd; + pointer base; + + if (devMemChecked) + return; + devMemChecked = TRUE; + + if ((fd = open(DEV_MEM, O_RDWR)) >= 0) + { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); + + if (base != MAP_FAILED) + { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + return; + } else { + /* This should not happen */ + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; + } + } + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; +} + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + + checkDevMem(TRUE); + pVidMem->linearSupported = useDevMem; + pVidMem->mapMem = armMapVidMem; + pVidMem->unmapVidMem = armUnmapVidMem; + + pVidMem->initialised = TRUE; +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + + checkDevMem(FALSE); + + if (useDevMem) + { + if (devMemFd < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); + if (base == MAP_FAILED) + { + FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", DEV_MEM, Size, Base, + strerror(errno)); + } + return(base); + } + + /* else, mmap /dev/vga */ + if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) + { + FatalError("%s: Address 0x%x outside allowable range\n", + "xf86MapVidMem", Base); + } + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, xf86Info.screenFd, + (unsigned long)Base - 0xA0000); + if (base == MAP_FAILED) + { + FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", + strerror(errno)); + } + return(base); +} + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap((caddr_t)Base, Size); +} + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + unsigned char *ptr; + int psize; + int mlen; + + checkDevMem(TRUE); + if (devMemFd == -1) { + return(-1); + } + + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); + if ((long)ptr == -1) + { + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); + return(-1); + } +#ifdef DEBUG + ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", + Base, ptr[0] | (ptr[1] << 8)); +#endif + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); +#endif + return(Len); +} + + +/* XXX This needs to be updated for the ND */ + +/* +** Find out whether the console driver provides memory mapping information +** for the specified region and return the map_info pointer. Print a warning if required. +*/ +static struct memAccess * +checkMapInfo(Bool warn, int Region) +{ + struct memAccess *memAccP; + + switch (Region) + { + case VGA_REGION: + memAccP = &vgaMemInfo; + break; + + case LINEAR_REGION: + memAccP = &linearMemInfo; + break; + + case MMIO_REGION: + memAccP = &ioMemInfo; + break; + + default: + return NULL; + break; + } + + if(!memAccP->Checked) + { + if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1) + { + if(warn) + { + xf86Msg(X_WARNING, + "checkMapInfo: failed to get map info for region %d\n\t(%s)\n", + Region, strerror(errno)); + } + } + else + { + if(memAccP->memInfo.u.map_info_mmap.map_offset + != MAP_INFO_UNKNOWN) + memAccP->OK = TRUE; + } + memAccP->Checked = TRUE; + } + if (memAccP->OK) + { + return memAccP; + } + else + { + return NULL; + } +} + +static pointer +xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size) +{ + struct map_info *mapInfoP = &(memInfoP->memInfo); + + if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) + { + Size = (unsigned long)Base + Size; + } + else + { + Size = mapInfoP->u.map_info_mmap.map_size; + } + + switch(mapInfoP->method) + { + case MAP_MMAP: + /* Need to remap if size is unknown because we may not have + mapped the whole region initially */ + if(memInfoP->regionVirtBase == NULL || + mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) + { + if((memInfoP->regionVirtBase = + mmap((caddr_t)0, + Size, + PROT_READ | PROT_WRITE, + MAP_SHARED, + xf86Info.screenFd, + (unsigned long)mapInfoP->u.map_info_mmap.map_offset)) + == (pointer)-1) + { + FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n", + mapInfoP->u.map_info_mmap.map_offset, strerror(errno)); + } + if(mapInfoP->u.map_info_mmap.internal_offset > 0) + memInfoP->regionVirtBase += + mapInfoP->u.map_info_mmap.internal_offset; + } + break; + + default: + FatalError("xf86MapInfoMap: Unsuported mapping method\n"); + break; + } + + return (pointer)((int)memInfoP->regionVirtBase + (int)Base); +} + +static void +xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) +{ + struct map_info *mapInfoP = &(memInfoP->memInfo); + + switch(mapInfoP->method) + { + case MAP_MMAP: + if(memInfoP->regionVirtBase != NULL) + { + if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN) + Size = mapInfoP->u.map_info_mmap.map_size; + munmap((caddr_t)memInfoP->regionVirtBase, Size); + memInfoP->regionVirtBase = NULL; + } + break; + default: + FatalError("xf86MapInfoMap: Unsuported mapping method\n"); + break; + } +} + +static pointer +armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + struct memAccess *memInfoP; + + if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) + { + /* + ** xf86 passes in a physical address offset from the start + ** of physical memory, but xf86MapInfoMap expects an + ** offset from the start of the specified region - it gets + ** the physical address of the region from the display driver. + */ + switch(Region) + { + case LINEAR_REGION: + if (vgaPhysLinearBase) + { + Base -= vgaPhysLinearBase; + } + break; + case VGA_REGION: + Base -= 0xA0000; + break; + } + + base = xf86MapInfoMap(memInfoP, Base, Size); + return (base); + } + return mapVidMem(ScreenNum, Base, Size, flags); +} + +static void +armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + struct memAccess *memInfoP; + + if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) + { + xf86MapInfoUnmap(memInfoP, Base, Size); + } + unmapVidMem(ScreenNum, Base, Size); +} + +#ifdef USE_DEV_IO +static int IoFd = -1; + +_X_EXPORT Bool +xf86EnableIO() +{ + if (IoFd >= 0) + return TRUE; + + if ((IoFd = open("/dev/io", O_RDWR)) == -1) + { + xf86Msg(X_WARNING,"xf86EnableIO: " + "Failed to open /dev/io for extended I/O\n"); + return FALSE; + } + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + if (IoFd < 0) + return; + + close(IoFd); + IoFd = -1; + return; +} + +#endif + +#if defined(USE_ARC_MMAP) || defined(__arm32__) + +Bool +xf86EnableIO() +{ + int fd; + pointer base; + + if (ExtendedEnabled) + return TRUE; + + if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { + /* Try to map a page at the pccons I/O space */ + base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0x0000); + + if (base != (pointer)-1) { + IOPortBase = base; + } + else { + xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + return FALSE; + } + } + else { + xf86Msg("EnableIO: failed to open %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + return FALSE; + } + + ExtendedEnabled = TRUE; + + return TRUE; +} + +void +xf86DisableIO() +{ + return; +} + +#endif /* USE_ARC_MMAP */ + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + + return; +} + + + +#if 0 +/* + * XXX This is here for reference. It needs to be handled differently for the + * ND. + */ +#if defined(USE_ARC_MMAP) || defined(__arm32__) + +#ifdef USE_ARM32_MMAP +#define DEV_MEM_IOBASE 0x43000000 +#endif + +static Bool ScreenEnabled[MAXSCREENS]; +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; + +Bool +xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + int fd; + pointer base; + +#ifdef __arm32__ + struct memAccess *memInfoP; + int *Size; +#endif + + ScreenEnabled[ScreenNum] = TRUE; + + if (ExtendedEnabled) + return TRUE; + +#ifdef USE_ARC_MMAP + if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { + /* Try to map a page at the pccons I/O space */ + base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0x0000); + + if (base != (pointer)-1) { + IOPortBase = base; + } + else { + xf86Msg(X_ERROR, + "EnableIOPorts: failed to mmap %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + } + } + else { + xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + } +#endif + +#ifdef __arm32__ + IOPortBase = (unsigned int)-1; + + if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) + { + /* + * xf86MapInfoMap maps an offset from the start of video IO + * space (e.g. 0x3B0), but IOPortBase is expected to map to + * physical address 0x000, so subtract the start of video I/O + * space from the result. This is safe for now becase we + * actually mmap the start of the page, then the start of video + * I/O space is added as an internal offset. + */ + IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP, + (caddr_t)0x0, 0L) + - memInfoP->memInfo.u.map_info_mmap.internal_offset; + ExtendedEnabled = TRUE; + return TRUE; + } +#ifdef USE_ARM32_MMAP + checkDevMem(TRUE); + + if (devMemFd >= 0 && useDevMem) + { + base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE, + MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE); + + if (base != (pointer)-1) + IOPortBase = (unsigned int)base; + } + + if (IOPortBase == (unsigned int)-1) + { + xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ +Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n"); + return FALSE; + } +#else + /* We don't have the IOBASE, so we can't map the address */ + xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ +Try building the server with USE_ARM32_MMAP defined\n"); + return FALSE; +#endif +#endif + + ExtendedEnabled = TRUE; + + return TRUE; +} + +void +xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; +#ifdef __arm32__ + struct memAccess *memInfoP; +#endif + + ScreenEnabled[ScreenNum] = FALSE; + +#ifdef __arm32__ + if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) + { + xf86MapInfoUnmap(memInfoP, 0); + } +#endif + +#ifdef USE_ARM32_MMAP + if (!ExtendedEnabled) + return; + + for (i = 0; i < MAXSCREENS; i++) + if (ScreenEnabled[i]) + return; + + munmap((caddr_t)IOPortBase, 0x400); + IOPortBase = (unsigned int)-1; + ExtendedEnabled = FALSE; +#endif + + return; +} + +#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */ +#endif + + diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsdResource.c b/xorg-server/hw/xfree86/os-support/bsd/bsdResource.c new file mode 100644 index 000000000..d1ee787f1 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsdResource.c @@ -0,0 +1,92 @@ + +/* Resource information code */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Privstr.h" +#include "xf86Pci.h" +#include "xf86Resources.h" +#define NEED_OS_RAC_PROTOS +#include "xf86_OSlib.h" + +/* Avoid Imakefile changes */ +#include "bus/Pci.h" + +#ifdef INCLUDE_XF86_NO_DOMAIN + +#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__x86_64__) + +resPtr +xf86AccResFromOS(resPtr ret) +{ + resRange range; + + /* + * Fallback is to claim the following areas: + * + * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS + */ + + RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* + * Fallback would be to claim well known ports in the 0x0 - 0x3ff range + * along with their sparse I/O aliases, but that's too imprecise. Instead + * claim a bare minimum here. + */ + RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ + ret = xf86AddResToList(ret, &range, -1); + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ + RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); +/* RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); */ + RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* XXX add others */ + return ret; +} + +#elif defined(__powerpc__) + +resPtr +xf86AccResFromOS(resPtr ret) +{ + resRange range; + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ + RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + + return ret; +} + +#else + +#error : Put your platform dependent code here!! + +#endif + +#endif /* INCLUDE_XF86_NO_DOMAIN */ diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c new file mode 100644 index 000000000..476a0e957 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c @@ -0,0 +1,94 @@ +/* + * Derived from VTsw_usl.c which is + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * by S_ren Schmidt (sos@login.dkuug.dk) + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Handle the VT-switching interface for OSs that use USL-style ioctl()s + * (the bsd, sysv, sco, and linux subdirs). + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. + */ +void +xf86VTRequest(int sig) +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = TRUE; + } +#endif + return; +} + +Bool +xf86VTSwitchPending() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + return(xf86Info.vtRequestsPending ? TRUE : FALSE); + } +#endif + return FALSE; +} + +Bool +xf86VTSwitchAway() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) + return(FALSE); + else + return(TRUE); + } +#endif + return FALSE; +} + +Bool +xf86VTSwitchTo() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + return(FALSE); + else + return(TRUE); + } +#endif + return(TRUE); +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c new file mode 100644 index 000000000..43eda7421 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c @@ -0,0 +1,139 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86_OSlib.h" + +#include <machine/apmvar.h> + +#define APM_DEVICE "/dev/apm" + +static pointer APMihPtr = NULL; +static void bsdCloseAPM(void); + +static struct { + u_int apmBsd; + pmEvent xf86; +} bsdToXF86Array [] = { + { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, + { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, + { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, + { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, + { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, + { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, + { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, + { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, + { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, + { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, + { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, +#ifdef APM_CAPABILITY_CHANGE + { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, +#endif +}; + +#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0])) + +static pmEvent +bsdToXF86(int type) +{ + int i; + + for (i = 0; i < numApmEvents; i++) { + if (type == bsdToXF86Array[i].apmBsd) { + return bsdToXF86Array[i].xf86; + } + } + return XF86_APM_UNKNOWN; +} + +/* + * APM events can be requested direclty from /dev/apm + */ +static int +bsdPMGetEventFromOS(int fd, pmEvent *events, int num) +{ + struct apm_event_info bsdEvent; + int i; + + for (i = 0; i < num; i++) { + + if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) { + if (errno != EAGAIN) { + xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT" + " %s\n", strerror(errno)); + } + break; + } + events[i] = bsdToXF86(bsdEvent.type); + } + return i; +} + +/* + * XXX This won't work on /dev/apm ! + * We should either use /dev/apm_ctl (and kill apmd(8)) + * or talk to apmd (but its protocol is not publically available)... + */ +static pmWait +bsdPMConfirmEventToOs(int fd, pmEvent event) +{ + switch (event) { + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: + if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0) + return PM_WAIT; /* should we stop the Xserver in standby, too? */ + else + return PM_NONE; + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: + case XF86_APM_USER_SUSPEND: + if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0) + return PM_WAIT; + else + return PM_NONE; + case XF86_APM_STANDBY_RESUME: + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + case XF86_APM_STANDBY_FAILED: + case XF86_APM_SUSPEND_FAILED: + return PM_CONTINUE; + default: + return PM_NONE; + } +} + +PMClose +xf86OSPMOpen(void) +{ + int fd; + + if (APMihPtr || !xf86Info.pmFlag) { + return NULL; + } + + if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { + return NULL; + } + xf86PMGetEventFromOs = bsdPMGetEventFromOS; + xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; + APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL); + return bsdCloseAPM; +} + +static void +bsdCloseAPM(void) +{ + int fd; + + if (APMihPtr) { + fd = xf86RemoveInputHandler(APMihPtr); + close(fd); + APMihPtr = NULL; + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c new file mode 100644 index 000000000..51ffef148 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c @@ -0,0 +1,72 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Axp.h" +#include <sys/param.h> +#include "xf86_OSlib.h" +#include <stdio.h> +#include <sys/sysctl.h> + +axpDevice bsdGetAXP(void); + +/* + * BSD does a very nice job providing system information to + * user space programs. Unfortunately it doesn't provide all + * the information required. Therefore we just obtain the + * system type and look up the rest from a list we maintain + * ourselves. + */ + +typedef struct { + char *name; + int type; +} _AXP; + +static _AXP axpList[] = { + {"apecs",APECS}, + {"pyxis",PYXIS}, + {"cia",CIA}, + {"irongate",IRONGATE}, + {"lca",LCA}, + {"t2",T2}, + {"tsunami",TSUNAMI}, + {NULL,NONE} +}; + +axpDevice +bsdGetAXP(void) +{ + int i; + char sysname[64]; + size_t len = sizeof(sysname); + +#ifdef __OpenBSD__ + int mib[3]; + int error; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_CHIPSET; + mib[2] = CPU_CHIPSET_TYPE; + + if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0) +#else + if ((sysctlbyname("hw.chipset.type", &sysname, &len, + 0, 0)) < 0) +#endif + FatalError("bsdGetAXP: can't find machine type\n"); +#ifdef DEBUG + xf86Msg(X_INFO,"AXP is a: %s\n",sysname); +#endif + for (i=0;;i++) { + if (axpList[i].name == NULL) + return NONE; + if (!strcmp(sysname, axpList[i].name)) + return axpList[i].type; + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c new file mode 100644 index 000000000..0d2420102 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c @@ -0,0 +1,86 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Dawes <dawes@xfree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Dawes make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#if defined (SYSCONS_SUPPORT) +#include <sys/kbio.h> +#endif + +#include <termios.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifdef WSCONS_SUPPORT +#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd) +#endif + +_X_EXPORT void +xf86OSRingBell(int loudness, int pitch, int duration) +{ +#ifdef WSCONS_SUPPORT + struct wskbd_bell_data wsb; +#endif + + if (loudness && pitch) + { +#ifdef PCCONS_SUPPORT + int data[2]; +#endif + + switch (xf86Info.consType) { + +#ifdef PCCONS_SUPPORT + case PCCONS: + data[0] = pitch; + data[1] = (duration * loudness) / 50; + ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data); + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration*loudness/50)<<16)); + break; +#endif +#if defined (WSCONS_SUPPORT) + case WSCONS: + wsb.which = WSKBD_BELL_DOALL; + wsb.pitch = pitch; + wsb.period = duration; + wsb.volume = loudness; + ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL, + &wsb); + break; +#endif + } + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c new file mode 100644 index 000000000..b2141192e --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c @@ -0,0 +1,90 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +int readDense8(pointer Base, register unsigned long Offset); +int readDense16(pointer Base, register unsigned long Offset); +int readDense32(pointer Base, register unsigned long Offset); +void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset); +void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset); +void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset); +void +writeDense8(int Value, pointer Base, register unsigned long Offset); +void +writeDense16(int Value, pointer Base, register unsigned long Offset); +void +writeDense32(int Value, pointer Base, register unsigned long Offset); + +int +readDense8(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD8*) ((unsigned long)Base+(Offset)); +} + +int +readDense16(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD16*) ((unsigned long)Base+(Offset)); +} + +int +readDense32(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD32*)((unsigned long)Base+(Offset)); +} + +void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD8*)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD16*)((unsigned long)Base + (Offset)) = Value; +} + +void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD32*)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense8(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD8 *)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense16(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD16 *)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense32(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD32 *)((unsigned long)Base+(Offset)) = Value; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c new file mode 100644 index 000000000..83583d5b9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c @@ -0,0 +1,739 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include <sys/utsname.h> +#include <sys/ioctl.h> +#include <stdlib.h> +#include <errno.h> + +static Bool KeepTty = FALSE; +static int devConsoleFd = -1; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) +static int VTnum = -1; +static int initialVT = -1; +#endif + +#ifdef PCCONS_SUPPORT +/* Stock 0.1 386bsd pccons console driver interface */ +#ifndef __OpenBSD__ +# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0" +#else +# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0" +#endif +#define PCCONS_CONSOLE_DEV2 "/dev/vga" +#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#ifdef SYSCONS_SUPPORT +/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */ +#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0" +#define SYSCONS_CONSOLE_DEV2 "/dev/vga" +#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#ifdef PCVT_SUPPORT +/* Hellmuth Michaelis' pcvt driver */ +#ifndef __OpenBSD__ +# define PCVT_CONSOLE_DEV "/dev/ttyv0" +#else +# define PCVT_CONSOLE_DEV "/dev/ttyC0" +#endif +#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#if defined(WSCONS_SUPPORT) && defined(__NetBSD__) +/* NetBSD's new console driver */ +#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0" +#endif + +#ifdef __GLIBC__ +#define setpgrp setpgid +#endif + +#define CHECK_DRIVER_MSG \ + "Check your kernel's console driver configuration and /dev entries" + +static char *supported_drivers[] = { +#ifdef PCCONS_SUPPORT + "pccons (with X support)", +#endif +#ifdef SYSCONS_SUPPORT + "syscons", +#endif +#ifdef PCVT_SUPPORT + "pcvt", +#endif +#ifdef WSCONS_SUPPORT + "wscons", +#endif +}; + + +/* + * Functions to probe for the existance of a supported console driver. + * Any function returns either a valid file descriptor (driver probed + * succesfully), -1 (driver not found), or uses FatalError() if the + * driver was found but proved to not support the required mode to run + * an X server. + */ + +typedef int (*xf86ConsOpen_t)(void); + +#ifdef PCCONS_SUPPORT +static int xf86OpenPccons(void); +#endif /* PCCONS_SUPPORT */ + +#ifdef SYSCONS_SUPPORT +static int xf86OpenSyscons(void); +#endif /* SYSCONS_SUPPORT */ + +#ifdef PCVT_SUPPORT +static int xf86OpenPcvt(void); +#endif /* PCVT_SUPPORT */ + +#ifdef WSCONS_SUPPORT +static int xf86OpenWScons(void); +#endif + +/* + * The sequence of the driver probes is important; start with the + * driver that is best distinguishable, and end with the most generic + * driver. (Otherwise, pcvt would also probe as syscons, and either + * pcvt or syscons might succesfully probe as pccons.) + */ +static xf86ConsOpen_t xf86ConsTab[] = { +#ifdef PCVT_SUPPORT + xf86OpenPcvt, +#endif +#ifdef SYSCONS_SUPPORT + xf86OpenSyscons, +#endif +#ifdef PCCONS_SUPPORT + xf86OpenPccons, +#endif +#ifdef WSCONS_SUPPORT + xf86OpenWScons, +#endif + (xf86ConsOpen_t)NULL +}; + + +void +xf86OpenConsole() +{ + int i, fd = -1; + xf86ConsOpen_t *driver; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + int result; +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + struct utsname uts; +#endif + vtmode_t vtmode; +#endif + + if (serverGeneration == 1) + { + /* check if we are run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be suid root"); + } + + if (!KeepTty) + { + /* + * detaching the controlling tty solves problems of kbd character + * loss. This is not interesting for CO driver, because it is + * exclusive. + */ + setpgrp(0, getpid()); + if ((i = open("/dev/tty",O_RDWR)) >= 0) + { + ioctl(i,TIOCNOTTY,(char *)0); + close(i); + } + } + + /* detect which driver we are running on */ + for (driver = xf86ConsTab; *driver; driver++) + { + if ((fd = (*driver)()) >= 0) + break; + } + + /* Check that a supported console driver was found */ + if (fd < 0) + { + char cons_drivers[80] = {0, }; + for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++) + { + if (i) + { + strcat(cons_drivers, ", "); + } + strcat(cons_drivers, supported_drivers[i]); + } + FatalError( + "%s: No console driver found\n\tSupported drivers: %s\n\t%s", + "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG); + } +#if 0 /* stdin is already closed in OsInit() */ + fclose(stdin); +#endif + xf86Info.consoleFd = fd; + xf86Info.screenFd = fd; + + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS: + if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0) + { + FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + /* + * Hack to prevent keyboard hanging when syslogd closes + * /dev/console + */ + if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: couldn't open /dev/console (%s)\n", + strerror(errno)); + } + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt + * switching anymore. Here we check for FreeBSD 3.1 and up. + * Add cases for other *BSD that behave the same. + */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + uname (&uts); + i = atof(uts.release) * 100; + if (i >= 310) goto acquire_vt; +#endif + /* otherwise fall through */ + case PCVT: +#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000)) + /* + * First activate the #1 VT. This is a hack to allow a server + * to be started while another one is active. There should be + * a better way. + */ + if (initialVT != 1) { + + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + sleep(1); + } +#endif +acquire_vt: + /* + * now get the VT + */ + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno)); + if (result != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno)); + if (result != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + + signal(SIGUSR1, xf86VTRequest); + + vtmode.mode = VT_PROCESS; + vtmode.relsig = SIGUSR1; + vtmode.acqsig = SIGUSR1; + vtmode.frsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed"); + } +#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) + if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) + { + FatalError("xf86OpenConsole: KDENABIO failed (%s)", + strerror(errno)); + } +#endif + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + { + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed"); + } + break; +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + fprintf(stderr, "xf86OpenConsole\n"); + /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */ + break; +#endif + } + } + else + { + /* serverGeneration != 1 */ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) + { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + } +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + } + return; +} + + +#ifdef PCCONS_SUPPORT + +static int +xf86OpenPccons() +{ + int fd = -1; + + if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0)) + >= 0 || + (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0)) + >= 0) + { + if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0) + { + FatalError( + "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s", + "xf86OpenPccons", + strerror(errno), + "Was expecting pccons driver with X support", + CHECK_DRIVER_MSG); + } + xf86Info.consType = PCCONS; + xf86Msg(X_PROBED, "Using pccons driver with X support\n"); + } + return fd; +} + +#endif /* PCCONS_SUPPORT */ + +#ifdef SYSCONS_SUPPORT + +static int +xf86OpenSyscons() +{ + int fd = -1; + vtmode_t vtmode; + char vtname[12]; + struct stat status; + long syscons_version; + MessageType from; + + /* Check for syscons */ + if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0 + || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0) + { + if (ioctl(fd, VT_GETMODE, &vtmode) >= 0) + { + /* Get syscons version */ + if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0) + { + syscons_version = 0; + } + + xf86Info.vtno = VTnum; + from = X_CMDLINE; + +#ifdef VT_GETACTIVE + if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) + initialVT = -1; +#endif + if (xf86Info.vtno == -1) + { + /* + * For old syscons versions (<0x100), VT_OPENQRY returns + * the current VT rather than the next free VT. In this + * case, the server gets started on the current VT instead + * of the next free VT. + */ + +#if 0 + /* check for the fixed VT_OPENQRY */ + if (syscons_version >= 0x100) + { +#endif + if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) + { + /* No free VTs */ + xf86Info.vtno = -1; + } +#if 0 + } +#endif + + if (xf86Info.vtno == -1) + { + /* + * All VTs are in use. If initialVT was found, use it. + * Otherwise, if stdin is a VT, use that one. + * XXX stdin is already closed, so this won't work. + */ + if (initialVT != -1) + { + xf86Info.vtno = initialVT; + } + else if ((fstat(0, &status) >= 0) + && S_ISCHR(status.st_mode) + && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) + { + /* stdin is a VT */ + xf86Info.vtno = minor(status.st_rdev) + 1; + } + else + { + if (syscons_version >= 0x100) + { + FatalError("%s: Cannot find a free VT", + "xf86OpenSyscons"); + } + /* Should no longer reach here */ + FatalError("%s: %s %s\n\t%s %s", + "xf86OpenSyscons", + "syscons versions prior to 1.0 require", + "either the", + "server's stdin be a VT", + "or the use of the vtxx server option"); + } + } + from = X_PROBED; + } + + close(fd); +#ifndef __OpenBSD__ + sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1); +#else + sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1); +#endif + if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0) + { + FatalError("xf86OpenSyscons: Cannot open %s (%s)", + vtname, strerror(errno)); + } + if (ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("xf86OpenSyscons: VT_GETMODE failed"); + } + xf86Info.consType = SYSCONS; + xf86Msg(X_PROBED, "Using syscons driver with X support"); + if (syscons_version >= 0x100) + { + xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8, + syscons_version & 0xFF); + } + else + { + xf86ErrorF(" (version 0.x)\n"); + } + xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); + } + else + { + /* VT_GETMODE failed, probably not syscons */ + close(fd); + fd = -1; + } + } + return fd; +} + +#endif /* SYSCONS_SUPPORT */ + + +#ifdef PCVT_SUPPORT + +static int +xf86OpenPcvt() +{ + /* This looks much like syscons, since pcvt is API compatible */ + int fd = -1; + vtmode_t vtmode; + char vtname[12], *vtprefix; + struct stat status; + struct pcvtid pcvt_version; + +#ifndef __OpenBSD__ + vtprefix = "/dev/ttyv"; +#else + vtprefix = "/dev/ttyC"; +#endif + + fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); +#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV + if (fd < 0) + { + fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); + vtprefix = "/dev/ttyE"; + } +#endif + if (fd >= 0) + { + if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0) + { + if(ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("%s: VT_GETMODE failed\n%s%s\n%s", + "xf86OpenPcvt", + "Found pcvt driver but X11 seems to be", + " not supported.", CHECK_DRIVER_MSG); + } + + xf86Info.vtno = VTnum; + + if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) + initialVT = -1; + + if (xf86Info.vtno == -1) + { + if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) + { + /* No free VTs */ + xf86Info.vtno = -1; + } + + if (xf86Info.vtno == -1) + { + /* + * All VTs are in use. If initialVT was found, use it. + * Otherwise, if stdin is a VT, use that one. + * XXX stdin is already closed, so this won't work. + */ + if (initialVT != -1) + { + xf86Info.vtno = initialVT; + } + else if ((fstat(0, &status) >= 0) + && S_ISCHR(status.st_mode) + && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) + { + /* stdin is a VT */ + xf86Info.vtno = minor(status.st_rdev) + 1; + } + else + { + FatalError("%s: Cannot find a free VT", + "xf86OpenPcvt"); + } + } + } + + close(fd); + sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); + if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) + { + FatalError("xf86OpenPcvt: Cannot open %s (%s)", + vtname, strerror(errno)); + } + if (ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("xf86OpenPcvt: VT_GETMODE failed"); + } + xf86Info.consType = PCVT; +#ifdef WSCONS_SUPPORT + xf86Msg(X_PROBED, + "Using wscons driver in pcvt compatibility mode " + "(version %d.%d)\n", + pcvt_version.rmajor, pcvt_version.rminor); +#else + xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n", + pcvt_version.rmajor, pcvt_version.rminor); +#endif + } + else + { + /* Not pcvt */ + close(fd); + fd = -1; + } + } + return fd; +} + +#endif /* PCVT_SUPPORT */ + +#ifdef WSCONS_SUPPORT + +static int +xf86OpenWScons() +{ + int fd = -1; + int mode = WSDISPLAYIO_MODE_MAPPED; + int i; + char ttyname[16]; + + /* XXX Is this ok? */ + for (i = 0; i < 8; i++) { +#if defined(__NetBSD__) + sprintf(ttyname, "/dev/ttyE%d", i); +#elif defined(__OpenBSD__) + sprintf(ttyname, "/dev/ttyC%d", i); +#endif + if ((fd = open(ttyname, 2)) != -1) + break; + } + if (fd != -1) { + if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) { + FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + xf86Info.consType = WSCONS; + xf86Msg(X_PROBED, "Using wscons driver\n"); + } + return fd; +} + +#endif /* WSCONS_SUPPORT */ + +void +xf86CloseConsole() +{ +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + struct vt_mode VT; +#endif + + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS: + ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0); + break; +#endif /* PCCONS_SUPPORT */ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */ + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */ + } +#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) + if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) + { + xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)", + strerror(errno)); + } +#endif + if (initialVT != -1) + ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT); + break; +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + { + int mode = WSDISPLAYIO_MODE_EMUL; + ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode); + break; + } +#endif + } + + if (xf86Info.screenFd != xf86Info.consoleFd) + { + close(xf86Info.screenFd); + close(xf86Info.consoleFd); + if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0) + { + xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)", + strerror(errno)); + } + } + close(xf86Info.consoleFd); + if (devConsoleFd >= 0) + close(devConsoleFd); + return; +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0 || + VTnum < 1 || VTnum > 12) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + return(0); +} + +void +xf86UseMsg() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + ErrorF("vtXX use the specified VT number (1-12)\n"); +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c new file mode 100644 index 000000000..b5b91b0c7 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c @@ -0,0 +1,183 @@ +/* + * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> + * + * 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 Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED 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. + * + */ + +/* Modified for FreeBSD by David Dawes <dawes@XFree86.org> */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/types.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include <machine/joystick.h> +#include <fcntl.h> + +#include "misc.h" +#include "xf86.h" + +#define JS_RETURN sizeof(struct joystick) + +/*********************************************************************** + * + * xf86JoystickOn -- + * + * open the device and init timeout according to the device value. + * + *********************************************************************** + */ + +int +xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY) +{ + int status; + int changed = 0; + int timeinmicros; + struct joystick js; + +#ifdef DEBUG + ErrorF("xf86JoystickOn: %s\n", name); +#endif + + if ((status = open(name, O_RDWR | O_NDELAY, 0)) < 0) + { + xf86Msg(X_WARNING, "xf86JoystickOn: Cannot open joystick '%s' (%s)\n", + name, strerror(errno)); + return -1; + } + + if (*timeout <= 0) { + /* Use the current setting */ + ioctl(status, JOY_GETTIMEOUT, (char *)&timeinmicros); + *timeout = timeinmicros / 1000; + if (*timeout == 0) + *timeout = 1; + changed = 1; + } + /* Maximum allowed timeout in the FreeBSD driver is 10ms */ + if (*timeout > 10) { + *timeout = 10; + changed = 1; + } + + if (changed) + xf86Msg(X_PROBED, "Joystick: timeout value = %d\n", *timeout); + + timeinmicros = *timeout * 1000; + + /* Assume the joystick is centred when this is called */ + read(status, &js, JS_RETURN); + if (*centerX < 0) { + *centerX = js.x; + xf86Msg(X_PROBED, "Joystick: CenterX set to %d\n", *centerX); + } + if (*centerY < 0) { + *centerY = js.y; + xf86Msg(X_PROBED, "Joystick: CenterY set to %d\n", *centerY); + } + + return status; +} + +/*********************************************************************** + * + * xf86JoystickInit -- + * + * called when X device is initialized. + * + *********************************************************************** + */ + +void +xf86JoystickInit() +{ + return; +} + +/*********************************************************************** + * + * xf86JoystickOff -- + * + * close the handle. + * + *********************************************************************** + */ + +int +xf86JoystickOff(int *fd, int doclose) +{ + int oldfd; + + if (((oldfd = *fd) >= 0) && doclose) { + close(*fd); + *fd = -1; + } + return oldfd; +} + +/*********************************************************************** + * + * xf86JoystickGetState -- + * + * return the state of buttons and the position of the joystick. + * + *********************************************************************** + */ + +int +xf86JoystickGetState(int fd, int *x, int *y, int *buttons) +{ + struct joystick js; + int status; + + status = read(fd, &js, JS_RETURN); + + if (status != JS_RETURN) + { + Error("Joystick read"); + return 0; + } + + *x = js.x; + *y = js.y; + *buttons = js.b1 | (js.b2 << 1); +#ifdef DEBUG + ErrorF("xf86JoystickGetState: x = %d, y = %d, buttons = %d\n", *x, *y, + *buttons); +#endif + + return 1; +} + +/* + * Entry point for XFree86 Loader + */ +void +bsd_jstkModuleInit(pointer *data, INT32 *magic) +{ + *magic = MAGIC_DONE; + *data = NULL; +} +/* end of bsd_jstk.c */ diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c new file mode 100644 index 000000000..b6c755852 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c @@ -0,0 +1,28 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/param.h> +#include <sys/linker.h> + +#include "xf86_OSproc.h" + +/* + * Load a FreeBSD kernel module. + * This is used by the DRI/DRM to load a DRM kernel module when + * the X server starts. It could be used for other purposes in the future. + * Input: + * modName - name of the kernel module (Ex: "tdfx") + * Return: + * 0 for failure, 1 for success + */ +_X_EXPORT int xf86LoadKernelModule(const char *modName) +{ + if (kldload(modName) != -1) + return 1; + else + return 0; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c new file mode 100644 index 000000000..b37070c37 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from the XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86_OSlib.h" + +#include <sys/event.h> +#include <machine/apmvar.h> + +#define _PATH_APM_SOCKET "/var/run/apmdev" +#define _PATH_APM_DEV "/dev/apm" +#define _PATH_APM_CTLDEV "/dev/apmctl" + +static pointer APMihPtr = NULL; +static int devFd = -1; +static int ctlFd = -1; +static void bsdCloseAPM(void); + +static struct { + u_int apmBsd; + pmEvent xf86; +} bsdToXF86Array [] = { + { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, + { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, + { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, + { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, + { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, + { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, + { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, + { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, + { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, + { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, + { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, +#ifdef APM_CAPABILITY_CHANGE + { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, +#endif +}; + +#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0])) + +static pmEvent +bsdToXF86(int type) +{ + int i; + + for (i = 0; i < numApmEvents; i++) { + if (type == bsdToXF86Array[i].apmBsd) { + return bsdToXF86Array[i].xf86; + } + } + return XF86_APM_UNKNOWN; +} + +/* + * APM events can be requested direclty from /dev/apm + */ +static int +bsdPMGetEventFromOS(int kq, pmEvent *events, int num) +{ + struct kevent ev; + int i, result; + struct timespec ts = { 0, 0 }; + + for (i = 0; i < num; i++) { + result = kevent(kq, NULL, 0, &ev, 1, &ts); + if (result == 0 || APM_EVENT_TYPE(ev.data) == APM_NOEVENT) { + /* no event */ + break; + } else if (result < 0) { + xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns" + " %s\n", strerror(errno)); + break; + } + events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data)); + } + return i; +} + +/* + * If apmd(8) is running, he will get the events and handle them, + * so, we've nothing to do here. + * Otherwise, opening /dev/apmctl will succeed and we have to send the + * confirmations to /dev/apmctl. + */ +static pmWait +bsdPMConfirmEventToOs(int dummyfd, pmEvent event) +{ + if (ctlFd < 0) { + if ((ctlFd = open(_PATH_APM_CTLDEV, O_RDWR)) < 0) { + return PM_NONE; + } + } + /* apmctl open succeedeed */ + switch (event) { + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: + if (ioctl( ctlFd, APM_IOC_STANDBY, NULL ) == 0) + return PM_WAIT; /* should we stop the Xserver in standby, too? */ + else + return PM_NONE; + + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: + case XF86_APM_USER_SUSPEND: + if (ioctl( ctlFd, APM_IOC_SUSPEND, NULL ) == 0) + return PM_WAIT; + else + return PM_NONE; + break; + case XF86_APM_STANDBY_RESUME: + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + case XF86_APM_STANDBY_FAILED: + case XF86_APM_SUSPEND_FAILED: + return PM_CONTINUE; + break; + default: + return PM_NONE; + } +} + +PMClose +xf86OSPMOpen(void) +{ + int kq; + struct kevent ev; + + if (APMihPtr || !xf86Info.pmFlag) { + return NULL; + } + if ((devFd = open(_PATH_APM_DEV, O_RDONLY)) == -1) { + return NULL; + } + if ((kq = kqueue()) <= 0) { + close(devFd); + return NULL; + } + EV_SET(&ev, devFd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR, + 0, 0, NULL); + if (kevent(kq, &ev, 1, NULL, 0, NULL) < 0) { + close(devFd); + return NULL; + } + + xf86PMGetEventFromOs = bsdPMGetEventFromOS; + xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; + APMihPtr = xf86AddInputHandler(kq, xf86HandlePMEvents, NULL); + return bsdCloseAPM; +} + +static void +bsdCloseAPM(void) +{ + int kq; + + if (APMihPtr) { + kq = xf86RemoveInputHandler(APMihPtr); + close(devFd); + devFd = -1; + close(kq); + if (ctlFd >= 0) { + close(ctlFd); + ctlFd = -1; + } + APMihPtr = NULL; + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c new file mode 100644 index 000000000..ca2c1bbd5 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c @@ -0,0 +1,791 @@ + +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" +#include "xisb.h" +#include "mipointer.h" +#ifdef WSCONS_SUPPORT +#include <dev/wscons/wsconsio.h> +#endif +#ifdef USBMOUSE_SUPPORT +#ifdef HAS_LIB_USB_HID +#include <usbhid.h> +#else +#include "usb.h" +#endif + +#include <dev/usb/usb.h> +#ifdef USB_GET_REPORT_ID +#define USB_NEW_HID +#endif + +#define HUP_GENERIC_DESKTOP 0x0001 +#define HUP_BUTTON 0x0009 + +#define HUG_X 0x0030 +#define HUG_Y 0x0031 +#define HUG_Z 0x0032 +#define HUG_WHEEL 0x0038 + +#define HID_USAGE2(p,u) (((p) << 16) | u) + +/* The UMS mices have middle button as number 3 */ +#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i)) +#endif /* USBMOUSE_SUPPORT */ + +#ifdef USBMOUSE_SUPPORT +static void usbSigioReadInput (int fd, void *closure); +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +/* These are for FreeBSD and DragonFly */ +#define DEFAULT_MOUSE_DEV "/dev/mouse" +#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse" +#define DEFAULT_PS2_DEV "/dev/psm0" + +static const char *mouseDevs[] = { + DEFAULT_MOUSE_DEV, + DEFAULT_SYSMOUSE_DEV, + DEFAULT_PS2_DEV, + NULL +}; +#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) +/* Only wsmouse mices are autoconfigured for now on OpenBSD */ +#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse" +#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0" + +static const char *mouseDevs[] = { + DEFAULT_WSMOUSE_DEV, + DEFAULT_WSMOUSE0_DEV, + NULL +}; +#endif + +static int +SupportedInterfaces(void) +{ +#if defined(__NetBSD__) + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO; +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC; +#else + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; +#endif +} + +/* Names of protocols that are handled internally here. */ +static const char *internalNames[] = { +#if defined(WSCONS_SUPPORT) + "WSMouse", +#endif +#if defined(USBMOUSE_SUPPORT) + "usb", +#endif + NULL +}; + +/* + * Names of MSC_MISC protocols that the OS supports. These are decoded by + * main "mouse" driver. + */ +static const char *miscNames[] = { +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + "SysMouse", +#endif + NULL +}; + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + for (i = 0; miscNames[i]; i++) + if (xf86NameCmp(protocol, miscNames[i]) == 0) + return TRUE; + return FALSE; +} + +static const char * +DefaultProtocol(void) +{ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + return "Auto"; +#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) + return "WSMouse"; +#else + return NULL; +#endif +} + +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE) +static struct { + int dproto; + const char *name; +} devproto[] = { + { MOUSE_PROTO_MS, "Microsoft" }, + { MOUSE_PROTO_MSC, "MouseSystems" }, + { MOUSE_PROTO_LOGI, "Logitech" }, + { MOUSE_PROTO_MM, "MMSeries" }, + { MOUSE_PROTO_LOGIMOUSEMAN, "MouseMan" }, + { MOUSE_PROTO_BUS, "BusMouse" }, + { MOUSE_PROTO_INPORT, "BusMouse" }, + { MOUSE_PROTO_PS2, "PS/2" }, + { MOUSE_PROTO_HITTAB, "MMHitTab" }, + { MOUSE_PROTO_GLIDEPOINT, "GlidePoint" }, + { MOUSE_PROTO_INTELLI, "Intellimouse" }, + { MOUSE_PROTO_THINK, "ThinkingMouse" }, + { MOUSE_PROTO_SYSMOUSE, "SysMouse" } +}; + +static const char * +SetupAuto(InputInfoPtr pInfo, int *protoPara) +{ + int i; + mousehw_t hw; + mousemode_t mode; + + if (pInfo->fd == -1) + return NULL; + + /* set the driver operation level, if applicable */ + i = 1; + ioctl(pInfo->fd, MOUSE_SETLEVEL, &i); + + /* interrogate the driver and get some intelligence on the device. */ + hw.iftype = MOUSE_IF_UNKNOWN; + hw.model = MOUSE_MODEL_GENERIC; + ioctl(pInfo->fd, MOUSE_GETHWINFO, &hw); + xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: hw.iftype is %d, hw.model is %d\n", + pInfo->name, hw.iftype, hw.model); + if (ioctl(pInfo->fd, MOUSE_GETMODE, &mode) == 0) { + for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); ++i) { + if (mode.protocol == devproto[i].dproto) { + /* override some parameters */ + if (protoPara) { + protoPara[4] = mode.packetsize; + protoPara[0] = mode.syncmask[0]; + protoPara[1] = mode.syncmask[1]; + } + xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n", + pInfo->name, devproto[i].name); + return devproto[i].name; + } + } + } + return NULL; +} + +static void +SetSysMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res) +{ + mousemode_t mode; + MouseDevPtr pMse; + + pMse = pInfo->private; + + mode.rate = rate > 0 ? rate : -1; + mode.resolution = res > 0 ? res : -1; + mode.accelfactor = -1; +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + if (pMse->autoProbe || + (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) { + /* + * As the FreeBSD sysmouse driver defaults to protocol level 0 + * everytime it is opened we enforce protocol level 1 again at + * this point. + */ + mode.level = 1; + } else + mode.level = -1; +#else + mode.level = -1; +#endif + ioctl(pInfo->fd, MOUSE_SETMODE, &mode); +} +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + +#define MOUSED_PID_FILE "/var/run/moused.pid" + +/* + * Try to check if moused is running. DEFAULT_SYSMOUSE_DEV is useless without + * it. There doesn't seem to be a better way of checking. + */ +static Bool +MousedRunning(void) +{ + FILE *f = NULL; + unsigned int pid; + + if ((f = fopen(MOUSED_PID_FILE, "r")) != NULL) { + if (fscanf(f, "%u", &pid) == 1 && pid > 0) { + if (kill(pid, 0) == 0) { + fclose(f); + return TRUE; + } + } + fclose(f); + } + return FALSE; +} + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + int fd = -1; + const char **pdev, *dev = NULL; + Bool devMouse = FALSE; + struct stat devMouseStat; + struct stat sb; + + for (pdev = mouseDevs; *pdev; pdev++) { + SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK)); + if (fd == -1) { +#ifdef DEBUG + ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno)); +#endif + } else { + /* + * /dev/mouse is held until checks for matches with other devices + * are done. This is so that when it points to /dev/sysmouse, + * the test for whether /dev/sysmouse is usable can be made. + */ + if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) { + if (fstat(fd, &devMouseStat) == 0) + devMouse = TRUE; + close(fd); + continue; + } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) { + /* Check if /dev/mouse is the same as /dev/sysmouse. */ + if (devMouse && fstat(fd, &sb) == 0 && + devMouseStat.st_dev == sb.st_dev && + devMouseStat.st_ino == sb.st_ino) { + /* If the same, use /dev/sysmouse. */ + devMouse = FALSE; + } + close(fd); + if (MousedRunning()) + break; + else { +#ifdef DEBUG + ErrorF("moused isn't running\n"); +#endif + } + } else { + close(fd); + break; + } + } + } + + if (*pdev) + dev = *pdev; + else if (devMouse) + dev = DEFAULT_MOUSE_DEV; + + if (dev) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", dev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, dev); + } + + return *pdev; +} +#endif + +#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) + +/* Only support wsmouse configuration for now */ +static const char * +SetupAuto(InputInfoPtr pInfo, int *protoPara) +{ + + xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n", + pInfo->name, "wsmouse"); + return "wsmouse"; +} + +static void +SetMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res) +{ + + xf86MsgVerb(X_INFO, 3, "%s: SetMouseRes: protocol %s rate %d res %d\n", + pInfo->name, protocol, rate, res); +} + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + int fd = -1; + const char **pdev; + + for (pdev = mouseDevs; *pdev; pdev++) { + SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK)); + if (fd != -1) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, + "Device", *pdev); + xf86Msg(X_INFO, "%s: found Device \"%s\"\n", + pInfo->name, *pdev); + close(fd); + break; + } + } + return *pdev; +} +#endif /* __OpenBSD__ || __NetBSD__ && WSCONS_SUPPORT */ + +#ifdef WSCONS_SUPPORT +#define NUMEVENTS 64 + +static void +wsconsReadInput(InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + static struct wscons_event eventList[NUMEVENTS]; + int n, c; + struct wscons_event *event = eventList; + unsigned char *pBuf; + + pMse = pInfo->private; + + XisbBlockDuration(pMse->buffer, -1); + pBuf = (unsigned char *)eventList; + n = 0; + while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0) { + pBuf[n++] = (unsigned char)c; + } + + if (n == 0) + return; + + n /= sizeof(struct wscons_event); + while( n-- ) { + int buttons = pMse->lastButtons; + int dx = 0, dy = 0, dz = 0, dw = 0; + switch (event->type) { + case WSCONS_EVENT_MOUSE_UP: +#define BUTBIT (1 << (event->value <= 2 ? 2 - event->value : event->value)) + buttons &= ~BUTBIT; + break; + case WSCONS_EVENT_MOUSE_DOWN: + buttons |= BUTBIT; + break; + case WSCONS_EVENT_MOUSE_DELTA_X: + dx = event->value; + break; + case WSCONS_EVENT_MOUSE_DELTA_Y: + dy = -event->value; + break; +#ifdef WSCONS_EVENT_MOUSE_DELTA_Z + case WSCONS_EVENT_MOUSE_DELTA_Z: + dz = event->value; + break; +#endif + default: + xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name, + event->type); + ++event; + continue; + } + + pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); + ++event; + } + return; +} + + +/* This function is called when the protocol is "wsmouse". */ +static Bool +wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse = pInfo->private; + + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pMse); + return FALSE; + } + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local input proc. */ + pInfo->read_input = wsconsReadInput; + pMse->xisbscale = sizeof(struct wscons_event); + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} +#endif + +#if defined(USBMOUSE_SUPPORT) + +typedef struct _UsbMseRec { + int packetSize; + int iid; + hid_item_t loc_x; /* x locator item */ + hid_item_t loc_y; /* y locator item */ + hid_item_t loc_z; /* z (wheel) locator item */ + hid_item_t loc_btn[MSE_MAXBUTTONS]; /* buttons locator items */ + unsigned char *buffer; +} UsbMseRec, *UsbMsePtr; + +static int +usbMouseProc(DeviceIntPtr pPointer, int what) +{ + InputInfoPtr pInfo; + MouseDevPtr pMse; + UsbMsePtr pUsbMse; + unsigned char map[MSE_MAXBUTTONS + 1]; + int nbuttons; + + pInfo = pPointer->public.devicePrivate; + pMse = pInfo->private; + pMse->device = pPointer; + pUsbMse = pMse->mousePriv; + + switch (what) { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons) + map[nbuttons + 1] = nbuttons + 1; + + InitPointerDeviceStruct((DevicePtr)pPointer, + map, + min(pMse->buttons, MSE_MAXBUTTONS), + miPointerGetMotionEvents, + pMse->Ctrl, + miPointerGetMotionBufferSize()); + + /* X valuator */ + xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 0); + /* Y valuator */ + xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 1); + xf86MotionHistoryAllocate(pInfo); + break; + + case DEVICE_ON: + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize); + if (!pMse->buffer) { + xfree(pMse); + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } else { + xf86FlushInput(pInfo->fd); + if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput, + pInfo)) + AddEnabledDevice(pInfo->fd); + } + } + pMse->lastButtons = 0; + pMse->lastMappedButtons = 0; + pMse->emulateState = 0; + pPointer->public.on = TRUE; + break; + + case DEVICE_OFF: + case DEVICE_CLOSE: + if (pInfo->fd != -1) { + RemoveEnabledDevice(pInfo->fd); + if (pUsbMse->packetSize > 8 && pUsbMse->buffer) { + xfree(pUsbMse->buffer); + } + if (pMse->buffer) { + XisbFree(pMse->buffer); + pMse->buffer = NULL; + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } + pPointer->public.on = FALSE; + usleep(300000); + break; + } + return Success; +} + +static void +usbReadInput(InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + UsbMsePtr pUsbMse; + int buttons = pMse->lastButtons; + int dx = 0, dy = 0, dz = 0, dw = 0; + int n, c; + unsigned char *pBuf; + + pMse = pInfo->private; + pUsbMse = pMse->mousePriv; + + XisbBlockDuration(pMse->buffer, -1); + pBuf = pUsbMse->buffer; + n = 0; + while ((c = XisbRead(pMse->buffer)) >= 0 && n < pUsbMse->packetSize) { + pBuf[n++] = (unsigned char)c; + } + if (n == 0) + return; + if (n != pUsbMse->packetSize) { + xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", pInfo->name, + n); + } + /* discard packets with an id that don't match the mouse */ + /* XXX this is probably not the right thing */ + if (pUsbMse->iid != 0) { + if (*pBuf++ != pUsbMse->iid) + return; + } + dx = hid_get_data(pBuf, &pUsbMse->loc_x); + dy = hid_get_data(pBuf, &pUsbMse->loc_y); + dz = hid_get_data(pBuf, &pUsbMse->loc_z); + + buttons = 0; + for (n = 0; n < pMse->buttons; n++) { + if (hid_get_data(pBuf, &pUsbMse->loc_btn[n])) + buttons |= (1 << UMS_BUT(n)); + } + pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); + return; +} + +static void +usbSigioReadInput (int fd, void *closure) +{ + usbReadInput ((InputInfoPtr) closure); +} + +/* This function is called when the protocol is "usb". */ +static Bool +usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse = pInfo->private; + UsbMsePtr pUsbMse; + report_desc_t reportDesc; + int i; + + pUsbMse = xalloc(sizeof(UsbMseRec)); + if (pUsbMse == NULL) { + xf86Msg(X_ERROR, "%s: cannot allocate UsbMouseRec\n", pInfo->name); + xfree(pMse); + return FALSE; + } + + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pUsbMse); + xfree(pMse); + return FALSE; + } + } + /* Get USB informations */ + reportDesc = hid_get_report_desc(pInfo->fd); + /* Get packet size & iid */ +#ifdef USB_NEW_HID + if (ioctl(pInfo->fd, USB_GET_REPORT_ID, &pUsbMse->iid) == -1) { + xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n", + pInfo->name, strerror(errno)); + return FALSE; + } + pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, + pUsbMse->iid); +#else + pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, + &pUsbMse->iid); +#endif + /* Allocate buffer */ + if (pUsbMse->packetSize <= 8) { + pUsbMse->buffer = pMse->protoBuf; + } else { + pUsbMse->buffer = xalloc(pUsbMse->packetSize); + } + if (pUsbMse->buffer == NULL) { + xf86Msg(X_ERROR, "%s: cannot allocate buffer\n", pInfo->name); + xfree(pUsbMse); + xfree(pMse); + xf86CloseSerial(pInfo->fd); + return FALSE; + } +#ifdef USB_NEW_HID + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), + hid_input, &pUsbMse->loc_x, pUsbMse->iid) < 0) { + xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), + hid_input, &pUsbMse->loc_y, pUsbMse->iid) < 0) { + xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), + hid_input, &pUsbMse->loc_z, pUsbMse->iid) < 0) { + } +#else + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), + hid_input, &pUsbMse->loc_x) < 0) { + xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), + hid_input, &pUsbMse->loc_y) < 0) { + xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), + hid_input, &pUsbMse->loc_z) < 0) { + } +#endif + /* Probe for number of buttons */ + for (i = 1; i <= MSE_MAXBUTTONS; i++) { + if (!hid_locate(reportDesc, HID_USAGE2(HUP_BUTTON, i), + hid_input, &pUsbMse->loc_btn[i-1] +#ifdef USB_NEW_HID + , pUsbMse->iid +#endif + )) + break; + } + pMse->buttons = i-1; + + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Private structure */ + pMse->mousePriv = pUsbMse; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pInfo->device_control = usbMouseProc; + pInfo->read_input = usbReadInput; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} +#endif /* USBMOUSE */ + +static Bool +bsdMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + /* The protocol is guaranteed to be one of the internalNames[] */ +#ifdef WSCONS_SUPPORT + if (xf86NameCmp(protocol, "WSMouse") == 0) { + return wsconsPreInit(pInfo, protocol, flags); + } +#endif +#ifdef USBMOUSE_SUPPORT + if (xf86NameCmp(protocol, "usb") == 0) { + return usbPreInit(pInfo, protocol, flags); + } +#endif + return TRUE; +} + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; + p->BuiltinNames = BuiltinNames; + p->DefaultProtocol = DefaultProtocol; + p->CheckProtocol = CheckProtocol; +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE) + p->SetupAuto = SetupAuto; + p->SetPS2Res = SetSysMouseRes; + p->SetBMRes = SetSysMouseRes; + p->SetMiscRes = SetSysMouseRes; +#endif +#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) + p->SetupAuto = SetupAuto; + p->SetMiscRes = SetMouseRes; +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__) + p->FindDevice = FindDevice; +#endif + p->PreInit = bsdMousePreInit; + return p; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c new file mode 100644 index 000000000..e2f6420d8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c @@ -0,0 +1,1006 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include <errno.h> +#include <sys/mman.h> + +#ifdef HAS_MTRR_SUPPORT +#ifndef __NetBSD__ +#include <sys/types.h> +#include <sys/memrange.h> +#else +#include "memrange.h" +#endif +#define X_MTRR_ID "XFree86" +#endif + +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) +#include <machine/mtrr.h> +#include <machine/sysarch.h> +#include <sys/queue.h> +#ifdef __x86_64__ +#define i386_set_mtrr x86_64_set_mtrr +#define i386_get_mtrr x86_64_get_mtrr +#define i386_iopl x86_64_iopl +#endif +#endif + +#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__)) +#include <machine/mtrr.h> +#include <machine/sysarch.h> +#endif + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#if defined(__NetBSD__) && !defined(MAP_FILE) +#define MAP_FLAGS MAP_SHARED +#else +#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + +#ifdef __OpenBSD__ +#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ + "\tin /etc/sysctl.conf and reboot your machine\n" \ + "\trefer to xf86(4) for details" +#define SYSCTL_MSG2 \ + "Check that you have set 'machdep.allowaperture=2'\n" \ + "\tin /etc/sysctl.conf and reboot your machine\n" \ + "\trefer to xf86(4) for details" +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static Bool useDevMem = FALSE; +static int devMemFd = -1; + +#ifdef HAS_APERTURE_DRV +#define DEV_APERTURE "/dev/xf86" +#endif +#define DEV_MEM "/dev/mem" + +static pointer mapVidMem(int, unsigned long, unsigned long, int); +static void unmapVidMem(int, pointer, unsigned long); + +#ifdef HAS_MTRR_SUPPORT +static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); +static void undoWC(int, pointer); +static Bool cleanMTRR(void); +#endif +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) +static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool, + MessageType); +static void NetBSDundoWC(int, pointer); +#endif +#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__) +static pointer amd64setWC(int, unsigned long, unsigned long, Bool, + MessageType); +static void amd64undoWC(int, pointer); +#endif + +/* + * Check if /dev/mem can be mmap'd. If it can't print a warning when + * "warn" is TRUE. + */ +static void +checkDevMem(Bool warn) +{ + static Bool devMemChecked = FALSE; + int fd; + pointer base; + + if (devMemChecked) + return; + devMemChecked = TRUE; + + if ((fd = open(DEV_MEM, O_RDWR)) >= 0) + { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000); + + if (base != MAP_FAILED) + { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + return; + } else { + /* This should not happen */ + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; + } + } +#ifndef HAS_APERTURE_DRV + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; +#else + /* Failed to open /dev/mem, try the aperture driver */ + if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) + { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000); + + if (base != MAP_FAILED) + { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", + DEV_APERTURE); + return; + } else { + + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_APERTURE, strerror(errno)); + } + } + } else { + if (warn) + { +#ifndef __OpenBSD__ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno)); +#else /* __OpenBSD__ */ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno), + SYSCTL_MSG); +#endif /* __OpenBSD__ */ + } + } + + useDevMem = FALSE; + return; + +#endif +} + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + checkDevMem(TRUE); + pVidMem->linearSupported = useDevMem; + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; + +#if HAVE_PCI_SYSTEM_INIT_DEV_MEM + if (useDevMem) + pci_system_init_dev_mem(devMemFd); +#endif + +#ifdef HAS_MTRR_SUPPORT + if (useDevMem) { + if (cleanMTRR()) { + pVidMem->setWC = setWC; + pVidMem->undoWC = undoWC; + } + } +#endif +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) + pVidMem->setWC = NetBSDsetWC; + pVidMem->undoWC = NetBSDundoWC; +#endif +#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__) + pVidMem->setWC = amd64setWC; + pVidMem->undoWC = amd64undoWC; +#endif + pVidMem->initialised = TRUE; +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + + checkDevMem(FALSE); + + if (useDevMem) + { + if (devMemFd < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, devMemFd, (off_t)Base); + if (base == MAP_FAILED) + { + FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)", + "xf86MapVidMem", DEV_MEM, Size, Base, + strerror(errno)); + } + return(base); + } + + /* else, mmap /dev/vga */ + if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) + { + FatalError("%s: Address 0x%lx outside allowable range", + "xf86MapVidMem", Base); + } + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, xf86Info.screenFd, + (unsigned long)Base - 0xA0000 + ); + if (base == MAP_FAILED) + { + FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)", + strerror(errno)); + } + return(base); +} + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap((caddr_t)Base, Size); +} + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + unsigned char *ptr; + int psize; + int mlen; + + checkDevMem(TRUE); + if (devMemFd == -1) { + return(-1); + } + + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, devMemFd, (off_t)Base); + if ((long)ptr == -1) + { + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); +#ifdef __OpenBSD__ + if (Base < 0xa0000) { + xf86Msg(X_WARNING, SYSCTL_MSG2); + } +#endif + return(-1); + } +#ifdef DEBUG + ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", + Base, ptr[0] | (ptr[1] << 8)); +#endif + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); +#endif + return(Len); +} + +#ifdef USE_I386_IOPL +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; + +_X_EXPORT Bool +xf86EnableIO() +{ + if (ExtendedEnabled) + return TRUE; + + if (i386_iopl(TRUE) < 0) + { +#ifndef __OpenBSD__ + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O", + "xf86EnableIO"); +#else + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s", + "xf86EnableIO", SYSCTL_MSG); +#endif + return FALSE; + } + ExtendedEnabled = TRUE; + + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + i386_iopl(FALSE); + ExtendedEnabled = FALSE; + + return; +} + +#endif /* USE_I386_IOPL */ + +#ifdef USE_AMD64_IOPL +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; + +Bool +xf86EnableIO() +{ + if (ExtendedEnabled) + return TRUE; + + if (amd64_iopl(TRUE) < 0) + { +#ifndef __OpenBSD__ + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O", + "xf86EnableIO"); +#else + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s", + "xf86EnableIO", SYSCTL_MSG); +#endif + return FALSE; + } + ExtendedEnabled = TRUE; + + return TRUE; +} + +void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + if (amd64_iopl(FALSE) == 0) { + ExtendedEnabled = FALSE; + } + /* Otherwise, the X server has revoqued its root uid, + and thus cannot give up IO privileges any more */ + + return; +} + +#endif /* USE_AMD64_IOPL */ + +#ifdef USE_DEV_IO +static int IoFd = -1; + +Bool +xf86EnableIO() +{ + if (IoFd >= 0) + return TRUE; + + if ((IoFd = open("/dev/io", O_RDWR)) == -1) + { + xf86Msg(X_WARNING,"xf86EnableIO: " + "Failed to open /dev/io for extended I/O"); + return FALSE; + } + return TRUE; +} + +void +xf86DisableIO() +{ + if (IoFd < 0) + return; + + close(IoFd); + IoFd = -1; + return; +} + +#endif + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + return; +} + + +#ifdef __NetBSD__ +/***************************************************************************/ +/* Set TV output mode */ +/***************************************************************************/ +void +xf86SetTVOut(int mode) +{ + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS:{ + + if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_ON, &mode) < 0) + { + xf86Msg(X_WARNING, + "xf86SetTVOut: Could not set console to TV output, %s\n", + strerror(errno)); + } + } + break; +#endif /* PCCONS_SUPPORT */ + + default: + FatalError("Xf86SetTVOut: Unsupported console"); + break; + } + return; +} + +void +xf86SetRGBOut() +{ + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS:{ + + if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_OFF, 0) < 0) + { + xf86Msg(X_WARNING, + "xf86SetTVOut: Could not set console to RGB output, %s\n", + strerror(errno)); + } + } + break; +#endif /* PCCONS_SUPPORT */ + + default: + FatalError("Xf86SetTVOut: Unsupported console"); + break; + } + return; +} +#endif + +#ifdef HAS_MTRR_SUPPORT +/* memory range (MTRR) support for FreeBSD */ + +/* + * This code is experimental. Some parts may be overkill, and other parts + * may be incomplete. + */ + +/* + * getAllRanges returns the full list of memory ranges with attributes set. + */ + +static struct mem_range_desc * +getAllRanges(int *nmr) +{ + struct mem_range_desc *mrd; + struct mem_range_op mro; + + /* + * Find how many ranges there are. If this fails, then the kernel + * probably doesn't have MTRR support. + */ + mro.mo_arg[0] = 0; + if (ioctl(devMemFd, MEMRANGE_GET, &mro)) + return NULL; + *nmr = mro.mo_arg[0]; + mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc)); + mro.mo_arg[0] = *nmr; + mro.mo_desc = mrd; + if (ioctl(devMemFd, MEMRANGE_GET, &mro)) { + xfree(mrd); + return NULL; + } + return mrd; +} + +/* + * cleanMTRR removes any memory attribute that may be left by a previous + * X server. Normally there won't be any, but this takes care of the + * case where a server crashed without being able finish cleaning up. + */ + +static Bool +cleanMTRR() +{ + struct mem_range_desc *mrd; + struct mem_range_op mro; + int nmr, i; + + /* This shouldn't happen */ + if (devMemFd < 0) + return FALSE; + + if (!(mrd = getAllRanges(&nmr))) + return FALSE; + + for (i = 0; i < nmr; i++) { + if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 && + (mrd[i].mr_flags & MDF_ACTIVE)) { +#ifdef DEBUG + ErrorF("Clean for (0x%lx,0x%lx)\n", + (unsigned long)mrd[i].mr_base, + (unsigned long)mrd[i].mr_len); +#endif + if (mrd[i].mr_flags & MDF_FIXACTIVE) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + mrd[i].mr_flags = MDF_UNCACHEABLE; + } else { + mro.mo_arg[0] = MEMRANGE_SET_REMOVE; + } + mro.mo_desc = mrd + i; + ioctl(devMemFd, MEMRANGE_SET, &mro); + } + } +#ifdef DEBUG + sleep(10); +#endif + xfree(mrd); + return TRUE; +} + +typedef struct x_RangeRec { + struct mem_range_desc mrd; + Bool wasWC; + struct x_RangeRec * next; +} RangeRec, *RangePtr; + +static void +freeRangeList(RangePtr range) +{ + RangePtr rp; + + while (range) { + rp = range; + range = rp->next; + xfree(rp); + } +} + +static RangePtr +dupRangeList(RangePtr list) +{ + RangePtr new = NULL, rp, p; + + rp = list; + while (rp) { + p = xnfalloc(sizeof(RangeRec)); + *p = *rp; + p->next = new; + new = p; + rp = rp->next; + } + return new; +} + +static RangePtr +sortRangeList(RangePtr list) +{ + RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev; + unsigned long minBase; + + /* Sort by base address */ + rp1 = copy = dupRangeList(list); + while (rp1) { + minBase = rp1->mrd.mr_base; + minp = rp1; + minprev = NULL; + prev = rp1; + rp2 = rp1->next; + while (rp2) { + if (rp2->mrd.mr_base < minBase) { + minBase = rp2->mrd.mr_base; + minp = rp2; + minprev = prev; + } + prev = rp2; + rp2 = rp2->next; + } + if (minprev) { + minprev->next = minp->next; + rp1 = copy; + } else { + rp1 = minp->next; + } + minp->next = sorted; + sorted = minp; + } + return sorted; +} + +/* + * findRanges returns a list of ranges that overlap the specified range. + */ + +static void +findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp) +{ + struct mem_range_desc *mrd; + int nmr, i; + RangePtr rp, *p; + + if (!(mrd = getAllRanges(&nmr))) + return; + + for (i = 0; i < nmr; i++) { + if ((mrd[i].mr_flags & MDF_ACTIVE) && + mrd[i].mr_base < base + size && + mrd[i].mr_base + mrd[i].mr_len > base) { + if (mrd[i].mr_flags & MDF_WRITECOMBINE) + p = wcp; + else if (mrd[i].mr_flags & MDF_UNCACHEABLE) + p = ucp; + else + continue; + rp = xnfalloc(sizeof(RangeRec)); + rp->mrd = mrd[i]; + rp->next = *p; + *p = rp; + } + } + xfree(mrd); +} + +/* + * This checks if the existing overlapping ranges fully cover the requested + * range. Is this overkill? + */ + +static Bool +fullCoverage(unsigned long base, unsigned long size, RangePtr overlap) +{ + RangePtr rp1, sorted = NULL; + unsigned long end; + + sorted = sortRangeList(overlap); + /* Look for gaps */ + rp1 = sorted; + end = base + size; + while (rp1) { + if (rp1->mrd.mr_base > base) { + freeRangeList(sorted); + return FALSE; + } else { + base = rp1->mrd.mr_base + rp1->mrd.mr_len; + } + if (base >= end) { + freeRangeList(sorted); + return TRUE; + } + rp1 = rp1->next; + } + freeRangeList(sorted); + return FALSE; +} + +static pointer +addWC(int screenNum, unsigned long base, unsigned long size, MessageType from) +{ + RangePtr uc = NULL, wc = NULL, retlist = NULL; + struct mem_range_desc mrd; + struct mem_range_op mro; + + findRanges(base, size, &uc, &wc); + + /* See of the full range is already WC */ + if (!uc && fullCoverage(base, size, wc)) { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx) was already set\n", + base, size); + return NULL; + } + + /* Otherwise, try to add the new range */ + mrd.mr_base = base; + mrd.mr_len = size; + strcpy(mrd.mr_owner, X_MTRR_ID); + mrd.mr_flags = MDF_WRITECOMBINE; + mro.mo_desc = &mrd; + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to set write-combining range " + "(0x%lx,0x%lx)\n", base, size); + return NULL; + } else { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx)\n", base, size); + retlist = xnfalloc(sizeof(RangeRec)); + retlist->mrd = mrd; + retlist->wasWC = FALSE; + retlist->next = NULL; + return retlist; + } +} + +static pointer +delWC(int screenNum, unsigned long base, unsigned long size, MessageType from) +{ + RangePtr uc = NULL, wc = NULL, retlist = NULL; + struct mem_range_desc mrd; + struct mem_range_op mro; + + findRanges(base, size, &uc, &wc); + + /* + * See of the full range is already not WC, or if there is full + * coverage from UC ranges. + */ + if (!wc || fullCoverage(base, size, uc)) { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx) was already clear\n", + base, size); + return NULL; + } + + /* Otherwise, try to add the new range */ + mrd.mr_base = base; + mrd.mr_len = size; + strcpy(mrd.mr_owner, X_MTRR_ID); + mrd.mr_flags = MDF_UNCACHEABLE; + mro.mo_desc = &mrd; + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to remove write-combining range " + "(0x%lx,0x%lx)\n", base, size); + /* XXX Should then remove all of the overlapping WC ranges */ + return NULL; + } else { + xf86DrvMsg(screenNum, from, + "Removed Write-combining range (0x%lx,0x%lx)\n", + base, size); + retlist = xnfalloc(sizeof(RangeRec)); + retlist->mrd = mrd; + retlist->wasWC = TRUE; + retlist->next = NULL; + return retlist; + } +} + +static pointer +setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + if (enable) + return addWC(screenNum, base, size, from); + else + return delWC(screenNum, base, size, from); +} + +static void +undoWC(int screenNum, pointer list) +{ + RangePtr rp; + struct mem_range_op mro; + Bool failed; + + rp = list; + while (rp) { +#ifdef DEBUG + ErrorF("Undo for (0x%lx,0x%lx), %d\n", + (unsigned long)rp->mrd.mr_base, + (unsigned long)rp->mrd.mr_len, rp->wasWC); +#endif + failed = FALSE; + if (rp->wasWC) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + rp->mrd.mr_flags = MDF_WRITECOMBINE; + strcpy(rp->mrd.mr_owner, "unknown"); + } else { + mro.mo_arg[0] = MEMRANGE_SET_REMOVE; + } + mro.mo_desc = &rp->mrd; + + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + if (!rp->wasWC) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + rp->mrd.mr_flags = MDF_UNCACHEABLE; + strcpy(rp->mrd.mr_owner, "unknown"); + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) + failed = TRUE; + } else + failed = TRUE; + } + if (failed) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to restore MTRR range (0x%lx,0x%lx)\n", + (unsigned long)rp->mrd.mr_base, + (unsigned long)rp->mrd.mr_len); + } + rp = rp->next; + } +} + +#endif /* HAS_MTRR_SUPPORT */ + + +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) +static pointer +NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + struct mtrr *mtrrp; + int n; + + xf86DrvMsg(screenNum, X_WARNING, + "%s MTRR %lx - %lx\n", enable ? "set" : "remove", + base, (base + size)); + + mtrrp = xnfalloc(sizeof (struct mtrr)); + mtrrp->base = base; + mtrrp->len = size; + mtrrp->type = MTRR_TYPE_WC; + + /* + * MTRR_PRIVATE will make this MTRR get reset automatically + * if this process exits, so we have no need for an explicit + * cleanup operation when starting a new server. + */ + + if (enable) + mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; + else + mtrrp->flags = 0; + n = 1; + + if (i386_set_mtrr(mtrrp, &n) < 0) { + xfree(mtrrp); + return NULL; + } + return mtrrp; +} + +static void +NetBSDundoWC(int screenNum, pointer list) +{ + struct mtrr *mtrrp = (struct mtrr *)list; + int n; + + if (mtrrp == NULL) + return; + n = 1; + mtrrp->flags &= ~MTRR_VALID; + i386_set_mtrr(mtrrp, &n); + xfree(mtrrp); +} +#endif + +#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__)) +static pointer +amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + struct mtrr *mtrrp; + int n; + + xf86DrvMsg(screenNum, X_WARNING, + "%s MTRR %lx - %lx\n", enable ? "set" : "remove", + base, (base + size)); + + mtrrp = xnfalloc(sizeof (struct mtrr)); + mtrrp->base = base; + mtrrp->len = size; + mtrrp->type = MTRR_TYPE_WC; + + /* + * MTRR_PRIVATE will make this MTRR get reset automatically + * if this process exits, so we have no need for an explicit + * cleanup operation when starting a new server. + */ + + if (enable) + mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; + else + mtrrp->flags = 0; + n = 1; + + if (amd64_set_mtrr(mtrrp, &n) < 0) { + xfree(mtrrp); + return NULL; + } + return mtrrp; +} + +static void +amd64undoWC(int screenNum, pointer list) +{ + struct mtrr *mtrrp = (struct mtrr *)list; + int n; + + if (mtrrp == NULL) + return; + n = 1; + mtrrp->flags &= ~MTRR_VALID; + amd64_set_mtrr(mtrrp, &n); + xfree(mtrrp); +} +#endif /* OpenBSD/amd64 */ + diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/data.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/data.c new file mode 100644 index 000000000..292e5d885 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/data.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <assert.h> +#include <stdlib.h> +#include "usb.h" + +int +hid_get_data(void *p, hid_item_t *h) +{ + unsigned char *buf; + unsigned int hpos; + unsigned int hsize; + int data; + int i, end, offs; + + _DIAGASSERT(p != NULL); + _DIAGASSERT(h != NULL); + + buf = p; + hpos = h->pos; /* bit position of data */ + hsize = h->report_size; /* bit length of data */ + + if (hsize == 0) + return (0); + offs = hpos / 8; + end = (hpos + hsize) / 8 - offs; + data = 0; + for (i = 0; i <= end; i++) + data |= buf[offs + i] << (i*8); + data >>= hpos % 8; + data &= (1 << hsize) - 1; + if (h->logical_minimum < 0) { + /* Need to sign extend */ + hsize = sizeof data * 8 - hsize; + data = (data << hsize) >> hsize; + } + return (data); +} + +void +hid_set_data(void *p, hid_item_t *h, int data) +{ + unsigned char *buf; + unsigned int hpos; + unsigned int hsize; + int i, end, offs; + + _DIAGASSERT(p != NULL); + _DIAGASSERT(h != NULL); + + buf = p; + hpos = h->pos; /* bit position of data */ + hsize = h->report_size; /* bit length of data */ + + if (hsize != 32) + data &= (1 << hsize) - 1; + data <<= (hpos % 8); + + offs = hpos / 8; + end = (hpos + hsize) / 8 - offs; + data = 0; + for (i = 0; i <= end; i++) + buf[offs + i] |= (data >> (i*8)) & 0xff; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/descr.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/descr.c new file mode 100644 index 000000000..4dc3524d5 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/descr.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/types.h> + +#include <assert.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/time.h> + +#include <dev/usb/usb.h> + +#include "usb.h" +#include "usbvar.h" + +report_desc_t +hid_get_report_desc(fd) + int fd; +{ + struct usb_ctl_report_desc rep; + report_desc_t r; + + _DIAGASSERT(fd != -1); + + rep.size = 0; + if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0) + return (0); + r = malloc(sizeof *r + rep.size); + if (r == 0) { + errno = ENOMEM; + return (0); + } + r->size = rep.size; + memcpy(r->data, rep.data, (unsigned int)rep.size); + return (r); +} + +void +hid_dispose_report_desc(r) + report_desc_t r; +{ + + free(r); +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/parse.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/parse.c new file mode 100644 index 000000000..0a846e42b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/parse.c @@ -0,0 +1,401 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <assert.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> + +#include <dev/usb/usb.h> +#include <dev/usb/usbhid.h> + +#include "usb.h" +#include "usbvar.h" + +#define MAXUSAGE 100 +struct hid_data { + u_char *start; + u_char *end; + u_char *p; + hid_item_t cur; + unsigned int usages[MAXUSAGE]; + int nusage; + int minset; + int multi; + int multimax; + int kindset; +}; + +static int min(int x, int y) { return x < y ? x : y; } + +static void +hid_clear_local(hid_item_t *c) +{ + + _DIAGASSERT(c != NULL); + + c->usage = 0; + c->usage_minimum = 0; + c->usage_maximum = 0; + c->designator_index = 0; + c->designator_minimum = 0; + c->designator_maximum = 0; + c->string_index = 0; + c->string_minimum = 0; + c->string_maximum = 0; + c->set_delimiter = 0; +} + +hid_data_t +hid_start_parse(report_desc_t d, int kindset) +{ + struct hid_data *s; + + _DIAGASSERT(d != NULL); + + s = malloc(sizeof *s); + memset(s, 0, sizeof *s); + s->start = s->p = d->data; + s->end = d->data + d->size; + s->kindset = kindset; + return (s); +} + +void +hid_end_parse(hid_data_t s) +{ + + _DIAGASSERT(s != NULL); + + while (s->cur.next) { + hid_item_t *hi = s->cur.next->next; + free(s->cur.next); + s->cur.next = hi; + } + free(s); +} + +int +hid_get_item(hid_data_t s, hid_item_t *h) +{ + hid_item_t *c; + unsigned int bTag = 0, bType = 0, bSize; + unsigned char *data; + int dval; + unsigned char *p; + hid_item_t *hi; + int i; + + _DIAGASSERT(s != NULL); + _DIAGASSERT(h != NULL); + + c = &s->cur; + + top: + if (s->multimax) { + if (s->multi < s->multimax) { + c->usage = s->usages[min(s->multi, s->nusage-1)]; + s->multi++; + *h = *c; + c->pos += c->report_size; + h->next = 0; + return (1); + } else { + c->report_count = s->multimax; + s->multimax = 0; + s->nusage = 0; + hid_clear_local(c); + } + } + for (;;) { + p = s->p; + if (p >= s->end) + return (0); + + bSize = *p++; + if (bSize == 0xfe) { + /* long item */ + bSize = *p++; + bSize |= *p++ << 8; + bTag = *p++; + data = p; + p += bSize; + } else { + /* short item */ + bTag = bSize >> 4; + bType = (bSize >> 2) & 3; + bSize &= 3; + if (bSize == 3) bSize = 4; + data = p; + p += bSize; + } + s->p = p; + /* + * The spec is unclear if the data is signed or unsigned. + */ + switch(bSize) { + case 0: + dval = 0; + break; + case 1: + dval = (int8_t)*data++; + break; + case 2: + dval = *data++; + dval |= *data++ << 8; + dval = (int16_t)dval; + break; + case 4: + dval = *data++; + dval |= *data++ << 8; + dval |= *data++ << 16; + dval |= *data++ << 24; + break; + default: + return (-1); + } + + switch (bType) { + case 0: /* Main */ + switch (bTag) { + case 8: /* Input */ + if (!(s->kindset & (1 << hid_input))) + continue; + c->kind = hid_input; + c->flags = dval; + ret: + if (c->flags & HIO_VARIABLE) { + s->multimax = c->report_count; + s->multi = 0; + c->report_count = 1; + if (s->minset) { + for (i = c->usage_minimum; + i <= c->usage_maximum; + i++) { + s->usages[s->nusage] = i; + if (s->nusage < MAXUSAGE-1) + s->nusage++; + } + s->minset = 0; + } + goto top; + } else { + if (s->minset) + c->usage = c->usage_minimum; + *h = *c; + h->next = 0; + c->pos += c->report_size * c->report_count; + hid_clear_local(c); + s->minset = 0; + return (1); + } + case 9: /* Output */ + if (!(s->kindset & (1 << hid_output))) + continue; + c->kind = hid_output; + c->flags = dval; + goto ret; + case 10: /* Collection */ + c->kind = hid_collection; + c->collection = dval; + c->collevel++; + *h = *c; + hid_clear_local(c); + s->nusage = 0; + return (1); + case 11: /* Feature */ + if (!(s->kindset & (1 << hid_feature))) + continue; + c->kind = hid_feature; + c->flags = dval; + goto ret; + case 12: /* End collection */ + c->kind = hid_endcollection; + c->collevel--; + *h = *c; + hid_clear_local(c); + s->nusage = 0; + return (1); + default: + return (-2); + } + + case 1: /* Global */ + switch (bTag) { + case 0: + c->_usage_page = dval << 16; + break; + case 1: + c->logical_minimum = dval; + break; + case 2: + c->logical_maximum = dval; + break; + case 3: + c->physical_maximum = dval; + break; + case 4: + c->physical_maximum = dval; + break; + case 5: + c->unit_exponent = dval; + break; + case 6: + c->unit = dval; + break; + case 7: + c->report_size = dval; + break; + case 8: + c->report_ID = dval; + break; + case 9: + c->report_count = dval; + break; + case 10: /* Push */ + hi = malloc(sizeof *hi); + *hi = s->cur; + c->next = hi; + break; + case 11: /* Pop */ + hi = c->next; + s->cur = *hi; + free(hi); + break; + default: + return (-3); + } + break; + case 2: /* Local */ + switch (bTag) { + case 0: + if (bSize == 1) + dval = c->_usage_page | (dval&0xff); + else if (bSize == 2) + dval = c->_usage_page | (dval&0xffff); + c->usage = dval; + if (s->nusage < MAXUSAGE) + s->usages[s->nusage++] = dval; + /* else XXX */ + break; + case 1: + s->minset = 1; + if (bSize == 1) + dval = c->_usage_page | (dval&0xff); + else if (bSize == 2) + dval = c->_usage_page | (dval&0xffff); + c->usage_minimum = dval; + break; + case 2: + if (bSize == 1) + dval = c->_usage_page | (dval&0xff); + else if (bSize == 2) + dval = c->_usage_page | (dval&0xffff); + c->usage_maximum = dval; + break; + case 3: + c->designator_index = dval; + break; + case 4: + c->designator_minimum = dval; + break; + case 5: + c->designator_maximum = dval; + break; + case 7: + c->string_index = dval; + break; + case 8: + c->string_minimum = dval; + break; + case 9: + c->string_maximum = dval; + break; + case 10: + c->set_delimiter = dval; + break; + default: + return (-4); + } + break; + default: + return (-5); + } + } +} + +int +hid_report_size(report_desc_t r, enum hid_kind k, int *idp) +{ + struct hid_data *d; + hid_item_t h; + int size, id; + + _DIAGASSERT(r != NULL); + /* idp may be NULL */ + + id = 0; + if (idp) + *idp = 0; + memset(&h, 0, sizeof h); + for (d = hid_start_parse(r, 1<<k); hid_get_item(d, &h); ) { + if (h.report_ID != 0) { + if (idp) + *idp = h.report_ID; + id = 8; + } + } + hid_end_parse(d); + size = h.pos + id; + return ((size + 7) / 8); +} + +int +hid_locate(desc, u, k, h) + report_desc_t desc; + unsigned int u; + enum hid_kind k; + hid_item_t *h; +{ + hid_data_t d; + + _DIAGASSERT(desc != NULL); + _DIAGASSERT(h != NULL); + + for (d = hid_start_parse(desc, 1<<k); hid_get_item(d, h); ) { + if (h->kind == k && !(h->flags & HIO_CONST) && h->usage == u) { + hid_end_parse(d); + return (1); + } + } + hid_end_parse(d); + h->report_size = 0; + return (0); +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usage.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/usage.c new file mode 100644 index 000000000..9b491c57a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usage.c @@ -0,0 +1,196 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <ctype.h> +#include <err.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "usb.h" + +#define _PATH_HIDTABLE "/usr/share/misc/usb_hid_usages" + +struct usage_in_page { + char *name; + int usage; +}; + +static struct usage_page { + char *name; + int usage; + struct usage_in_page *page_contents; + int pagesize, pagesizemax; +} *pages; +static int npages, npagesmax; + +#ifdef DEBUG +void +dump_hid_table(void) +{ + int i, j; + + for (i = 0; i < npages; i++) { + printf("%d\t%s\n", pages[i].usage, pages[i].name); + for (j = 0; j < pages[i].pagesize; j++) { + printf("\t%d\t%s\n", pages[i].page_contents[j].usage, + pages[i].page_contents[j].name); + } + } +} +#endif + +void +hid_init(char *hidname) +{ + FILE *f; + char line[100], name[100], *p, *n; + int no; + int lineno; + struct usage_page *curpage = 0; + + if (hidname == 0) + hidname = _PATH_HIDTABLE; + + f = fopen(hidname, "r"); + if (f == NULL) + err(1, "%s", hidname); + for (lineno = 1; ; lineno++) { + if (fgets(line, sizeof line, f) == NULL) + break; + if (line[0] == '#') + continue; + for (p = line; *p && isspace(*p); p++) + ; + if (!*p) + continue; + if (sscanf(line, " * %[^\n]", name) == 1) + no = -1; + else if (sscanf(line, " 0x%x %[^\n]", &no, name) != 2 && + sscanf(line, " %d %[^\n]", &no, name) != 2) + errx(1, "file %s, line %d, syntax error\n", + hidname, lineno); + for (p = name; *p; p++) + if (isspace(*p) || *p == '.') + *p = '_'; + n = strdup(name); + if (!n) + err(1, "strdup"); + if (isspace(line[0])) { + if (!curpage) + errx(1, "file %s, line %d, syntax error\n", + hidname, lineno); + if (curpage->pagesize >= curpage->pagesizemax) { + curpage->pagesizemax += 10; + curpage->page_contents = + realloc(curpage->page_contents, + curpage->pagesizemax * + sizeof (struct usage_in_page)); + if (!curpage->page_contents) + err(1, "realloc"); + } + curpage->page_contents[curpage->pagesize].name = n; + curpage->page_contents[curpage->pagesize].usage = no; + curpage->pagesize++; + } else { + if (npages >= npagesmax) { + if (pages == 0) { + npagesmax = 5; + pages = malloc(npagesmax * + sizeof (struct usage_page)); + } else { + npagesmax += 5; + pages = realloc(pages, + npagesmax * + sizeof (struct usage_page)); + } + if (!pages) + err(1, "alloc"); + } + curpage = &pages[npages++]; + curpage->name = n; + curpage->usage = no; + curpage->pagesize = 0; + curpage->pagesizemax = 10; + curpage->page_contents = + malloc(curpage->pagesizemax * + sizeof (struct usage_in_page)); + if (!curpage->page_contents) + err(1, "malloc"); + } + } + fclose(f); +#ifdef DEBUG + dump_hid_table(); +#endif +} + +char * +hid_usage_page(int i) +{ + static char b[10]; + int k; + + if (!pages) + errx(1, "no hid table\n"); + + for (k = 0; k < npages; k++) + if (pages[k].usage == i) + return pages[k].name; + sprintf(b, "0x%02x", i); + return b; +} + +char * +hid_usage_in_page(unsigned int u) +{ + int page = HID_PAGE(u); + int i = HID_USAGE(u); + static char b[100]; + int j, k, us; + + for (k = 0; k < npages; k++) + if (pages[k].usage == page) + break; + if (k >= npages) + goto bad; + for (j = 0; j < pages[k].pagesize; j++) { + us = pages[k].page_contents[j].usage; + if (us == -1) { + sprintf(b, pages[k].page_contents[j].name, i); + return b; + } + if (us == i) + return pages[k].page_contents[j].name; + } + bad: + sprintf(b, "0x%02x", i); + return b; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 new file mode 100644 index 000000000..f88a28cd6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 @@ -0,0 +1,191 @@ +.\" $NetBSD: usb.3,v 1.9 1999/11/08 22:33:40 augustss Exp $ +.\" +.\" Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3,v 1.1 2000/02/11 18:06:50 dawes Exp $ +.\" +.Dd May 11, 1999 +.Dt USB 3 +.Os +.Sh NAME +.Nm usb , +.Nm hid_get_report_desc , +.Nm hid_dispose_report_desc , +.Nm hid_start_parse , +.Nm hid_end_parse , +.Nm hid_get_item , +.Nm hid_report_size , +.Nm hid_locate , +.Nm hid_usage_page , +.Nm hid_usage_in_page , +.Nm hid_init , +.Nm hid_get_data , +.Nm hid_set_data +.Nd USB HID access routines +.Sh LIBRARY +.Lb libusb +.Sh SYNOPSIS +.Fd #include <usb.h> +.Ft report_desc_t +.Fn hid_get_report_desc "int file" +.Ft void +.Fn hid_dispose_report_desc "report_desc_t d" +.Ft hid_data_t +.Fn hid_start_parse "report_desc_t d" "int kindset" +.Ft void +.Fn hid_end_parse "hid_data_t s" +.Ft int +.Fn hid_get_item "hid_data_t s" "hid_item_t *h" +.Ft int +.Fn hid_report_size "report_desc_t d" "hid_kind_t k" "int *idp" +.Ft int +.Fn hid_locate "report_desc_t d" "u_int usage" "hid_kind_t k" "hid_item_t *h" +.Ft char * +.Fn hid_usage_page "int i" +.Ft char * +.Fn hid_usage_in_page "u_int u" +.Ft void +.Fn hid_init "char *file" +.Ft int +.Fn hid_get_data "void *data" "hid_item_t *h" +.Ft void +.Fn hid_set_data "void *data" "hid_item_t *h" "u_int data" +.Sh DESCRIPTION +The +.Nm +library provides routines to extract data from USB Human Interface Devices. +.Ss INTRODUCTION +USB HID devices send and receive data layed out a device dependent +way. The +.Nm +library contains routines to extract the +.Em report descriptor +which contains the data layout information and then use this information. +.Pp +The routines can be divided into four parts: extraction of the descriptor, +parsing of the descriptor, translating to/from symbolic names, and +data manipulation. +.Ss DESCRIPTOR FUNCTIONS +A report descriptor can be obtained by calling +.Fn hid_get_report_desc +with a file descriptor obtained by opening a +.Xr uhid 4 +device. +When the report descriptor is no longer needed it should be freed +by calling +.Fn hid_dispose_report_desc . +The type +.Fa report_desc_t +is opaque and should be used when calling the parsing functions. +.Ss DESCRIPTOR PARSING FUNCTIONS +To parse the report descriptor the +.Fn hid_start_parse +function should be called with a report descriptor and a set that +describes which items that are interesting. The set is obtained +by oring together values +.Fa "(1 << k)" +where +.Fa k +is an item of type +.Fa hid_kind_t . +The function returns +.Fa NULL +if the initialization fails, otherwise an opaque value to be used +in subsequent calls. +After parsing the +.Fn hid_end_parse +function should be called to free internal data structures. +.Pp +To iterate through all the items in the report descriptor +.Fn hid_get_item +should be called while it returns a value greater than 0. +When the report descriptor ends it will returns 0; a syntax +error within the report descriptor will cause a return value less +than 0. +The struct pointed to by +.Fa h +will be filled with the relevant data for the item. +The definition of +.Fa hid_item_t +can be found in +.Pa <usb.h> +and the meaning of the components in the USB HID documentation. +.Pp +Data should be read/written to the device in the size of +the report. The size of a report (of a certain kind) can be +computed by the +.Fn hid_report_size +function. If the report is prefixed by an ID byte it is +stored at +.Fa idp , +otherwise it will contain 0. +.Pp +To locate a single item the +.Fn hid_locate +function can be used. It should be given the usage code of +the item and its kind and it will fill the item and return +non-zero if the item was found. +.Pp +.Ss NAME TRANSLATION FUNCTIONS +The function +.Fn hid_usage_page +will return the symbolic name of a usage page, and the function +.Fn hid_usage_in_page +will return the symbolic name of the usage within the page. +Both these functions may return a pointer to static data. +Before either of these functions can be called the usage table +must be parsed, this is done by calling +.Fn hid_init +with the name of the table. Passing +.Fa NULL +to this function will cause it to use the default table. +.Ss DATA EXTRACTION FUNCTIONS +Given the data obtained from a HID device and an item in the +report descriptor the +.Fn hid_get_data +function extracts the value of the item. +Conversely +.Fn hid_set_data +can be used to put data into a report (which must be zeroed first). +.Sh EXAMPLE +Not yet. +.Sh FILES +.Pa /usr/share/misc/usb_hid_usages +The default HID usage table. +.Sh BUGS +This man page is woefully incomplete. +.Sh SEE ALSO +The +.Tn USB +specifications can be found at +.Dv http://www.usb.org/developers/docs.htm . +.Pp +.Xr hid 4 , +.Xr usb 4 . +.Sh HISTORY +The +.Nm +library first appeared in +.Nx 1.5 . diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h new file mode 100644 index 000000000..c39dc063a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define _DIAGASSERT(e) assert(e) + +typedef struct report_desc *report_desc_t; + +typedef struct hid_data *hid_data_t; + +typedef enum hid_kind { + hid_input, hid_output, hid_feature, hid_collection, hid_endcollection +}hid_kind_t; + +typedef struct hid_item { + /* Global */ + int _usage_page; + int logical_minimum; + int logical_maximum; + int physical_minimum; + int physical_maximum; + int unit_exponent; + int unit; + int report_size; + int report_ID; + int report_count; + /* Local */ + unsigned int usage; + int usage_minimum; + int usage_maximum; + int designator_index; + int designator_minimum; + int designator_maximum; + int string_index; + int string_minimum; + int string_maximum; + int set_delimiter; + /* Misc */ + int collection; + int collevel; + enum hid_kind kind; + unsigned int flags; + /* Absolute data position (bits) */ + unsigned int pos; + /* */ + struct hid_item *next; +} hid_item_t; + +#define HID_PAGE(u) ((u) >> 16) +#define HID_USAGE(u) ((u) & 0xffff) + +/* Obtaining a report descriptor, descr.c: */ +report_desc_t hid_get_report_desc __P((int file)); +void hid_dispose_report_desc __P((report_desc_t)); + +/* Parsing of a HID report descriptor, parse.c: */ +hid_data_t hid_start_parse __P((report_desc_t d, int kindset)); +void hid_end_parse __P((hid_data_t s)); +int hid_get_item __P((hid_data_t s, hid_item_t *h)); +int hid_report_size __P((report_desc_t d, enum hid_kind k, int *idp)); +int hid_locate __P((report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h)); + +/* Conversion to/from usage names, usage.c: */ +char *hid_usage_page __P((int i)); +char *hid_usage_in_page __P((unsigned int u)); +void hid_init __P((char *file)); + +/* Extracting/insertion of data, data.c: */ +int hid_get_data __P((void *p, hid_item_t *h)); +void hid_set_data __P((void *p, hid_item_t *h, int data)); diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usb_hid_usages b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb_hid_usages new file mode 100644 index 000000000..02f122028 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb_hid_usages @@ -0,0 +1,1079 @@ +# $NetBSD: usb_hid_usages,v 1.3 1999/07/02 15:46:53 simonb Exp $ +# +# USB HID usage table +# Syntax: +# - lines that do not start with a white space give the number and name of +# a usage page. +# - lines that start with a white space give the number and name of +# a usage with the last given page. +# If the number is * then the line matches all usages and the name +# is a printf formatting string that will be given the usage number. +# +# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usb_hid_usages,v 1.1.2.2 1999/12/03 10:12:43 hohndel Exp $ +# +1 Generic Desktop + 0x00 Undefined + 0x01 Pointer + 0x02 Mouse + 0x03 Reserved + 0x04 Joystick + 0x05 Game Pad + 0x06 Keyboard + 0x07 Keypad + 0x08 Multi-axis Controller + 0x30 X + 0x31 Y + 0x32 Z + 0x33 Rx + 0x34 Ry + 0x35 Rz + 0x36 Slider + 0x37 Dial + 0x38 Wheel + 0x39 Hat Switch + 0x3A Counted Buffer + 0x3B Byte Count + 0x3C Motion Wakeup + 0x40 Vx + 0x41 Vy + 0x42 Vz + 0x43 Vbrx + 0x44 Vbry + 0x45 Vbrx + 0x46 Vno + 0x80 System Control + 0x81 System Power Down + 0x82 System Sleep + 0x83 System Wake Up + 0x84 System Context Menu + 0x85 System Main Menu + 0x86 System App Menu + 0x87 System Menu Help + 0x88 System Menu Exit + 0x89 System Menu Select + 0x8A System Menu Right + 0x8B System Menu Left + 0x8C System Menu Up + 0x8D System Menu Down + 0x90 D-pad Up + 0x91 D-pad Down + 0x92 D-pad Right + 0x93 D-pad Left + +2 Simulation Controls + 0x00 Undefined + 0x01 Flight Simulation Device + 0x02 Automobile Simulation Device + 0x03 Tank Simulation Device + 0x04 Spaceship Simulation Device + 0x05 Submarine Simulation Device + 0x06 Sailing Simulation Device + 0x07 Motorcycle Simulation Device + 0x08 Sports Simulation Device + 0x09 Airplane Simulation Device + 0x0A Helicopter Simulation Device + 0x0B Magic Carpet Simulation Device + 0x0C Bicycle + 0x20 Flight Control Stick + 0x21 Flight Stick + 0x22 Cyclic Control + 0x23 Cyclic Trim + 0x24 Flight Yoke + 0x25 Track Control + 0x26 Driving Control + 0xB0 Aileron + 0xB1 Aileron Trim + 0xB2 Anti-Torque Control + 0xB3 Auto-pilot Enable + 0xB4 Chaff Release + 0xB5 Collective Control + 0xB6 Dive Brake + 0xB7 Electronic Counter Measures + 0xB8 Elevator + 0xB9 Elevator Trim + 0xBA Rudder + 0xBB Throttle + 0xBC Flight Communication + 0xBD Flare Release + 0xBE Landing Gear + 0xBF Toe Brake + 0xC0 Trigger + 0xC1 Weapons Arm + 0xC2 Weapons Select + 0xC3 Wing Flaps + 0xC4 Accelerator + 0xC5 Brake + 0xC6 Clutch + 0xC7 Shifter + 0xC8 Steering + 0xC9 Turret Direction + 0xCA Barrel Elevation + 0xCB Dive Plane + 0xCC Ballast + 0xCD Bicycle Crank + 0xCE Handle Bars + 0xCF Front Brake + 0xD0 Rear Brake + +3 VR Controls + 0x00 Unidentified + 0x01 Belt + 0x02 Body Suit + 0x03 Flexor + 0x04 Glove + 0x05 Head Tracker + 0x06 Head Mounted Display + 0x07 Hand Tracker + 0x08 Oculometer + 0x09 Vest + 0x0A Animatronic Device + 0x20 Stereo Enable + 0x21 Display Enable + +4 Sports Controls + 0x00 Unidentified + 0x01 Baseball Bat + 0x02 Golf Club + 0x03 Rowing Machine + 0x04 Treadmill + 0x30 Oar + 0x31 Slope + 0x32 Rate + 0x33 Stick Speed + 0x34 Stick Face Angle + 0x35 Stick Heel/Toe + 0x36 Stick Follow Through + 0x37 Stick Tempo + 0x38 Stick Type + 0x39 Stick Height + 0x50 Putter + 0x51 1 Iron + 0x52 2 Iron + 0x53 3 Iron + 0x54 4 Iron + 0x55 5 Iron + 0x56 6 Iron + 0x57 7 Iron + 0x58 8 Iron + 0x59 9 Iron + 0x5A 10 Iron + 0x5B 11 Iron + 0x5C Sand Wedge + 0x5D Loft Wedge + 0x5E Power Wedge + 0x5F 1 Wood + 0x60 3 Wood + 0x61 5 Wood + 0x62 7 Wood + 0x63 9 Wood + +5 Game Controls + 0x00 Undefined + 0x01 3D Game Controller + 0x02 Pinball Device + 0x03 Gun Device + 0x20 Point of View + 0x21 Turn Right/Left + 0x22 Pitch Right/Left + 0x23 Roll Forward/Backward + 0x24 Move Right/Left + 0x25 Move Forward/Backward + 0x26 Move Up/Down + 0x27 Lean Right/Left + 0x28 Lean Forward/Backward + 0x29 Height of POV + 0x2A Flipper + 0x2B Secondary Flipper + 0x2C Bump + 0x2D New Game + 0x2E Shoot Ball + 0x2F Player + 0x30 Gun Bolt + 0x31 Gun Clip + 0x32 Gun Selector + 0x33 Gun Single Shot + 0x34 Gun Burst + 0x35 Gun Automatic + 0x36 Gun Safety + 0x37 Gamepad Fire/Jump + 0x39 Gamepad Trigger + +7 Keyboard + 0x00 Reserved (no event indicated) + 0x01 Keyboard ErrorRollOver + 0x02 Keyboard POSTFail + 0x03 Keyboard ErrorUndefined + 0x04 Keyboard a and A + 0x05 Keyboard b and B + 0x06 Keyboard c and C + 0x07 Keyboard d and D + 0x08 Keyboard e and E + 0x09 Keyboard f and F + 0x0A Keyboard g and G + 0x0B Keyboard h and H + 0x0C Keyboard i and I + 0x0D Keyboard j and J + 0x0E Keyboard k and K + 0x0F Keyboard l and L + 0x10 Keyboard m and M + 0x11 Keyboard n and N + 0x12 Keyboard o and O + 0x13 Keyboard p and P + 0x14 Keyboard q and Q + 0x15 Keyboard r and R + 0x16 Keyboard s and S + 0x17 Keyboard t and T + 0x18 Keyboard u and U + 0x19 Keyboard v and V + 0x1A Keyboard w and W + 0x1B Keyboard x and X + 0x1C Keyboard y and Y + 0x1D Keyboard z and Z + 0x1E Keyboard 1 and ! + 0x1F Keyboard 2 and @ + 0x20 Keyboard 3 and # + 0x21 Keyboard 4 and $ + 0x22 Keyboard 5 and % + 0x23 Keyboard 6 and ^ + 0x24 Keyboard 7 and & + 0x25 Keyboard 8 and * + 0x26 Keyboard 9 and ( + 0x27 Keyboard 0 and ) + 0x28 Keyboard Return (ENTER) + 0x29 Keyboard ESCAPE + 0x2A Keyboard DELETE (Backspace) + 0x2B Keyboard Tab + 0x2C Keyboard Spacebar + 0x2D Keyboard - and (underscore) + 0x2E Keyboard = and + + 0x2F Keyboard [ and { + 0x30 Keyboard ] and } + 0x31 Keyboard \ and | + 0x32 Keyboard Non-US # and ~ + 0x33 Keyboard ; and : + 0x34 Keyboard ' and " + 0x35 Keyboard Grave Accent and Tilde + 0x36 Keyboard, and < + 0x37 Keyboard . and > + 0x38 Keyboard / and ? + 0x39 Keyboard Caps Lock + 0x3A Keyboard F1 + 0x3B Keyboard F2 + 0x3C Keyboard F3 + 0x3D Keyboard F4 + 0x3E Keyboard F5 + 0x3F Keyboard F6 + 0x40 Keyboard F7 + 0x41 Keyboard F8 + 0x42 Keyboard F9 + 0x43 Keyboard F10 + 0x44 Keyboard F11 + 0x45 Keyboard F12 + 0x46 Keyboard PrintScreen + 0x47 Keyboard Scroll Lock + 0x48 Keyboard Pause + 0x49 Keyboard Insert + 0x4A Keyboard Home + 0x4B Keyboard PageUp + 0x4C Keyboard Delete Forward + 0x4D Keyboard End + 0x4E Keyboard PageDown + 0x4F Keyboard RightArrow + 0x50 Keyboard LeftArrow + 0x51 Keyboard DownArrow + 0x52 Keyboard UpArrow + 0x53 Keypad Num Lock and Clear + 0x54 Keypad / + 0x55 Keypad * + 0x56 Keypad - + 0x57 Keypad + + 0x58 Keypad ENTER + 0x59 Keypad 1 and End + 0x5A Keypad 2 and Down Arrow + 0x5B Keypad 3 and PageDn + 0x5C Keypad 4 and Left Arrow + 0x5D Keypad 5 + 0x5E Keypad 6 and Right Arrow + 0x5F Keypad 7 and Home + 0x60 Keypad 8 and Up Arrow + 0x61 Keypad 9 and PageUp + 0x62 Keypad 0 and Insert + 0x63 Keypad . and Delete + 0x64 Keyboard Non-US \ and | + 0x65 Keyboard Application + 0x66 Keyboard Power + 0x67 Keypad = + 0x68 Keyboard F13 + 0x69 Keyboard F14 + 0x6A Keyboard F15 + 0x6B Keyboard F16 + 0x6C Keyboard F17 + 0x6D Keyboard F18 + 0x6E Keyboard F19 + 0x6F Keyboard F20 + 0x70 Keyboard F21 + 0x71 Keyboard F22 + 0x72 Keyboard F23 + 0x73 Keyboard F24 + 0x74 Keyboard Execute + 0x75 Keyboard Help + 0x76 Keyboard Menu + 0x77 Keyboard Select + 0x78 Keyboard Stop + 0x79 Keyboard Again + 0x7A Keyboard Undo + 0x7B Keyboard Cut + 0x7C Keyboard Copy + 0x7D Keyboard Paste + 0x7E Keyboard Find + 0x7F Keyboard Mute + 0x80 Keyboard Volume Up + 0x81 Keyboard Volume Down + 0x82 Keyboard Locking Caps Lock + 0x83 Keyboard Locking Num Lock + 0x84 Keyboard Locking Scroll Lock + 0x85 Keypad Comma + 0x86 Keypad Equal Sign + 0x87 Keyboard International1 + 0x88 Keyboard International2 + 0x89 Keyboard International3 + 0x8A Keyboard International4 + 0x8B Keyboard International5 + 0x8C Keyboard International6 + 0x8D Keyboard International7 + 0x8E Keyboard International8 + 0x8F Keyboard International9 + 0x90 Keyboard LANG1 + 0x91 Keyboard LANG2 + 0x92 Keyboard LANG3 + 0x93 Keyboard LANG4 + 0x94 Keyboard LANG5 + 0x95 Keyboard LANG6 + 0x96 Keyboard LANG7 + 0x97 Keyboard LANG8 + 0x98 Keyboard LANG9 + 0x99 Keyboard Alternate Erase + 0x9A Keyboard SysReq/Attention + 0x9B Keyboard Cancel + 0x9C Keyboard Clear + 0x9D Keyboard Prior + 0x9E Keyboard Return + 0x9F Keyboard Separator + 0xA0 Keyboard Out + 0xA1 Keyboard Oper + 0xA2 Keyboard Clear/Again + 0xA3 Keyboard CrSel/Props + 0xA4 Keyboard ExSel + 0xE0 Keyboard LeftControl + 0xE1 Keyboard LeftShift + 0xE2 Keyboard LeftAlt + 0xE3 Keyboard Left GUI + 0xE4 Keyboard RightControl + 0xE5 Keyboard RightShift + 0xE6 Keyboard RightAlt + 0xE7 Keyboard Right GUI + +8 LEDs + 0x00 Undefined + 0x01 Num Lock + 0x02 Caps Lock + 0x03 Scroll Lock + 0x04 Compose + 0x05 Kana + 0x06 Power + 0x07 Shift + 0x08 Do Not Disturb + 0x09 Mute + 0x0A Tone Enable + 0x0B High Cut Filter + 0x0C Low Cut Filter + 0x0D Equalizer Enable + 0x0E Sound Field On + 0x0F Surround Field On + 0x10 Repeat + 0x11 Stereo + 0x12 Sampling Rate Detect + 0x13 Spinning + 0x14 CAV + 0x15 CLV + 0x16 Recording Format Detect + 0x17 Off-Hook + 0x18 Ring + 0x19 Message Waiting + 0x1A Data Mode + 0x1B Battery Operation + 0x1C Battery OK + 0x1D Battery Low + 0x1E Speaker + 0x1F Head Set + 0x20 Hold + 0x21 Microphone + 0x22 Coverage + 0x23 Night Mode + 0x24 Send Calls + 0x25 Call Pickup + 0x26 Conference + 0x27 Stand-by + 0x28 Camera On + 0x29 Camera Off + 0x2A On-Line + 0x2B Off-Line + 0x2C Busy + 0x2D Ready + 0x2E Paper-Out + 0x2F Paper-Jam + 0x30 Remote + 0x31 Forward + 0x32 Reverse + 0x33 Stop + 0x34 Rewind + 0x35 Fast Forward + 0x36 Play + 0x37 Pause + 0x38 Record + 0x39 Error + 0x3A Usage Selected Indicator + 0x3B Usage In Use Indicator + 0x3C Usage Multi Mode Indicator + 0x3D Indicator On + 0x3E Indicator Flash + 0x3F Indicator Slow Blink + 0x40 Indicator Fast Blink + 0x41 Indicator Off + 0x42 Flash On Time + 0x43 Slow Blink On Time + 0x44 Slow Blink Off Time + 0x45 Fast Blink On Time + 0x46 Fast Blink Off Time + 0x47 Usage Indicator Color + 0x48 Red + 0x49 Green + 0x4A Amber + 0x4B Generic Indicator + 0x4C System Suspend + 0x4D External Power Connected + 0x4C-FFFF Reserved + +9 Button + 0x00 No Button Pressed + * Button %d + +10 Ordinal + 0x00 Unused + * Instance %d + +11 Telephony + 0x00 Unassigned + 0x01 Phone + 0x02 Answering Machine + 0x03 Message Controls + 0x04 Handset + 0x05 Headset + 0x06 Telephony Key Pad + 0x07 Programmable Button + 0x20 Hook Switch + 0x21 Flash + 0x22 Feature + 0x23 Hold + 0x24 Redial + 0x25 Transfer + 0x26 Drop + 0x27 Park + 0x28 Forward Calls + 0x29 Alternate Function + 0x2A Line + 0x2B Speaker Phone + 0x2C Conference + 0x2D Ring Enable + 0x2E Ring Select + 0x2F Phone Mute + 0x30 Caller ID + 0x50 Speed Dial + 0x51 Store Number + 0x52 Recall Number + 0x53 Phone Directory + 0x70 Voice Mail + 0x71 Screen Calls + 0x72 Do Not Disturb + 0x73 Message + 0x74 Answer On/Off + 0x90 Inside Dial Tone + 0x91 Outside Dial Tone + 0x92 Inside Ring Tone + 0x93 Outside Ring Tone + 0x94 Priority Ring Tone + 0x95 Inside Ringback + 0x96 Priority Ringback + 0x97 Line Busy Tone + 0x98 Reorder Tone + 0x99 Call Waiting Tone + 0x9A Confirmation Tone 1 + 0x9B Confirmation Tone 2 + 0x9C Tones Off + 0xB0 Phone Key 0 + 0xB1 Phone Key 1 + 0xB2 Phone Key 2 + 0xB3 Phone Key 3 + 0xB4 Phone Key 4 + 0xB5 Phone Key 5 + 0xB6 Phone Key 6 + 0xB7 Phone Key 7 + 0xB8 Phone Key 8 + 0xB9 Phone Key 9 + 0xBA Phone Key Star + 0xBB Phone Key Pound + 0xBC Phone Key A + 0xBD Phone Key B + 0xBE Phone Key C + 0xBF Phone Key D + +12 Consumer + 0x00 Unassigned + 0x01 Consumer Control + 0x02 Numeric Key Pad + 0x03 Programmable Buttons + 0x20 +10 + 0x21 +100 + 0x22 AM/PM + 0x30 Power + 0x31 Reset + 0x32 Sleep + 0x33 Sleep After + 0x34 Sleep Mode + 0x35 Illumination + 0x36 Function Buttons + 0x40 Menu + 0x41 Menu Pick + 0x42 Menu Up + 0x43 Menu Down + 0x44 Menu Left + 0x45 Menu Right + 0x46 Menu Escape + 0x47 Menu Value Increase + 0x48 Menu Value Decrease + 0x60 Data On Screen + 0x61 Closed Caption + 0x62 Closed Caption Select + 0x63 VCR/TV + 0x64 Broadcast Mode + 0x65 Snapshot + 0x66 Still + 0x80 Selection + 0x81 Assign Selection + 0x82 Mode Step + 0x83 Recall Last + 0x84 Enter Channel + 0x85 Order Movie + 0x86 Channel + 0x87 Media Selection + 0x88 Media Select Computer + 0x89 Media Select TV + 0x8A Media Select WWW + 0x8B Media Select DVD + 0x8C Media Select Telephone + 0x8D Media Select Program Guide + 0x8E Media Select Video Phone + 0x8F Media Select Games + 0x90 Media Select Messages + 0x91 Media Select CD + 0x92 Media Select VCR + 0x93 Media Select Tuner + 0x94 Quit + 0x95 Help + 0x96 Media Select Tape + 0x97 Media Select Cable + 0x98 Media Select Satellite + 0x99 Media Select Security + 0x9A Media Select Home + 0x9B Media Select Call + 0x9C Channel Increment + 0x9D Channel Decrement + 0x9E Media Select SAP + 0xA0 VCR Plus + 0xA1 Once + 0xA2 Daily + 0xA3 Weekly + 0xA4 Monthly + 0xB0 Play + 0xB1 Pause + 0xB2 Record + 0xB3 Fast Forward + 0xB4 Rewind + 0xB5 Scan Next Track + 0xB6 Scan Previous Track + 0xB7 Stop + 0xB8 Eject + 0xB9 Random Play + 0xBA Select DisC + 0xBB Enter Disc + 0xBC Repeat + 0xBD Tracking + 0xBE Track Normal + 0xBF Slow Tracking + 0xC0 Frame Forward + 0xC1 Frame Back + 0xC2 Mark + 0xC3 Clear Mark + 0xC4 Repeat From Mark + 0xC5 Return To Mark + 0xC6 Search Mark Forward + 0xC7 Search Mark Backwards + 0xC8 Counter Reset + 0xC9 Show Counter + 0xCA Tracking Increment + 0xCB Tracking Decrement + 0xE0 Volume + 0xE1 Balance + 0xE2 Mute + 0xE3 Bass + 0xE4 Treble + 0xE5 Bass Boost + 0xE6 Surround Mode + 0xE7 Loudness + 0xE8 MPX + 0xE9 Volume Up + 0xEA Volume Down + 0xF0 Speed Select + 0xF1 Playback Speed + 0xF2 Standard Play + 0xF3 Long Play + 0xF4 Extended Play + 0xF5 Slow + 0x100 Fan Enable + 0x101 Fan Speed + 0x102 Light + 0x103 Light Illumination Level + 0x104 Climate Control Enable + 0x105 Room Temperature + 0x106 Security Enable + 0x107 Fire Alarm + 0x108 Police Alarm + 0x150 Balance Right + 0x151 Balance Left + 0x152 Bass Increment + 0x153 Bass Decrement + 0x154 Treble Increment + 0x155 Treble Decrement + 0x160 Speaker System + 0x161 Channel Left + 0x162 Channel Right + 0x163 Channel Center + 0x164 Channel Front + 0x165 Channel Center Front + 0x166 Channel Side + 0x167 Channel Surround + 0x168 Channel Low Frequency Enhancement + 0x169 Channel Top + 0x16A Channel Unknown + 0x170 Sub-channel + 0x171 Sub-channel Increment + 0x172 Sub-channel Decrement + 0x173 Alternate Audio Increment + 0x174 Alternate Audio Decrement + 0x180 Application Launch Buttons + 0x181 AL Launch Button Configuration Tool + 0x182 AL Programmable Button Configuration + 0x183 AL Consumer Control Configuration + 0x184 AL Word Processor + 0x185 AL Text Editor + 0x186 AL Spreadsheet + 0x187 AL Graphics Editor + 0x188 AL Presentation App + 0x189 AL Database App + 0x18A AL Email Reader + 0x18B AL Newsreader + 0x18C AL Voicemail + 0x18D AL Contacts/Address Book + 0x18E AL Calendar/Schedule + 0x18F AL Task/Project Manager + 0x190 AL Log/Journal/Timecard + 0x191 AL Checkbook/Finance + 0x192 AL Calculator + 0x193 AL A/V Capture/Playback + 0x194 AL Local Machine Browser + 0x195 AL LAN/WAN Browser + 0x196 AL Internet Browser + 0x197 AL Remote Networking/ISP Connect + 0x198 AL Network Conference + 0x199 AL Network Chat + 0x19A AL Telephony/Dialer + 0x19B AL Logon + 0x19C AL Logoff + 0x19D AL Logon/Logoff + 0x19E AL Terminal Lock/Screensaver + 0x19F AL Control Panel + 0x1A0 AL Command Line Processor/Run + 0x1A1 AL Process/Task Manager + 0x1A2 AL Select Tast/Application + 0x1A3 AL Next Task/Application + 0x1A4 AL Previous Task/Application + 0x1A5 AL Preemptive Halt Task/Application + 0x200 Generic GUI Application Controls + 0x201 AC New + 0x202 AC Open + 0x203 AC Close + 0x204 AC Exit + 0x205 AC Maximize + 0x206 AC Minimize + 0x207 AC Save + 0x208 AC Print + 0x209 AC Properties + 0x21A AC Undo + 0x21B AC Copy + 0x21C AC Cut + 0x21D AC Paste + 0x21E AC Select All + 0x21F AC Find + 0x220 AC Find and Replace + 0x221 AC Search + 0x222 AC Go To + 0x223 AC Home + 0x224 AC Back + 0x225 AC Forward + 0x226 AC Stop + 0x227 AC Refresh + 0x228 AC Previous Link + 0x229 AC Next Link + 0x22A AC Bookmarks + 0x22B AC History + 0x22C AC Subscriptions + 0x22D AC Zoom In + 0x22E AC Zoom Out + 0x22F AC Zoom + 0x230 AC Full Screen View + 0x231 AC Normal View + 0x232 AC View Toggle + 0x233 AC Scroll Up + 0x234 AC Scroll Down + 0x235 AC Scroll + 0x236 AC Pan Left + 0x237 AC Pan Right + 0x238 AC Pan + 0x239 AC New Window + 0x23A AC Tile Horizontally + 0x23B AC Tile Vertically + 0x23C AC Format + +13 Digitizer + 0x00 Undefined + 0x01 Digitizer + 0x02 Pen + 0x03 Light Pen + 0x04 Touch Screen + 0x05 Touch Pad + 0x06 White Board + 0x07 Coordinate Measuring Machine + 0x08 3-D Digitizer + 0x09 Stereo Plotter + 0x0A Articulated Arm + 0x0B Armature + 0x0C Multiple Point Digitizer + 0x0D Free Space Wand + 0x20 Stylus + 0x21 Puck + 0x22 Finger + 0x30 Tip Pressure + 0x31 Barrel Pressure + 0x32 In Range + 0x33 Touch + 0x34 Untouch + 0x35 Tap + 0x36 Quality + 0x37 Data Valid + 0x38 Transducer Index + 0x39 Tablet Function Keys + 0x3A Program Change Keys + 0x3B Battery Strength + 0x3C Invert + 0x3D X Tilt + 0x3E Y Tilt + 0x3F Azimuth + 0x40 Altitude + 0x41 Twist + 0x42 Tip Switch + 0x43 Secondary Tip Switch + 0x44 Barrel Switch + 0x45 Eraser + 0x46 Tablet Pick + +15 Physical Interface Device + +16 Unicode + * Unicode Char u%04x + +20 Alphnumeric Display + 0x00 Undefined + 0x01 Alphanumeric Display + 0x20 Display Attributes Report + 0x21 ASCII Character Set + 0x22 Data Read Back + 0x23 Font Read Back + 0x24 Display Control Report + 0x25 Clear Display + 0x26 Display Enable + 0x27 Screen Saver Delay + 0x28 Screen Saver Enable + 0x29 Vertical Scroll + 0x2A Horizontal Scroll + 0x2B Character Report + 0x2C Display Data + 0x2D Display Status + 0x2E Stat Not Ready + 0x2F Stat Ready + 0x30 Err Not a loadable character + 0x31 Err Font data cannot be read + 0x32 Cursor Position Report + 0x33 Row + 0x34 Column + 0x35 Rows + 0x36 Columns + 0x37 Cursor Pixel Positioning + 0x38 Cursor Mode + 0x39 Cursor Enable + 0x3A Cursor Blink + 0x3B Font Report + 0x3C Font Data + 0x3D Character Width + 0x3E Character Height + 0x3F Character Spacing Horizontal + 0x40 Character Spacing Vertical + 0x41 Unicode Character Set + +128 Monitor + 0x00 Undefined + 0x01 Monitor Control + 0x02 EDID Information + 0x03 VDIF Information + 0x04 VESA Version + 0x05 On Screen Display + 0x06 Auto Size Center + 0x07 Polarity Horz Synch + 0x08 Polarity Vert Synch + 0x09 Sync Type + 0x0A Screen Position + 0x0B Horizontal Frequency + 0x0C Vertical Frequency + +129 Monitor Enumerated Values + 0x00 unassigned + * ENUM %d + +130 VESA Virtual Controls + 0x10 Brightness + 0x12 Contrast + 0x16 Video Gain Red + 0x18 Video Gain Green + 0x1A Video Gain Blue + 0x1C Focus + 0x20 Horizontal Position + 0x22 Horizontal Size + 0x24 Horizontal Pincushion + 0x26 Horizontal Pincushion Balance + 0x28 Horizontal Misconvergence + 0x2A Horizontal Linearity + 0x2C Horizontal Linearity Balance + 0x30 Vertical Position + 0x32 Vertical Size + 0x34 Vertical Pincushion + 0x36 Vertical Pincushion Balance + 0x38 Vertical Misconvergence + 0x3A Vertical Linearity + 0x3C Vertical Linearity Balance + 0x40 Parallelogram Distortion + 0x42 Trapezoidal Distortion + 0x44 Tilt + 0x46 Top Corner Distortion Control + 0x48 Top Corner Distortion Balance + 0x4A Bottom Corner Distortion Control + 0x4C Bottom Corner Distortion Balance + 0x56 Moiré Horizontal + 0x58 Moiré Vertical + 0x5E Input Level Select + 0x60 Input Source Select + 0x62 Stereo Mode + 0x6C Video Black Level Red + 0x6E Video Black Level Green + 0x70 Video Black Level Blue + +131 VESA Command + 0x00 Undefined + 0x01 Settings + 0x02 Degauss + +132 Power Device + 0x00 Undefined + 0x01 iName + 0x02 PresentStatus + 0x03 ChangedStatus + 0x04 UPS + 0x05 PowerSupply + 0x10 BatterySystem + 0x11 BatterySystemID + 0x12 Battery + 0x13 BatteryID + 0x14 Charger + 0x15 ChargerID + 0x16 PowerConverter + 0x17 PowerConverterID + 0x18 OutletSystem + 0x19 OutletSystemID + 0x1A Input + 0x1B InputID + 0x1C Output + 0x1D OutputID + 0x1E Flow + 0x1F FlowID + 0x20 Outlet + 0x21 OutletID + 0x22 Gang + 0x23 GangID + 0x24 Sink + 0x25 SinkID + 0x30 Voltage + 0x31 Current + 0x32 Frequency + 0x33 ApparentPower + 0x34 ActivePower + 0x35 PercentLoad + 0x36 Temperature + 0x37 Humidity + 0x40 ConfigVoltage + 0x41 ConfigCurrent + 0x42 ConfigFrequency + 0x43 ConfigApparentPower + 0x44 ConfigActivePower + 0x45 ConfigPercentLoad + 0x46 ConfigTemperature + 0x47 ConfigHumidity + 0x50 SwitchOnControl + 0x51 SwitchOffControl + 0x52 ToggleControl + 0x53 LowVoltageTransfer + 0x54 HighVoltageTransfer + 0x55 DelayBeforeReboot + 0x56 DelayBeforeStartup + 0x57 DelayBeforeShutdown + 0x58 Test + 0x59 Vendorspecificcommand + 0x60 Present + 0x61 Good + 0x62 InternalFailure + 0x63 VoltageOutOfRange + 0x64 FrequencyOutOfRange + 0x65 Overload + 0x66 OverCharged + 0x67 OverTemperature + 0x68 ShutdownRequested + 0x69 ShutdownImminent + 0x6A VendorSpecificAnswerValid + 0x6B SwitchOn/Off + 0x6C Switcheble + 0x6D Used + 0x6E Boost + 0x6F Buck + 0x70 Initialized + 0x71 Tested + +133 Battery System + 0x00 Undefined + 0x01 SMBBatteryMode + 0x02 SMBBatteryStatus + 0x03 SMBAlarmWarning + 0x04 SMBChargerMode + 0x05 SMBChargerStatus + 0x06 SMBChargerSpecInfo + 0x07 SMBSelectorState + 0x08 SMBSelectorPreset + 0x09 SMBSelectorInfo + 0x10 OptionalMfgFunction1 + 0x11 OptionalMfgFunction2 + 0x12 OptionalMfgFunction3 + 0x13 OptionalMfgFunction4 + 0x14 OptionalMfgFunction5 + 0x15 ConnectionToSMBus + 0x16 OutputConnection + 0x17 ChargerConnection + 0x18 BatteryInsertion + 0x19 Usenext + 0x1A OKToUse + 0x28 ManufacturerAccess + 0x29 RemainingCapacityLimit + 0x2A RemainingTimeLimit + 0x2B AtRate + 0x2C CapacityMode + 0x2D BroadcastToCharger + 0x2E PrimaryBattery + 0x2F ChargeController + 0x40 TerminateCharge + 0x41 TermminateDischarge + 0x42 BelowRemainingCapacityLimit + 0x43 RemainingTimeLimitExpired + 0x44 Charging + 0x45 Discharging + 0x46 FullyCharged + 0x47 FullyDischarged + 0x48 ConditionningFlag + 0x49 AtRateOK + 0x4A SMBErrorCode + 0x4B NeedReplacement + 0x60 AtRateTimeToFull + 0x61 AtRateTimeToEmpty + 0x62 AverageCurrent + 0x63 Maxerror + 0x64 RelativeStateOfCharge + 0x65 AbsoluteStateOfCharge + 0x66 RemainingCapacity + 0x67 FullChargeCapacity + 0x68 RunTimeToEmpty + 0x69 AverageTimeToEmpty + 0x6A AverageTimeToFull + 0x6B CycleCount + 0x80 BattPackModelLevel + 0x81 InternalChargeController + 0x82 PrimaryBatterySupport + 0x83 DesignCapacity + 0x84 SpecificationInfo + 0x85 ManufacturerDate + 0x86 SerialNumber + 0x87 iManufacturerName + 0x88 iDevicename + 0x89 iDeviceChemistery + 0x8A iManufacturerData + 0x8B Rechargeable + 0x8C WarningCapacityLimit + 0x8D CapacityGranularity1 + 0x8E CapacityGranularity2 + 0xC0 InhibitCharge + 0xC1 EnablePolling + 0xC2 ResetToZero + 0xD0 ACPresent + 0xD1 BatteryPresent + 0xD2 PowerFail + 0xD3 AlarmInhibited + 0xD4 ThermistorUnderRange + 0xD5 ThermistorHot + 0xD6 ThermistorCold + 0xD7 ThermistorOverRange + 0xD8 VoltageOutOfRange + 0xD9 CurrentOutOfRange + 0xDA CurrentNotRegulated + 0xDB VoltageNotRegulated + 0xDC MasterMode + 0xDD ChargerBattery/HostControlled + 0xF0 ChargerSpecInfo + 0xF1 ChargerSpecRef + 0xF2 Level2 + 0xF3 Level3 + +140 Bar Code Scanner + +141 Scale Device + +144 Camera Control + +145 Arcade Device + +# Some Micro$oft non-standard extensions +0xff00 Microsoft + 0xe9 Base Up + 0xea Base Down diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usbvar.h b/xorg-server/hw/xfree86/os-support/bsd/libusb/usbvar.h new file mode 100644 index 000000000..ce38a0730 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usbvar.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +struct report_desc { + unsigned int size; + unsigned char data[1]; +}; + diff --git a/xorg-server/hw/xfree86/os-support/bsd/memrange.h b/xorg-server/hw/xfree86/os-support/bsd/memrange.h new file mode 100644 index 000000000..03c479144 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/memrange.h @@ -0,0 +1,69 @@ +/* + * Memory range attribute operations, peformed on /dev/mem + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _MEMRANGE_H +#define _MEMRANGE_H + +/* Memory range attributes */ +#define MDF_UNCACHEABLE (1<<0) /* region not cached */ +#define MDF_WRITECOMBINE (1<<1) /* region supports "write combine" + * action */ +#define MDF_WRITETHROUGH (1<<2) /* write-through cached */ +#define MDF_WRITEBACK (1<<3) /* write-back cached */ +#define MDF_WRITEPROTECT (1<<4) /* read-only region */ +#define MDF_ATTRMASK (0x00ffffff) + +#define MDF_FIXBASE (1<<24) /* fixed base */ +#define MDF_FIXLEN (1<<25) /* fixed length */ +#define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */ +#define MDF_ACTIVE (1<<27) /* currently active */ +#define MDF_BOGUS (1<<28) /* we don't like it */ +#define MDF_FIXACTIVE (1<<29) /* can't be turned off */ +#define MDF_BUSY (1<<30) /* range is in use */ + +struct mem_range_desc { + u_int64_t mr_base; + u_int64_t mr_len; + int mr_flags; + char mr_owner[8]; +}; + +struct mem_range_op { + struct mem_range_desc *mo_desc; + int mo_arg[2]; +#define MEMRANGE_SET_UPDATE 0 +#define MEMRANGE_SET_REMOVE 1 + /* XXX want a flag that says "set and undo when I exit" */ +}; +#define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op) +#define MEMRANGE_SET _IOW('m', 51, struct mem_range_op) + +#ifdef _KERNEL + +struct mem_range_softc; +struct mem_range_ops { + void (*init) __P((struct mem_range_softc * sc)); + int (*set) __P((struct mem_range_softc * sc, struct mem_range_desc * mrd, int *arg)); + void (*initAP) __P((struct mem_range_softc * sc)); +}; + +struct mem_range_softc { + struct mem_range_ops *mr_op; + int mr_cap; + int mr_ndesc; + struct mem_range_desc *mr_desc; +}; + +extern struct mem_range_softc mem_range_softc; + +extern int mem_range_attr_get __P((struct mem_range_desc * mrd, int *arg)); +extern int mem_range_attr_set __P((struct mem_range_desc * mrd, int *arg)); +extern void mem_range_AP_init __P((void)); +#endif + +#endif diff --git a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c new file mode 100644 index 000000000..06be654e1 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c @@ -0,0 +1,171 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#include "bus/Pci.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +#ifndef __OpenBSD__ +#define DEV_MEM "/dev/mem" +#else +#define DEV_MEM "/dev/xf86" +#endif + +static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags); +static void ppcUnmapVidMem(int, pointer, unsigned long); + +Bool xf86EnableIO(void); +void xf86DisableIO(void); + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = ppcMapVidMem; + pVidMem->unmapMem = ppcUnmapVidMem; + pVidMem->initialised = TRUE; + xf86EnableIO(); +} + + +_X_EXPORT volatile unsigned char *ioBase = MAP_FAILED; + +static pointer +ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + int fd = xf86Info.screenFd; + pointer base; +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", + Base, Size, fd); +#endif + + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", + "xf86MapVidMem", Size, Base, strerror(errno)); + + return base; +} + +static void +ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int rv; + static int kmem = -1; + + if (kmem == -1) { + kmem = open(DEV_MEM, 2); + if (kmem == -1) { + FatalError("xf86ReadBIOS: open %s", DEV_MEM); + } + } + +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", + Base, Offset, Len); +#endif + + + lseek(kmem, Base + Offset, 0); + rv = read(kmem, Buf, Len); + + return rv; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + + return; +} + +Bool xf86EnableIO() +{ + int fd = xf86Info.screenFd; + + xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd); + if (ioBase == MAP_FAILED) + { + ioBase=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, + 0xf2000000); + xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase); + if (ioBase == MAP_FAILED) { + xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n"); + return FALSE; + } + } + return TRUE; +} + +void xf86DisableIO() +{ + + if (ioBase != MAP_FAILED) + { + munmap(__UNVOLATILE(ioBase), 0x10000); + ioBase = MAP_FAILED; + } +} + diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c new file mode 100644 index 000000000..fb5e8529b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c @@ -0,0 +1,109 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int); +static void sparc64UnmapVidMem(int, pointer, unsigned long); + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = sparc64MapVidMem; + pVidMem->unmapMem = sparc64UnmapVidMem; + pVidMem->initialised = TRUE; +} + +static pointer +sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, + int flags) +{ + int fd = xf86Info.screenFd; + pointer base; + +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", + Base, Size, fd); +#endif + + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", + "xf86MapVidMem", Size, Base, strerror(errno)); + return base; +} + +static void +sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + + return (0); +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + + return; +} diff --git a/xorg-server/hw/xfree86/os-support/bus/Makefile.am b/xorg-server/hw/xfree86/os-support/bus/Makefile.am new file mode 100644 index 000000000..d48fcb67d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/Makefile.am @@ -0,0 +1,38 @@ +noinst_LTLIBRARIES = libbus.la +sdk_HEADERS = xf86Pci.h + +PCI_SOURCES = + +if XORG_BUS_LINUXPCI +PCI_SOURCES += linuxPci.c +endif + +if XORG_BUS_BSDPCI +PCI_SOURCES += bsd_pci.c +endif + +if XORG_BUS_IX86PCI +PCI_SOURCES += ix86Pci.c +endif + +if XORG_BUS_PPCPCI +PCI_SOURCES += ppcPci.c +endif + +if XORG_BUS_SPARCPCI +PCI_SOURCES += sparcPci.c +endif + +if XORG_BUS_SPARC +PLATFORM_SOURCES = Sbus.c +sdk_HEADERS += xf86Sbus.h +endif + +libbus_la_SOURCES = Pci.c Pci.h $(PCI_SOURCES) $(PLATFORM_PCI_SOURCES) \ + $(PLATFORM_SOURCES) + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) + +EXTRA_DIST = $(sdk_HEADERS) diff --git a/xorg-server/hw/xfree86/os-support/bus/Makefile.in b/xorg-server/hw/xfree86/os-support/bus/Makefile.in new file mode 100644 index 000000000..fb2391280 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/Makefile.in @@ -0,0 +1,705 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@XORG_BUS_LINUXPCI_TRUE@am__append_1 = linuxPci.c +@XORG_BUS_BSDPCI_TRUE@am__append_2 = bsd_pci.c +@XORG_BUS_IX86PCI_TRUE@am__append_3 = ix86Pci.c +@XORG_BUS_PPCPCI_TRUE@am__append_4 = ppcPci.c +@XORG_BUS_SPARCPCI_TRUE@am__append_5 = sparcPci.c +@XORG_BUS_SPARC_TRUE@am__append_6 = xf86Sbus.h +subdir = hw/xfree86/os-support/bus +DIST_COMMON = $(am__sdk_HEADERS_DIST) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libbus_la_LIBADD = +am__libbus_la_SOURCES_DIST = Pci.c Pci.h linuxPci.c bsd_pci.c \ + ix86Pci.c ppcPci.c sparcPci.c Sbus.c +@XORG_BUS_LINUXPCI_TRUE@am__objects_1 = linuxPci.lo +@XORG_BUS_BSDPCI_TRUE@am__objects_2 = bsd_pci.lo +@XORG_BUS_IX86PCI_TRUE@am__objects_3 = ix86Pci.lo +@XORG_BUS_PPCPCI_TRUE@am__objects_4 = ppcPci.lo +@XORG_BUS_SPARCPCI_TRUE@am__objects_5 = sparcPci.lo +am__objects_6 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ + $(am__objects_4) $(am__objects_5) +@XORG_BUS_SPARC_TRUE@am__objects_7 = Sbus.lo +am_libbus_la_OBJECTS = Pci.lo $(am__objects_6) $(am__objects_7) +libbus_la_OBJECTS = $(am_libbus_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libbus_la_SOURCES) +DIST_SOURCES = $(am__libbus_la_SOURCES_DIST) +am__sdk_HEADERS_DIST = xf86Pci.h xf86Sbus.h +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LTLIBRARIES = libbus.la +sdk_HEADERS = xf86Pci.h $(am__append_6) +PCI_SOURCES = $(am__append_1) $(am__append_2) $(am__append_3) \ + $(am__append_4) $(am__append_5) +@XORG_BUS_SPARC_TRUE@PLATFORM_SOURCES = Sbus.c +libbus_la_SOURCES = Pci.c Pci.h $(PCI_SOURCES) $(PLATFORM_PCI_SOURCES) \ + $(PLATFORM_SOURCES) + +INCLUDES = $(XORG_INCS) +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) +EXTRA_DIST = $(sdk_HEADERS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/bus/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/bus/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libbus.la: $(libbus_la_OBJECTS) $(libbus_la_DEPENDENCIES) + $(LINK) $(libbus_la_OBJECTS) $(libbus_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Pci.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sbus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_pci.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ix86Pci.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linuxPci.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcPci.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparcPci.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.c b/xorg-server/hw/xfree86/os-support/bus/Pci.c new file mode 100644 index 000000000..064533c77 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/Pci.c @@ -0,0 +1,193 @@ +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This software is derived from the original XFree86 PCI code + * which includes the following copyright notices as well: + * + * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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. + * + * This code is also based heavily on the code in FreeBSD-current, which was + * written by Wolfgang Stanglmeier, and contains the following copyright: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <signal.h> +#include <X11/Xarch.h> +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "Pci.h" + +#include <pciaccess.h> + +#define PCI_MFDEV_SUPPORT 1 /* Include PCI multifunction device support */ +#define PCI_BRIDGE_SUPPORT 1 /* Include support for PCI-to-PCI bridges */ + +/* + * Global data + */ + +pciBusInfo_t *pciBusInfo[MAX_PCI_BUSES] = { NULL, }; +_X_EXPORT int pciNumBuses = 0; /* Actual number of PCI buses */ +int pciMaxBusNum = MAX_PCI_BUSES; + + +_X_EXPORT ADDRESS +pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr) +{ + int bus = PCI_BUS_FROM_TAG(tag); + + if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] && + pciBusInfo[bus]->funcs->pciAddrBusToHost) + return (*pciBusInfo[bus]->funcs->pciAddrBusToHost)(tag, type, addr); + else + return(addr); +} + +_X_EXPORT PCITAG +pciTag(int busnum, int devnum, int funcnum) +{ + return(PCI_MAKE_TAG(busnum,devnum,funcnum)); +} + +ADDRESS +pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS addr) +{ + return(addr); +} + +_X_EXPORT Bool +xf86scanpci(void) +{ + Bool success = FALSE; + + success = (pci_system_init() == 0); + + /* XXX */ +#if defined(DEBUGPCI) + if (DEBUGPCI >= xf86Verbose) { + xf86Verbose = DEBUGPCI; + } +#endif + + /* choose correct platform/OS specific PCI init routine */ + ARCH_PCI_INIT(); + + return success; +} diff --git a/xorg-server/hw/xfree86/os-support/bus/Pci.h b/xorg-server/hw/xfree86/os-support/bus/Pci.h new file mode 100644 index 000000000..557483b9b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/Pci.h @@ -0,0 +1,269 @@ +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This file is derived in part from the original xf86_PCI.h that included + * following copyright message: + * + * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* + * This file has the private Pci definitions. The public ones are imported + * from xf86Pci.h. Drivers should not use this file. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _PCI_H +#define _PCI_H 1 + +#include <X11/Xarch.h> +#include <X11/Xfuncproto.h> +#include "xf86Pci.h" +#include "xf86PciInfo.h" + +/* + * Global Definitions + */ +#define MAX_PCI_DEVICES 128 /* Max number of devices accomodated */ + /* by xf86scanpci */ +#if defined(sun) && defined(SVR4) && defined(sparc) +# define MAX_PCI_BUSES 4096 /* Max number of PCI buses */ +#elif (defined(__alpha__) || defined(__ia64__)) && defined (linux) +# define MAX_PCI_DOMAINS 512 +# define PCI_DOM_MASK 0x01fful +# define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */ +#else +# define MAX_PCI_BUSES 256 /* Max number of PCI buses */ +#endif + +#define DEVID(vendor, device) \ + ((CARD32)((PCI_##device << 16) | PCI_##vendor)) + +#ifndef PCI_DOM_MASK +# define PCI_DOM_MASK 0x0ffu +#endif +#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) + +/* + * "b" contains an optional domain number. + */ +#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ + (((d) & 0x00001fu) << 11) | \ + (((f) & 0x000007u) << 8)) + +#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu)) + +#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK)) +#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) +#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) +#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) + +#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) +#define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u) + +#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK)) +#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) +#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u) + +/* + * Debug Macros/Definitions + */ +/* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */ + +#if defined(DEBUGPCI) + +# define PCITRACE(lvl,printfargs) \ + if (lvl > xf86Verbose) { \ + ErrorF printfargs; \ + } + +#else /* !defined(DEBUGPCI) */ + +# define PCITRACE(lvl,printfargs) + +#endif /* !defined(DEBUGPCI) */ + +/* + * PCI Config mechanism definitions + */ +#define PCI_EN 0x80000000 + +#define PCI_CFGMECH1_ADDRESS_REG 0xCF8 +#define PCI_CFGMECH1_DATA_REG 0xCFC + +#define PCI_CFGMECH1_MAXDEV 32 + +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__DragonFly__) +#define ARCH_PCI_INIT bsdPciInit +#endif + +#if defined(linux) +# define ARCH_PCI_INIT linuxPciInit +# if defined(__m32r__) +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN +# endif +#endif /* defined(linux) */ + + +#if !defined(ARCH_PCI_INIT) +/* + * Select architecture specific PCI init function + */ +#if defined(__i386__) || defined(__i386) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) +# define ARCH_PCI_INIT ix86PciInit +#elif defined(__powerpc__) || defined(__powerpc64__) +# define ARCH_PCI_INIT ppcPciInit +#elif defined(__sparc__) || defined(sparc) +# define ARCH_PCI_INIT sparcPciInit +# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge +#endif +#endif /* !defined(ARCH_PCI_INIT) */ + +#ifndef ARCH_PCI_INIT +#error No PCI support available for this architecture/OS combination +#endif + +extern void ARCH_PCI_INIT(void); + +#if defined(XF86SCANPCI_WRAPPER) +typedef enum { + SCANPCI_INIT, + SCANPCI_TERM +} scanpciWrapperOpt; +extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags); +#endif + +/* + * Table of functions used to access a specific PCI bus domain + * (e.g. a primary PCI bus and all of its secondaries) + */ +typedef struct pci_bus_funcs { + ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS); +} pciBusFuncs_t, *pciBusFuncs_p; + +/* + * pciBusInfo_t - One structure per defined PCI bus + */ +typedef struct pci_bus_info { + unsigned char configMech; /* PCI config type to use */ + unsigned char numDevices; /* Range of valid devnums */ + unsigned char secondary; /* Boolean: bus is a secondary */ + int primary_bus; /* Parent bus */ + pciBusFuncs_p funcs; /* PCI access functions */ + void *pciBusPriv; /* Implementation private data */ + struct pci_device *bridge; /* bridge that opens this bus */ +} pciBusInfo_t; + +#define HOST_NO_BUS ((pciBusInfo_t *)(-1)) + +/* configMech values */ +#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */ +#define PCI_CFG_MECH_1 1 /* Most machines */ +#define PCI_CFG_MECH_2 2 /* Older PC's */ +#define PCI_CFG_MECH_OTHER 3 /* Something else */ + +/* Generic PCI service functions and helpers */ +CARD32 pciCfgMech1Read(PCITAG tag, int offset); +void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val); +void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask, + CARD32 val); +ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS); + +extern int pciMaxBusNum; + +extern pciBusInfo_t *pciBusInfo[]; + +#endif /* _PCI_H */ diff --git a/xorg-server/hw/xfree86/os-support/bus/Sbus.c b/xorg-server/hw/xfree86/os-support/bus/Sbus.c new file mode 100644 index 000000000..ff257a8c7 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/Sbus.c @@ -0,0 +1,636 @@ +/* + * SBUS and OpenPROM access functions. + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * 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 + * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <sys/mman.h> +#ifdef sun +#include <sys/utsname.h> +#endif +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include "xf86sbusBus.h" +#include "xf86Sbus.h" + +int promRootNode; + +static int promFd = -1; +static int promCurrentNode; +static int promOpenCount = 0; +static int promP1275 = -1; +#define MAX_PROP 128 +#define MAX_VAL (4096-128-4) +static struct openpromio *promOpio; + +sbusDevicePtr *xf86SbusInfo = NULL; + +struct sbus_devtable sbusDeviceTable[] = { + { SBUS_DEVICE_BW2, FBTYPE_SUN2BW, "bwtwo", "Sun Monochrome (bwtwo)" }, + { SBUS_DEVICE_CG2, FBTYPE_SUN2COLOR, "cgtwo", "Sun Color2 (cgtwo)" }, + { SBUS_DEVICE_CG3, FBTYPE_SUN3COLOR, "cgthree", "Sun Color3 (cgthree)" }, + { SBUS_DEVICE_CG4, FBTYPE_SUN4COLOR, "cgfour", "Sun Color4 (cgfour)" }, + { SBUS_DEVICE_CG6, FBTYPE_SUNFAST_COLOR, "cgsix", "Sun GX" }, + { SBUS_DEVICE_CG8, FBTYPE_MEMCOLOR, "cgeight", "Sun CG8/RasterOps" }, + { SBUS_DEVICE_CG12, FBTYPE_SUNGP3, "cgtwelve", "Sun GS (cgtwelve)" }, + { SBUS_DEVICE_CG14, FBTYPE_MDICOLOR, "cgfourteen", "Sun SX" }, + { SBUS_DEVICE_GT, FBTYPE_SUNGT, "gt", "Sun Graphics Tower" }, + { SBUS_DEVICE_MGX, -1, "mgx", "Quantum 3D MGXplus" }, + { SBUS_DEVICE_LEO, FBTYPE_SUNLEO, "leo", "Sun ZX or Turbo ZX" }, + { SBUS_DEVICE_TCX, FBTYPE_TCXCOLOR, "tcx", "Sun TCX" }, + { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "ffb", "Sun FFB" }, + { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "afb", "Sun Elite3D" }, + { 0, 0, NULL } +}; + +int +promGetSibling(int node) +{ + promOpio->oprom_size = sizeof(int); + + if (node == -1) return 0; + *(int *)promOpio->oprom_array = node; + if (ioctl(promFd, OPROMNEXT, promOpio) < 0) + return 0; + promCurrentNode = *(int *)promOpio->oprom_array; + return *(int *)promOpio->oprom_array; +} + +int +promGetChild(int node) +{ + promOpio->oprom_size = sizeof(int); + + if (!node || node == -1) return 0; + *(int *)promOpio->oprom_array = node; + if (ioctl(promFd, OPROMCHILD, promOpio) < 0) + return 0; + promCurrentNode = *(int *)promOpio->oprom_array; + return *(int *)promOpio->oprom_array; +} + +char * +promGetProperty(const char *prop, int *lenp) +{ + promOpio->oprom_size = MAX_VAL; + + strcpy(promOpio->oprom_array, prop); + if (ioctl(promFd, OPROMGETPROP, promOpio) < 0) + return 0; + if (lenp) *lenp = promOpio->oprom_size; + return promOpio->oprom_array; +} + +int +promGetBool(const char *prop) +{ + promOpio->oprom_size = 0; + + *(int *)promOpio->oprom_array = 0; + for (;;) { + promOpio->oprom_size = MAX_PROP; + if (ioctl(promFd, OPROMNXTPROP, promOpio) < 0) + return 0; + if (!promOpio->oprom_size) + return 0; + if (!strcmp(promOpio->oprom_array, prop)) + return 1; + } +} + +#define PROM_NODE_SIBLING 0x01 +#define PROM_NODE_PREF 0x02 +#define PROM_NODE_SBUS 0x04 +#define PROM_NODE_EBUS 0x08 +#define PROM_NODE_PCI 0x10 + +static int +promSetNode(sbusPromNodePtr pnode) +{ + int node; + + if (!pnode->node || pnode->node == -1) + return -1; + if (pnode->cookie[0] & PROM_NODE_SIBLING) + node = promGetSibling(pnode->cookie[1]); + else + node = promGetChild(pnode->cookie[1]); + if (pnode->node != node) + return -1; + return 0; +} + +static void +promIsP1275(void) +{ +#ifdef linux + FILE *f; + char buffer[1024]; + + if (promP1275 != -1) + return; + promP1275 = 0; + f = fopen("/proc/cpuinfo","r"); + if (!f) return; + while (fgets(buffer, 1024, f) != NULL) + if (!strncmp (buffer, "type", 4) && strstr (buffer, "sun4u")) { + promP1275 = 1; + break; + } + fclose(f); +#elif defined(sun) + struct utsname buffer; + + if ((uname(&buffer) >= 0) && !strcmp(buffer.machine, "sun4u")) + promP1275 = TRUE; + else + promP1275 = FALSE; +#elif defined(__FreeBSD__) + promP1275 = TRUE; +#else +#error Missing promIsP1275() function for this OS +#endif +} + +_X_EXPORT void +sparcPromClose(void) +{ + if (promOpenCount > 1) { + promOpenCount--; + return; + } + if (promFd != -1) { + close(promFd); + promFd = -1; + } + if (promOpio) { + xfree(promOpio); + promOpio = NULL; + } + promOpenCount = 0; +} + +_X_EXPORT int +sparcPromInit(void) +{ + if (promOpenCount) { + promOpenCount++; + return 0; + } + promFd = open("/dev/openprom", O_RDONLY, 0); + if (promFd == -1) + return -1; + promOpio = (struct openpromio *)xalloc(4096); + if (!promOpio) { + sparcPromClose(); + return -1; + } + promRootNode = promGetSibling(0); + if (!promRootNode) { + sparcPromClose(); + return -1; + } + promIsP1275(); + promOpenCount++; + + return 0; +} + +_X_EXPORT char * +sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp) +{ + if (promSetNode(pnode)) + return NULL; + return promGetProperty(prop, lenp); +} + +_X_EXPORT int +sparcPromGetBool(sbusPromNodePtr pnode, const char *prop) +{ + if (promSetNode(pnode)) + return 0; + return promGetBool(prop); +} + +static void +promWalkAssignNodes(int node, int oldnode, int flags, sbusDevicePtr *devicePtrs) +{ + int nextnode; + int len, sbus = flags & PROM_NODE_SBUS; + char *prop; + int devId, i, j; + sbusPromNode pNode, pNode2; + + prop = promGetProperty("device_type", &len); + if (prop && (len > 0)) do { + if (!strcmp(prop, "display")) { + prop = promGetProperty("name", &len); + if (!prop || len <= 0) + break; + while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',') + prop++; + for (i = 0; sbusDeviceTable[i].devId; i++) + if (!strcmp(prop, sbusDeviceTable[i].promName)) + break; + devId = sbusDeviceTable[i].devId; + if (!devId) + break; + if (!sbus) { + if (devId == SBUS_DEVICE_FFB) { + /* + * All /SUNW,ffb outside of SBUS tree come before all + * /SUNW,afb outside of SBUS tree in Linux. + */ + if (!strcmp(prop, "afb")) + flags |= PROM_NODE_PREF; + } else if (devId != SBUS_DEVICE_CG14) + break; + } + for (i = 0; i < 32; i++) { + if (!devicePtrs[i] || devicePtrs[i]->devId != devId) + continue; + if (devicePtrs[i]->node.node) { + if ((devicePtrs[i]->node.cookie[0] & ~PROM_NODE_SIBLING) <= + (flags & ~PROM_NODE_SIBLING)) + continue; + for (j = i + 1, pNode = devicePtrs[i]->node; j < 32; j++) { + if (!devicePtrs[j] || devicePtrs[j]->devId != devId) + continue; + pNode2 = devicePtrs[j]->node; + devicePtrs[j]->node = pNode; + pNode = pNode2; + } + } + devicePtrs[i]->node.node = node; + devicePtrs[i]->node.cookie[0] = flags; + devicePtrs[i]->node.cookie[1] = oldnode; + break; + } + break; + } + } while (0); + + prop = promGetProperty("name", &len); + if (prop && len > 0) { + if (!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) + sbus = PROM_NODE_SBUS; + } + + nextnode = promGetChild(node); + if (nextnode) + promWalkAssignNodes(nextnode, node, sbus, devicePtrs); + + nextnode = promGetSibling(node); + if (nextnode) + promWalkAssignNodes(nextnode, node, PROM_NODE_SIBLING | sbus, devicePtrs); +} + +void +sparcPromAssignNodes(void) +{ + sbusDevicePtr psdp, *psdpp; + int n, holes = 0, i, j; + FILE *f; + sbusDevicePtr devicePtrs[32]; + + (void)memset(devicePtrs, 0, sizeof(devicePtrs)); + for (psdpp = xf86SbusInfo, n = 0; (psdp = *psdpp); psdpp++, n++) { + if (psdp->fbNum != n) + holes = 1; + devicePtrs[psdp->fbNum] = psdp; + } + if (holes && (f = fopen("/proc/fb", "r")) != NULL) { + /* We could not open one of fb devices, check /proc/fb to see what + * were the types of the cards missed. */ + char buffer[64]; + int fbNum, devId; + static struct { + int devId; + char *prefix; + } procFbPrefixes[] = { + { SBUS_DEVICE_BW2, "BWtwo" }, + { SBUS_DEVICE_CG14, "CGfourteen" }, + { SBUS_DEVICE_CG6, "CGsix" }, + { SBUS_DEVICE_CG3, "CGthree" }, + { SBUS_DEVICE_FFB, "Creator" }, + { SBUS_DEVICE_FFB, "Elite 3D" }, + { SBUS_DEVICE_LEO, "Leo" }, + { SBUS_DEVICE_TCX, "TCX" }, + { 0, NULL }, + }; + + while (fscanf(f, "%d %63s\n", &fbNum, buffer) == 2) { + for (i = 0; procFbPrefixes[i].devId; i++) + if (! strncmp(procFbPrefixes[i].prefix, buffer, + strlen(procFbPrefixes[i].prefix))) + break; + devId = procFbPrefixes[i].devId; + if (! devId) continue; + if (devicePtrs[fbNum]) { + if (devicePtrs[fbNum]->devId != devId) + xf86ErrorF("Inconsistent /proc/fb with FBIOGATTR\n"); + } else if (!devicePtrs[fbNum]) { + devicePtrs[fbNum] = psdp = xnfcalloc(sizeof (sbusDevice), 1); + psdp->devId = devId; + psdp->fbNum = fbNum; + psdp->fd = -2; + } + } + fclose(f); + } + promGetSibling(0); + promWalkAssignNodes(promRootNode, 0, PROM_NODE_PREF, devicePtrs); + for (i = 0, j = 0; i < 32; i++) + if (devicePtrs[i] && devicePtrs[i]->fbNum == -1) + j++; + xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (n + j + 1)); + for (i = 0, psdpp = xf86SbusInfo; i < 32; i++) + if (devicePtrs[i]) { + if (devicePtrs[i]->fbNum == -1) { + memmove(psdpp + 1, psdpp, sizeof(psdpp) * (n + 1)); + *psdpp = devicePtrs[i]; + } else + n--; + } +} + +static char * +promGetReg(int type) +{ + char *prop; + int len; + static char regstr[40]; + + regstr[0] = 0; + prop = promGetProperty("reg", &len); + if (prop && len >= 4) { + unsigned int *reg = (unsigned int *)prop; + if (!promP1275 || (type == PROM_NODE_SBUS) || (type == PROM_NODE_EBUS)) + sprintf (regstr, "@%x,%x", reg[0], reg[1]); + else if (type == PROM_NODE_PCI) { + if ((reg[0] >> 8) & 7) + sprintf (regstr, "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7); + else + sprintf (regstr, "@%x", (reg[0] >> 11) & 0x1f); + } else if (len == 4) + sprintf (regstr, "@%x", reg[0]); + else { + unsigned int regs[2]; + + /* Things get more complicated on UPA. If upa-portid exists, + then address is @upa-portid,second-int-in-reg, otherwise + it is @first-int-in-reg/16,second-int-in-reg (well, probably + upa-portid always exists, but just to be safe). */ + memcpy (regs, reg, sizeof(regs)); + prop = promGetProperty("upa-portid", &len); + if (prop && len == 4) { + reg = (unsigned int *)prop; + sprintf (regstr, "@%x,%x", reg[0], regs[1]); + } else + sprintf (regstr, "@%x,%x", regs[0] >> 4, regs[1]); + } + } + return regstr; +} + +static int +promWalkNode2Pathname(char *path, int parent, int node, int searchNode, int type) +{ + int nextnode; + int len, ntype = type; + char *prop, *p; + + prop = promGetProperty("name", &len); + *path = '/'; + if (!prop || len <= 0) + return 0; + if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type) + ntype = PROM_NODE_SBUS; + else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI) + ntype = PROM_NODE_EBUS; + else if (!strcmp(prop, "pci") && !type) + ntype = PROM_NODE_PCI; + strcpy (path + 1, prop); + p = promGetReg(type); + if (*p) + strcat (path, p); + if (node == searchNode) + return 1; + nextnode = promGetChild(node); + if (nextnode && + promWalkNode2Pathname(strchr(path, 0), node, nextnode, searchNode, ntype)) + return 1; + nextnode = promGetSibling(node); + if (nextnode && + promWalkNode2Pathname(path, parent, nextnode, searchNode, type)) + return 1; + return 0; +} + +char * +sparcPromNode2Pathname(sbusPromNodePtr pnode) +{ + char *ret; + + if (!pnode->node) return NULL; + ret = xalloc(4096); + if (!ret) return NULL; + if (promWalkNode2Pathname(ret, promRootNode, promGetChild(promRootNode), pnode->node, 0)) + return ret; + xfree(ret); + return NULL; +} + +static int +promWalkPathname2Node(char *name, char *regstr, int parent, int type) +{ + int len, node, ret; + char *prop, *p; + + for (;;) { + prop = promGetProperty("name", &len); + if (!prop || len <= 0) + return 0; + if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type) + type = PROM_NODE_SBUS; + else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI) + type = PROM_NODE_EBUS; + else if (!strcmp(prop, "pci") && !type) + type = PROM_NODE_PCI; + for (node = promGetChild(parent); node; node = promGetSibling(node)) { + prop = promGetProperty("name", &len); + if (!prop || len <= 0) + continue; + if (*name && strcmp(name, prop)) + continue; + if (*regstr) { + p = promGetReg(type); + if (! *p || strcmp(p + 1, regstr)) + continue; + } + break; + } + if (!node) { + for (node = promGetChild(parent); node; node = promGetSibling(node)) { + ret = promWalkPathname2Node(name, regstr, node, type); + if (ret) return ret; + } + return 0; + } + name = strchr(regstr, 0) + 1; + if (! *name) + return node; + p = strchr(name, '/'); + if (p) + *p = 0; + else + p = strchr(name, 0); + regstr = strchr(name, '@'); + if (regstr) + *regstr++ = 0; + else + regstr = p; + if (name == regstr) + return 0; + parent = node; + } +} + +int +sparcPromPathname2Node(const char *pathName) +{ + int i; + char *name, *regstr, *p; + + i = strlen(pathName); + name = xalloc(i + 2); + if (! name) return 0; + strcpy (name, pathName); + name [i + 1] = 0; + if (name[0] != '/') + return 0; + p = strchr(name + 1, '/'); + if (p) + *p = 0; + else + p = strchr(name, 0); + regstr = strchr(name, '@'); + if (regstr) + *regstr++ = 0; + else + regstr = p; + if (name + 1 == regstr) + return 0; + promGetSibling(0); + i = promWalkPathname2Node(name + 1, regstr, promRootNode, 0); + xfree(name); + return i; +} + +_X_EXPORT pointer +xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size) +{ + pointer ret; + unsigned long pagemask = getpagesize() - 1; + unsigned long off = offset & ~pagemask; + unsigned long len = ((offset + size + pagemask) & ~pagemask) - off; + + if (psdp->fd == -1) { + psdp->fd = open(psdp->device, O_RDWR); + if (psdp->fd == -1) + return NULL; + } else if (psdp->fd < 0) + return NULL; + + ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, + psdp->fd, off); + if (ret == (pointer) -1) { + ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, + psdp->fd, off); + } + if (ret == (pointer) -1) + return NULL; + + return (char *)ret + (offset - off); +} + +_X_EXPORT void +xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size) +{ + unsigned long mask = getpagesize() - 1; + unsigned long base = (unsigned long)addr & ~mask; + unsigned long len = (((unsigned long)addr + size + mask) & ~mask) - base; + + munmap ((pointer)base, len); +} + +/* Tell OS that we are driving the HW cursor ourselves. */ +_X_EXPORT void +xf86SbusHideOsHwCursor(sbusDevicePtr psdp) +{ + struct fbcursor fbcursor; + unsigned char zeros[8]; + + memset(&fbcursor, 0, sizeof(fbcursor)); + memset(&zeros, 0, sizeof(zeros)); + fbcursor.cmap.count = 2; + fbcursor.cmap.red = zeros; + fbcursor.cmap.green = zeros; + fbcursor.cmap.blue = zeros; + fbcursor.image = (char *)zeros; + fbcursor.mask = (char *)zeros; + fbcursor.size.x = 32; + fbcursor.size.y = 1; + fbcursor.set = FB_CUR_SETALL; + ioctl(psdp->fd, FBIOSCURSOR, &fbcursor); +} + +/* Set HW cursor colormap. */ +_X_EXPORT void +xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg, int fg) +{ + struct fbcursor fbcursor; + unsigned char red[2], green[2], blue[2]; + + memset(&fbcursor, 0, sizeof(fbcursor)); + red[0] = bg >> 16; + green[0] = bg >> 8; + blue[0] = bg; + red[1] = fg >> 16; + green[1] = fg >> 8; + blue[1] = fg; + fbcursor.cmap.count = 2; + fbcursor.cmap.red = red; + fbcursor.cmap.green = green; + fbcursor.cmap.blue = blue; + fbcursor.set = FB_CUR_SETCMAP; + ioctl(psdp->fd, FBIOSCURSOR, &fbcursor); +} diff --git a/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c b/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c new file mode 100644 index 000000000..57ad09b6a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/bsd_pci.c @@ -0,0 +1,86 @@ +/* + * Copyright © 2007 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt <eric@anholt.net> + * + */ + +/** + * @file bsd_pci.c + * + * This is a trivial implementation of the remaining PCI support hooks in the + * X Server that is unaware of domains. + * + * Most of even this should go away once drivers are converted and the + * old interfaces are confirmed to all be obsolete. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "Pci.h" + +#include "pciaccess.h" + +static pciBusFuncs_t bsd_funcs = { + .pciAddrBusToHost = pciAddrNOOP, +}; + +static pciBusInfo_t bsd_pci = { + .configMech = PCI_CFG_MECH_OTHER, + .numDevices = 32, + .secondary = FALSE, + .primary_bus = 0, + .funcs = &bsd_funcs, + .pciBusPriv = NULL, + .bridge = NULL, +}; + +_X_EXPORT pointer +xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, + ADDRESS Base, unsigned long Size) +{ + return xf86MapVidMem(ScreenNum, Flags, Base, Size); +} + +IOADDRESS +xf86MapLegacyIO(struct pci_device *dev) +{ + (void)dev; + return 0; +} + +void +bsdPciInit(void) +{ + pciNumBuses = 1; + pciBusInfo[0] = &bsd_pci; + + xf86InitVidMem(); +} diff --git a/xorg-server/hw/xfree86/os-support/bus/ix86Pci.c b/xorg-server/hw/xfree86/os-support/bus/ix86Pci.c new file mode 100644 index 000000000..e54246355 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/ix86Pci.c @@ -0,0 +1,718 @@ +/* + * ix86Pci.c - x86 PCI driver + * + * The XFree86 server PCI access functions have been reimplemented as a + * framework that allows each supported platform/OS to have their own + * platform/OS specific PCI driver. + * + * Most of the code of these functions was simply lifted from the + * Intel architecture specifric portion of the original Xfree86 + * PCI code in hw/xfree86/common_hw/xf86_PCI.C... + * + * Gary Barton + * Concurrent Computer Corporation + * garyb@gate.net + */ + +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This software is derived from the original XFree86 PCI code + * which includes the following copyright notices as well: + * + * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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. + * + * This code is also based heavily on the code in FreeBSD-current, which was + * written by Wolfgang Stanglmeier, and contains the following copyright: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "Pci.h" + +#ifdef PC98 +#define outb(port,data) _outb(port,data) +#define outl(port,data) _outl(port,data) +#define inb(port) _inb(port) +#define inl(port) _inl(port) +#endif + +#define PCI_CFGMECH2_ENABLE_REG 0xCF8 +#ifdef PC98 +#define PCI_CFGMECH2_FORWARD_REG 0xCF9 +#else +#define PCI_CFGMECH2_FORWARD_REG 0xCFA +#endif + +#define PCI_CFGMECH2_MAXDEV 16 + +#define PCI_ADDR_FROM_TAG_CFG1(tag,reg) (PCI_EN | tag | (reg & 0xfc)) +#define PCI_FORWARD_FROM_TAG(tag) PCI_BUS_FROM_TAG(tag) +#define PCI_ENABLE_FROM_TAG(tag) (0xf0 | (((tag) & 0x00000700) >> 7)) +#define PCI_ADDR_FROM_TAG_CFG2(tag,reg) (0xc000 | (((tag) & 0x0000f800) >> 3) \ + | (reg & 0xfc)) + +/* + * Intel x86 platform specific PCI access functions + */ +#if 0 +static CARD32 ix86PciReadLongSetup(PCITAG tag, int off); +static void ix86PciWriteLongSetup(PCITAG, int off, CARD32 val); +static void ix86PciSetBitsLongSetup(PCITAG, int off, CARD32 mask, CARD32 val); +static CARD32 ix86PciReadLongCFG1(PCITAG tag, int off); +static void ix86PciWriteLongCFG1(PCITAG, int off, CARD32 val); +static void ix86PciSetBitsLongCFG1(PCITAG, int off, CARD32 mask, CARD32 val); +static CARD32 ix86PciReadLongCFG2(PCITAG tag, int off); +static void ix86PciWriteLongCFG2(PCITAG, int off, CARD32 val); +static void ix86PciSetBitsLongCFG2(PCITAG, int off, CARD32 mask, CARD32 val); +#endif + +static pciBusFuncs_t ix86Funcs0 = { +#if 0 +/* pciReadLong */ ix86PciReadLongSetup, +/* pciWriteLong */ ix86PciWriteLongSetup, +/* pciSetBitsLong */ ix86PciSetBitsLongSetup, +/* pciAddrHostToBus */ pciAddrNOOP, +#endif +/* pciAddrBusToHost */ pciAddrNOOP +}; + +static pciBusFuncs_t ix86Funcs1 = { +#if 0 +/* pciReadLong */ ix86PciReadLongCFG1, +/* pciWriteLong */ ix86PciWriteLongCFG1, +/* pciSetBitsLong */ ix86PciSetBitsLongCFG1, +/* pciAddrHostToBus */ pciAddrNOOP, +#endif +/* pciAddrBusToHost */ pciAddrNOOP +}; + +static pciBusFuncs_t ix86Funcs2 = { +#if 0 +/* pciReadLong */ ix86PciReadLongCFG2, +/* pciWriteLong */ ix86PciWriteLongCFG2, +/* pciSetBitsLong */ ix86PciSetBitsLongCFG2, +/* pciAddrHostToBus */ pciAddrNOOP, +#endif +/* pciAddrBusToHost */ pciAddrNOOP +}; + +static pciBusInfo_t ix86Pci0 = { +/* configMech */ PCI_CFG_MECH_UNKNOWN, /* Set by ix86PciInit() */ +/* numDevices */ 0, /* Set by ix86PciInit() */ +/* secondary */ FALSE, +/* primary_bus */ 0, +/* funcs */ &ix86Funcs0, /* Set by ix86PciInit() */ +/* pciBusPriv */ NULL, +/* bridge */ NULL +}; + +_X_EXPORT pointer +xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, + ADDRESS Base, unsigned long Size) +{ + return xf86MapVidMem(ScreenNum, Flags, Base, Size); +} + +IOADDRESS +xf86MapLegacyIO(struct pci_device *dev) +{ + (void)dev; + return 0; +} + +static Bool +ix86PciBusCheck(void) +{ +#if 0 + PCITAG tag; + CARD32 id, class; + CARD8 device; + + for (device = 0; device < ix86Pci0.numDevices; device++) { + tag = PCI_MAKE_TAG(0, device, 0); + id = (*ix86Pci0.funcs->pciReadLong)(tag, PCI_ID_REG); + + if ((CARD16)(id + 1U) <= (CARD16)1UL) + continue; + + /* The rest of this is inspired by the Linux kernel */ + class = (*ix86Pci0.funcs->pciReadLong)(tag, PCI_CLASS_REG); + + /* Ignore revision id and programming interface */ + switch (class >> 16) { + case (PCI_CLASS_PREHISTORIC << 8) | PCI_SUBCLASS_PREHISTORIC_MISC: + /* Check for vendors of known buggy chipsets */ + id &= 0x0000ffff; + if ((id == PCI_VENDOR_INTEL) || (id == PCI_VENDOR_COMPAQ)) + return TRUE; + continue; + + case (PCI_CLASS_PREHISTORIC << 8) | PCI_SUBCLASS_PREHISTORIC_VGA: + case (PCI_CLASS_DISPLAY << 8) | PCI_SUBCLASS_DISPLAY_VGA: + case (PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_HOST: + return TRUE; + + default: + break; + } + } +#endif + return FALSE; +} + +static +void ix86PciSelectCfgmech(void) +{ + static Bool beenhere = FALSE; + CARD32 mode1Res1 = 0, mode1Res2 = 0, oldVal1 = 0; + CARD8 mode2Res1 = 0, mode2Res2 = 0, oldVal2 = 0; + int stages = 0; + + if (beenhere) + return; /* Been there, done that */ + + beenhere = TRUE; + + /* + * Determine if motherboard chipset supports PCI Config Mech 1 or 2 + * We rely on xf86Info.pciFlags to tell which mechanisms to try.... + */ + switch (xf86Info.pciFlags) { + case PCIOsConfig: + case PCIProbe1: + if (!xf86EnableIO()) + return; + + xf86MsgVerb(X_INFO, 2, + "PCI: Probing config type using method 1\n"); + oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("Checking config type 1:\n" + "\tinitial value of MODE1_ADDR_REG is 0x%08x\n", oldVal1); + ErrorF("\tChecking that all bits in mask 0x7f000000 are clear\n"); + } +#endif + + /* Assuming config type 1 to start with */ + if ((oldVal1 & 0x7f000000) == 0) { + + stages |= 0x01; + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tValue indicates possibly config type 1\n"); + ErrorF("\tWriting 32-bit value 0x%08x to MODE1_ADDR_REG\n", PCI_EN); +#if 0 + ErrorF("\tWriting 8-bit value 0x00 to MODE1_ADDR_REG + 3\n"); +#endif + } +#endif + + ix86Pci0.configMech = PCI_CFG_MECH_1; + ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; + ix86Pci0.funcs = &ix86Funcs1; + + outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN); + +#if 0 + /* + * This seems to cause some Neptune-based PCI machines to switch + * from config type 1 to config type 2 + */ + outb(PCI_CFGMECH1_ADDRESS_REG + 3, 0); +#endif + mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG); + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n", + mode1Res1); + ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n"); + } +#endif + + outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); + + if (mode1Res1) { + + stages |= 0x02; + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tValue read back is non-zero, and indicates possible" + " config type 1\n"); + } +#endif + + if (ix86PciBusCheck()) { + +#ifdef DEBUGPCI + if (xf86Verbose > 2) + ErrorF("\tBus check Confirms this: "); +#endif + + xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); + xf86MsgVerb(X_INFO, 3, + "PCI: stages = 0x%02x, oldVal1 = 0x%08lx, mode1Res1" + " = 0x%08lx\n", stages, (unsigned long)oldVal1, + (unsigned long)mode1Res1); + return; + } + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tBus check fails to confirm this, continuing type 1" + " check ...\n"); + } +#endif + + } + + stages |= 0x04; + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tWriting 0xff000001 to MODE1_ADDR_REG\n"); + } +#endif + outl(PCI_CFGMECH1_ADDRESS_REG, 0xff000001); + mode1Res2 = inl(PCI_CFGMECH1_ADDRESS_REG); + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n", + mode1Res2); + ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n"); + } +#endif + + outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); + + if ((mode1Res2 & 0x80000001) == 0x80000000) { + + stages |= 0x08; + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tValue read back has only the msb set\n" + "\tThis indicates possible config type 1\n"); + } +#endif + + if (ix86PciBusCheck()) { + +#ifdef DEBUGPCI + if (xf86Verbose > 2) + ErrorF("\tBus check Confirms this: "); +#endif + + xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); + xf86MsgVerb(X_INFO, 3, + "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" + "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", + stages, (unsigned long)oldVal1, + (unsigned long)mode1Res1, (unsigned long)mode1Res2); + return; + } + +#ifdef DEBUGPCI + if (xf86Verbose > 2) { + ErrorF("\tBus check fails to confirm this.\n"); + } +#endif + + } + } + + xf86MsgVerb(X_INFO, 3, "PCI: Standard check for type 1 failed.\n"); + xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" + "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", + stages, (unsigned long)oldVal1, (unsigned long)mode1Res1, + (unsigned long)mode1Res2); + + /* Try config type 2 */ + oldVal2 = inb(PCI_CFGMECH2_ENABLE_REG); + if ((oldVal2 & 0xf0) == 0) { + ix86Pci0.configMech = PCI_CFG_MECH_2; + ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; + ix86Pci0.funcs = &ix86Funcs2; + + outb(PCI_CFGMECH2_ENABLE_REG, 0x0e); + mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG); + outb(PCI_CFGMECH2_ENABLE_REG, oldVal2); + + if (mode2Res1 == 0x0e) { + if (ix86PciBusCheck()) { + xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n"); + return; + } + } + } + break; /* } */ + + case PCIProbe2: /* { */ + if (!xf86EnableIO()) + return; + + /* The scanpci-style detection method */ + + xf86MsgVerb(X_INFO, 2, "PCI: Probing config type using method 2\n"); + + outb(PCI_CFGMECH2_ENABLE_REG, 0x00); + outb(PCI_CFGMECH2_FORWARD_REG, 0x00); + mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG); + mode2Res2 = inb(PCI_CFGMECH2_FORWARD_REG); + + if (mode2Res1 == 0 && mode2Res2 == 0) { + xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n"); + ix86Pci0.configMech = PCI_CFG_MECH_2; + ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; + ix86Pci0.funcs = &ix86Funcs2; + return; + } + + oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); + outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN); + mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG); + outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); + if (mode1Res1 == PCI_EN) { + xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); + ix86Pci0.configMech = PCI_CFG_MECH_1; + ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; + ix86Pci0.funcs = &ix86Funcs1; + return; + } + break; /* } */ + + case PCIForceConfig1: + if (!xf86EnableIO()) + return; + + xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 1\n"); + + ix86Pci0.configMech = PCI_CFG_MECH_1; + ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; + ix86Pci0.funcs = &ix86Funcs1; + return; + + case PCIForceConfig2: + if (!xf86EnableIO()) + return; + + xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 2\n"); + + ix86Pci0.configMech = PCI_CFG_MECH_2; + ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; + ix86Pci0.funcs = &ix86Funcs2; + return; + + case PCIForceNone: + break; + } + + /* No PCI found */ + ix86Pci0.configMech = PCI_CFG_MECH_UNKNOWN; + xf86MsgVerb(X_INFO, 2, "PCI: No PCI bus found or probed for\n"); +} + +#if 0 +static pciTagRec +ix86PcibusTag(CARD8 bus, CARD8 cardnum, CARD8 func) +{ + pciTagRec tag; + + tag.cfg1 = 0; + + if (func > 7 || cardnum >= pciBusInfo[bus]->numDevices) + return tag; + + switch (ix86Pci0.configMech) { + case PCI_CFG_MECH_1: + tag.cfg1 = PCI_EN | ((CARD32)bus << 16) | + ((CARD32)cardnum << 11) | + ((CARD32)func << 8); + break; + + case PCI_CFG_MECH_2: + tag.cfg2.port = 0xc000 | ((CARD16)cardnum << 8); + tag.cfg2.enable = 0xf0 | (func << 1); + tag.cfg2.forward = bus; + break; + } + + return tag; +} +#endif + +#if 0 +static CARD32 +ix86PciReadLongSetup(PCITAG Tag, int reg) +{ + ix86PciSelectCfgmech(); + return (*ix86Pci0.funcs->pciReadLong)(Tag,reg); +} + +static CARD32 +ix86PciReadLongCFG1(PCITAG Tag, int reg) +{ + CARD32 addr, data = 0; + +#ifdef DEBUGPCI + ErrorF("ix86PciReadLong 0x%lx, %d\n", Tag, reg); +#endif + + addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg); + outl(PCI_CFGMECH1_ADDRESS_REG, addr); + data = inl(PCI_CFGMECH1_DATA_REG); + outl(PCI_CFGMECH1_ADDRESS_REG, 0); + +#ifdef DEBUGPCI + ErrorF("ix86PciReadLong 0x%lx\n", data); +#endif + + return data; +} + +static CARD32 +ix86PciReadLongCFG2(PCITAG Tag, int reg) +{ + CARD32 addr, data = 0; + CARD8 forward, enable; + +#ifdef DEBUGPCI + ErrorF("ix86PciReadLong 0x%lx, %d\n", Tag, reg); +#endif + + forward = PCI_FORWARD_FROM_TAG(Tag); + enable = PCI_ENABLE_FROM_TAG(Tag); + addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg); + + outb(PCI_CFGMECH2_ENABLE_REG, enable); + outb(PCI_CFGMECH2_FORWARD_REG, forward); + data = inl((CARD16)addr); + outb(PCI_CFGMECH2_ENABLE_REG, 0); + outb(PCI_CFGMECH2_FORWARD_REG, 0); + +#ifdef DEBUGPCI + ErrorF("ix86PciReadLong 0x%lx\n", data); +#endif + + return data; +} + +static void +ix86PciWriteLongSetup(PCITAG Tag, int reg, CARD32 data) +{ + ix86PciSelectCfgmech(); + (*ix86Pci0.funcs->pciWriteLong)(Tag,reg,data); +} + +static void +ix86PciWriteLongCFG1(PCITAG Tag, int reg, CARD32 data) +{ + CARD32 addr; + + addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg); + outl(PCI_CFGMECH1_ADDRESS_REG, addr); + outl(PCI_CFGMECH1_DATA_REG, data); + outl(PCI_CFGMECH1_ADDRESS_REG, 0); +} + +static void +ix86PciWriteLongCFG2(PCITAG Tag, int reg, CARD32 data) +{ + CARD32 addr; + CARD8 forward, enable; + + forward = PCI_FORWARD_FROM_TAG(Tag); + enable = PCI_ENABLE_FROM_TAG(Tag); + addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg); + + outb(PCI_CFGMECH2_ENABLE_REG, enable); + outb(PCI_CFGMECH2_FORWARD_REG, forward); + outl((CARD16)addr, data); + outb(PCI_CFGMECH2_ENABLE_REG, 0); + outb(PCI_CFGMECH2_FORWARD_REG, 0); +} + +static void +ix86PciSetBitsLongSetup(PCITAG Tag, int reg, CARD32 mask, CARD32 val) +{ + ix86PciSelectCfgmech(); + (*ix86Pci0.funcs->pciSetBitsLong)(Tag,reg,mask,val); +} + +static void +ix86PciSetBitsLongCFG1(PCITAG Tag, int reg, CARD32 mask, CARD32 val) +{ + CARD32 addr, data = 0; + +#ifdef DEBUGPCI + ErrorF("ix86PciSetBitsLong 0x%lx, %d\n", Tag, reg); +#endif + + addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg); + outl(PCI_CFGMECH1_ADDRESS_REG, addr); + data = inl(PCI_CFGMECH1_DATA_REG); + data = (data & ~mask) | (val & mask); + outl(PCI_CFGMECH1_DATA_REG, data); + outl(PCI_CFGMECH1_ADDRESS_REG, 0); +} + +static void +ix86PciSetBitsLongCFG2(PCITAG Tag, int reg, CARD32 mask, CARD32 val) +{ + CARD32 addr, data = 0; + CARD8 enable, forward; + +#ifdef DEBUGPCI + ErrorF("ix86PciSetBitsLong 0x%lx, %d\n", Tag, reg); +#endif + + forward = PCI_FORWARD_FROM_TAG(Tag); + enable = PCI_ENABLE_FROM_TAG(Tag); + addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg); + + outb(PCI_CFGMECH2_ENABLE_REG, enable); + outb(PCI_CFGMECH2_FORWARD_REG, forward); + data = inl((CARD16)addr); + data = (data & ~mask) | (val & mask); + outl((CARD16)addr, data); + outb(PCI_CFGMECH2_ENABLE_REG, 0); + outb(PCI_CFGMECH2_FORWARD_REG, 0); +} +#endif + +void +ix86PciInit() +{ + /* Initialize pciBusInfo[] array and function pointers */ + pciNumBuses = 1; + pciBusInfo[0] = &ix86Pci0; + + /* Make sure that there is a PCI bus present. */ + ix86PciSelectCfgmech(); + if (ix86Pci0.configMech == PCI_CFG_MECH_UNKNOWN) { + pciNumBuses = 0; + pciBusInfo[0] = NULL; + } +} diff --git a/xorg-server/hw/xfree86/os-support/bus/linuxPci.c b/xorg-server/hw/xfree86/os-support/bus/linuxPci.c new file mode 100644 index 000000000..11eb4f9e8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/linuxPci.c @@ -0,0 +1,606 @@ +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "Pci.h" +#include <dirent.h> + +/* + * linux platform specific PCI access functions -- using /proc/bus/pci + * needs kernel version 2.2.x + */ +static ADDRESS linuxTransAddrBusToHost(PCITAG tag, PciAddrType type, ADDRESS addr); +#if defined(__powerpc__) +static ADDRESS linuxPpcBusAddrToHostAddr(PCITAG, PciAddrType, ADDRESS); +#endif + +static pciBusFuncs_t linuxFuncs0 = { +#if defined(__powerpc__) +/* pciAddrBusToHost */ linuxPpcBusAddrToHostAddr, +#else +/* linuxTransAddrBusToHost is busted on sparc64 but the PCI rework tree + * makes it all moot, so we kludge it for now */ +#if defined(__sparc__) +/* pciAddrBusToHost */ pciAddrNOOP, +#else +/* pciAddrBusToHost */ linuxTransAddrBusToHost, +#endif /* __sparc64__ */ +#endif +}; + +static pciBusInfo_t linuxPci0 = { +/* configMech */ PCI_CFG_MECH_OTHER, +/* numDevices */ 32, +/* secondary */ FALSE, +/* primary_bus */ 0, +/* funcs */ &linuxFuncs0, +/* pciBusPriv */ NULL, +/* bridge */ NULL +}; + +static const struct pci_id_match match_host_bridge = { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_HOST << 8), + 0x0000ffff00, 0 +}; + +#ifndef INCLUDE_XF86_NO_DOMAIN +#define MAX_DOMAINS 257 +static pointer DomainMmappedIO[MAX_DOMAINS]; +#endif + +void +linuxPciInit(void) +{ + struct stat st; + +#ifndef INCLUDE_XF86_NO_DOMAIN + (void) memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO)); +#endif + + if ((xf86Info.pciFlags == PCIForceNone) || + (-1 == stat("/proc/bus/pci", &st))) { + /* when using this as default for all linux architectures, + we'll need a fallback for 2.0 kernels here */ + return; + } + pciNumBuses = 1; + pciBusInfo[0] = &linuxPci0; +} + +/** + * \bug + * The generation of the procfs file name for the domain != 0 case may not be + * correct. + */ +static int +linuxPciOpenFile(struct pci_device *dev, Bool write) +{ + static struct pci_device *last_dev = NULL; + static int fd = -1,is_write = 0; + char file[64]; + struct stat ignored; + static int is26 = -1; + + if (dev == NULL) { + return -1; + } + + if (is26 == -1) { + is26 = (stat("/sys/bus/pci", &ignored) < 0) ? 0 : 1; + } + + if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) { + if (fd != -1) { + close(fd); + fd = -1; + } + + if (is26) { + sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config", + dev->domain, dev->bus, dev->dev, dev->func); + } else { + if (dev->domain == 0) { + sprintf(file,"/proc/bus/pci/%02x", dev->bus); + if (stat(file, &ignored) < 0) { + sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x", + dev->bus, dev->dev, dev->func); + } else { + sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", + dev->bus, dev->dev, dev->func); + } + } else { + sprintf(file,"/proc/bus/pci/%02x%02x", dev->domain, dev->bus); + if (stat(file, &ignored) < 0) { + sprintf(file, "/proc/bus/pci/%04x:%04x/%02x.%1x", + dev->domain, dev->bus, dev->dev, dev->func); + } else { + sprintf(file, "/proc/bus/pci/%02x%02x/%02x.%1x", + dev->domain, dev->bus, dev->dev, dev->func); + } + } + } + + if (write) { + fd = open(file,O_RDWR); + if (fd != -1) is_write = TRUE; + } else { + switch (is_write) { + case TRUE: + fd = open(file,O_RDWR); + if (fd > -1) + break; + default: + fd = open(file,O_RDONLY); + is_write = FALSE; + } + } + + last_dev = dev; + } + + return fd; +} + +/* + * This function will convert a BAR address into a host address + * suitable for passing into the mmap function of a /proc/bus + * device. + */ +ADDRESS linuxTransAddrBusToHost(PCITAG tag, PciAddrType type, ADDRESS addr) +{ + ADDRESS ret = xf86GetOSOffsetFromPCI(tag, PCI_MEM|PCI_IO, addr); + + if (ret) + return ret; + + /* + * if it is not a BAR address, it must be legacy, (or wrong) + * return it as is.. + */ + return addr; +} + + +#if defined(__powerpc__) + +#ifndef __NR_pciconfig_iobase +#define __NR_pciconfig_iobase 200 +#endif + +static ADDRESS +linuxPpcBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr) +{ + if (type == PCI_MEM) + { + ADDRESS membase = syscall(__NR_pciconfig_iobase, 1, + PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag)); + return (addr + membase); + } + else if (type == PCI_IO) + { + ADDRESS iobase = syscall(__NR_pciconfig_iobase, 2, + PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag)); + return (addr + iobase); + } + else return addr; +} + +#endif /* __powerpc__ */ + +#ifndef INCLUDE_XF86_NO_DOMAIN + +/* + * Compiling the following simply requires the presence of <linux/pci.c>. + * Actually running this is another matter altogether... + * + * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O + * and memory spaces through its /proc/bus/pci/BUS/DFN entry. Which one is + * determined by a prior ioctl(). + * + * For the sparc64 port, this means 2.4.12 or later. For ppc, this + * functionality is almost, but not quite there yet. Alpha and other kernel + * ports to multi-domain architectures still need to implement this. + * + * This scheme is also predicated on the use of an IOADDRESS compatible type to + * designate I/O addresses. Although IOADDRESS is defined as an unsigned + * integral type, it is actually the virtual address of, i.e. a pointer to, the + * I/O port to access. And so, the inX/outX macros in "compiler.h" need to be + * #define'd appropriately (as is done on SPARC's). + * + * Another requirement to port this scheme to another multi-domain architecture + * is to add the appropriate entries in the pciControllerSizes array below. + * + * TO DO: Address the deleterious reaction some host bridges have to master + * aborts. This is already done for secondary PCI buses, but not yet + * for accesses to primary buses (except for the SPARC port, where + * master aborts are avoided during PCI scans). + */ + +#include <linux/pci.h> + +#ifndef PCIIOC_BASE /* Ioctls for /proc/bus/pci/X/Y nodes. */ +#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8) + +/* Get controller for PCI device. */ +#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) +/* Set mmap state to I/O space. */ +#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) +/* Set mmap state to MEM space. */ +#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) +/* Enable/disable write-combining. */ +#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) + +#endif + +/* This probably shouldn't be Linux-specific */ +static struct pci_device * +get_parent_bridge(struct pci_device *dev) +{ + struct pci_id_match bridge_match = { + PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, + (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8), + 0 + }; + struct pci_device *bridge; + struct pci_device_iterator *iter; + + if (dev == NULL) { + return NULL; + } + + iter = pci_id_match_iterator_create(& bridge_match); + if (iter == NULL) { + return NULL; + } + + while ((bridge = pci_device_next(iter)) != NULL) { + if (bridge->domain == dev->domain) { + const struct pci_bridge_info *info = + pci_device_get_bridge_info(bridge); + + if (info != NULL) { + if (info->secondary_bus == dev->bus) { + break; + } + } + } + } + + pci_iterator_destroy(iter); + + return bridge; +} + +/* + * This is ugly, but until I can extract this information from the kernel, + * it'll have to do. The default I/O space size is 64K, and 4G for memory. + * Anything else needs to go in this table. (PowerPC folk take note.) + * + * Note that Linux/SPARC userland is 32-bit, so 4G overflows to zero here. + * + * Please keep this table in ascending vendor/device order. + */ +static const struct pciSizes { + unsigned short vendor, device; + unsigned long io_size, mem_size; +} pciControllerSizes[] = { + { + PCI_VENDOR_SUN, PCI_CHIP_PSYCHO, + 1U << 16, 1U << 31 + }, + { + PCI_VENDOR_SUN, PCI_CHIP_SCHIZO, + 1U << 24, 1U << 31 /* ??? */ + }, + { + PCI_VENDOR_SUN, PCI_CHIP_SABRE, + 1U << 24, (unsigned long)(1ULL << 32) + }, + { + PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD, + 1U << 24, (unsigned long)(1ULL << 32) + } +}; +#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0])) + +static const struct pciSizes * +linuxGetSizesStruct(const struct pci_device *dev) +{ + static const struct pciSizes default_size = { + 0, 0, 1U << 16, (unsigned long)(1ULL << 32) + }; + int i; + + /* Look up vendor/device */ + if (dev != NULL) { + for (i = 0; i < NUM_SIZES; i++) { + if ((dev->vendor_id == pciControllerSizes[i].vendor) + && (dev->device_id == pciControllerSizes[i].device)) { + return & pciControllerSizes[i]; + } + } + } + + /* Default to 64KB I/O and 4GB memory. */ + return & default_size; +} + +static __inline__ unsigned long +linuxGetIOSize(const struct pci_device *dev) +{ + const struct pciSizes * const sizes = linuxGetSizesStruct(dev); + return sizes->io_size; +} + +static pointer +linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev, + ADDRESS Base, unsigned long Size, int mmap_ioctl) +{ + /* Align to page boundary */ + const ADDRESS realBase = Base & ~(getpagesize() - 1); + const ADDRESS Offset = Base - realBase; + + do { + unsigned char *result; + int fd, mmapflags, prot; + + xf86InitVidMem(); + + /* If dev is NULL, linuxPciOpenFile will return -1, and this routine + * will fail gracefully. + */ + prot = ((Flags & VIDMEM_READONLY) == 0); + if (((fd = linuxPciOpenFile(dev, prot)) < 0) || + (ioctl(fd, mmap_ioctl, 0) < 0)) + break; + +/* Note: IA-64 doesn't compile this and doesn't need to */ +#ifdef __ia64__ + +# ifndef MAP_WRITECOMBINED +# define MAP_WRITECOMBINED 0x00010000 +# endif +# ifndef MAP_NONCACHED +# define MAP_NONCACHED 0x00020000 +# endif + + if (Flags & VIDMEM_FRAMEBUFFER) + mmapflags = MAP_SHARED | MAP_WRITECOMBINED; + else + mmapflags = MAP_SHARED | MAP_NONCACHED; + +#else /* !__ia64__ */ + + mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER; + + if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0) + break; + + mmapflags = MAP_SHARED; + +#endif /* ?__ia64__ */ + + + if (Flags & VIDMEM_READONLY) + prot = PROT_READ; + else + prot = PROT_READ | PROT_WRITE; + + result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase); + + if (!result || ((pointer)result == MAP_FAILED)) + return NULL; + + xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result); + + return result + Offset; + } while (0); + + if (mmap_ioctl == PCIIOC_MMAP_IS_MEM) + return xf86MapVidMem(ScreenNum, Flags, Base, Size); + + return NULL; +} + +static int +linuxOpenLegacy(struct pci_device *dev, char *name) +{ + static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s"; + char path[sizeof(PREFIX) + 10]; + int fd = -1; + + while (dev != NULL) { + snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name); + fd = open(path, O_RDWR); + if (fd >= 0) { + return fd; + } + + dev = get_parent_bridge(dev); + } + + return fd; +} + +/* + * xf86MapDomainMemory - memory map PCI domain memory + * + * This routine maps the memory region in the domain specified by Tag and + * returns a pointer to it. The pointer is saved for future use if it's in + * the legacy ISA memory space (memory in a domain between 0 and 1MB). + */ +_X_EXPORT pointer +xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, + ADDRESS Base, unsigned long Size) +{ + int fd = -1; + pointer addr; + + /* + * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs + * legacy_mem interface is unavailable. + */ + if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0)) + return linuxMapPci(ScreenNum, Flags, dev, Base, Size, + PCIIOC_MMAP_IS_MEM); + else + addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); + + if (fd >= 0) + close(fd); + if (addr == NULL || addr == MAP_FAILED) { + perror("mmap failure"); + FatalError("xf86MapDomainMem(): mmap() failure\n"); + } + return addr; +} + +/** + * Map I/O space in this domain + * + * Each domain has a legacy ISA I/O space. This routine will try to + * map it using the Linux sysfs legacy_io interface. If that fails, + * it'll fall back to using /proc/bus/pci. + * + * If the legacy_io interface \b does exist, the file descriptor (\c fd below) + * will be saved in the \c DomainMmappedIO array in the upper bits of the + * pointer. Callers will do I/O with small port numbers (<64k values), so + * the platform I/O code can extract the port number and the \c fd, \c lseek + * to the port number in the legacy_io file, and issue the read or write. + * + * This has no means of returning failure, so all errors are fatal + */ +IOADDRESS +xf86MapLegacyIO(struct pci_device *dev) +{ + const int domain = dev->domain; + struct pci_device *bridge = get_parent_bridge(dev); + int fd; + + if (domain >= MAX_DOMAINS) + FatalError("xf86MapLegacyIO(): domain out of range\n"); + + if (DomainMmappedIO[domain] == NULL) { + /* Permanently map all of I/O space */ + fd = linuxOpenLegacy(bridge, "legacy_io"); + if (fd < 0) { + DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge, + 0, linuxGetIOSize(bridge), + PCIIOC_MMAP_IS_IO); + } + else { /* legacy_io file exists, encode fd */ + DomainMmappedIO[domain] = (pointer)(fd << 24); + } + } + + return (IOADDRESS)DomainMmappedIO[domain]; +} + +resPtr +xf86AccResFromOS(resPtr pRes) +{ + struct pci_device *dev; + struct pci_device_iterator *iter; + resRange range; + + iter = pci_id_match_iterator_create(& match_host_bridge); + while ((dev = pci_device_next(iter)) != NULL) { + const int domain = dev->domain; + const struct pciSizes * const sizes = linuxGetSizesStruct(dev); + + /* + * At minimum, the top and bottom resources must be claimed, so + * that resources that are (or appear to be) unallocated can be + * relocated. + */ + RANGE(range, 0x00000000u, 0x0009ffffu, + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + RANGE(range, 0x000c0000u, 0x000effffu, + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + RANGE(range, 0x000f0000u, 0x000fffffu, + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + + RANGE(range, (ADDRESS)(sizes->mem_size - 1), + (ADDRESS)(sizes->mem_size - 1), + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + + RANGE(range, 0x00000000u, 0x00000000u, + RANGE_TYPE(ResExcIoBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + RANGE(range, (IOADDRESS)(sizes->io_size - 1), + (IOADDRESS)(sizes->io_size - 1), + RANGE_TYPE(ResExcIoBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + + /* FIXME: The old code reserved domain 0 for a special purpose. The + * FIXME: new code just uses whatever domains the kernel tells it, + * FIXME: but there is no way to get a domain < 0. What should + * FIXME: happen here? + * + if (domain <= 0) + break; + */ + } + + pci_iterator_destroy(iter); + + return pRes; +} + +#endif /* !INCLUDE_XF86_NO_DOMAIN */ diff --git a/xorg-server/hw/xfree86/os-support/bus/ppcPci.c b/xorg-server/hw/xfree86/os-support/bus/ppcPci.c new file mode 100644 index 000000000..49c1a2a39 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/ppcPci.c @@ -0,0 +1,82 @@ +/* + * ppcPci.c - PowerPC PCI access functions + * + * PCI driver functions supporting Motorola PowerPC platforms + * including Powerstack(RiscPC/RiscPC+), PowerStackII, MTX, and + * MVME 160x/260x/360x/460x VME boards + * + * Gary Barton + * Concurrent Computer Corporation + * garyb@gate.net + * + */ + +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "Pci.h" + +#ifndef MAP_FAILED +#define MAP_FAILED (pointer)(-1) +#endif + +void +ppcPciInit() +{ + + static void motoppcPciInit(void); + motoppcPciInit(); + +} diff --git a/xorg-server/hw/xfree86/os-support/bus/sparcPci.c b/xorg-server/hw/xfree86/os-support/bus/sparcPci.c new file mode 100644 index 000000000..2d8039c29 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/sparcPci.c @@ -0,0 +1,979 @@ +/* + * Copyright (C) 2001-2003 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "Pci.h" +#include "xf86sbusBus.h" + +#if defined(sun) + +extern char *apertureDevName; +static int apertureFd = -1; + +/* + * A version of xf86MapVidMem() that allows for 64-bit displacements (but not + * sizes). Areas thus mapped can be unmapped by xf86UnMapVidMem(). + */ +static pointer +sparcMapAperture(int iScreen, int Flags, + unsigned long long Base, unsigned long Size) +{ + pointer result; + static int lastFlags = 0; + + /* Assume both Base & Size are multiples of the page size */ + + if ((apertureFd < 0) || (Flags != lastFlags)) { + if (apertureFd >= 0) + close(apertureFd); + lastFlags = Flags; + apertureFd = open(apertureDevName, + (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (apertureFd < 0) + FatalError("sparcMapAperture: open failure: %s\n", + strerror(errno)); + } + + result = mmap(NULL, Size, + (Flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, apertureFd, (off_t)Base); + + if (result == MAP_FAILED) + FatalError("sparcMapAperture: mmap failure: %s\n", strerror(errno)); + + return result; +} + +/* + * Platform-specific bus privates. + */ +typedef struct _sparcDomainRec { + unsigned long long io_addr, io_size; + unsigned long long mem_addr, mem_size; + pointer pci, io; + int bus_min, bus_max; + unsigned char dfn_mask[256 / 8]; +} sparcDomainRec, *sparcDomainPtr; + +#define SetBitInMap(bit, map) \ + do { \ + int _bit = (bit); \ + (map)[_bit >> 3] |= 1 << (_bit & 7); \ + } while (0) + +#define IsBitSetInMap(bit, map) \ + ((map)[(bit) >> 3] & (1 << ((bit) & 7))) + +/* + * Domain 0 is reserved for the one that represents the system as a whole, i.e. + * the one without any resource relocations. + */ +#define MAX_DOMAINS (MAX_PCI_BUSES / 256) +static sparcDomainPtr xf86DomainInfo[MAX_DOMAINS]; +static int pciNumDomains = 1; + +/* Variables that are assigned this must be declared volatile */ +#define PciReg(base, tag, off, type) \ + *(volatile type *)(pointer)((char *)(base) + \ + (PCI_TAG_NO_DOMAIN(tag) | (off))) + +/* Generic SPARC PCI access functions */ +static CARD32 +sparcPciCfgRead32(PCITAG tag, int off) +{ + pciBusInfo_t *pBusInfo; + sparcDomainPtr pDomain; + volatile CARD32 result = (CARD32)(-1); /* Must be volatile */ + int bus; + + if ((off >= 0) && (off <= 252) && !(off & 3) && + ((bus = PCI_BUS_FROM_TAG(tag)) < pciNumBuses) && + (pBusInfo = pciBusInfo[bus]) && (pDomain = pBusInfo->pciBusPriv) && + (bus >= pDomain->bus_min) && (bus < pDomain->bus_max) && + ((bus > pDomain->bus_min) || + IsBitSetInMap(PCI_DFN_FROM_TAG(tag), pDomain->dfn_mask))) { + result = PciReg(pDomain->pci, tag, off, CARD32); + + result = PCI_CPU(result); + } + + return result; +} + +static void +sparcPciCfgWrite32(PCITAG tag, int off, CARD32 val) +{ + pciBusInfo_t *pBusInfo; + sparcDomainPtr pDomain; + int bus; + + if ((off < 0) || (off > 252) || (off & 3) || + ((bus = PCI_BUS_FROM_TAG(tag)) >= pciNumBuses) || + !(pBusInfo = pciBusInfo[bus]) || !(pDomain = pBusInfo->pciBusPriv) || + (bus < pDomain->bus_min) || (bus >= pDomain->bus_max) || + ((bus == pDomain->bus_min) && + !IsBitSetInMap(PCI_DFN_FROM_TAG(tag), pDomain->dfn_mask))) + return; + + val = PCI_CPU(val); + PciReg(pDomain->pci, tag, off, CARD32) = val; +} + +static void +sparcPciCfgSetBits32(PCITAG tag, int off, CARD32 mask, CARD32 bits) +{ + CARD32 PciVal; + + PciVal = sparcPciCfgRead32(tag, off); + PciVal &= ~mask; + PciVal |= bits; + sparcPciCfgWrite32(tag, off, PciVal); +} + +static pciBusFuncs_t sparcPCIFunctions = +{ + sparcPciCfgRead32, + sparcPciCfgWrite32, + sparcPciCfgSetBits32, + pciAddrNOOP, + pciAddrNOOP +}; + +/* + * Sabre-specific versions of the above because of its peculiar access size + * requirements. + */ +static CARD32 +sabrePciCfgRead32(PCITAG tag, int off) +{ + pciBusInfo_t *pBusInfo; + sparcDomainPtr pDomain; + volatile CARD32 result; /* Must be volatile */ + int bus; + + if (PCI_BDEV_FROM_TAG(tag)) + return sparcPciCfgRead32(tag, off); + + if (PCI_FUNC_FROM_TAG(tag) || (off < 0) || (off > 252) || (off & 3) || + ((bus = PCI_BUS_FROM_TAG(tag)) >= pciNumBuses) || + !(pBusInfo = pciBusInfo[bus]) || !(pDomain = pBusInfo->pciBusPriv) || + (bus != pDomain->bus_min)) + return (CARD32)(-1); + + if (off < 8) { + result = (PciReg(pDomain->pci, tag, off, CARD16) << 16) | + PciReg(pDomain->pci, tag, off + 2, CARD16); + return PCI_CPU(result); + } + + result = (PciReg(pDomain->pci, tag, off + 3, CARD8) << 24) | + (PciReg(pDomain->pci, tag, off + 2, CARD8) << 16) | + (PciReg(pDomain->pci, tag, off + 1, CARD8) << 8) | + (PciReg(pDomain->pci, tag, off , CARD8) ); + return result; +} + +static void +sabrePciCfgWrite32(PCITAG tag, int off, CARD32 val) +{ + pciBusInfo_t *pBusInfo; + sparcDomainPtr pDomain; + int bus; + + if (PCI_BDEV_FROM_TAG(tag)) + sparcPciCfgWrite32(tag, off, val); + else if (!PCI_FUNC_FROM_TAG(tag) && + (off >= 0) && (off <= 252) && !(off & 3) && + ((bus = PCI_BUS_FROM_TAG(tag)) < pciNumBuses) && + (pBusInfo = pciBusInfo[bus]) && + (pDomain = pBusInfo->pciBusPriv) && + (bus == pDomain->bus_min)) { + if (off < 8) { + val = PCI_CPU(val); + PciReg(pDomain->pci, tag, off , CARD16) = val >> 16; + PciReg(pDomain->pci, tag, off + 2, CARD16) = val; + } else { + PciReg(pDomain->pci, tag, off , CARD8) = val; + PciReg(pDomain->pci, tag, off + 1, CARD8) = val >> 8; + PciReg(pDomain->pci, tag, off + 2, CARD8) = val >> 16; + PciReg(pDomain->pci, tag, off + 3, CARD8) = val >> 24; + } + } +} + +static void +sabrePciCfgSetBits32(PCITAG tag, int off, CARD32 mask, CARD32 bits) +{ + CARD32 PciVal; + + PciVal = sabrePciCfgRead32(tag, off); + PciVal &= ~mask; + PciVal |= bits; + sabrePciCfgWrite32(tag, off, PciVal); +} + +static pciBusFuncs_t sabrePCIFunctions = +{ + sabrePciCfgRead32, + sabrePciCfgWrite32, + sabrePciCfgSetBits32, + pciAddrNOOP, + pciAddrNOOP +}; + +static int pagemask; + +/* Scan PROM for all PCI host bridges in the system */ +void +sparcPciInit(void) +{ + int node, node2; + + if (!xf86LinearVidMem()) + return; + + apertureFd = open(apertureDevName, O_RDWR); + if (apertureFd < 0) { + xf86Msg(X_ERROR, + "sparcPciInit: open failure: %s\n", strerror(errno)); + return; + } + + sparcPromInit(); + pagemask = getpagesize() - 1; + + for (node = promGetChild(promRootNode); + node; + node = promGetSibling(node)) { + unsigned long long pci_addr; + sparcDomainRec domain; + sparcDomainPtr pDomain; + pciBusFuncs_p pFunctions; + char *prop_val; + int prop_len, bus; + + prop_val = promGetProperty("name", &prop_len); + /* Some PROMs include the trailing null; some don't */ + if (!prop_val || (prop_len < 3) || (prop_len > 4) || + strcmp(prop_val, "pci")) + continue; + + prop_val = promGetProperty("model", &prop_len); + if (!prop_val || (prop_len <= 0)) { + prop_val = promGetProperty("compatible", &prop_len); + if (!prop_val || (prop_len <= 0)) + continue; + } + + pFunctions = &sparcPCIFunctions; + (void)memset(&domain, 0, sizeof(domain)); + + if (!strncmp("SUNW,sabre", prop_val, prop_len) || + !strncmp("pci108e,a000", prop_val, prop_len) || + !strncmp("pci108e,a001", prop_val, prop_len)) { + /* + * There can only be one "Sabre" bridge in a system. It provides + * PCI configuration space, a 24-bit I/O space and a 32-bit memory + * space, all three of which are at fixed physical CPU addresses. + */ + static Bool sabre_seen = FALSE; + + xf86Msg(X_INFO, + "Sabre or Hummingbird PCI host bridge found (\"%s\")\n", + prop_val); + + /* There can only be one Sabre */ + if (sabre_seen) + continue; + sabre_seen = TRUE; + + /* Get "bus-range" property */ + prop_val = promGetProperty("bus-range", &prop_len); + if (!prop_val || (prop_len != 8) || + (((unsigned int *)prop_val)[0]) || + (((unsigned int *)prop_val)[1] >= 256)) + continue; + + pci_addr = 0x01fe01000000ull; + domain.io_addr = 0x01fe02000000ull; + domain.io_size = 0x000001000000ull; + domain.mem_addr = 0x01ff00000000ull; + domain.mem_size = 0x000100000000ull; + domain.bus_min = 0; /* Always */ + domain.bus_max = ((int *)prop_val)[1]; + + pFunctions = &sabrePCIFunctions; + } else + if (!strncmp("SUNW,psycho", prop_val, prop_len) || + !strncmp("pci108e,8000", prop_val, prop_len)) { + /* + * A "Psycho" host bridge provides two PCI interfaces, each with + * its own 16-bit I/O and 31-bit memory spaces. Both share the + * same PCI configuration space. Here, they are assigned separate + * domain numbers to prevent unintentional I/O and/or memory + * resource conflicts. + */ + xf86Msg(X_INFO, + "Psycho PCI host bridge found (\"%s\")\n", prop_val); + + /* Get "bus-range" property */ + prop_val = promGetProperty("bus-range", &prop_len); + if (!prop_val || (prop_len != 8) || + (((unsigned int *)prop_val)[1] >= 256) || + (((unsigned int *)prop_val)[0] > ((unsigned int *)prop_val)[1])) + continue; + + domain.bus_min = ((int *)prop_val)[0]; + domain.bus_max = ((int *)prop_val)[1]; + + /* Get "ranges" property */ + prop_val = promGetProperty("ranges", &prop_len); + if (!prop_val || (prop_len != 112) || + prop_val[0] || (prop_val[28] != 0x01u) || + (prop_val[56] != 0x02u) || (prop_val[84] != 0x03u) || + (((unsigned int *)prop_val)[4] != 0x01000000u) || + ((unsigned int *)prop_val)[5] || + ((unsigned int *)prop_val)[12] || + (((unsigned int *)prop_val)[13] != 0x00010000u) || + ((unsigned int *)prop_val)[19] || + (((unsigned int *)prop_val)[20] != 0x80000000u) || + ((((unsigned int *)prop_val)[11] & ~0x00010000u) != + 0x02000000u) || + (((unsigned int *)prop_val)[18] & ~0x80000000u) || + (((unsigned int *)prop_val)[3] != + ((unsigned int *)prop_val)[10]) || + (((unsigned int *)prop_val)[17] != + ((unsigned int *)prop_val)[24]) || + (((unsigned int *)prop_val)[18] != + ((unsigned int *)prop_val)[25]) || + (((unsigned int *)prop_val)[19] != + ((unsigned int *)prop_val)[26]) || + (((unsigned int *)prop_val)[20] != + ((unsigned int *)prop_val)[27])) + continue; + + /* Use memcpy() to avoid alignment issues */ + (void)memcpy(&pci_addr, prop_val + 12, + sizeof(pci_addr)); + (void)memcpy(&domain.io_addr, prop_val + 40, + sizeof(domain.io_addr)); + (void)memcpy(&domain.mem_addr, prop_val + 68, + sizeof(domain.mem_addr)); + + domain.io_size = 0x000000010000ull; + domain.mem_size = 0x000080000000ull; + } else + if (!strncmp("SUNW,schizo", prop_val, prop_len) || + !strncmp("pci108e,8001", prop_val, prop_len)) { + /* + * I have no docs on the "Schizo", but judging from the Linux + * kernel, it also provides two PCI domains. Each PCI + * configuration space is the usual 16M in size, followed by a + * variable-length I/O space. Each domain also provides a + * variable-length memory space. The kernel seems to think the I/O + * spaces are 16M long, and the memory spaces, 2G, but these + * assumptions are actually only present in source code comments. + * Sun has, however, confirmed to me the validity of these + * assumptions. + */ + volatile unsigned long long mem_match, mem_mask, io_match, io_mask; + unsigned long Offset; + pointer pSchizo; + + xf86Msg(X_INFO, + "Schizo PCI host bridge found (\"%s\")\n", prop_val); + + /* Get "bus-range" property */ + prop_val = promGetProperty("bus-range", &prop_len); + if (!prop_val || (prop_len != 8) || + (((unsigned int *)prop_val)[1] >= 256) || + (((unsigned int *)prop_val)[0] > ((unsigned int *)prop_val)[1])) + continue; + + domain.bus_min = ((int *)prop_val)[0]; + domain.bus_max = ((int *)prop_val)[1]; + + /* Get "reg" property */ + prop_val = promGetProperty("reg", &prop_len); + if (!prop_val || (prop_len != 48)) + continue; + + /* Temporarily map some of Schizo's registers */ + pSchizo = sparcMapAperture(-1, VIDMEM_MMIO, + ((unsigned long long *)prop_val)[2] - 0x000000010000ull, + 0x00010000ul); + + /* Determine where PCI config, I/O and memory spaces reside */ + if ((((unsigned long long *)prop_val)[0] & 0x000000700000ull) == + 0x000000600000ull) + Offset = 0x0040; + else + Offset = 0x0060; + + mem_match = PciReg(pSchizo, 0, Offset, unsigned long long); + mem_mask = PciReg(pSchizo, 0, Offset + 8, unsigned long long); + io_match = PciReg(pSchizo, 0, Offset + 16, unsigned long long); + io_mask = PciReg(pSchizo, 0, Offset + 24, unsigned long long); + + /* Unmap Schizo registers */ + xf86UnMapVidMem(-1, pSchizo, 0x00010000ul); + + /* Calculate sizes */ + mem_mask = (((mem_mask - 1) ^ mem_mask) >> 1) + 1; + io_mask = (((io_mask - 1) ^ io_mask ) >> 1) + 1; + + if (io_mask <= 0x000001000000ull) /* Nothing left for I/O */ + continue; + + domain.mem_addr = mem_match & ~0x8000000000000000ull; + domain.mem_size = mem_mask; + pci_addr = io_match & ~0x8000000000000000ull; + domain.io_addr = pci_addr + 0x0000000001000000ull; + domain.io_size = io_mask - 0x0000000001000000ull; + } else { + xf86Msg(X_WARNING, "Unknown PCI host bridge: \"%s\"\n", prop_val); + continue; + } + + /* Only map as much PCI configuration as we need */ + domain.pci = (char *)sparcMapAperture(-1, VIDMEM_MMIO, + pci_addr + PCI_MAKE_TAG(domain.bus_min, 0, 0), + PCI_MAKE_TAG(domain.bus_max - domain.bus_min + 1, 0, 0)) - + PCI_MAKE_TAG(domain.bus_min, 0, 0); + + /* Allocate a domain record */ + pDomain = xnfalloc(sizeof(sparcDomainRec)); + *pDomain = domain; + + /* + * Allocate and prime pciBusInfo records. These are allocated one at a + * time because those for empty buses are eventually released. + */ + bus = pDomain->bus_min = + PCI_MAKE_BUS(pciNumDomains, domain.bus_min); + pciNumBuses = pDomain->bus_max = + PCI_MAKE_BUS(pciNumDomains, domain.bus_max) + 1; + + pciBusInfo[bus] = xnfcalloc(1, sizeof(pciBusInfo_t)); + pciBusInfo[bus]->configMech = PCI_CFG_MECH_OTHER; + pciBusInfo[bus]->numDevices = 32; + pciBusInfo[bus]->funcs = pFunctions; + pciBusInfo[bus]->pciBusPriv = pDomain; + while (++bus < pciNumBuses) { + pciBusInfo[bus] = xnfalloc(sizeof(pciBusInfo_t)); + *(pciBusInfo[bus]) = *(pciBusInfo[bus - 1]); + pciBusInfo[bus]->funcs = &sparcPCIFunctions; + } + + /* Next domain, please... */ + xf86DomainInfo[pciNumDomains++] = pDomain; + + /* + * OK, enough of the straight-forward stuff. Time to deal with some + * brokenness... + * + * The PCI specs require that when a bus transaction remains unclaimed + * for too long, the master entity on that bus is to cancel the + * transaction it issued or passed on with a master abort. Two + * outcomes are possible: + * + * - the master abort can be treated as an error that is propogated + * back through the bus tree to the entity that ultimately originated + * the transaction; or + * - the transaction can be allowed to complete normally, which means + * that writes are ignored and reads return all ones. + * + * In the first case, if the CPU happens to be at the tail end of the + * tree path through one of its host bridges, it will be told there is + * a hardware mal-function, despite being generated by software. + * + * For a software function (be it firmware, OS or userland application) + * to determine how a PCI bus tree is populated, it must be able to + * detect when master aborts occur. Obviously, PCI discovery is much + * simpler when master aborts are allowed to complete normally. + * + * Unfortunately, a number of non-Intel PCI implementations have chosen + * to treat master aborts as severe errors. The net effect is to + * cripple PCI discovery algorithms in userland. + * + * On SPARCs, master aborts cause a number of different behaviours, + * including delivering a signal to the userland application, rebooting + * the system, "dropping down" to firmware, or, worst of all, bus + * lockouts. Even in the first case, the SIGBUS signal that is + * eventually generated isn't delivered in a timely enough fashion to + * allow an application to reliably detect the master abort that + * ultimately caused it. + * + * This can be somewhat mitigated. On all architectures, master aborts + * that occur on secondary buses can be forced to complete normally + * because the PCI-to-PCI bridges that serve them are governed by an + * industry-wide specification. (This is just another way of saying + * that whatever justification there might be for erroring out master + * aborts is deemed by the industry as insufficient to generate more + * PCI non-compliance than there already is...) + * + * This leaves us with master aborts that occur on primary buses. + * There is no specification for host-to-PCI bridges. Bridges used in + * SPARCs can be told to ignore all PCI errors, but not specifically + * master aborts. Not only is this too coarse-grained, but + * master-aborted read transactions on the primary bus end up returning + * garbage rather than all ones. + * + * I have elected to work around this the only way I can think of doing + * so right now. The following scans an additional PROM level and + * builds a device/function map for the primary bus. I can only hope + * this PROM information represents all devices on the primary bus, + * rather than only a subset of them. + * + * Master aborts are useful in other ways too, that are not addressed + * here. These include determining whether or not a domain provides + * VGA, or if a PCI device actually implements PCI disablement. + * + * --- TSI @ UQV 2001.09.19 + */ + for (node2 = promGetChild(node); + node2; + node2 = promGetSibling(node2)) { + /* Get "reg" property */ + prop_val = promGetProperty("reg", &prop_len); + if (!prop_val || (prop_len % 20)) + continue; + + /* + * It's unnecessary to scan the entire "reg" property, but I'll do + * so anyway. + */ + prop_len /= 20; + for (; prop_len--; prop_val += 20) + SetBitInMap(PCI_DFN_FROM_TAG(*(PCITAG *)prop_val), + pDomain->dfn_mask); + } + + /* Assume the host bridge is device 0, function 0 on its bus */ + SetBitInMap(0, pDomain->dfn_mask); + } + + sparcPromClose(); + + close(apertureFd); + apertureFd = -1; +} + +#ifndef INCLUDE_XF86_NO_DOMAIN + +_X_EXPORT int +xf86GetPciDomain(PCITAG Tag) +{ + return PCI_DOM_FROM_TAG(Tag); +} + +_X_EXPORT pointer +xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, + ADDRESS Base, unsigned long Size) +{ + sparcDomainPtr pDomain; + pointer result; + int domain = PCI_DOM_FROM_TAG(Tag); + + if ((domain <= 0) || (domain >= pciNumDomains) || + !(pDomain = xf86DomainInfo[domain]) || + (((unsigned long long)Base + (unsigned long long)Size) > + pDomain->mem_size)) + FatalError("xf86MapDomainMemory() called with invalid parameters.\n"); + + result = sparcMapAperture(ScreenNum, Flags, pDomain->mem_addr + Base, Size); + + if (apertureFd >= 0) { + close(apertureFd); + apertureFd = -1; + } + + return result; +} + +_X_EXPORT IOADDRESS +xf86MapLegacyIO(int ScreenNum, int Flags, PCITAG Tag, + IOADDRESS Base, unsigned long Size) +{ + sparcDomainPtr pDomain; + int domain = PCI_DOM_FROM_TAG(Tag); + + if ((domain <= 0) || (domain >= pciNumDomains) || + !(pDomain = xf86DomainInfo[domain]) || + (((unsigned long long)Base + (unsigned long long)Size) > + pDomain->io_size)) + FatalError("xf86MapLegacyIO() called with invalid parameters.\n"); + + /* Permanently map all of I/O space */ + if (!pDomain->io) { + pDomain->io = sparcMapAperture(ScreenNum, Flags, + pDomain->io_addr, pDomain->io_size); + + if (apertureFd >= 0) { + close(apertureFd); + apertureFd = -1; + } + } + + return (IOADDRESS)pDomain->io + Base; +} + +resPtr +xf86AccResFromOS(resPtr pRes) +{ + sparcDomainPtr pDomain; + resRange range; + int domain; + + for (domain = 1; domain < pciNumDomains; domain++) { + if (!(pDomain = xf86DomainInfo[domain])) + continue; + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ + RANGE(range, 0x00000000u, 0x0009ffffu, + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + RANGE(range, 0x000c0000u, 0x000effffu, + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + RANGE(range, 0x000f0000u, 0x000fffffu, + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + + RANGE(range, pDomain->mem_size - 1, pDomain->mem_size - 1, + RANGE_TYPE(ResExcMemBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + + RANGE(range, 0x00000000u, 0x00000000u, + RANGE_TYPE(ResExcIoBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + RANGE(range, pDomain->io_size - 1, pDomain->io_size - 1, + RANGE_TYPE(ResExcIoBlock, domain)); + pRes = xf86AddResToList(pRes, &range, -1); + } + + return pRes; +} + +#endif /* !INCLUDE_XF86_NO_DOMAIN */ + +#endif /* defined(sun) */ + +#if defined(ARCH_PCI_PCI_BRIDGE) + +/* Definitions specific to Sun's APB P2P bridge (a.k.a. Simba) */ +#define APB_IO_ADDRESS_MAP 0xDE +#define APB_MEM_ADDRESS_MAP 0xDF + +/* + * Simba's can only occur on bus 0. Furthermore, Simba's must have a non-zero + * device/function number because the Sabre interface they must connect to + * occupies the 0:0:0 slot. Also, there can be only one Sabre interface in the + * system, and therefore, only one Simba function can route any particular + * resource. Thus, it is appropriate to use a single set of static variables + * to hold the tag of the Simba function routing a VGA resource range at any + * one time, and to test these variables for non-zero to determine whether or + * not the Sabre would master-abort a VGA access (and kill the system). + * + * The trick is to determine when it is safe to re-route VGA, because doing so + * re-routes much more. + */ +static PCITAG simbavgaIOTag = 0, simbavgaMemTag = 0; +static Bool simbavgaRoutingAllow = TRUE; + +/* + * Scan the bus subtree rooted at 'bus' for a non-display device that might be + * decoding the bottom 2 MB of I/O space and/or the bottom 512 MB of memory + * space. Reset simbavgaRoutingAllow if such a device is found. + * + * XXX For now, this is very conservative and should be made less so as the + * need arises. + */ +static void +simbaCheckBus(CARD16 pcicommand, int bus) +{ + pciConfigPtr pPCI, *ppPCI = xf86scanpci(0); + + while ((pPCI = *ppPCI++)) { + if (pPCI->busnum < bus) + continue; + if (pPCI->busnum > bus) + break; + + /* XXX Assume all devices respect PCI disablement */ + if (!(pcicommand & pPCI->pci_command)) + continue; + + /* XXX This doesn't deal with mis-advertised classes */ + switch (pPCI->pci_base_class) { + case PCI_CLASS_PREHISTORIC: + if (pPCI->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA) + continue; /* Ignore VGA */ + break; + + case PCI_CLASS_DISPLAY: + continue; + + case PCI_CLASS_BRIDGE: + switch (pPCI->pci_sub_class) { + case PCI_SUBCLASS_BRIDGE_PCI: + case PCI_SUBCLASS_BRIDGE_CARDBUS: + /* Scan secondary bus */ + /* XXX First check bridge routing? */ + simbaCheckBus(pcicommand & pPCI->pci_command, + PCI_SECONDARY_BUS_EXTRACT(pPCI->pci_pp_bus_register, + pPCI->tag)); + if (!simbavgaRoutingAllow) + return; + + default: + break; + } + + default: + break; + } + + /* + * XXX We could check the device's bases here, but PCI doesn't limit + * the device's decoding to them. + */ + + simbavgaRoutingAllow = FALSE; + break; + } +} + +static pciConfigPtr +simbaVerifyBus(int bus) +{ + pciConfigPtr pPCI; + if ((bus < 0) || (bus >= pciNumBuses) || + !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) || + (pPCI->pci_device_vendor != DEVID(VENDOR_SUN, CHIP_SIMBA))) + return NULL; + + return pPCI; +} + +static CARD16 +simbaControlBridge(int bus, CARD16 mask, CARD16 value) +{ + pciConfigPtr pPCI; + CARD16 current = 0, tmp; + CARD8 iomap, memmap; + + if ((pPCI = simbaVerifyBus(bus))) { + /* + * The Simba does not implement VGA enablement as described in the P2P + * spec. It does however route I/O and memory in large enough chunks + * so that we can determine were VGA resources would be routed + * (including ISA VGA I/O aliases). We can allow changes to that + * routing only under certain circumstances. + */ + iomap = pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP); + memmap = pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP); + if (iomap & memmap & 0x01) { + current |= PCI_PCI_BRIDGE_VGA_EN; + if ((mask & PCI_PCI_BRIDGE_VGA_EN) && + !(value & PCI_PCI_BRIDGE_VGA_EN)) { + if (!simbavgaRoutingAllow) { + xf86MsgVerb(X_WARNING, 3, "Attempt to disable VGA routing" + " through Simba at %x:%x:%x disallowed.\n", + pPCI->busnum, pPCI->devnum, pPCI->funcnum); + value |= PCI_PCI_BRIDGE_VGA_EN; + } else { + pciWriteByte(pPCI->tag, APB_IO_ADDRESS_MAP, + iomap & ~0x01); + pciWriteByte(pPCI->tag, APB_MEM_ADDRESS_MAP, + memmap & ~0x01); + simbavgaIOTag = simbavgaMemTag = 0; + } + } + } else { + if (mask & value & PCI_PCI_BRIDGE_VGA_EN) { + if (!simbavgaRoutingAllow) { + xf86MsgVerb(X_WARNING, 3, "Attempt to enable VGA routing" + " through Simba at %x:%x:%x disallowed.\n", + pPCI->busnum, pPCI->devnum, pPCI->funcnum); + value &= ~PCI_PCI_BRIDGE_VGA_EN; + } else { + if (pPCI->tag != simbavgaIOTag) { + if (simbavgaIOTag) { + tmp = pciReadByte(simbavgaIOTag, + APB_IO_ADDRESS_MAP); + pciWriteByte(simbavgaIOTag, APB_IO_ADDRESS_MAP, + tmp & ~0x01); + } + + pciWriteByte(pPCI->tag, APB_IO_ADDRESS_MAP, + iomap | 0x01); + simbavgaIOTag = pPCI->tag; + } + + if (pPCI->tag != simbavgaMemTag) { + if (simbavgaMemTag) { + tmp = pciReadByte(simbavgaMemTag, + APB_MEM_ADDRESS_MAP); + pciWriteByte(simbavgaMemTag, APB_MEM_ADDRESS_MAP, + tmp & ~0x01); + } + + pciWriteByte(pPCI->tag, APB_MEM_ADDRESS_MAP, + memmap | 0x01); + simbavgaMemTag = pPCI->tag; + } + } + } + } + + /* Move on to master abort failure enablement (as per P2P spec) */ + tmp = pciReadWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG); + current |= tmp; + if (tmp & PCI_PCI_BRIDGE_MASTER_ABORT_EN) { + if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) && + !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)) + pciWriteWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG, + tmp & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN); + } else { + if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN) + pciWriteWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG, + tmp | PCI_PCI_BRIDGE_MASTER_ABORT_EN); + } + + /* Insert emulation of other P2P controls here */ + } + + return (current & ~mask) | (value & mask); +} + +static void +simbaGetBridgeResources(int bus, + pointer *ppIoRes, + pointer *ppMemRes, + pointer *ppPmemRes) +{ + pciConfigPtr pPCI = simbaVerifyBus(bus); + resRange range; + int i; + + if (!pPCI) + return; + + if (ppIoRes) { + xf86FreeResList(*ppIoRes); + *ppIoRes = NULL; + + if (pPCI->pci_command & PCI_CMD_IO_ENABLE) { + unsigned char iomap = pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP); + if (simbavgaRoutingAllow) + iomap |= 0x01; + for (i = 0; i < 8; i++) { + if (iomap & (1 << i)) { + RANGE(range, i << 21, ((i + 1) << 21) - 1, + RANGE_TYPE(ResExcIoBlock, + xf86GetPciDomain(pPCI->tag))); + *ppIoRes = xf86AddResToList(*ppIoRes, &range, -1); + } + } + } + } + + if (ppMemRes) { + xf86FreeResList(*ppMemRes); + *ppMemRes = NULL; + + if (pPCI->pci_command & PCI_CMD_MEM_ENABLE) { + unsigned char memmap = pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP); + if (simbavgaRoutingAllow) + memmap |= 0x01; + for (i = 0; i < 8; i++) { + if (memmap & (1 << i)) { + RANGE(range, i << 29, ((i + 1) << 29) - 1, + RANGE_TYPE(ResExcMemBlock, + xf86GetPciDomain(pPCI->tag))); + *ppMemRes = xf86AddResToList(*ppMemRes, &range, -1); + } + } + } + } + + if (ppPmemRes) { + xf86FreeResList(*ppPmemRes); + *ppPmemRes = NULL; + } +} + +void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI) +{ + static pciBusFuncs_t simbaBusFuncs; + pciBusInfo_t *pBusInfo; + CARD16 pcicommand; + + if (pPCI->pci_device_vendor != DEVID(VENDOR_SUN, CHIP_SIMBA)) + return; + + pBusInfo = pPCI->businfo; + + simbaBusFuncs = *(pBusInfo->funcs); + simbaBusFuncs.pciControlBridge = simbaControlBridge; + simbaBusFuncs.pciGetBridgeResources = simbaGetBridgeResources; + + pBusInfo->funcs = &simbaBusFuncs; + + if (!simbavgaRoutingAllow) + return; + + pcicommand = 0; + + if (pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP) & 0x01) { + pcicommand |= PCI_CMD_IO_ENABLE; + simbavgaIOTag = pPCI->tag; + } + + if (pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP) & 0x01) { + pcicommand |= PCI_CMD_MEM_ENABLE; + simbavgaMemTag = pPCI->tag; + } + + if (!pcicommand) + return; + + simbaCheckBus(pcicommand, + PCI_SECONDARY_BUS_EXTRACT(pPCI->pci_pp_bus_register, pPCI->tag)); +} + +#endif /* defined(ARCH_PCI_PCI_BRIDGE) */ diff --git a/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h new file mode 100644 index 000000000..2b8a4f76b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/xf86Pci.h @@ -0,0 +1,265 @@ +/* + * Copyright 1998 by Concurrent Computer Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Concurrent Computer + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Concurrent Computer Corporation makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * + * This file is derived in part from the original xf86_PCI.h that included + * following copyright message: + * + * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holder(s) + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holder(s) make(s) no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* + * This file contains just the public interface to the PCI code. + * Drivers should use this file rather than Pci.h. + */ + +#ifndef _XF86PCI_H +#define _XF86PCI_H 1 +#include <X11/Xarch.h> +#include <X11/Xfuncproto.h> +#include "misc.h" +#include <pciaccess.h> + +/* + * PCI cfg space definitions (e.g. stuff right out of the PCI spec) + */ + +/* Device identification register */ +#define PCI_ID_REG 0x00 + +/* Command and status register */ +#define PCI_CMD_STAT_REG 0x04 +#define PCI_CMD_BASE_REG 0x10 +#define PCI_CMD_BIOS_REG 0x30 +#define PCI_CMD_MASK 0xffff +#define PCI_CMD_IO_ENABLE 0x01 +#define PCI_CMD_MEM_ENABLE 0x02 +#define PCI_CMD_MASTER_ENABLE 0x04 +#define PCI_CMD_SPECIAL_ENABLE 0x08 +#define PCI_CMD_INVALIDATE_ENABLE 0x10 +#define PCI_CMD_PALETTE_ENABLE 0x20 +#define PCI_CMD_PARITY_ENABLE 0x40 +#define PCI_CMD_STEPPING_ENABLE 0x80 +#define PCI_CMD_SERR_ENABLE 0x100 +#define PCI_CMD_BACKTOBACK_ENABLE 0x200 +#define PCI_CMD_BIOS_ENABLE 0x01 + +/* base class */ +#define PCI_CLASS_REG 0x08 +#define PCI_CLASS_MASK 0xff000000 +#define PCI_CLASS_SHIFT 24 +#define PCI_CLASS_EXTRACT(x) \ + (((x) & PCI_CLASS_MASK) >> PCI_CLASS_SHIFT) + +/* base class values */ +#define PCI_CLASS_PREHISTORIC 0x00 +#define PCI_CLASS_MASS_STORAGE 0x01 +#define PCI_CLASS_NETWORK 0x02 +#define PCI_CLASS_DISPLAY 0x03 +#define PCI_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MEMORY 0x05 +#define PCI_CLASS_BRIDGE 0x06 +#define PCI_CLASS_COMMUNICATIONS 0x07 +#define PCI_CLASS_SYSPERIPH 0x08 +#define PCI_CLASS_INPUT 0x09 +#define PCI_CLASS_DOCKING 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIALBUS 0x0c +#define PCI_CLASS_WIRELESS 0x0d +#define PCI_CLASS_I2O 0x0e +#define PCI_CLASS_SATELLITE 0x0f +#define PCI_CLASS_CRYPT 0x10 +#define PCI_CLASS_DATA_ACQUISTION 0x11 +#define PCI_CLASS_UNDEFINED 0xff + +/* sub class */ +#define PCI_SUBCLASS_MASK 0x00ff0000 +#define PCI_SUBCLASS_SHIFT 16 +#define PCI_SUBCLASS_EXTRACT(x) \ + (((x) & PCI_SUBCLASS_MASK) >> PCI_SUBCLASS_SHIFT) + +/* Sub class values */ +/* 0x00 prehistoric subclasses */ +#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00 +#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01 + +/* 0x03 display subclasses */ +#define PCI_SUBCLASS_DISPLAY_VGA 0x00 +#define PCI_SUBCLASS_DISPLAY_XGA 0x01 +#define PCI_SUBCLASS_DISPLAY_MISC 0x80 + +/* 0x04 multimedia subclasses */ +#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00 +#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01 +#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80 + +/* 0x06 bridge subclasses */ +#define PCI_SUBCLASS_BRIDGE_HOST 0x00 +#define PCI_SUBCLASS_BRIDGE_ISA 0x01 +#define PCI_SUBCLASS_BRIDGE_EISA 0x02 +#define PCI_SUBCLASS_BRIDGE_MC 0x03 +#define PCI_SUBCLASS_BRIDGE_PCI 0x04 +#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05 +#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06 +#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07 +#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08 +#define PCI_SUBCLASS_BRIDGE_MISC 0x80 +#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01 + +/* 0x0b processor subclasses */ +#define PCI_SUBCLASS_PROCESSOR_386 0x00 +#define PCI_SUBCLASS_PROCESSOR_486 0x01 +#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02 +#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10 +#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20 +#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30 +#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40 + +/* PCI-PCI bridge mapping registers */ +#define PCI_PCI_BRIDGE_BUS_REG 0x18 +#define PCI_SUBORDINATE_BUS_MASK 0x00ff0000 +#define PCI_SECONDARY_BUS_MASK 0x0000ff00 +#define PCI_PRIMARY_BUS_MASK 0x000000ff + +#define PCI_PCI_BRIDGE_IO_REG 0x1c +#define PCI_PCI_BRIDGE_MEM_REG 0x20 +#define PCI_PCI_BRIDGE_PMEM_REG 0x24 + +#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E +#define PCI_PCI_BRIDGE_PARITY_EN 0x01 +#define PCI_PCI_BRIDGE_SERR_EN 0x02 +#define PCI_PCI_BRIDGE_ISA_EN 0x04 +#define PCI_PCI_BRIDGE_VGA_EN 0x08 +#define PCI_PCI_BRIDGE_MASTER_ABORT_EN 0x20 +#define PCI_PCI_BRIDGE_SECONDARY_RESET 0x40 +#define PCI_PCI_BRIDGE_FAST_B2B_EN 0x80 + +/* Subsystem identification register */ +#define PCI_SUBSYSTEM_ID_REG 0x2c + +/* User defined cfg space regs */ +#define PCI_REG_USERCONFIG 0x40 +#define PCI_OPTION_REG 0x40 + +/* + * Typedefs, etc... + */ + +/* Primitive Types */ +typedef unsigned long ADDRESS; /* Memory/PCI address */ +typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */ +typedef unsigned long PCITAG; + +typedef enum { + PCI_MEM, + PCI_MEM_SIZE, + PCI_MEM_SPARSE_BASE, + PCI_MEM_SPARSE_MASK, + PCI_IO, + PCI_IO_SIZE, + PCI_IO_SPARSE_BASE, + PCI_IO_SPARSE_MASK +} PciAddrType; + + +/* Public PCI access functions */ +ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr); +PCITAG pciTag(int busnum, int devnum, int funcnum); +Bool xf86scanpci(void); + +extern int pciNumBuses; + +/* Domain access functions. Some of these probably shouldn't be public */ +pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, + ADDRESS Base, unsigned long Size); +IOADDRESS xf86MapLegacyIO(struct pci_device *dev); + +#endif /* _XF86PCI_H */ diff --git a/xorg-server/hw/xfree86/os-support/bus/xf86Sbus.h b/xorg-server/hw/xfree86/os-support/bus/xf86Sbus.h new file mode 100644 index 000000000..cff5e808a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bus/xf86Sbus.h @@ -0,0 +1,69 @@ +/* + * Platform specific SBUS and OpenPROM access declarations. + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * 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 + * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _XF86_SBUS_H +#define _XF86_SBUS_H + +#if defined(linux) +#include <asm/types.h> +#include <linux/fb.h> +#include <asm/fbio.h> +#include <asm/openpromio.h> +#elif defined(SVR4) +#include <sys/fbio.h> +#include <sys/openpromio.h> +#elif defined(__OpenBSD__) && defined(__sparc64__) +/* XXX */ +#elif defined(CSRG_BASED) +#if defined(__FreeBSD__) +#include <sys/types.h> +#include <sys/fbio.h> +#include <dev/ofw/openpromio.h> +#else +#include <machine/fbio.h> +#endif +#else +#include <sun/fbio.h> +#endif + +#ifndef FBTYPE_SUNGP3 +#define FBTYPE_SUNGP3 -1 +#endif +#ifndef FBTYPE_MDICOLOR +#define FBTYPE_MDICOLOR -1 +#endif +#ifndef FBTYPE_SUNLEO +#define FBTYPE_SUNLEO -1 +#endif +#ifndef FBTYPE_TCXCOLOR +#define FBTYPE_TCXCOLOR -1 +#endif +#ifndef FBTYPE_CREATOR +#define FBTYPE_CREATOR -1 +#endif + +#endif /* _XF86_SBUS_H */ diff --git a/xorg-server/hw/xfree86/os-support/hurd/Makefile.am b/xorg-server/hw/xfree86/os-support/hurd/Makefile.am new file mode 100644 index 000000000..2214b1c2d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/hurd/Makefile.am @@ -0,0 +1,15 @@ +noinst_LTLIBRARIES = libhurd.la + +libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \ + hurd_mouse.c hurd_video.c \ + $(srcdir)/../shared/VTsw_noop.c \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/stdResource.c \ + $(srcdir)/../shared/sigiostubs.c \ + $(srcdir)/../shared/pm_noop.c \ + $(srcdir)/../shared/kmod_noop.c \ + $(srcdir)/../shared/agp_noop.c + +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) + +INCLUDES = $(XORG_INCS) diff --git a/xorg-server/hw/xfree86/os-support/hurd/Makefile.in b/xorg-server/hw/xfree86/os-support/hurd/Makefile.in new file mode 100644 index 000000000..4f7be3e1e --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/hurd/Makefile.in @@ -0,0 +1,715 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/hurd +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libhurd_la_LIBADD = +am_libhurd_la_OBJECTS = hurd_bell.lo hurd_init.lo hurd_mmap.lo \ + hurd_mouse.lo hurd_video.lo VTsw_noop.lo posix_tty.lo \ + stdResource.lo sigiostubs.lo pm_noop.lo kmod_noop.lo \ + agp_noop.lo +libhurd_la_OBJECTS = $(am_libhurd_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libhurd_la_SOURCES) +DIST_SOURCES = $(libhurd_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LTLIBRARIES = libhurd.la +libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \ + hurd_mouse.c hurd_video.c \ + $(srcdir)/../shared/VTsw_noop.c \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/stdResource.c \ + $(srcdir)/../shared/sigiostubs.c \ + $(srcdir)/../shared/pm_noop.c \ + $(srcdir)/../shared/kmod_noop.c \ + $(srcdir)/../shared/agp_noop.c + +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) +INCLUDES = $(XORG_INCS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/hurd/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/hurd/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libhurd.la: $(libhurd_la_OBJECTS) $(libhurd_la_DEPENDENCIES) + $(LINK) $(libhurd_la_OBJECTS) $(libhurd_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VTsw_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agp_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hurd_bell.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hurd_init.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hurd_mmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hurd_mouse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hurd_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kmod_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pm_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix_tty.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigiostubs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdResource.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +VTsw_noop.lo: $(srcdir)/../shared/VTsw_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT VTsw_noop.lo -MD -MP -MF $(DEPDIR)/VTsw_noop.Tpo -c -o VTsw_noop.lo `test -f '$(srcdir)/../shared/VTsw_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/VTsw_noop.Tpo $(DEPDIR)/VTsw_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/VTsw_noop.c' object='VTsw_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o VTsw_noop.lo `test -f '$(srcdir)/../shared/VTsw_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_noop.c + +posix_tty.lo: $(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT posix_tty.lo -MD -MP -MF $(DEPDIR)/posix_tty.Tpo -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/posix_tty.Tpo $(DEPDIR)/posix_tty.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/posix_tty.c' object='posix_tty.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c + +stdResource.lo: $(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdResource.lo -MD -MP -MF $(DEPDIR)/stdResource.Tpo -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/stdResource.Tpo $(DEPDIR)/stdResource.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/stdResource.c' object='stdResource.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c + +sigiostubs.lo: $(srcdir)/../shared/sigiostubs.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sigiostubs.lo -MD -MP -MF $(DEPDIR)/sigiostubs.Tpo -c -o sigiostubs.lo `test -f '$(srcdir)/../shared/sigiostubs.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigiostubs.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sigiostubs.Tpo $(DEPDIR)/sigiostubs.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/sigiostubs.c' object='sigiostubs.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sigiostubs.lo `test -f '$(srcdir)/../shared/sigiostubs.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigiostubs.c + +pm_noop.lo: $(srcdir)/../shared/pm_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pm_noop.lo -MD -MP -MF $(DEPDIR)/pm_noop.Tpo -c -o pm_noop.lo `test -f '$(srcdir)/../shared/pm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/pm_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/pm_noop.Tpo $(DEPDIR)/pm_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/pm_noop.c' object='pm_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pm_noop.lo `test -f '$(srcdir)/../shared/pm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/pm_noop.c + +kmod_noop.lo: $(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kmod_noop.lo -MD -MP -MF $(DEPDIR)/kmod_noop.Tpo -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kmod_noop.Tpo $(DEPDIR)/kmod_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/kmod_noop.c' object='kmod_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c + +agp_noop.lo: $(srcdir)/../shared/agp_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT agp_noop.lo -MD -MP -MF $(DEPDIR)/agp_noop.Tpo -c -o agp_noop.lo `test -f '$(srcdir)/../shared/agp_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/agp_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/agp_noop.Tpo $(DEPDIR)/agp_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/agp_noop.c' object='agp_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o agp_noop.lo `test -f '$(srcdir)/../shared/agp_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/agp_noop.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_bell.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_bell.c new file mode 100644 index 000000000..732a1cadb --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_bell.c @@ -0,0 +1,37 @@ +/* + * Copyright © 2006 Daniel Stone + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Daniel Stone <daniel@fooishbar.org> + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86Priv.h" + +_X_EXPORT void +xf86OSRingBell(int loudness, int pitch, int duration) +{ + return; +} diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_init.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_init.c new file mode 100644 index 000000000..8cd8f54d6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_init.c @@ -0,0 +1,89 @@ +/* + * Copyright 1997,1998 by UCHIYAMA Yasushi + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of UCHIYAMA Yasushi not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. UCHIYAMA Yasushi makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include <stdio.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/file.h> +#include <assert.h> +#include <mach.h> + +int +xf86ProcessArgument( int argc,char **argv, int i ) +{ + return 0; +} +void +xf86UseMsg() +{ + return; +} + + +void +xf86OpenConsole() +{ + if( serverGeneration == 1 ) + { + kern_return_t err; + mach_port_t device; + int fd; + err = get_privileged_ports( NULL, &device ); + if( err ) + { + errno = err; + FatalError( "xf86KbdInit can't get_privileged_ports. (%s)\n" , strerror(errno) ); + } + mach_port_deallocate (mach_task_self (), device); + + if( ( fd = open( "/dev/kbd" , O_RDONLY|O_NONBLOCK ) ) < 0 ) + { + fprintf( stderr , "Cannot open keyboard (%s)\n",strerror(errno) ); + exit(1); + } + xf86Info.consoleFd = fd; + } + return; +} + +void +xf86CloseConsole() +{ + close( xf86Info.consoleFd ); + return; +} diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c new file mode 100644 index 000000000..ccef5f218 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c @@ -0,0 +1,95 @@ +/* + * Copyright 1997 by UCHIYAMA Yasushi + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of UCHIYAMA Yasushi not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. UCHIYAMA Yasushi makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include<mach.h> +#include<device/device.h> +#include<mach/machine/mach_i386.h> + +#include <X11/X.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#define BIOS_SIZE 0x20000 + +int +xf86ReadBIOS(unsigned long Base,unsigned long Offset,unsigned char *Buf,int Len) +{ + mach_port_t device,iopl_dev; + memory_object_t iopl_mem; + vm_address_t addr = (vm_address_t)0; /* serach starting address */ + kern_return_t err; + + + err = get_privileged_ports (NULL, &device); + if( err ) + { + errno = err; + FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",strerror(errno)); + } + err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev); + mach_port_deallocate (mach_task_self (), device); + if( err ) + { + errno = err; + FatalError("xf86ReadBIOS() can't device_open. (%s)\n",strerror(errno)); + } + err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , BIOS_SIZE ,&iopl_mem,0); + if( err ) + { + errno = err; + FatalError("xf86ReadBIOS() can't device_map. (%s)\n",strerror(errno)); + } + err = vm_map(mach_task_self(), + &addr, + BIOS_SIZE, + 0, + TRUE, + iopl_mem, + Base, + FALSE, + VM_PROT_READ|VM_PROT_WRITE, + VM_PROT_READ|VM_PROT_WRITE, + VM_INHERIT_SHARE); + mach_port_deallocate(mach_task_self(),iopl_mem); + if( err ) + { + errno = err; + FatalError("xf86ReadBIOS() can't vm_map. (%s)\n",strerror(errno)); + } + + memcpy(Buf,(void*)((int)addr + Offset), Len); + + err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE); + if( err ) + { + errno = err; + FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",strerror(errno)); + } + + return Len; +} diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_mouse.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_mouse.c new file mode 100644 index 000000000..089cba38d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_mouse.c @@ -0,0 +1,242 @@ +/* + * Copyright 1997,1998 by UCHIYAMA Yasushi + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of UCHIYAMA Yasushi not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. UCHIYAMA Yasushi makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#define NEED_EVENTS +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "inputstr.h" +#include "scrnintstr.h" +#include "mipointer.h" + +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" +#include "xf86_OSlib.h" +#include "xisb.h" + +#include <stdio.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/file.h> +#include <assert.h> +#include <mach.h> +#include <sys/ioctl.h> + +#define DEFAULT_MOUSE_DEV "/dev/mouse" + +typedef unsigned short kev_type; /* kd event type */ +typedef unsigned char Scancode; + +struct mouse_motion { + short mm_deltaX; /* units? */ + short mm_deltaY; +}; + +typedef struct { + kev_type type; /* see below */ + struct timeval time; /* timestamp */ + union { /* value associated with event */ + boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */ + Scancode sc; /* KEYBD_EVENT */ + struct mouse_motion mmotion; /* MOUSE_MOTION */ + } value; +} kd_event; + +/* + * kd_event ID's. + */ +#define MOUSE_LEFT 1 /* mouse left button up/down */ +#define MOUSE_MIDDLE 2 +#define MOUSE_RIGHT 3 +#define MOUSE_MOTION 4 /* mouse motion */ +#define KEYBD_EVENT 5 /* key up/down */ + +#define NUMEVENTS 64 + +/* + * OsMouseReadInput -- + * Get some events from our queue. Process all outstanding events now. + */ +static void +OsMouseReadInput(InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + static kd_event eventList[NUMEVENTS]; + int n, c; + kd_event *event = eventList; + unsigned char *pBuf; + + pMse = pInfo->private; + + XisbBlockDuration(pMse->buffer, -1); + pBuf = (unsigned char *)eventList; + n = 0; + while ((c = XisbRead(pMse->buffer)) >= 0 && n < sizeof(eventList)) + pBuf[n++] = (unsigned char)c; + + if (n == 0) + return; + + n /= sizeof(kd_event); + while( n-- ) { + int buttons = pMse->lastButtons; + int dx = 0, dy = 0; + switch (event->type) { + case MOUSE_RIGHT: + buttons = buttons & 6 |(event->value.up ? 0 : 1); + break; + case MOUSE_MIDDLE: + buttons = buttons & 5 |(event->value.up ? 0 : 2); + break; + case MOUSE_LEFT: + buttons = buttons & 3 |(event->value.up ? 0 : 4) ; + break; + case MOUSE_MOTION: + dx = event->value.mmotion.mm_deltaX; + dy = - event->value.mmotion.mm_deltaY; + break; + default: + ErrorF("Bad mouse event (%d)\n",event->type); + continue; + } + pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0); + ++event; + } + return; +} + +static Bool +OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse; + + /* This is called when the protocol is "OSMouse". */ + + pMse = pInfo->private; + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pMse); + return FALSE; + } + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pInfo->read_input = OsMouseReadInput; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + const char path[] = DEFAULT_MOUSE_DEV; + int fd; + + SYSCALL (fd = open(path, O_RDWR | O_NONBLOCK | O_EXCL)); + + if (fd == -1) + return NULL; + + close(fd); + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", path); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", pInfo->name, + path); + + return path; +} + +static int +SupportedInterfaces(void) +{ + /* XXX Need to check this. */ + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; +} + +static const char *internalNames[] = { + "OSMouse", + NULL +}; + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + return FALSE; +} + +static const char * +DefaultProtocol(void) +{ + return "OSMouse"; +} + +OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; + p->BuiltinNames = BuiltinNames; + p->FindDevice = FindDevice; + p->DefaultProtocol = DefaultProtocol; + p->CheckProtocol = CheckProtocol; + p->PreInit = OsMousePreInit; + return p; +} + diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c new file mode 100644 index 000000000..04763ada7 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c @@ -0,0 +1,170 @@ +/* + * Copyright 1997, 1998 by UCHIYAMA Yasushi + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of UCHIYAMA Yasushi not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. UCHIYAMA Yasushi makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <mach.h> +#include <device/device.h> +#include <mach/machine/mach_i386.h> + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +/************************************************************************** + * Video Memory Mapping section + ***************************************************************************/ +pointer +xf86MapVidMem(int ScreenNum,int Flags, unsigned long Base, unsigned long Size) +{ + mach_port_t device,iopl_dev; + memory_object_t iopl_mem; + kern_return_t err; + vm_address_t addr=(vm_address_t)0; + + err = get_privileged_ports (NULL, &device); + if( err ) + { + errno = err; + FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",strerror(errno)); + } + err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev); + mach_port_deallocate (mach_task_self(), device); + if( err ) + { + errno = err; + FatalError("xf86MapVidMem() can't device_open. (%s)\n",strerror(errno)); + } + + err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , Size ,&iopl_mem,0); + if( err ) + { + errno = err; + FatalError("xf86MapVidMem() can't device_map. (%s)\n",strerror(errno)); + } + err = vm_map(mach_task_self(), + &addr, + Size, + 0, /* mask */ + TRUE, /* anywhere */ + iopl_mem, + (vm_offset_t)Base, + FALSE, /* copy on write */ + VM_PROT_READ|VM_PROT_WRITE, + VM_PROT_READ|VM_PROT_WRITE, + VM_INHERIT_SHARE); + mach_port_deallocate(mach_task_self(),iopl_mem); + if( err ) + { + errno = err; + FatalError("xf86MapVidMem() can't vm_map.(iopl_mem) (%s)\n",strerror(errno)); + } + mach_port_deallocate(mach_task_self(),iopl_dev); + if( err ) + { + errno = err; + FatalError("xf86MapVidMem() can't mach_port_deallocate.(iopl_dev) (%s)\n",strerror(errno)); + } + return (pointer)addr; +} + +void +xf86UnMapVidMem(int ScreenNum,pointer Base,unsigned long Size) +{ + kern_return_t err = vm_deallocate(mach_task_self(), (int)Base, Size); + if( err ) + { + errno = err; + ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",strerror(errno)); + } + return; +} + +Bool +xf86LinearVidMem() +{ + return(TRUE); +} + +/************************************************************************** + * I/O Permissions section + ***************************************************************************/ + +/* + * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare + * this. + */ +extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on); + +Bool +xf86EnableIO() +{ + if (ioperm(0, 0x10000, 1)) { + FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno)); + return FALSE; + } + ioperm(0x40,4,0); /* trap access to the timer chip */ + ioperm(0x60,4,0); /* trap access to the keyboard controller */ + return TRUE; +} + +void +xf86DisableIO() +{ + ioperm(0,0x10000,0); + return; +} + +/************************************************************************** + * Interrupt Handling section + **************************************************************************/ +Bool +xf86DisableInterrupts() +{ + return TRUE; +} +void +xf86EnableInterrupts() +{ + return; +} + +void +xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, + unsigned long Size) +{ +} + +Bool +xf86CheckMTRR(int s) +{ + return FALSE; +} + diff --git a/xorg-server/hw/xfree86/os-support/int10Defines.h b/xorg-server/hw/xfree86/os-support/int10Defines.h new file mode 100644 index 000000000..d942fbdad --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/int10Defines.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2000-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _INT10DEFINES_H_ +#define _INT10DEFINES_H_ 1 + +#ifdef _VM86_LINUX + +#include <asm/vm86.h> + +#define CPU_R(type,name,num) \ + (((type *)&(((struct vm86_struct *)REG->cpuRegs)->regs.name))[num]) +#define CPU_RD(name,num) CPU_R(CARD32,name,num) +#define CPU_RW(name,num) CPU_R(CARD16,name,num) +#define CPU_RB(name,num) CPU_R(CARD8,name,num) + +#define X86_EAX CPU_RD(eax,0) +#define X86_EBX CPU_RD(ebx,0) +#define X86_ECX CPU_RD(ecx,0) +#define X86_EDX CPU_RD(edx,0) +#define X86_ESI CPU_RD(esi,0) +#define X86_EDI CPU_RD(edi,0) +#define X86_EBP CPU_RD(ebp,0) +#define X86_EIP CPU_RD(eip,0) +#define X86_ESP CPU_RD(esp,0) +#define X86_EFLAGS CPU_RD(eflags,0) + +#define X86_FLAGS CPU_RW(eflags,0) +#define X86_AX CPU_RW(eax,0) +#define X86_BX CPU_RW(ebx,0) +#define X86_CX CPU_RW(ecx,0) +#define X86_DX CPU_RW(edx,0) +#define X86_SI CPU_RW(esi,0) +#define X86_DI CPU_RW(edi,0) +#define X86_BP CPU_RW(ebp,0) +#define X86_IP CPU_RW(eip,0) +#define X86_SP CPU_RW(esp,0) +#define X86_CS CPU_RW(cs,0) +#define X86_DS CPU_RW(ds,0) +#define X86_ES CPU_RW(es,0) +#define X86_SS CPU_RW(ss,0) +#define X86_FS CPU_RW(fs,0) +#define X86_GS CPU_RW(gs,0) + +#define X86_AL CPU_RB(eax,0) +#define X86_BL CPU_RB(ebx,0) +#define X86_CL CPU_RB(ecx,0) +#define X86_DL CPU_RB(edx,0) + +#define X86_AH CPU_RB(eax,1) +#define X86_BH CPU_RB(ebx,1) +#define X86_CH CPU_RB(ecx,1) +#define X86_DH CPU_RB(edx,1) + +#elif defined(_X86EMU) + +#include "xf86x86emu.h" + +#endif + +#endif diff --git a/xorg-server/hw/xfree86/os-support/linux/Makefile.am b/xorg-server/hw/xfree86/os-support/linux/Makefile.am new file mode 100644 index 000000000..beaae3d5b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/Makefile.am @@ -0,0 +1,58 @@ +noinst_LTLIBRARIES = liblinux.la + +if LINUX_IA64 +PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c +PLATFORM_DEFINES = -DOS_PROBE_PCI_CHIPSET=lnxProbePciChipset +PLATFORM_INCLUDES = -I$(srcdir)/../shared +endif +if LINUX_ALPHA +noinst_LTLIBRARIES += liblinuxev56.la +PLATFORM_PCI_SUPPORT = \ + $(srcdir)/lnx_axp.c \ + $(srcdir)/../shared/xf86Axp.c + +liblinuxev56_la_CFLAGS = $(AM_CFLAGS) -mcpu=ev56 + +liblinuxev56_la_SOURCES = lnx_ev56.c +endif + +if LNXACPI +ACPI_SRCS = lnx_acpi.c lnx_apm.c +XORG_CFLAGS += -DHAVE_ACPI +endif + +if LNXAPM +APM_SRCS = lnx_apm.c +XORG_CFLAGS += -DHAVE_APM +endif + +liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_mouse.c \ + lnx_pci.c lnx_agp.c lnx_kmod.c lnx_bell.c \ + $(srcdir)/../shared/bios_mmap.c \ + $(srcdir)/../shared/VTsw_usl.c \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/vidmem.c \ + $(srcdir)/../shared/sigio.c \ + $(srcdir)/../shared/stdResource.c \ + $(ACPI_SRCS) \ + $(APM_SRCS) \ + $(PLATFORM_PCI_SUPPORT) + +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES) + +INCLUDES = $(XORG_INCS) $(PLATFORM_INCLUDES) -I/usr/include/drm # FIXME this last part is crack + +# FIXME: These need to be added to the build +LNX_EXTRA_SRCS = \ + lnx_font.c \ + lnx_jstk.c \ + lnxResource.c + +EXTRA_DIST = \ + $(LNX_EXTRA_SRCS) \ + lnx.h \ + $(srcdir)/../shared/xf86Axp.h + +if LINUX_ALPHA +liblinux_la_LIBADD = liblinuxev56.la +endif diff --git a/xorg-server/hw/xfree86/os-support/linux/Makefile.in b/xorg-server/hw/xfree86/os-support/linux/Makefile.in new file mode 100644 index 000000000..a753ac9a0 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/Makefile.in @@ -0,0 +1,795 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@LINUX_ALPHA_TRUE@am__append_1 = liblinuxev56.la +@LNXACPI_TRUE@am__append_2 = -DHAVE_ACPI +@LNXAPM_TRUE@am__append_3 = -DHAVE_APM +subdir = hw/xfree86/os-support/linux +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +@LINUX_ALPHA_TRUE@liblinux_la_DEPENDENCIES = liblinuxev56.la +am__liblinux_la_SOURCES_DIST = lnx_init.c lnx_video.c lnx_mouse.c \ + lnx_pci.c lnx_agp.c lnx_kmod.c lnx_bell.c \ + $(srcdir)/../shared/bios_mmap.c $(srcdir)/../shared/VTsw_usl.c \ + $(srcdir)/../shared/posix_tty.c $(srcdir)/../shared/vidmem.c \ + $(srcdir)/../shared/sigio.c $(srcdir)/../shared/stdResource.c \ + lnx_acpi.c lnx_apm.c $(srcdir)/lnx_axp.c \ + $(srcdir)/../shared/xf86Axp.c $(srcdir)/../shared/ia64Pci.c +@LNXACPI_TRUE@am__objects_1 = lnx_acpi.lo lnx_apm.lo +@LNXAPM_TRUE@am__objects_2 = lnx_apm.lo +@LINUX_ALPHA_FALSE@@LINUX_IA64_TRUE@am__objects_3 = ia64Pci.lo +@LINUX_ALPHA_TRUE@am__objects_3 = lnx_axp.lo xf86Axp.lo +am_liblinux_la_OBJECTS = lnx_init.lo lnx_video.lo lnx_mouse.lo \ + lnx_pci.lo lnx_agp.lo lnx_kmod.lo lnx_bell.lo bios_mmap.lo \ + VTsw_usl.lo posix_tty.lo vidmem.lo sigio.lo stdResource.lo \ + $(am__objects_1) $(am__objects_2) $(am__objects_3) +liblinux_la_OBJECTS = $(am_liblinux_la_OBJECTS) +liblinuxev56_la_LIBADD = +am__liblinuxev56_la_SOURCES_DIST = lnx_ev56.c +@LINUX_ALPHA_TRUE@am_liblinuxev56_la_OBJECTS = \ +@LINUX_ALPHA_TRUE@ liblinuxev56_la-lnx_ev56.lo +liblinuxev56_la_OBJECTS = $(am_liblinuxev56_la_OBJECTS) +liblinuxev56_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(liblinuxev56_la_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +@LINUX_ALPHA_TRUE@am_liblinuxev56_la_rpath = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(liblinux_la_SOURCES) $(liblinuxev56_la_SOURCES) +DIST_SOURCES = $(am__liblinux_la_SOURCES_DIST) \ + $(am__liblinuxev56_la_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ $(am__append_2) $(am__append_3) +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LTLIBRARIES = liblinux.la $(am__append_1) +@LINUX_ALPHA_TRUE@PLATFORM_PCI_SUPPORT = \ +@LINUX_ALPHA_TRUE@ $(srcdir)/lnx_axp.c \ +@LINUX_ALPHA_TRUE@ $(srcdir)/../shared/xf86Axp.c + +@LINUX_IA64_TRUE@PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c +@LINUX_IA64_TRUE@PLATFORM_DEFINES = -DOS_PROBE_PCI_CHIPSET=lnxProbePciChipset +@LINUX_IA64_TRUE@PLATFORM_INCLUDES = -I$(srcdir)/../shared +@LINUX_ALPHA_TRUE@liblinuxev56_la_CFLAGS = $(AM_CFLAGS) -mcpu=ev56 +@LINUX_ALPHA_TRUE@liblinuxev56_la_SOURCES = lnx_ev56.c +@LNXACPI_TRUE@ACPI_SRCS = lnx_acpi.c lnx_apm.c +@LNXAPM_TRUE@APM_SRCS = lnx_apm.c +liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_mouse.c \ + lnx_pci.c lnx_agp.c lnx_kmod.c lnx_bell.c \ + $(srcdir)/../shared/bios_mmap.c \ + $(srcdir)/../shared/VTsw_usl.c \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/vidmem.c \ + $(srcdir)/../shared/sigio.c \ + $(srcdir)/../shared/stdResource.c \ + $(ACPI_SRCS) \ + $(APM_SRCS) \ + $(PLATFORM_PCI_SUPPORT) + +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES) +INCLUDES = $(XORG_INCS) $(PLATFORM_INCLUDES) -I/usr/include/drm # FIXME this last part is crack + +# FIXME: These need to be added to the build +LNX_EXTRA_SRCS = \ + lnx_font.c \ + lnx_jstk.c \ + lnxResource.c + +EXTRA_DIST = \ + $(LNX_EXTRA_SRCS) \ + lnx.h \ + $(srcdir)/../shared/xf86Axp.h + +@LINUX_ALPHA_TRUE@liblinux_la_LIBADD = liblinuxev56.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/linux/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/linux/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +liblinux.la: $(liblinux_la_OBJECTS) $(liblinux_la_DEPENDENCIES) + $(LINK) $(liblinux_la_OBJECTS) $(liblinux_la_LIBADD) $(LIBS) +liblinuxev56.la: $(liblinuxev56_la_OBJECTS) $(liblinuxev56_la_DEPENDENCIES) + $(liblinuxev56_la_LINK) $(am_liblinuxev56_la_rpath) $(liblinuxev56_la_OBJECTS) $(liblinuxev56_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VTsw_usl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bios_mmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ia64Pci.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblinuxev56_la-lnx_ev56.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_acpi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_agp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_apm.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_axp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_bell.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_init.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_kmod.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_mouse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_pci.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix_tty.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigio.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdResource.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vidmem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Axp.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +bios_mmap.lo: $(srcdir)/../shared/bios_mmap.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bios_mmap.lo -MD -MP -MF $(DEPDIR)/bios_mmap.Tpo -c -o bios_mmap.lo `test -f '$(srcdir)/../shared/bios_mmap.c' || echo '$(srcdir)/'`$(srcdir)/../shared/bios_mmap.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/bios_mmap.Tpo $(DEPDIR)/bios_mmap.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/bios_mmap.c' object='bios_mmap.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bios_mmap.lo `test -f '$(srcdir)/../shared/bios_mmap.c' || echo '$(srcdir)/'`$(srcdir)/../shared/bios_mmap.c + +VTsw_usl.lo: $(srcdir)/../shared/VTsw_usl.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT VTsw_usl.lo -MD -MP -MF $(DEPDIR)/VTsw_usl.Tpo -c -o VTsw_usl.lo `test -f '$(srcdir)/../shared/VTsw_usl.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_usl.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/VTsw_usl.Tpo $(DEPDIR)/VTsw_usl.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/VTsw_usl.c' object='VTsw_usl.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o VTsw_usl.lo `test -f '$(srcdir)/../shared/VTsw_usl.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_usl.c + +posix_tty.lo: $(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT posix_tty.lo -MD -MP -MF $(DEPDIR)/posix_tty.Tpo -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/posix_tty.Tpo $(DEPDIR)/posix_tty.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/posix_tty.c' object='posix_tty.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c + +vidmem.lo: $(srcdir)/../shared/vidmem.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT vidmem.lo -MD -MP -MF $(DEPDIR)/vidmem.Tpo -c -o vidmem.lo `test -f '$(srcdir)/../shared/vidmem.c' || echo '$(srcdir)/'`$(srcdir)/../shared/vidmem.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/vidmem.Tpo $(DEPDIR)/vidmem.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/vidmem.c' object='vidmem.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o vidmem.lo `test -f '$(srcdir)/../shared/vidmem.c' || echo '$(srcdir)/'`$(srcdir)/../shared/vidmem.c + +sigio.lo: $(srcdir)/../shared/sigio.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sigio.lo -MD -MP -MF $(DEPDIR)/sigio.Tpo -c -o sigio.lo `test -f '$(srcdir)/../shared/sigio.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigio.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sigio.Tpo $(DEPDIR)/sigio.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/sigio.c' object='sigio.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sigio.lo `test -f '$(srcdir)/../shared/sigio.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigio.c + +stdResource.lo: $(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdResource.lo -MD -MP -MF $(DEPDIR)/stdResource.Tpo -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/stdResource.Tpo $(DEPDIR)/stdResource.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/stdResource.c' object='stdResource.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c + +lnx_axp.lo: $(srcdir)/lnx_axp.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lnx_axp.lo -MD -MP -MF $(DEPDIR)/lnx_axp.Tpo -c -o lnx_axp.lo `test -f '$(srcdir)/lnx_axp.c' || echo '$(srcdir)/'`$(srcdir)/lnx_axp.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/lnx_axp.Tpo $(DEPDIR)/lnx_axp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/lnx_axp.c' object='lnx_axp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lnx_axp.lo `test -f '$(srcdir)/lnx_axp.c' || echo '$(srcdir)/'`$(srcdir)/lnx_axp.c + +xf86Axp.lo: $(srcdir)/../shared/xf86Axp.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xf86Axp.lo -MD -MP -MF $(DEPDIR)/xf86Axp.Tpo -c -o xf86Axp.lo `test -f '$(srcdir)/../shared/xf86Axp.c' || echo '$(srcdir)/'`$(srcdir)/../shared/xf86Axp.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xf86Axp.Tpo $(DEPDIR)/xf86Axp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/xf86Axp.c' object='xf86Axp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xf86Axp.lo `test -f '$(srcdir)/../shared/xf86Axp.c' || echo '$(srcdir)/'`$(srcdir)/../shared/xf86Axp.c + +ia64Pci.lo: $(srcdir)/../shared/ia64Pci.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ia64Pci.lo -MD -MP -MF $(DEPDIR)/ia64Pci.Tpo -c -o ia64Pci.lo `test -f '$(srcdir)/../shared/ia64Pci.c' || echo '$(srcdir)/'`$(srcdir)/../shared/ia64Pci.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ia64Pci.Tpo $(DEPDIR)/ia64Pci.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/ia64Pci.c' object='ia64Pci.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ia64Pci.lo `test -f '$(srcdir)/../shared/ia64Pci.c' || echo '$(srcdir)/'`$(srcdir)/../shared/ia64Pci.c + +liblinuxev56_la-lnx_ev56.lo: lnx_ev56.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblinuxev56_la_CFLAGS) $(CFLAGS) -MT liblinuxev56_la-lnx_ev56.lo -MD -MP -MF $(DEPDIR)/liblinuxev56_la-lnx_ev56.Tpo -c -o liblinuxev56_la-lnx_ev56.lo `test -f 'lnx_ev56.c' || echo '$(srcdir)/'`lnx_ev56.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/liblinuxev56_la-lnx_ev56.Tpo $(DEPDIR)/liblinuxev56_la-lnx_ev56.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lnx_ev56.c' object='liblinuxev56_la-lnx_ev56.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblinuxev56_la_CFLAGS) $(CFLAGS) -c -o liblinuxev56_la-lnx_ev56.lo `test -f 'lnx_ev56.c' || echo '$(srcdir)/'`lnx_ev56.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c new file mode 100644 index 000000000..9e2c6199c --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c @@ -0,0 +1,557 @@ +/* + * linux specific part of the int10 module + * Copyright 1999, 2000, 2001, 2002, 2003, 2004 Egbert Eich + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Pci.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "xf86int10.h" +#ifdef __sparc__ +#define DEV_MEM "/dev/fb" +#else +#define DEV_MEM "/dev/mem" +#endif +#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1) +#define SHMERRORPTR (pointer)(-1) + +#include <fcntl.h> +#include <errno.h> +#include <sys/mman.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <unistd.h> +#include <string.h> + +static int counter = 0; +static unsigned long int10Generation = 0; + +static CARD8 read_b(xf86Int10InfoPtr pInt, int addr); +static CARD16 read_w(xf86Int10InfoPtr pInt, int addr); +static CARD32 read_l(xf86Int10InfoPtr pInt, int addr); +static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val); +static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val); +static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val); + +int10MemRec linuxMem = { + read_b, + read_w, + read_l, + write_b, + write_w, + write_l +}; + +typedef struct { + int lowMem; + int highMem; + char* base; + char* base_high; + int screen; + char* alloc; +} linuxInt10Priv; + +#if defined DoSubModules + +typedef enum { + INT10_NOT_LOADED, + INT10_LOADED_VM86, + INT10_LOADED_X86EMU, + INT10_LOAD_FAILED +} Int10LinuxSubModuleState; + +static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED; + +static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn); + +#endif /* DoSubModules */ + +xf86Int10InfoPtr +xf86ExtendedInitInt10(int entityIndex, int Flags) +{ + xf86Int10InfoPtr pInt = NULL; + int screen; + int fd; + static void* vidMem = NULL; + static void* sysMem = NULL; + void* vMem = NULL; + void *options = NULL; + int low_mem; + int high_mem = -1; + char *base = SHMERRORPTR; + char *base_high = SHMERRORPTR; + int pagesize; + memType cs; + legacyVGARec vga; + Bool videoBiosMapped = FALSE; + + if (int10Generation != serverGeneration) { + counter = 0; + int10Generation = serverGeneration; + } + + screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex; + + options = xf86HandleInt10Options(xf86Screens[screen],entityIndex); + + if (int10skip(options)) { + xfree(options); + return NULL; + } + +#if defined DoSubModules + if (loadedSubModule == INT10_NOT_LOADED) + loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]); + + if (loadedSubModule == INT10_LOAD_FAILED) + return NULL; +#endif + + if ((!vidMem) || (!sysMem)) { + if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { + if (!sysMem) { +#ifdef DEBUG + ErrorF("Mapping sys bios area\n"); +#endif + if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE, + PROT_READ | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, SYS_BIOS)) + == MAP_FAILED) { + xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n"); + close(fd); + goto error0; + } + } + if (!vidMem) { +#ifdef DEBUG + ErrorF("Mapping VRAM area\n"); +#endif + if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, V_RAM)) + == MAP_FAILED) { + xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n"); + close(fd); + goto error0; + } + } + close(fd); + } else { + xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM); + goto error0; + } + } + + pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec)); + pInt->scrnIndex = screen; + pInt->entityIndex = entityIndex; + pInt->dev = xf86GetPciInfoForEntity(entityIndex); + + if (!xf86Int10ExecSetup(pInt)) + goto error0; + pInt->mem = &linuxMem; + pagesize = getpagesize(); + pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv)); + ((linuxInt10Priv*)pInt->private)->screen = screen; + ((linuxInt10Priv*)pInt->private)->alloc = + (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize)); + + if (!xf86IsEntityPrimary(entityIndex)) { +#ifdef DEBUG + ErrorF("Mapping high memory area\n"); +#endif + if ((high_mem = shmget(counter++, HIGH_MEM_SIZE, + IPC_CREAT | SHM_R | SHM_W)) == -1) { + if (errno == ENOSYS) + xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure" + " your kernel to include System V IPC support\n"); + else + xf86DrvMsg(screen, X_ERROR, + "shmget(highmem) error: %s\n",strerror(errno)); + goto error1; + } + } else { +#ifdef DEBUG + ErrorF("Mapping Video BIOS\n"); +#endif + videoBiosMapped = TRUE; + if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { + if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, V_BIOS)) + == MAP_FAILED) { + xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n"); + close(fd); + goto error1; + } + close (fd); + } else + goto error1; + } + ((linuxInt10Priv*)pInt->private)->highMem = high_mem; + +#ifdef DEBUG + ErrorF("Mapping 640kB area\n"); +#endif + if ((low_mem = shmget(counter++, V_RAM, + IPC_CREAT | SHM_R | SHM_W)) == -1) { + xf86DrvMsg(screen, X_ERROR, + "shmget(lowmem) error: %s\n",strerror(errno)); + goto error2; + } + + ((linuxInt10Priv*)pInt->private)->lowMem = low_mem; + base = shmat(low_mem, 0, 0); + if (base == SHMERRORPTR) { + xf86DrvMsg(screen, X_ERROR, + "shmat(low_mem) error: %s\n",strerror(errno)); + goto error3; + } + ((linuxInt10Priv *)pInt->private)->base = base; + if (high_mem > -1) { + base_high = shmat(high_mem, 0, 0); + if (base_high == SHMERRORPTR) { + xf86DrvMsg(screen, X_ERROR, + "shmat(high_mem) error: %s\n",strerror(errno)); + goto error3; + } + ((linuxInt10Priv*)pInt->private)->base_high = base_high; + } else + ((linuxInt10Priv*)pInt->private)->base_high = NULL; + + if (!MapCurrentInt10(pInt)) + goto error3; + + Int10Current = pInt; + +#ifdef DEBUG + ErrorF("Mapping int area\n"); +#endif + if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) { + xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n"); + goto error3; + } +#ifdef DEBUG + ErrorF("done\n"); +#endif + /* + * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes + * have executable code there. Note that xf86ReadBIOS() can only bring in + * 64K bytes at a time. + */ + if (!videoBiosMapped) { + (void)memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS); +#ifdef DEBUG + ErrorF("Reading BIOS\n"); +#endif + for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE) + if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE) + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x%06lX.\n", cs); +#ifdef DEBUG + ErrorF("done\n"); +#endif + } + + if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) { + if (!xf86int10GetBiosSegment(pInt, NULL)) + goto error3; + + set_return_trap(pInt); +#ifdef _PC + pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH); + if (! (pInt->Flags & SET_BIOS_SCRATCH)) + pInt->Flags &= ~RESTORE_BIOS_SCRATCH; + xf86Int10SaveRestoreBIOSVars(pInt, TRUE); +#endif + } else { + const BusType location_type = xf86int10GetBiosLocationType(pInt); + + switch (location_type) { + case BUS_PCI: { + int err; + struct pci_device *rom_device = + xf86GetPciInfoForEntity(pInt->entityIndex); + +#if HAVE_PCI_DEVICE_ENABLE + pci_device_enable(rom_device); +#endif + + err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS)); + if (err) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n", + strerror(err)); + goto error3; + } + + pInt->BIOSseg = V_BIOS >> 4; + break; + } + case BUS_ISA: + if (!xf86int10GetBiosSegment(pInt, NULL)) + goto error3; + break; + default: + goto error3; + } + + pInt->num = 0xe6; + reset_int_vect(pInt); + set_return_trap(pInt); + LockLegacyVGA(pInt, &vga); + xf86ExecX86int10(pInt); + UnlockLegacyVGA(pInt, &vga); + } +#ifdef DEBUG + dprint(0xc0000, 0x20); +#endif + + xfree(options); + return pInt; + +error3: + if (base_high) + shmdt(base_high); + shmdt(base); + shmdt(0); + if (base_high) + shmdt((char*)HIGH_MEM); + shmctl(low_mem, IPC_RMID, NULL); + Int10Current = NULL; +error2: + if (high_mem > -1) + shmctl(high_mem, IPC_RMID,NULL); +error1: + if (vMem) + munmap(vMem, SYS_BIOS - V_BIOS); + xfree(((linuxInt10Priv*)pInt->private)->alloc); + xfree(pInt->private); +error0: + xfree(options); + xfree(pInt); + return NULL; +} + +Bool +MapCurrentInt10(xf86Int10InfoPtr pInt) +{ + pointer addr; + int fd = -1; + + if (Int10Current) { + shmdt(0); + if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0) + shmdt((char*)HIGH_MEM); + else + munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS)); + } + addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND); + if (addr == SHMERRORPTR) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n"); + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "shmat(low_mem) error: %s\n",strerror(errno)); + return FALSE; + } + + if (((linuxInt10Priv*)pInt->private)->highMem >= 0) { + addr = shmat(((linuxInt10Priv*)pInt->private)->highMem, + (char*)HIGH_MEM, 0); + if (addr == SHMERRORPTR) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "Cannot shmat() high memory\n"); + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "shmget error: %s\n",strerror(errno)); + return FALSE; + } + } else { + if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { + if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, V_BIOS) + == MAP_FAILED) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n"); + close (fd); + return FALSE; + } + } else { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM); + return FALSE; + } + close (fd); + } + + return TRUE; +} + +void +xf86FreeInt10(xf86Int10InfoPtr pInt) +{ + if (!pInt) + return; + +#ifdef _PC + xf86Int10SaveRestoreBIOSVars(pInt, FALSE); +#endif + if (Int10Current == pInt) { + shmdt(0); + if (((linuxInt10Priv*)pInt->private)->highMem >= 0) + shmdt((char*)HIGH_MEM); + else + munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS)); + Int10Current = NULL; + } + + if (((linuxInt10Priv*)pInt->private)->base_high) + shmdt(((linuxInt10Priv*)pInt->private)->base_high); + shmdt(((linuxInt10Priv*)pInt->private)->base); + shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL); + if (((linuxInt10Priv*)pInt->private)->highMem >= 0) + shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL); + xfree(((linuxInt10Priv*)pInt->private)->alloc); + xfree(pInt->private); + xfree(pInt); +} + +void * +xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off) +{ + int pagesize = getpagesize(); + int num_pages = ALLOC_ENTRIES(pagesize); + int i, j; + + for (i = 0; i < (num_pages - num); i++) { + if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) { + for (j = i; j < (num + i); j++) + if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0)) + break; + if (j == (num + i)) + break; + else + i = i + num; + } + } + if (i == (num_pages - num)) + return NULL; + + for (j = i; j < (i + num); j++) + ((linuxInt10Priv*)pInt->private)->alloc[j] = 1; + + *off = (i + 1) * pagesize; + + return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize); +} + +void +xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num) +{ + int pagesize = getpagesize(); + int first = (((unsigned long)pbase + - (unsigned long)((linuxInt10Priv*)pInt->private)->base) + / pagesize) - 1; + int i; + + for (i = first; i < (first + num); i++) + ((linuxInt10Priv*)pInt->private)->alloc[i] = 0; +} + +static CARD8 +read_b(xf86Int10InfoPtr pInt, int addr) +{ + return *((CARD8 *)(memType)addr); +} + +static CARD16 +read_w(xf86Int10InfoPtr pInt, int addr) +{ + return *((CARD16 *)(memType)addr); +} + +static CARD32 +read_l(xf86Int10InfoPtr pInt, int addr) +{ + return *((CARD32 *)(memType)addr); +} + +static void +write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val) +{ + *((CARD8 *)(memType)addr) = val; +} + +static void +write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val) +{ + *((CARD16 *)(memType)addr) = val; +} + +static +void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val) +{ + *((CARD32 *)(memType) addr) = val; +} + +pointer +xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr) +{ + if (addr < V_RAM) + return ((linuxInt10Priv*)pInt->private)->base + addr; + else if (addr < V_BIOS) + return (pointer)(memType)addr; + else if (addr < SYS_BIOS) { + if (((linuxInt10Priv*)pInt->private)->base_high) + return (pointer)(((linuxInt10Priv*)pInt->private)->base_high + - V_BIOS + addr); + else + return (pointer) (memType)addr; + } else + return (pointer) (memType)addr; +} + +#if defined DoSubModules + +static Bool +vm86_tst(void) +{ + int __res; + +#ifdef __PIC__ + /* When compiling with -fPIC, we can't use asm constraint "b" because + %ebx is already taken by gcc. */ + __asm__ __volatile__("pushl %%ebx\n\t" + "movl %2,%%ebx\n\t" + "movl %1,%%eax\n\t" + "int $0x80\n\t" + "popl %%ebx" + :"=a" (__res) + :"n" ((int)113), "r" (NULL)); +#else + __asm__ __volatile__("int $0x80\n\t" + :"=a" (__res):"a" ((int)113), + "b" ((struct vm86_struct *)NULL)); +#endif + + if (__res < 0 && __res == -ENOSYS) + return FALSE; + + return TRUE; +} + +static Int10LinuxSubModuleState +int10LinuxLoadSubModule(ScrnInfoPtr pScrn) +{ + if (vm86_tst()) { + if (xf86LoadSubModule(pScrn,"vm86")) + return INT10_LOADED_VM86; + } + if (xf86LoadSubModule(pScrn,"x86emu")) + return INT10_LOADED_X86EMU; + + return INT10_LOAD_FAILED; +} + +#endif /* DoSubModules */ diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c b/xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c new file mode 100644 index 000000000..9412b07a4 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c @@ -0,0 +1,302 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <string.h> + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Pci.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "xf86int10.h" + +#define REG pInt + +#ifdef _VM86_LINUX +#include "int10Defines.h" + +static int vm86_rep(struct vm86_struct *ptr); +static struct vm86_struct vm86_s; + +Bool +xf86Int10ExecSetup(xf86Int10InfoPtr pInt) +{ +#define VM86S ((struct vm86_struct *)pInt->cpuRegs) + + pInt->cpuRegs = &vm86_s; + VM86S->flags = 0; + VM86S->screen_bitmap = 0; + VM86S->cpu_type = CPU_586; + memset(&VM86S->int_revectored, 0xff, sizeof(VM86S->int_revectored)); + memset(&VM86S->int21_revectored, 0xff, sizeof(VM86S->int21_revectored)); + return TRUE; +} + +/* get the linear address */ +#define LIN_PREF_SI ((pref_seg << 4) + X86_SI) +#define LWECX ((prefix66 ^ prefix67) ? X86_ECX : X86_CX) +#define LWECX_ZERO {if (prefix66 ^ prefix67) X86_ECX = 0; else X86_CX = 0;} +#define DF (1 << 10) + +/* vm86 fault handling */ +static Bool +vm86_GP_fault(xf86Int10InfoPtr pInt) +{ + unsigned char *csp, *lina; + CARD32 org_eip; + int pref_seg; + int done, is_rep, prefix66, prefix67; + + csp = lina = SEG_ADR((unsigned char *), X86_CS, IP); + + is_rep = 0; + prefix66 = prefix67 = 0; + pref_seg = -1; + + /* eat up prefixes */ + done = 0; + do { + switch (MEM_RB(pInt, (int)csp++)) { + case 0x66: /* operand prefix */ prefix66=1; break; + case 0x67: /* address prefix */ prefix67=1; break; + case 0x2e: /* CS */ pref_seg=X86_CS; break; + case 0x3e: /* DS */ pref_seg=X86_DS; break; + case 0x26: /* ES */ pref_seg=X86_ES; break; + case 0x36: /* SS */ pref_seg=X86_SS; break; + case 0x65: /* GS */ pref_seg=X86_GS; break; + case 0x64: /* FS */ pref_seg=X86_FS; break; + case 0xf0: /* lock */ break; + case 0xf2: /* repnz */ + case 0xf3: /* rep */ is_rep=1; break; + default: done=1; + } + } while (!done); + csp--; /* oops one too many */ + org_eip = X86_EIP; + X86_IP += (csp - lina); + + switch (MEM_RB(pInt, (int)csp)) { + case 0x6c: /* insb */ + /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx + * but is anyone using extended regs in real mode? */ + /* WARNING: no test for DI wrapping! */ + X86_EDI += port_rep_inb(pInt, X86_DX, SEG_EADR((CARD32), X86_ES, DI), + X86_FLAGS & DF, is_rep ? LWECX : 1); + if (is_rep) LWECX_ZERO; + X86_IP++; + break; + + case 0x6d: /* (rep) insw / insd */ + /* NOTE: ES can't be overwritten */ + /* WARNING: no test for _DI wrapping! */ + if (prefix66) { + X86_DI += port_rep_inl(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI), + X86_EFLAGS & DF, is_rep ? LWECX : 1); + } + else { + X86_DI += port_rep_inw(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI), + X86_FLAGS & DF, is_rep ? LWECX : 1); + } + if (is_rep) LWECX_ZERO; + X86_IP++; + break; + + case 0x6e: /* (rep) outsb */ + if (pref_seg < 0) pref_seg = X86_DS; + /* WARNING: no test for _SI wrapping! */ + X86_SI += port_rep_outb(pInt, X86_DX, (CARD32)LIN_PREF_SI, + X86_FLAGS & DF, is_rep ? LWECX : 1); + if (is_rep) LWECX_ZERO; + X86_IP++; + break; + + case 0x6f: /* (rep) outsw / outsd */ + if (pref_seg < 0) pref_seg = X86_DS; + /* WARNING: no test for _SI wrapping! */ + if (prefix66) { + X86_SI += port_rep_outl(pInt, X86_DX, (CARD32)LIN_PREF_SI, + X86_EFLAGS & DF, is_rep ? LWECX : 1); + } + else { + X86_SI += port_rep_outw(pInt, X86_DX, (CARD32)LIN_PREF_SI, + X86_FLAGS & DF, is_rep ? LWECX : 1); + } + if (is_rep) LWECX_ZERO; + X86_IP++; + break; + + case 0xe5: /* inw xx, inl xx */ + if (prefix66) X86_EAX = x_inl(csp[1]); + else X86_AX = x_inw(csp[1]); + X86_IP += 2; + break; + + case 0xe4: /* inb xx */ + X86_AL = x_inb(csp[1]); + X86_IP += 2; + break; + + case 0xed: /* inw dx, inl dx */ + if (prefix66) X86_EAX = x_inl(X86_DX); + else X86_AX = x_inw(X86_DX); + X86_IP += 1; + break; + + case 0xec: /* inb dx */ + X86_AL = x_inb(X86_DX); + X86_IP += 1; + break; + + case 0xe7: /* outw xx */ + if (prefix66) x_outl(csp[1], X86_EAX); + else x_outw(csp[1], X86_AX); + X86_IP += 2; + break; + + case 0xe6: /* outb xx */ + x_outb(csp[1], X86_AL); + X86_IP += 2; + break; + + case 0xef: /* outw dx */ + if (prefix66) x_outl(X86_DX, X86_EAX); + else x_outw(X86_DX, X86_AX); + X86_IP += 1; + break; + + case 0xee: /* outb dx */ + x_outb(X86_DX, X86_AL); + X86_IP += 1; + break; + + case 0xf4: +#ifdef DEBUG + ErrorF("hlt at %p\n", lina); +#endif + return FALSE; + + case 0x0f: + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "CPU 0x0f Trap at CS:EIP=0x%4.4x:0x%8.8lx\n", X86_CS, X86_EIP); + goto op0ferr; + + default: + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown reason for exception\n"); + + op0ferr: + dump_registers(pInt); + stack_trace(pInt); + dump_code(pInt); + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "cannot continue\n"); + return FALSE; + } /* end of switch() */ + return TRUE; +} + +static int +do_vm86(xf86Int10InfoPtr pInt) +{ + int retval, signo; + + xf86InterceptSignals(&signo); + retval = vm86_rep(VM86S); + xf86InterceptSignals(NULL); + + if (signo >= 0) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "vm86() syscall generated signal %d.\n", signo); + dump_registers(pInt); + dump_code(pInt); + stack_trace(pInt); + return 0; + } + + switch (VM86_TYPE(retval)) { + case VM86_UNKNOWN: + if (!vm86_GP_fault(pInt)) return 0; + break; + case VM86_STI: + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "vm86_sti :-((\n"); + dump_registers(pInt); + dump_code(pInt); + stack_trace(pInt); + return 0; + case VM86_INTx: + pInt->num = VM86_ARG(retval); + if (!int_handler(pInt)) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "Unknown vm86_int: 0x%X\n\n", VM86_ARG(retval)); + dump_registers(pInt); + dump_code(pInt); + stack_trace(pInt); + return 0; + } + /* I'm not sure yet what to do if we can handle ints */ + break; + case VM86_SIGNAL: + return 1; + /* + * we used to warn here and bail out - but now the sigio stuff + * always fires signals at us. So we just ignore them for now. + */ + xf86DrvMsg(pInt->scrnIndex, X_WARNING, "received signal\n"); + return 0; + default: + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown type(0x%x)=0x%x\n", + VM86_ARG(retval), VM86_TYPE(retval)); + dump_registers(pInt); + dump_code(pInt); + stack_trace(pInt); + return 0; + } + + return 1; +} + +void +xf86ExecX86int10(xf86Int10InfoPtr pInt) +{ + int sig = setup_int(pInt); + + if (int_handler(pInt)) + while(do_vm86(pInt)) {}; + + finish_int(pInt, sig); +} + +static int +vm86_rep(struct vm86_struct *ptr) +{ + int __res; + +#ifdef __PIC__ + /* When compiling with -fPIC, we can't use asm constraint "b" because + %ebx is already taken by gcc. */ + __asm__ __volatile__("pushl %%ebx\n\t" + "push %%gs\n\t" + "movl %2,%%ebx\n\t" + "movl %1,%%eax\n\t" + "int $0x80\n\t" + "pop %%gs\n\t" + "popl %%ebx" + :"=a" (__res) + :"n" ((int)113), "r" ((struct vm86_struct *)ptr)); +#else + __asm__ __volatile__("push %%gs\n\t" + "int $0x80\n\t" + "pop %%gs" + :"=a" (__res):"a" ((int)113), + "b" ((struct vm86_struct *)ptr)); +#endif + + if (__res < 0) { + errno = -__res; + __res = -1; + } + else errno = 0; + return __res; +} + +#endif diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx.h b/xorg-server/hw/xfree86/os-support/linux/lnx.h new file mode 100644 index 000000000..085c94265 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx.h @@ -0,0 +1,53 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef LNX_H_ +# ifdef __alpha__ +extern unsigned long _bus_base __P ((void)) __attribute__ ((const)); +extern unsigned long _bus_base_sparse __P ((void)) __attribute__ ((const)); +extern int iopl __P ((int __level)); + +/* new pciconfig_iobase syscall added in 2.2.15 and 2.3.99 */ +# include <linux/unistd.h> +extern long (*_iobase)(unsigned, int, int, int); + +/* + * _iobase deals with the case the __NR_pciconfig_iobase is either undefined + * or unsupported by the kernel, but we need to make sure that the `which' + * argument symbols are defined. + */ +# ifndef IOBASE_HOSE +# define IOBASE_HOSE 0 +# endif +# ifndef IOBASE_SPARSE_MEM +# define IOBASE_SPARSE_MEM 1 +# endif +# ifndef IOBASE_DENSE_MEM +# define IOBASE_DENSE_MEM 2 +# endif +# ifndef IOBASE_SPARSE_IO +# define IOBASE_SPARSE_IO 3 +# endif +# ifndef IOBASE_DENSE_IO +# define IOBASE_DENSE_IO 4 +# endif +# ifndef IOBASE_ROOT_BUS +# define IOBASE_ROOT_BUS 5 +# endif +# ifndef IOBASE_FROM_HOSE +# define IOBASE_FROM_HOSE 0x10000 +# endif +# endif /* __alpha__ */ + +# if defined(DO_OS_FONTRESTORE) +Bool lnx_savefont(void); +Bool lnx_restorefont(void); +Bool lnx_switchaway(void); +void lnx_freefontdata(void); +# endif + +#define LNX_H_ + +#endif diff --git a/xorg-server/hw/xfree86/os-support/linux/lnxResource.c b/xorg-server/hw/xfree86/os-support/linux/lnxResource.c new file mode 100644 index 000000000..67af9db3d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnxResource.c @@ -0,0 +1,104 @@ + +/* Resource information code */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Privstr.h" +#include "xf86Pci.h" +#include "xf86Resources.h" +#define NEED_OS_RAC_PROTOS +#include "xf86_OSlib.h" +#include "lnx.h" + +/* Avoid Imakefile changes */ +#include "bus/Pci.h" + +#ifdef INCLUDE_XF86_NO_DOMAIN + +#ifdef __alpha__ + +resPtr +xf86AccResFromOS(resPtr ret) +{ + resRange range; + + /* + * Fallback is to claim the following areas: + * + * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS + */ + + RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* + * Fallback would be to claim well known ports in the 0x0 - 0x3ff range + * along with their sparse I/O aliases, but that's too imprecise. Instead + * claim a bare minimum here. + */ + RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ + ret = xf86AddResToList(ret, &range, -1); + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ + RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); +/* RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); */ + RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* XXX add others */ + return ret; +} + +#elif defined(__powerpc__) || \ + defined(__sparc__) || \ + defined(__mips__) || \ + defined(__sh__) || \ + defined(__mc68000__) || \ + defined(__arm__) || \ + defined(__s390__) || \ + defined(__hppa__) + +resPtr +xf86AccResFromOS(resPtr ret) +{ + resRange range; + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ + RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); +#if defined(__sparc__) || defined(__powerpc__) + RANGE(range, 0x00ffffff, 0x00ffffff, ResExcIoBlock); +#else + RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); +#endif + ret = xf86AddResToList(ret, &range, -1); + + return ret; +} + +#else + +#error : Put your platform dependent code here!! + +#endif + +#endif /* INCLUDE_XF86_NO_DOMAIN */ diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_acpi.c b/xorg-server/hw/xfree86/os-support/linux/lnx_acpi.c new file mode 100644 index 000000000..bb975cc5d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_acpi.c @@ -0,0 +1,181 @@ +#ifdef HAVE_XORG_CONFIG_H +#include "xorg-config.h" +#endif + +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> + +#define ACPI_SOCKET "/var/run/acpid.socket" + +#define ACPI_VIDEO_NOTIFY_SWITCH 0x80 +#define ACPI_VIDEO_NOTIFY_PROBE 0x81 +#define ACPI_VIDEO_NOTIFY_CYCLE 0x82 +#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83 +#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84 + +#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85 +#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86 +#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87 +#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88 +#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89 + +#define ACPI_VIDEO_HEAD_INVALID (~0u - 1) +#define ACPI_VIDEO_HEAD_END (~0u) + +static void lnxCloseACPI(void); +static pointer ACPIihPtr = NULL; +PMClose lnxACPIOpen(void); + +/* in milliseconds */ +#define ACPI_REOPEN_DELAY 1000 + +static CARD32 +lnxACPIReopen(OsTimerPtr timer, CARD32 time, pointer arg) +{ + if (lnxACPIOpen()) { + TimerFree(timer); + return 0; + } + + return ACPI_REOPEN_DELAY; +} + +#define LINE_LENGTH 80 + +static int +lnxACPIGetEventFromOs(int fd, pmEvent *events, int num) +{ + char ev[LINE_LENGTH]; + int n; + + memset(ev, 0, LINE_LENGTH); + + do { + n = read( fd, ev, LINE_LENGTH ); + } while ((n == -1) && (errno == EAGAIN || errno == EINTR)); + + if (n <= 0) { + lnxCloseACPI(); + TimerSet(NULL, 0, ACPI_REOPEN_DELAY, lnxACPIReopen, NULL); + return 0; + } + /* FIXME: this only processes the first read ACPI event & might break + * with interrupted reads. */ + + /* Check that we have a video event */ + if (!strncmp(ev, "video", 5)) { + char *video = NULL; + char *GFX = NULL; + char *notify = NULL; + char *data = NULL; /* doesn't appear to be used in the kernel */ + unsigned long int notify_l, data_l; + + video = strtok(ev, " "); + + GFX = strtok(NULL, " "); +#if 0 + ErrorF("GFX: %s\n",GFX); +#endif + + notify = strtok(NULL, " "); + notify_l = strtoul(notify, NULL, 16); +#if 0 + ErrorF("notify: 0x%lx\n",notify_l); +#endif + + data = strtok(NULL, " "); + data_l = strtoul(data, NULL, 16); +#if 0 + ErrorF("data: 0x%lx\n",data_l); +#endif + + /* Differentiate between events */ + switch (notify_l) { + case ACPI_VIDEO_NOTIFY_SWITCH: + case ACPI_VIDEO_NOTIFY_CYCLE: + case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: + case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: + events[0] = XF86_APM_CAPABILITY_CHANGED; + return 1; + case ACPI_VIDEO_NOTIFY_PROBE: + return 0; + default: + return 0; + } + } + + return 0; +} + +static pmWait +lnxACPIConfirmEventToOs(int fd, pmEvent event) +{ + /* No ability to send back to the kernel in ACPI */ + switch (event) { + default: + return PM_NONE; + } +} + +PMClose +lnxACPIOpen(void) +{ + int fd; + struct sockaddr_un addr; + int r = -1; + +#ifdef DEBUG + ErrorF("ACPI: OSPMOpen called\n"); +#endif + if (ACPIihPtr || !xf86Info.pmFlag) + return NULL; + +#ifdef DEBUG + ErrorF("ACPI: Opening device\n"); +#endif + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) > -1) { + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, ACPI_SOCKET); + if ((r = connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1) { + xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_SOCKET, + strerror(errno)); + shutdown(fd, 2); + close(fd); + return NULL; + } + } + + xf86PMGetEventFromOs = lnxACPIGetEventFromOs; + xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs; + ACPIihPtr = xf86AddGeneralHandler(fd,xf86HandlePMEvents,NULL); + xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET); + + return lnxCloseACPI; +} + +static void +lnxCloseACPI(void) +{ + int fd; + +#ifdef DEBUG + ErrorF("ACPI: Closing device\n"); +#endif + if (ACPIihPtr) { + fd = xf86RemoveGeneralHandler(ACPIihPtr); + shutdown(fd, 2); + close(fd); + ACPIihPtr = NULL; + } +} diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c new file mode 100644 index 000000000..ded9e0fae --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c @@ -0,0 +1,374 @@ +/* + * Abstraction of the AGP GART interface. + * + * This version is for Linux and Free/Open/NetBSD. + * + * Copyright © 2000 VA Linux Systems, Inc. + * Copyright © 2001 The XFree86 Project, Inc. + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#if defined(linux) +#include <asm/ioctl.h> +#include <linux/agpgart.h> +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +#include <sys/ioctl.h> +#include <sys/agpio.h> +#endif + +#ifndef AGP_DEVICE +#define AGP_DEVICE "/dev/agpgart" +#endif +/* AGP page size is independent of the host page size. */ +#ifndef AGP_PAGE_SIZE +#define AGP_PAGE_SIZE 4096 +#endif +#define AGPGART_MAJOR_VERSION 0 +#define AGPGART_MINOR_VERSION 99 + +static int gartFd = -1; +static int acquiredScreen = -1; +static Bool initDone = FALSE; +/* + * Close /dev/agpgart. This frees all associated memory allocated during + * this server generation. + */ +_X_EXPORT Bool +xf86GARTCloseScreen(int screenNum) +{ + if(gartFd != -1) { + close(gartFd); + acquiredScreen = -1; + gartFd = -1; + initDone = FALSE; + } + return TRUE; +} + +/* + * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called. + */ +static Bool +GARTInit(int screenNum) +{ + struct _agp_info agpinf; + + if (initDone) + return (gartFd != -1); + + initDone = TRUE; + + if (gartFd == -1) + gartFd = open(AGP_DEVICE, O_RDWR, 0); + else + return FALSE; + + if (gartFd == -1) { + xf86DrvMsg(screenNum, X_ERROR, + "GARTInit: Unable to open " AGP_DEVICE " (%s)\n", + strerror(errno)); + return FALSE; + } + + xf86AcquireGART(-1); + /* Check the kernel driver version. */ + if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { + xf86DrvMsg(screenNum, X_ERROR, + "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno)); + close(gartFd); + gartFd = -1; + return FALSE; + } + xf86ReleaseGART(-1); + +#if defined(linux) + /* Per Dave Jones, every effort will be made to keep the + * agpgart interface backwards compatible, so allow all + * future versions. + */ + if ( +#if (AGPGART_MAJOR_VERSION > 0) /* quiet compiler */ + agpinf.version.major < AGPGART_MAJOR_VERSION || +#endif + (agpinf.version.major == AGPGART_MAJOR_VERSION && + agpinf.version.minor < AGPGART_MINOR_VERSION)) { + xf86DrvMsg(screenNum, X_ERROR, + "GARTInit: Kernel agpgart driver version is not current" + " (%d.%d vs %d.%d)\n", + agpinf.version.major, agpinf.version.minor, + AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION); + close(gartFd); + gartFd = -1; + return FALSE; + } +#endif + + return TRUE; +} + +_X_EXPORT Bool +xf86AgpGARTSupported() +{ + return GARTInit(-1); +} + +_X_EXPORT AgpInfoPtr +xf86GetAGPInfo(int screenNum) +{ + struct _agp_info agpinf; + AgpInfoPtr info; + + if (!GARTInit(screenNum)) + return NULL; + + + if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86GetAGPInfo: Failed to allocate AgpInfo\n"); + return NULL; + } + + memset((char*)&agpinf, 0, sizeof(agpinf)); + + if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n", + strerror(errno)); + return NULL; + } + + info->bridgeId = agpinf.bridge_id; + info->agpMode = agpinf.agp_mode; + info->base = agpinf.aper_base; + info->size = agpinf.aper_size; + info->totalPages = agpinf.pg_total; + info->systemPages = agpinf.pg_system; + info->usedPages = agpinf.pg_used; + + xf86DrvMsg(screenNum, X_INFO, "Kernel reported %d total, %d used\n", agpinf.pg_total, agpinf.pg_used); + + return info; +} + +/* + * XXX If multiple screens can acquire the GART, should we have a reference + * count instead of using acquiredScreen? + */ + +_X_EXPORT Bool +xf86AcquireGART(int screenNum) +{ + if (screenNum != -1 && !GARTInit(screenNum)) + return FALSE; + + if (screenNum == -1 || acquiredScreen != screenNum) { + if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = screenNum; + } + return TRUE; +} + +_X_EXPORT Bool +xf86ReleaseGART(int screenNum) +{ + if (screenNum != -1 && !GARTInit(screenNum)) + return FALSE; + + if (acquiredScreen == screenNum) { + /* + * The FreeBSD agp driver removes allocations on release. + * The Linux driver doesn't. xf86ReleaseGART() is expected + * to give up access to the GART, but not to remove any + * allocations. + */ +#if !defined(linux) + if (screenNum == -1) +#endif + { + if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = -1; + } + return TRUE; + } + return FALSE; +} + +_X_EXPORT int +xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical) +{ + struct _agp_allocate alloc; + int pages; + + /* + * Allocates "size" bytes of GART memory (rounds up to the next + * page multiple) or type "type". A handle (key) for the allocated + * memory is returned. On error, the return value is -1. + */ + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return -1; + + pages = (size / AGP_PAGE_SIZE); + if (size % AGP_PAGE_SIZE != 0) + pages++; + + /* XXX check for pages == 0? */ + + alloc.pg_count = pages; + alloc.type = type; + + if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: " + "allocation of %d pages failed\n\t(%s)\n", pages, + strerror(errno)); + return -1; + } + + if (physical) + *physical = alloc.physical; + + return alloc.key; +} + +_X_EXPORT Bool +xf86DeallocateGARTMemory(int screenNum, int key) +{ + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86UnbindGARTMemory: AGP not acquired by this screen\n"); + return FALSE; + } + +#ifdef __linux__ + if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) { +#else + if (ioctl(gartFd, AGPIOC_DEALLOCATE, &key) != 0) { +#endif + xf86DrvMsg(screenNum, X_WARNING,"xf86DeAllocateGARTMemory: " + "deallocation gart memory with key %d failed\n\t(%s)\n", + key, strerror(errno)); + return FALSE; + } + + return TRUE; +} + +/* Bind GART memory with "key" at "offset" */ +_X_EXPORT Bool +xf86BindGARTMemory(int screenNum, int key, unsigned long offset) +{ + struct _agp_bind bind; + int pageOffset; + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86BindGARTMemory: AGP not acquired by this screen\n"); + return FALSE; + } + + if (offset % AGP_PAGE_SIZE != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "offset (0x%lx) is not page-aligned (%d)\n", + offset, AGP_PAGE_SIZE); + return FALSE; + } + pageOffset = offset / AGP_PAGE_SIZE; + + xf86DrvMsgVerb(screenNum, X_INFO, 3, + "xf86BindGARTMemory: bind key %d at 0x%08lx " + "(pgoffset %d)\n", key, offset, pageOffset); + + bind.pg_start = pageOffset; + bind.key = key; + + if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "binding of gart memory with key %d\n" + "\tat offset 0x%lx failed (%s)\n", + key, offset, strerror(errno)); + return FALSE; + } + + return TRUE; +} + + +/* Unbind GART memory with "key" */ +_X_EXPORT Bool +xf86UnbindGARTMemory(int screenNum, int key) +{ + struct _agp_unbind unbind; + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86UnbindGARTMemory: AGP not acquired by this screen\n"); + return FALSE; + } + + unbind.priority = 0; + unbind.key = key; + + if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: " + "unbinding of gart memory with key %d " + "failed (%s)\n", key, strerror(errno)); + return FALSE; + } + + xf86DrvMsgVerb(screenNum, X_INFO, 3, + "xf86UnbindGARTMemory: unbind key %d\n", key); + + return TRUE; +} + + +/* XXX Interface may change. */ +_X_EXPORT Bool +xf86EnableAGP(int screenNum, CARD32 mode) +{ + agp_setup setup; + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + setup.agp_mode = mode; + if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: " + "AGPIOC_SETUP with mode %ld failed (%s)\n", + (unsigned long)mode, strerror(errno)); + return FALSE; + } + + return TRUE; +} + diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c b/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c new file mode 100644 index 000000000..16ac80db8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c @@ -0,0 +1,206 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" + +#ifdef HAVE_ACPI +extern PMClose lnxACPIOpen(void); +#endif + +#ifdef HAVE_APM + +#include "lnx.h" +#include <linux/apm_bios.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> + +#define APM_PROC "/proc/apm" +#define APM_DEVICE "/dev/apm_bios" + +#ifndef APM_STANDBY_FAILED +# define APM_STANDBY_FAILED 0xf000 +#endif +#ifndef APM_SUSPEND_FAILED +# define APM_SUSPEND_FAILED 0xf001 +#endif + +static PMClose lnxAPMOpen(void); +static void lnxCloseAPM(void); +static pointer APMihPtr = NULL; + +static struct { + apm_event_t apmLinux; + pmEvent xf86; +} LinuxToXF86[] = { + { APM_SYS_STANDBY, XF86_APM_SYS_STANDBY }, + { APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND }, + { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, + { APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME }, + { APM_LOW_BATTERY, XF86_APM_LOW_BATTERY }, + { APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, + { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, + { APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND }, + { APM_USER_STANDBY, XF86_APM_USER_STANDBY }, + { APM_USER_SUSPEND, XF86_APM_USER_SUSPEND }, + { APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, +#if defined(APM_CAPABILITY_CHANGED) + { APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED }, +#endif +#if 0 + { APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED }, + { APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED } +#endif +}; + +#define numApmEvents (sizeof(LinuxToXF86) / sizeof(LinuxToXF86[0])) + +/* + * APM is still under construction. + * I'm not sure if the places where I initialize/deinitialize + * apm is correct. Also I don't know what to do in SETUP state. + * This depends if wakeup gets called in this situation, too. + * Also we need to check if the action that is taken on an + * event is reasonable. + */ +static int +lnxPMGetEventFromOs(int fd, pmEvent *events, int num) +{ + int i,j,n; + apm_event_t linuxEvents[8]; + + if ((n = read( fd, linuxEvents, num * sizeof(apm_event_t) )) == -1) + return 0; + n /= sizeof(apm_event_t); + if (n > num) + n = num; + for (i = 0; i < n; i++) { + for (j = 0; j < numApmEvents; j++) + if (LinuxToXF86[j].apmLinux == linuxEvents[i]) { + events[i] = LinuxToXF86[j].xf86; + break; + } + if (j == numApmEvents) + events[i] = XF86_APM_UNKNOWN; + } + return n; +} + +static pmWait +lnxPMConfirmEventToOs(int fd, pmEvent event) +{ + switch (event) { + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: + if (ioctl( fd, APM_IOC_STANDBY, NULL )) + return PM_FAILED; + return PM_CONTINUE; + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: + case XF86_APM_USER_SUSPEND: + if (ioctl( fd, APM_IOC_SUSPEND, NULL )) { + /* I believe this is wrong (EE) + EBUSY is sent when a device refuses to be suspended. + In this case we still need to undo everything we have + done to suspend ourselves or we will stay in suspended + state forever. */ + if (errno == EBUSY) + return PM_CONTINUE; + else + return PM_FAILED; + } + return PM_CONTINUE; + case XF86_APM_STANDBY_RESUME: + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + case XF86_APM_STANDBY_FAILED: + case XF86_APM_SUSPEND_FAILED: + return PM_CONTINUE; + default: + return PM_NONE; + } +} + +#endif // HAVE_APM + +PMClose +xf86OSPMOpen(void) +{ + PMClose ret = NULL; + +#ifdef HAVE_ACPI + /* Favour ACPI over APM, but only when enabled */ + + if (!xf86acpiDisableFlag) + ret = lnxACPIOpen(); + + if (!ret) +#endif +#ifdef HAVE_APM + ret = lnxAPMOpen(); +#endif + + return ret; +} + +#ifdef HAVE_APM + +static PMClose +lnxAPMOpen(void) +{ + int fd, pfd; + +#ifdef DEBUG + ErrorF("APM: OSPMOpen called\n"); +#endif + if (APMihPtr || !xf86Info.pmFlag) + return NULL; + +#ifdef DEBUG + ErrorF("APM: Opening device\n"); +#endif + if ((fd = open( APM_DEVICE, O_RDWR )) > -1) { + if (access( APM_PROC, R_OK ) || + ((pfd = open( APM_PROC, O_RDONLY)) == -1)) { + xf86MsgVerb(X_WARNING,3,"Cannot open APM (%s) (%s)\n", + APM_PROC, strerror(errno)); + close(fd); + return NULL; + } else + close(pfd); + xf86PMGetEventFromOs = lnxPMGetEventFromOs; + xf86PMConfirmEventToOs = lnxPMConfirmEventToOs; + APMihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL); + xf86MsgVerb(X_INFO,3,"Open APM successful\n"); + return lnxCloseAPM; + } + xf86MsgVerb(X_INFO,3,"No APM support in BIOS or kernel\n"); + return NULL; +} + +static void +lnxCloseAPM(void) +{ + int fd; + +#ifdef DEBUG + ErrorF("APM: Closing device\n"); +#endif + if (APMihPtr) { + fd = xf86RemoveInputHandler(APMihPtr); + close(fd); + APMihPtr = NULL; + } +} + +#endif // HAVE_APM diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c new file mode 100644 index 000000000..a8ad161b6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c @@ -0,0 +1,199 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "shared/xf86Axp.h" + +axpDevice lnxGetAXP(void); + +typedef struct + { char* sysName; + char* sysVari; + char* cpu; + axpDevice sys; } +AXP; + +static AXP axpList[] = { + { "Tsunami", NULL, NULL, TSUNAMI }, + { "Eiger", NULL, NULL, TSUNAMI }, + {"Noname", NULL, NULL, LCA }, + { "AlphaBook1", NULL, NULL, LCA }, + {"EB66", NULL, NULL, LCA}, + {"EB64+",NULL,NULL, APECS}, + {"Noritake",NULL,"EV5",CIA}, + {"Noritake",NULL,"EV56",CIA}, + {"Noritake",NULL,NULL,APECS}, + {"XL",NULL,NULL,APECS}, + {"Avanti",NULL,NULL,APECS}, + {"Mikasa",NULL,"EV5",CIA}, + {"Mikasa",NULL,"EV56",CIA}, + {"Mikasa",NULL,NULL,APECS}, + {"EB164","EB164",NULL,CIA}, + {"EB164","PC164", NULL,CIA}, + {"EB164","LX164",NULL, PYXIS}, + {"EB164","SX164",NULL, PYXIS}, + {"EB164","RX164",NULL, POLARIS}, + {"Alcor",NULL,NULL,CIA}, + {"Takara",NULL,NULL,CIA}, + {"Sable",NULL, "EV5",T2_GAMMA}, + {"Sable",NULL,"EV56",T2_GAMMA}, + {"Sable",NULL,NULL,T2}, + {"Rawhide",NULL,NULL,MCPCIA}, + {"Jensen",NULL,NULL,JENSEN}, + {"Miata",NULL,NULL,PYXIS_CIA}, + {"Ruffian",NULL,NULL,PYXIS_CIA}, + {"Nautilus",NULL,NULL,IRONGATE}, + {NULL,NULL,NULL,NONE} +}; + + +axpDevice +lnxGetAXP(void) +{ + FILE *file; + int count = 0; + char res[256]; + char cpu[255]; + char systype[255]; + char sysvari[255]; + if (!(file = fopen("/proc/cpuinfo","r"))) + return SYS_NONE; + do { + if (!fgets(res,0xff,file)) return SYS_NONE; + switch (count) { + case 1: + sscanf(res, "cpu model : %s",cpu); +#ifdef DEBUG + ErrorF("CPU %s\n",cpu); +#endif + break; + case 5: + sscanf(res, "system type : %s",systype); +#ifdef DEBUG + ErrorF("system type : %s\n",systype); +#endif + break; + case 6: + sscanf(res, "system variation : %s",sysvari); +#ifdef DEBUG + ErrorF("system variation: %s\n",sysvari); +#endif + break; + } + count++; + } while (count < 8); + + fclose(file); + + count = 0; + + do { + if (!axpList[count].sysName || !strcmp(axpList[count].sysName,systype)) { + if (axpList[count].sysVari && strcmp(axpList[count].sysVari,sysvari)) { + count++; + continue; + }; + if (axpList[count].cpu && strcmp(axpList[count].cpu,cpu)) { + count++; + continue; + } + return axpList[count].sys; + } + count++; + } while (1); +} + +/* + * pciconfig_iobase wrappers and dynamic i/o selection + */ +#include "lnx.h" +#include <unistd.h> +#include <errno.h> + +/* glibc versions (single hose only) */ +extern void _outb(char val, unsigned long port); +extern void _outw(short val, unsigned long port); +extern void _outl(int val, unsigned long port); +extern unsigned int _inb(unsigned long port); +extern unsigned int _inw(unsigned long port); +extern unsigned int _inl(unsigned long port); + +extern void _dense_outb(char, unsigned long); +extern void _dense_outw(short, unsigned long); +extern void _dense_outl(int, unsigned long); +extern unsigned int _dense_inb(unsigned long); +extern unsigned int _dense_inw(unsigned long); +extern unsigned int _dense_inl(unsigned long); + +_X_EXPORT void (*_alpha_outb)(char, unsigned long) = _outb; +_X_EXPORT void (*_alpha_outw)(short, unsigned long) = _outw; +_X_EXPORT void (*_alpha_outl)(int, unsigned long) = _outl; +_X_EXPORT unsigned int (*_alpha_inb)(unsigned long) = _inb; +_X_EXPORT unsigned int (*_alpha_inw)(unsigned long) = _inw; +_X_EXPORT unsigned int (*_alpha_inl)(unsigned long) = _inl; + +static long _alpha_iobase_query(unsigned, int, int, int); +long (*_iobase)(unsigned, int, int, int) = _alpha_iobase_query; + +static long +_alpha_iobase(unsigned flags, int hose, int bus, int devfn) +{ +#ifdef __NR_pciconfig_iobase + if (bus < 0) { + bus = hose; + flags |= IOBASE_FROM_HOSE; + } + + return syscall(__NR_pciconfig_iobase, flags, bus, devfn); +#else + return -ENOSYS +#endif +} + +static long +_alpha_iobase_legacy(unsigned flags, int hose, int bus, int devfn) +{ + if (hose > 0) return -ENODEV; + if (flags & IOBASE_DENSE_MEM) return _bus_base(); + if (flags & IOBASE_SPARSE_MEM) return _bus_base_sparse(); + return 0; +} + +static long +_alpha_iobase_query(unsigned flags, int hose, int bus, int devfn) +{ + /* + * Only use iobase if the syscall is supported *and* it's + * a dense io system + */ + if (_alpha_iobase(IOBASE_DENSE_IO, 0, 0, 0) > 0) { + /* + * The syscall worked and it's a dense io system - take over the + * io subsystem + */ + _iobase = _alpha_iobase; + +#ifndef INCLUDE_XF86_NO_DOMAIN + /* + * Only take over the inx/outx functions if this is a dense I/O + * system *and* addressing domains are being used. The dense I/O + * routines expect I/O to be mapped (as done in xf86MapLegacyIO) + */ + _alpha_outb = _dense_outb; + _alpha_outw = _dense_outw; + _alpha_outl = _dense_outl; + _alpha_inb = _dense_inb; + _alpha_inw = _dense_inw; + _alpha_inl = _dense_inl; +#endif /* !INCLUDE_XF86_NO_DOMAIN */ + } else _iobase = _alpha_iobase_legacy; + + return _iobase(flags, hose, bus, devfn); +} + diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_bell.c b/xorg-server/hw/xfree86/os-support/linux/lnx_bell.c new file mode 100644 index 000000000..93ad680d7 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_bell.c @@ -0,0 +1,45 @@ +/* + * Copyright © 2006 Daniel Stone + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Daniel Stone <daniel@fooishbar.org> + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/ioctl.h> +#include <linux/kd.h> + +#include "xf86.h" +#include "xf86Priv.h" + +_X_EXPORT void +xf86OSRingBell(int loudness, int pitch, int duration) +{ + if (xf86Info.consoleFd == -1 || !pitch || !loudness) + return; + + ioctl(xf86Info.consoleFd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration * loudness / 50) << 16)); +} diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c b/xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c new file mode 100644 index 000000000..11c45e538 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_ev56.c @@ -0,0 +1,150 @@ +/* This file has to be built with -mcpu=ev56 */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +int readDense8(pointer Base, register unsigned long Offset); +int readDense16(pointer Base, register unsigned long Offset); +int readDense32(pointer Base, register unsigned long Offset); +void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset); +void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset); +void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset); +void +writeDense8(int Value, pointer Base, register unsigned long Offset); +void +writeDense16(int Value, pointer Base, register unsigned long Offset); +void +writeDense32(int Value, pointer Base, register unsigned long Offset); + +int +readDense8(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD8*) ((unsigned long)Base+(Offset)); +} + +int +readDense16(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD16*) ((unsigned long)Base+(Offset)); +} + +int +readDense32(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD32*)((unsigned long)Base+(Offset)); +} + +void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD8*)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD16*)((unsigned long)Base + (Offset)) = Value; +} + +void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD32*)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense8(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD8 *)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense16(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD16 *)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense32(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD32 *)((unsigned long)Base+(Offset)) = Value; +} + + +#ifndef INCLUDE_XF86_NO_DOMAIN + +void +_dense_outb(char val, unsigned long port) +{ + if ((port & ~0xffff) == 0) return _outb(val, port); + + write_mem_barrier(); + *(volatile CARD8 *)port = val; +} + +void +_dense_outw(short val, unsigned long port) +{ + if ((port & ~0xffff) == 0) return _outw(val, port); + + write_mem_barrier(); + *(volatile CARD16 *)port = val; +} + +void +_dense_outl(int val, unsigned long port) +{ + if ((port & ~0xffff) == 0) return _outl(val, port); + + write_mem_barrier(); + *(volatile CARD32 *)port = val; +} + +unsigned int +_dense_inb(unsigned long port) +{ + if ((port & ~0xffff) == 0) return _inb(port); + + mem_barrier(); + return *(volatile CARD8 *)port; +} + +unsigned int +_dense_inw(unsigned long port) +{ + if ((port & ~0xffff) == 0) return _inw(port); + + mem_barrier(); + return *(volatile CARD16 *)port; +} + +unsigned int +_dense_inl(unsigned long port) +{ + if ((port & ~0xffff) == 0) return _inl(port); + + mem_barrier(); + return *(volatile CARD32 *)port; +} + +#endif /* !INCLUDE_XF86_NO_DOMAIN */ + diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_font.c b/xorg-server/hw/xfree86/os-support/linux/lnx_font.c new file mode 100644 index 000000000..e9a5b6aef --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_font.c @@ -0,0 +1,291 @@ +/* + * Copyright 2004, Egbert Eich + * + * 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 + * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- + * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Egbert Eich shall not + * be used in advertising or otherwise to promote the sale, use or other deal- + *ings in this Software without prior written authorization from Egbert Eich. + * + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "lnx.h" + +#include <sys/stat.h> +#include <string.h> +#include <errno.h> + +struct { + int width; + int height; + int charcount; + unsigned char *data; +} lnxfont = { 0, 0, 0, NULL }; + + +static Bool +getfont(int *width, int *height, + int *charcount, unsigned char *data) +{ + struct console_font_op op; + struct consolefontdesc ds; + int result; + + op.op = KD_FONT_OP_GET; + op.width = *width; + op.height = *height; + op.charcount = *charcount; + op.data = data; + op.flags = 0; + + SYSCALL(result = ioctl(xf86Info.consoleFd, KDFONTOP, &op)); +#ifdef DEBUG + ErrorF("Console font read: h: %i count: %i\n",op.height,op.charcount); +#endif + + if (!result) { + + *width = op.width; + *height = op.height; + *charcount = op.charcount; + + return TRUE; + } + + if (errno != ENOSYS && errno != EINVAL) + return FALSE; + + /* GIO_FONTX fallback */ + ds.charcount = *charcount; + ds.charheight = *height; + ds.chardata = (char *)data; + *width = 8; + + SYSCALL(result = ioctl(xf86Info.consoleFd, GIO_FONTX, &ds)); + + if (!result) { + + *charcount = ds.charcount; + *height = ds.charheight; + + return TRUE; + } + + if (errno != ENOSYS && errno != EINVAL) + return FALSE; + + /* GIO_FONT fallback */ + if (*charcount < 256) + return FALSE; + + SYSCALL(result = ioctl(xf86Info.consoleFd, GIO_FONT, data)); + + if (!result) { + *height = 0; + *charcount = 512; + return TRUE; + } + + return FALSE; + +} + +#define VERSION_LEN 31 + +Bool +lnx_savefont(void) +{ + unsigned char *fontdata; +#if CHECK_OS_VERSION + char kernel_version[VERSION_LEN + 1]; + int k_major, k_minor, k_release; +#endif + int size; + int fd; + int width = 32, height = 32, charcount = 2048; + +#ifdef DEBUG + ErrorF("SAVE font\n"); +#endif + +#if CHECK_OS_VERSION + /* Check if the kernel has full support for this */ + if ((fd = open ("/proc/sys/kernel/osrelease",O_RDONLY)) == -1) { + close (fd); + return TRUE; + } + size = read(fd, kernel_version, VERSION_LEN); + close (fd); + + if (size < 0) + return TRUE; + + size = sscanf(kernel_version, "%d.%d.%d",&k_major,&k_minor,&k_release); + if (size < 3 + || (k_major < 2) + || ((k_major == 2) + && ((k_minor < 6) + || ( k_minor == 6 + && k_release < 11)))) + return TRUE; +#endif + + /* if we are in fbdev mode we don't bother saving fonts */ + if ((fd = open ("/dev/fb0",O_RDWR)) != -1) { + close (fd); + return TRUE; + } + + if (!getfont(&width, &height, &charcount, NULL)) { + xf86Msg(X_WARNING, + "lnx_savefont: cannot obtain font info\n"); + goto error; + } else if (charcount == 2048) { + xf86Msg(X_WARNING, "lnx_savefont: " + "kernel bug: kernel doesn't report font info\n"); + return FALSE; + } + + size = (width + 7)/8 * 32 * charcount; + fontdata = (unsigned char *)xnfalloc(size); + if (!fontdata) { + xf86Msg(X_WARNING, + "lnx_savefont: cannot allocate memory to save font\n"); + goto error; + } + + if (!getfont(&width, &height, &charcount, fontdata)) { + xf86Msg(X_WARNING,"lnx_savefont: cannot read font data\n"); + goto error; + } + lnxfont.width = width; + lnxfont.height = height; + lnxfont.charcount = charcount; + lnxfont.data = fontdata; + + return TRUE; + + error: + return FALSE; +} + +static Bool +setfont(int width, int height, + int charcount, unsigned char *data) +{ + struct console_font_op op; + struct consolefontdesc ds; + int result; + + op.op = KD_FONT_OP_SET; + op.flags = 0; + op.charcount = charcount; + op.width = width; + op.height = height; + op.data = data; + + SYSCALL(result = ioctl(xf86Info.consoleFd, KDFONTOP, &op)); + + if (!result) + return TRUE; + + if (errno != ENOSYS && errno != EINVAL) + return FALSE; + + /* PIO_FONTX fallback */ + if (width != 8) + return FALSE; + + ds.charcount = charcount; + ds.chardata = (char *)data; + ds.charheight = height; + SYSCALL(result = ioctl(xf86Info.consoleFd, PIO_FONTX, &ds)); + + if (!result) + return TRUE; + + if (errno != ENOSYS && errno != EINVAL) + return FALSE; + + /* PIO_FONT fallback */ + SYSCALL(result = ioctl(xf86Info.consoleFd, PIO_FONT, data)); + + if (!result) + return TRUE; + + return FALSE; +} + +Bool +lnx_restorefont(void) +{ + if (lnxfont.data == NULL) + return FALSE; +#ifdef DEBUG + ErrorF("RESTORE font\n"); +#endif +#if 0 + /* must wack the height to make the kernel reprogram the VGA registers */ + if (!setfont(lnxfont.width, lnxfont.height + 1, lnxfont.charcount, + lnxfont.data)) { + xf86Msg(X_WARNING,"lnx_fontretore: cannot write font data\n"); + return FALSE; + } +#endif + if (!setfont(lnxfont.width, lnxfont.height, lnxfont.charcount, + lnxfont.data)) { + xf86Msg(X_WARNING,"lnx_restorefont: cannot write font data\n"); + return FALSE; + } + + return TRUE; +} + +Bool +lnx_switchaway(void) +{ + Bool ret; + + /* temporarily switch to text mode */ + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); + ret = lnx_restorefont(); + ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS); + return ret; +} + +void +lnx_freefontdata(void) +{ + if (lnxfont.data == NULL) + return; + + xfree(lnxfont.data); + lnxfont.data = NULL; + lnxfont.width = lnxfont.height = lnxfont.charcount = 0; +} diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c new file mode 100644 index 000000000..da5ca57cc --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c @@ -0,0 +1,466 @@ +/* + * Copyright 1992 by Orest Zborowski <obz@Kodak.com> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Orest Zborowski and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Orest Zborowski + * and David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "lnx.h" + +#include <sys/stat.h> + +#ifdef USE_DEV_FB +extern char *getenv(const char *); +#include <linux/fb.h> +char *fb_dev_name; +#endif + +static Bool KeepTty = FALSE; +static int VTnum = -1; +static Bool VTSwitch = TRUE; +static Bool ShareVTs = FALSE; +static int activeVT = -1; + +static int vtPermSave[4]; +static char vtname[11]; +static struct termios tty_attr; /* tty state to restore */ +static int tty_mode; /* kbd mode to restore */ + +static int +saveVtPerms(void) +{ + /* We need to use stat to get permissions. */ + struct stat svtp; + + /* Do them numerically ordered, hard coded tty0 first. */ + if (stat("/dev/tty0", &svtp) != 0) + return 0; + vtPermSave[0] = (int)svtp.st_uid; + vtPermSave[1] = (int)svtp.st_gid; + + /* Now check the console we are dealing with. */ + if (stat(vtname, &svtp) != 0) + return 0; + vtPermSave[2] = (int)svtp.st_uid; + vtPermSave[3] = (int)svtp.st_gid; + + return 1; +} + +static void +restoreVtPerms(void) +{ + /* Set the terminal permissions back to before we started. */ + chown("/dev/tty0", vtPermSave[0], vtPermSave[1]); + chown(vtname, vtPermSave[2], vtPermSave[3]); +} + +static void *console_handler; + +static void +drain_console(int fd, void *closure) +{ + tcflush(fd, TCIOFLUSH); +} + +void +xf86OpenConsole(void) +{ + int i, fd = -1; + struct vt_mode VT; + struct vt_stat vts; + MessageType from = X_PROBED; +#ifdef USE_DEV_FB + struct fb_var_screeninfo var; + int fbfd; +#endif + char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL }; + char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL }; + + if (serverGeneration == 1) { + + /* when KeepTty check if we're run with euid==0 */ + if (KeepTty && geteuid() != 0) + FatalError("xf86OpenConsole:" + " Server must be suid root for option \"KeepTTY\"\n"); + + /* + * setup the virtual terminal manager + */ + if (VTnum != -1) { + xf86Info.vtno = VTnum; + from = X_CMDLINE; + } else { + + i=0; + while (tty0[i] != NULL) { + if ((fd = open(tty0[i],O_WRONLY,0)) >= 0) + break; + i++; + } + + if (fd < 0) + FatalError( + "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n", + strerror(errno)); + + if (ShareVTs) + { + if (ioctl(fd, VT_GETSTATE, &vts) == 0) + xf86Info.vtno = vts.v_active; + else + FatalError("xf86OpenConsole: Cannot find the current" + " VT (%s)\n", strerror(errno)); + } else { + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + FatalError("xf86OpenConsole: Cannot find a free VT: %s\n", + strerror(errno)); + } + close(fd); + } + +#ifdef USE_DEV_FB + if (!ShareVTs) + { + fb_dev_name=getenv("FRAMEBUFFER"); + if (!fb_dev_name) + fb_dev_name="/dev/fb0current"; + + if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0) + FatalError("xf86OpenConsole: Cannot open %s (%s)\n", + fb_dev_name, strerror(errno)); + + if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var) < 0) + FatalError("xf86OpenConsole: Unable to get screen info %s\n", + strerror(errno)); + } +#endif + xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); + + if (!KeepTty) { + pid_t ppid = getppid(); + pid_t ppgid; + ppgid = getpgid(ppid); + + /* + * change to parent process group that pgid != pid so + * that setsid() doesn't fail and we become process + * group leader + */ + if (setpgid(0,ppgid) < 0) + xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n", + strerror(errno)); + + /* become process group leader */ + if ((setsid() < 0)) + xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n", + strerror(errno)); + } + + i=0; + while (vcs[i] != NULL) { + sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */ + if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0) + break; + i++; + } + + if (xf86Info.consoleFd < 0) + FatalError("xf86OpenConsole: Cannot open virtual console" + " %d (%s)\n", xf86Info.vtno, strerror(errno)); + + if (!ShareVTs) + { + /* + * Grab the vt ownership before we overwrite it. + * Hard coded /dev/tty0 into this function as well for below. + */ + if (!saveVtPerms()) + xf86Msg(X_WARNING, + "xf86OpenConsole: Could not save ownership of VT\n"); + + /* change ownership of the vt */ + if (chown(vtname, getuid(), getgid()) < 0) + xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n", + vtname, strerror(errno)); + + /* + * the current VT device we're running on is not "console", we want + * to grab all consoles too + * + * Why is this needed?? + */ + if (chown("/dev/tty0", getuid(), getgid()) < 0) + xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n", + strerror(errno)); + } + + /* + * Linux doesn't switch to an active vt after the last close of a vt, + * so we do this ourselves by remembering which is active now. + */ + if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0) + xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n", + strerror(errno)); + else + activeVT = vts.v_active; + +#if 0 + if (!KeepTty) { + /* + * Detach from the controlling tty to avoid char loss + */ + if ((i = open("/dev/tty",O_RDWR)) >= 0) { + ioctl(i, TIOCNOTTY, 0); + close(i); + } + } +#endif + + if (!ShareVTs) + { +#if defined(DO_OS_FONTRESTORE) + lnx_savefont(); +#endif + /* + * now get the VT. This _must_ succeed, or else fail completely. + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) + FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", + strerror(errno)); + + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) + FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n", + strerror(errno)); + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + FatalError("xf86OpenConsole: VT_GETMODE failed %s\n", + strerror(errno)); + + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n", + strerror(errno)); + + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n", + strerror(errno)); + + /* Set the keyboard to RAW mode. If we're using the keyboard + * driver, the driver does it for us. If we have AEI on, then + * we're expecting the devices to be added (i.e. evdev) and we + * have to set it manually. + */ + if (xf86Info.allowEmptyInput) + { + struct termios nTty; + + tcgetattr(xf86Info.consoleFd, &tty_attr); + ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode); + + if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0) + FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n", + strerror(errno)); + + nTty = tty_attr; + nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8; + nTty.c_lflag = 0; + nTty.c_cc[VTIME]=0; + nTty.c_cc[VMIN]=1; + cfsetispeed(&nTty, 9600); + cfsetospeed(&nTty, 9600); + tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty); + + /* need to keep the buffer clean, else the kernel gets angry */ + console_handler = xf86AddGeneralHandler(xf86Info.consoleFd, + drain_console, NULL); + } + + /* we really should have a InitOSInputDevices() function instead + * of Init?$#*&Device(). So I just place it here */ + +#ifdef USE_DEV_FB + /* copy info to new console */ + var.yoffset=0; + var.xoffset=0; + if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var)) + FatalError("Unable to set screen info\n"); + close(fbfd); +#endif + } else { /* ShareVTs */ + close(xf86Info.consoleFd); + } + signal(SIGUSR2, xf86ReloadInputDevs); + } else { /* serverGeneration != 1 */ + if (!ShareVTs && VTSwitch) + { + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n", + strerror(errno)); + } + + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n", + strerror(errno)); + } + return; +} + +void +xf86CloseConsole() +{ + struct vt_mode VT; +#if defined(DO_OS_FONTRESTORE) + struct vt_stat vts; + int vtno = -1; +#endif + + if (ShareVTs) return; + + if (console_handler) { + xf86RemoveGeneralHandler(console_handler); + console_handler = NULL; + }; + +#if defined(DO_OS_FONTRESTORE) + if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETSTATE failed: %s\n", + strerror(errno)); + else + vtno = vts.v_active; +#endif + + /* Back to text mode ... */ + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n", + strerror(errno)); + + ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode); + tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr); + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n", + strerror(errno)); + else { + /* set dflt vt handling */ + VT.mode = VT_AUTO; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n", + strerror(errno)); + } + + if (VTSwitch) + { + /* + * Perform a switch back to the active VT when we were started + */ + if (activeVT >= 0) { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n", + strerror(errno)); + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0) + xf86Msg(X_WARNING, + "xf86CloseConsole: VT_WAITACTIVE failed: %s\n", + strerror(errno)); + activeVT = -1; + } + +#if defined(DO_OS_FONTRESTORE) + if (xf86Info.vtno == vtno) /* check if we are active */ + lnx_restorefont(); + lnx_freefontdata(); +#endif + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + + restoreVtPerms(); /* restore the permissions */ + + return; +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } + if (!strcmp(argv[i], "-novtswitch")) + { + VTSwitch = FALSE; + return(1); + } + if (!strcmp(argv[i], "-sharevts")) + { + ShareVTs = TRUE; + return(1); + } + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + return(0); +} + +void +xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + ErrorF("-novtswitch don't immediately switch to new VT\n"); + ErrorF("-sharevts share VTs with another X server\n"); + return; +} diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_jstk.c b/xorg-server/hw/xfree86/os-support/linux/lnx_jstk.c new file mode 100644 index 000000000..d77631ba4 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_jstk.c @@ -0,0 +1,180 @@ +/* + * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> + * + * 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 Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED 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. + * + */ + + +static const char rcs_id[] = "Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp"; + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/types.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#define inline __inline__ +#include <linux/joystick.h> +#include <fcntl.h> +#include <sys/ioctl.h> + +#include "xf86.h" + +#if !defined(JSIOCGTIMELIMIT) +/* make 2.1.x joystick.h backward compatable */ +#define JSIOCGTIMELIMIT JS_GET_TIMELIMIT +#define JSIOCSTIMELIMIT JS_SET_TIMELIMIT +#define js_status JS_DATA_TYPE +#endif + + +/*********************************************************************** + * + * xf86JoystickOn -- + * + * open the device and init timeout according to the device value. + * + *********************************************************************** + */ + +int +xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY) +{ + int fd; + struct js_status js; + +#ifdef DEBUG + ErrorF("xf86JoystickOn %s\n", name); +#endif + + if ((fd = open(name, O_RDWR | O_NDELAY, 0)) < 0) + { + xf86Msg(X_WARNING, "Cannot open joystick '%s' (%s)\n", name, + strerror(errno)); + return -1; + } + + if (*timeout == 0) { + if (ioctl (fd, JSIOCGTIMELIMIT, timeout) == -1) { + Error("joystick JSIOCGTIMELIMIT ioctl"); + } + else { + xf86Msg(X_CONFIG, "Joystick: timeout value = %d\n", *timeout); + } + } + else { + if (ioctl(fd, JSIOCSTIMELIMIT, timeout) == -1) { + Error("joystick JSIOCSTIMELIMIT ioctl"); + } + } + + /* Assume the joystick is centred when this is called */ + read(fd, &js, JS_RETURN); + if (*centerX < 0) { + *centerX = js.x; + xf86Msg(X_CONFIG, "Joystick: CenterX set to %d\n", *centerX); + } + if (*centerY < 0) { + *centerY = js.y; + xf86Msg(X_CONFIG, "Joystick: CenterY set to %d\n", *centerY); + } + + return fd; +} + +/*********************************************************************** + * + * xf86JoystickInit -- + * + * called when X device is initialized. + * + *********************************************************************** + */ + +void +xf86JoystickInit() +{ + return; +} + +/*********************************************************************** + * + * xf86JoystickOff -- + * + * close the handle. + * + *********************************************************************** + */ + +int +xf86JoystickOff(int *fd, int doclose) +{ + int oldfd; + + if (((oldfd = *fd) >= 0) && doclose) { + close(*fd); + *fd = -1; + } + return oldfd; +} + +/*********************************************************************** + * + * xf86JoystickGetState -- + * + * return the state of buttons and the position of the joystick. + * + *********************************************************************** + */ + +int +xf86JoystickGetState(int fd, int *x, int *y, int *buttons) +{ + struct js_status js; + int status; + + status = read(fd, &js, JS_RETURN); + + if (status != JS_RETURN) + { + Error("Joystick read"); + return 0; + } + + *x = js.x; + *y = js.y; + *buttons = js.buttons; + + return 1; +} + +/* + * Entry point for XFree86 Loader + */ +void +linux_jstkModuleInit(pointer *data, INT32 *magic) +{ + *magic = MAGIC_DONE; + *data = NULL; +} + +/* end of lnx_jstk.c */ diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c b/xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c new file mode 100644 index 000000000..4e6f2d25d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_kmod.c @@ -0,0 +1,112 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/wait.h> +#include <signal.h> +#include "xf86_OSlib.h" +#include "xf86.h" + + +#define MODPROBE_PATH_FILE "/proc/sys/kernel/modprobe" +#define MAX_PATH 1024 + + +#if 0 +/* XFree86 #defines execl to be the xf86execl() function which does + * a fork AND exec. We don't want that. We want the regular, + * standard execl(). + */ +#ifdef execl +#undef execl +#endif +#endif + + +/* + * Load a Linux kernel module. + * This is used by the DRI/DRM to load a DRM kernel module when + * the X server starts. It could be used for other purposes in the future. + * Input: + * modName - name of the kernel module (Ex: "tdfx") + * Return: + * 0 for failure, 1 for success + */ +_X_EXPORT int +xf86LoadKernelModule(const char *modName) +{ + char mpPath[MAX_PATH] = ""; + int fd = -1, status, n; + pid_t pid; + + /* get the path to the modprobe program */ + fd = open(MODPROBE_PATH_FILE, O_RDONLY); + if (fd >= 0) { + int count = read(fd, mpPath, MAX_PATH - 1); + if (count <= 0) { + mpPath[0] = 0; + } + else if (mpPath[count - 1] == '\n') { + mpPath[count - 1] = 0; /* replaces \n with \0 */ + } + close(fd); + /* if this worked, mpPath will be "/sbin/modprobe" or similar. */ + } + + if (mpPath[0] == 0) { + /* we failed to get the path from the system, use a default */ + strcpy(mpPath, "/sbin/modprobe"); + } + + /* now fork/exec the modprobe command */ + /* + * It would be good to capture stdout/stderr so that it can be directed + * to the log file. modprobe errors currently are missing from the log + * file. + */ + switch (pid = fork()) { + case 0: /* child */ + /* change real/effective user ID to 0/0 as we need to + * preinstall agpgart module for some DRM modules + */ + if (setreuid(0,0)) { + xf86Msg(X_WARNING,"LoadKernelModule: " + "Setting of real/effective user Id to 0/0 failed"); + } + setenv("PATH","/sbin",1); + n = execl(mpPath, "modprobe", modName, NULL); + xf86Msg(X_WARNING,"LoadKernelModule %s\n",strerror(errno)); + exit(EXIT_FAILURE); /* if we get here the child's exec failed */ + break; + case -1: /* fork failed */ + return 0; + default: /* fork worked */ + { + /* XXX we loop over waitpid() because it sometimes fails on + * the first attempt. Don't know why! + */ + int count = 0, p; + do { + p = waitpid(pid, &status, 0); + } while (p == -1 && count++ < 4); + + if (p == -1) { + return 0; + } + + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { + return 1; /* success! */ + } + else { + return 0; + } + } + } + + /* never get here */ + return 0; +} diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_mouse.c b/xorg-server/hw/xfree86/os-support/linux/lnx_mouse.c new file mode 100644 index 000000000..d2822153f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_mouse.c @@ -0,0 +1,221 @@ + +/* + * Copyright 1999 by The XFree86 Project, Inc. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" +#include "xf86_OSlib.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +static int +SupportedInterfaces(void) +{ + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; +} + +static const char * +DefaultProtocol(void) +{ + return "Auto"; +} + +#define DEFAULT_MOUSE_DEV "/dev/input/mice" +#define DEFAULT_PS2_DEV "/dev/psaux" +#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata" +#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata" + +static const char *mouseDevs[] = { + DEFAULT_MOUSE_DEV, + DEFAULT_PS2_DEV, + DEFAULT_GPM_DATA_DEV, + NULL +}; + +typedef enum { + MOUSE_PROTO_UNKNOWN = 0, + MOUSE_PROTO_SERIAL, + MOUSE_PROTO_PS2, + MOUSE_PROTO_MSC, + MOUSE_PROTO_GPM, + MOUSE_PROTO_EXPPS2, +} protocolTypes; + +static struct { + protocolTypes proto; + const char *name; +} devproto[] = { + { MOUSE_PROTO_UNKNOWN, NULL }, + { MOUSE_PROTO_PS2, "PS/2" }, + { MOUSE_PROTO_MSC, "MouseSystems" }, + { MOUSE_PROTO_GPM, "GPM" }, + { MOUSE_PROTO_EXPPS2, "ExplorerPS/2" }, +}; + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + int fd = -1; + const char **pdev; + + for (pdev = mouseDevs; *pdev; pdev++) { + SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL)); + if (fd == -1) { +#ifdef DEBUG + ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno)); +#endif + } else + break; + } + + if (*pdev) { + close(fd); + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", *pdev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, *pdev); + } + + return *pdev; +} + +static const char * +lnxMouseMagic(InputInfoPtr pInfo) +{ + int fd = -1; + const char *dev; + char *realdev; + struct stat sbuf; + int i; + int proto = MOUSE_PROTO_UNKNOWN; + + dev = xf86SetStrOption(pInfo->conf_idev->commonOptions, "Device", NULL); + if (!dev) { +#ifdef DEBUG + ErrorF("xf86SetStrOption failed to return the device name\n"); +#endif + return NULL; + } + /* Look at the device name to guess the protocol. */ + realdev = NULL; + if (strcmp(dev, DEFAULT_MOUSE_DEV) == 0) { + if (lstat(dev, &sbuf) != 0) { +#ifdef DEBUG + ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno)); +#endif + return NULL; + } + if (S_ISLNK(sbuf.st_mode)) { + realdev = xnfalloc(PATH_MAX + 1); + i = readlink(dev, realdev, PATH_MAX); + if (i <= 0) { +#ifdef DEBUG + ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno)); +#endif + xfree(realdev); + return NULL; + } + realdev[i] = '\0'; + } + } + if (!realdev) + realdev = xnfstrdup(dev); + else { + /* If realdev doesn't contain a '/' then prepend "/dev/" */ + if (!strchr(realdev, '/')) { + char *tmp = xnfalloc(strlen(realdev) + 5 + 1); + sprintf(tmp, "/dev/%s", realdev); + xfree(realdev); + realdev = tmp; + } + } + + if (strcmp(realdev, DEFAULT_MOUSE_DEV) == 0) + proto = MOUSE_PROTO_EXPPS2; + else if (strcmp(realdev, DEFAULT_PS2_DEV) == 0) + proto = MOUSE_PROTO_EXPPS2; + else if (strcmp(realdev, DEFAULT_GPM_DATA_DEV) == 0) + proto = MOUSE_PROTO_MSC; + else if (strcmp(realdev, DEFAULT_GPM_CTL_DEV) == 0) + proto = MOUSE_PROTO_GPM; + xfree(realdev); + /* + * If the protocol can't be guessed from the device name, + * try to characterise it. + */ + if (proto == MOUSE_PROTO_UNKNOWN) { + SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL)); + if (isatty(fd)) { + /* Serial PnP has already failed, so give up. */ + } else { + if (fstat(fd, &sbuf) != 0) { +#ifdef DEBUG + ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno)); +#endif + close(fd); + return NULL; + } + if (S_ISFIFO(sbuf.st_mode)) { + /* Assume GPM data in MSC format. */ + proto = MOUSE_PROTO_MSC; + } else { + /* Default to PS/2 */ + proto = MOUSE_PROTO_PS2; + } + } + close(fd); + } + if (proto == MOUSE_PROTO_UNKNOWN) { + xf86Msg(X_ERROR, "%s: Cannot find mouse protocol.\n", + pInfo->name); + return NULL; + } else { + for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) { + if (devproto[i].proto == proto) { + xf86Msg(X_INFO, + "%s: Setting mouse protocol to \"%s\"\n", + pInfo->name, devproto[i].name); + return devproto[i].name; + } + } + } + return NULL; +} + +static const char * +GuessProtocol(InputInfoPtr pInfo, int flags) +{ + return lnxMouseMagic(pInfo); +} + +static const char * +SetupAuto(InputInfoPtr pInfo, int *protoPara) +{ + return lnxMouseMagic(pInfo); +} + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; + p->DefaultProtocol = DefaultProtocol; + p->FindDevice = FindDevice; + p->GuessProtocol = GuessProtocol; + p->SetupAuto = SetupAuto; + return p; +} + diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_pci.c b/xorg-server/hw/xfree86/os-support/linux/lnx_pci.c new file mode 100644 index 000000000..8eedfa49f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_pci.c @@ -0,0 +1,193 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/types.h> +#include <stdio.h> +#include <dirent.h> +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86Pci.h" +#include "Pci.h" + +#ifdef __sparc__ +#define PCIADDR_TYPE long long +#define PCIADDR_IGNORE_FMT "%*x" +#define PCIADDR_FMT "%llx" +#else +#define PCIADDR_TYPE long +#define PCIADDR_IGNORE_FMT "%*x" +#define PCIADDR_FMT "%lx" +#endif + +struct pci_dev { + unsigned int domain; + unsigned int bus; + unsigned int dev; + unsigned int fn; + PCIADDR_TYPE offset[7]; + PCIADDR_TYPE size[7]; + struct pci_dev *next; +}; + +struct pci_dev *xf86OSLinuxPCIDevs = NULL; +int xf86OSLinuxNumPciDevs = 0; + +static struct pci_dev *xf86OSLinuxGetPciDevs(void) { + char c[0x200]; + FILE *file = NULL; + DIR *dir; + struct dirent *dirent; + struct pci_dev *tmp, *ret = NULL; + unsigned int i, num, devfn; + unsigned PCIADDR_TYPE begin, end; + char *res; + + /* Try 2.6 devices first, with domain support */ + if ( (dir = opendir ("/sys/bus/pci/devices")) ) { + xf86OSLinuxNumPciDevs = 0; + while ( (dirent = readdir (dir)) ) { + unsigned int domain, bus, dev, fn; + if (sscanf (dirent->d_name, "%04x:%02x:%02x.%01x", + &domain, &bus, &dev, &fn) == 4) { + tmp = xcalloc (sizeof(struct pci_dev), 1); + tmp->domain = domain; + tmp->bus = bus; + tmp->dev = dev; + tmp->fn = fn; + sprintf (c, "/sys/bus/pci/devices/%12s/resource", + dirent->d_name); + i = 0; + if ( (file = fopen (c, "r")) ) { + while (i < 7 && fgets (c, 0x200, file)) { + if (sscanf (c, PCIADDR_FMT " " PCIADDR_FMT " " + PCIADDR_IGNORE_FMT, &begin, &end) == 2) { + tmp->offset[i] = begin; + tmp->size[i] = begin ? end-begin+1 : 0; + i++; + } + } + fclose (file); + } + if (i > 0) { + tmp->next = ret; + ret = tmp; + xf86OSLinuxNumPciDevs++; + } else + xfree (tmp); + } + } + closedir (dir); + } + + if (ret) + return ret; + + file = fopen("/proc/bus/pci/devices", "r"); + if (!file) return NULL; + + xf86OSLinuxNumPciDevs = 0; + + do { + res = fgets(c, 0x1ff, file); + if (res) { + tmp = xcalloc(sizeof(struct pci_dev),1); + num = sscanf(res, + /*bus+dev vendorid deviceid irq */ + "%02x%02x\t%*04x%*04x\t%*x" + /* 7 PCI resource base addresses */ + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + /* 7 PCI resource sizes, and then optionally a driver name */ + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT + "\t" PCIADDR_FMT, + &tmp->bus,&devfn,&tmp->offset[0],&tmp->offset[1],&tmp->offset[2],&tmp->offset[3], + &tmp->offset[4],&tmp->offset[5],&tmp->offset[6], &tmp->size[0], &tmp->size[1], &tmp->size[2], + &tmp->size[3], &tmp->size[4], &tmp->size[5], &tmp->size[6]); + tmp->dev = devfn >> 3; + tmp->fn = devfn & 0x7; + if (num != 16) { /* apparantly not 2.3 style */ + xfree(tmp); + fclose(file); + return NULL; + } + if (ret) { + tmp->next = ret; + } + ret = tmp; + xf86OSLinuxNumPciDevs++; + } + } while (res); + fclose(file); + return ret; +} + +/* Query the kvirt address (64bit) of a BAR range from size for a given TAG */ +unsigned long +xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) +{ + unsigned int ndx; + struct pci_dev *device; + struct pci_device *dev; + + if (!xf86OSLinuxPCIDevs) { + xf86OSLinuxPCIDevs = xf86OSLinuxGetPciDevs(); + } + if (!xf86OSLinuxPCIDevs) { + return FALSE; + } + + for (device = xf86OSLinuxPCIDevs; device; device = device->next) { + dev = pci_device_find_by_slot(device->domain, device->bus, + device->dev, device->fn); + if (dev != NULL) { + /* ok now look through all the BAR values of this device */ + for (ndx=0; ndx<7; ndx++) { + uint32_t savePtr; + uint32_t flagMask; + + /* The ROM BAR isn't with the other BARs. + */ + const pciaddr_t offset = (ndx == 6) + ? (4 * 12) : (4 * ndx) + 16; + + pci_device_cfg_read_u32(dev, &savePtr, offset); + + /* Ignore unset base addresses. The kernel may have reported + * non-zero size and address even if they are disabled (e.g., + * disabled ROM BAR). + */ + if (savePtr == 0) + continue; + + /* Remove memory attribute bits, different for IO + * and memory ranges. + */ + flagMask = (savePtr & 0x1) ? ~0x3UL : ~0xFUL; + savePtr &= flagMask; + + /* find the index of the incoming base */ + if (base >= savePtr && base < (savePtr + device->size[ndx])) { + return (device->offset[ndx] & flagMask) + (base - savePtr); + } + } + } + } + + return 0; +} diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c new file mode 100644 index 000000000..1bd2d575f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c @@ -0,0 +1,1106 @@ +/* + * Copyright 1992 by Orest Zborowski <obz@Kodak.com> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Orest Zborowski and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Orest Zborowski + * and David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <string.h> + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" +#include "lnx.h" +#ifdef __alpha__ +#include "shared/xf86Axp.h" +#endif + +#ifdef HAS_MTRR_SUPPORT +#include <asm/mtrr.h> +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +static Bool ExtendedEnabled = FALSE; + +#ifdef __ia64__ + +#include "compiler.h" +#include <sys/io.h> + +#elif !defined(__powerpc__) && \ + !defined(__mc68000__) && \ + !defined(__sparc__) && \ + !defined(__mips__) && \ + !defined(__arm__) + +/* + * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare + * these. + */ +extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on); +extern int iopl(int __level); + +#endif + +#ifdef __alpha__ + +# ifdef LIBC_IS_FIXED +extern void sethae(unsigned long hae); +# else +# include <unistd.h> +# define sethae(x) syscall(301,x); +# endif + +/* define to test the Sparse addressing on a non-Jensen */ +# ifdef TEST_JENSEN_CODE +# define isJensen (1) +# else +# define isJensen (axpSystem == JENSEN) +# endif + +# define BUS_BASE bus_base + +#else + +#define BUS_BASE (0) + +#endif /* __alpha__ */ + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static pointer mapVidMem(int, unsigned long, unsigned long, int); +static void unmapVidMem(int, pointer, unsigned long); +#if defined (__alpha__) +static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); +extern axpDevice lnxGetAXP(void); +static void unmapVidMemSparse(int, pointer, unsigned long); +# if defined(JENSEN_SUPPORT) +static pointer mapVidMemJensen(int, unsigned long, unsigned long, int); +static void unmapVidMemJensen(int, pointer, unsigned long); +# endif +static axpDevice axpSystem = -1; +static Bool needSparse; +static unsigned long hae_thresh; +static unsigned long hae_mask; +static unsigned long bus_base; +static unsigned long sparse_size; +#endif + +#ifdef HAS_MTRR_SUPPORT + +#define SPLIT_WC_REGIONS 1 + +static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); +static void undoWC(int, pointer); + +/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr + driver will clean up when we exit. */ +#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */ +#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had + a problem. */ +static int mtrr_fd = MTRR_FD_UNOPENED; + +/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, + and will fail on Linux 2.2 with MTRR support configured out, + so verbosity should be chosen appropriately. */ +static Bool +mtrr_open(int verbosity) +{ + /* Only report absence of /proc/mtrr once. */ + static Bool warned = FALSE; + + if (mtrr_fd == MTRR_FD_UNOPENED) { + mtrr_fd = open("/proc/mtrr", O_WRONLY); + + if (mtrr_fd < 0) + mtrr_fd = MTRR_FD_PROBLEM; + } + + if (mtrr_fd == MTRR_FD_PROBLEM) { + /* To make sure we only ever warn once, need to check + verbosity outside xf86MsgVerb */ + if (!warned && verbosity <= xf86GetVerbosity()) { + xf86MsgVerb(X_WARNING, verbosity, + "System lacks support for changing MTRRs\n"); + warned = TRUE; + } + + return FALSE; + } + else + return TRUE; +} + +/* + * We maintain a list of WC regions for each physical mapping so they can + * be undone when unmapping. + */ + +struct mtrr_wc_region { + struct mtrr_sentry sentry; + Bool added; /* added WC or removed it */ + struct mtrr_wc_region * next; +}; + + +static struct mtrr_wc_region * +mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size, + MessageType from) +{ + /* Some BIOS writers thought that setting wc over the mmio + region of a graphics devices was a good idea. Try to fix + it. */ + + struct mtrr_gentry gent; + struct mtrr_wc_region *wcreturn = NULL, *wcr; + int count, ret=0; + + /* Linux 2.0 users should not get a warning without -verbose */ + if (!mtrr_open(2)) + return NULL; + + for (gent.regnum = 0; + ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; + gent.regnum++) { + if (gent.type != MTRR_TYPE_WRCOMB + || gent.base + gent.size <= base + || base + size <= gent.base) + continue; + + /* Found an overlapping region. Delete it. */ + + wcr = xalloc(sizeof(*wcr)); + if (!wcr) + return NULL; + wcr->sentry.base = gent.base; + wcr->sentry.size = gent.size; + wcr->sentry.type = MTRR_TYPE_WRCOMB; + wcr->added = FALSE; + + count = 3; + while (count-- && + (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0); + + if (ret >= 0) { + xf86DrvMsg(screenNum, from, + "Removed MMIO write-combining range " + "(0x%lx,0x%lx)\n", + (unsigned long) gent.base, (unsigned long) gent.size); + wcr->next = wcreturn; + wcreturn = wcr; + gent.regnum--; + } else { + xfree(wcr); + xf86DrvMsgVerb(screenNum, X_WARNING, 0, + "Failed to remove MMIO " + "write-combining range (0x%lx,0x%lx)\n", + gent.base, (unsigned long) gent.size); + } + } + return wcreturn; +} + + +static struct mtrr_wc_region * +mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size, + MessageType from) +{ + struct mtrr_gentry gent; + struct mtrr_wc_region *wcreturn = NULL, **wcr; + + if (!mtrr_open(2)) + return NULL; + + wcr = &wcreturn; + for (gent.regnum = 0; + ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++ ) { + if (gent.type == MTRR_TYPE_WRCOMB + && ((gent.base >= base && gent.base + gent.size < base + size) || + (gent.base > base && gent.base + gent.size <= base + size))) { + *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from); + if (*wcr) gent.regnum--; + while(*wcr) { + wcr = &((*wcr)->next); + } + } + } + return wcreturn; +} + + +static struct mtrr_wc_region * +mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size, + MessageType from) +{ + struct mtrr_wc_region **wcr, *wcreturn, *curwcr; + + /* + * There can be only one.... + */ + + wcreturn = mtrr_remove_offending(screenNum, base, size, from); + wcr = &wcreturn; + while (*wcr) { + wcr = &((*wcr)->next); + } + + /* Linux 2.0 should not warn, unless the user explicitly asks for + WC. */ + + if (!mtrr_open(from == X_CONFIG ? 0 : 2)) + return wcreturn; + + *wcr = curwcr = xalloc(sizeof(**wcr)); + if (!curwcr) + return wcreturn; + + curwcr->sentry.base = base; + curwcr->sentry.size = size; + curwcr->sentry.type = MTRR_TYPE_WRCOMB; + curwcr->added = TRUE; + curwcr->next = NULL; + +#if SPLIT_WC_REGIONS + /* + * Splits up the write-combining region if it is not aligned on a + * size boundary. + */ + + { + unsigned long lbase, d_size = 1; + unsigned long n_size = size; + unsigned long n_base = base; + + for (lbase = n_base, d_size = 1; !(lbase & 1); + lbase = lbase >> 1, d_size <<= 1); + while (d_size > n_size) + d_size = d_size >> 1; +#ifdef DEBUG + ErrorF("WC_BASE: 0x%lx WC_END: 0x%lx\n",base,base+d_size-1); +#endif + n_base += d_size; + n_size -= d_size; + if (n_size) { + xf86DrvMsgVerb(screenNum,X_INFO,3,"Splitting WC range: " + "base: 0x%lx, size: 0x%lx\n",base,size); + curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size,from); + } + curwcr->sentry.size = d_size; + } + + /*****************************************************************/ +#endif /* SPLIT_WC_REGIONS */ + + if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) { + /* Avoid printing on every VT switch */ + if (xf86ServerIsInitialising()) { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx)\n", + base, size); + } + return wcreturn; + } + else { + *wcr = curwcr->next; + xfree(curwcr); + + /* Don't complain about the VGA region: MTRR fixed + regions aren't currently supported, but might be in + the future. */ + if ((unsigned long)base >= 0x100000) { + xf86DrvMsgVerb(screenNum, X_WARNING, 0, + "Failed to set up write-combining range " + "(0x%lx,0x%lx)\n", base, size); + } + return wcreturn; + } +} + +static void +mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr) +{ + struct mtrr_wc_region *p, *prev; + + if (mtrr_fd > 0) { + p = wcr; + while (p) { + if (p->added) + ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry); + prev = p; + p = p->next; + xfree(prev); + } + } +} + +static pointer +setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + if (enable) + return mtrr_add_wc_region(screenNum, base, size, from); + else + return mtrr_cull_wc_region(screenNum, base, size, from); +} + +static void +undoWC(int screenNum, pointer regioninfo) +{ + mtrr_undo_wc_region(screenNum, regioninfo); +} + +#endif /* HAS_MTRR_SUPPORT */ + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; +#ifdef __alpha__ + if (axpSystem == -1) { + axpSystem = lnxGetAXP(); + if ((needSparse = (_bus_base_sparse() > 0))) { + hae_thresh = xf86AXPParams[axpSystem].hae_thresh; + hae_mask = xf86AXPParams[axpSystem].hae_mask; + sparse_size = xf86AXPParams[axpSystem].size; + } + bus_base = _bus_base(); + } + if (isJensen) { +# ifndef JENSEN_SUPPORT + FatalError("Jensen is not supported any more\n" + "If you are intereseted in fixing Jensen support\n" + "please contact xorg@lists.freedesktop.org\n"); +# else + xf86Msg(X_INFO,"Machine type is Jensen\n"); + pVidMem->mapMem = mapVidMemJensen; + pVidMem->unmapMem = unmapVidMemJensen; +# endif /* JENSEN_SUPPORT */ + } else if (needSparse) { + xf86Msg(X_INFO,"Machine needs sparse mapping\n"); + pVidMem->mapMem = mapVidMemSparse; + pVidMem->unmapMem = unmapVidMemSparse; + } else { + xf86Msg(X_INFO,"Machine type has 8/16 bit access\n"); + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; + } +#else + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; +#endif /* __alpha__ */ + + +#ifdef HAS_MTRR_SUPPORT + pVidMem->setWC = setWC; + pVidMem->undoWC = undoWC; +#endif + pVidMem->initialised = TRUE; +} + +#ifdef __sparc__ +/* Basically, you simply cannot do this on Sparc. You have to do something portable + * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM + */ +static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + return NULL; +} +#else +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + int fd; + int mapflags = MAP_SHARED; + int prot; + memType realBase, alignOff; + + realBase = Base & ~(getpagesize() - 1); + alignOff = Base - realBase; +#ifdef DEBUG + ErrorF("base: %lx, realBase: %lx, alignOff: %lx \n", + Base,realBase,alignOff); +#endif + +#if defined(__ia64__) || defined(__arm__) || defined(__s390__) +#ifndef MAP_WRITECOMBINED +#define MAP_WRITECOMBINED 0x00010000 +#endif +#ifndef MAP_NONCACHED +#define MAP_NONCACHED 0x00020000 +#endif + if(flags & VIDMEM_FRAMEBUFFER) + mapflags |= MAP_WRITECOMBINED; + else + mapflags |= MAP_NONCACHED; +#endif + +#if 0 + /* this will disappear when people upgrade their kernels */ + fd = open(DEV_MEM, + ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC); +#else + fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); +#endif + if (fd < 0) + { + FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", + strerror(errno)); + } + + if (flags & VIDMEM_READONLY) + prot = PROT_READ; + else + prot = PROT_READ | PROT_WRITE; + + /* This requires linux-0.99.pl10 or above */ + base = mmap((caddr_t)0, Size + alignOff, prot, mapflags, fd, + (off_t)realBase + BUS_BASE); + close(fd); + if (base == MAP_FAILED) { + FatalError("xf86MapVidMem: Could not mmap framebuffer" + " (0x%08lx,0x%lx) (%s)\n", Base, Size, + strerror(errno)); + } +#ifdef DEBUG + ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff); +#endif + return (char *)base + alignOff; +} +#endif /* !(__sparc__) */ + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + memType alignOff = (memType)Base + - ((memType)Base & ~(getpagesize() - 1)); + +#ifdef DEBUG + ErrorF("alignment offset: %lx\n",alignOff); +#endif + munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff)); +} + + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +#if defined(__powerpc__) +_X_EXPORT volatile unsigned char *ioBase = NULL; + +#ifndef __NR_pciconfig_iobase +#define __NR_pciconfig_iobase 200 +#endif + +#endif + +_X_EXPORT Bool +xf86EnableIO(void) +{ +#if defined(__powerpc__) + int fd; + unsigned int ioBase_phys; +#endif + + if (ExtendedEnabled) + return TRUE; + +#if defined(__powerpc__) + ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0); + + fd = open("/dev/mem", O_RDWR); + if (ioBase == NULL) { + ioBase = (volatile unsigned char *)mmap(0, 0x20000, + PROT_READ | PROT_WRITE, MAP_SHARED, fd, + ioBase_phys); +/* Should this be fatal or just a warning? */ +#if 0 + if (ioBase == MAP_FAILED) { + xf86Msg(X_WARNING, + "xf86EnableIOPorts: Failed to map iobase (%s)\n", + strerror(errno)); + return FALSE; + } +#endif + } + close(fd); +#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) + if (ioperm(0, 1024, 1) || iopl(3)) { + if (errno == ENODEV) + ErrorF("xf86EnableIOPorts: no I/O ports found\n"); + else + FatalError("xf86EnableIOPorts: failed to set IOPL" + " for I/O (%s)\n", strerror(errno)); + return FALSE; + } +# if !defined(__alpha__) + ioperm(0x40,4,0); /* trap access to the timer chip */ + ioperm(0x60,4,0); /* trap access to the keyboard controller */ +# endif +#endif + ExtendedEnabled = TRUE; + + return TRUE; +} + +_X_EXPORT void +xf86DisableIO(void) +{ + if (!ExtendedEnabled) + return; +#if defined(__powerpc__) + munmap(ioBase, 0x20000); + ioBase = NULL; +#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) + iopl(0); + ioperm(0, 1024, 0); +#endif + ExtendedEnabled = FALSE; + + return; +} + +/* + * Don't use these two functions. They can't possibly work. If you actually + * need interrupts off for something, you ought to be doing it in the kernel + * anyway. + */ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + return (TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + return; +} + +#if defined (__alpha__) + +#define vuip volatile unsigned int * + +extern int readDense8(pointer Base, register unsigned long Offset); +extern int readDense16(pointer Base, register unsigned long Offset); +extern int readDense32(pointer Base, register unsigned long Offset); +extern void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset); +extern void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset); +extern void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense8(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense16(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense32(int Value, pointer Base, register unsigned long Offset); + +static int readSparse8(pointer Base, register unsigned long Offset); +static int readSparse16(pointer Base, register unsigned long Offset); +static int readSparse32(pointer Base, register unsigned long Offset); +static void +writeSparseNB8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseNB16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseNB32(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse32(int Value, pointer Base, register unsigned long Offset); + +#define DENSE_BASE 0x2ff00000000UL +#define SPARSE_BASE 0x30000000000UL + +static unsigned long msb_set = 0; + +static pointer +mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + int fd, prot; + unsigned long ret, rets = 0; + + static Bool was_here = FALSE; + + if (!was_here) { + was_here = TRUE; + + xf86WriteMmio8 = writeSparse8; + xf86WriteMmio16 = writeSparse16; + xf86WriteMmio32 = writeSparse32; + xf86WriteMmioNB8 = writeSparseNB8; + xf86WriteMmioNB16 = writeSparseNB16; + xf86WriteMmioNB32 = writeSparseNB32; + xf86ReadMmio8 = readSparse8; + xf86ReadMmio16 = readSparse16; + xf86ReadMmio32 = readSparse32; + } + + fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) { + FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", + strerror(errno)); + } + +#if 0 + xf86Msg(X_INFO,"mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n", + Base, Size, flags); +#endif + + if (flags & VIDMEM_READONLY) + prot = PROT_READ; + else + prot = PROT_READ | PROT_WRITE; + + /* This requirers linux-0.99.pl10 or above */ + + /* + * Always do DENSE mmap, since read32/write32 currently require it. + */ + ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size, + prot, MAP_SHARED, fd, + (off_t) (bus_base + Base)); + + /* + * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER + * and SPARSE (which should require the use of read/write macros). + * + * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K + * bytes worth of pagetable (32 pages). + */ + if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) || + ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) + { + rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)), + Size << 5, prot, MAP_SHARED, fd, + (off_t) _bus_base_sparse() + (Base << 5)); + } + + close(fd); + + if (ret == (unsigned long)MAP_FAILED) { + FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n", + strerror(errno)); + } + + if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) || + ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) + { + if (rets == (unsigned long)MAP_FAILED || + rets != (SPARSE_BASE + (Base << 5))) + { + FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n", + strerror(errno)); + } + } + +#if 1 + if (rets) + xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx" + " to DENSE at 0x%lx and SPARSE at 0x%lx\n", + Base, Size, ret, rets); + else + xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx" + " to DENSE only at 0x%lx\n", + Base, Size, ret); + +#endif + return (pointer) ret; +} + +static void +unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size) +{ + unsigned long Offset = (unsigned long)Base - DENSE_BASE; +#if 1 + xf86Msg(X_INFO,"unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n", + Base, Size); +#endif + /* Unmap DENSE always. */ + munmap((caddr_t)Base, Size); + + /* Unmap SPARSE always, and ignore error in case we did not map it. */ + munmap((caddr_t)(SPARSE_BASE + (Offset << 5)), Size << 5); +} + +static int +readSparse8(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + register unsigned long msb; + + mem_barrier(); + Offset += (unsigned long)Base - DENSE_BASE; + shift = (Offset & 0x3) << 3; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { + sethae(msb); + msb_set = msb; + } + } + + mem_barrier(); + result = *(vuip) (SPARSE_BASE + (Offset << 5)); + result >>= shift; + return 0xffUL & result; +} + +static int +readSparse16(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + register unsigned long msb; + + mem_barrier(); + Offset += (unsigned long)Base - DENSE_BASE; + shift = (Offset & 0x2) << 3; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { + sethae(msb); + msb_set = msb; + } + } + + mem_barrier(); + result = *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))); + result >>= shift; + return 0xffffUL & result; +} + +static int +readSparse32(pointer Base, register unsigned long Offset) +{ + /* NOTE: this is really using DENSE. */ + mem_barrier(); + return *(vuip)((unsigned long)Base+(Offset)); +} + +static void +writeSparse8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int b = Value & 0xffU; + + write_mem_barrier(); + Offset += (unsigned long)Base - DENSE_BASE; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { + sethae(msb); + msb_set = msb; + } + } + + write_mem_barrier(); + *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101; +} + +static void +writeSparse16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int w = Value & 0xffffU; + + write_mem_barrier(); + Offset += (unsigned long)Base - DENSE_BASE; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { + sethae(msb); + msb_set = msb; + } + } + + write_mem_barrier(); + *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))) = w * 0x00010001; +} + +static void +writeSparse32(int Value, pointer Base, register unsigned long Offset) +{ + /* NOTE: this is really using DENSE. */ + write_mem_barrier(); + *(vuip)((unsigned long)Base + (Offset)) = Value; + return; +} + +static void +writeSparseNB8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int b = Value & 0xffU; + + Offset += (unsigned long)Base - DENSE_BASE; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { + sethae(msb); + msb_set = msb; + } + } + *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101; +} + +static void +writeSparseNB16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int w = Value & 0xffffU; + + Offset += (unsigned long)Base - DENSE_BASE; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { + sethae(msb); + msb_set = msb; + } + } + *(vuip)(SPARSE_BASE+(Offset<<5)+(1<<(5-2))) = w * 0x00010001; +} + +static void +writeSparseNB32(int Value, pointer Base, register unsigned long Offset) +{ + /* NOTE: this is really using DENSE. */ + *(vuip)((unsigned long)Base + (Offset)) = Value; + return; +} + +_X_EXPORT void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset) + = writeDense8; +_X_EXPORT void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset) + = writeDense16; +_X_EXPORT void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset) + = writeDense32; +_X_EXPORT void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB8; +_X_EXPORT void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB16; +_X_EXPORT void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB32; +_X_EXPORT int (*xf86ReadMmio8)(pointer Base, unsigned long Offset) + = readDense8; +_X_EXPORT int (*xf86ReadMmio16)(pointer Base, unsigned long Offset) + = readDense16; +_X_EXPORT int (*xf86ReadMmio32)(pointer Base, unsigned long Offset) + = readDense32; + +#ifdef JENSEN_SUPPORT + +static int +readSparseJensen8(pointer Base, register unsigned long Offset); +static int +readSparseJensen16(pointer Base, register unsigned long Offset); +static int +readSparseJensen32(pointer Base, register unsigned long Offset); +static void +writeSparseJensen8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseJensen16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseJensen32(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset); + +/* + * The Jensen lacks dense memory, thus we have to address the bus via + * the sparse addressing scheme. + * + * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 + */ + +#ifdef TEST_JENSEN_CODE +#define SPARSE (5) +#else +#define SPARSE (7) +#endif + +#define JENSEN_SHIFT(x) ((long)x<<SPARSE) + +static pointer +mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + int fd, prot; + + xf86WriteMmio8 = writeSparseJensen8; + xf86WriteMmio16 = writeSparseJensen16; + xf86WriteMmio32 = writeSparseJensen32; + xf86WriteMmioNB8 = writeSparseJensenNB8; + xf86WriteMmioNB16 = writeSparseJensenNB16; + xf86WriteMmioNB32 = writeSparseJensenNB32; + xf86ReadMmio8 = readSparseJensen8; + xf86ReadMmio16 = readSparseJensen16; + xf86ReadMmio32 = readSparseJensen32; + + fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) { + FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", + strerror(errno)); + } + + if (flags & VIDMEM_READONLY) + prot = PROT_READ; + else + prot = PROT_READ | PROT_WRITE; + + /* This requires linux-0.99.pl10 or above */ + base = mmap((caddr_t)0, JENSEN_SHIFT(Size), + prot, MAP_SHARED, fd, + (off_t)(JENSEN_SHIFT((off_t)Base) + _bus_base_sparse())); + close(fd); + if (base == MAP_FAILED) { + FatalError("xf86MapVidMem: Could not mmap framebuffer" + " (0x%08x,0x%x) (%s)\n", Base, Size, + strerror(errno)); + } + return base; +} + +static void +unmapVidMemJensen(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap((caddr_t)Base, JENSEN_SHIFT(Size)); +} + +static int +readSparseJensen8(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + + mem_barrier(); + shift = (Offset & 0x3) << 3; + + result = *(vuip) ((unsigned long)Base + (Offset << SPARSE)); + + result >>= shift; + return 0xffUL & result; +} + +static int +readSparseJensen16(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + + mem_barrier(); + shift = (Offset & 0x2) << 3; + + result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))); + + result >>= shift; + return 0xffffUL & result; +} + +static int +readSparseJensen32(pointer Base, register unsigned long Offset) +{ + register unsigned long result; + + mem_barrier(); + result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))); + + return result; +} + +static void +writeSparseJensen8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned int b = Value & 0xffU; + + write_mem_barrier(); + *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101; +} + +static void +writeSparseJensen16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned int w = Value & 0xffffU; + + write_mem_barrier(); + *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) = + w * 0x00010001; +} + +static void +writeSparseJensen32(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value; +} + +static void +writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned int b = Value & 0xffU; + + *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101; +} + +static void +writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned int w = Value & 0xffffU; + + *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) = + w * 0x00010001; +} + +static void +writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset) +{ + *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value; +} +#endif /* JENSEN_SUPPORT */ + +#endif /* __alpha__ */ diff --git a/xorg-server/hw/xfree86/os-support/lynxos/Makefile.am b/xorg-server/hw/xfree86/os-support/lynxos/Makefile.am new file mode 100644 index 000000000..4085c49a9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/Makefile.am @@ -0,0 +1,8 @@ +EXTRA_DIST = \ + lynx_init.c \ + lynx_mmap.c \ + lynx_mouse.c \ + lynx_noinline.c \ + lynx_ppc.c \ + lynx_video.c \ + lynx_ppc.S diff --git a/xorg-server/hw/xfree86/os-support/lynxos/Makefile.in b/xorg-server/hw/xfree86/os-support/lynxos/Makefile.in new file mode 100644 index 000000000..b4641474d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/Makefile.in @@ -0,0 +1,540 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/lynxos +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +EXTRA_DIST = \ + lynx_init.c \ + lynx_mmap.c \ + lynx_mouse.c \ + lynx_noinline.c \ + lynx_ppc.c \ + lynx_video.c \ + lynx_ppc.S + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/lynxos/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/lynxos/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/lynxos/lynx_init.c b/xorg-server/hw/xfree86/os-support/lynxos/lynx_init.c new file mode 100644 index 000000000..03f72ca19 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/lynx_init.c @@ -0,0 +1,192 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * 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 Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static int VTnum = -1; + +void +xf86OpenConsole() +{ + struct vt_mode VT; + char vtname1[11]; + int fd, pgrp; + MessageType from = X_PROBED; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be suid root\n"); + } + + /* + * setup the virtual terminal manager + * NOTE: + * We use the out-of-the-box atc terminal driver, + * not the GE contributed vdt driver. + * Also, we do setup signals for VT switching which + * is not really necessary because we don't feed the + * VT switch keystrokes to the kernel in xf86Events.c + * (it bombs occasionally...) + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + from = X_CMDLINE; + } + else + { + /* We could use /dev/con which is usually a symlink + * to /dev/atc0 but one could configure the system + * to use a serial line as console device, so to + * be sure we take /dev/atc0. + */ + if ((fd = open("/dev/atc0",O_WRONLY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open /dev/atc0 (%s)\n", + strerror(errno)); + } + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + { + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + } + close(fd); + } + xf86Msg(from, "using VT number %d\n", xf86Info.vtno); + + sprintf(vtname1,"/dev/atc%d",xf86Info.vtno); + + pgrp = getpgrp(); /* POSIX version ! */ + ioctl(xf86Info.consoleFd, TIOCSPGRP, &pgrp); + + if ((xf86Info.consoleFd = open(vtname1,O_RDWR|O_NDELAY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open %s (%s)\n", + vtname1, strerror(errno)); + } + /* change ownership of the vt */ + chown(vtname1, getuid(), getgid()); + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_GETMODE failed\n"); + } + + /* for future use... */ + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + } + else + { + /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86Screens[0]->vtSema) + sleep(5); + } + return; +} + +void +xf86CloseConsole() +{ + struct vt_mode VT; + +#if 0 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno); + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0); +#endif + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + return(0); +} + +void +xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + return; +} + diff --git a/xorg-server/hw/xfree86/os-support/lynxos/lynx_mmap.c b/xorg-server/hw/xfree86/os-support/lynxos/lynx_mmap.c new file mode 100644 index 000000000..3364399aa --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/lynx_mmap.c @@ -0,0 +1,72 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * 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 Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Read BIOS using smem_create facility + */ + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ +#if defined(__powerpc__) + xf86Msg(X_WARNING, "xf86ReadBios: no BIOS-probe on PowerPC\n"); + return(-1); +#else + char *p; + int mlen; + + mlen = (Offset + Len + 4095) & ~4095; + p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ); + if (p == NULL) + { + /* check if there is a stale segment around */ + if (smem_remove("BIOS-probe") == 0) { + xf86Msg(X_INFO, + "xf86ReadBios: removed stale smem_ segment\n"); + p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ); + } + if (p == NULL) { + xf86Msg(X_WARNING, "xf86ReadBios: Failed to smem_create " + "Base %x len %x %s \n", + Base, mlen, strerror(errno)); + return(-1); + } + } + memcpy(Buf, p + Offset, Len); + smem_create(NULL, p, 0, SM_DETACH); + smem_remove("BIOS-probe"); + return(Len); +#endif +} diff --git a/xorg-server/hw/xfree86/os-support/lynxos/lynx_mouse.c b/xorg-server/hw/xfree86/os-support/lynxos/lynx_mouse.c new file mode 100644 index 000000000..b48202977 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/lynx_mouse.c @@ -0,0 +1,33 @@ + +/* + * Copyright 1999 by The XFree86 Project, Inc. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" + +static int +SupportedInterfaces(void) +{ + /* XXX Need to check this. */ + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO; +} + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; + return p; +} + diff --git a/xorg-server/hw/xfree86/os-support/lynxos/lynx_noinline.c b/xorg-server/hw/xfree86/os-support/lynxos/lynx_noinline.c new file mode 100644 index 000000000..d4db82cca --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/lynx_noinline.c @@ -0,0 +1,177 @@ +/* + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#if /* NO_INLINE && */ defined(__powerpc__) + +#include "xf86Pci.h" + +extern volatile unsigned char *ioBase; + +_X_EXPORT void +eieio() +{ + __asm__ __volatile__ ("eieio"); +} + +_X_EXPORT unsigned long +ldl_brx(volatile unsigned char *base, int ndx) +{ + register unsigned long tmp = *(volatile unsigned long *)(base+ndx); + return( ((tmp & 0x000000ff) << 24) | + ((tmp & 0x0000ff00) << 8) | + ((tmp & 0x00ff0000) >> 8) | + ((tmp & 0xff000000) >> 24) ); +} + +_X_EXPORT unsigned short +ldw_brx(volatile unsigned char *base, int ndx) +{ + register unsigned short tmp = *(volatile unsigned short *)(base+ndx); + return((tmp << 8) | (tmp >> 8)); +} + +_X_EXPORT void +stl_brx(unsigned long val, volatile unsigned char *base, int ndx) +{ + unsigned char *p = (unsigned char *)&val; + unsigned long tmp = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0); + *(volatile unsigned long *)(base+ndx) = tmp; +} + +_X_EXPORT void +stw_brx(unsigned short val, volatile unsigned char *base, int ndx) +{ + unsigned char *p = (unsigned char *)&val; + unsigned short tmp = (p[1] << 8) | p[0]; + *(volatile unsigned short *)(base+ndx) = tmp; +} + +_X_EXPORT void +outb(IOADDRESS port, unsigned char value) +{ + *((volatile unsigned char *)(ioBase + port)) = value; eieio(); +} + +_X_EXPORT void +outw(IOADDRESS port, unsigned short value) +{ + stw_brx(value, ioBase, port); eieio(); +} + +_X_EXPORT void +outl(IOADDRESS port, unsigned int value) +{ + stl_brx(value, ioBase, port); eieio(); +} + +_X_EXPORT unsigned char +inb(IOADDRESS port) +{ + unsigned char val; + + val = *((volatile unsigned char *)(ioBase + port)); eieio(); + return(val); +} + +_X_EXPORT unsigned short +inw(IOADDRESS port) +{ + unsigned short val; + + val = ldw_brx(ioBase, port); eieio(); + return(val); +} + +_X_EXPORT unsigned int +inl(IOADDRESS port) +{ + unsigned int val; + + val = ldl_brx(ioBase, port); eieio(); + return(val); +} + +_X_EXPORT unsigned long +ldl_u(void *p) +{ + return (((*(unsigned char *)(p)) | + (*((unsigned char *)(p)+1)<<8) | + (*((unsigned char *)(p)+2)<<16) | + (*((unsigned char *)(p)+3)<<24))); +} + +_X_EXPORT unsigned long +ldq_u(void *p) +{ + return ldl_u(p); +} + +_X_EXPORT unsigned short +ldw_u(void *p) +{ + return(((*(unsigned char *)(p)) | + (*((unsigned char *)(p)+1)<<8))); +} + +_X_EXPORT void +stl_u(unsigned long v, void *p) +{ + + (*(unsigned char *)(p)) = (v); + (*((unsigned char *)(p)+1)) = ((v) >> 8); + (*((unsigned char *)(p)+2)) = ((v) >> 16); + (*((unsigned char *)(p)+3)) = ((v) >> 24); +} + +_X_EXPORT void +stq_u(unsigned long v, void *p) +{ + stl_u(v,p); +} + +_X_EXPORT void +stw_u(unsigned short v, void *p) +{ + (*(unsigned char *)(p)) = (v); + (*((unsigned char *)(p)+1)) = ((v) >> 8); +} + + +_X_EXPORT void +mem_barrier(void) +{ + __asm__ __volatile__("eieio"); +} + +_X_EXPORT void +write_mem_barrier(void) +{ + __asm__ __volatile__("eieio"); +} + +#endif /* NO_INLINE && __powerpc__ */ diff --git a/xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.S b/xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.S new file mode 100644 index 000000000..3865850d1 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.S @@ -0,0 +1,70 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S,v 1.1 1999/07/10 07:24:49 dawes Exp $ */ +/* + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + + .file "ppc.s" +.toc + .csect .text[PR] + .balign 4 + .globl ppc_flush_icache + .globl .ppc_flush_icache +.csect ppc_flush_icache[DS] +ppc_flush_icache: + .long .ppc_flush_icache, TOC[tc0], 0 +.csect .text[PR] +.ppc_flush_icache: + mflr 0 + stw 31,-4(1) + stw 0,8(1) + stwu 1,-64(1) + mr 31,1 + stw 3,88(31) + li 6, 0 /* __inst_dcbf (addr, 0); */ + dcbf 3, 6 + li 5, 32 /* __inst_dcbf (addr, LINESIZE); */ + dcbf 3, 5 + sync /* __inst_sync (); */ + li 4,0 /* __inst_icbi (addr, 0); */ + icbi 3,4 + li 7,32 /* __inst_icbi (addr, LINESIZE); */ + icbi 3,7 + sync /* __inst_sync (); */ + isync /* __inst_isync (); */ +L..1: + lwz 1,0(1) + lwz 0,8(1) + mtlr 0 + lwz 31,-4(1) + blr +LT..ppc_flush_icache: + .long 0 + .byte 0,0,32,97,128,1,1,1 + .long 0 + .long LT..ppc_flush_icache-.ppc_flush_icache + .short 16 + .byte "ppc_flush_icache" + .byte 31 +_section_.text: + .csect .data[RW] + .long _section_.text diff --git a/xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.c b/xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.c new file mode 100644 index 000000000..6300f38c8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/lynx_ppc.c @@ -0,0 +1,51 @@ +/* + * Copyright 1998 by Metro Link Incorporated + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Metro Link + * Incorporated not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Metro Link Incorporated makes no representations + * about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +void ppc_flush_icache() +{ +__asm__ __volatile__ (" \ + mflr 0 ;\ + stw 31,-4(1) ;\ + stw 0,8(1) ;\ + stwu 1,-64(1) ;\ + mr 31,1 ;\ + stw 3,88(31) ;\ + li 6, 0 ;\ + dcbf 3, 6 ;\ + li 5, 32 ;\ + dcbf 3, 5 ;\ + sync ;\ + li 4,0 ;\ + icbi 3,4 ;\ + li 7,32 ;\ + icbi 3,7 ;\ + sync ;\ + isync ;\ + lwz 1,0(1) ;\ + lwz 0,8(1) ;\ + mtlr 0 ;\ + lwz 31,-4(1) ;\ + blr ;\ +"); +} diff --git a/xorg-server/hw/xfree86/os-support/lynxos/lynx_video.c b/xorg-server/hw/xfree86/os-support/lynxos/lynx_video.c new file mode 100644 index 000000000..4602076c7 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/lynxos/lynx_video.c @@ -0,0 +1,710 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * 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 Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#if defined(__powerpc__) + +# if defined(USE_MACHINE_ABSOLUTE) +# include <machine/absolute.h> +# else +# define __USER_SPACE_INCLUDE +# include <hw_absolute.h> +# endif + +void ppcPciIoMap(int bus); +#endif + +#if 0 +#define DEBUG +#endif + +#ifdef HAS_MTRR_SUPPORT +#include <sys/memrange.h> +#define X_MTRR_ID "XFree86" + +static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); +static void undoWC(int, pointer); +static Bool cleanMTRR(void); +static int devMemFd = -1; +#define MTRR_DEVICE "/dev/mtrr" +#endif + + +#if !defined(NO_MMAP) +#include <sys/mman.h> + +int smem_remove(char *name) +{ + return(0); +} + +char *smem_create(char *name, char *arg_addr, long size, int mode) +{ + int fd; + void *addr = 0; + char *retval; + size_t len = size; + int prot = PROT_READ|PROT_WRITE|PROT_UNCACHE; + int flags = MAP_SHARED; + off_t off = (off_t)arg_addr; + + if ((fd = open("/dev/mem" , O_RDWR)) < 0) + { + retval = (char *)-1; + } + else + { + if (mode == SM_DETACH) + { + munmap(arg_addr, len); + retval = 0; + } + else + { + if ((retval = mmap (addr, len, prot, flags, fd, off) ) == MAP_FAILED) + { + retval = (char *)-1; + } + } + + close(fd); + } + + return(retval); +} + +#endif + + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +typedef struct +{ + char name[16]; + unsigned long Base; + unsigned long Size; + char *ptr; + int RefCnt; +} +_SMEMS; + +#define MAX_SMEMS 16 + +static _SMEMS smems[MAX_SMEMS]; + + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +static void +smemCleanup(void) +{ + int i; + + for (i = 0; i < MAX_SMEMS; i++) { + if (*smems[i].name && smems[i].ptr) { + (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH); + (void)smem_remove(smems[i].name); + *smems[i].name = '\0'; + smems[i].ptr = NULL; + smems[i].Base = 0; + smems[i].Size = 0; + smems[i].RefCnt = 0; + } + } +} + +static pointer +MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + static int once; + int free_slot = -1; + int i; + + if (!once) + { + atexit(smemCleanup); + once = 1; + } + for (i = 0; i < MAX_SMEMS; i++) + { + if (!*smems[i].name && free_slot == -1) + free_slot = i; + if (smems[i].Base == Base && smems[i].Size == Size + && *smems[i].name) { + smems[i].RefCnt++; + return smems[i].ptr; + } + } + if (i == MAX_SMEMS && free_slot == -1) + { + FatalError("MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n", + Base, Size); + } + + i = free_slot; + sprintf(smems[i].name, "Video-%d", i); + smems[i].Base = Base; + smems[i].Size = Size; + + xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x\n", + Base, Size); + +#if defined(__powerpc__) + if (((unsigned long)Base & PHYS_IO_MEM_START) != PHYS_IO_MEM_START) { + Base = Base | PHYS_IO_MEM_START; + } +#endif + + smems[i].ptr = smem_create(smems[i].name, (char *)Base, Size, SM_READ|SM_WRITE); + smems[i].RefCnt = 1; + if (smems[i].ptr == NULL) + { + /* check if there is a stale segment around */ + if (smem_remove(smems[i].name) == 0) { + xf86Msg(X_INFO, + "MapVidMem: removed stale smem_ segment %s\n", + smems[i].name); + smems[i].ptr = smem_create(smems[i].name, + (char *)Base, Size, SM_READ|SM_WRITE); + } + if (smems[i].ptr == NULL) { + *smems[i].name = '\0'; + FatalError("MapVidMem: failed to smem_create Base %x Size %x (%s)\n", + Base, Size, strerror(errno)); + } + } + xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x Ptr=0x%x\n", + Base, Size, smems[i].ptr); + return smems[i].ptr; +} + +static void +UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + int i; + + xf86MsgVerb(X_INFO, 3, "UnMapVidMem: Base/Ptr=0x%x Size=0x%x\n", + Base, Size); + for (i = 0; i < MAX_SMEMS; i++) + { + if (*smems[i].name && smems[i].ptr == Base + && smems[i].Size == Size) + { + if (--smems[i].RefCnt > 0) + return; + + (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH); + xf86MsgVerb(X_INFO, 3, + "UnMapVidMem: smem_create(%s, 0x%08x, ... " + "SM_DETACH)\n", smems[i].name, smems[i].ptr); + (void)smem_remove(smems[i].name); + *smems[i].name = '\0'; + smems[i].RefCnt = 0; + return; + } + } + xf86MsgVerb(X_WARNING, 2, + "UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n", + Base, Size); +} + + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = MapVidMem; + pVidMem->unmapMem = UnMapVidMem; + pVidMem->setWC = 0; + pVidMem->undoWC = 0; +#ifdef HAS_MTRR_SUPPORT + if (cleanMTRR()) { + pVidMem->setWC = setWC; + pVidMem->undoWC = undoWC; + } +#endif + pVidMem->initialised = TRUE; +} + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + return; +} + +/***************************************************************************/ +/* I/O Permissions section for PowerPC */ +/***************************************************************************/ + +#if defined(__powerpc__) + +_X_EXPORT volatile unsigned char *ioBase = MAP_FAILED; +volatile unsigned char *pciConfBase = MAP_FAILED; + +static int IOEnabled; + + +static void +removeIOSmem(void) +{ + smem_create(NULL, (char *) ioBase, 0, SM_DETACH); + smem_remove("IOBASE"); + ioBase = MAP_FAILED; +} + +_X_EXPORT Bool +xf86EnableIO() +{ + if (IOEnabled++ == 0) { + ioBase = (unsigned char *) smem_create("IOBASE", + (char *)PHYS_ISA_IO_SPACE, 64*1024, SM_READ|SM_WRITE); + if (ioBase == MAP_FAILED) { + --IOEnabled; + xf86Msg(X_WARNING,"xf86EnableIO: Failed to map I/O\n"); + return FALSE; + } else { +#ifdef DEBUG + ErrorF("xf86EnableIO: mapped I/O at vaddr 0x%08x\n", + ioBase); +#endif + atexit(removeIOSmem); + } + } + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + if (!IOEnabled) + return; + + if (--IOEnabled == 0) + removeIOSmem(); + return; +} + +#if 0 +void +xf86DisableIOPrivs(void) +{ + return; +} +#endif +void +ppcPciIoMap(int bus) +{ + xf86EnableIO(); +} + +#endif + + +#ifdef HAS_MTRR_SUPPORT +/* memory range (MTRR) support for LynxOS (taken from BSD MTRR support) */ + +/* + * This code is experimental. Some parts may be overkill, and other parts + * may be incomplete. + */ + +/* + * getAllRanges returns the full list of memory ranges with attributes set. + */ + +static struct mem_range_desc * +getAllRanges(int *nmr) +{ + struct mem_range_desc *mrd; + struct mem_range_op mro; + + /* + * Find how many ranges there are. If this fails, then the kernel + * probably doesn't have MTRR support. + */ + mro.mo_arg[0] = 0; + if (ioctl(devMemFd, MEMRANGE_GET, &mro)) + return NULL; + *nmr = mro.mo_arg[0]; + mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc)); + mro.mo_arg[0] = *nmr; + mro.mo_desc = mrd; + if (ioctl(devMemFd, MEMRANGE_GET, &mro)) { + xfree(mrd); + return NULL; + } + return mrd; +} + +/* + * cleanMTRR removes any memory attribute that may be left by a previous + * X server. Normally there won't be any, but this takes care of the + * case where a server crashed without being able finish cleaning up. + */ + +static Bool +cleanMTRR() +{ + struct mem_range_desc *mrd; + struct mem_range_op mro; + int nmr, i; + + /* This shouldn't happen */ + if (devMemFd < 0) { + if ((devMemFd = open(MTRR_DEVICE, O_RDONLY)) < 0) { +perror("open MTRR"); + return FALSE; + } + } + + if (!(mrd = getAllRanges(&nmr))) + return FALSE; + + for (i = 0; i < nmr; i++) { + if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 && + (mrd[i].mr_flags & MDF_ACTIVE)) { +#ifdef DEBUG + ErrorF("Clean for (0x%lx,0x%lx)\n", + (unsigned long)mrd[i].mr_base, + (unsigned long)mrd[i].mr_len); +#endif + if (mrd[i].mr_flags & MDF_FIXACTIVE) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + mrd[i].mr_flags = MDF_UNCACHEABLE; + } else { + mro.mo_arg[0] = MEMRANGE_SET_REMOVE; + } + mro.mo_desc = mrd + i; + ioctl(devMemFd, MEMRANGE_SET, &mro); + } + } +#ifdef DEBUG + sleep(10); +#endif + xfree(mrd); + return TRUE; +} + +typedef struct x_RangeRec { + struct mem_range_desc mrd; + Bool wasWC; + struct x_RangeRec * next; +} RangeRec, *RangePtr; + +static void +freeRangeList(RangePtr range) +{ + RangePtr rp; + + while (range) { + rp = range; + range = rp->next; + xfree(rp); + } +} + +static RangePtr +dupRangeList(RangePtr list) +{ + RangePtr new = NULL, rp, p; + + rp = list; + while (rp) { + p = xnfalloc(sizeof(RangeRec)); + *p = *rp; + p->next = new; + new = p; + rp = rp->next; + } + return new; +} + +static RangePtr +sortRangeList(RangePtr list) +{ + RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev; + unsigned long minBase; + + /* Sort by base address */ + rp1 = copy = dupRangeList(list); + while (rp1) { + minBase = rp1->mrd.mr_base; + minp = rp1; + minprev = NULL; + prev = rp1; + rp2 = rp1->next; + while (rp2) { + if (rp2->mrd.mr_base < minBase) { + minBase = rp2->mrd.mr_base; + minp = rp2; + minprev = prev; + } + prev = rp2; + rp2 = rp2->next; + } + if (minprev) { + minprev->next = minp->next; + rp1 = copy; + } else { + rp1 = minp->next; + } + minp->next = sorted; + sorted = minp; + } + return sorted; +} + +/* + * findRanges returns a list of ranges that overlap the specified range. + */ + +static void +findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp) +{ + struct mem_range_desc *mrd; + int nmr, i; + RangePtr rp, *p; + + if (!(mrd = getAllRanges(&nmr))) + return; + + for (i = 0; i < nmr; i++) { + if ((mrd[i].mr_flags & MDF_ACTIVE) && + mrd[i].mr_base < base + size && + mrd[i].mr_base + mrd[i].mr_len > base) { + if (mrd[i].mr_flags & MDF_WRITECOMBINE) + p = wcp; + else if (mrd[i].mr_flags & MDF_UNCACHEABLE) + p = ucp; + else + continue; + rp = xnfalloc(sizeof(RangeRec)); + rp->mrd = mrd[i]; + rp->next = *p; + *p = rp; + } + } + xfree(mrd); +} + +/* + * This checks if the existing overlapping ranges fully cover the requested + * range. Is this overkill? + */ + +static Bool +fullCoverage(unsigned long base, unsigned long size, RangePtr overlap) +{ + RangePtr rp1, sorted = NULL; + unsigned long end; + + sorted = sortRangeList(overlap); + /* Look for gaps */ + rp1 = sorted; + end = base + size; + while (rp1) { + if (rp1->mrd.mr_base > base) { + freeRangeList(sorted); + return FALSE; + } else { + base = rp1->mrd.mr_base + rp1->mrd.mr_len; + } + if (base >= end) { + freeRangeList(sorted); + return TRUE; + } + rp1 = rp1->next; + } + freeRangeList(sorted); + return FALSE; +} + +static pointer +addWC(int screenNum, unsigned long base, unsigned long size, MessageType from) +{ + RangePtr uc = NULL, wc = NULL, retlist = NULL; + struct mem_range_desc mrd; + struct mem_range_op mro; + + findRanges(base, size, &uc, &wc); + + /* See of the full range is already WC */ + if (!uc && fullCoverage(base, size, wc)) { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx) was already set\n", + base, size); + return NULL; + } + + /* Otherwise, try to add the new range */ + mrd.mr_base = base; + mrd.mr_len = size; + strcpy(mrd.mr_owner, X_MTRR_ID); + mrd.mr_flags = MDF_WRITECOMBINE; + mro.mo_desc = &mrd; + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to set write-combining range " + "(0x%lx,0x%lx)\n", base, size); + return NULL; + } else { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx)\n", base, size); + retlist = xnfalloc(sizeof(RangeRec)); + retlist->mrd = mrd; + retlist->wasWC = FALSE; + retlist->next = NULL; + return retlist; + } +} + +static pointer +delWC(int screenNum, unsigned long base, unsigned long size, MessageType from) +{ + RangePtr uc = NULL, wc = NULL, retlist = NULL; + struct mem_range_desc mrd; + struct mem_range_op mro; + + findRanges(base, size, &uc, &wc); + + /* + * See of the full range is already not WC, or if there is full + * coverage from UC ranges. + */ + if (!wc || fullCoverage(base, size, uc)) { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx) was already clear\n", + base, size); + return NULL; + } + + /* Otherwise, try to add the new range */ + mrd.mr_base = base; + mrd.mr_len = size; + strcpy(mrd.mr_owner, X_MTRR_ID); + mrd.mr_flags = MDF_UNCACHEABLE; + mro.mo_desc = &mrd; + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to remove write-combining range " + "(0x%lx,0x%lx)\n", base, size); + /* XXX Should then remove all of the overlapping WC ranges */ + return NULL; + } else { + xf86DrvMsg(screenNum, from, + "Removed Write-combining range (0x%lx,0x%lx)\n", + base, size); + retlist = xnfalloc(sizeof(RangeRec)); + retlist->mrd = mrd; + retlist->wasWC = TRUE; + retlist->next = NULL; + return retlist; + } +} + +static pointer +setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + if (enable) + return addWC(screenNum, base, size, from); + else + return delWC(screenNum, base, size, from); +} + +static void +undoWC(int screenNum, pointer list) +{ + RangePtr rp; + struct mem_range_op mro; + Bool failed; + + rp = list; + while (rp) { +#ifdef DEBUG + ErrorF("Undo for (0x%lx,0x%lx), %d\n", + (unsigned long)rp->mrd.mr_base, + (unsigned long)rp->mrd.mr_len, rp->wasWC); +#endif + failed = FALSE; + if (rp->wasWC) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + rp->mrd.mr_flags = MDF_WRITECOMBINE; + strcpy(rp->mrd.mr_owner, "unknown"); + } else { + mro.mo_arg[0] = MEMRANGE_SET_REMOVE; + } + mro.mo_desc = &rp->mrd; + + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + if (!rp->wasWC) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + rp->mrd.mr_flags = MDF_UNCACHEABLE; + strcpy(rp->mrd.mr_owner, "unknown"); + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) + failed = TRUE; + } else + failed = TRUE; + } + if (failed) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to restore MTRR range (0x%lx,0x%lx)\n", + (unsigned long)rp->mrd.mr_base, + (unsigned long)rp->mrd.mr_len); + } + rp = rp->next; + } +} + +#endif /* HAS_MTRR_SUPPORT */ + diff --git a/xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.S b/xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.S new file mode 100644 index 000000000..373723c7d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.S @@ -0,0 +1,153 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.s,v 1.2 1998/07/25 16:56:49 dawes Exp $ */ +/****************************************************************************** + Copyright 1993 by Glenn G. Lai + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Glenn G. Lai not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +Glenn G. Lai +P.O. Box 4314 +Austin, Tx 78765 +(glenn@cs.utexas.edu) +8/9/93 +******************************************************************************/ +/* $XConsortium: BUSmemcpy.s /main/4 1996/02/21 17:39:34 kaleb $ */ + +/* + * Modified to use long-alignment of video memory rather than word-alignment + * to improve performance for LocalBus video cards. Function names changed + * from ISAToMem and MemToISA to BusToMem and MemToBus. + * + * David Dawes <dawes@XFree86.org>, 25 August 1993. + */ + + +#include "assyntax.h" + + FILE("BUSmemcpy.s") + + AS_BEGIN + +/* BusToMem copies from video memory to main memory + MemToBus copies from main memory to video memory + + void xf86BusToMem(unsigned char *dst, unsigned char *src, int len); + void xf86MemToBus(unsigned char *dst, unsigned char *src, int len); +*/ + +#define dst REGOFF(4,ESP) +#define src REGOFF(8,ESP) +#define len REGOFF(12,ESP) + + GLOBL GLNAME(xf86BusToMem) + GLOBL GLNAME(xf86MemToBus) + + SEG_DATA +copyright: + STRING("Copyright 8/9/1993 by Glenn G. Lai") + + SEG_TEXT + ALIGNTEXT4 +GLNAME(xf86BusToMem): + CLD + PUSH_L (ESI) + MOV_L (EDI, EDX) + + MOV_L (src, ESI) + MOV_L (dst, EDI) + MOV_L (len, ECX) + + CMP_L (CONST(7), ECX) + JC (quickBM) + + TEST_L (CONST(1), ESI) + JZ (BwM) + + MOVS_B + DEC_L (ECX) + +BwM: + TEST_L (CONST(2), ESI) + JZ (BlM) + + MOVS_W + DEC_L (ECX) + DEC_L (ECX) + +BlM: + MOV_L (ECX, EAX) + AND_L (CONST(3), EAX) + SHR_L (CONST(2), ECX) + REP + MOVS_L + MOV_L (EAX, ECX) +quickBM: + OR_L (ECX, ECX) + JZ (return) + REP + MOVS_B +return: + POP_L (ESI) + MOV_L (EDX, EDI) + RET +/************************/ + + ALIGNTEXT4 +GLNAME(xf86MemToBus): + CLD + PUSH_L (ESI) + MOV_L (EDI, EDX) + + MOV_L (src, ESI) + MOV_L (dst, EDI) + MOV_L (len, ECX) + + CMP_L (CONST(7), ECX) + JC (quickMB) + + TEST_L (CONST(1), EDI) + JZ (MwB) + + MOVS_B + DEC_L (ECX) + +MwB: + TEST_L (CONST(2), EDI) + JZ (MlB) + + MOVS_W + DEC_L (ECX) + DEC_L (ECX) + +MlB: + MOV_L (ECX, EAX) + AND_L (CONST(3), EAX) + SHR_L (CONST(2), ECX) + REP + MOVS_L + MOV_L (EAX, ECX) +quickMB: + OR_L (ECX, ECX) + JZ (return) + REP + MOVS_B + + POP_L (ESI) + MOV_L (EDX, EDI) + RET + diff --git a/xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.c b/xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.c new file mode 100644 index 000000000..b482b867a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/BUSmemcpy.c @@ -0,0 +1,412 @@ + +/**************************************************************************** + + For Alpha Linux, BusToMem() and MemToBus() can be simply memcpy(), BUT: + we need to prevent unaligned operations when accessing DENSE space on the BUS, + as the video memory is mmap'd that way. The below code does this. + +NOTE: we could simply use the "memcpy()" from LIBC here, but that, currently, is + not as fast. + +Thanks to Linus Torvalds for contributing this code. + +****************************************************************************/ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifdef __alpha__ + +#include "compiler.h" + +/* + * The Jensen lacks dense memory, thus we have to address the bus via + * the sparse addressing scheme. These routines are only used in s3im.c + * Non time critical code uses SlowBCopy_{from/to} bus. + * + * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 + */ + +#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ +#define LWORD_CODING (0x18) +#define SPARSE (5) +#else +#define LWORD_CODING (0x60) +#define SPARSE (7) +#endif + +void +xf86JensenMemToBus(char *Base, long dst, long src, int count) +{ + if( ((long)src^((long)dst)) & 3) { + /* src & dst are NOT aligned to each other */ + unsigned long addr; + unsigned long low_word, high_word,last_read; + long rm,loop; + unsigned long tmp,org,org2,mask,src_org,count_org; + + src_org=src; + count_org=count; + + /* add EISA longword coding and round off*/ + addr = (long)(Base+(dst<<SPARSE) + LWORD_CODING) & ~(3<<SPARSE); + rm = (long)dst & 3; + count += rm; + + count = count_org + rm; + org = *(volatile unsigned int *)addr; + __asm__("ldq_u %0,%1" + :"=r" (low_word):"m" (*(unsigned long *)(src_org))); + src = src_org - rm; + if( count > 4 ) { + last_read = src_org+count_org - 1; + __asm__("ldq_u %0,%1" + :"=r" (high_word):"m" (*(unsigned long *)(src+4))); + __asm__("extll %1,%2,%0" + :"=r" (low_word) + :"r" (low_word), "r" ((unsigned long)(src))); + __asm__("extlh %1,%2,%0" + :"=r" (tmp) + :"r" (high_word), "r" ((unsigned long)(src))); + tmp |= low_word; + src += 4; + __asm__("mskqh %1,%2,%0" + :"=r" (tmp) + :"r" (tmp), "r" (rm)); + __asm__("mskql %1,%2,%0" + :"=r" (org2) + :"r" (org), "r" (rm)); + tmp |= org2; + + loop = (count-4) >> 2; /* loop eqv. count>=4 ; count -= 4 */ + while (loop) { + /* tmp to be stored completly -- need to read next word*/ + low_word = high_word; + *(volatile unsigned int *) (addr) = tmp; + __asm__("ldq_u %0,%1" + :"=r" (high_word):"m" (*(unsigned long*)(src+4))); + loop --; + __asm__("extll %1,%2,%0" + :"=r" (low_word) + :"r" (low_word), "r" ((unsigned long)src)); + __asm__("extlh %1,%2,%0" + :"=r" (tmp) + :"r" (high_word), "r" ((unsigned long)src)); + src += 4; + tmp |= low_word; + addr += 4<<SPARSE; + } + if ( count & 3 ) { + /* Store tmp completly, and possibly read one more word.*/ + *(volatile unsigned int *) (addr) = tmp; + __asm__("ldq_u %0,%1" + :"=r" (tmp):"m" (*((unsigned long *)(last_read)) )); + addr += 4<<SPARSE; + __asm__("extll %1,%2,%0" + :"=r" (low_word) + :"r" (high_word), "r" ((unsigned long)src)); + __asm__("extlh %1,%2,%0" + :"=r" (tmp) + :"r" (tmp), "r" ((unsigned long)src)); + tmp |= low_word; + org = *(volatile unsigned int *)addr; + + __asm__("mskql %1,%2,%0" + :"=r" (tmp) + :"r" (tmp), "r" (count&3)); + __asm__("mskqh %1,%2,%0" + :"=r" (org) + :"r" (org), "r" (count&3)); + + tmp |= org; + } + *(volatile unsigned int *) (addr) = tmp; + return; + } else { /* count > 4 */ + __asm__("ldq_u %0,%1" + :"=r" (high_word):"m" (*(unsigned long *)(src+4))); + __asm__("extll %1,%2,%0" + :"=r" (low_word) + :"r" (low_word), "r" ((unsigned long)(src))); + __asm__("extlh %1,%2,%0" + :"=r" (tmp) + :"r" (high_word), "r" ((unsigned long)(src))); + tmp |= low_word; + if( count < 4 ) { + + mask = -1; + __asm__("mskqh %1,%2,%0" + :"=r" (mask) + :"r" (mask), "r" (rm)); + __asm__("mskql %1,%2,%0" + :"=r" (mask) + :"r" (mask), "r" (count)); + tmp = (tmp & mask) | (org & ~mask); + *(volatile unsigned int *) (addr) = tmp; + return; + } else { + __asm__("mskqh %1,%2,%0" + :"=r" (tmp) + :"r" (tmp), "r" (rm)); + __asm__("mskql %1,%2,%0" + :"=r" (org2) + :"r" (org), "r" (rm)); + + tmp |= org2; + *(volatile unsigned int *) (addr) = tmp; + return; + } + } + } else { /* src & dst are aligned to each other */ + unsigned long addr; + unsigned int tmp,org,rm; + unsigned int *src_r; + + /* add EISA longword coding and round off*/ + addr = (long)(Base+(dst<<SPARSE) + LWORD_CODING) & ~(3<<SPARSE); + + src_r = (unsigned int*)((long)src & ~3L); + rm=(long)src & 3; + count += rm; + + tmp = *src_r; + org = *(volatile unsigned int *)addr; + + __asm__("mskqh %1,%2,%0" + :"=r" (tmp) + :"r" (tmp), "r" (rm)); + __asm__("mskql %1,%2,%0" + :"=r" (org) + :"r" (org), "r" (rm)); + + tmp |= org; + + while (count > 4) { + *(volatile unsigned int *) addr = tmp; + addr += 4<<SPARSE; + src_r += 1; + tmp = *src_r; + count -= 4; + } + + org = *(volatile unsigned int *)addr; + __asm__("mskql %1,%2,%0" + :"=r" (tmp) + :"r" (tmp), "r" (count)); + __asm__("mskqh %1,%2,%0" + :"=r" (org) + :"r" (org), "r" (count)); + tmp |= org; + *(volatile unsigned int *) (addr) = tmp; + } +} + +void +xf86JensenBusToMem(char *Base, char *dst, unsigned long src, int count) +{ +#if 0 + /* Optimization of BusToMem() is left as an exercise to the reader ;-) + * Consider that ldq_u/extlh/extll won't work because of the bus being + * only 4 bytes wide! + */ +#else + unsigned long addr; + long result; + + addr = (unsigned long)(Base+(src<<SPARSE)) ; + while( addr & (3<<SPARSE) ){ + if(count <= 0) return; + result = *(volatile int *) addr; + result >>= ((addr>>SPARSE) & 3) * 8; + *dst++ = (char) result; + addr += 1<<SPARSE; + count--; + } + count -=4; + while(count >= 0){ + int i; + + result = *(volatile int *) (addr+LWORD_CODING); + for(i=4;i--;) { + *dst++ = (char) result; + result >>= 8; + } + addr += 4<<SPARSE; + count -= 4; + } + count +=4; + + while( count ){ + result = *(volatile int *) addr; + result >>= ((addr>>SPARSE) & 3) * 8; + *dst++ = (char) result; + addr += 1<<SPARSE; + count--; + } +#endif +} + + +static unsigned long __memcpy(unsigned long dest, unsigned long src, int n); + +_X_EXPORT void +xf86BusToMem(unsigned char *dst, unsigned char *src, int len) +{ + __memcpy((unsigned long)dst, (unsigned long)src, len); +} +_X_EXPORT void +xf86MemToBus(unsigned char *dst, unsigned char *src, int len) +{ + if (len == sizeof(int)) + if (!(((long)src | (long)dst) & 3)) + *((unsigned int*)dst) = *((unsigned int*)(src)); + else { + int i; + if (((long)src) & 3) + i = ldl_u((unsigned int*)src); + else + i = *(unsigned int*)src; + if (((long)dst) & 3) + stl_u(i,(unsigned int*)dst); + else + *(unsigned int*)dst = i; + } + else + __memcpy((unsigned long)dst, (unsigned long)src, len); +} + +/* + * linux/arch/alpha/lib/memcpy.c + * + * Copyright (C) 1995 Linus Torvalds, used with his permission. + */ + +/* + * This is a reasonably optimized memcpy() routine. + */ + +/* + * Note that the C code is written to be optimized into good assembly. However, + * at this point gcc is unable to sanely compile "if (n >= 0)", resulting in a + * explicit compare against 0 (instead of just using the proper "blt reg, xx" or + * "bge reg, xx"). I hope alpha-gcc will be fixed to notice this eventually.. + */ + +/* + * This should be done in one go with ldq_u*2/mask/stq_u. Do it + * with a macro so that we can fix it up later.. + */ +#define ALIGN_DEST_TO8(d,s,n) \ + while (d & 7) { \ + if (n <= 0) return; \ + n--; \ + *(char *) d = *(char *) s; \ + d++; s++; \ + } + +/* + * This should similarly be done with ldq_u*2/mask/stq. The destination + * is aligned, but we don't fill in a full quad-word + */ +#define DO_REST(d,s,n) \ + while (n > 0) { \ + n--; \ + *(char *) d = *(char *) s; \ + d++; s++; \ + } + +/* + * This should be done with ldq/mask/stq. The source and destination are + * aligned, but we don't fill in a full quad-word + */ +#define DO_REST_ALIGNED(d,s,n) DO_REST(d,s,n) + +/* + * This does unaligned memory copies. We want to avoid storing to + * an unaligned address, as that would do a read-modify-write cycle. + * We also want to avoid double-reading the unaligned reads. + * + * Note the ordering to try to avoid load (and address generation) latencies. + */ +static __inline__ void __memcpy_unaligned(unsigned long d, unsigned long s, long n) +{ + ALIGN_DEST_TO8(d,s,n); + n -= 8; /* to avoid compare against 8 in the loop */ + if (n >= 0) { + unsigned long low_word, high_word; + __asm__("ldq_u %0,%1":"=r" (low_word):"m" (*(unsigned long *) s)); + do { + unsigned long tmp; + __asm__("ldq_u %0,%1":"=r" (high_word):"m" (*(unsigned long *)(s+8))); + n -= 8; + __asm__("extql %1,%2,%0" + :"=r" (low_word) + :"r" (low_word), "r" (s)); + __asm__("extqh %1,%2,%0" + :"=r" (tmp) + :"r" (high_word), "r" (s)); + s += 8; + *(unsigned long *) d = low_word | tmp; + d += 8; + low_word = high_word; + } while (n >= 0); + } + n += 8; + DO_REST(d,s,n); +} + +/* + * Hmm.. Strange. The __asm__ here is there to make gcc use a integer register + * for the load-store. I don't know why, but it would seem that using a floating + * point register for the move seems to slow things down (very small difference, + * though). + * + * Note the ordering to try to avoid load (and address generation) latencies. + */ +static __inline__ void __memcpy_aligned(unsigned long d, unsigned long s, long n) +{ + ALIGN_DEST_TO8(d,s,n); + n -= 8; + while (n >= 0) { + unsigned long tmp; + __asm__("ldq %0,%1":"=r" (tmp):"m" (*(unsigned long *) s)); + n -= 8; + s += 8; + *(unsigned long *) d = tmp; + d += 8; + } + n += 8; + DO_REST_ALIGNED(d,s,n); +} + +static unsigned long __memcpy(unsigned long dest, unsigned long src, int n) +{ + if (!((dest ^ src) & 7)) { + __memcpy_aligned(dest, src, n); + return dest; + } + __memcpy_unaligned(dest, src, n); + return dest; +} + +#else /* __alpha__ */ + +void +xf86BusToMem(unsigned char *dst, unsigned char *src, int len) +{ + memcpy(dst, src, len); +} +void +xf86MemToBus(unsigned char *dst, unsigned char *src, int len) +{ + memcpy(dst, src, len); +} + +#endif /* __alpha__ */ diff --git a/xorg-server/hw/xfree86/os-support/misc/Delay.c b/xorg-server/hw/xfree86/os-support/misc/Delay.c new file mode 100644 index 000000000..b18789a3a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/Delay.c @@ -0,0 +1,39 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include <time.h> + +_X_EXPORT void +xf86UDelay(long usec) +{ +#if 0 + struct timeval start, interrupt; +#else + int sigio; + + sigio = xf86BlockSIGIO(); + usleep(usec); + xf86UnblockSIGIO(sigio); +#endif + +#if 0 + gettimeofday(&start,NULL); + + do { + usleep(usec); + gettimeofday(&interrupt,NULL); + + if ((usec = usec - (interrupt.tv_sec - start.tv_sec) * 1000000 + - (interrupt.tv_usec - start.tv_usec)) < 0) + break; + start = interrupt; + } while (1); +#endif +} + diff --git a/xorg-server/hw/xfree86/os-support/misc/IODelay.S b/xorg-server/hw/xfree86/os-support/misc/IODelay.S new file mode 100644 index 000000000..4c6e32f3f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/IODelay.S @@ -0,0 +1,53 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.S,v 1.1 1999/07/10 07:24:50 dawes Exp $ */ +/******************************************************************************* + Copyright 1994 by Glenn G. Lai + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyr notice appear in all copies and that +both that copyr notice and this permission notice appear in +supporting documentation, and that the name of Glenn G. Lai not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +Glenn G. Lai +P.O. Box 4314 +Austin, Tx 78765 +glenn@cs.utexas.edu) +7/21/94 +*******************************************************************************/ +/* $XConsortium: IODelay.s /main/4 1996/02/21 17:40:21 kaleb $ */ + +/* + * All we really need is a delay of about 40ns for I/O recovery for just + * about any occasion, but we'll be more conservative here: On a + * 100-MHz CPU, produce at least a delay of 1,000ns. + */ + +#include "assyntax.h" + + FILE("DACDelay.s") + + AS_BEGIN + + GLOBL GLNAME(xf86IODelay) + + SEG_TEXT + ALIGNTEXT4 +GLNAME(xf86IODelay): + MOV_L (CONST(100), EAX) +delay_it: + DEC_L (EAX) + JNE (delay_it) + RET + diff --git a/xorg-server/hw/xfree86/os-support/misc/IODelay.c b/xorg-server/hw/xfree86/os-support/misc/IODelay.c new file mode 100644 index 000000000..e4422f234 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/IODelay.c @@ -0,0 +1,24 @@ +/******************************************************************************* + Stub for Alpha Linux +*******************************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * All we really need is a delay of about 40ns for I/O recovery for just + * about any occasion, but we'll be more conservative here: On a + * 100-MHz CPU, produce at least a delay of 1,000ns. + */ +_X_EXPORT void +xf86IODelay() +{ + xf86UDelay(1); +} + diff --git a/xorg-server/hw/xfree86/os-support/misc/Makefile.am b/xorg-server/hw/xfree86/os-support/misc/Makefile.am new file mode 100644 index 000000000..65fbe92b4 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/Makefile.am @@ -0,0 +1,23 @@ +# FIXME: Add the *.S files to build when applicable +I386_SRCS = BUSmemcpy.S IODelay.S SlowBcopy.S +OTHER_SRCS = BUSmemcpy.c IODelay.c SlowBcopy.c + +ARCH_SRCS = $(OTHER_SRCS) + +# FIXME: Add to the build (NeedPortIO) +PORTIO_SRCS = PortIO.S + +# FIXME: Add to the build (if HasGcc || HasGcc2) +ILHACK_SRCS = xf86_IlHack.c + +noinst_LTLIBRARIES = libmisc.la + +libmisc_la_SOURCES = xf86_Util.c Delay.c $(ARCH_SRCS) + +#AM_LDFLAGS = -r + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) + +EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS) $(ILHACK_SRCS) diff --git a/xorg-server/hw/xfree86/os-support/misc/Makefile.in b/xorg-server/hw/xfree86/os-support/misc/Makefile.in new file mode 100644 index 000000000..19a94d7cc --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/Makefile.in @@ -0,0 +1,663 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/misc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libmisc_la_LIBADD = +am__objects_1 = BUSmemcpy.lo IODelay.lo SlowBcopy.lo +am__objects_2 = $(am__objects_1) +am_libmisc_la_OBJECTS = xf86_Util.lo Delay.lo $(am__objects_2) +libmisc_la_OBJECTS = $(am_libmisc_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libmisc_la_SOURCES) +DIST_SOURCES = $(libmisc_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ + +# FIXME: Add the *.S files to build when applicable +I386_SRCS = BUSmemcpy.S IODelay.S SlowBcopy.S +OTHER_SRCS = BUSmemcpy.c IODelay.c SlowBcopy.c +ARCH_SRCS = $(OTHER_SRCS) + +# FIXME: Add to the build (NeedPortIO) +PORTIO_SRCS = PortIO.S + +# FIXME: Add to the build (if HasGcc || HasGcc2) +ILHACK_SRCS = xf86_IlHack.c +noinst_LTLIBRARIES = libmisc.la +libmisc_la_SOURCES = xf86_Util.c Delay.c $(ARCH_SRCS) + +#AM_LDFLAGS = -r +INCLUDES = $(XORG_INCS) +AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) +EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS) $(ILHACK_SRCS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/misc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/misc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libmisc.la: $(libmisc_la_OBJECTS) $(libmisc_la_DEPENDENCIES) + $(LINK) $(libmisc_la_OBJECTS) $(libmisc_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BUSmemcpy.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Delay.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IODelay.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SlowBcopy.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86_Util.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/misc/PortIO.S b/xorg-server/hw/xfree86/os-support/misc/PortIO.S new file mode 100644 index 000000000..75db31156 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/PortIO.S @@ -0,0 +1,57 @@ +/* $XFree86$ */ + +/* Port I/O functions for platforms with no inlining. */ + +#include "assyntax.h" + + FILE("PortIO.s") + + AS_BEGIN + + GLOBL GLNAME(outb) + GLOBL GLNAME(outw) + GLOBL GLNAME(outl) + GLOBL GLNAME(inb) + GLOBL GLNAME(inw) + GLOBL GLNAME(inl) + + SEG_TEXT + ALIGNTEXT4 +GLNAME(outb): + MOV_L (REGOFF(4,ESP), EDX) + MOV_L (REGOFF(8,ESP), EAX) + OUT_B + RET + + ALIGNTEXT4 +GLNAME(outw): + MOV_L (REGOFF(4,ESP), EDX) + MOV_L (REGOFF(8,ESP), EAX) + OUT_W + RET + + ALIGNTEXT4 +GLNAME(outl): + MOV_L (REGOFF(4,ESP), EDX) + MOV_L (REGOFF(8,ESP), EAX) + OUT_L + RET + + ALIGNTEXT4 +GLNAME(inb): + MOV_L (REGOFF(4,ESP), EDX) + IN_B + RET + + ALIGNTEXT4 +GLNAME(inw): + MOV_L (REGOFF(4,ESP), EDX) + IN_L + RET + + ALIGNTEXT4 +GLNAME(inl): + MOV_L (REGOFF(4,ESP), EDX) + IN_L + RET + diff --git a/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.S b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.S new file mode 100644 index 000000000..9b6af1d69 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.S @@ -0,0 +1,108 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.S,v 1.1 1999/07/10 07:24:51 dawes Exp $ */ +/******************************************************************************* + Copyright 1994 by Glenn G. Lai + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyr notice appear in all copies and that +both that copyr notice and this permission notice appear in +supporting documentation, and that the name of Glenn G. Lai not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +Glenn G. Lai +P.O. Box 4314 +Austin, Tx 78765 +glenn@cs.utexas.edu) +7/21/94 +*******************************************************************************/ +/* $XConsortium: SlowBcopy.s /main/4 1996/02/21 17:40:52 kaleb $ */ + +/* + * Modified from the output generated by GCC + * + * Create a dependency that should be immune from the effect of register + * renaming as is commonly seen in superscalar processors. This should + * insert a minimum of 100-ns delays between reads/writes at clock rates + * up to 100 MHz---GGL + * + * Slowbcopy(char *src, char *dst, int count) + * + */ + +#include "assyntax.h" + + FILE("SlowBcopy.s") + + AS_BEGIN + +gcc2_compiled.: +___gnu_compiled_c: + + GLOBL GLNAME(xf86SlowBcopy) + + SEG_TEXT + ALIGNTEXT4 +GLNAME(xf86SlowBcopy): + PUSH_L (EBP) + MOV_L (ESP,EBP) + PUSH_L (ESI) + PUSH_L (EBX) + MOV_L (REGOFF(8,EBP),ECX) + MOV_L (REGOFF(12,EBP),EDX) + MOV_L (REGOFF(16,EBP),ESI) + XOR_L (EAX,EAX) + CMP_L (ESI,EAX) + JGE (L3) + + ALIGNTEXT4 +L5: + MOV_B (REGIND(ECX),BL) + + MOV_B (BL, BH) + MOV_B (BH, BL) + MOV_B (BL, BH) + MOV_B (BH, BL) + MOV_B (BL, BH) + MOV_B (BH, BL) + MOV_B (BL, BH) + MOV_B (BH, BL) + MOV_B (BL, BH) + MOV_B (BH, BL) + + MOV_B (BL,REGIND(EDX)) + + INC_L (ECX) + DEC_L (ECX) + INC_L (ECX) + DEC_L (ECX) + INC_L (ECX) + DEC_L (ECX) + INC_L (ECX) + DEC_L (ECX) + INC_L (ECX) + DEC_L (ECX) + + INC_L (ECX) + INC_L (EDX) + INC_L (EAX) + CMP_L (ESI,EAX) + JL (L5) +L3: + LEA_L (REGOFF(-8,EBP),ESP) + POP_L (EBX) + POP_L (ESI) + MOV_L (EBP,ESP) + POP_L (EBP) + RET + diff --git a/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c new file mode 100644 index 000000000..5cd716823 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/SlowBcopy.c @@ -0,0 +1,127 @@ +/******************************************************************************* + for Alpha Linux +*******************************************************************************/ + +/* + * Create a dependency that should be immune from the effect of register + * renaming as is commonly seen in superscalar processors. This should + * insert a minimum of 100-ns delays between reads/writes at clock rates + * up to 100 MHz---GGL + * + * Slowbcopy(char *src, char *dst, int count) + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "compiler.h" + +static int really_slow_bcopy; + +_X_EXPORT void +xf86SetReallySlowBcopy(void) +{ + really_slow_bcopy = 1; +} + +#if defined(__i386__) || defined(__x86_64__) +static void xf86_really_slow_bcopy(unsigned char *src, unsigned char *dst, int len) +{ + while(len--) + { + *dst++ = *src++; + outb(0x80, 0x00); + } +} +#endif + +/* The outb() isn't needed on my machine, but who knows ... -- ost */ +_X_EXPORT void +xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len) +{ +#if defined(__i386__) || defined(__x86_64__) + if (really_slow_bcopy) { + xf86_really_slow_bcopy(src, dst, len); + return; + } +#endif + while(len--) + *dst++ = *src++; +} + +#ifdef __alpha__ +/* + * The Jensen lacks dense memory, thus we have to address the bus via + * the sparse addressing scheme. Time critical code uses routines from + * BUSmemcpy.c + * + * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 + */ + +#ifdef linux + +unsigned long _bus_base(void); + +#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ +#define SPARSE (5) +#else +#define SPARSE (7) +#endif + +#define isJensen() (!_bus_base()) + +#else + +#define isJensen() 0 +#define SPARSE 0 + +#endif + +_X_EXPORT void +xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count) +{ + if (isJensen()) + { + unsigned long addr; + long result; + + addr = (unsigned long) src; + while( count ){ + result = *(volatile int *) addr; + result >>= ((addr>>SPARSE) & 3) * 8; + *dst++ = (unsigned char) (0xffUL & result); + addr += 1<<SPARSE; + count--; + outb(0x80, 0x00); + } + } + else + xf86SlowBcopy(src,dst,count); +} + +_X_EXPORT void +xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count) +{ + if (isJensen()) + { + unsigned long addr; + + addr = (unsigned long) dst; + while(count) { + *(volatile unsigned int *) addr = (unsigned short)(*src) * 0x01010101; + src++; + addr += 1<<SPARSE; + count--; + outb(0x80, 0x00); + } + } + else + xf86SlowBcopy(src,dst,count); +} +#endif diff --git a/xorg-server/hw/xfree86/os-support/misc/xf86_IlHack.c b/xorg-server/hw/xfree86/os-support/misc/xf86_IlHack.c new file mode 100644 index 000000000..6c9871d93 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/xf86_IlHack.c @@ -0,0 +1,16 @@ +/* + * This file is an incredible crock to get the normally-inline functions + * built into the server so that things can be debugged properly. + * + * Note: this doesn't work when using a compiler other than GCC. + */ + +#define static /**/ +#define __inline__ /**/ +#undef NO_INLINE +#define DO_PROTOTYPES +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "compiler.h" diff --git a/xorg-server/hw/xfree86/os-support/misc/xf86_Util.c b/xorg-server/hw/xfree86/os-support/misc/xf86_Util.c new file mode 100644 index 000000000..9e690591d --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/misc/xf86_Util.c @@ -0,0 +1,94 @@ +/* + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * This file is for utility functions that will be shared by other pieces + * of the system. Putting things here ensure that all the linking order + * dependencies are dealt with, as this library will be linked in last. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <ctype.h> + +/* To prevent empty source file warnings */ +int _xf86misc; + +#if 0 +/* For use only with gcc */ +#ifdef __GNUC__ + +#include "os.h" + +char * +debug_alloca(char *file, int line, int size) +{ + char *ptr; + + ptr = Xalloc(size); + ErrorF("Alloc: %s line %d; ptr = 0x%x, length = %d\n", file, line, + ptr, size); + return ptr; +} + +void +debug_dealloca(char *file, int line, char *ptr) +{ + ErrorF("Dealloc: %s line %d; ptr = 0x%x\n", file, line, ptr); + Xfree(ptr); +} +#endif +#endif + +#if defined(ISC) || defined(Lynx) + +#include <math.h> + +/* Needed for apm_driver.c */ +/* These functions are modeled after the functions inside gnu's libc */ + +static double +copysign(double x, double y) +{ + x = fabs(x); + return y < 0 ? - x : x; +} + +double +RInt(double x) +{ + double s,t; + const double one = 1.0; + const static double L = 4503599627370496.0E0; + + if (x!=x) + return(x); + if (copysign(x,one) >= L) + return(x); + s = copysign(L,x); + t = x + s; + return (t - s); +} +#endif diff --git a/xorg-server/hw/xfree86/os-support/sco/Makefile.am b/xorg-server/hw/xfree86/os-support/sco/Makefile.am new file mode 100644 index 000000000..9cb5011fb --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sco/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = \ + VTsw_sco.c \ + sco_init.c \ + sco_iop.c \ + sco_mouse.c \ + sco_video.c diff --git a/xorg-server/hw/xfree86/os-support/sco/Makefile.in b/xorg-server/hw/xfree86/os-support/sco/Makefile.in new file mode 100644 index 000000000..a417e9a94 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sco/Makefile.in @@ -0,0 +1,538 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/sco +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +EXTRA_DIST = \ + VTsw_sco.c \ + sco_init.c \ + sco_iop.c \ + sco_mouse.c \ + sco_video.c + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/sco/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/sco/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c new file mode 100644 index 000000000..d126e7869 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c @@ -0,0 +1,117 @@ +/* + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1993 by David McCullough <davidm@stallion.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* For the event driver prototypes */ +#include <sys/event.h> +#include <mouse.h> + +/* + * Handle the VT-switching interface for SCO + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. NOTE: we do NOT need + * to re-arm the signal here, since we used sigaction() to set the signal + * disposition in sco_init.c. If we had used signal(), we would need to + * re-arm the signal here. All we need to do now is record the fact that + * we got the signal. XFree86 handles the rest. + */ +void +xf86VTRequest(int sig) +{ + xf86Info.vtRequestsPending = TRUE; + return; +} + +Bool +xf86VTSwitchPending(void) +{ + return(xf86Info.vtRequestsPending ? TRUE : FALSE); +} + +/* + * When we switch away, we need to flush and suspend the event driver + * before the VT_RELDISP. We also need to get the current LED status + * and preserve it, so that we can restore it when we come back. + */ +static int sco_ledstatus = -1; +static unsigned int sco_ledstate = 0; + +Bool +xf86VTSwitchAway(void) +{ + ev_flush(); + ev_suspend(); + + sco_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &sco_ledstate); + + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) { + return(FALSE); + } else { + return(TRUE); + } +} + +/* + * When we come back to the X server, we need to resume the event driver, + * and we need to restore the LED settings to what they were when we + * switched away. + */ +Bool +xf86VTSwitchTo(void) +{ + ev_resume(); + + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) { + return(FALSE); + } else { + if (sco_ledstatus >= 0) { + ioctl (xf86Info.consoleFd, KDSETLED, sco_ledstate); + } + sco_ledstatus = -1; + + /* + * Convince the console driver this screen is in graphics mode, + * otherwise it assumes it can do more to the screen than it should. + */ + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { + ErrorF("Failed to set graphics mode (%s)\n", strerror(errno)); + } + + return TRUE; + } +} diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_init.c b/xorg-server/hw/xfree86/os-support/sco/sco_init.c new file mode 100644 index 000000000..5f7db3437 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sco/sco_init.c @@ -0,0 +1,294 @@ +/* + * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com> + * + * 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 J. Kean Johnston not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. J. Kean Johnston makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL J. KEAN JOHNSTON 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. + */ + +/* Re-written May 2001 to represent the current state of reality */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static Bool KeepTty = FALSE; +static int VTnum = -1; +static char vtdevice[48]; +static int sco_console_mode = -1; + +extern Bool mpxLock; + +void +xf86OpenConsole(void) +{ + int i, ioctl_ret; + struct vt_mode VT; + struct vid_info vidinf; + struct sigaction sigvtsw; + char *ttn; + + if (serverGeneration == 1) { + /* check if we're run with euid==0 */ + if (geteuid() != 0) { + FatalError("xf86OpenConsole: Server must be setuid root\n"); + } + + /* If we are run in the background we will get SIGTTOU. Ignore it. */ + OsSignal (SIGTTOU, SIG_IGN); + + /* + * Set up the virtual terminal (multiscreen in SCO parlance). + * For the actual console itself, screens are numbered from + * 1 to (usually) 16. However, it is possible to have a nested + * server, and it is also possible to be on a multi-console + * system such as MaxSpeed or SunRiver. Therefore, we should + * not make any assumptions about the TTY name we are on, and + * instead we rely on ttyname() to give us the real TTY name. + * Previously, we tried to determine the TTY name manually. + * This is wrong. The only time we need to futz with the TTY name + * is if we were given the name of a TTY to run on explicity on + * the command line. + */ + + if (VTnum == -1) { + /* + * No device was specified. We need to query the kernel to see which + * console device we are on (and in fact if we are on a console at all). + */ + ttn = ttyname (1); + + if (ttn == (char *)0) { + FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n", + strerror(errno)); + } + strlcpy (vtdevice, ttn, sizeof(vtdevice)); + } else if (VTnum >= 0) { + snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum); + } + + /* + * Now we can dispose of stdin/stdout + */ + fclose (stdin); + fclose (stdout); + + if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) { + FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice, + strerror(errno)); + } + + /* + * We make 100% sure we use the correct VT number. This can get ugly + * where there are multi-consoles in use, so we make sure we query + * the kernel for the correct VT number. It knows best, we don't. + */ + vidinf.size = sizeof(vidinf); + if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) { + FatalError ("xf86OpenConsole: %s not a console device " + "or error querying device: %s\n", vtdevice, strerror (errno)); + } + xf86Info.vtno = vidinf.m_num; + VTnum = vidinf.m_num + 1; /* 0-based */ + + ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice); + + /* We activate the console just in case its not the one we are on */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno)); + } + + /* Disassociate from controling TTY */ + if (!KeepTty) { + setpgrp(); + } + + /* + * Now we get the current mode that the console device is in. We will + * use this later when we close the console device to restore it to + * that same mode. + */ + if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) { + FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n", + strerror(errno)); + } + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) { + FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno)); + } + + sigvtsw.sa_handler = xf86VTRequest; + sigfillset(&sigvtsw.sa_mask); + sigvtsw.sa_flags = 0; + + /* NOTE: Using sigaction means we dont have to re-arm the signal */ + sigaction(SIGUSR1, &sigvtsw, NULL); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + VT.frsig = SIGINT; /* Not implemented */ + VT.waitv = 0; + + /* + * The SCO X server tries the following call 5 times. Lets do the same + * thing. It shouldn't really be required but sometimes things take a + * while to settle down when switching screens. *helpless shrug* I know + * its sucks but ... + */ + + ioctl_ret = 0; + for (i = 0; i < 5; i++) { + ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); + if (ioctl_ret >= 0) + break; + usleep(999999); /* Dont use nap() - it forces linking with -lx */ + } + + if (ioctl_ret < 0) { + FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno)); + } + + /* + * Convince the console driver we are in graphics mode. + */ + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { + ErrorF("Failed to set graphics mode (%s)\n", strerror(errno)); + } + } else { /* serverGeneration != 1 */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno)); + } + } +} + +/* + * Restore the console to its previous state. This may cause flicker if + * the screen was previous in a graphics mode, because we first set it + * to text mode. This has the advantage of getting the console driver + * to do a soft reset on the card, which really does help settle the + * video card down again after coming out of Xfree86. + */ +void +xf86CloseConsole(void) +{ + struct vt_mode VT; + struct sigaction sigvtsw; + + /* Set text mode (possibly briefly) */ + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0); + + /* Restore the original mode */ + if (sco_console_mode != -1) { + ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L); + } + + ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */ + + sigvtsw.sa_handler = SIG_DFL; + sigfillset(&sigvtsw.sa_mask); + sigvtsw.sa_flags = 0; + + sigaction(SIGUSR1, &sigvtsw, NULL); + + VT.mode = VT_AUTO; + VT.waitv = 0; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + VT.frsig = SIGINT; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */ + + close(xf86Info.consoleFd); /* We're done with the device */ +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals). + */ + if (!strcmp(argv[i], "-keeptty")) { + KeepTty = TRUE; + return(1); + } + + /* + * By default, the X server wants to bind itself to CPU 0. This makes + * sure that the server has full access to the I/O ports at IOPL 3. + * Some SMP systems have trouble with I/O on CPU's other than 0. If, + * however, you have a system that is well behaved, you can specify + * this argument and let the scheduler decide which CPU the server + * should run on. + */ + if (!strcmp(argv[i], "-nompxlock")) { + mpxLock = FALSE; + return (1); + } + + /* + * Specify the VT number to run on (NOT the device). + */ + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) { + UseMsg(); + VTnum = -1; + return(0); + } + if (VTnum <= 0) { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + + /* + * Use a device the user specifies. + */ + if (!strcmp(argv[i], "-crt")) { + if (++i > argc) { + UseMsg(); + VTnum = -1; + return(0); + } else { + VTnum = -2; + strlcpy (vtdevice, argv[i], sizeof(vtdevice)); + return(2); + } + } + return(0); +} + +void +xf86UseMsg(void) +{ + ErrorF("vtXX use the specified VT number\n"); + ErrorF("-crt DEVICE use the specified VT device\n"); + ErrorF("-nompxlock dont bind X server to CPU 0\n"); + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); +} diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_iop.c b/xorg-server/hw/xfree86/os-support/sco/sco_iop.c new file mode 100644 index 000000000..bb8d06d2e --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sco/sco_iop.c @@ -0,0 +1,134 @@ +/* + * Copyright 2001 by J. Kean Johnston <jkj@caldera.com> + * + * 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 J. Kean Johnston not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. J. Kean Johnston makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "compiler.h" + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86OSpriv.h" +#include "xf86_OSlib.h" + + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +/* + * There is a right way and a wrong way of doing this. Unfortunately, we + * are forced to do it the wrong way. The right way is to be told the range + * or ranges of I/O ports the driver(s) need access to, in order to use the + * CONS_IOPERM ioctl() to grant access only to those ports we care about. + * This way we can guarantee some small level of stability because a driver + * does not have access to all ports (which would mean it could play with + * the PIT and thus affect scheduling times, or a whole slew of other + * nasty things). However, because XFree86 currently only enables or disables + * ALL port access, we need to run at IOPL 3, which basically means the + * X Server runs at the same level as the kernel. You can image why this is + * unsafe. Oh, and this is not a problem unique to OSR5, other OSes are + * affected by this as well. + * + * So, for the time being, we change our IOPL until such time as the XFree86 + * architecture is changed to allow for tighter control of I/O ports. If and + * when it is, then the CONS_ADDIOP/DELIOP ioctl() should be used to enable + * or disable access to the desired ports. + */ + +extern long sysi86 (int cmd, ...); + +static Bool IOEnabled = FALSE; + +_X_EXPORT Bool +xf86EnableIO(void) +{ + if (IOEnabled) + return TRUE; + + if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) { + xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n"); + return FALSE; + } + + IOEnabled = TRUE; + return TRUE; +} + +_X_EXPORT void +xf86DisableIO(void) +{ + if (!IOEnabled) + return; + + sysi86(SI86V86, V86SC_IOPL, 0); + IOEnabled = FALSE; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts(void) +{ + if (!IOEnabled) { + if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) + return FALSE; + } + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + if (!IOEnabled) { + sysi86(SI86V86, V86SC_IOPL, PS_IOPL); + } + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts(void) +{ + if (!IOEnabled) { + if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) + return; + } + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + if (!IOEnabled) { + sysi86(SI86V86, V86SC_IOPL, PS_IOPL); + } +} diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_mouse.c b/xorg-server/hw/xfree86/os-support/sco/sco_mouse.c new file mode 100644 index 000000000..af57cdedf --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sco/sco_mouse.c @@ -0,0 +1,258 @@ +/* + * Copyright 2001 by J. Kean Johnston <jkj@sco.com> + * + * 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 J. Kean Johnston not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. J. Kean Johnston makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" +#include "mipointer.h" +#include <sys/event.h> +#include <mouse.h> + +static int +SupportedInterfaces (void) +{ + return MSE_MISC; +} + +static const char *internalNames[] = { + "OSMouse", + NULL +}; + +static const char ** +BuiltinNames (void) +{ + return internalNames; +} + +static Bool +CheckProtocol (const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) { + if (xf86NameCmp (protocol, internalNames[i]) == 0) + return TRUE; + } + + return FALSE; +} + +static const char * +DefaultProtocol (void) +{ + return "OSMouse"; +} + +static const char * +evtErrStr (int evterr) +{ + switch (evterr) { + case -1: return "error in config files"; + case -2: return "no mouse devices to attach"; + case -3: return "unable to open device"; + case -4: return "unable to open event queue"; + case -999: return "unable to initialize event driver"; + default: return "unknown event driver error"; + } +} + +static int +OsMouseProc (DeviceIntPtr pPointer, int what) +{ + InputInfoPtr pInfo; + MouseDevPtr pMse; + unsigned char map[9]; + dmask_t dmask; + MessageType from = X_CONFIG; + int evi; + + pInfo = pPointer->public.devicePrivate; + pMse = pInfo->private; + pMse->device = pPointer; + + switch (what) { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + dmask = D_ABS | D_REL | D_BUTTON; + if ((evi = ev_initf(xf86Info.consoleFd)) < 0) { + FatalError ("OsMouseProc: Event driver initialization failed (%s)\n", + evtErrStr(evi)); + } + pInfo->fd = ev_open (&dmask); + if (pInfo->fd < 0) { + FatalError ("OsMouseProc: DEVICE_INIT failed (%s)\n", evtErrStr(pInfo->fd)); + } + + pMse->buttons = xf86SetIntOption (pInfo->options, "Buttons", 0); + if (pMse->buttons == 0) { + pMse->buttons = 8; + from = X_DEFAULT; + } + xf86Msg (from, "%s: Buttons: %d\n", pInfo->name, pMse->buttons); + + for (evi = 0; evi <= 8; evi++) + map[evi] = evi; + + InitPointerDeviceStruct((DevicePtr)pPointer, map, 8, + miPointerGetMotionEvents, pMse->Ctrl, + miPointerGetMotionBufferSize()); + + /* X valuator */ + xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 0); + + /* Y valuator */ + xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 1); + + xf86MotionHistoryAllocate(pInfo); + + ev_flush(); + ev_suspend(); + break; + + case DEVICE_ON: + pMse->lastButtons = 0; + pMse->lastMappedButtons = 0; + pMse->emulateState = 0; + pPointer->public.on = TRUE; + ev_resume(); + AddEnabledDevice (pInfo->fd); + break; + + case DEVICE_OFF: + case DEVICE_CLOSE: + pPointer->public.on = FALSE; + RemoveEnabledDevice (pInfo->fd); + if (what == DEVICE_CLOSE) { + ev_close(); + pInfo->fd = -1; + } else { + ev_suspend(); + } + break; + } + + return Success; +} + +static void +OsMouseReadInput (InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + EVENT *evp; + + pMse = pInfo->private; + + while ((evp = ev_read()) != (EVENT *)0) { + int buttons = EV_BUTTONS(*evp); + int dx = EV_DX(*evp), dy = -(EV_DY(*evp)), dz = 0; + + if (buttons & WHEEL_FWD) + dz = -1; + else if (buttons & WHEEL_BACK) + dz = 1; + + buttons &= ~(WHEEL_FWD | WHEEL_BACK); + + pMse->PostEvent (pInfo, buttons, dx, dy, dz, 0); + ev_pop(); + } +} + +static Bool +OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse; + + /* This is called when the protocol is "OSMouse". */ + + pMse = pInfo->private; + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = ev_initf(xf86Info.consoleFd); + if (pInfo->fd != -1) { + dmask_t dmask = (D_ABS | D_REL | D_BUTTON); + pInfo->fd = ev_open(&dmask); + } else { + pInfo->fd = -999; + } + + if (pInfo->fd < 0) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open event manager (%s)\n", + pInfo->name, evtErrStr(pInfo->fd)); + else { + xf86Msg(X_ERROR, "%s: cannot open event manager (%s)\n", + pInfo->name, evtErrStr(pInfo->fd)); + xfree(pMse); + return FALSE; + } + } + ev_close(); + pInfo->fd = -1; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pInfo->device_control = OsMouseProc; + pInfo->read_input = OsMouseReadInput; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit (int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + + p->SupportedInterfaces = SupportedInterfaces; + p->BuiltinNames = BuiltinNames; + p->DefaultProtocol = DefaultProtocol; + p->CheckProtocol = CheckProtocol; + p->PreInit = OsMousePreInit; + + return p; +} diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_video.c b/xorg-server/hw/xfree86/os-support/sco/sco_video.c new file mode 100644 index 000000000..7edf71db3 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sco/sco_video.c @@ -0,0 +1,294 @@ +/* + * Copyright 2001 by J. Kean Johnston <jkj@sco.com> + * + * 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 J. Kean Johnston not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. J. Kean Johnston makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL J. KEAN JOHNSTON 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. + */ + +/* Re-written May 2001 to represent the current state of reality */ + +/* + * This file contains the completely re-written SCO OpenServer video + * routines for XFree86 4.x. Much of this is based on the SCO X server + * code (which is an X11R5 server) and will probably only work on + * OpenServer versions 5.0.5, 5.0.6 and later. Please send me (jkj@sco.com) + * email if you have any questions. + * + * Ideally, you should use OSR5.0.6A or later, with the updated console + * driver for 5.0.6A (its the default driver in 5.0.7 and later). + * However, if you are running on an older system, this code will detect + * that and adjust accordingly. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86OSpriv.h" +#include "xf86_OSlib.h" + +#include <sys/ci/ciioctl.h> +#define MPXNAME "/dev/atp1" +#define BASECPU 1 + +Bool mpxLock = TRUE; + +#define USE_VASMETHOD 1 + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static int sco_mcdone = 0, sco_ismc = 0; + +/***************************************************************************/ +/* + * To map the video memory, we first need to see if we are on a multi-console + * system. If we are, we need to try to use an existing video class in the + * kernel. We do this by retrieving the list of currently defined classes + * (via the new CONS_GETCLASS ioctl()) to see if we have a class that will + * match the range of memory we desire. If we can't find one, we have an + * error and we abort. + * + * If we are not using a multi-console, we can simply use mmap() to map in + * the frame buffer, using the classs-access method as a fall-back only if + * the mmap() fails (it shouldn't). We always set the appropriate pointers + * in the config structure to point ot the right function to map and unmap + * the video memory. An alternative to using mmap() is to use the new + * CONS_ADDVAS call, which will use vasmalloc() and vasbind() in the kernel + * to map the physical address to a virtual one, which it then returns. + * I am not 100% sure if this is faster or not, but it may prove easier to + * debug things. Just to be on the safe side, I have included both methods + * here, and the mmap() method can be used by setting USE_VASMETHOD to 0 + * above. + */ + +#if !defined(CONS_ADDVAS) +# undef USE_VASMETHOD +# define USE_VASMETHOD 0 +#endif + +static int +scoIsMultiConsole (void) +{ + int x; + + if (sco_mcdone) + return sco_ismc; + x = access ("/usr/lib/vidconf/.multiconsole", F_OK); + if (x == 0) + sco_ismc = 1; + sco_mcdone = 1; + return sco_ismc; +} + +/* + * This maps memory using mmap() + */ +static pointer +mapVidMemMMAP(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + int fd; + unsigned long realBase, alignOff; + pointer base; + + fd = open (DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", DEV_MEM, + strerror(errno)); + return 0; /* NOTREACHED */ + } + + realBase = Base & ~(getpagesize() - 1); + alignOff = Base - realBase; + +#ifdef DEBUG + ErrorF("base: %lx, realBase: %lx, alignOff: %lx\n", Base,realBase,alignOff); +#endif + + base = mmap((caddr_t)0, Size + alignOff, + (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, (off_t)realBase); + close(fd); + if (base == MAP_FAILED) { + FatalError("xf86MapVidMem: Could not mmap framebuffer (0x%08x,0x%x) (%s)\n", + Base, Size, strerror(errno)); + return 0; /* NOTREACHED */ + } + +#ifdef DEBUG + ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff); +#endif + return (pointer)((char *)base + alignOff); +} + +#if (USE_VASMETHOD) +/* + * This maps memory using the virtual address space (VAS) console calls. + */ +static pointer +mapVidMemVAS(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + struct vidvasmem vas; + pointer base; + + vas.base = (long)Base; + vas.size = (long)Size; + + base = (pointer)ioctl (xf86Info.consoleFd, CONS_ADDVAS, &vas); + if (base == (pointer)-1) { + return mapVidMemMMAP(ScreenNum, Base, Size, flags); + } + return base; +} +#endif /* USE_VASMETHOD */ + +struct vidclass vidclasslist[] = { + { "VBE", "", 0xf0000000, 0x2000000, 0 }, + { "P9000", "", 0xc0000000, 0x400000, 0 }, + { "TULIP", "", 0x80000000, 0x400000, 0 }, + { "VIPER", "", 0xa0000000, 0x400000, 0 }, + { "S3T", "", 0xa0000000, 0x200000, 0 }, + { "S3DT", "", 0x4000000, 0x400000, 0 }, + { "MGA", "", 0x2200000, 0x4000, 0 }, + { "CLVGA", "", 0xa0000, 0x20000, 0 }, + { "OLIVE", "", 0xd8000000, 0x400000, 0 }, + { "S3C", "", 0xa0000, 0x10000, 0 }, + { "MGAVLB", "", 0xac000, 0x34000, 0 }, + { "ATI8514", "", 0xFF000, 0x1000, 0 }, + { "GXREGS", "", 0xb0000, 0x10000, 0 }, + { "GX", "", 0xa0000, 0x10000, 0 }, + { "CT64300", "", 0xa0000000, 0x400000, 0 }, + { "SVGA", "", 0xa0000, 0x20000, 0 }, + { "S3V", "", 0xa0000000, 0x400000, 0 }, + { "8514A", "", 0xFF000, 0x1000, 0 }, + { "VGA", "", 0xa0000, 0x10000, 0 }, + { 0 } +}; + +static pointer +mapVidMemVC(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + struct vidclass *vcp; + char *class = NULL; + pointer base; + + for (vcp = vidclasslist; vcp->name; vcp++) { + if ((vcp->base == Base) && (vcp->size == Size)) { + class = vcp->name; + break; + } + } + + if (class == NULL) { + /* + * As a fall-back, we will try and use the mmap() approach. This may + * prove to be the wrong thing to do, but time and testing will tell. + */ + ErrorF("xf86MapVidMem: No class map defined for (0x%08x,0x%08x)\n", Base, Size); +#if USE_VASMETHOD + return mapVidMemVAS(ScreenNum, Base, Size, flags); +#else /* !USE_VASMETHOD */ + return mapVidMemMMAP(ScreenNum, Base, Size, flags); +#endif + } + + /* + * We found a suitable class. Try and use it. + */ + base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class); + if ((int)base == -1) { + FatalError("xf86MapVidMem: Failed to map video memory class `%s'\n", class); + return 0; /* NOTREACHED */ + } + + return base; +} + +/* + * Unmapping the video memory is easy. We always call munmap(), as it is + * safe to do so even if we haven't actually mapped in any pages via mmap(). + * In the case where we used the video class, we don't need to do anything + * as the kernel will clean up the TSS when we exit, and will undo the + * vasbind() that was done when the class was originally mapped. If we used + * vasmap, we simply undo the map. Again, it is benign to call vasunmap + * even if we got the frame buffer via some other mechanism (like mmap). + */ + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ +#if USE_VASMETHOD + struct vidvasmem vas; + int x; + + vas.base = (long)Base; + vas.size = (long)Size; + + x = ioctl (xf86Info.consoleFd, CONS_DELVAS, &vas); + if (x == 0) + return; +#endif /* USE_VASMETHOD */ + + munmap(Base, Size); +} + +/* + * Set things up to point to our local functions. When the kernel gets + * MTRR support, we will need to add the required functions for that + * here too. MTRR support will most likely appear in 5.0.8 or 5.1.0. + * + * We also want to lock the X server process to the base CPU in an MPX + * system, since we will be going to IOPL 3. Most engine drivers can cope + * with I/O access on any CPU but there are a few (AST Manhattan I believe) + * that can't, so the server needs to be locked to CPU0. + */ +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + int mpx_fd; + + if (scoIsMultiConsole ()) { + pVidMem->mapMem = mapVidMemVC; + } else { +#if USE_VASMETHOD + pVidMem->mapMem = mapVidMemVAS; +#else + pVidMem->mapMem = mapVidMemMMAP; +#endif + } + + pVidMem->unmapMem = unmapVidMem; + pVidMem->linearSupported = TRUE; + pVidMem->initialised = TRUE; + + if (mpxLock && (mpx_fd = open (MPXNAME, O_RDONLY)) > 0) { + if (ioctl (mpx_fd, ACPU_XLOCK, BASECPU) < 0) + ErrorF ("xf86OSInitVidMem: Can not bind to CPU 0 (%s)\n", + strerror(errno)); + close (mpx_fd); + } +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c new file mode 100644 index 000000000..a3cfe40b9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c @@ -0,0 +1,54 @@ +/* + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * No-op functions for OSs without VTs + */ + +Bool +xf86VTSwitchPending() +{ + return(FALSE); +} + +Bool +xf86VTSwitchAway() +{ + return(FALSE); +} + +Bool +xf86VTSwitchTo() +{ + return(TRUE); +} diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c new file mode 100644 index 000000000..4d473147f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c @@ -0,0 +1,90 @@ +/* + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifdef OSHEADER +# include OSHEADER +#endif + +/* + * Handle the VT-switching interface for OSs that use USL-style ioctl()s + * (the sysv, sco, and linux subdirs). + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. + */ +void +xf86VTRequest(int sig) +{ + signal(sig, (void(*)(int))xf86VTRequest); + xf86Info.vtRequestsPending = TRUE; + return; +} + +Bool +xf86VTSwitchPending() +{ + return(xf86Info.vtRequestsPending ? TRUE : FALSE); +} + +Bool +xf86VTSwitchAway() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) + { + return(FALSE); + } + else + { +#ifdef OSSWITCHAWAY + OSSWITCHAWAY; +#endif + return(TRUE); + } +} + +Bool +xf86VTSwitchTo() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + { + return(FALSE); + } + else + { + return(TRUE); + } +} diff --git a/xorg-server/hw/xfree86/os-support/shared/agp_noop.c b/xorg-server/hw/xfree86/os-support/shared/agp_noop.c new file mode 100644 index 000000000..5774bc231 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/agp_noop.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2000-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * Abstraction of the AGP GART interface. Stubs for platforms without + * AGP GART support. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +_X_EXPORT Bool +xf86GARTCloseScreen(int screenNum) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86AgpGARTSupported() +{ + return FALSE; +} + +_X_EXPORT AgpInfoPtr +xf86GetAGPInfo(int screenNum) +{ + return NULL; +} + +_X_EXPORT Bool +xf86AcquireGART(int screenNum) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86ReleaseGART(int screenNum) +{ + return FALSE; +} + +_X_EXPORT int +xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical) +{ + return -1; +} + +_X_EXPORT Bool +xf86DeallocateGARTMemory(int screenNum, int key) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86BindGARTMemory(int screenNum, int key, unsigned long offset) +{ + return FALSE; +} + + +_X_EXPORT Bool +xf86UnbindGARTMemory(int screenNum, int key) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86EnableAGP(int screenNum, CARD32 mode) +{ + return FALSE; +} diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c new file mode 100644 index 000000000..7288239be --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c @@ -0,0 +1,75 @@ +/* + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include <string.h> + +/* + * Read BIOS via /dev/mem. + */ + +#ifndef DEV_MEM +# define DEV_MEM "/dev/mem" +#endif + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int fd; + +#ifdef __ia64__ + if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0) +#else + if ((fd = open(DEV_MEM, O_RDONLY)) < 0) +#endif + { + xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + return(-1); + } + + if (lseek(fd, (Base+Offset), SEEK_SET) < 0) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n", + DEV_MEM, strerror(errno)); + close(fd); + return(-1); + } + if (read(fd, Buf, Len) != Len) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n", + DEV_MEM, strerror(errno)); + close(fd); + return(-1); + } + close(fd); + return(Len); +} diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c new file mode 100644 index 000000000..8bac87ebe --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c @@ -0,0 +1,162 @@ +/* + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +#ifndef __alpha__ +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int fd; + unsigned char *ptr; + int psize; + int mlen; + + if ((fd = open(DEV_MEM, O_RDONLY)) < 0) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + return(-1); + } + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, fd, (off_t)Base); + if (ptr == MAP_FAILED) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n", + DEV_MEM, strerror(errno)); + close(fd); + return(-1); + } +#ifdef DEBUG + ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", + Base, ptr[0] | (ptr[1] << 8)); +#endif + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); + (void)close(fd); + return(Len); +} + +#else /* __alpha__ */ + + /* + * We trick "mmap" into mapping BUS memory for us via BUS_BASE, + * which is the KSEG address of the start of the DENSE memory + * area. + */ + + /* + * NOTE: there prolly ought to be more validity checks and all + * re: boundaries and sizes and such... + */ + +/* + * The Jensen lacks dense memory, thus we have to address the bus via + * the sparse addressing scheme. + * + * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 + */ + +#ifdef linux + +#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ +#define SPARSE (5) +#define isJensen (1) +#else +#define isJensen (!_bus_base()) +#define SPARSE (7) +#endif + +extern unsigned long _bus_base(void); +extern unsigned long _bus_base_sparse(void); +#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base()) +#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x) + +#else + +extern u_int64_t dense_base(void); +#define BUS_BASE dense_base() +#define JENSEN_SHIFT(x) ((long) x) + +#endif + +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + caddr_t base; + int fd; + int psize; + int mlen; + + if ((fd = open(DEV_MEM, O_RDONLY)) < 0) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + return(-1); + } + + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + base = mmap((caddr_t)0, JENSEN_SHIFT(mlen), PROT_READ, + MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE)); + + if (base == MAP_FAILED) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + return(-1); + } + + xf86SlowBCopyFromBus((unsigned char *)(base+JENSEN_SHIFT(Offset)), + Buf, Len); + + munmap((caddr_t)JENSEN_SHIFT(base), JENSEN_SHIFT(mlen)); + close(fd); + return(Len); +} + +#endif /* __alpha__ */ diff --git a/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c b/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c new file mode 100644 index 000000000..6f6924b59 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/ia64Pci.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +/* + * This file contains the glue needed to support various IA-64 chipsets. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <fcntl.h> +#include <unistd.h> +#include <signal.h> +#include <dirent.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <linux/pci.h> + +#include "compiler.h" +#include "Pci.h" + +/* + * We use special in/out routines here since Altix platforms require the + * use of the sysfs legacy_io interface. The legacy_io file maps to the I/O + * space of a given PCI domain; reads and writes are used to do port I/O. + * The file descriptor for the file is stored in the upper bits of the + * value passed in by the caller, and is created and populated by + * xf86MapLegacyIO. + * + * If the legacy_io interface doesn't exist, we fall back to the glibc in/out + * routines, which are prefixed by an underscore (e.g. _outb). + */ +static int ia64_port_to_fd(unsigned long port) +{ + return (port >> 24) & 0xffffffff; +} + +_X_EXPORT void outb(unsigned long port, unsigned char val) +{ + int fd = ia64_port_to_fd(port); + + if (!fd) { + _outb(val, port & 0xffff); + goto out; + } + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + goto out; + } + if (write(fd, &val, 1) != 1) { + ErrorF("I/O write failed\n"); + goto out; + } + out: + return; +} + +_X_EXPORT void outw(unsigned long port, unsigned short val) +{ + int fd = ia64_port_to_fd(port); + + if (!fd) { + _outw(val, port & 0xffff); + goto out; + } + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + goto out; + } + if (write(fd, &val, 2) != 2) { + ErrorF("I/O write failed\n"); + goto out; + } + out: + return; +} + +_X_EXPORT void outl(unsigned long port, unsigned int val) +{ + int fd = ia64_port_to_fd(port); + + if (!fd) { + _outl(val, port & 0xffff); + goto out; + } + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + goto out; + } + if (write(fd, &val, 4) != 4) { + ErrorF("I/O write failed\n"); + goto out; + } + out: + return; +} + +_X_EXPORT unsigned int inb(unsigned long port) +{ + int fd = ia64_port_to_fd(port); + unsigned char val; + + if (!fd) + return _inb(port & 0xffff); + + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + val = -1; + goto out; + } + if (read(fd, &val, 1) != 1) { + ErrorF("I/O read failed\n"); + val = -1; + goto out; + } + out: + return val; +} + +_X_EXPORT unsigned int inw(unsigned long port) +{ + int fd = ia64_port_to_fd(port); + unsigned short val; + + if (!fd) + return _inw(port & 0xffff); + + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + val = -1; + goto out; + } + if (read(fd, &val, 2) != 2) { + ErrorF("I/O read failed\n"); + val = -1; + goto out; + } + out: + return val; +} + +_X_EXPORT unsigned int inl(unsigned long port) +{ + int fd = ia64_port_to_fd(port); + unsigned int val; + + if (!fd) + return _inl(port & 0xffff); + + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + val = -1; + goto out; + } + if (read(fd, &val, 4) != 4) { + ErrorF("I/O read failed\n"); + val = -1; + goto out; + } + out: + return val; +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/inout.S b/xorg-server/hw/xfree86/os-support/shared/inout.S new file mode 100644 index 000000000..80c47c419 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/inout.S @@ -0,0 +1,111 @@ +/* $XConsortium: inout.s /main/6 1996/02/21 17:53:35 kaleb $ */ + + + + + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/inout.S,v 1.1 1999/07/10 07:24:52 dawes Exp $ */ + +#include "assyntax.h" + +/* + * Make i80386 io primitives available at C-level. + */ + + FILE("inout.s") + AS_BEGIN + SEG_TEXT + +/* + *----------------------------------------------------------------------- + * inb --- + * Input one byte. + * + * Results: + * Byte in al. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(inb) +GLNAME(inb): + MOV_L (REGOFF(4,ESP),EDX) + SUB_L (EAX,EAX) + IN_B + RET + +/* + *----------------------------------------------------------------------- + * outb --- + * Output one byte. + * + * Results: + * None. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(outb) +GLNAME(outb): + MOV_L (REGOFF(4,sp),EDX) + MOV_L (REGOFF(8,sp),EAX) + OUT_B + RET +/* + *----------------------------------------------------------------------- + * inw --- + * Input one 16-bit word. + * + * Results: + * Word in ax. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(inw) +GLNAME(inw): + MOV_L (REGOFF(4,ESP),EDX) + IN_W + RET + +/* + *----------------------------------------------------------------------- + * outw --- + * Output one 16-bit word. + * + * Results: + * None. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(outw) +GLNAME(outw): + MOV_L (REGOFF(4,ESP),EDX) + MOV_L (REGOFF(8,ESP),EAX) + OUT_W + RET + +/* + *----------------------------------------------------------------------- + * inl --- + * Input one 32-bit longword. + * + * Results: + * Word in eax. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(inl) +GLNAME(inl): + MOV_L (REGOFF(4,ESP),EDX) + IN_L + RET + +/* + *----------------------------------------------------------------------- + * outl --- + * Output one 32-bit longword. + * + * Results: + * None. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(outl) +GLNAME(outl): + MOV_L (REGOFF(4,ESP),EDX) + MOV_L (REGOFF(8,ESP),EAX) + OUT_L + RET + diff --git a/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c b/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c new file mode 100644 index 000000000..1d7851a5b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c @@ -0,0 +1,49 @@ +/* + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * Some platforms don't bother with I/O permissions, + * or the permissions are implicit with opening/enabling the console. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +_X_EXPORT Bool +xf86EnableIO() +{ + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + return; +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c b/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c new file mode 100644 index 000000000..6525e8414 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86_OSproc.h" + +_X_EXPORT int xf86LoadKernelModule(const char *pathname) +{ + (void) pathname; + return 0; /* failure */ +} diff --git a/xorg-server/hw/xfree86/os-support/shared/pm_noop.c b/xorg-server/hw/xfree86/os-support/shared/pm_noop.c new file mode 100644 index 000000000..bfac4b1c8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/pm_noop.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Stubs for the OS-support layer power-management functions. */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" + +PMClose +xf86OSPMOpen(void) +{ + return NULL; +} + + diff --git a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c new file mode 100644 index 000000000..002e3a275 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c @@ -0,0 +1,686 @@ +/* + * Copyright 1993-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static int +GetBaud (int baudrate) +{ +#ifdef B300 + if (baudrate == 300) + return B300; +#endif +#ifdef B1200 + if (baudrate == 1200) + return B1200; +#endif +#ifdef B2400 + if (baudrate == 2400) + return B2400; +#endif +#ifdef B4800 + if (baudrate == 4800) + return B4800; +#endif +#ifdef B9600 + if (baudrate == 9600) + return B9600; +#endif +#ifdef B19200 + if (baudrate == 19200) + return B19200; +#endif +#ifdef B38400 + if (baudrate == 38400) + return B38400; +#endif +#ifdef B57600 + if (baudrate == 57600) + return B57600; +#endif +#ifdef B115200 + if (baudrate == 115200) + return B115200; +#endif +#ifdef B230400 + if (baudrate == 230400) + return B230400; +#endif +#ifdef B460800 + if (baudrate == 460800) + return B460800; +#endif + return (0); +} + +_X_EXPORT int +xf86OpenSerial (pointer options) +{ +#ifdef Lynx + struct sgttyb ms_sgtty; +#endif + struct termios t; + int fd, i; + char *dev; + + dev = xf86SetStrOption (options, "Device", NULL); + if (!dev) + { + xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n"); + return (-1); + } + + SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK)); + if (fd == -1) + { + xf86Msg (X_ERROR, + "xf86OpenSerial: Cannot open device %s\n\t%s.\n", + dev, strerror (errno)); + xfree(dev); + return (-1); + } + + if (!isatty (fd)) + { +#if 1 + /* Allow non-tty devices to be opened. */ + xfree(dev); + return (fd); +#else + xf86Msg (X_WARNING, + "xf86OpenSerial: Specified device %s is not a tty\n", + dev); + SYSCALL (close (fd)); + errno = EINVAL; + xfree(dev); + return (-1); +#endif + } + +#ifdef Lynx + /* LynxOS does not assert DTR without this */ + ioctl (fd, TIOCGETP, (char *) &ms_sgtty); + ioctl (fd, TIOCSDTR, (char *) &ms_sgtty); +#endif + + /* set up default port parameters */ + SYSCALL (tcgetattr (fd, &t)); + t.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\ + |IGNCR|ICRNL|IXON); + t.c_oflag &= ~OPOST; + t.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + t.c_cflag &= ~(CSIZE|PARENB); + t.c_cflag |= CS8|CLOCAL; + + cfsetispeed (&t, B9600); + cfsetospeed (&t, B9600); + t.c_cc[VMIN] = 1; + t.c_cc[VTIME] = 0; + + SYSCALL (tcsetattr (fd, TCSANOW, &t)); + + if (xf86SetSerial (fd, options) == -1) + { + SYSCALL (close (fd)); + xfree(dev); + return (-1); + } + + SYSCALL (i = fcntl (fd, F_GETFL, 0)); + if (i == -1) + { + SYSCALL (close (fd)); + xfree(dev); + return (-1); + } + i &= ~O_NONBLOCK; + SYSCALL (i = fcntl (fd, F_SETFL, i)); + if (i == -1) + { + SYSCALL (close (fd)); + xfree(dev); + return (-1); + } + xfree(dev); + return (fd); +} + +_X_EXPORT int +xf86SetSerial (int fd, pointer options) +{ + struct termios t; + int val; + const char *s; + int baud, r; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + + SYSCALL (tcgetattr (fd, &t)); + + if ((val = xf86SetIntOption (options, "BaudRate", 0))) + { + if ((baud = GetBaud (val))) + { + cfsetispeed (&t, baud); + cfsetospeed (&t, baud); + } + else + { + xf86Msg (X_ERROR, + "Invalid Option BaudRate value: %d\n", val); + return (-1); + } + } + + if ((val = xf86SetIntOption (options, "StopBits", 0))) + { + switch (val) + { + case 1: + t.c_cflag &= ~(CSTOPB); + break; + case 2: + t.c_cflag |= CSTOPB; + break; + default: + xf86Msg (X_ERROR, + "Invalid Option StopBits value: %d\n", val); + return (-1); + break; + } + } + + if ((val = xf86SetIntOption (options, "DataBits", 0))) + { + switch (val) + { + case 5: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS5; + break; + case 6: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS6; + break; + case 7: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS7; + break; + case 8: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS8; + break; + default: + xf86Msg (X_ERROR, + "Invalid Option DataBits value: %d\n", val); + return (-1); + break; + } + } + + if ((s = xf86SetStrOption (options, "Parity", NULL))) + { + if (xf86NameCmp (s, "Odd") == 0) + { + t.c_cflag |= PARENB | PARODD; + } + else if (xf86NameCmp (s, "Even") == 0) + { + t.c_cflag |= PARENB; + t.c_cflag &= ~(PARODD); + } + else if (xf86NameCmp (s, "None") == 0) + { + t.c_cflag &= ~(PARENB); + } + else + { + xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n", + s); + return (-1); + } + } + + if ((val = xf86SetIntOption (options, "Vmin", -1)) != -1) + { + t.c_cc[VMIN] = val; + } + if ((val = xf86SetIntOption (options, "Vtime", -1)) != -1) + { + t.c_cc[VTIME] = val; + } + + if ((s = xf86SetStrOption (options, "FlowControl", NULL))) + { + xf86MarkOptionUsedByName (options, "FlowControl"); + if (xf86NameCmp (s, "Xoff") == 0) + { + t.c_iflag |= IXOFF; + } + else if (xf86NameCmp (s, "Xon") == 0) + { + t.c_iflag |= IXON; + } + else if (xf86NameCmp (s, "XonXoff") == 0) + { + t.c_iflag |= IXON|IXOFF; + } + else if (xf86NameCmp (s, "None") == 0) + { + t.c_iflag &= ~(IXON | IXOFF); + } + else + { + xf86Msg (X_ERROR, + "Invalid Option FlowControl value: %s\n", s); + return (-1); + } + } + + if ((xf86SetBoolOption (options, "ClearDTR", FALSE))) + { +#ifdef CLEARDTR_SUPPORT +# if !defined(Lynx) || defined(TIOCMBIC) + val = TIOCM_DTR; + SYSCALL (ioctl(fd, TIOCMBIC, &val)); +# else + SYSCALL (ioctl(fd, TIOCCDTR, NULL)); +# endif +#else + xf86Msg (X_WARNING, + "Option ClearDTR not supported on this OS\n"); + return (-1); +#endif + xf86MarkOptionUsedByName (options, "ClearDTR"); + } + + if ((xf86SetBoolOption (options, "ClearRTS", FALSE))) + { +#ifdef CLEARRTS_SUPPORT + val = TIOCM_RTS; + SYSCALL (ioctl(fd, TIOCMBIC, &val)); +#else + xf86Msg (X_WARNING, + "Option ClearRTS not supported on this OS\n"); + return (-1); +#endif + xf86MarkOptionUsedByName (options, "ClearRTS"); + } + + SYSCALL (r = tcsetattr (fd, TCSANOW, &t)); + return (r); +} + +_X_EXPORT int +xf86SetSerialSpeed (int fd, int speed) +{ + struct termios t; + int baud, r; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + + SYSCALL (tcgetattr (fd, &t)); + + if ((baud = GetBaud (speed))) + { + cfsetispeed (&t, baud); + cfsetospeed (&t, baud); + } + else + { + xf86Msg (X_ERROR, + "Invalid Option BaudRate value: %d\n", speed); + return (-1); + } + + SYSCALL (r = tcsetattr (fd, TCSANOW, &t)); + return (r); +} + +_X_EXPORT int +xf86ReadSerial (int fd, void *buf, int count) +{ + int r; +#ifdef DEBUG + int i; +#endif + SYSCALL (r = read (fd, buf, count)); +#ifdef DEBUG + ErrorF("ReadingSerial: 0x%x", + (unsigned char)*(((unsigned char *)buf))); + for (i = 1; i < r; i++) + ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i)); + ErrorF("\n"); +#endif + return (r); +} + +_X_EXPORT int +xf86WriteSerial (int fd, const void *buf, int count) +{ + int r; +#ifdef DEBUG + int i; + + ErrorF("WritingSerial: 0x%x",(unsigned char)*(((unsigned char *)buf))); + for (i = 1; i < count; i++) + ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i)); + ErrorF("\n"); +#endif + SYSCALL (r = write (fd, buf, count)); + return (r); +} + +_X_EXPORT int +xf86CloseSerial (int fd) +{ + int r; + + SYSCALL (r = close (fd)); + return (r); +} + +_X_EXPORT int +xf86WaitForInput (int fd, int timeout) +{ + fd_set readfds; + struct timeval to; + int r; + + FD_ZERO(&readfds); + + if (fd >= 0) { + FD_SET(fd, &readfds); + } + + to.tv_sec = timeout / 1000000; + to.tv_usec = timeout % 1000000; + + if (fd >= 0) { + SYSCALL (r = select (FD_SETSIZE, &readfds, NULL, NULL, &to)); + } + else { + SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to)); + } + xf86ErrorFVerb (9,"select returned %d\n", r); + return (r); +} + +_X_EXPORT int +xf86SerialSendBreak (int fd, int duration) +{ + int r; + + SYSCALL (r = tcsendbreak (fd, duration)); + return (r); + +} + +_X_EXPORT int +xf86FlushInput(int fd) +{ + fd_set fds; + struct timeval timeout; + char c[4]; + +#ifdef DEBUG + ErrorF("FlushingSerial\n"); +#endif + if (tcflush(fd, TCIFLUSH) == 0) + return 0; + + timeout.tv_sec = 0; + timeout.tv_usec = 0; + FD_ZERO(&fds); + FD_SET(fd, &fds); + while (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) { + if (read(fd, &c, sizeof(c)) < 1) + return 0; + FD_ZERO(&fds); + FD_SET(fd, &fds); + } + return 0; +} + +static struct states { + int xf; + int os; +} modemStates[] = { +#ifdef TIOCM_LE + { XF86_M_LE, TIOCM_LE }, +#endif +#ifdef TIOCM_DTR + { XF86_M_DTR, TIOCM_DTR }, +#endif +#ifdef TIOCM_RTS + { XF86_M_RTS, TIOCM_RTS }, +#endif +#ifdef TIOCM_ST + { XF86_M_ST, TIOCM_ST }, +#endif +#ifdef TIOCM_SR + { XF86_M_SR, TIOCM_SR }, +#endif +#ifdef TIOCM_CTS + { XF86_M_CTS, TIOCM_CTS }, +#endif +#ifdef TIOCM_CAR + { XF86_M_CAR, TIOCM_CAR }, +#elif defined(TIOCM_CD) + { XF86_M_CAR, TIOCM_CD }, +#endif +#ifdef TIOCM_RNG + { XF86_M_RNG, TIOCM_RNG }, +#elif defined(TIOCM_RI) + { XF86_M_CAR, TIOCM_RI }, +#endif +#ifdef TIOCM_DSR + { XF86_M_DSR, TIOCM_DSR }, +#endif +}; + +static int numStates = sizeof(modemStates) / sizeof(modemStates[0]); + +static int +xf2osState(int state) +{ + int i; + int ret = 0; + + for (i = 0; i < numStates; i++) + if (state & modemStates[i].xf) + ret |= modemStates[i].os; + return ret; +} + +static int +os2xfState(int state) +{ + int i; + int ret = 0; + + for (i = 0; i < numStates; i++) + if (state & modemStates[i].os) + ret |= modemStates[i].xf; + return ret; +} + +static int +getOsStateMask(void) +{ + int i; + int ret = 0; + for (i = 0; i < numStates; i++) + ret |= modemStates[i].os; + return ret; +} + +static int osStateMask = 0; + +_X_EXPORT int +xf86SetSerialModemState(int fd, int state) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + if (!osStateMask) + osStateMask = getOsStateMask(); + + state = xf2osState(state); + SYSCALL((ret = ioctl(fd, TIOCMGET, &s))); + if (ret < 0) + return -1; + s &= ~osStateMask; + s |= state; + SYSCALL((ret = ioctl(fd, TIOCMSET, &s))); + if (ret < 0) + return -1; + else + return 0; +#endif +} + +_X_EXPORT int +xf86GetSerialModemState(int fd) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + SYSCALL((ret = ioctl(fd, TIOCMGET, &s))); + if (ret < 0) + return -1; + return os2xfState(s); +#endif +} + +_X_EXPORT int +xf86SerialModemSetBits(int fd, int bits) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + s = xf2osState(bits); + SYSCALL((ret = ioctl(fd, TIOCMBIS, &s))); + return ret; +#endif +} + +_X_EXPORT int +xf86SerialModemClearBits(int fd, int bits) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + s = xf2osState(bits); + SYSCALL((ret = ioctl(fd, TIOCMBIC, &s))); + return ret; +#endif +} diff --git a/xorg-server/hw/xfree86/os-support/shared/sigio.c b/xorg-server/hw/xfree86/os-support/shared/sigio.c new file mode 100644 index 000000000..f51131c6b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/sigio.c @@ -0,0 +1,282 @@ + +/* sigio.c -- Support for SIGIO handler installation and removal + * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + */ +/* + * Copyright (c) 2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +# include <X11/X.h> +# include "xf86.h" +# include "xf86Priv.h" +# include "xf86_OSlib.h" +# include "inputstr.h" + +/* + * Linux libc5 defines FASYNC, but not O_ASYNC. Don't know if it is + * functional or not. + */ +#if defined(FASYNC) && !defined(O_ASYNC) +# define O_ASYNC FASYNC +#endif + +#ifdef MAX_DEVICES +/* MAX_DEVICES represents the maximimum number of input devices usable + * at the same time plus one entry for DRM support. + */ +# define MAX_FUNCS (MAX_DEVICES + 1) +#else +# define MAX_FUNCS 16 +#endif + +typedef struct _xf86SigIOFunc { + void (*f) (int, void *); + int fd; + void *closure; +} Xf86SigIOFunc; + +static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS]; +static int xf86SigIOMax; +static int xf86SigIOMaxFd; +static fd_set xf86SigIOMask; + +/* + * SIGIO gives no way of discovering which fd signalled, select + * to discover + */ +static void +xf86SIGIO (int sig) +{ + int i; + fd_set ready; + struct timeval to; + int save_errno = errno; /* do not clobber the global errno */ + int r; + + ready = xf86SigIOMask; + to.tv_sec = 0; + to.tv_usec = 0; + SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to)); + for (i = 0; r > 0 && i < xf86SigIOMax; i++) + if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready)) + { + (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd, + xf86SigIOFuncs[i].closure); + r--; + } + if (r > 0) { + xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r); + } + /* restore global errno */ + errno = save_errno; +} + +static int +xf86IsPipe (int fd) +{ + struct stat buf; + + if (fstat (fd, &buf) < 0) + return 0; + return S_ISFIFO(buf.st_mode); +} + +_X_EXPORT int +xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure) +{ + struct sigaction sa; + struct sigaction osa; + int i; + int blocked; + + for (i = 0; i < MAX_FUNCS; i++) + { + if (!xf86SigIOFuncs[i].f) + { + if (xf86IsPipe (fd)) + return 0; + blocked = xf86BlockSIGIO(); + if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) { + xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n", + fd, strerror(errno)); + xf86UnblockSIGIO(blocked); + return 0; + } + if (fcntl(fd, F_SETOWN, getpid()) == -1) { + xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n", + fd, strerror(errno)); + xf86UnblockSIGIO(blocked); + return 0; + } + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGIO); + sa.sa_flags = 0; + sa.sa_handler = xf86SIGIO; + sigaction(SIGIO, &sa, &osa); + xf86SigIOFuncs[i].fd = fd; + xf86SigIOFuncs[i].closure = closure; + xf86SigIOFuncs[i].f = f; + if (i >= xf86SigIOMax) + xf86SigIOMax = i+1; + if (fd >= xf86SigIOMaxFd) + xf86SigIOMaxFd = fd + 1; + FD_SET (fd, &xf86SigIOMask); + xf86UnblockSIGIO(blocked); + return 1; + } + /* Allow overwriting of the closure and callback */ + else if (xf86SigIOFuncs[i].fd == fd) + { + xf86SigIOFuncs[i].closure = closure; + xf86SigIOFuncs[i].f = f; + return 1; + } + } + return 0; +} + +_X_EXPORT int +xf86RemoveSIGIOHandler(int fd) +{ + struct sigaction sa; + struct sigaction osa; + int i; + int max; + int maxfd; + int ret; + + max = 0; + maxfd = -1; + ret = 0; + for (i = 0; i < MAX_FUNCS; i++) + { + if (xf86SigIOFuncs[i].f) + { + if (xf86SigIOFuncs[i].fd == fd) + { + xf86SigIOFuncs[i].f = 0; + xf86SigIOFuncs[i].fd = 0; + xf86SigIOFuncs[i].closure = 0; + FD_CLR (fd, &xf86SigIOMask); + ret = 1; + } + else + { + max = i + 1; + if (xf86SigIOFuncs[i].fd >= maxfd) + maxfd = xf86SigIOFuncs[i].fd + 1; + } + } + } + if (ret) + { + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC); + xf86SigIOMax = max; + xf86SigIOMaxFd = maxfd; + if (!max) + { + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGIO); + sa.sa_flags = 0; + sa.sa_handler = SIG_DFL; + sigaction(SIGIO, &sa, &osa); + } + } + return ret; +} + +_X_EXPORT int +xf86BlockSIGIO (void) +{ + sigset_t set, old; + int ret; + + sigemptyset (&set); + sigaddset (&set, SIGIO); + sigprocmask (SIG_BLOCK, &set, &old); + ret = sigismember (&old, SIGIO); + return ret; +} + +_X_EXPORT void +xf86UnblockSIGIO (int wasset) +{ + sigset_t set; + + if (!wasset) + { + sigemptyset (&set); + sigaddset (&set, SIGIO); + sigprocmask (SIG_UNBLOCK, &set, NULL); + } +} + +void +xf86AssertBlockedSIGIO (char *where) +{ + sigset_t set, old; + + sigemptyset (&set); + sigprocmask (SIG_BLOCK, &set, &old); + if (!sigismember (&old, SIGIO)) + xf86Msg (X_ERROR, "SIGIO not blocked at %s\n", where); +} + +/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */ + +int +xf86SIGIOSupported (void) +{ + return 1; +} diff --git a/xorg-server/hw/xfree86/os-support/shared/sigiostubs.c b/xorg-server/hw/xfree86/os-support/shared/sigiostubs.c new file mode 100644 index 000000000..7113968c6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/sigiostubs.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +# include <X11/X.h> +# include "xf86.h" +# include "xf86Priv.h" +# include "xf86_OSlib.h" + +_X_EXPORT int +xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure) +{ + return 0; +} + +_X_EXPORT int +xf86RemoveSIGIOHandler(int fd) +{ + return 0; +} + +_X_EXPORT int +xf86BlockSIGIO (void) +{ + return 0; +} + +_X_EXPORT void +xf86UnblockSIGIO (int wasset) +{ +} + +void +xf86AssertBlockedSIGIO (char *where) +{ +} + +/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */ +Bool +xf86SIGIOSupported () +{ + return FALSE; +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/stdResource.c b/xorg-server/hw/xfree86/os-support/shared/stdResource.c new file mode 100644 index 000000000..c144211f0 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/stdResource.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Standard resource information code */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Privstr.h" +#include "xf86Pci.h" +#define NEED_OS_RAC_PROTOS +#include "xf86_OSlib.h" +#include "xf86Resources.h" + +/* Avoid Imakefile changes */ +#include "bus/Pci.h" + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__) || defined(__sun) +#define xf86StdAccResFromOS xf86AccResFromOS +#endif + +resPtr +xf86StdAccResFromOS(resPtr ret) +{ + resRange range; + + /* + * Fallback is to claim the following areas: + * + * 0x00000000 - 0x0009ffff low 640k host memory + * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS + * 0x000f0000 - 0x000fffff system BIOS + * 0x00100000 - 0x3fffffff low 1G - 1MB host memory + * 0xfec00000 - 0xfecfffff default I/O APIC config space + * 0xfee00000 - 0xfeefffff default Local APIC config space + * 0xffe00000 - 0xffffffff high BIOS area (should this be included?) + * + * reference: Intel 440BX AGP specs + * + * The two APIC spaces appear to be BX-specific and should be dealt with + * elsewhere. + */ + + /* Fallback is to claim 0x0 - 0x9ffff and 0x100000 - 0x7fffffff */ + RANGE(range, 0x00000000, 0x0009ffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x000f0000, 0x000fffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x00100000, 0x3fffffff, + ResExcMemBlock | ResBios | ResEstimated); + ret = xf86AddResToList(ret, &range, -1); +#if 0 + RANGE(range, 0xfec00000, 0xfecfffff, ResExcMemBlock | ResBios); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xfee00000, 0xfeefffff, ResExcMemBlock | ResBios); + ret = xf86AddResToList(ret, &range, -1); + /* airlied - remove BIOS range it shouldn't be here + this should use E820 - or THE OS */ + RANGE(range, 0xffe00000, 0xffffffff, ResExcMemBlock | ResBios); + ret = xf86AddResToList(ret, &range, -1); +#endif + /* + * Fallback would be to claim well known ports in the 0x0 - 0x3ff range + * along with their sparse I/O aliases, but that's too imprecise. Instead + * claim a bare minimum here. + */ + RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ + ret = xf86AddResToList(ret, &range, -1); + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ +/* RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); */ + RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* XXX add others */ + return ret; +} diff --git a/xorg-server/hw/xfree86/os-support/shared/vidmem.c b/xorg-server/hw/xfree86/os-support/shared/vidmem.c new file mode 100644 index 000000000..0b4411604 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/vidmem.c @@ -0,0 +1,296 @@ +/* + * Copyright (c) 1993-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +/* + * This file contains the common part of the video memory mapping functions + */ + +/* + * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold + * the MTRR option information, but it is likely to be expanded if we do + * auto unmapping of memory at VT switch. + * + */ + +typedef struct { + unsigned long physBase; + unsigned long size; + pointer virtBase; + pointer mtrrInfo; + int flags; +} MappingRec, *MappingPtr; + +typedef struct { + int numMappings; + MappingPtr * mappings; + Bool mtrrEnabled; + MessageType mtrrFrom; + Bool mtrrOptChecked; + ScrnInfoPtr pScrn; +} VidMapRec, *VidMapPtr; + +static int vidMapIndex = -1; + +#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr)) + +static VidMemInfo vidMemInfo = {FALSE, }; +static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL}; + +static VidMapPtr +getVidMapRec(int scrnIndex) +{ + VidMapPtr vp; + ScrnInfoPtr pScrn; + + if ((scrnIndex < 0) || + !(pScrn = xf86Screens[scrnIndex])) + return &vidMapRec; + + if (vidMapIndex < 0) + vidMapIndex = xf86AllocateScrnInfoPrivateIndex(); + + if (VIDMAPPTR(pScrn) != NULL) + return VIDMAPPTR(pScrn); + + vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1); + vp->mtrrEnabled = TRUE; /* default to enabled */ + vp->mtrrFrom = X_DEFAULT; + vp->mtrrOptChecked = FALSE; + vp->pScrn = pScrn; + return vp; +} + +static MappingPtr +newMapping(VidMapPtr vp) +{ + vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) * + (vp->numMappings + 1)); + vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1); + return vp->mappings[vp->numMappings++]; +} + +static MappingPtr +findMapping(VidMapPtr vp, pointer vbase, unsigned long size) +{ + int i; + + for (i = 0; i < vp->numMappings; i++) { + if (vp->mappings[i]->virtBase == vbase && + vp->mappings[i]->size == size) + return vp->mappings[i]; + } + return NULL; +} + +static void +removeMapping(VidMapPtr vp, MappingPtr mp) +{ + int i, found = 0; + + for (i = 0; i < vp->numMappings; i++) { + if (vp->mappings[i] == mp) { + found = 1; + xfree(vp->mappings[i]); + } else if (found) { + vp->mappings[i - 1] = vp->mappings[i]; + } + } + vp->numMappings--; + vp->mappings[vp->numMappings] = NULL; +} + +enum { OPTION_MTRR }; +static const OptionInfoRec opts[] = +{ + { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +static void +checkMtrrOption(VidMapPtr vp) +{ + if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) { + OptionInfoPtr options; + + options = xnfalloc(sizeof(opts)); + (void)memcpy(options, opts, sizeof(opts)); + xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, + options); + if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled)) + vp->mtrrFrom = X_CONFIG; + xfree(options); + vp->mtrrOptChecked = TRUE; + } +} + +void +xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase) +{ + VidMapPtr vp; + MappingPtr mp; + + vp = getVidMapRec(ScreenNum); + mp = newMapping(vp); + mp->physBase = Base; + mp->size = Size; + mp->virtBase = Vbase; + mp->flags = Flags; +} + +void +xf86InitVidMem(void) +{ + if (!vidMemInfo.initialised) { + memset(&vidMemInfo, 0, sizeof(VidMemInfo)); + xf86OSInitVidMem(&vidMemInfo); + } +} + +_X_EXPORT pointer +xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) +{ + pointer vbase = NULL; + VidMapPtr vp; + MappingPtr mp; + + if (((Flags & VIDMEM_FRAMEBUFFER) && + (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)))) + FatalError("Mapping memory with more than one type\n"); + + xf86InitVidMem(); + if (!vidMemInfo.initialised || !vidMemInfo.mapMem) + return NULL; + + vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags); + + if (!vbase || vbase == (pointer)-1) + return NULL; + + vp = getVidMapRec(ScreenNum); + mp = newMapping(vp); + mp->physBase = Base; + mp->size = Size; + mp->virtBase = vbase; + mp->flags = Flags; + + /* + * Check the "mtrr" option even when MTRR isn't supported to avoid + * warnings about unrecognised options. + */ + checkMtrrOption(vp); + + if (vp->mtrrEnabled && vidMemInfo.setWC) { + if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)) + mp->mtrrInfo = + vidMemInfo.setWC(ScreenNum, Base, Size, FALSE, + vp->mtrrFrom); + else if (Flags & VIDMEM_FRAMEBUFFER) + mp->mtrrInfo = + vidMemInfo.setWC(ScreenNum, Base, Size, TRUE, + vp->mtrrFrom); + } + return vbase; +} + +_X_EXPORT void +xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + VidMapPtr vp; + MappingPtr mp; + + if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) { + xf86DrvMsg(ScreenNum, X_WARNING, + "xf86UnMapVidMem() called before xf86MapVidMem()\n"); + return; + } + + vp = getVidMapRec(ScreenNum); + mp = findMapping(vp, Base, Size); + if (!mp) { + xf86DrvMsg(ScreenNum, X_WARNING, + "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n", + Base, Size); + return; + } + if (vp->mtrrEnabled && vidMemInfo.undoWC && mp) + vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo); + + vidMemInfo.unmapMem(ScreenNum, Base, Size); + removeMapping(vp, mp); +} + +_X_EXPORT Bool +xf86CheckMTRR(int ScreenNum) +{ + VidMapPtr vp = getVidMapRec(ScreenNum); + + /* + * Check the "mtrr" option even when MTRR isn't supported to avoid + * warnings about unrecognised options. + */ + checkMtrrOption(vp); + + if (vp->mtrrEnabled && vidMemInfo.setWC) + return TRUE; + + return FALSE; +} + +_X_EXPORT Bool +xf86LinearVidMem() +{ + xf86InitVidMem(); + return vidMemInfo.linearSupported; +} + +_X_EXPORT void +xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base, + unsigned long Size) +{ + if (!(Flags & VIDMEM_READSIDEEFFECT)) + return; + + if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects) + return; + + vidMemInfo.readSideEffects(ScreenNum, base, Size); +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c new file mode 100644 index 000000000..e6511dd43 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Axp.h" + +axpParams xf86AXPParams[] = { + {SYS_NONE, 0, 0, 0}, + {TSUNAMI, 0, 0, 0}, + {LCA, 1<<24,0xf8000000, 1UL << 32}, + {APECS, 1<<24,0xf8000000, 1UL << 32}, + {T2, 0,0xFC000000, 1UL << 31}, + {T2_GAMMA, 0,0xFC000000, 1UL << 31}, + {CIA, 0,0xE0000000, 1UL << 34}, + {MCPCIA, 0,0xf8000000, 1UL << 31}, + {JENSEN, 0, 0xE000000, 1UL << 32}, + {POLARIS, 0, 0, 0}, + {PYXIS, 0, 0, 0}, + {PYXIS_CIA, 0,0xE0000000, 1UL << 34}, + {IRONGATE, 0, 0, 0} +}; + diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h new file mode 100644 index 000000000..5e9d6284c --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h @@ -0,0 +1,34 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _XF86_AXP_H_ +#define _XF86_AXP_H_ + +typedef enum { + SYS_NONE, + TSUNAMI, + LCA, + APECS, + T2, + T2_GAMMA, + CIA, + MCPCIA, + JENSEN, + POLARIS, + PYXIS, + PYXIS_CIA, + IRONGATE +} axpDevice; + +typedef struct { + axpDevice id; + unsigned long hae_thresh; + unsigned long hae_mask; + unsigned long size; +} axpParams; + +extern axpParams xf86AXPParams[]; + +#endif + diff --git a/xorg-server/hw/xfree86/os-support/solaris/Makefile.am b/xorg-server/hw/xfree86/os-support/solaris/Makefile.am new file mode 100644 index 000000000..68f6b4cd0 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/Makefile.am @@ -0,0 +1,37 @@ +if SOLARIS_USL_CONSOLE +VTSW_SRC = $(srcdir)/../shared/VTsw_usl.c +else +VTSW_SRC = $(srcdir)/../shared/VTsw_noop.c +endif + +# TODO: Don't build agpgart on SPARC +#if defined(i386Architecture) || defined(AMD64Architecture) +AGP_SRC = sun_agp.c +#else +#AGP_SRC = $(srcdir)/../shared/agp_noop.c +#endif + +SOLARIS_INOUT_SRC = solaris-@SOLARIS_INOUT_ARCH@.S +DISTCLEANFILES = solaris-@SOLARIS_INOUT_ARCH@.il + +solaris-@SOLARIS_INOUT_ARCH@.il: solaris-@SOLARIS_INOUT_ARCH@.S + $(CPP) -P -DINLINE_ASM solaris-@SOLARIS_INOUT_ARCH@.S > $@ + +noinst_LTLIBRARIES = libsolaris.la +libsolaris_la_SOURCES = sun_bios.c sun_init.c \ + sun_mouse.c sun_vid.c sun_bell.c $(AGP_SRC) sun_apm.c \ + $(srcdir)/../shared/kmod_noop.c \ + $(srcdir)/../shared/posix_tty.c $(srcdir)/../shared/sigiostubs.c \ + $(srcdir)/../shared/stdResource.c \ + $(VTSW_SRC) +nodist_libsolaris_la_SOURCES = $(SOLARIS_INOUT_SRC) + +sdk_HEADERS = agpgart.h +nodist_sdk_HEADERS = solaris-@SOLARIS_INOUT_ARCH@.il + +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) + +INCLUDES = $(XORG_INCS) + +EXTRA_DIST = solaris-amd64.S solaris-ia32.S solaris-sparcv8plus.S \ + apSolaris.shar sun_inout.s diff --git a/xorg-server/hw/xfree86/os-support/solaris/Makefile.in b/xorg-server/hw/xfree86/os-support/solaris/Makefile.in new file mode 100644 index 000000000..cf4e440c8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/Makefile.in @@ -0,0 +1,818 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/solaris +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libsolaris_la_LIBADD = +am__libsolaris_la_SOURCES_DIST = sun_bios.c sun_init.c sun_mouse.c \ + sun_vid.c sun_bell.c sun_agp.c sun_apm.c \ + $(srcdir)/../shared/kmod_noop.c \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigiostubs.c \ + $(srcdir)/../shared/stdResource.c \ + $(srcdir)/../shared/VTsw_noop.c $(srcdir)/../shared/VTsw_usl.c +am__objects_1 = sun_agp.lo +@SOLARIS_USL_CONSOLE_FALSE@am__objects_2 = VTsw_noop.lo +@SOLARIS_USL_CONSOLE_TRUE@am__objects_2 = VTsw_usl.lo +am_libsolaris_la_OBJECTS = sun_bios.lo sun_init.lo sun_mouse.lo \ + sun_vid.lo sun_bell.lo $(am__objects_1) sun_apm.lo \ + kmod_noop.lo posix_tty.lo sigiostubs.lo stdResource.lo \ + $(am__objects_2) +am__objects_3 = solaris-@SOLARIS_INOUT_ARCH@.lo +nodist_libsolaris_la_OBJECTS = $(am__objects_3) +libsolaris_la_OBJECTS = $(am_libsolaris_la_OBJECTS) \ + $(nodist_libsolaris_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) +LTCPPASCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libsolaris_la_SOURCES) $(nodist_libsolaris_la_SOURCES) +DIST_SOURCES = $(am__libsolaris_la_SOURCES_DIST) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" "$(DESTDIR)$(sdkdir)" +nodist_sdkHEADERS_INSTALL = $(INSTALL_HEADER) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(nodist_sdk_HEADERS) $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +@SOLARIS_USL_CONSOLE_FALSE@VTSW_SRC = $(srcdir)/../shared/VTsw_noop.c +@SOLARIS_USL_CONSOLE_TRUE@VTSW_SRC = $(srcdir)/../shared/VTsw_usl.c + +# TODO: Don't build agpgart on SPARC +#if defined(i386Architecture) || defined(AMD64Architecture) +AGP_SRC = sun_agp.c +#else +#AGP_SRC = $(srcdir)/../shared/agp_noop.c +#endif +SOLARIS_INOUT_SRC = solaris-@SOLARIS_INOUT_ARCH@.S +DISTCLEANFILES = solaris-@SOLARIS_INOUT_ARCH@.il +noinst_LTLIBRARIES = libsolaris.la +libsolaris_la_SOURCES = sun_bios.c sun_init.c \ + sun_mouse.c sun_vid.c sun_bell.c $(AGP_SRC) sun_apm.c \ + $(srcdir)/../shared/kmod_noop.c \ + $(srcdir)/../shared/posix_tty.c $(srcdir)/../shared/sigiostubs.c \ + $(srcdir)/../shared/stdResource.c \ + $(VTSW_SRC) + +nodist_libsolaris_la_SOURCES = $(SOLARIS_INOUT_SRC) +sdk_HEADERS = agpgart.h +nodist_sdk_HEADERS = solaris-@SOLARIS_INOUT_ARCH@.il +AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) +INCLUDES = $(XORG_INCS) +EXTRA_DIST = solaris-amd64.S solaris-ia32.S solaris-sparcv8plus.S \ + apSolaris.shar sun_inout.s + +all: all-am + +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/solaris/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/solaris/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libsolaris.la: $(libsolaris_la_OBJECTS) $(libsolaris_la_DEPENDENCIES) + $(LINK) $(libsolaris_la_OBJECTS) $(libsolaris_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VTsw_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VTsw_usl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kmod_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix_tty.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigiostubs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/solaris-@SOLARIS_INOUT_ARCH@.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdResource.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_agp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_apm.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_bell.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_bios.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_init.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_mouse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sun_vid.Plo@am__quote@ + +.S.o: +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCCAS_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(CPPASCOMPILE) -c -o $@ $< + +.S.obj: +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCCAS_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.S.lo: +@am__fastdepCCAS_TRUE@ $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCCAS_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(LTCPPASCOMPILE) -c -o $@ $< + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +kmod_noop.lo: $(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kmod_noop.lo -MD -MP -MF $(DEPDIR)/kmod_noop.Tpo -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kmod_noop.Tpo $(DEPDIR)/kmod_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/kmod_noop.c' object='kmod_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c + +posix_tty.lo: $(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT posix_tty.lo -MD -MP -MF $(DEPDIR)/posix_tty.Tpo -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/posix_tty.Tpo $(DEPDIR)/posix_tty.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/posix_tty.c' object='posix_tty.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c + +sigiostubs.lo: $(srcdir)/../shared/sigiostubs.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sigiostubs.lo -MD -MP -MF $(DEPDIR)/sigiostubs.Tpo -c -o sigiostubs.lo `test -f '$(srcdir)/../shared/sigiostubs.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigiostubs.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sigiostubs.Tpo $(DEPDIR)/sigiostubs.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/sigiostubs.c' object='sigiostubs.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sigiostubs.lo `test -f '$(srcdir)/../shared/sigiostubs.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigiostubs.c + +stdResource.lo: $(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdResource.lo -MD -MP -MF $(DEPDIR)/stdResource.Tpo -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/stdResource.Tpo $(DEPDIR)/stdResource.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/stdResource.c' object='stdResource.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c + +VTsw_noop.lo: $(srcdir)/../shared/VTsw_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT VTsw_noop.lo -MD -MP -MF $(DEPDIR)/VTsw_noop.Tpo -c -o VTsw_noop.lo `test -f '$(srcdir)/../shared/VTsw_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/VTsw_noop.Tpo $(DEPDIR)/VTsw_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/VTsw_noop.c' object='VTsw_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o VTsw_noop.lo `test -f '$(srcdir)/../shared/VTsw_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_noop.c + +VTsw_usl.lo: $(srcdir)/../shared/VTsw_usl.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT VTsw_usl.lo -MD -MP -MF $(DEPDIR)/VTsw_usl.Tpo -c -o VTsw_usl.lo `test -f '$(srcdir)/../shared/VTsw_usl.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_usl.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/VTsw_usl.Tpo $(DEPDIR)/VTsw_usl.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/VTsw_usl.c' object='VTsw_usl.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o VTsw_usl.lo `test -f '$(srcdir)/../shared/VTsw_usl.c' || echo '$(srcdir)/'`$(srcdir)/../shared/VTsw_usl.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-nodist_sdkHEADERS: $(nodist_sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(nodist_sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(nodist_sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(nodist_sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-nodist_sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(sdkdir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-nodist_sdkHEADERS install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-nodist_sdkHEADERS uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-nodist_sdkHEADERS install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-nodist_sdkHEADERS \ + uninstall-sdkHEADERS + + +solaris-@SOLARIS_INOUT_ARCH@.il: solaris-@SOLARIS_INOUT_ARCH@.S + $(CPP) -P -DINLINE_ASM solaris-@SOLARIS_INOUT_ARCH@.S > $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/solaris/agpgart.h b/xorg-server/hw/xfree86/os-support/solaris/agpgart.h new file mode 100644 index 000000000..566de8046 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/agpgart.h @@ -0,0 +1,108 @@ +/* + * AGPGART module version 0.99 + * Copyright (C) 1999 Jeff Hartmann + * Copyright (C) 1999 Precision Insight, Inc. + * Copyright (C) 1999 Xi Graphics, 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 + * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS 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. + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, 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. + */ + +#ifndef _AGPGART_H +#define _AGPGART_H + +#pragma ident "@(#)agpgart.h 1.1 05/04/04 SMI" + +typedef struct _agp_version { + uint16_t agpv_major; + uint16_t agpv_minor; +} agp_version_t; + +typedef struct _agp_info { + agp_version_t agpi_version; + uint32_t agpi_devid; /* bridge vendor + device */ + uint32_t agpi_mode; /* mode of bridge */ + ulong_t agpi_aperbase; /* base of aperture */ + size_t agpi_apersize; /* aperture range size */ + uint32_t agpi_pgtotal; /* max number of pages in aperture */ + uint32_t agpi_pgsystem; /* same as pg_total */ + uint32_t agpi_pgused; /* NUMBER of currently used pages */ +} agp_info_t; + +typedef struct _agp_setup { + uint32_t agps_mode; +} agp_setup_t; + +typedef struct _agp_allocate { + int32_t agpa_key; + uint32_t agpa_pgcount; + uint32_t agpa_type; + uint32_t agpa_physical; /* for i810/830 driver */ +} agp_allocate_t; + +typedef struct _agp_bind { + int32_t agpb_key; + uint32_t agpb_pgstart; +} agp_bind_t; + +typedef struct _agp_unbind { + int32_t agpu_key; + uint32_t agpu_pri; /* no use in solaris */ +} agp_unbind_t; + +#define AGPIOC_BASE 'G' +#define AGPIOC_INFO _IOR(AGPIOC_BASE, 0, 100) +#define AGPIOC_ACQUIRE _IO(AGPIOC_BASE, 1) +#define AGPIOC_RELEASE _IO(AGPIOC_BASE, 2) +#define AGPIOC_SETUP _IOW(AGPIOC_BASE, 3, agp_setup_t) +#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 4, agp_allocate_t) +#define AGPIOC_DEALLOCATE _IOW(AGPIOC_BASE, 5, int) +#define AGPIOC_BIND _IOW(AGPIOC_BASE, 6, agp_bind_t) +#define AGPIOC_UNBIND _IOW(AGPIOC_BASE, 7, agp_unbind_t) + +#define AGP_DEVICE "/dev/agpgart" + +#endif /* _AGPGART_H */ diff --git a/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar b/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar new file mode 100644 index 000000000..a3548f7b4 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar @@ -0,0 +1,806 @@ +#!/bin/sh +# +# This is a shell archive. Save it in a file, remove anything before +# this line, and then unpack it by entering "sh file". Note, it may +# create directories; files and directories will be owned by you and +# have default permissions. +# Made on Sun Jun 25 20:24:59 CEST 2006 by Martin Bochnig at martux.org +# +# This archive contains: +# +# ./aperture +# +# ./aperture/Makefile +# ./aperture/Makefile.amd64 +# ./aperture/Makefile.sparcv9 +# ./aperture/README +# ./aperture/aperture.c +# ./aperture/aperture.conf +# ./aperture/devlink.tab +# +echo c - ./aperture +mkdir -p ./aperture > /dev/null 2>&1 +# +echo x - ./aperture/Makefile +sed 's/^X//' >./aperture/Makefile << 'END-of-./aperture/Makefile' +X# +X# File: makefile for aperture Framebuffer Driver +X# Author: Doug Anson (danson@lgc.com) +X# Date: 2/15/94 +X# Modified: David Holland (davidh@use.com) +X# Date: 2/23/94 +X# - Changed name, and debugging structure +X# Modified: Marc Aurele La France (tsi@xfree86.org) +X# Date: 2001.06.08 +X# - SPARC support, cleanup and turf aptest. +X# +X# >>NOTE<< Have a look at Makefile.sparcv9 for specifics. +X# +X# Modified: Martin Bochnig (martin@martux.org) +X# Date: 2006.06.24 +X# - Slightly modified to also build on Solaris 10 and 11. +X# - amd64 64 bit kernel support +X# - cosmetical changes to also support sun4v, not only sun4u +X# +X# >>NOTE<< Have a look at Makefile.amd64 for amd64 specifics. +X# +X# GNU gcc compiler +XCC=gcc +XCFLGS=-fno-builtin -Wall -O3 +X +X# +X# SUNWspro compiler +X#CC=/opt/SUNWspro/bin/cc +X#CFLGS=-Xa -xnolib -xO3 +X +X# +X# Debug error reporting +X#DEBUG_FLG= +X#DEBUG_FLG=-DAPERTURE_DEBUG +X +X# +X# Files and object declarations +XKERNEL_FLGS=-D_KERNEL -DSUNDDI +XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) +XCFILES= aperture.c +XOBJS= aperture.o +XDRIVER= aperture +X +X# +X# Make rules +Xall: $(DRIVER) +X +X$(DRIVER): $(OBJS) +X @if [ -f "Makefile.`isainfo -k`" ]; then \ +X make -f Makefile.`isainfo -k` $(DRIVER); \ +X else \ +X rm -f $(DRIVER); \ +X ld -r -o $(DRIVER) $(OBJS); \ +X fi +X +Xinstall: $(DRIVER) +X @if [ -f "Makefile.`isainfo -k`" ]; then \ +X make -f Makefile.`isainfo -k` install; \ +X else \ +X cp aperture.conf /kernel/drv; \ +X cp $(DRIVER) /kernel/drv; \ +X fi +X +Xadd_drv: +X @if [ -f "Makefile.`isainfo -k`" ]; then \ +X make -f Makefile.`isainfo -k` add_drv; \ +X else \ +X add_drv aperture; \ +X fi +X +Xclean: +X rm -f *% *.BAK $(OBJS) $(DRIVER) core +X +X.SUFFIXES: .i +X +X.c.i: +X $(CC) -E $(CFLAGS) $*.c > $@ +X +X.c.o: +X @if [ -f "Makefile.`isainfo -k`" ]; then \ +X make -f Makefile.`isainfo -k` $@; \ +X else \ +X rm -f $@; \ +X $(CC) -c $(CFLAGS) $*.c -o $@; \ +X fi +END-of-./aperture/Makefile +echo x - ./aperture/Makefile.amd64 +sed 's/^X//' >./aperture/Makefile.amd64 << 'END-of-./aperture/Makefile.amd64' +X# +X# File: Makefile for aperture Framebuffer Driver +X# Author: Doug Anson (danson@lgc.com) +X# Date: 2/15/94 +X# Modified: David Holland (davidh@use.com) +X# Date: 2/23/94 +X# - Changed name, and debugging structure +X# Modified: Marc Aurele La France (tsi@xfree86.org) +X# Date: 2001.06.08 +X# - SPARC support, cleanup and turf aptest. +X# Modified: Martin Bochnig (martin@martux.org) +X# - amd64 64 bit kernel support, cosmetics and also +X# supporting sun4v (and arbitrary sparcv9) platforms +X# as well as SunOS 5.10 or higher now +X# - Changed name +X# +X +X# +X# GNU gcc compiler, version 3.2 or later +X# +XCC=gcc +XCFLGS=-fno-builtin -Wall -O3 -m64 -mcmodel=kernel +X +X# +X# SUNWspro compiler (untested, might not properly work for amd64 here) +X#CC=/opt/SUNWspro/bin/cc +X#CFLGS=-Xa -xarch=v9 -xnolib -xO3 +X +X# +X# Debug error reporting +X#DEBUG_FLG= +X#DEBUG_FLG=-DAPERTURE_DEBUG +X +X# +X# Files and object declarations +XKERNEL_FLGS=-D_KERNEL -DSUNDDI +XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) +XCFILES= aperture.c +XOBJS= aperture.o +XDRIVER= aperture +X +X# +X# Make rules +Xall: $(DRIVER) +X +X$(DRIVER): $(OBJS) +X rm -f $(DRIVER) +X ld -r -o $(DRIVER) $(OBJS) +X +Xinstall: $(DRIVER) +X cp aperture.conf /kernel/drv +X cp $(DRIVER) /kernel/drv/amd64 +X +Xadd_drv: +X add_drv aperture +X +Xclean: +X rm -f *% *.BAK $(OBJS) $(DRIVER) core +X +X.SUFFIXES: .i +X +X.c.i: +X $(CC) -E $(CFLAGS) $*.c > $@ +END-of-./aperture/Makefile.amd64 +echo x - ./aperture/Makefile.sparcv9 +sed 's/^X//' >./aperture/Makefile.sparcv9 << 'END-of-./aperture/Makefile.sparcv9' +X# +X# File: makefile for aperture Framebuffer Driver +X# Author: Doug Anson (danson@lgc.com) +X# Date: 2/15/94 +X# Modified: David Holland (davidh@use.com) +X# Date: 2/23/94 +X# - Changed name, and debugging structure +X# Modified: Marc Aurele La France (tsi@xfree86.org) +X# Date: 2001.06.08 +X# - SPARC support, cleanup and turf aptest. +X# Modified: Martin Bochnig (martin@martux.org) +X# Date: 2006.06.24 +X# - Changed name for generic sparcv9 support +X# - updated to better work with Solaris 10 and 11 +X# +X +X# +X# GNU gcc compiler, version 3.2 or later +X# +XCC=gcc +XCFLGS=-fno-builtin -Wall -O3 -m64 +X +X# +X# SUNWspro compiler +X#CC=/opt/SUNWspro/bin/cc +X#CFLGS=-Xa -xarch=v9 -xnolib -xO3 +X +X# +X# Debug error reporting +X#DEBUG_FLG= +X#DEBUG_FLG=-DAPERTURE_DEBUG +X +X# +X# Files and object declarations +XKERNEL_FLGS=-D_KERNEL -DSUNDDI +XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) +XCFILES= aperture.c +XOBJS= aperture.o +XDRIVER= aperture +X +X# +X# Make rules +Xall: $(DRIVER) +X +X$(DRIVER): $(OBJS) +X rm -f $(DRIVER) +X ld -r -o $(DRIVER) $(OBJS) +X +Xinstall: $(DRIVER) +X cp aperture.conf /kernel/drv +X cp $(DRIVER) /kernel/drv/sparcv9 +X +Xadd_drv: +X add_drv aperture +X +Xclean: +X rm -f *% *.BAK $(OBJS) $(DRIVER) core +X +X.SUFFIXES: .i +X +X.c.i: +X $(CC) -E $(CFLAGS) $*.c > $@ +END-of-./aperture/Makefile.sparcv9 +echo x - ./aperture/README +sed 's/^X//' >./aperture/README << 'END-of-./aperture/README' +XFramebuffer aperture driver. +X +XThis driver was written to provide a device that, unlike /dev/mem, allows +Xmmap()'ing of ranges beyond installed memory. +X +XThe original x86-based version of this driver was the collaborative work of +XDoug Anson (danson@lgc.com), and David Holland (davidh@use.com). It has since +Xbeen rewritten to also work on sparc machines and - later on - also on sparcv9 +Xand recently amd64 64 bit kernels. +XIt flawlessly compiles and installs on Solaris 10 and 11 now. +X +X +XInstallation instructions: +X +X1) Check the Makefile, for appropriate CC, and CFLAGS definitions. Compiling +X with APERTURE_DEBUG defined means the driver will generate reams of +X debugging output. You'll probably want to leave this off... +X +X2) Type 'make' (or 'gmake'). Both the driver and test program should compile +X without any problems. No warning messages should be generated. +X +X3) Become 'root'. +X +X4) Type 'make install' and 'make add_drv'. The screen should look something +X like this: +X +X # make install +X cp aperture aperture.conf /kernel/drv +X # make add_drv +X add_drv aperture +X +X On a sparcv9 machine this will mention the /kernel/drv/sparcv9 directory +X instead of /kernel/drv. Similarily /kernel/drv/amd64 should be used on amd64. +X +X This installs the driver to the system. +X +X5) While as root modify the file /etc/devlink.tab, adding these lines: +X +X# The following entry is for the framebuffer driver +Xtype=ddi_pseudo;name=aperture fbs/\M0 +X +X Add that line exactly as shown. You may also simply add the +X contents of the devlink.tab file supplied to /etc/devlink.tab. +X It contains the lines as well. (Yes, that is a tab between +X aperture and fbs, not spaces - very important) +X +X6) Perform a reconfiguration boot of the system. +X +X # touch /reconfigure +X # init 6 +X +XBug reports, questions, suggestions, etc can be sent to xfree86@xfree86.org. +END-of-./aperture/README +echo x - ./aperture/aperture.c +sed 's/^X//' >./aperture/aperture.c << 'END-of-./aperture/aperture.c' +X/* +X * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved. +X * +X * Permission is hereby granted, free of charge, to any person obtaining a copy +X * of this software and associated documentation files (the "Software"), to +X * deal in the Software without restriction, including without limitation the +X * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +X * sell copies of the Software, and to permit persons to whom the Software is +X * furnished to do so, subject to the following conditions: +X * +X * The above copyright notice and this permission notice shall be included in +X * all copies or substantial portions of the Software. +X * +X * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +X * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +X * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +X * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +X * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +X * +X * Except as contained in this notice, the name of the XFree86 Project shall +X * not be used in advertising or otherwise to promote the sale, use or other +X * dealings in this Software without prior written authorization from the +X * XFree86 Project. +X */ +X +X/* +X * Aperture driver for Solaris. +X */ +X +X/* +X * Modified: Martin Bochnig (martin@martux.org) +X * Log: Commented out obsolete kernel interfaces DDI_IDENTIFIED and DDI_NOT_IDENTIFIED +X * not supported by SunOS 5.10 or higher anymore, +X * see http://docs.sun.com/app/docs/doc/819-2255/6n4ibnffr?a=view +X */ +X +X#include <sys/conf.h> +X#include <sys/ddi.h> +X#include <sys/modctl.h> +X#include <sys/open.h> +X#include <sys/stat.h> +X#include <sys/sunddi.h> +X +X#define DEV_IDENT "aperture" +X#define DEV_BANNER "XFree86 aperture driver" +X +X#ifndef D_64BIT +X#define D_64BIT 0 +X#endif +X +X#ifndef NULL +X#define NULL ((void *)0) +X#endif +X +X/* +X * open(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_open +X( +X#ifdef __STDC__ +X dev_t *devp, +X int flag, +X int typ, +X struct cred *cred +X#endif +X) +X#ifndef __STDC__ +X dev_t *devp; +X int flag; +X int typ; +X struct cred *cred; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering open()\n"); +X +X#endif +X +X if ((typ != OTYP_CHR) || (getminor(*devp))) +X error = EINVAL; +X else +X error = 0; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving open() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * mmap(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_mmap +X( +X#ifdef __STDC__ +X dev_t dev, +X off_t off, +X int prot +X#endif +X) +X#ifndef __STDC__ +X dev_t dev; +X off_t off; +X int prot; +X#endif +X{ +X pfn_t pf; +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering mmap(0x%016lx)\n", off); +X +X#endif +X +X pf = btop((unsigned long)off); +X +X /* Deal with mmap(9E) interface limits */ +X error = (int)pf; +X if ((error < 0) || (pf != (pfn_t)error)) +X error = -1; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving mmap() = 0x%08lx", error); +X +X#endif +X +X return error; +X} +X +Xstatic struct cb_ops aperture_cb_ops = +X{ +X aperture_open, /* open */ +X nulldev, /* close */ +X nodev, /* strategy */ +X nodev, /* print */ +X nodev, /* dump */ +X nodev, /* read */ +X nodev, /* write */ +X nodev, /* ioctl */ +X nodev, /* devmap */ +X aperture_mmap, /* mmap */ +X ddi_segmap, /* segmap */ +X nochpoll, /* poll */ +X ddi_prop_op, /* cb_prop_op */ +X 0, /* streamtab */ +X D_NEW | D_MP | D_64BIT /* Driver compatibility flag */ +X}; +X +X +Xstatic dev_info_t *aperture_dip; /* private copy of devinfo pointer */ +X +X/* +X * getinfo(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_getinfo +X( +X#ifdef __STDC__ +X dev_info_t *dip, +X ddi_info_cmd_t infocmd, +X void *arg, +X void **result +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X ddi_info_cmd_t infocmd; +X void *arg; +X void **result; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering getinfo()\n"); +X +X#endif +X +X switch (infocmd) { +X case DDI_INFO_DEVT2DEVINFO: +X *result = aperture_dip; +X error = DDI_SUCCESS; +X break; +X case DDI_INFO_DEVT2INSTANCE: +X *result = NULL; +X error = DDI_SUCCESS; +X break; +X default: +X error = DDI_FAILURE; +X } +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving getinfo() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * identify(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_identify +X( +X#ifdef __STDC__ +X dev_info_t *dip +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering identify()\n"); +X +X#endif +X +X if (strcmp(ddi_get_name(dip), DEV_IDENT)) +X error = 1 /* DDI_NOT_IDENTIFIED obsolete since SunOS 5.10 */ ; +X else +X error = 2 /* DDI_IDENTIFIED obsolete since SunOS 5.10 */ ; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving identify() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * attach(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_attach +X( +X#ifdef __STDC__ +X dev_info_t *dip, +X ddi_attach_cmd_t cmd +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X ddi_attach_cmd_t cmd; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering attach()\n"); +X +X#endif +X +X if (cmd != DDI_ATTACH) +X { +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": not attach(, DDI_ATTACH)\n"); +X +X#endif +X +X error = DDI_FAILURE; +X } +X else +X { +X error = ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR, +X (minor_t)ddi_get_instance(dip), +X NULL, 0 /* NODESPECIFIC_DEV obsolete since SunOS 5.10 */ ); +X +X if (error == DDI_SUCCESS) +X { +X aperture_dip = dip; +X ddi_report_dev(dip); +X } +X } +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving attach() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * detach(9E) +X */ +Xstatic int +Xaperture_detach +X( +X#ifdef __STDC__ +X dev_info_t *dip, +X ddi_detach_cmd_t cmd +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X ddi_detach_cmd_t cmd; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering detach()\n"); +X +X#endif +X +X if (cmd != DDI_DETACH) +X { +X error = DDI_FAILURE; +X } +X else +X { +X ddi_remove_minor_node(dip, NULL); +X aperture_dip = NULL; +X error = DDI_SUCCESS; +X } +X +X#if APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving detach() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X +Xstatic struct dev_ops aperture_ops = +X{ +X DEVO_REV, /* revision */ +X 0, /* refcnt */ +X aperture_getinfo, /* getinfo */ +X aperture_identify, /* identify */ +X nulldev, /* probe */ +X aperture_attach, /* attach */ +X aperture_detach, /* detach */ +X nodev, /* reset */ +X &aperture_cb_ops, /* driver operations */ +X NULL /* bus operations */ +X}; +X +X +Xstatic struct modldrv modldrv = +X{ +X &mod_driverops, /* mod_ops structure pointer */ +X DEV_BANNER, /* driver banner string */ +X &aperture_ops, /* dev_ops structure pointer */ +X}; +X +X +Xstatic struct modlinkage modlinkage = +X{ +X MODREV_1, /* module API revision */ +X { +X &modldrv, /* module driver structure pointer */ +X NULL /* list termination */ +X } +X}; +X +X +X/* +X * _init(9E) +X */ +Xint +X_init +X( +X#ifdef __STDC__ +X void +X#endif +X) +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering _init()\n"); +X +X#endif +X +X error = mod_install(&modlinkage); +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving _init() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * _info(9E) +X */ +Xint +X_info +X( +X#ifdef __STDC__ +X struct modinfo *modinfop +X#endif +X) +X#ifndef __STDC__ +X struct modinfo *modinfop; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering _info()\n"); +X +X#endif +X +X error = mod_info(&modlinkage, modinfop); +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving _info() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * _fini(9E) +X */ +Xint +X_fini +X( +X#ifdef __STDC__ +X void +X#endif +X) +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering _fini()\n"); +X +X#endif +X +X error = mod_remove(&modlinkage); +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving _fini() = %d\n", error); +X +X#endif +X +X return error; +X} +END-of-./aperture/aperture.c +echo x - ./aperture/aperture.conf +sed 's/^X//' >./aperture/aperture.conf << 'END-of-./aperture/aperture.conf' +X# +X# Copyright 1994 Doug Anson, danson@lgc.com & David Holland, davidh@use.com +X# +X# File: aperture.conf +X# Author: Doug Anson (danson@lgc.com) +X# +X# Modified: David Holland (davidh@use.com) +X# Log: Change comments 02/23/94 +X# Change defaults/comments 09/25/94 +X# +X# Modified: Marc Aurele La France (tsi@xfree86.org) +X# Log: SPARC changes 2001.09 +X# +X# Purpose: This conf file is used by the aperture driver. +X# +Xname="aperture" parent="pseudo"; +END-of-./aperture/aperture.conf +echo x - ./aperture/devlink.tab +sed 's/^X//' >./aperture/devlink.tab << 'END-of-./aperture/devlink.tab' +X# The following entry is for the aperture driver +Xtype=ddi_pseudo;name=aperture fbs/\M0 +END-of-./aperture/devlink.tab +exit + diff --git a/xorg-server/hw/xfree86/os-support/solaris/solaris-amd64.S b/xorg-server/hw/xfree86/os-support/solaris/solaris-amd64.S new file mode 100644 index 000000000..9f5e58cb0 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/solaris-amd64.S @@ -0,0 +1,73 @@ +/ Copyright 2005 Sun Microsystems, Inc. All rights reserved. +/ +/ Permission is hereby granted, free of charge, to any person obtaining a +/ copy of this software and associated documentation files (the +/ "Software"), to deal in the Software without restriction, including +/ without limitation the rights to use, copy, modify, merge, publish, +/ distribute, 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. + +#ifdef INLINE_ASM +#define FUNCTION_START(f,n) .inline f,n +#define FUNCTION_END(f) .end +#else +#define _ASM +#include <sys/asm_linkage.h> +#define FUNCTION_START(f,n) ENTRY(f) +#define FUNCTION_END(f) SET_SIZE(f) +#endif + + FUNCTION_START(inb,4) + movq %rdi, %rdx + xorq %rax, %rax + inb (%dx) + FUNCTION_END(inb) + + FUNCTION_START(inw,4) + movq %rdi, %rdx + xorq %rax, %rax + inw (%dx) + FUNCTION_END(inw) + + FUNCTION_START(inl,4) + movq %rdi, %rdx + xorq %rax, %rax + inl (%dx) + FUNCTION_END(inl) + + FUNCTION_START(outb,8) + movq %rdi, %rdx + movq %rsi, %rax + outb (%dx) + FUNCTION_END(outb) + + FUNCTION_START(outw,8) + movq %rdi, %rdx + movq %rsi, %rax + outw (%dx) + FUNCTION_END(outw) + + FUNCTION_START(outl,8) + movq %rdi, %rdx + movq %rsi, %rax + outl (%dx) + FUNCTION_END(outl) + diff --git a/xorg-server/hw/xfree86/os-support/solaris/solaris-ia32.S b/xorg-server/hw/xfree86/os-support/solaris/solaris-ia32.S new file mode 100644 index 000000000..e2d9cf60a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/solaris-ia32.S @@ -0,0 +1,73 @@ +/ Copyright 2004 Sun Microsystems, Inc. All rights reserved. +/ +/ Permission is hereby granted, free of charge, to any person obtaining a +/ copy of this software and associated documentation files (the +/ "Software"), to deal in the Software without restriction, including +/ without limitation the rights to use, copy, modify, merge, publish, +/ distribute, 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. + +#ifdef INLINE_ASM +#define FUNCTION_START(f,n) .inline f,n +#define FUNCTION_END(f) .end +#else +#define _ASM +#include <sys/asm_linkage.h> +#define FUNCTION_START(f,n) ENTRY(f) +#define FUNCTION_END(f) SET_SIZE(f) +#endif + + FUNCTION_START(inb,4) + movl (%esp), %edx + xorl %eax, %eax + inb (%dx) + FUNCTION_END(inb) + + FUNCTION_START(inw,4) + movl (%esp), %edx + xorl %eax, %eax + inw (%dx) + FUNCTION_END(inw) + + FUNCTION_START(inl,4) + movl (%esp), %edx + xorl %eax, %eax + inl (%dx) + FUNCTION_END(inl) + + FUNCTION_START(outb,8) + movl (%esp), %edx + movl 4(%esp), %eax + outb (%dx) + FUNCTION_END(outb) + + FUNCTION_START(outw,8) + movl (%esp), %edx + movl 4(%esp), %eax + outw (%dx) + FUNCTION_END(outw) + + FUNCTION_START(outl,8) + movl (%esp), %edx + movl 4(%esp), %eax + outl (%dx) + FUNCTION_END(outl) + diff --git a/xorg-server/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S b/xorg-server/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S new file mode 100644 index 000000000..fb23942ef --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S @@ -0,0 +1,144 @@ +/* Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, 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. + */ + +#ifdef INLINE_ASM +#define FUNCTION_START(f,n) .inline f,n +#define FUNCTION_END(f) .end +#else +#define _ASM +#include <sys/asm_linkage.h> +#define FUNCTION_START(f,n) ENTRY(f) +#define FUNCTION_END(f) SET_SIZE(f) +#endif + +/* Converted from common/compiler.h gcc inline format to Sun cc inline + * format by Kenjiro Tsuji + * + * The value 0x88 means ASI_PRIMARY_LITTLE. + * The store or load to/from the address space will be done + * as little-endian. In the original xrog code, the value + * is defined as the macro ASI_PL. + * + * In the original xorg code, "membar #StoreStore|#StoreLoad" + * is directly implemented as an instruction "0x8143e00a". + * + */ + + FUNCTION_START(outb, 0) + stba %o1, [%o0] 0x88 + membar #StoreStore|#StoreLoad + FUNCTION_END(outb) + + FUNCTION_START(outw, 0) + stha %o1, [%o0] 0x88 + membar #StoreStore|#StoreLoad + FUNCTION_END(outw) + + FUNCTION_START(outl, 0) + sta %o1, [%o0] 0x88 + membar #StoreStore|#StoreLoad + FUNCTION_END(outl) + + FUNCTION_START(inb, 0) + lduba [%o0] 0x88, %o0 + FUNCTION_END(inb) + + FUNCTION_START(inw, 0) + lduha [%o0] 0x88, %o0 + FUNCTION_END(inw) + + FUNCTION_START(inl, 0) + lda [%o0] 0x88, %o0 + FUNCTION_END(inl) + + FUNCTION_START(xf86ReadMmio8, 0) + lduba [%o0 + %o1] 0x88, %o0 + FUNCTION_END(xf86ReadMmio8) + + FUNCTION_START(xf86ReadMmio16Be, 0) + lduh [%o0 + %o1], %o0 + FUNCTION_END(xf86ReadMmio16Be) + + FUNCTION_START(xf86ReadMmio16Le, 0) + lduha [%o0 + %o1] 0x88, %o0 + FUNCTION_END(xf86ReadMmio16Le) + + FUNCTION_START(xf86ReadMmio32Be, 0) + ld [%o0 + %o1], %o0 + FUNCTION_END(xf86ReadMmio32Be) + + FUNCTION_START(xf86ReadMmio32Le, 0) + lda [%o0 + %o1] 0x88, %o0 + FUNCTION_END(xf86ReadMmio32Le) + + FUNCTION_START(xf86WriteMmio8, 0) + stba %o2, [%o0 + %o1] 0x88 + membar #StoreStore|#StoreLoad + FUNCTION_END(xf86WriteMmio8) + + FUNCTION_START(xf86WriteMmio16Be, 0) + sth %o2, [%o0 + %o1] + membar #StoreStore|#StoreLoad + FUNCTION_END(xf86WriteMmio16Be) + + FUNCTION_START(xf86WriteMmio16Le, 0) + stha %o2, [%o0 + %o1] 0x88 + membar #StoreStore|#StoreLoad + FUNCTION_END(xf86WriteMmio16Le) + + FUNCTION_START(xf86WriteMmio32Be, 0) + st %o2, [%o0 + %o1] + membar #StoreStore|#StoreLoad + FUNCTION_END(xf86WriteMmio32Be) + + FUNCTION_START(xf86WriteMmio32Le, 0) + sta %o2, [%o0 + %o1] 0x88 + membar #StoreStore|#StoreLoad + FUNCTION_END(xf86WriteMmio32Le) + + FUNCTION_START(xf86WriteMmio8NB, 0) + add %o0, %o1, %o0 + stba %o2, [%o0] 0x88 + FUNCTION_END(xf86WriteMmio8NB) + + FUNCTION_START(xf86WriteMmio16BeNB, 0) + sth %o2, [%o0 + %o1] + FUNCTION_END(xf86WriteMmio16BeNB) + + FUNCTION_START(xf86WriteMmio16LeNB, 0) + stha %o2, [%o0 + %o1] 0x88 + FUNCTION_END(xf86WriteMmio16LeNB) + + FUNCTION_START(xf86WriteMmio32BeNB, 0) + st %o2, [%o0 + %o1] + FUNCTION_END(xf86WriteMmio32BeNB) + + FUNCTION_START(xf86WriteMmio32LeNB, 0) + sta %o2, [%o0 + %o1] 0x88 + FUNCTION_END(xf86WriteMmio32LeNB) + diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c b/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c new file mode 100644 index 000000000..e97ab9ef9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c @@ -0,0 +1,338 @@ +/* + * Abstraction of the AGP GART interface. + * + * This version is for Solaris. + * + * Copyright © 2000 VA Linux Systems, Inc. + * Copyright © 2001 The XFree86 Project, Inc. + */ +/* Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, 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. + */ + +#pragma ident "@(#)sun_agp.c 1.1 05/04/04 SMI" + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86_OSproc.h" +#include <unistd.h> +#include <sys/ioccom.h> +#include <sys/types.h> +#include <fcntl.h> +#include "agpgart.h" + +#ifndef AGP_DEVICE +#define AGP_DEVICE "/dev/agpgart" +#endif +/* AGP page size is independent of the host page size. */ +#ifndef AGP_PAGE_SIZE +#define AGP_PAGE_SIZE 4096 +#endif + +static int gartFd = -1; +static int acquiredScreen = -1; +static Bool initDone = FALSE; +/* + * Close /dev/agpgart. This frees all associated memory allocated during + * this server generation. + */ +_X_EXPORT Bool +xf86GARTCloseScreen(int screenNum) +{ + if (gartFd != -1) { + close(gartFd); + acquiredScreen = -1; + gartFd = -1; + initDone = FALSE; + + xf86DrvMsg(screenNum, X_INFO, + "xf86GARTCloseScreen: device closed successfully\n"); + + } + return TRUE; +} + +/* + * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called. + */ +static Bool +GARTInit(int screenNum) +{ + if (initDone) + return (gartFd != -1); + + if (gartFd == -1) + gartFd = open(AGP_DEVICE, O_RDWR); + else + return FALSE; + + if (gartFd == -1) { + xf86DrvMsg(screenNum, X_ERROR, + "GARTInit: Unable to open " AGP_DEVICE " (%s)\n", + strerror(errno)); + return FALSE; + } + + initDone = TRUE; + xf86DrvMsg(screenNum, X_INFO, + "GARTInit: " AGP_DEVICE " opened successfully\n"); + + return TRUE; +} + +_X_EXPORT Bool +xf86AgpGARTSupported(void) +{ + return (GARTInit(-1)); + +} + +_X_EXPORT AgpInfoPtr +xf86GetAGPInfo(int screenNum) +{ + agp_info_t agpinf; + AgpInfoPtr info; + + if (!GARTInit(screenNum)) + return NULL; + + if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86GetAGPInfo: Failed to allocate AgpInfo\n"); + return NULL; + } + + if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n", + strerror(errno)); + return NULL; + } + + info->bridgeId = agpinf.agpi_devid; + info->agpMode = agpinf.agpi_mode; + info->base = agpinf.agpi_aperbase; + info->size = agpinf.agpi_apersize; + info->totalPages = (unsigned long)agpinf.agpi_pgtotal; + info->systemPages = (unsigned long)agpinf.agpi_pgsystem; + info->usedPages = (unsigned long)agpinf.agpi_pgused; + + return info; +} + +_X_EXPORT Bool +xf86AcquireGART(int screenNum) +{ + + if (!GARTInit(screenNum)) + return FALSE; + + if (acquiredScreen != screenNum) { + if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = screenNum; + xf86DrvMsg(screenNum, X_INFO, + "xf86AcquireGART: AGPIOC_ACQUIRE succeeded\n"); + } + return TRUE; +} + +_X_EXPORT Bool +xf86ReleaseGART(int screenNum) +{ + + if (!GARTInit(screenNum)) + return FALSE; + + if (acquiredScreen == screenNum) { + /* + * The FreeBSD agp driver removes allocations on release. + * The Solaris driver doesn't. xf86ReleaseGART() is expected + * to give up access to the GART, but not to remove any + * allocations. + */ + + if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = -1; + xf86DrvMsg(screenNum, X_INFO, + "xf86ReleaseGART: AGPIOC_RELEASE succeeded\n"); + return TRUE; + } + return FALSE; +} + +_X_EXPORT int +xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical) +{ + agp_allocate_t alloc; + int pages; + + /* + * Allocates "size" bytes of GART memory (rounds up to the next + * page multiple) or type "type". A handle (key) for the allocated + * memory is returned. On error, the return value is -1. + * "size" should be larger than 0, or AGPIOC_ALLOCATE ioctl will + * return error. + */ + + if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) + return -1; + + pages = (size / AGP_PAGE_SIZE); + if (size % AGP_PAGE_SIZE != 0) + pages++; + + alloc.agpa_pgcount = pages; + alloc.agpa_type = type; + + if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: " + "allocation of %d pages failed\n\t(%s)\n", pages, + strerror(errno)); + return -1; + } + + if (physical) + *physical = (unsigned long)alloc.agpa_physical; + + return alloc.agpa_key; +} + +_X_EXPORT Bool +xf86DeallocateGARTMemory(int screenNum, int key) +{ + if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) + return FALSE; + + if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86DeAllocateGARTMemory: " + "deallocation of gart memory with key %d failed\n" + "\t(%s)\n", key, strerror(errno)); + return FALSE; + } + + return TRUE; +} + +/* Bind GART memory with "key" at "offset" */ +_X_EXPORT Bool +xf86BindGARTMemory(int screenNum, int key, unsigned long offset) +{ + agp_bind_t bind; + int pageOffset; + + if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) + return FALSE; + + if (offset % AGP_PAGE_SIZE != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "offset (0x%lx) is not page-aligned (%d)\n", + offset, AGP_PAGE_SIZE); + return FALSE; + } + pageOffset = offset / AGP_PAGE_SIZE; + + xf86DrvMsgVerb(screenNum, X_INFO, 3, + "xf86BindGARTMemory: bind key %d at 0x%08lx " + "(pgoffset %d)\n", key, offset, pageOffset); + + bind.agpb_pgstart = pageOffset; + bind.agpb_key = key; + + if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "binding of gart memory with key %d\n" + "\tat offset 0x%lx failed (%s)\n", + key, offset, strerror(errno)); + return FALSE; + } + + return TRUE; +} + +/* Unbind GART memory with "key" */ +_X_EXPORT Bool +xf86UnbindGARTMemory(int screenNum, int key) +{ + agp_unbind_t unbind; + + if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) + return FALSE; + + unbind.agpu_pri = 0; + unbind.agpu_key = key; + + if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: " + "unbinding of gart memory with key %d " + "failed (%s)\n", key, strerror(errno)); + return FALSE; + } + + xf86DrvMsgVerb(screenNum, X_INFO, 3, + "xf86UnbindGARTMemory: unbind key %d\n", key); + + return TRUE; +} + + +/* XXX Interface may change. */ +_X_EXPORT Bool +xf86EnableAGP(int screenNum, CARD32 mode) +{ + agp_setup_t setup; + + if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) + return FALSE; + + setup.agps_mode = mode; + if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: " + "AGPIOC_SETUP with mode %x failed (%s)\n", + mode, strerror(errno)); + return FALSE; + } + + return TRUE; +} + diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c new file mode 100644 index 000000000..7decc900f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c @@ -0,0 +1,232 @@ +/* Based on hw/xfree86/os-support/bsd/bsd_apm.c which bore no explicit + * copyright notice, so is covered by the following notice: + * + * Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +/* Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, 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. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86_OSlib.h" + +#ifndef PLEASE_FIX_THIS +#define APM_STANDBY_REQ 0xa01 +#define APM_SUSPEND_REQ 0xa02 +#define APM_NORMAL_RESUME 0xa03 +#define APM_CRIT_RESUME 0xa04 +#define APM_BATTERY_LOW 0xa05 +#define APM_POWER_CHANGE 0xa06 +#define APM_UPDATE_TIME 0xa07 +#define APM_CRIT_SUSPEND_REQ 0xa08 +#define APM_USER_STANDBY_REQ 0xa09 +#define APM_USER_SUSPEND_REQ 0xa0a +#define APM_SYS_STANDBY_RESUME 0xa0b +#define APM_IOC_NEXTEVENT 0xa0c +#define APM_IOC_RESUME 0xa0d +#define APM_IOC_SUSPEND 0xa0e +#define APM_IOC_STANDBY 0xa0f +#endif + +typedef struct apm_event_info +{ + int type; +} apm_event_info; + +/* + This may be replaced with a better device name + very soon... +*/ +#define APM_DEVICE "/dev/srn" +#define APM_DEVICE1 "/dev/apm" + +static pointer APMihPtr = NULL; +static void sunCloseAPM(void); + +static struct { + u_int apmBsd; + pmEvent xf86; +} sunToXF86Array [] = { + { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, + { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, + { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, + { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, + { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, + { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, + { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, + { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, + { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, + { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, + { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, +#ifdef APM_CAPABILITY_CHANGE + { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, +#endif +}; + +#define numApmEvents (sizeof(sunToXF86Array) / sizeof(sunToXF86Array[0])) + +static pmEvent +sunToXF86(int type) +{ + int i; + + for (i = 0; i < numApmEvents; i++) { + if (type == sunToXF86Array[i].apmBsd) { + return sunToXF86Array[i].xf86; + } + } + return XF86_APM_UNKNOWN; +} + +/* + * APM events can be requested direclty from /dev/apm + */ +static int +sunPMGetEventFromOS(int fd, pmEvent *events, int num) +{ + struct apm_event_info sunEvent; + int i; + + for (i = 0; i < num; i++) { + + if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) { + if (errno != EAGAIN) { + xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT" + " %s\n", strerror(errno)); + } + break; + } + events[i] = sunToXF86(sunEvent.type); + } + xf86Msg(X_WARNING, "Got some events\n"); + return i; +} + +static pmWait +sunPMConfirmEventToOs(int fd, pmEvent event) +{ + switch (event) { +/* XXX: NOT CURRENTLY RETURNED FROM OS */ + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: + if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0) + return PM_WAIT; /* should we stop the Xserver in standby, too? */ + else + return PM_NONE; + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: + case XF86_APM_USER_SUSPEND: + xf86Msg(X_WARNING, "Got SUSPENDED\n"); + if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0) + return PM_CONTINUE; + else { + xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND" + " %s\n", strerror(errno)); + return PM_FAILED; + } + case XF86_APM_STANDBY_RESUME: + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + case XF86_APM_STANDBY_FAILED: + case XF86_APM_SUSPEND_FAILED: + xf86Msg(X_WARNING, "Got RESUME\n"); + if (ioctl( fd, APM_IOC_RESUME, NULL ) == 0) + return PM_CONTINUE; + else { + xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME" + " %s\n", strerror(errno)); + return PM_FAILED; + } + default: + return PM_NONE; + } +} + +PMClose +xf86OSPMOpen(void) +{ + int fd; + + if (APMihPtr || !xf86Info.pmFlag) { + return NULL; + } + + if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { + if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) { + return NULL; + } + } + xf86PMGetEventFromOs = sunPMGetEventFromOS; + xf86PMConfirmEventToOs = sunPMConfirmEventToOs; + APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL); + return sunCloseAPM; +} + +static void +sunCloseAPM(void) +{ + int fd; + + if (APMihPtr) { + fd = xf86RemoveInputHandler(APMihPtr); + close(fd); + APMihPtr = NULL; + } +} diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c new file mode 100644 index 000000000..29ecd7300 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c @@ -0,0 +1,185 @@ +/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, 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. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/audio.h> +#include <sys/uio.h> +#include <limits.h> +#include <math.h> +#include <poll.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#define BELL_RATE 48000 /* Samples per second */ +#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */ +#define BELL_MS (1000/BELL_HZ) /* MS */ +#define BELL_SAMPLES (BELL_RATE / BELL_HZ) +#define BELL_MIN 3 /* Min # of repeats */ + +#define AUDIO_DEVICE "/dev/audio" + +_X_EXPORT void +xf86OSRingBell(int loudness, int pitch, int duration) +{ + static short samples[BELL_SAMPLES]; + static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */ + static int lastFreq; + int cnt; + int i; + int written; + int repeats; + int freq; + audio_info_t audioInfo; + struct iovec iov[IOV_MAX]; + int iovcnt; + double ampl, cyclen, phase; + int audioFD; + + if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) { + return; + } + + lastFreq = 0; + bzero(silence, sizeof(silence)); + + audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK); + if (audioFD == -1) { + xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n", + AUDIO_DEVICE, strerror(errno)); + return; + } + + freq = pitch; + freq = min(freq, (BELL_RATE / 2) - 1); + freq = max(freq, 2 * BELL_HZ); + + /* + * Ensure full waves per buffer + */ + freq -= freq % BELL_HZ; + + if (freq != lastFreq) { + lastFreq = freq; + ampl = 16384.0; + + cyclen = (double) freq / (double) BELL_RATE; + phase = 0.0; + + for (i = 0; i < BELL_SAMPLES; i++) { + samples[i] = (short) (ampl * sin(2.0 * M_PI * phase)); + phase += cyclen; + if (phase >= 1.0) + phase -= 1.0; + } + } + + repeats = (duration + (BELL_MS / 2)) / BELL_MS; + repeats = max(repeats, BELL_MIN); + + loudness = max(0, loudness); + loudness = min(loudness, 100); + +#ifdef DEBUG + ErrorF("BELL : freq %d volume %d duration %d repeats %d\n", + freq, loudness, duration, repeats); +#endif + + AUDIO_INITINFO(&audioInfo); + audioInfo.play.encoding = AUDIO_ENCODING_LINEAR; + audioInfo.play.sample_rate = BELL_RATE; + audioInfo.play.channels = 2; + audioInfo.play.precision = 16; + audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100); + + if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){ + xf86Msg(X_ERROR, + "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n", + AUDIO_DEVICE, strerror(errno)); + close(audioFD); + return; + } + + iovcnt = 0; + + for (cnt = 0; cnt <= repeats; cnt++) { + iov[iovcnt].iov_base = (char *) samples; + iov[iovcnt++].iov_len = sizeof(samples); + if (cnt == repeats) { + /* Insert a bit of silence so that multiple beeps are distinct and + * not compressed into a single tone. + */ + iov[iovcnt].iov_base = (char *) silence; + iov[iovcnt++].iov_len = sizeof(silence); + } + if ((iovcnt >= IOV_MAX) || (cnt == repeats)) { + written = writev(audioFD, iov, iovcnt); + + if ((written < ((int)(sizeof(samples) * iovcnt)))) { + /* audio buffer was full! */ + + int naptime; + + if (written == -1) { + if (errno != EAGAIN) { + xf86Msg(X_ERROR, + "Bell: writev failed on audio device \"%s\": %s\n", + AUDIO_DEVICE, strerror(errno)); + close(audioFD); + return; + } + i = iovcnt; + } else { + i = ((sizeof(samples) * iovcnt) - written) + / sizeof(samples); + } + cnt -= i; + + /* sleep a little to allow audio buffer to drain */ + naptime = BELL_MS * i; + poll(NULL, 0, naptime); + + i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples); + iovcnt = 0; + if ((written != -1) && (i > 0)) { + iov[iovcnt].iov_base = ((char *) samples) + i; + iov[iovcnt++].iov_len = sizeof(samples) - i; + } + } else { + iovcnt = 0; + } + } + } + + close(audioFD); + return; +} diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_bios.c b/xorg-server/hw/xfree86/os-support/solaris/sun_bios.c new file mode 100644 index 000000000..a27a5a5a7 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_bios.c @@ -0,0 +1,103 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1999 by David Holland <davidh@iquest.net> + * + * 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 names of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#if defined(__i386__) || defined(__i386) +#define _NEED_SYSI86 +#endif +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +extern char *apertureDevName; + +/* + * Read BIOS via mmap()ing physical memory. + */ +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int fd; + unsigned char *ptr; + char solx86_vtname[20]; + int psize; + int mlen; + + /* + * Solaris 2.1 x86 SVR4 (10/27/93) + * The server must treat the virtual terminal device file + * as the standard SVR4 /dev/pmem. By default, then used VT + * is considered the "default" file to open. + * + * Solaris 2.8 x86 (7/26/99) - DWH + * + * Use /dev/xsvc for everything. + */ + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); +#if (defined(__i386__) || defined(__i386)) && !defined(__SOL8__) + if (Base >= 0xA0000 && Base + mlen < 0xFFFFF && xf86Info.vtno >= 0) + sprintf(solx86_vtname, "/dev/vt%02d", xf86Info.vtno); + else +#endif + { + if (!xf86LinearVidMem()) + FatalError("xf86ReadBIOS: Could not mmap BIOS" + " [a=%lx]\n", Base); + sprintf(solx86_vtname, apertureDevName); + } + + if ((fd = open(solx86_vtname, O_RDONLY)) < 0) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", + solx86_vtname, strerror(errno)); + return(-1); + } + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, fd, (off_t)Base); + if (ptr == MAP_FAILED) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed " + "[0x%08lx, 0x%04x]\n", + solx86_vtname, Base, mlen); + close(fd); + return -1; + } + + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); + (void)close(fd); + + return Len; +} diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_init.c b/xorg-server/hw/xfree86/os-support/solaris/sun_init.c new file mode 100644 index 000000000..1f389cb40 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_init.c @@ -0,0 +1,357 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1999 by David Holland <davidh@iquest.net> + * + * 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 names of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#if defined(__i386__) || defined(__i386) || defined(__x86) +# include <sys/kd.h> +#endif + +static Bool KeepTty = FALSE; +static Bool Protect0 = FALSE; +#ifdef HAS_USL_VTS +static int VTnum = -1; +static int xf86StartVT = -1; +#endif + +#if defined(__SOL8__) || (!defined(__i386__) && !defined(__i386)) +static char fb_dev[PATH_MAX] = "/dev/fb"; +#else +static char fb_dev[PATH_MAX] = "/dev/console"; +#endif + +void +xf86OpenConsole(void) +{ +#ifdef HAS_USL_VTS + int fd, i; + struct vt_mode VT; + struct vt_stat vtinfo; + int FreeVTslot; + MessageType from = X_PROBED; +#endif + + if (serverGeneration == 1) + { + /* Check if we're run with euid==0 */ + if (geteuid() != 0) + FatalError("xf86OpenConsole: Server must be suid root\n"); + + /* Protect page 0 to help find NULL dereferencing */ + /* mprotect() doesn't seem to work */ + if (Protect0) + { + int fd = -1; + + if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: cannot open /dev/zero (%s)\n", + strerror(errno)); + } + else + { + if ((int)mmap(0, 0x1000, PROT_NONE, + MAP_FIXED | MAP_SHARED, fd, 0) == -1) + xf86Msg(X_WARNING, + "xf86OpenConsole: failed to protect page 0 (%s)\n", + strerror(errno)); + + close(fd); + } + } + +#ifdef HAS_USL_VTS + + /* + * Setup the virtual terminal manager + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + from = X_CMDLINE; + } + else + { + if ((fd = open("/dev/vt00",O_RDWR,0)) < 0) + FatalError("xf86OpenConsole: Cannot open /dev/vt00 (%s)\n", + strerror(errno)); + + if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0) + FatalError("xf86OpenConsole: Cannot determine current VT\n"); + + xf86StartVT = vtinfo.v_active; + + /* + * There is a SEVERE problem with x86's VT's. The VT_OPENQRY + * ioctl() will panic the entire system if all 8 (7 VT's+Console) + * terminals are used. The only other way I've found to determine + * if there is a free VT is to try activating all the the available + * VT's and see if they all succeed - if they do, there there is no + * free VT, and the Xserver cannot continue without panic'ing the + * system. (It's ugly, but it seems to work.) Note there is a + * possible race condition here. + * + * David Holland 2/23/94 + */ + + FreeVTslot = 0; + for (i = 7; (i >= 0) && !FreeVTslot; i--) + if (ioctl(fd, VT_ACTIVATE, i) != 0) + FreeVTslot = 1; + + if (!FreeVTslot || + (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + + close(fd); + } + + xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); + + sprintf(fb_dev, "/dev/vt%02d", xf86Info.vtno); /* Solaris 2.1 x86 */ + +#endif /* HAS_USL_VTS */ + + if (!KeepTty) + setpgrp(); + + if (((xf86Info.consoleFd = open(fb_dev, O_RDWR | O_NDELAY, 0)) < 0)) + FatalError("xf86OpenConsole: Cannot open %s (%s)\n", + fb_dev, strerror(errno)); + +#ifdef HAS_USL_VTS + + /* Change ownership of the vt */ + chown(fb_dev, getuid(), getgid()); + + /* + * Now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + FatalError("xf86OpenConsole: VT_GETMODE failed\n"); + + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); +#endif +#ifdef KDSETMODE + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); +#endif + } + else /* serverGeneration != 1 */ + { +#ifdef HAS_USL_VTS + /* + * Now re-get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86Screens[0]->vtSema) + sleep(5); + +#endif /* HAS_USL_VTS */ + + } +} + +void +xf86CloseConsole(void) +{ +#ifdef HAS_USL_VTS + struct vt_mode VT; +#endif + +#if !defined(__i386__) && !defined(__i386) && !defined(__x86) + + if (!xf86DoProbe && !xf86DoConfigure) { + int fd; + + /* + * Wipe out framebuffer just like the non-SI Xsun server does. This + * could be improved by saving framebuffer contents in + * xf86OpenConsole() above and restoring them here. Also, it's unclear + * at this point whether this should be done for all framebuffers in + * the system, rather than only the console. + */ + if ((fd = open("/dev/fb", O_RDWR, 0)) < 0) { + xf86Msg(X_WARNING, + "xf86CloseConsole(): unable to open framebuffer (%s)\n", + strerror(errno)); + } else { + struct fbgattr fbattr; + + if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) && + (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) { + xf86Msg(X_WARNING, + "xf86CloseConsole(): unable to retrieve framebuffer" + " attributes (%s)\n", strerror(errno)); + } else { + pointer fbdata; + + fbdata = mmap(NULL, fbattr.fbtype.fb_size, + PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (fbdata == MAP_FAILED) { + xf86Msg(X_WARNING, + "xf86CloseConsole(): unable to mmap framebuffer" + " (%s)\n", strerror(errno)); + } else { + (void)memset(fbdata, 0, fbattr.fbtype.fb_size); + (void)munmap(fbdata, fbattr.fbtype.fb_size); + } + } + + close(fd); + } + } + +#endif + +#ifdef KDSETMODE + /* Reset the display back to text mode */ + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); +#endif + +#ifdef HAS_USL_VTS + + /* + * Solaris 2.1 x86 doesn't seem to "switch" back to the console when the VT + * is relinquished and its mode is reset to auto. Also, Solaris 2.1 seems + * to associate vt00 with the console so I've opened the "console" back up + * and made it the active vt again in text mode and then closed it. There + * must be a better hack for this but I'm not aware of one at this time. + * + * Doug Anson 11/6/93 + * danson@lgc.com + * + * Fixed - 12/5/93 - David Holland - davidh@dorite.use.com + * Did the whole thing similarly to the way linux does it + */ + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; /* Set default vt handling */ + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); + } + + /* Activate the VT that X was started on */ + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT); + +#endif /* HAS_USL_VTS */ + + close(xf86Info.consoleFd); +} + +int +xf86ProcessArgument(int argc, char **argv, int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful when + * debugging, so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return 1; + } + + /* + * Undocumented flag to protect page 0 from read/write to help catch NULL + * pointer dereferences. This is purely a debugging flag. + */ + if (!strcmp(argv[i], "-protect0")) + { + Protect0 = TRUE; + return 1; + } + +#ifdef HAS_USL_VTS + + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return 0; + } + + return 1; + } + +#endif /* HAS_USL_VTS */ + +#if defined(__SOL8__) || (!defined(__i386__) && !defined(__i386)) + + if ((i + 1) < argc) { + if (!strcmp(argv[i], "-dev")) { + strncpy(fb_dev, argv[i+1], PATH_MAX); + fb_dev[PATH_MAX - 1] = '\0'; + return 2; + } + } + +#endif + + return 0; +} + +void xf86UseMsg() +{ +#ifdef HAS_USL_VTS + ErrorF("vtXX Use the specified VT number\n"); +#endif +#if defined(__SOL8__) || !defined(__i386__) + ErrorF("-dev <fb> Framebuffer device\n"); +#endif + ErrorF("-keeptty Don't detach controlling tty\n"); + ErrorF(" (for debugging only)\n"); +} diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_mouse.c b/xorg-server/hw/xfree86/os-support/solaris/sun_mouse.c new file mode 100644 index 000000000..a5955ef2c --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_mouse.c @@ -0,0 +1,717 @@ +/* + * Copyright 1999-2001 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ +/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, 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. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86_OSlib.h" +#include "xf86OSmouse.h" + +#if defined(__SOL8__) || !defined(__i386) + +#include "xisb.h" +#include "mipointer.h" +#include <sys/stropts.h> +#include <sys/vuid_event.h> +#include <sys/msio.h> + +/* Wheel mouse support in VUID drivers in Solaris 9 updates & Solaris 10 */ +#ifdef WHEEL_DEVID /* Defined in vuid_event.h if VUID wheel support present */ +# define HAVE_VUID_WHEEL +#endif +#ifdef HAVE_VUID_WHEEL +# include <sys/vuid_wheel.h> +#endif + +/* Support for scaling absolute coordinates to screen size in + * Solaris 10 updates and beyond */ +#if !defined(HAVE_ABSOLUTE_MOUSE_SCALING) +# ifdef MSIOSRESOLUTION /* Defined in msio.h if scaling support present */ +# define HAVE_ABSOLUTE_MOUSE_SCALING +# endif +#endif + +/* Names of protocols that are handled internally here. */ + +static const char *internalNames[] = { + "VUID", + NULL +}; + +static const char *solarisMouseDevs[] = { + /* Device file: Protocol: */ + "/dev/mouse", "VUID", /* USB or SPARC */ +#if defined(__i386) || defined(__x86) + "/dev/kdmouse", "PS/2", /* PS/2 */ +#endif + NULL +}; + +typedef struct _VuidMseRec { + struct _VuidMseRec *next; + InputInfoPtr pInfo; + Firm_event event; + unsigned char * buffer; + char * strmod; + Bool(*wrapped_device_control)(DeviceIntPtr device, int what); +#ifdef HAVE_ABSOLUTE_MOUSE_SCALING + Ms_screen_resolution absres; +#endif +} VuidMseRec, *VuidMsePtr; + +static VuidMsePtr vuidMouseList = NULL; + +static int vuidMouseProc(DeviceIntPtr pPointer, int what); +static void vuidReadInput(InputInfoPtr pInfo); + +#ifdef HAVE_ABSOLUTE_MOUSE_SCALING +static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse); +static void vuidMouseAdjustFrame(int index, int x, int y, int flags); + +static int vuidMouseGeneration = 0; +static DevPrivateKey vuidMouseScreenKey = &vuidMouseScreenKey; +#define vuidMouseGetScreenPrivate(s) ( \ + dixLookupPrivate(&(s)->devPrivates, vuidMouseScreenKey)) +#define vuidMouseSetScreenPrivate(s,p) \ + dixSetPrivate(&(s)->devPrivates, vuidMouseScreenKey, (void *) p) +#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */ + +static inline +VuidMsePtr getVuidMsePriv(InputInfoPtr pInfo) +{ + VuidMsePtr m = vuidMouseList; + + while ((m != NULL) && (m->pInfo != pInfo)) { + m = m->next; + } + + return m; +} + + +/* + * Initialize and enable the mouse wheel, if present. + * + * Returns 1 if mouse wheel was successfully enabled. + * Returns 0 if an error occurred or if there is no mouse wheel. + */ +static int +vuidMouseWheelInit(InputInfoPtr pInfo) +{ +#ifdef HAVE_VUID_WHEEL + wheel_state wstate; + int nwheel = -1; + int i; + + wstate.vers = VUID_WHEEL_STATE_VERS; + wstate.id = 0; + wstate.stateflags = -1; + + SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel)); + if (i != 0) + return (0); + + SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate)); + if (i != 0) { + xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name); + return (0); + } + + wstate.stateflags |= VUID_WHEEL_STATE_ENABLED; + + SYSCALL(i = ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate)); + if (i != 0) { + xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name); + return (0); + } + + return (1); +#else + return (0); +#endif +} + + +/* This function is called when the protocol is "VUID". */ +static Bool +vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse = pInfo->private; + VuidMsePtr pVuidMse; + int buttons, i; + + pVuidMse = xcalloc(sizeof(VuidMseRec), 1); + if (pVuidMse == NULL) { + xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name); + xfree(pMse); + return FALSE; + } + + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pVuidMse); + xfree(pMse); + return FALSE; + } + } + + pVuidMse->buffer = (unsigned char *)&pVuidMse->event; + + pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL); + if (pVuidMse->strmod) { + SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod)); + if (i < 0) { + xf86Msg(X_ERROR, + "%s: cannot push module '%s' onto mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + xfree(pVuidMse->strmod); + xfree(pVuidMse); + xfree(pMse); + return FALSE; + } + } + + buttons = xf86SetIntOption(pInfo->options, "Buttons", 0); + if (buttons == 0) { + SYSCALL(i = ioctl(pInfo->fd, MSIOBUTTONS, &buttons)); + if (i == 0) { + pInfo->conf_idev->commonOptions = + xf86ReplaceIntOption(pInfo->conf_idev->commonOptions, + "Buttons", buttons); + xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n", + pInfo->name, buttons); + } + } + + if (pVuidMse->strmod) { + SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod)); + if (i == -1) { + xf86Msg(X_WARNING, + "%s: cannot pop module '%s' off mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + } + } + + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pVuidMse->wrapped_device_control = pInfo->device_control; + pInfo->device_control = vuidMouseProc; + pInfo->read_input = vuidReadInput; + + pMse->xisbscale = sizeof(Firm_event); + +#ifdef HAVE_ABSOLUTE_MOUSE_SCALING + pVuidMse->absres.height = pVuidMse->absres.width = 0; +#endif + pVuidMse->pInfo = pInfo; + pVuidMse->next = vuidMouseList; + vuidMouseList = pVuidMse; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} + +static void +vuidFlushAbsEvents(InputInfoPtr pInfo, int absX, int absY, + Bool *absXset, Bool *absYset) +{ +#ifdef DEBUG + ErrorF("vuidFlushAbsEvents: %d,%d (set: %d, %d)\n", absX, absY, + *absXset, *absYset); +#endif + if ((*absXset) && (*absYset)) { + xf86PostMotionEvent(pInfo->dev, + /* is_absolute: */ TRUE, + /* first_valuator: */ 0, + /* num_valuators: */ 2, + absX, absY); + } else if (*absXset) { + xf86PostMotionEvent(pInfo->dev, + /* is_absolute: */ TRUE, + /* first_valuator: */ 0, + /* num_valuators: */ 1, + absX); + } else if (*absYset) { + xf86PostMotionEvent(pInfo->dev, + /* is_absolute: */ TRUE, + /* first_valuator: */ 1, + /* num_valuators: */ 1, + absY); + } + + *absXset = FALSE; + *absYset = FALSE; +} + +static void +vuidReadInput(InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + VuidMsePtr pVuidMse; + int buttons; + int dx = 0, dy = 0, dz = 0, dw = 0; + unsigned int n; + int c; + unsigned char *pBuf; + int wmask; + int absX, absY; + Bool absXset = FALSE, absYset = FALSE; + + pMse = pInfo->private; + pVuidMse = getVuidMsePriv(pInfo); + buttons = pMse->lastButtons; + XisbBlockDuration(pMse->buffer, -1); + pBuf = pVuidMse->buffer; + n = 0; + + do { + while (n < sizeof(Firm_event) && (c = XisbRead(pMse->buffer)) >= 0) { + pBuf[n++] = (unsigned char)c; + } + + if (n == 0) + return; + + if (n != sizeof(Firm_event)) { + xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", + pInfo->name, n); + } + +#ifdef DEBUG + ErrorF("vuidReadInput: event type: %3d value: %5d\n", + pVuidMse->event.id, pVuidMse->event.value); +#endif + + if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) { + /* button */ + int butnum = pVuidMse->event.id - BUT_FIRST; + + if (butnum < 3) + butnum = 2 - butnum; + if (!pVuidMse->event.value) + buttons &= ~(1 << butnum); + else + buttons |= (1 << butnum); + } else if (pVuidMse->event.id >= VLOC_FIRST && + pVuidMse->event.id <= VLOC_LAST) { + /* axis */ + int delta = pVuidMse->event.value; + switch(pVuidMse->event.id) { + case LOC_X_DELTA: + dx += delta; + break; + case LOC_Y_DELTA: + dy -= delta; + break; + case LOC_X_ABSOLUTE: + if (absXset) { + vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset); + } + absX = delta; + absXset = TRUE; + break; + case LOC_Y_ABSOLUTE: + if (absYset) { + vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset); + } + absY = delta; + absYset = TRUE; + break; + } + } +#ifdef HAVE_VUID_WHEEL + else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) { + if (vuid_id_offset(pVuidMse->event.id) == 0) + dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value); + else + dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value); + } +#endif +#ifdef HAVE_ABSOLUTE_MOUSE_SCALING + else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) { + /* force sending absolute resolution scaling ioctl */ + pVuidMse->absres.height = pVuidMse->absres.width = 0; + vuidMouseSendScreenSize(miPointerCurrentScreen(), pVuidMse); + } +#endif + + n = 0; + if ((c = XisbRead(pMse->buffer)) >= 0) { + /* Another packet. Handle it right away. */ + pBuf[n++] = c; + } + } while (n != 0); + + if (absXset || absYset) { + vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset); + } + + pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); + return; +} + +#ifdef HAVE_ABSOLUTE_MOUSE_SCALING +static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse) +{ + InputInfoPtr pInfo = pVuidMse->pInfo; + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + int result; + + if ((pVuidMse->absres.width != pScr->currentMode->HDisplay) || + (pVuidMse->absres.height != pScr->currentMode->VDisplay)) + { + pVuidMse->absres.width = pScr->currentMode->HDisplay; + pVuidMse->absres.height = pScr->currentMode->VDisplay; + + do { + result = ioctl(pInfo->fd, MSIOSRESOLUTION, &(pVuidMse->absres)); + } while ( (result != 0) && (errno == EINTR) ); + + if (result != 0) { + xf86Msg(X_WARNING, + "%s: couldn't set absolute mouse scaling resolution: %s\n", + pInfo->name, strerror(errno)); +#ifdef DEBUG + } else { + xf86Msg(X_INFO, + "%s: absolute mouse scaling resolution set to %d x %d\n", + pInfo->name, + pVuidMse->absres.width, pVuidMse->absres.height); +#endif + } + } +} + +static void vuidMouseAdjustFrame(int index, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + ScreenPtr pScreen = pScrn->pScreen; + xf86AdjustFrameProc *wrappedAdjustFrame + = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen); + VuidMsePtr m; + + if(wrappedAdjustFrame) { + pScrn->AdjustFrame = wrappedAdjustFrame; + (*pScrn->AdjustFrame)(index, x, y, flags); + pScrn->AdjustFrame = vuidMouseAdjustFrame; + } + + if (miPointerCurrentScreen() == pScreen) { + for (m = vuidMouseList; m != NULL ; m = m->next) { + vuidMouseSendScreenSize(pScreen, m); + } + } +} +#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */ + + +static int +vuidMouseProc(DeviceIntPtr pPointer, int what) +{ + InputInfoPtr pInfo; + MouseDevPtr pMse; + VuidMsePtr pVuidMse; + int ret = Success; + int i; + + pInfo = pPointer->public.devicePrivate; + pMse = pInfo->private; + pMse->device = pPointer; + + pVuidMse = getVuidMsePriv(pInfo); + if (pVuidMse == NULL) { + return BadImplementation; + } + + switch (what) { + + case DEVICE_INIT: +#ifdef HAVE_ABSOLUTE_MOUSE_SCALING + if (vuidMouseGeneration != serverGeneration) { + for (i = 0; i < screenInfo.numScreens; i++) { + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); + vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame); + pScrn->AdjustFrame = vuidMouseAdjustFrame; + } + vuidMouseGeneration = serverGeneration; + } +#endif + ret = pVuidMse->wrapped_device_control(pPointer, what); + break; + + case DEVICE_ON: + ret = pVuidMse->wrapped_device_control(pPointer, DEVICE_ON); + + if ((ret == Success) && (pInfo->fd != -1)) { + int fmt = VUID_FIRM_EVENT; + + if (pVuidMse->strmod) { + SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod)); + if (i < 0) { + xf86Msg(X_WARNING, + "%s: cannot push module '%s' onto mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + xfree(pVuidMse->strmod); + pVuidMse->strmod = NULL; + } + } + SYSCALL(i = ioctl(pInfo->fd, VUIDSFORMAT, &fmt)); + if (i < 0) { + xf86Msg(X_WARNING, + "%s: cannot set mouse device to VUID mode: %s\n", + pInfo->name, strerror(errno)); + } + vuidMouseWheelInit(pInfo); +#ifdef HAVE_ABSOLUTE_MOUSE_SCALING + vuidMouseSendScreenSize(screenInfo.screens[0], pVuidMse); +#endif + xf86FlushInput(pInfo->fd); + } + break; + + case DEVICE_OFF: + case DEVICE_CLOSE: + if (pInfo->fd != -1) { + if (pVuidMse->strmod) { + SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod)); + if (i == -1) { + xf86Msg(X_WARNING, + "%s: cannot pop module '%s' off mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + } + } + } + ret = pVuidMse->wrapped_device_control(pPointer, what); + break; + + default: /* Should never be called, but just in case */ + ret = pVuidMse->wrapped_device_control(pPointer, what); + break; + } + return ret; +} + +static Bool +sunMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + /* The protocol is guaranteed to be one of the internalNames[] */ + if (xf86NameCmp(protocol, "VUID") == 0) { + return vuidPreInit(pInfo, protocol, flags); + } + return TRUE; +} + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + + return FALSE; +} + +static const char * +DefaultProtocol(void) +{ + return "Auto"; +} + +static Bool +solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol, + const char **device) +{ + const char **pdev, **pproto, *dev = NULL; + int fd = -1; + Bool found; + + for (pdev = solarisMouseDevs; *pdev; pdev += 2) { + pproto = pdev + 1; + if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) && + (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) { + continue; + } + if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) { + continue; + } + SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK)); + if (fd == -1) { +#ifdef DEBUG + ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno)); +#endif + } else { + found = TRUE; + if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) { + int i, r; + SYSCALL(r = ioctl(fd, VUIDGFORMAT, &i)); + if (r < 0) { + found = FALSE; + } + } + close(fd); + if (found == TRUE) { + if (*pproto != NULL) { + *protocol = *pproto; + } + *device = *pdev; + return TRUE; + } + } + } + return FALSE; +} + +static const char * +SetupAuto(InputInfoPtr pInfo, int *protoPara) +{ + const char *pdev = NULL; + const char *pproto = NULL; + MouseDevPtr pMse = pInfo->private; + + if (pInfo->fd == -1) { + /* probe to find device/protocol to use */ + if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, pdev); + } + } else if (pMse->protocolID == PROT_AUTO) { + pdev = xf86CheckStrOption(pInfo->conf_idev->commonOptions, + "Device", NULL); + solarisMouseAutoProbe(pInfo, &pproto, &pdev); + } + return pproto; +} + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + const char *pdev = NULL; + const char *pproto = protocol; + + if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, pdev); + } + return pdev; +} + +#else /* __SOL8__ || !__i386 */ + +#undef MSE_MISC +#define MSE_MISC 0 + +#endif /* !__SOL8__ && __i386 */ + +static int +SupportedInterfaces(void) +{ + /* XXX This needs to be checked. */ + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_XPS2 | MSE_MISC; +} + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; +#if defined(__SOL8__) || !defined(__i386) + p->BuiltinNames = BuiltinNames; + p->CheckProtocol = CheckProtocol; + p->PreInit = sunMousePreInit; + p->DefaultProtocol = DefaultProtocol; + p->SetupAuto = SetupAuto; + p->FindDevice = FindDevice; +#endif + return p; +} + diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c new file mode 100644 index 000000000..e7b529ccb --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c @@ -0,0 +1,236 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the names of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/types.h> /* get __x86 definition if not set by compiler */ + +#if defined(__i386__) || defined(__i386) || defined(__x86) +#define _NEED_SYSI86 +#endif +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +char *apertureDevName = NULL; + +_X_EXPORT Bool +xf86LinearVidMem(void) +{ + int mmapFd; + + if (apertureDevName) + return TRUE; + + apertureDevName = "/dev/xsvc"; + if ((mmapFd = open(apertureDevName, O_RDWR)) < 0) + { + apertureDevName = "/dev/fbs/aperture"; + if((mmapFd = open(apertureDevName, O_RDWR)) < 0) + { + xf86MsgVerb(X_WARNING, 0, + "xf86LinearVidMem: failed to open %s (%s)\n", + apertureDevName, strerror(errno)); + xf86MsgVerb(X_WARNING, 0, + "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc" + " device driver required\n"); + xf86MsgVerb(X_WARNING, 0, + "xf86LinearVidMem: linear memory access disabled\n"); + apertureDevName = NULL; + return FALSE; + } + } + close(mmapFd); + return TRUE; +} + +_X_EXPORT pointer +xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) +{ + pointer base; + int fd; + char vtname[20]; + + /* + * Solaris 2.1 x86 SVR4 (10/27/93) + * The server must treat the virtual terminal device file as the + * standard SVR4 /dev/pmem. + * + * Using the /dev/vtXX device as /dev/pmem only works for the + * A0000-FFFFF region - If we wish you mmap the linear aperture + * it requires a device driver. + * + * So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and + * try to use the /dev/fbs/aperture or /dev/xsvc driver if the server + * tries to mmap anything > FFFFF. Its very very unlikely that the + * server will try to mmap anything below FFFFF that can't be handled + * by /dev/vtXX. + * + * DWH - 2/23/94 + * DWH - 1/31/99 (Gee has it really been 5 years?) + * + * Solaris 2.8 7/26/99 + * Use /dev/xsvc for everything + * + * DWH - 7/26/99 - Solaris8/dev/xsvc changes + * + * TSI - 2001.09 - SPARC changes + */ + +#if defined(__i386__) && !defined(__SOL8__) + if(Base < 0xFFFFF) + sprintf(vtname, "/dev/vt%02d", xf86Info.vtno); + else +#endif + { + if (!xf86LinearVidMem()) + FatalError("xf86MapVidMem: no aperture device\n"); + + strcpy(vtname, apertureDevName); + } + + fd = open(vtname, (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + vtname, strerror(errno)); + + base = mmap(NULL, Size, + (Flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, (off_t)Base); + close(fd); + if (base == MAP_FAILED) + FatalError("xf86MapVidMem: mmap failure: %s\n", + strerror(errno)); + + return(base); +} + +/* ARGSUSED */ +_X_EXPORT void +xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +#if defined(__i386__) || defined(__i386) || defined(__x86) +static Bool ExtendedEnabled = FALSE; +#endif + +_X_EXPORT Bool +xf86EnableIO(void) +{ +#if defined(__i386__) || defined(__i386) || defined(__x86) + if (ExtendedEnabled) + return TRUE; + + if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) { + xf86Msg(X_WARNING,"xf86EnableIOPorts: Failed to set IOPL for I/O\n"); + return FALSE; + } + ExtendedEnabled = TRUE; +#endif /* i386 */ + return TRUE; +} + +_X_EXPORT void +xf86DisableIO(void) +{ +#if defined(__i386__) || defined(__i386) || defined(__x86) + if(!ExtendedEnabled) + return; + + sysi86(SI86V86, V86SC_IOPL, 0); + + ExtendedEnabled = FALSE; +#endif /* i386 */ +} + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool xf86DisableInterrupts(void) +{ +#if defined(__i386__) || defined(__i386) || defined(__x86) + if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)) + return FALSE; + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + sysi86(SI86V86, V86SC_IOPL, 0); +#endif /* i386 */ + + return TRUE; +} + +_X_EXPORT void xf86EnableInterrupts(void) +{ +#if defined(__i386__) || defined(__i386) || defined(__x86) + if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)) + return; + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + sysi86(SI86V86, V86SC_IOPL, 0); +#endif /* i386 */ +} + +_X_EXPORT void +xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, + unsigned long Size) +{ +} + +_X_EXPORT Bool +xf86CheckMTRR(int ScreenNum) +{ + return FALSE; +} + diff --git a/xorg-server/hw/xfree86/os-support/sysv/Makefile.am b/xorg-server/hw/xfree86/os-support/sysv/Makefile.am new file mode 100644 index 000000000..f9d2f237a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sysv/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = sysv_init.c sysv_mouse.c sysv_video.c diff --git a/xorg-server/hw/xfree86/os-support/sysv/Makefile.in b/xorg-server/hw/xfree86/os-support/sysv/Makefile.in new file mode 100644 index 000000000..2a27a19e1 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sysv/Makefile.in @@ -0,0 +1,532 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/sysv +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +EXTRA_DIST = sysv_init.c sysv_mouse.c sysv_video.c +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/sysv/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/sysv/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c new file mode 100644 index 000000000..170bb8914 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c @@ -0,0 +1,252 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static Bool KeepTty = FALSE; +#ifdef SVR4 +static Bool Protect0 = FALSE; +#endif +static int VTnum = -1; + + +void +xf86OpenConsole() +{ + int fd; + struct vt_mode VT; + char vtname1[10],vtname2[10]; + MessageType from = X_PROBED; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be suid root\n"); + } + +#ifdef SVR4 + /* Protect page 0 to help find NULL dereferencing */ + /* mprotect() doesn't seem to work */ + if (Protect0) + { + int fd = -1; + + if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: cannot open /dev/zero (%s)\n", + strerror(errno)); + } + else + { + if ((int)mmap(0, 0x1000, PROT_NONE, + MAP_FIXED | MAP_SHARED, fd, 0) == -1) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: failed to protect page 0 (%s)\n", + strerror(errno)); + } + close(fd); + } + } +#endif + /* + * setup the virtual terminal manager + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + from = X_CMDLINE; + } + else + { + if ((fd = open("/dev/console",O_WRONLY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open /dev/console (%s)\n", + strerror(errno)); + } + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + { + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + } + close(fd); + } + xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); + + sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */ + sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */ + + if (!KeepTty) + { + setpgrp(); + } + + if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) && + ((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0)) + { + FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n", + vtname2, vtname1, strerror(errno)); + } + + /* change ownership of the vt */ + if (chown(vtname1, getuid(), getgid()) < 0) + { + chown(vtname2, getuid(), getgid()); + } + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_GETMODE failed\n"); + } + + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + { + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); + } + } + else + { + /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86Screens[0]->vtSema) + sleep(5); + } + return; +} + +void +xf86CloseConsole() +{ + struct vt_mode VT; + +#if 0 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno); + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0); +#endif + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */ + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } +#ifdef SVR4 + /* + * Undocumented flag to protect page 0 from read/write to help + * catch NULL pointer dereferences. This is purely a debugging + * flag. + */ + if (!strcmp(argv[i], "-protect0")) + { + Protect0 = TRUE; + return(1); + } +#endif + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + return(0); +} + +void +xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_mouse.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_mouse.c new file mode 100644 index 000000000..e62010515 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_mouse.c @@ -0,0 +1,60 @@ + +/* + * Copyright 1999 by The XFree86 Project, Inc. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" + +static int +SupportedInterfaces(void) +{ + /* XXX Need to check this. */ + return MSE_SERIAL | MSE_AUTO; +} + +#ifndef ISC +static const char *internalNames[] = { + NULL +}; + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + return FALSE; +} +#endif + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; +#ifndef ISC + p->BuiltinNames = BuiltinNames; + p->CheckProtocol = CheckProtocol; +#endif + return p; +} + diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c new file mode 100644 index 000000000..9972bcaa4 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c @@ -0,0 +1,367 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +#ifndef SI86IOPL +#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL) +#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0) +#else +#define SET_IOPL() sysi86(SI86IOPL,3) +#define RESET_IOPL() sysi86(SI86IOPL,0) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +/* + * XXX Support for SVR3 will need to be reworked if needed. In particular + * the Region parameter is no longer passed, and will need to be dealt + * with internally if required. + * OK, i'll rework that thing ... (clean it up a lot) + * SVR3 Support only with SVR3_MMAPDRV (mr) + * + */ + +#ifdef HAS_SVR3_MMAPDRV +#ifndef MMAP_DEBUG +#define MMAP_DEBUG 3 +#endif + +struct kd_memloc MapDSC; +int mmapFd = -2; + +static int +mmapStat(pointer Base, unsigned long Size) { + + int nmmreg,i=0,region=-1; + mmapinfo_t *ibuf; + + nmmreg = ioctl(mmapFd, GETNMMREG); + + if(nmmreg <= 0) + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "\nNo physical memory mapped currently.\n\n"); + else { + if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL) + xf86Msg(X_WARNING, + "Couldn't allocate memory 4 mmapinfo_t\n"); + else { + if(ioctl(mmapFd, GETMMREG, ibuf) != -1) + { + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# mmapStat: [Size=%x,Base=%x]\n", Size, Base); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# Physical Address Size Reference Count\n"); + for(i = 0; i < nmmreg; i++) { + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "%-4d 0x%08X %5dk %5d ", + i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt); + if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) { + xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!"); + if (region==-1) region=i; + } + xf86ErrorFVerb(MMAP_DEBUG, "\n"); + } + xf86ErrorFVerb(MMAP_DEBUG, "\n"); + } + free(ibuf); + } + } + if (region == -1 && nmmreg > 0) region=region * i; + return(region); +} +#endif + + +static Bool +linearVidMem() +{ +#ifdef SVR4 + return TRUE; +#elif defined(HAS_SVR3_MMAPDRV) + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# xf86LinearVidMem: MMAP 2.2.2 called\n"); + + if(mmapFd >= 0) return TRUE; + + if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1) + { + if(ioctl(mmapFd, GETVERSION) < 0x0222) { + xf86Msg(X_WARNING, + "xf86LinearVidMem: MMAP 2.2.2 or above required\n"); + xf86ErrorF("\tlinear memory access disabled\n"); + return FALSE; + } + return TRUE; + } + xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n", + strerror(errno)); + xf86ErrorF("\tlinear memory access disabled\n"); + return FALSE; +#endif +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + int fd; + +#if defined(SVR4) + fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, (off_t)Base); + close(fd); + if (base == MAP_FAILED) + { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + } +#else /* SVR4 */ +#ifdef HAS_SVR3_MMAPDRV + + xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n"); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); + if (ioctl(mmapFd, GETVERSION) == -1) + { + xf86LinearVidMem(); + } + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: Screen: %d\n", ScreenNum); + mmapStat(Base,Size); + /* To force the MMAP driver to provide the address */ + base = (pointer)0; + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base); + MapDSC.vaddr = (char *)base; + MapDSC.physaddr = (char *)Base; + MapDSC.length = Size; + MapDSC.ioflg = 1; + if(mmapFd >= 0) + { + if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1) + { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + /* NOTREACHED */ + } + + /* Next time we want the same address! */ + MapDSC.vaddr = (char *)base; + } + + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MapDSC.length : %d\n", MapDSC.length); + mmapStat(Base,Size); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n"); +#endif /* HAS_SVR3_MMAPDRV */ +#endif /* SVR4 */ + return(base); +} + +/* ARGSUSED */ +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ +#if defined (SVR4) + munmap(Base, Size); +#else /* SVR4 */ +#ifdef HAS_SVR3_MMAPDRV + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# xf86UnMapVidMem: UNMapping FrameBuffer\n"); + mmapStat(Base,Size); + ioctl(mmapFd, UNMAPRM , Base); + mmapStat(Base,Size); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base); +#endif /* HAS_SVR3_MMAPDRV */ +#endif /* SVR4 */ + return; +} + +#if defined(SVR4) && defined(__i386__) && !defined(sun) +/* + * For some SVR4 versions, a 32-bit read is done for the first location + * in each page when the page is first mapped. If this is done while + * memory access is enabled for regions that have read side-effects, + * this can cause unexpected results, including lockups on some hardware. + * This function is called to make sure each page is mapped while it is + * safe to do so. + */ + +/* + * XXX Should get this the correct way (see os/xalloc.c), but since this is + * for one platform I'll be lazy. + */ +#define X_PAGE_SIZE 4096 + +static void +readSideEffects(int ScreenNum, pointer Base, unsigned long Size) +{ + unsigned long base, end, addr; + CARD32 val; + + base = (unsigned long)Base; + end = base + Size; + + for (addr = base; addr < end; addr += X_PAGE_SIZE) + val = *(volatile CARD32 *)addr; +} +#endif + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = linearVidMem(); + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; +#if defined(SVR4) && defined(__i386__) && !defined(sun) + pVidMem->readSideEffects = readSideEffects; +#endif + pVidMem->initialised = TRUE; +} + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; + +_X_EXPORT Bool +xf86EnableIO() +{ + int i; + + if (ExtendedEnabled) + return TRUE; + + if (SET_IOPL() < 0) + { + xf86Msg(X_WARNING, + "xf86EnableIO: Failed to set IOPL for extended I/O\n"); + return FALSE; + } + ExtendedEnabled = TRUE; + + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + RESET_IOPL(); + ExtendedEnabled = FALSE; + + return; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + if (!ExtendedEnabled) + { + if (SET_IOPL() < 0) + { + return(FALSE); + } + } + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + { + RESET_IOPL(); + } + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + if (!ExtendedEnabled) + { + if (SET_IOPL() < 0) + { + return; + } + } + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + { + RESET_IOPL(); + } + return; +} diff --git a/xorg-server/hw/xfree86/os-support/usl/Makefile.am b/xorg-server/hw/xfree86/os-support/usl/Makefile.am new file mode 100644 index 000000000..db08f5d85 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/usl/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = \ + usl_init.c \ + usl_iop.c \ + usl_mouse.c \ + usl_video.c \ + usl_vtsw.c diff --git a/xorg-server/hw/xfree86/os-support/usl/Makefile.in b/xorg-server/hw/xfree86/os-support/usl/Makefile.in new file mode 100644 index 000000000..bf5c2ac17 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/usl/Makefile.in @@ -0,0 +1,538 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/usl +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +EXTRA_DIST = \ + usl_init.c \ + usl_iop.c \ + usl_mouse.c \ + usl_video.c \ + usl_vtsw.c + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/usl/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/usl/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/usl/usl_init.c b/xorg-server/hw/xfree86/os-support/usl/usl_init.c new file mode 100644 index 000000000..d27b206c8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/usl/usl_init.c @@ -0,0 +1,357 @@ +/* + * Copyright 2001-2005 by Kean Johnston <jkj@sco.com> + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell, David Wexelblat + * and Kean Johnston not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * Thomas Roell, David Wexelblat and Kean Johnston make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL, DAVID WEXELBLAT AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT + * OR KEAN JOHNSTON 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 "X.h" +#include "Xmd.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include <sys/utsname.h> + +static Bool KeepTty = FALSE; +static Bool Protect0 = FALSE; +static Bool CRTSpecified = FALSE; +static int VTnum = -1; +static char vtdevice[48]; + +int usl_is_osr6 = -1; + +static Bool +IsConsoleDevice(const char *dev) +{ + if ((!strcmp (dev, "/dev/console")) || + (!strcmp (dev, "/dev/syscon")) || + (!strcmp (dev, "/dev/systty"))) + return TRUE; + + return FALSE; +} + +static int +is_osr6 (void) +{ + struct utsname uts; + + if (usl_is_osr6 == -1) { + if (uname (&uts) < 0) { + FatalError ("get_usl_ver: Failed to determine UNIX name (%s)\n", + strerror (errno)); + } + + if (uts.version[0] == '6') + usl_is_osr6 = 1; + else + usl_is_osr6 = 0; + } + + return usl_is_osr6; +} + + +void +xf86OpenConsole(void) +{ + int fd, i, ioctl_ret; + struct vt_mode VT; + struct vt_stat vts; + MessageType from = X_PROBED; + struct sigaction sigvtsw; + char *ttn; + + if (serverGeneration == 1) { + int isconsole = 0, consdev = 0; + + /* check if we're run with euid==0 */ + if (geteuid() != 0) { + FatalError("xf86OpenConsole: Server must be suid root\n"); + } + + /* If we are run in the background we will get SIGTTOU. Ignore it. */ + OsSignal (SIGTTOU, SIG_IGN); + + /* Protect page 0 to help find NULL dereferencing */ + /* mprotect() doesn't seem to work */ + if (Protect0) { + int fd = -1; + + if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) { + xf86Msg(X_WARNING, "xf86OpenConsole: cannot open /dev/zero (%s)\n", + strerror(errno)); + } else { + if ((int)mmap(0, 0x1000, PROT_NONE, + MAP_FIXED | MAP_SHARED, fd, 0) == -1) { + xf86Msg(X_WARNING, "xf86OpenConsole: failed to protect page 0 (%s)\n", + strerror(errno)); + } + close(fd); + } + } + + /* + * setup the virtual terminal manager + */ + if (VTnum == -1) { + /* + * No device was specified. We need to query the kernel to see which + * console device we are on (and in fact if we are on a console at all). + */ + if (ioctl (0, VT_GETSTATE, &vts) < 0) { + FatalError("xf86OpenConsole: Could not query active VT: %s\n", + strerror(errno)); + } + VTnum = vts.v_active; + if (is_osr6()) + snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1); + else + snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum); + } else { + from = X_CMDLINE; + if (is_osr6()) + snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1); + else + snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum); + } + + if (IsConsoleDevice(vtdevice)) { + isconsole = 1; + CRTSpecified = FALSE; /* Dont honour -crt /dev/console */ + } + + if (ioctl (0, KIOCINFO, 0) >= 0) + consdev = 1 + isconsole; + + if ((!CRTSpecified) && (isconsole || (!consdev))) { + /* + * Need to find a free VT + */ + if ((fd = open ("/dev/console", O_WRONLY | O_NOCTTY)) < 0) { + FatalError ("xf86OpenConsole: Could not open /dev/console: %s\n", + strerror (errno)); + } + + if (ioctl (fd, VT_OPENQRY, &VTnum) < 0) { + FatalError ("xf86OpenConsole: Cannot find a free VT: %s\n", + strerror(errno)); + } + close (fd); + if (usl_is_osr6) + snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1); + else + snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum); + } + + /* + * Now we can dispose of stdin/stdout + */ + fclose (stdin); + fclose (stdout); + + if (CRTSpecified || isconsole || consdev != 1) { + if (!KeepTty) { + setpgrp(); + } + } + + if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NONBLOCK, 0)) < 0) { + FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice, + strerror(errno)); + } + + xf86Msg (from, "using VT number %d (%s)\n\n", VTnum, vtdevice); + xf86Info.vtno = VTnum; + + /* change ownership of the vt */ + chown(vtdevice, getuid(), getgid()); + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { + FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", + strerror(errno)); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) { + FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",strerror(errno)); + } + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) { + FatalError("xf86OpenConsole: VT_GETMODE failed: %s\n", strerror(errno)); + } + + sigvtsw.sa_handler = xf86VTRequest; + sigfillset(&sigvtsw.sa_mask); + sigvtsw.sa_flags = 0; + sigaction(SIGUSR1, &sigvtsw, NULL); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + + ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); + if (ioctl_ret < 0) { + FatalError("xf86OpenConsole: VT_SETMODE failed: %s\n", strerror(errno)); + } + + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { + FatalError("xf86OpenConsole: KD_GRAPHICS failed: %s\n", strerror(errno)); + } + } else { /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { + FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", strerror(errno)); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) { + FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",strerror(errno)); + } + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86Screens[0]->vtSema) + sleep(5); + } + return; +} + +void +xf86CloseConsole(void) +{ + struct vt_mode VT; + struct sigaction sigvtsw; + + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */ + + sigvtsw.sa_handler = SIG_DFL; + sigfillset(&sigvtsw.sa_mask); + sigvtsw.sa_flags = 0; + sigaction(SIGUSR1, &sigvtsw, NULL); + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) { + VT.mode = VT_AUTO; + VT.waitv = 0; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) { + KeepTty = TRUE; + return(1); + } + + /* + * Undocumented flag to protect page 0 from read/write to help + * catch NULL pointer dereferences. This is purely a debugging + * flag. + */ + if (!strcmp(argv[i], "-protect0")) { + Protect0 = TRUE; + return(1); + } + + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) { + UseMsg(); + VTnum = -1; + return(0); + } + VTnum -= is_osr6(); + CRTSpecified = TRUE; + return(1); + } + + /* + * Use a device the user specifies. + */ + if (!strcmp(argv[i], "-crt")) { + if (++i > argc) { + UseMsg(); + VTnum = -1; + return(0); + } else { + char *mytty = ttyname(0); + char *arg = argv[i]; + + if (!mytty) + mytty = "\1"; + if (!arg[0]) + arg = "\2"; /* Prevent idiots from using -crt "" */ + + if (strcmp (mytty, arg) != 0) { + char *fmt; + + if (is_osr6()) + fmt = "/dev/tty%02d"; + else + fmt = "/dev/vt%02d"; + + if (sscanf(arg, fmt, &VTnum) == 0) { + UseMsg(); + VTnum = -1; + return(0); + } + + /* OSR6 devices start names at 1, UW7 starts at 0 */ + VTnum -= is_osr6(); + CRTSpecified = TRUE; + } + return(2); + } + } + return(0); +} + +void +xf86UseMsg(void) +{ + if (is_osr6()) { + ErrorF("-crt /dev/ttyXX use the specified VT device\n"); + ErrorF("vtXX use the specified VT number (01-16)\n"); + } else { + ErrorF("-crt /dev/vtXX use the specified VT device\n"); + ErrorF("vtXX use the specified VT number (00-15)\n"); + } + + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/xorg-server/hw/xfree86/os-support/usl/usl_iop.c b/xorg-server/hw/xfree86/os-support/usl/usl_iop.c new file mode 100644 index 000000000..c6382fc7e --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/usl/usl_iop.c @@ -0,0 +1,106 @@ +/* + * Copyright 2001,2005 by Kean Johnston <jkj@sco.com> + * + * 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 Kean Johnston not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Kean Johnston makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEAN JOHNSTON 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 "X.h" + +#include "compiler.h" + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86OSpriv.h" +#include "xf86_OSlib.h" + + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool IOEnabled = FALSE; + +_X_EXPORT Bool +xf86EnableIO(void) +{ + if (IOEnabled) + return TRUE; + + if (sysi86(SI86IOPL, 3) < 0) + FatalError("Failed to set IOPL for extended I/O\n"); + IOEnabled = TRUE; + return TRUE; +} + +_X_EXPORT void +xf86DisableIO(void) +{ + if (!IOEnabled) + return; + + sysi86(SI86IOPL, 0); + IOEnabled = FALSE; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts(void) +{ + if (!IOEnabled) { + if (sysi86(SI86IOPL, 3) < 0) + return FALSE; + } + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + if (!IOEnabled) { + sysi86(SI86IOPL, 0); + } + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts(void) +{ + if (!IOEnabled) { + if (sysi86(SI86IOPL, 3) < 0) + return; + } + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + if (!IOEnabled) { + sysi86(SI86IOPL, 0); + } +} + diff --git a/xorg-server/hw/xfree86/os-support/usl/usl_mouse.c b/xorg-server/hw/xfree86/os-support/usl/usl_mouse.c new file mode 100644 index 000000000..aa4600f79 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/usl/usl_mouse.c @@ -0,0 +1,177 @@ + +/* + * Copyright 2005 Kean Johnston + * Copyright 1999 by The XFree86 Project, 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 names of The XFree86 Project, Inc + * and Kean Johnston not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * The XFree86 Project, Inc and Kean Johnston make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE XFREE86 PROJECT, INC AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT + * OR KEAN JOHNSTON 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 "X.h" +#include "compiler.h" +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "mipointer.h" + +static int +SupportedInterfaces(void) +{ + return MSE_MISC; +} + +static const char *internalNames[] = { + NULL +}; + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static const char * +DefaultProtocol (void) +{ + return "OSMouse"; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + return FALSE; +} + +static int +OsMouseProc(DeviceIntPtr pPointer, int what) +{ + InputInfoPtr pInfo; + MouseDevPtr pMse; + unsigned char map[9]; + int ret; + + pInfo = pPointer->public.devicePrivate; + pMse = pInfo->private; + pMse->device = pPointer; + + switch (what) { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + for (ret = 0; ret <= 8; ret++) + map[ret] = ret; + + InitPointerDeviceStruct((DevicePtr)pPointer, map, 8, + miPointerGetMotionEvents, pMse->Ctrl, + miPointerGetMotionBufferSize()); + /* X valuator */ + xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 0); + + /* Y valuator */ + xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 1); + + xf86MotionHistoryAllocate(pInfo); + break; + + case DEVICE_ON: + pMse->lastButtons = 0; + pMse->emulateState = 0; + pPointer->public.on = TRUE; + XqMseOnOff (pInfo, 1); + break; + + case DEVICE_CLOSE: + case DEVICE_OFF: + pPointer->public.on = FALSE; + XqMseOnOff (pInfo, 0); + break; + } + return Success; +} + +static Bool +OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse; + + pMse = pInfo->private; + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + pInfo->fd = -1; +#if 0 + /* Make sure we can open the mouse */ + pInfo->fd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK); + + if (pInfo->fd < 0) { + if (xf86GetAllowMouseOpenFail()) { + xf86Msg(X_WARNING, "%s: cannot open /dev/mouse (%s)\n", + pInfo->name, strerror(errno)); + } else { + xf86Msg(X_ERROR, "%s: cannot open /dev/mouse (%s)\n", + pInfo->name, strerror(errno)); + xfree(pMse); + return FALSE; + } + } +#endif + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pInfo->device_control = OsMouseProc; + pInfo->read_input = NULL; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + + p->SupportedInterfaces = SupportedInterfaces; + p->BuiltinNames = BuiltinNames; + p->DefaultProtocol = DefaultProtocol; + p->CheckProtocol = CheckProtocol; + p->PreInit = OsMousePreInit; + return p; +} + diff --git a/xorg-server/hw/xfree86/os-support/usl/usl_video.c b/xorg-server/hw/xfree86/os-support/usl/usl_video.c new file mode 100644 index 000000000..41abd2259 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/usl/usl_video.c @@ -0,0 +1,109 @@ +/* + * Copyrught 2005 Kean Johnston <jkj@sco.com> + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell, David Dawes + * and Kean Johnston not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * Thomas Roell, David Dawes and Kean Johnston make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL, DAVID DAWES AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT + * OR KEAN JOHNSTON 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 "X.h" + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +static Bool +linearVidMem(void) +{ + return TRUE; +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + int fd; + + fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, (off_t)Base); + close(fd); + + if (base == MAP_FAILED) { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + } + return(base); +} + +/* ARGSUSED */ +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +/* + * For some SVR4 versions, a 32-bit read is done for the first location + * in each page when the page is first mapped. If this is done while + * memory access is enabled for regions that have read side-effects, + * this can cause unexpected results, including lockups on some hardware. + * This function is called to make sure each page is mapped while it is + * safe to do so. + */ + +#define X_PAGE_SIZE 4096 + +static void +readSideEffects(int ScreenNum, pointer Base, unsigned long Size) +{ + unsigned long base, end, addr; + CARD32 val; + + base = (unsigned long)Base; + end = base + Size; + + for (addr = base; addr < end; addr += X_PAGE_SIZE) + val = *(volatile CARD32 *)addr; +} + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = linearVidMem(); + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; + pVidMem->readSideEffects = readSideEffects; + pVidMem->initialised = TRUE; +} + diff --git a/xorg-server/hw/xfree86/os-support/usl/usl_vtsw.c b/xorg-server/hw/xfree86/os-support/usl/usl_vtsw.c new file mode 100644 index 000000000..812e5bddb --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/usl/usl_vtsw.c @@ -0,0 +1,95 @@ +/* + * Copyright 2005 by Kean Johnston <jkj@sco.com> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1993 by David McCullough <davidm@stallion.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#include "X.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Handle the VT-switching interface for SCO UnixWare / OpenServer 6 + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. NOTE: we do NOT need + * to re-arm the signal here, since we used sigaction() to set the signal + * disposition in usl_init.c. If we had used signal(), we would need to + * re-arm the signal here. All we need to do now is record the fact that + * we got the signal. XFree86 handles the rest. + */ +void +xf86VTRequest(int sig) +{ + xf86Info.vtRequestsPending = TRUE; + return; +} + +Bool +xf86VTSwitchPending(void) +{ + return(xf86Info.vtRequestsPending ? TRUE : FALSE); +} + +static int usl_ledstatus = -1; +static unsigned int usl_ledstate = 0; + +Bool +xf86VTSwitchAway(void) +{ + usl_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &usl_ledstate); + + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) { + return(FALSE); + } else { + return(TRUE); + } +} + +Bool +xf86VTSwitchTo(void) +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) { + return(FALSE); + } else { + if (usl_ledstatus >= 0) { + ioctl (xf86Info.consoleFd, KDSETLED, usl_ledstate); + } + usl_ledstatus = -1; + + /* + * Convince the console driver this screen is in graphics mode, + * otherwise it assumes it can do more to the screen than it should. + */ + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { + ErrorF("Failed to set graphics mode (%s)\n", strerror(errno)); + } + + return TRUE; + } +} diff --git a/xorg-server/hw/xfree86/os-support/xf86OSmouse.h b/xorg-server/hw/xfree86/os-support/xf86OSmouse.h new file mode 100644 index 000000000..600683866 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/xf86OSmouse.h @@ -0,0 +1,294 @@ +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Public interface to OS-specific mouse support. */ + +#ifndef _XF86OSMOUSE_H_ +#define _XF86OSMOUSE_H_ + +#include "xf86Xinput.h" + +/* Mouse interface classes */ +#define MSE_NONE 0x00 +#define MSE_SERIAL 0x01 /* serial port */ +#define MSE_BUS 0x02 /* old bus mouse */ +#define MSE_PS2 0x04 /* standard read-only PS/2 */ +#define MSE_XPS2 0x08 /* extended PS/2 */ +#define MSE_AUTO 0x10 /* auto-detect (PnP) */ +#define MSE_MISC 0x20 /* The OS layer will identify the + * specific protocol names that are + * supported for this class. */ + +/* Mouse Protocol IDs. */ +typedef enum { + PROT_UNKNOWN = -2, + PROT_UNSUP = -1, /* protocol is not supported */ + PROT_MS = 0, + PROT_MSC, + PROT_MM, + PROT_LOGI, + PROT_LOGIMAN, + PROT_MMHIT, + PROT_GLIDE, + PROT_IMSERIAL, + PROT_THINKING, + PROT_ACECAD, + PROT_VALUMOUSESCROLL, + PROT_PS2, + PROT_GENPS2, + PROT_IMPS2, + PROT_EXPPS2, + PROT_THINKPS2, + PROT_MMPS2, + PROT_GLIDEPS2, + PROT_NETPS2, + PROT_NETSCPS2, + PROT_BM, + PROT_AUTO, + PROT_SYSMOUSE, + PROT_NUMPROTOS /* This must always be last. */ +} MouseProtocolID; + +struct _MouseDevRec; + +typedef int (*GetInterfaceTypesProc)(void); +typedef const char **(*BuiltinNamesProc)(void); +typedef Bool (*CheckProtocolProc)(const char *protocol); +typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol, + int flags); +typedef const char *(*DefaultProtocolProc)(void); +typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara); +typedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate, + int res); +typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol, + int flags); +typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags); + +/* + * OSMouseInfoRec is used to pass information from the OSMouse layer to the + * OS-independent mouse driver. + */ +typedef struct { + GetInterfaceTypesProc SupportedInterfaces; + BuiltinNamesProc BuiltinNames; + CheckProtocolProc CheckProtocol; + BuiltinPreInitProc PreInit; + DefaultProtocolProc DefaultProtocol; + SetupAutoProc SetupAuto; + SetResProc SetPS2Res; + SetResProc SetBMRes; + SetResProc SetMiscRes; + FindDeviceProc FindDevice; + GuessProtocolProc GuessProtocol; +} OSMouseInfoRec, *OSMouseInfoPtr; + +/* + * SupportedInterfaces: Returns the mouse interface types that the OS support. + * If MSE_MISC is returned, then the BuiltinNames and + * CheckProtocol should be set. + * + * BuiltinNames: Returns the names of the protocols that are fully handled + * in the OS-specific code. These are names that don't appear + * directly in the main "mouse" driver. + * + * CheckProtocol: Checks if the protocol name given is supported by the + * OS. It should return TRUE for both "builtin" protocols and + * protocols of type MSE_MISC that are supported by the OS. + * + * PreInit: The PreInit function for protocols that are builtin. This + * function is passed the protocol name. + * + * DefaultProtocol: Returns the name of a default protocol that should be used + * for the OS when none has been supplied in the config file. + * This should only be set when there is a reasonable default. + * + * SetupAuto: This function can be used to do OS-specific protocol + * auto-detection. It returns the name of the detected protocol, + * or NULL when detection fails. It may also adjust one or more + * of the "protoPara" values for the detected protocol by setting + * then to something other than -1. SetupAuto gets called in two + * ways. The first is before any devices have been opened. This + * can be used when the protocol "Auto" always maps to a single + * protocol type. The second is with the device open, allowing + * OS-specific probing to be done. + * + * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2 + * protocol types. + * + * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types. + * + * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types. + * + * FindDevice: This function gets called when no Device has been specified + * in the config file. OS-specific methods may be used to guess + * which input device to use. This function is called after the + * pre-open attempts at protocol discovery are done, but before + * the device is open. I.e., after the first SetupAuto() call, + * after the DefaultProtocol() call, but before the PreInit() + * call. Available protocol information may be used in locating + * the default input device. + * + * GuessProtocol: A last resort attempt at guessing the mouse protocol by + * whatever OS-specific means might be available. OS-independent + * things should be in the mouse driver. This function gets + * called after the mouse driver's OS-independent methods have + * failed. + */ + +extern OSMouseInfoPtr xf86OSMouseInit(int flags); + +/* Adjust this when the mouse interface changes. */ + +/* + * History: + * + * 1.0.0 - Everything up to when versioning was started. + * 1.1.0 - FindDevice and GuessProtocol added to OSMouseInfoRec + * 1.2.0 - xisbscale added to MouseDevRec + * + */ + +#define OS_MOUSE_VERSION_MAJOR 1 +#define OS_MOUSE_VERSION_MINOR 2 +#define OS_MOUSE_VERSION_PATCH 0 + +#define OS_MOUSE_VERSION_CURRENT \ + BUILTIN_INTERFACE_VERSION_NUMERIC(OS_MOUSE_VERSION_MAJOR, \ + OS_MOUSE_VERSION_MINOR, \ + OS_MOUSE_VERSION_PATCH) + +#define HAVE_GUESS_PROTOCOL \ + (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \ + BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0)) + +#define HAVE_FIND_DEVICE \ + (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \ + BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0)) + +/* Z axis mapping */ +#define MSE_NOZMAP 0 +#define MSE_MAPTOX -1 +#define MSE_MAPTOY -2 +#define MSE_MAPTOZ -3 +#define MSE_MAPTOW -4 + +/* Generalize for other axes. */ +#define MSE_NOAXISMAP MSE_NOZMAP + +#define MSE_MAXBUTTONS 24 +#define MSE_DFLTBUTTONS 3 + +/* + * Mouse device record. This is shared by the mouse driver and the OSMouse + * layer. + */ + +typedef void (*checkMovementsProc)(InputInfoPtr,int, int); +typedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool); +typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char); +typedef Bool (*dataGoodProc)(struct _MouseDevRec *); + +typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons, + int dx, int dy, int dz, int dw); +typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo); + +typedef struct _MouseDevRec { + PtrCtrlProcPtr Ctrl; + PostMseEventProc PostEvent; + MouseCommonOptProc CommonOptions; + DeviceIntPtr device; + const char * mseDevice; + const char * protocol; + MouseProtocolID protocolID; + MouseProtocolID oldProtocolID; /* hack */ + int class; + int mseModel; + int baudRate; + int oldBaudRate; + int sampleRate; + int lastButtons; + int threshold; /* acceleration */ + int num; + int den; + int buttons; /* # of buttons */ + int emulateState; /* automata state for 2 button mode */ + Bool emulate3Buttons; + Bool emulate3ButtonsSoft; + int emulate3Timeout;/* Timeout for 3 button emulation */ + Bool chordMiddle; + Bool flipXY; + int invX; + int invY; + int mouseFlags; /* Flags to Clear after opening + * mouse dev */ + int truebuttons; /* (not used) + * Arg to maintain before + * emulate3buttons timer callback */ + int resolution; + int negativeZ; /* button mask */ + int positiveZ; /* button mask */ + int negativeW; /* button mask */ + int positiveW; /* button mask */ + pointer buffer; /* usually an XISBuffer* */ + int protoBufTail; + unsigned char protoBuf[8]; + unsigned char protoPara[8]; + unsigned char inSync; /* driver in sync with datastream */ + pointer mousePriv; /* private area */ + InputInfoPtr pInfo; + int origProtocolID; + const char * origProtocol; + Bool emulate3Pending;/* timer waiting */ + CARD32 emulate3Expires;/* time to fire emulation code */ + Bool emulateWheel; + int wheelInertia; + int wheelButton; + int negativeX; /* Button values. Unlike the Z and */ + int positiveX; /* W equivalents, these are button */ + int negativeY; /* values rather than button masks. */ + int positiveY; + int wheelYDistance; + int wheelXDistance; + Bool autoProbe; + checkMovementsProc checkMovements; + autoProbeProc autoProbeMouse; + collectDataProc collectData; + dataGoodProc dataGood; + int angleOffset; + pointer pDragLock; /* drag lock area */ + int xisbscale; /* buffer size for 1 event */ + int wheelButtonTimeout;/* Timeout for the wheel button emulation */ + CARD32 wheelButtonExpires; + int doubleClickSourceButtonMask; + int doubleClickTargetButton; + int doubleClickTargetButtonMask; + int doubleClickOldSourceState; + int lastMappedButtons; + int buttonMap[MSE_MAXBUTTONS]; +} MouseDevRec, *MouseDevPtr; + +#endif /* _XF86OSMOUSE_H_ */ diff --git a/xorg-server/hw/xfree86/os-support/xf86OSpriv.h b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h new file mode 100644 index 000000000..754128de9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1999-2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _XF86OSPRIV_H +#define _XF86OSPRIV_H + +typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long, int); +typedef void (*UnmapMemProcPtr)(int, pointer, unsigned long); +typedef pointer (*SetWCProcPtr)(int, unsigned long, unsigned long, Bool, + MessageType); +typedef void (*ProtectMemProcPtr)(int, pointer, unsigned long, Bool); +typedef void (*UndoWCProcPtr)(int, pointer); +typedef void (*ReadSideEffectsProcPtr)(int, pointer, unsigned long); + +typedef struct { + Bool initialised; + MapMemProcPtr mapMem; + UnmapMemProcPtr unmapMem; + ProtectMemProcPtr protectMem; + SetWCProcPtr setWC; + UndoWCProcPtr undoWC; + ReadSideEffectsProcPtr readSideEffects; + Bool linearSupported; +} VidMemInfo, *VidMemInfoPtr; + +void xf86OSInitVidMem(VidMemInfoPtr); + +#endif /* _XF86OSPRIV_H */ diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h new file mode 100644 index 000000000..aba47581f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h @@ -0,0 +1,683 @@ +/* + * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1992 by David Dawes <dawes@XFree86.org> + * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu> + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> + * Copyright 1992 by Orest Zborowski <obz@eskimo.com> + * Copyright 1993 by Vrije Universiteit, The Netherlands + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de> + * Copyright 1997 by Takis Psarogiannakopoulos <takis@dpmms.cam.ac.uk> + * Copyright 1994-2003 by The XFree86 Project, 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 names of the above listed copyright holders + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holders make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS 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. + * + */ + +/* + * The ARM32 code here carries the following copyright: + * + * Copyright 1997 + * Digital Equipment Corporation. All rights reserved. + * This software is furnished under license and may be used and copied only in + * accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * this software in source and/or binary form. No title or ownership is + * transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and retain + * this copyright notice and list of conditions as they appear in the + * source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of Digital + * Equipment Corporation. Neither the "Digital Equipment Corporation" + * name nor any trademark or logo of Digital Equipment Corporation may be + * used to endorse or promote products derived from this software without + * the prior written permission of Digital Equipment Corporation. + * + * 3) This software is provided "AS-IS" and any express or implied warranties, + * including but not limited to, any implied warranties of merchantability, + * fitness for a particular purpose, or non-infringement are disclaimed. + * In no event shall DIGITAL be liable for any damages whatsoever, and in + * particular, DIGITAL shall not be liable for special, indirect, + * consequential, or incidental damages or damages for lost profits, loss + * of revenue or loss of use, whether such damages arise in contract, + * negligence, tort, under statute, in equity, at law or otherwise, even + * if advised of the possibility of such damage. + * + */ + +/* + * This is private, and should not be included by any drivers. Drivers + * may include xf86_OSproc.h to get prototypes for public interfaces. + */ + +#ifndef _XF86_OSLIB_H +#define _XF86_OSLIB_H + +#include <X11/Xos.h> +#include <X11/Xfuncproto.h> + +#include <stdio.h> +#include <ctype.h> +#include <stddef.h> + +/**************************************************************************/ +/* SYSV386 (SVR3, SVR4), including Solaris */ +/**************************************************************************/ +#if (defined(SYSV) || defined(SVR4)) && \ + !defined(DGUX) && !defined(sgi) && \ + (defined(sun) || defined(__i386__)) +# ifdef SCO325 +# ifndef _SVID3 +# define _SVID3 +# endif +# ifndef _NO_STATIC +# define _NO_STATIC +# endif +# endif +# include <sys/ioctl.h> +# include <signal.h> +# include <termio.h> +# include <sys/stat.h> +# include <sys/types.h> +# if defined(__SCO__) || defined(ISC) +# include <sys/param.h> +# endif + +# ifdef ISC +# define TIOCMSET (TIOC|26) /* set all modem bits */ +# define TIOCMBIS (TIOC|27) /* bis modem bits */ +# define TIOCMBIC (TIOC|28) /* bic modem bits */ +# define TIOCMGET (TIOC|29) /* get all modem bits */ +# endif + +# include <errno.h> + +# if defined(_NEED_SYSI86) +# if !(defined (sun) && defined (SVR4)) +# include <sys/immu.h> +# include <sys/region.h> +# endif +# include <sys/proc.h> +# include <sys/tss.h> +# include <sys/sysi86.h> +# if defined(SVR4) && !defined(sun) +# include <sys/seg.h> +# endif /* SVR4 && !sun */ +/* V86SC_IOPL was moved to <sys/sysi86.h> on Solaris 7 and later */ +# if defined(sun) && defined (SVR4) /* Solaris? */ +# if defined(__i386__) || defined(__i386) || defined(__x86) /* on x86 or x64? */ +# if !defined(V86SC_IOPL) /* Solaris 7 or later? */ +# include <sys/v86.h> /* Nope */ +# endif +# endif /* V86SC_IOPL */ +# else +# include <sys/v86.h> /* Not solaris */ +# endif /* sun && i386 && SVR4 */ +# if defined(sun) && (defined (__i386__) || defined(__i386) || defined(__x86)) && defined (SVR4) +# include <sys/psw.h> +# endif +# endif /* _NEED_SYSI86 */ + +# if defined(HAS_SVR3_MMAPDRV) +# include <sys/sysmacros.h> +# if !defined(_NEED_SYSI86) +# include <sys/immu.h> +# include <sys/region.h> +# endif +# include <sys/mmap.h> /* MMAP driver header */ +# endif + +# if !defined(sun) || (!defined(sparc) && !defined(__SOL8__)) +# define HAS_USL_VTS +# endif +# if !defined(sun) +# include <sys/emap.h> +# endif +# if defined(SCO325) +# include <sys/vtkd.h> +# include <sys/console.h> +# include <sys/scankbd.h> +# include <sys/vid.h> +# define LED_CAP CLKED +# define LED_NUM NLKED +# define LED_SCR SLKED +# elif defined(HAS_USL_VTS) +# include <sys/at_ansi.h> +# include <sys/kd.h> +# include <sys/vt.h> +# elif defined(sun) +# include <sys/fbio.h> +# include <sys/kbd.h> +# include <sys/kbio.h> + +/* undefine symbols from <sys/kbd.h> we don't need that conflict with enum + definitions in parser/xf86tokens.h */ +# undef STRING +# undef LEFTALT +# undef RIGHTALT + +# define LED_CAP LED_CAPS_LOCK +# define LED_NUM LED_NUM_LOCK +# define LED_SCR LED_SCROLL_LOCK +# define LED_COMP LED_COMPOSE +# endif /* sun */ + +# if !defined(VT_ACKACQ) +# define VT_ACKACQ 2 +# endif /* !VT_ACKACQ */ + +# if defined(__SCO__) +# include <sys/sysmacros.h> +# define POSIX_TTY +# endif /* __SCO__ */ + +# if defined(SVR4) || defined(SCO325) +# include <sys/mman.h> +# if !(defined(sun) && defined (SVR4)) +# define DEV_MEM "/dev/pmem" +# endif +# ifdef SCO325 +# undef DEV_MEM +# define DEV_MEM "/dev/mem" +# endif +# define CLEARDTR_SUPPORT +# define POSIX_TTY +# endif /* SVR4 */ + +# ifdef ISC +# include <termios.h> +# define POSIX_TTY +# endif + +# if defined(sun) && (defined (__i386__) || defined(__i386)) && defined (SVR4) && !defined(__SOL8__) +# define USE_VT_SYSREQ +# define VT_SYSREQ_DEFAULT TRUE +# endif + +# ifdef SYSV +# if !defined(ISC) || defined(ISC202) || defined(ISC22) +# define NEED_STRERROR +# endif +# endif + +#endif /* (SYSV || SVR4) && !DGUX */ + + + +/**************************************************************************/ +/* DG/ux R4.20MU03 Intel AViion Machines */ +/**************************************************************************/ +#if defined(DGUX) && defined(SVR4) +#include <sys/ioctl.h> +#include <signal.h> +#include <ctype.h> +#include <termios.h> /* Use termios for BSD Flavor ttys */ +#include <sys/termios.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/param.h> +#include <errno.h> +#include <sys/sysi86.h> +#include <unistd.h> +#include <sys/proc.h> +#include <sys/map.h> +#include <sys/sysmacros.h> +#include <sys/mman.h> /* Memory handling */ +#include <sys/kd.h> /* definitios for KDENABIO KDDISABIO needed for IOPL s */ +#include <sys/kbd.h> +#include <fcntl.h> +#include <time.h> +#include <sys/stream.h> +#include <sys/ptms.h> + +#include <sys/socket.h> +#include <sys/utsname.h> +#include <sys/stropts.h> +#include <sys/sockio.h> + + +#define POSIX_TTY + +#undef HAS_USL_VTS +#undef USE_VT_SYSREQ +#undef VT_ACKACQ + +#define LED_CAP KBD_LED_CAPS_LOCK +#define LED_NUM KBD_LED_NUM_LOCK +#define LED_SCR KBD_LED_SCROLL_LOCK + +#define KDGKBTYPE KBD_GET_LANGUAGE + + +/* General keyboard types */ +# define KB_84 2 +# define KB_101 1 /* Because ioctl(dgkeybdFd,KBD_GET_LANGUAGE,&type) gives 1=US keyboard */ +# define KB_OTHER 3 + +#define KDSETLED KBD_SET_LED +#define KDGETLED KBD_GET_STATE +#undef KDMKTONE +#define KDMKTONE KBD_TONE_HIGH + + +#undef DEV_MEM +#define DEV_MEM "/dev/mem" +#define CLEARDTR_SUPPORT + +#undef VT_SYSREQ_DEFAULT +#define VT_SYSREQ_DEFAULT FALSE /* Make sure that we dont define any VTs since DG/ux has none */ + +#endif /* DGUX && SVR4 */ + +/**************************************************************************/ +/* Linux or Glibc-based system */ +/**************************************************************************/ +#if defined(__linux__) || defined(__GLIBC__) +# include <sys/ioctl.h> +# include <signal.h> +# include <stdlib.h> +# include <sys/types.h> +# include <assert.h> + +#ifdef __GNU__ /* GNU/Hurd */ +# define USE_OSMOUSE +#endif + +# ifdef __linux__ +# include <termio.h> +# else /* __GLIBC__ */ +# include <termios.h> +# endif +# ifdef __sparc__ +# include <sys/param.h> +# endif + +# include <errno.h> + +# include <sys/stat.h> + +# include <sys/mman.h> +# ifdef __linux__ +# define HAS_USL_VTS +# include <sys/kd.h> +# include <sys/vt.h> +# define LDGMAP GIO_SCRNMAP +# define LDSMAP PIO_SCRNMAP +# define LDNMAP LDSMAP +# define CLEARDTR_SUPPORT +# define USE_VT_SYSREQ +# endif + +# define POSIX_TTY + +#endif /* __linux__ || __GLIBC__ */ + +/**************************************************************************/ +/* LynxOS AT */ +/**************************************************************************/ +#if defined(Lynx) + +# include <termio.h> +# include <sys/ioctl.h> +# include <param.h> +# include <signal.h> +# include <kd.h> +# include <vt.h> +# include <sys/stat.h> + +# include <errno.h> +extern int errno; + +/* smem_create et.al. to access physical memory */ +# include <smem.h> + +/* keyboard types */ +# define KB_84 1 +# define KB_101 2 +# define KB_OTHER 3 + +/* atc drivers ignores argument to VT_RELDISP ioctl */ +# define VT_ACKACQ 2 + +# include <termios.h> +# define POSIX_TTY +# define CLEARDTR_SUPPORT + +/* LynxOS 2.5.1 has these */ +# ifdef LED_NUMLOCK +# define LED_CAP LED_CAPSLOCK +# define LED_NUM LED_NUMLOCK +# define LED_SCR LED_SCROLLOCK +# endif + +#endif /* Lynx */ + +/**************************************************************************/ +/* 386BSD and derivatives, BSD/386 */ +/**************************************************************************/ + +#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__)) +# undef __386BSD__ +#endif + +#ifdef CSRG_BASED +# include <sys/ioctl.h> +# include <signal.h> + +# include <termios.h> +# define termio termios +# define POSIX_TTY + +# include <errno.h> + +# include <sys/types.h> +# include <sys/mman.h> +# include <sys/stat.h> + +# if defined(__bsdi__) +# include <sys/param.h> +# if (_BSDI_VERSION < 199510) +# include <i386/isa/vgaioctl.h> +# endif +# endif /* __bsdi__ */ + +#endif /* CSRG_BASED */ + +/**************************************************************************/ +/* Kernel of *BSD */ +/**************************************************************************/ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) + +# include <sys/param.h> +# if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version) +# define __FreeBSD_kernel_version __FreeBSD_version +# endif + +# if !defined(LINKKIT) + /* Don't need this stuff for the Link Kit */ +# if defined(__bsdi__) +# include <i386/isa/pcconsioctl.h> +# define CONSOLE_X_MODE_ON PCCONIOCRAW +# define CONSOLE_X_MODE_OFF PCCONIOCCOOK +# define CONSOLE_X_BELL PCCONIOCBEEP +# else /* __bsdi__ */ +# if defined(__OpenBSD__) +# ifdef PCCONS_SUPPORT +# include <machine/pccons.h> +# undef CONSOLE_X_MODE_ON +# undef CONSOLE_X_MODE_OFF +# undef CONSOLE_X_BELL +# endif +# endif +# ifdef SYSCONS_SUPPORT +# define COMPAT_SYSCONS +# if defined(__NetBSD__) || defined(__OpenBSD__) +# include <machine/console.h> +# else +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +# if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000) +# include <sys/consio.h> +# include <sys/kbio.h> +# else +# include <machine/console.h> +# endif /* FreeBSD 4.1 RELEASE or lator */ +# else +# include <sys/console.h> +# endif +# endif +# endif /* SYSCONS_SUPPORT */ +# if defined(PCVT_SUPPORT) +# if !defined(SYSCONS_SUPPORT) + /* no syscons, so include pcvt specific header file */ +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include <machine/pcvt_ioctl.h> +# else +# if defined(__NetBSD__) || defined(__OpenBSD__) +# if !defined(WSCONS_SUPPORT) +# include <machine/pcvt_ioctl.h> +# endif /* WSCONS_SUPPORT */ +# else +# include <sys/pcvt_ioctl.h> +# endif /* __NetBSD__ */ +# endif /* __FreeBSD_kernel__ || __OpenBSD__ */ +# else /* pcvt and syscons: hard-code the ID magic */ +# define VGAPCVTID _IOWR('V',113, struct pcvtid) + struct pcvtid { + char name[16]; + int rmajor, rminor; + }; +# endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */ +# endif /* PCVT_SUPPORT */ +# ifdef WSCONS_SUPPORT +# include <dev/wscons/wsconsio.h> +# include <dev/wscons/wsdisplay_usl_io.h> +# endif /* WSCONS_SUPPORT */ +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +# if defined(__FreeBSD_kernel_version) && (__FreeBSD_kernel_version >= 500013) +# include <sys/mouse.h> +# else +# undef MOUSE_GETINFO +# include <machine/mouse.h> +# endif +# endif + /* Include these definitions in case ioctl_pc.h didn't get included */ +# ifndef CONSOLE_X_MODE_ON +# define CONSOLE_X_MODE_ON _IO('t',121) +# endif +# ifndef CONSOLE_X_MODE_OFF +# define CONSOLE_X_MODE_OFF _IO('t',122) +# endif +# ifndef CONSOLE_X_BELL +# define CONSOLE_X_BELL _IOW('t',123,int[2]) +# endif +# ifndef CONSOLE_X_TV_ON +# define CONSOLE_X_TV_ON _IOW('t',155,int) +# define XMODE_RGB 0 +# define XMODE_NTSC 1 +# define XMODE_PAL 2 +# define XMODE_SECAM 3 +# endif +# ifndef CONSOLE_X_TV_OFF +# define CONSOLE_X_TV_OFF _IO('t',156) +# endif +#ifndef CONSOLE_GET_LINEAR_INFO +# define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info) +#endif +#ifndef CONSOLE_GET_IO_INFO +# define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info) +#endif +#ifndef CONSOLE_GET_MEM_INFO +# define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info) +#endif +# endif /* __bsdi__ */ +# endif /* !LINKKIT */ + +#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL) +#include <machine/sysarch.h> +#endif + +# define CLEARDTR_SUPPORT + +# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) +# define USE_VT_SYSREQ +# endif + +#endif +/* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ || __bsdi__ */ + +/**************************************************************************/ +/* QNX4 */ +/**************************************************************************/ +/* This is the QNX code for Watcom 10.6 and QNX 4.x */ +#if defined(QNX4) +#include <signal.h> +#include <errno.h> +#include <sys/stat.h> +#include <termios.h> +#include <ioctl.h> +#include <sys/param.h> + +/* Warning: by default, the fd_set size is 32 in QNX! */ +#define FD_SETSIZE 256 +#include <sys/select.h> + + /* keyboard types */ +# define KB_84 1 +# define KB_101 2 +# define KB_OTHER 3 + + /* LEDs */ +# define LED_CAP 0x04 +# define LED_NUM 0x02 +# define LED_SCR 0x01 + +# define POSIX_TTY +# define OSMOUSE_ONLY +# define MOUSE_PROTOCOL_IN_KERNEL + +#define TIOCM_DTR 0x0001 /* data terminal ready */ +#define TIOCM_RTS 0x0002 /* request to send */ +#define TIOCM_CTS 0x1000 /* clear to send */ +#define TIOCM_DSR 0x2000 /* data set ready */ +#define TIOCM_RI 0x4000 /* ring */ +#define TIOCM_RNG TIOCM_RI +#define TIOCM_CD 0x8000 /* carrier detect */ +#define TIOCM_CAR TIOCM_CD +#define TIOCM_LE 0x0100 /* line enable */ +#define TIOCM_ST 0x0200 /* secondary transmit */ +#define TIOCM_SR 0x0400 /* secondary receive */ + +#endif + +/**************************************************************************/ +/* QNX/Neutrino */ +/**************************************************************************/ +/* This is the Neutrino code for for NTO2.0 and GCC */ +#if defined(__QNXNTO__) +#include <signal.h> +#include <errno.h> +#include <sys/stat.h> +#include <termios.h> +#include <ioctl.h> +#include <sys/param.h> + +/* Warning: by default, the fd_set size is 32 in NTO! */ +#define FD_SETSIZE 256 +#include <sys/select.h> + + /* keyboard types */ +# define KB_84 1 +# define KB_101 2 +# define KB_OTHER 3 + +# define POSIX_TTY + +#endif + +/**************************************************************************/ +/* IRIX */ +/**************************************************************************/ +#if defined(sgi) + +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> + +#endif + +/**************************************************************************/ +/* Generic */ +/**************************************************************************/ + +#include <sys/wait.h> /* May need to adjust this for other OSs */ + +/* + * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere, + * and it's safe, so just do it. + */ +#if !defined(O_NDELAY) && defined(O_NONBLOCK) +# define O_NDELAY O_NONBLOCK +#endif /* !O_NDELAY && O_NONBLOCK */ + +#if !defined(MAXHOSTNAMELEN) +# define MAXHOSTNAMELEN 32 +#endif /* !MAXHOSTNAMELEN */ + +#if !defined(X_NOT_POSIX) +# if defined(_POSIX_SOURCE) +# include <limits.h> +# else +# define _POSIX_SOURCE +# include <limits.h> +# undef _POSIX_SOURCE +# endif /* _POSIX_SOURCE */ +#endif /* !X_NOT_POSIX */ +#if !defined(PATH_MAX) +# if defined(MAXPATHLEN) +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 1024 +# endif /* MAXPATHLEN */ +#endif /* !PATH_MAX */ + +#ifdef NEED_STRERROR +# ifndef strerror +extern char *sys_errlist[]; +extern int sys_nerr; +# define strerror(n) \ + ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error" +# endif /* !strerror */ +#endif /* NEED_STRERROR */ + +#if defined(ISC) || defined(Lynx) +#define rint(x) RInt(x) +double RInt( + double x +); +#endif + +#ifndef DEV_MEM +#define DEV_MEM "/dev/mem" +#endif + +#ifndef VT_SYSREQ_DEFAULT +#define VT_SYSREQ_DEFAULT FALSE +#endif + +#ifdef OSMOUSE_ONLY +# ifndef MOUSE_PROTOCOL_IN_KERNEL +# define MOUSE_PROTOCOL_IN_KERNEL +# endif +#endif + +#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) + +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" + +#ifndef NO_COMPILER_H +#include "compiler.h" +#endif + +#endif /* _XF86_OSLIB_H */ diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h new file mode 100644 index 000000000..abf5a47c2 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h @@ -0,0 +1,248 @@ +/* + * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1992 by David Dawes <dawes@XFree86.org> + * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu> + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> + * Copyright 1992 by Orest Zborowski <obz@eskimo.com> + * Copyright 1993 by Vrije Universiteit, The Netherlands + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de> + * Copyright 1994-2003 by The XFree86 Project, 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 names of the above listed copyright holders + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holders make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS 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. + * + */ + +/* + * The ARM32 code here carries the following copyright: + * + * Copyright 1997 + * Digital Equipment Corporation. All rights reserved. + * This software is furnished under license and may be used and copied only in + * accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * this software in source and/or binary form. No title or ownership is + * transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and retain + * this copyright notice and list of conditions as they appear in the + * source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of Digital + * Equipment Corporation. Neither the "Digital Equipment Corporation" + * name nor any trademark or logo of Digital Equipment Corporation may be + * used to endorse or promote products derived from this software without + * the prior written permission of Digital Equipment Corporation. + * + * 3) This software is provided "AS-IS" and any express or implied warranties, + * including but not limited to, any implied warranties of merchantability, + * fitness for a particular purpose, or non-infringement are disclaimed. + * In no event shall DIGITAL be liable for any damages whatsoever, and in + * particular, DIGITAL shall not be liable for special, indirect, + * consequential, or incidental damages or damages for lost profits, loss + * of revenue or loss of use, whether such damages arise in contract, + * negligence, tort, under statute, in equity, at law or otherwise, even + * if advised of the possibility of such damage. + * + */ + + +#ifndef _XF86_OSPROC_H +#define _XF86_OSPROC_H + +#ifdef XF86_OS_PRIVS +#include "xf86Pci.h" +#endif + +/* + * The actual prototypes have been pulled into this seperate file so + * that they can can be used without pulling in all of the OS specific + * stuff like sys/stat.h, etc. This casues problem for loadable modules. + */ + +/* + * Flags for xf86MapVidMem(). Multiple flags can be or'd together. The + * flags may be used as hints. For example it would be permissible to + * enable write combining for memory marked only for framebuffer use. + */ + +#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */ +#define VIDMEM_MMIO 0x02 /* memory for I/O use */ +#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */ +#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */ +#define VIDMEM_SPARSE 0x10 /* sparse mapping required + * assumed when VIDMEM_MMIO is + * set. May be used with + * VIDMEM_FRAMEBUFFER) */ +#define VIDMEM_READONLY 0x20 /* read-only mapping + * used when reading BIOS images + * through xf86MapVidMem() */ + +/* + * OS-independent modem state flags for xf86SetSerialModemState() and + * xf86GetSerialModemState(). + */ +#define XF86_M_LE 0x001 /* line enable */ +#define XF86_M_DTR 0x002 /* data terminal ready */ +#define XF86_M_RTS 0x004 /* request to send */ +#define XF86_M_ST 0x008 /* secondary transmit */ +#define XF86_M_SR 0x010 /* secondary receive */ +#define XF86_M_CTS 0x020 /* clear to send */ +#define XF86_M_CAR 0x040 /* carrier detect */ +#define XF86_M_RNG 0x080 /* ring */ +#define XF86_M_DSR 0x100 /* data set ready */ + +#ifdef XF86_OS_PRIVS +extern void xf86WrapperInit(void); +#endif + +#ifndef NO_OSLIB_PROTOTYPES +/* + * This is to prevent re-entrancy to FatalError() when aborting. + * Anything that can be called as a result of AbortDDX() should use this + * instead of FatalError(). + */ + +#define xf86FatalError(a, b) \ + if (dispatchException & DE_TERMINATE) { \ + ErrorF(a, b); \ + ErrorF("\n"); \ + return; \ + } else FatalError(a, b) + +/***************************************************************************/ +/* Prototypes */ +/***************************************************************************/ + +#include <X11/Xfuncproto.h> +#include "opaque.h" + +_XFUNCPROTOBEGIN + +/* public functions */ +extern Bool xf86LinearVidMem(void); +extern Bool xf86CheckMTRR(int); +extern pointer xf86MapVidMem(int, int, unsigned long, unsigned long); +extern void xf86UnMapVidMem(int, pointer, unsigned long); +extern void xf86MapReadSideEffects(int, int, pointer, unsigned long); +extern int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int); +extern Bool xf86EnableIO(void); +extern void xf86DisableIO(void); +extern Bool xf86DisableInterrupts(void); +extern void xf86EnableInterrupts(void); +extern void xf86SetTVOut(int); +extern void xf86SetRGBOut(void); +extern void xf86OSRingBell(int, int, int); +#if defined(QNX4) +#pragma aux xf86BusToMem modify [eax ebx ecx edx esi edi]; +#pragma aux xf86MemToBus modify [eax ebx ecx edx esi edi]; +#endif +extern void xf86BusToMem(unsigned char *, unsigned char *, int); +extern void xf86MemToBus(unsigned char *, unsigned char *, int); +extern void xf86IODelay(void); +extern void xf86UDelay(long usec); +extern void xf86SetReallySlowBcopy(void); +extern void xf86SlowBcopy(unsigned char *, unsigned char *, int); +extern int xf86OpenSerial(pointer options); +extern int xf86SetSerial(int fd, pointer options); +extern int xf86SetSerialSpeed(int fd, int speed); +extern int xf86ReadSerial(int fd, void *buf, int count); +extern int xf86WriteSerial(int fd, const void *buf, int count); +extern int xf86CloseSerial(int fd); +extern int xf86FlushInput(int fd); +extern int xf86WaitForInput(int fd, int timeout); +extern int xf86SerialSendBreak(int fd, int duration); +extern int xf86SetSerialModemState(int fd, int state); +extern int xf86GetSerialModemState(int fd); +extern int xf86SerialModemSetBits(int fd, int bits); +extern int xf86SerialModemClearBits(int fd, int bits); +extern int xf86LoadKernelModule(const char *pathname); +extern void xf86RingBell(int volume, int pitch, int duration); + +/* AGP GART interface */ + +typedef struct _AgpInfo { + CARD32 bridgeId; + CARD32 agpMode; + unsigned long base; + unsigned long size; + unsigned long totalPages; + unsigned long systemPages; + unsigned long usedPages; +} AgpInfo, *AgpInfoPtr; + +extern Bool xf86AgpGARTSupported(void); +extern AgpInfoPtr xf86GetAGPInfo(int screenNum); +extern Bool xf86AcquireGART(int screenNum); +extern Bool xf86ReleaseGART(int screenNum); +extern int xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical); +extern Bool xf86DeallocateGARTMemory(int screenNum, int key); +extern Bool xf86BindGARTMemory(int screenNum, int key, unsigned long offset); +extern Bool xf86UnbindGARTMemory(int screenNum, int key); +extern Bool xf86EnableAGP(int screenNum, CARD32 mode); +extern Bool xf86GARTCloseScreen(int screenNum); + +/* These routines are in shared/sigio.c and are not loaded as part of the + module. These routines are small, and the code if very POSIX-signal (or + OS-signal) specific, so it seemed better to provide more complex + wrappers than to wrap each individual function called. */ +extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); +extern int xf86RemoveSIGIOHandler(int fd); +extern int xf86BlockSIGIO (void); +extern void xf86UnblockSIGIO (int); +extern void xf86AssertBlockedSIGIO (char *); +extern Bool xf86SIGIOSupported (void); + +#ifdef XF86_OS_PRIVS +typedef void (*PMClose)(void); +extern void xf86OpenConsole(void); +extern void xf86CloseConsole(void); +extern Bool xf86VTSwitchPending(void); +extern Bool xf86VTSwitchAway(void); +extern Bool xf86VTSwitchTo(void); +extern void xf86VTRequest(int sig); +extern int xf86ProcessArgument(int, char **, int); +extern void xf86UseMsg(void); +extern void xf86ReloadInputDevs(int sig); +extern PMClose xf86OSPMOpen(void); + +#ifdef NEED_OS_RAC_PROTOS +/* RAC-related privs */ +/* internal to os-support layer */ +resPtr xf86StdAccResFromOS(resPtr ret); + +/* available to the common layer */ +resPtr xf86AccResFromOS(resPtr ret); +#endif /* NEED_OS_RAC_PROTOS */ + +extern unsigned long xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base); + +extern void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer); +extern void xf86InitVidMem(void); + +#endif /* XF86_OS_PRIVS */ + + +_XFUNCPROTOEND +#endif /* NO_OSLIB_PROTOTYPES */ + +#endif /* _XF86_OSPROC_H */ diff --git a/xorg-server/hw/xfree86/os-support/xorgos.c b/xorg-server/hw/xfree86/os-support/xorgos.c new file mode 100644 index 000000000..e69de29bb diff --git a/xorg-server/hw/xfree86/osandcommon.c b/xorg-server/hw/xfree86/osandcommon.c new file mode 100644 index 000000000..e69de29bb diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h new file mode 100644 index 000000000..684a001fc --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Configint.h @@ -0,0 +1,226 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* + * These definitions are used through out the configuration file parser, but + * they should not be visible outside of the parser. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _Configint_h_ +#define _Configint_h_ + +#include <stdio.h> +#include <string.h> +#include <stdarg.h> +#include <stddef.h> +#include "xf86Parser.h" + +typedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType; + +typedef struct +{ + int num; /* returned number */ + char *str; /* private copy of the return-string */ + double realnum; /* returned number as a real */ + ParserNumType numType; /* used to enforce correct number formatting */ +} +LexRec, *LexPtr; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#include "configProcs.h" +#include <stdlib.h> +#define xf86confmalloc malloc +#define xf86confrealloc realloc +#define xf86confcalloc calloc +#define xf86conffree free + +#define TestFree(a) if (a) { xf86conffree (a); a = NULL; } + +#define parsePrologue(typeptr,typerec) typeptr ptr; \ +if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return NULL; } \ +memset(ptr,0,sizeof(typerec)); + +#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \ +if( (ptr=(typeptr)xf86confcalloc(1,sizeof(typerec))) == NULL ) { return; } \ +memset(ptr,0,sizeof(typerec)); + +#define HANDLE_RETURN(f,func)\ +if ((ptr->f=func) == NULL)\ +{\ + CLEANUP (ptr);\ + return (NULL);\ +} + +#define HANDLE_LIST(field,func,type)\ +{\ +type p = func ();\ +if (p == NULL)\ +{\ + CLEANUP (ptr);\ + return (NULL);\ +}\ +else\ +{\ + ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\ +}\ +} + +#define Error(a,b) do { \ + xf86parseError (a, b); CLEANUP (ptr); return NULL; \ + } while (0) + +/* + * These are defines for error messages to promote consistency. + * error messages are preceded by the line number, section and file name, + * so these messages should be about the specific keyword and syntax in error. + * To help limit namespace polution, end each with _MSG. + * limit messages to 70 characters if possible. + */ + +#define BAD_OPTION_MSG \ +"The Option keyword requires 1 or 2 quoted strings to follow it." +#define INVALID_KEYWORD_MSG \ +"\"%s\" is not a valid keyword in this section." +#define INVALID_SECTION_MSG \ +"\"%s\" is not a valid section name." +#define UNEXPECTED_EOF_MSG \ +"Unexpected EOF. Missing EndSection keyword?" +#define QUOTE_MSG \ +"The %s keyword requires a quoted string to follow it." +#define NUMBER_MSG \ +"The %s keyword requires a number to follow it." +#define POSITIVE_INT_MSG \ +"The %s keyword requires a positive integer to follow it." +#define ZAXISMAPPING_MSG \ +"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it." +#define AUTOREPEAT_MSG \ +"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it." +#define XLEDS_MSG \ +"The XLeds keyword requries one or more numbers to follow it." +#define DACSPEED_MSG \ +"The DacSpeed keyword must be followed by a list of up to %d numbers." +#define DISPLAYSIZE_MSG \ +"The DisplaySize keyword must be followed by the width and height in mm." +#define HORIZSYNC_MSG \ +"The HorizSync keyword must be followed by a list of numbers or ranges." +#define VERTREFRESH_MSG \ +"The VertRefresh keyword must be followed by a list of numbers or ranges." +#define VIEWPORT_MSG \ +"The Viewport keyword must be followed by an X and Y value." +#define VIRTUAL_MSG \ +"The Virtual keyword must be followed by a width and height value." +#define WEIGHT_MSG \ +"The Weight keyword must be followed by red, green and blue values." +#define BLACK_MSG \ +"The Black keyword must be followed by red, green and blue values." +#define WHITE_MSG \ +"The White keyword must be followed by red, green and blue values." +#define SCREEN_MSG \ +"The Screen keyword must be followed by an optional number, a screen name\n" \ +"\tin quotes, and optional position/layout information." +#define INVALID_SCR_MSG \ +"Invalid Screen line." +#define INPUTDEV_MSG \ +"The InputDevice keyword must be followed by an input device name in quotes." +#define INACTIVE_MSG \ +"The Inactive keyword must be followed by a Device name in quotes." +#define UNDEFINED_SCREEN_MSG \ +"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"." +#define UNDEFINED_MODES_MSG \ +"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"." +#define UNDEFINED_DEVICE_MSG \ +"Undefined Device \"%s\" referenced by Screen \"%s\"." +#define UNDEFINED_ADAPTOR_MSG \ +"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"." +#define ADAPTOR_REF_TWICE_MSG \ +"VideoAdaptor \"%s\" already referenced by Screen \"%s\"." +#define UNDEFINED_DEVICE_LAY_MSG \ +"Undefined Device \"%s\" referenced by ServerLayout \"%s\"." +#define UNDEFINED_INPUT_MSG \ +"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"." +#define NO_IDENT_MSG \ +"This section must have an Identifier line." +#define ONLY_ONE_MSG \ +"This section must have only one of either %s line." +#define UNDEFINED_INPUTDRIVER_MSG \ +"InputDevice section \"%s\" must have a Driver line." +#define INVALID_GAMMA_MSG \ +"gamma correction value(s) expected\n either one value or three r/g/b values." +#define GROUP_MSG \ +"The Group keyword must be followed by either a group name in quotes or\n" \ +"\ta numerical group id." +#define MULTIPLE_MSG \ +"Multiple \"%s\" lines." +#define MUST_BE_OCTAL_MSG \ +"The number \"%d\" given in this section must be in octal (0xxx) format." + +/* Warning messages */ +#define OBSOLETE_MSG \ +"Ignoring obsolete keyword \"%s\"." +#define MOVED_TO_FLAGS_MSG \ +"Keyword \"%s\" is now an Option flag in the ServerFlags section." + +#endif /* _Configint_h_ */ diff --git a/xorg-server/hw/xfree86/parser/DRI.c b/xorg-server/hw/xfree86/parser/DRI.c new file mode 100644 index 000000000..68a6db90b --- /dev/null +++ b/xorg-server/hw/xfree86/parser/DRI.c @@ -0,0 +1,187 @@ +/* DRI.c -- DRI Section in XF86Config file + * Created: Fri Mar 19 08:40:22 1999 by faith@precisioninsight.com + * Revised: Thu Jun 17 16:08:05 1999 by faith@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec DRITab[] = +{ + {ENDSECTION, "endsection"}, + {GROUP, "group"}, + {BUFFERS, "buffers"}, + {MODE, "mode"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeBuffersList + +static void +xf86freeBuffersList (XF86ConfBuffersPtr ptr) +{ + XF86ConfBuffersPtr prev; + + while (ptr) { + TestFree (ptr->buf_flags); + TestFree (ptr->buf_comment); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +static XF86ConfBuffersPtr +xf86parseBuffers (void) +{ + int token; + parsePrologue (XF86ConfBuffersPtr, XF86ConfBuffersRec) + + if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER) + Error ("Buffers count expected", NULL); + ptr->buf_count = val.num; + + if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER) + Error ("Buffers size expected", NULL); + ptr->buf_size = val.num; + + if ((token = xf86getSubToken (&(ptr->buf_comment))) == STRING) { + ptr->buf_flags = val.str; + if ((token = xf86getToken (NULL)) == COMMENT) + ptr->buf_comment = xf86addComment(ptr->buf_comment, val.str); + else + xf86unGetToken(token); + } + +#ifdef DEBUG + printf ("Buffers parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +#define CLEANUP xf86freeDRI + +XF86ConfDRIPtr +xf86parseDRISection (void) +{ + int token; + parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec); + + /* Zero is a valid value for this. */ + ptr->dri_group = -1; + while ((token = xf86getToken (DRITab)) != ENDSECTION) { + switch (token) + { + case GROUP: + if ((token = xf86getSubToken (&(ptr->dri_comment))) == STRING) + ptr->dri_group_name = val.str; + else if (token == NUMBER) + ptr->dri_group = val.num; + else + Error (GROUP_MSG, NULL); + break; + case MODE: + if (xf86getSubToken (&(ptr->dri_comment)) != NUMBER) + Error (NUMBER_MSG, "Mode"); + if (val.numType != PARSE_OCTAL) + Error (MUST_BE_OCTAL_MSG, val.num); + ptr->dri_mode = val.num; + break; + case BUFFERS: + HANDLE_LIST (dri_buffers_lst, xf86parseBuffers, + XF86ConfBuffersPtr); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + case COMMENT: + ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + ErrorF("DRI section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr) +{ + XF86ConfBuffersPtr bufs; + + if (ptr == NULL) + return; + + fprintf (cf, "Section \"DRI\"\n"); + if (ptr->dri_comment) + fprintf (cf, "%s", ptr->dri_comment); + if (ptr->dri_group_name) + fprintf (cf, "\tGroup \"%s\"\n", ptr->dri_group_name); + else if (ptr->dri_group >= 0) + fprintf (cf, "\tGroup %d\n", ptr->dri_group); + if (ptr->dri_mode) + fprintf (cf, "\tMode 0%o\n", ptr->dri_mode); + for (bufs = ptr->dri_buffers_lst; bufs; bufs = bufs->list.next) { + fprintf (cf, "\tBuffers %d %d", + bufs->buf_count, bufs->buf_size); + if (bufs->buf_flags) fprintf (cf, " \"%s\"", bufs->buf_flags); + if (bufs->buf_comment) + fprintf(cf, "%s", bufs->buf_comment); + else + fprintf (cf, "\n"); + } + fprintf (cf, "EndSection\n\n"); +} + +void +xf86freeDRI (XF86ConfDRIPtr ptr) +{ + if (ptr == NULL) + return; + + xf86freeBuffersList (ptr->dri_buffers_lst); + TestFree (ptr->dri_comment); + xf86conffree (ptr); +} diff --git a/xorg-server/hw/xfree86/parser/Device.c b/xorg-server/hw/xfree86/parser/Device.c new file mode 100644 index 000000000..216789fc1 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Device.c @@ -0,0 +1,382 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static +xf86ConfigSymTabRec DeviceTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {VENDOR, "vendorname"}, + {BOARD, "boardname"}, + {CHIPSET, "chipset"}, + {RAMDAC, "ramdac"}, + {DACSPEED, "dacspeed"}, + {CLOCKS, "clocks"}, + {OPTION, "option"}, + {VIDEORAM, "videoram"}, + {BIOSBASE, "biosbase"}, + {MEMBASE, "membase"}, + {IOBASE, "iobase"}, + {CLOCKCHIP, "clockchip"}, + {CHIPID, "chipid"}, + {CHIPREV, "chiprev"}, + {CARD, "card"}, + {DRIVER, "driver"}, + {BUSID, "busid"}, + {TEXTCLOCKFRQ, "textclockfreq"}, + {IRQ, "irq"}, + {SCREEN, "screen"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeDeviceList + +XF86ConfDevicePtr +xf86parseDeviceSection (void) +{ + int i; + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec) + + /* Zero is a valid value for these */ + ptr->dev_chipid = -1; + ptr->dev_chiprev = -1; + ptr->dev_irq = -1; + while ((token = xf86getToken (DeviceTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->dev_identifier = val.str; + has_ident = TRUE; + break; + case VENDOR: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Vendor"); + ptr->dev_vendor = val.str; + break; + case BOARD: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Board"); + ptr->dev_board = val.str; + break; + case CHIPSET: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Chipset"); + ptr->dev_chipset = val.str; + break; + case CARD: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Card"); + ptr->dev_card = val.str; + break; + case DRIVER: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + ptr->dev_driver = val.str; + break; + case RAMDAC: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "Ramdac"); + ptr->dev_ramdac = val.str; + break; + case DACSPEED: + for (i = 0; i < CONF_MAXDACSPEEDS; i++) + ptr->dev_dacSpeeds[i] = 0; + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + { + Error (DACSPEED_MSG, CONF_MAXDACSPEEDS); + } + else + { + ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5); + for (i = 1; i < CONF_MAXDACSPEEDS; i++) + { + if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER) + ptr->dev_dacSpeeds[i] = (int) + (val.realnum * 1000.0 + 0.5); + else + { + xf86unGetToken (token); + break; + } + } + } + break; + case VIDEORAM: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "VideoRam"); + ptr->dev_videoram = val.num; + break; + case BIOSBASE: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "BIOSBase"); + ptr->dev_bios_base = val.num; + break; + case MEMBASE: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "MemBase"); + ptr->dev_mem_base = val.num; + break; + case IOBASE: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "IOBase"); + ptr->dev_io_base = val.num; + break; + case CLOCKCHIP: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "ClockChip"); + ptr->dev_clockchip = val.str; + break; + case CHIPID: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "ChipID"); + ptr->dev_chipid = val.num; + break; + case CHIPREV: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "ChipRev"); + ptr->dev_chiprev = val.num; + break; + + case CLOCKS: + token = xf86getSubToken(&(ptr->dev_comment)); + for( i = ptr->dev_clocks; + token == NUMBER && i < CONF_MAXCLOCKS; i++ ) { + ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5); + token = xf86getSubToken(&(ptr->dev_comment)); + } + ptr->dev_clocks = i; + xf86unGetToken (token); + break; + case TEXTCLOCKFRQ: + if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER) + Error (NUMBER_MSG, "TextClockFreq"); + ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5); + break; + case OPTION: + ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst); + break; + case BUSID: + if (xf86getSubToken (&(ptr->dev_comment)) != STRING) + Error (QUOTE_MSG, "BusID"); + ptr->dev_busid = val.str; + break; + case IRQ: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (QUOTE_MSG, "IRQ"); + ptr->dev_irq = val.num; + break; + case SCREEN: + if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER) + Error (NUMBER_MSG, "Screen"); + ptr->dev_screen = val.num; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Device section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr) +{ + int i; + + while (ptr) + { + fprintf (cf, "Section \"Device\"\n"); + if (ptr->dev_comment) + fprintf (cf, "%s", ptr->dev_comment); + if (ptr->dev_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier); + if (ptr->dev_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver); + if (ptr->dev_vendor) + fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor); + if (ptr->dev_board) + fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board); + if (ptr->dev_chipset) + fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset); + if (ptr->dev_card) + fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card); + if (ptr->dev_ramdac) + fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac); + if (ptr->dev_dacSpeeds[0] > 0 ) { + fprintf (cf, "\tDacSpeed "); + for (i = 0; i < CONF_MAXDACSPEEDS + && ptr->dev_dacSpeeds[i] > 0; i++ ) + fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 ); + fprintf (cf, "\n"); + } + if (ptr->dev_videoram) + fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram); + if (ptr->dev_bios_base) + fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base); + if (ptr->dev_mem_base) + fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base); + if (ptr->dev_io_base) + fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base); + if (ptr->dev_clockchip) + fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip); + if (ptr->dev_chipid != -1) + fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid); + if (ptr->dev_chiprev != -1) + fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev); + + xf86printOptionList(cf, ptr->dev_option_lst, 1); + if (ptr->dev_clocks > 0 ) { + fprintf (cf, "\tClocks "); + for (i = 0; i < ptr->dev_clocks; i++ ) + fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 ); + fprintf (cf, "\n"); + } + if (ptr->dev_textclockfreq) { + fprintf (cf, "\tTextClockFreq %.1f\n", + (double)ptr->dev_textclockfreq / 1000.0); + } + if (ptr->dev_busid) + fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid); + if (ptr->dev_screen > 0) + fprintf (cf, "\tScreen %d\n", ptr->dev_screen); + if (ptr->dev_irq >= 0) + fprintf (cf, "\tIRQ %d\n", ptr->dev_irq); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeDeviceList (XF86ConfDevicePtr ptr) +{ + XF86ConfDevicePtr prev; + + while (ptr) + { + TestFree (ptr->dev_identifier); + TestFree (ptr->dev_vendor); + TestFree (ptr->dev_board); + TestFree (ptr->dev_chipset); + TestFree (ptr->dev_card); + TestFree (ptr->dev_driver); + TestFree (ptr->dev_ramdac); + TestFree (ptr->dev_clockchip); + TestFree (ptr->dev_comment); + xf86optionListFree (ptr->dev_option_lst); + + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +XF86ConfDevicePtr +xf86findDevice (const char *ident, XF86ConfDevicePtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->dev_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +char * +xf86configStrdup (const char *s) +{ + char *tmp; + if (!s) return NULL; + tmp = xf86confmalloc (sizeof (char) * (strlen (s) + 1)); + if (tmp) + strcpy (tmp, s); + return (tmp); +} diff --git a/xorg-server/hw/xfree86/parser/Extensions.c b/xorg-server/hw/xfree86/parser/Extensions.c new file mode 100644 index 000000000..b64f08111 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Extensions.c @@ -0,0 +1,111 @@ +/* + * Copyright 2004 Red Hat Inc., Raleigh, North Carolina. + * + * 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 RED HAT 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 <kem@redhat.com> + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec ExtensionsTab[] = +{ + {ENDSECTION, "endsection"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeExtensions + +XF86ConfExtensionsPtr +xf86parseExtensionsSection (void) +{ + int token; + parsePrologue (XF86ConfExtensionsPtr, XF86ConfExtensionsRec); + + while ((token = xf86getToken (ExtensionsTab)) != ENDSECTION) { + switch (token) { + case OPTION: + ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + case COMMENT: + ptr->extensions_comment = + xf86addComment(ptr->extensions_comment, val.str); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + ErrorF("Extensions section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr) +{ + XF86OptionPtr p; + + if (ptr == NULL || ptr->ext_option_lst == NULL) + return; + + p = ptr->ext_option_lst; + fprintf (cf, "Section \"Extensions\"\n"); + if (ptr->extensions_comment) + fprintf (cf, "%s", ptr->extensions_comment); + xf86printOptionList(cf, p, 1); + fprintf (cf, "EndSection\n\n"); +} + +void +xf86freeExtensions (XF86ConfExtensionsPtr ptr) +{ + if (ptr == NULL) + return; + + xf86optionListFree (ptr->ext_option_lst); + TestFree (ptr->extensions_comment); + xf86conffree (ptr); +} diff --git a/xorg-server/hw/xfree86/parser/Files.c b/xorg-server/hw/xfree86/parser/Files.c new file mode 100644 index 000000000..3777432b1 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Files.c @@ -0,0 +1,273 @@ +/* + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/Xos.h> +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec FilesTab[] = +{ + {ENDSECTION, "endsection"}, + {FONTPATH, "fontpath"}, + {MODULEPATH, "modulepath"}, + {INPUTDEVICES, "inputdevices"}, + {LOGFILEPATH, "logfile"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeFiles + +XF86ConfFilesPtr +xf86parseFilesSection (void) +{ + int i, j; + int k, l; + char *str; + int token; + parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec) + + while ((token = xf86getToken (FilesTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->file_comment = xf86addComment(ptr->file_comment, val.str); + break; + case FONTPATH: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "FontPath"); + j = FALSE; + str = val.str; + if (ptr->file_fontpath == NULL) + { + ptr->file_fontpath = xf86confmalloc (1); + ptr->file_fontpath[0] = '\0'; + i = strlen (str) + 1; + } + else + { + i = strlen (ptr->file_fontpath) + strlen (str) + 1; + if (ptr->file_fontpath[strlen (ptr->file_fontpath) - 1] != ',') + { + i++; + j = TRUE; + } + } + ptr->file_fontpath = + xf86confrealloc (ptr->file_fontpath, i); + if (j) + strcat (ptr->file_fontpath, ","); + + strcat (ptr->file_fontpath, str); + xf86conffree (val.str); + break; + case MODULEPATH: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "ModulePath"); + l = FALSE; + str = val.str; + if (ptr->file_modulepath == NULL) + { + ptr->file_modulepath = xf86confmalloc (1); + ptr->file_modulepath[0] = '\0'; + k = strlen (str) + 1; + } + else + { + k = strlen (ptr->file_modulepath) + strlen (str) + 1; + if (ptr->file_modulepath[strlen (ptr->file_modulepath) - 1] != ',') + { + k++; + l = TRUE; + } + } + ptr->file_modulepath = xf86confrealloc (ptr->file_modulepath, k); + if (l) + strcat (ptr->file_modulepath, ","); + + strcat (ptr->file_modulepath, str); + xf86conffree (val.str); + break; + case INPUTDEVICES: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "InputDevices"); + l = FALSE; + str = val.str; + if (ptr->file_inputdevs == NULL) + { + ptr->file_inputdevs = xf86confmalloc (1); + ptr->file_inputdevs[0] = '\0'; + k = strlen (str) + 1; + } + else + { + k = strlen (ptr->file_inputdevs) + strlen (str) + 1; + if (ptr->file_inputdevs[strlen (ptr->file_inputdevs) - 1] != ',') + { + k++; + l = TRUE; + } + } + ptr->file_inputdevs = xf86confrealloc (ptr->file_inputdevs, k); + if (l) + strcat (ptr->file_inputdevs, ","); + + strcat (ptr->file_inputdevs, str); + xf86conffree (val.str); + break; + case LOGFILEPATH: + if (xf86getSubToken (&(ptr->file_comment)) != STRING) + Error (QUOTE_MSG, "LogFile"); + ptr->file_logfile = val.str; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("File section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printFileSection (FILE * cf, XF86ConfFilesPtr ptr) +{ + char *p, *s; + + if (ptr == NULL) + return; + + if (ptr->file_comment) + fprintf (cf, "%s", ptr->file_comment); + if (ptr->file_logfile) + fprintf (cf, "\tLogFile \"%s\"\n", ptr->file_logfile); + if (ptr->file_modulepath) + { + s = ptr->file_modulepath; + p = index (s, ','); + while (p) + { + *p = '\000'; + fprintf (cf, "\tModulePath \"%s\"\n", s); + *p = ','; + s = p; + s++; + p = index (s, ','); + } + fprintf (cf, "\tModulePath \"%s\"\n", s); + } + if (ptr->file_inputdevs) + { + s = ptr->file_inputdevs; + p = index (s, ','); + while (p) + { + *p = '\000'; + fprintf (cf, "\tInputDevices \"%s\"\n", s); + *p = ','; + s = p; + s++; + p = index (s, ','); + } + fprintf (cf, "\tInputDevices \"%s\"\n", s); + } + if (ptr->file_fontpath) + { + s = ptr->file_fontpath; + p = index (s, ','); + while (p) + { + *p = '\000'; + fprintf (cf, "\tFontPath \"%s\"\n", s); + *p = ','; + s = p; + s++; + p = index (s, ','); + } + fprintf (cf, "\tFontPath \"%s\"\n", s); + } +} + +void +xf86freeFiles (XF86ConfFilesPtr p) +{ + if (p == NULL) + return; + + TestFree (p->file_logfile); + TestFree (p->file_modulepath); + TestFree (p->file_inputdevs); + TestFree (p->file_fontpath); + TestFree (p->file_comment); + + xf86conffree (p); +} diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c new file mode 100644 index 000000000..19b9d1477 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Flags.c @@ -0,0 +1,516 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include <math.h> +#include <X11/Xfuncproto.h> + +extern LexRec val; + +static xf86ConfigSymTabRec ServerFlagsTab[] = +{ + {ENDSECTION, "endsection"}, + {NOTRAPSIGNALS, "notrapsignals"}, + {DONTZAP, "dontzap"}, + {DONTZOOM, "dontzoom"}, + {DISABLEVIDMODE, "disablevidmodeextension"}, + {ALLOWNONLOCAL, "allownonlocalxvidtune"}, + {DISABLEMODINDEV, "disablemodindev"}, + {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"}, + {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"}, + {OPTION, "option"}, + {BLANKTIME, "blanktime"}, + {STANDBYTIME, "standbytime"}, + {SUSPENDTIME, "suspendtime"}, + {OFFTIME, "offtime"}, + {DEFAULTLAYOUT, "defaultserverlayout"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeFlags + +XF86ConfFlagsPtr +xf86parseFlagsSection (void) +{ + int token; + parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec) + + while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION) + { + int hasvalue = FALSE; + int strvalue = FALSE; + int tokentype; + switch (token) + { + case COMMENT: + ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str); + break; + /* + * these old keywords are turned into standard generic options. + * we fall through here on purpose + */ + case DEFAULTLAYOUT: + strvalue = TRUE; + case BLANKTIME: + case STANDBYTIME: + case SUSPENDTIME: + case OFFTIME: + hasvalue = TRUE; + case NOTRAPSIGNALS: + case DONTZAP: + case DONTZOOM: + case DISABLEVIDMODE: + case ALLOWNONLOCAL: + case DISABLEMODINDEV: + case MODINDEVALLOWNONLOCAL: + case ALLOWMOUSEOPENFAIL: + { + int i = 0; + while (ServerFlagsTab[i].token != -1) + { + char *tmp; + + if (ServerFlagsTab[i].token == token) + { + char *valstr = NULL; + /* can't use strdup because it calls malloc */ + tmp = xf86configStrdup (ServerFlagsTab[i].name); + if (hasvalue) + { + tokentype = xf86getSubToken(&(ptr->flg_comment)); + if (strvalue) { + if (tokentype != STRING) + Error (QUOTE_MSG, tmp); + valstr = val.str; + } else { + if (tokentype != NUMBER) + Error (NUMBER_MSG, tmp); + valstr = xf86confmalloc(16); + if (valstr) + sprintf(valstr, "%d", val.num); + } + } + ptr->flg_option_lst = xf86addNewOption + (ptr->flg_option_lst, tmp, valstr); + } + i++; + } + } + break; + case OPTION: + ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Flags section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags) +{ + XF86OptionPtr p; + + if ((!flags) || (!flags->flg_option_lst)) + return; + p = flags->flg_option_lst; + fprintf (f, "Section \"ServerFlags\"\n"); + if (flags->flg_comment) + fprintf (f, "%s", flags->flg_comment); + xf86printOptionList(f, p, 1); + fprintf (f, "EndSection\n\n"); +} + +static XF86OptionPtr +addNewOption2 (XF86OptionPtr head, char *name, char *val, int used) +{ + XF86OptionPtr new, old = NULL; + + /* Don't allow duplicates, free old strings */ + if (head != NULL && (old = xf86findOption(head, name)) != NULL) { + new = old; + xf86conffree(new->opt_name); + xf86conffree(new->opt_val); + } + else + new = xf86confcalloc (1, sizeof (XF86OptionRec)); + new->opt_name = name; + new->opt_val = val; + new->opt_used = used; + + if (old) + return head; + return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new)); +} + +XF86OptionPtr +xf86addNewOption (XF86OptionPtr head, char *name, char *val) +{ + return addNewOption2(head, name, val, 0); +} + +void +xf86freeFlags (XF86ConfFlagsPtr flags) +{ + if (flags == NULL) + return; + xf86optionListFree (flags->flg_option_lst); + TestFree(flags->flg_comment); + xf86conffree (flags); +} + +XF86OptionPtr +xf86optionListDup (XF86OptionPtr opt) +{ + XF86OptionPtr newopt = NULL; + + while (opt) + { + newopt = xf86addNewOption(newopt, xf86configStrdup(opt->opt_name), + xf86configStrdup(opt->opt_val)); + newopt->opt_used = opt->opt_used; + if (opt->opt_comment) + newopt->opt_comment = xf86configStrdup(opt->opt_comment); + opt = opt->list.next; + } + return newopt; +} + +void +xf86optionListFree (XF86OptionPtr opt) +{ + XF86OptionPtr prev; + + while (opt) + { + TestFree (opt->opt_name); + TestFree (opt->opt_val); + TestFree (opt->opt_comment); + prev = opt; + opt = opt->list.next; + xf86conffree (prev); + } +} + +char * +xf86optionName(XF86OptionPtr opt) +{ + if (opt) + return opt->opt_name; + return 0; +} + +char * +xf86optionValue(XF86OptionPtr opt) +{ + if (opt) + return opt->opt_val; + return 0; +} + +XF86OptionPtr +xf86newOption(char *name, char *value) +{ + XF86OptionPtr opt; + + opt = xf86confcalloc(1, sizeof (XF86OptionRec)); + if (!opt) + return NULL; + + opt->opt_used = 0; + opt->list.next = 0; + opt->opt_name = name; + opt->opt_val = value; + + return opt; +} + +XF86OptionPtr +xf86nextOption(XF86OptionPtr list) +{ + if (!list) + return NULL; + return list->list.next; +} + +/* + * this function searches the given option list for the named option and + * returns a pointer to the option rec if found. If not found, it returns + * NULL + */ + +XF86OptionPtr +xf86findOption (XF86OptionPtr list, const char *name) +{ + while (list) + { + if (xf86nameCompare (list->opt_name, name) == 0) + return (list); + list = list->list.next; + } + return (NULL); +} + +/* + * this function searches the given option list for the named option. If + * found and the option has a parameter, a pointer to the parameter is + * returned. If the option does not have a parameter an empty string is + * returned. If the option is not found, a NULL is returned. + */ + +_X_EXPORT char * +xf86findOptionValue (XF86OptionPtr list, const char *name) +{ + XF86OptionPtr p = xf86findOption (list, name); + + if (p) + { + if (p->opt_val) + return (p->opt_val); + else + return ""; + } + return (NULL); +} + +XF86OptionPtr +xf86optionListCreate( const char **options, int count, int used ) +{ + XF86OptionPtr p = NULL; + char *t1, *t2; + int i; + + if (count == -1) + { + for (count = 0; options[count]; count++) + ; + } + if( (count % 2) != 0 ) + { + fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" ); + return (NULL); + } + for (i = 0; i < count; i += 2) + { + /* can't use strdup because it calls malloc */ + t1 = xf86confmalloc (sizeof (char) * + (strlen (options[i]) + 1)); + strcpy (t1, options[i]); + t2 = xf86confmalloc (sizeof (char) * + (strlen (options[i + 1]) + 1)); + strcpy (t2, options[i + 1]); + p = addNewOption2 (p, t1, t2, used); + } + + return (p); +} + +/* the 2 given lists are merged. If an option with the same name is present in + * both, the option from the user list - specified in the second argument - + * is used. The end result is a single valid list of options. Duplicates + * are freed, and the original lists are no longer guaranteed to be complete. + */ +XF86OptionPtr +xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail) +{ + XF86OptionPtr a, b, ap = NULL, bp = NULL; + + a = tail; + b = head; + while (tail && b) { + if (xf86nameCompare (a->opt_name, b->opt_name) == 0) { + if (b == head) + head = a; + else + bp->list.next = a; + if (a == tail) + tail = a->list.next; + else + ap->list.next = a->list.next; + a->list.next = b->list.next; + b->list.next = NULL; + xf86optionListFree (b); + b = a->list.next; + bp = a; + a = tail; + ap = NULL; + } else { + ap = a; + if (!(a = a->list.next)) { + a = tail; + bp = b; + b = b->list.next; + ap = NULL; + } + } + } + + if (head) { + for (a = head; a->list.next; a = a->list.next) + ; + a->list.next = tail; + } else + head = tail; + + return (head); +} + +char * +xf86uLongToString(unsigned long i) +{ + char *s; + int l; + + l = (int)(ceil(log10((double)i) + 2.5)); + s = xf86confmalloc(l); + if (!s) + return NULL; + sprintf(s, "%lu", i); + return s; +} + +XF86OptionPtr +xf86parseOption(XF86OptionPtr head) +{ + XF86OptionPtr option, cnew, old; + char *name, *comment = NULL; + int token; + + if ((token = xf86getSubToken(&comment)) != STRING) { + xf86parseError(BAD_OPTION_MSG, NULL); + if (comment) + xf86conffree(comment); + return (head); + } + + name = val.str; + if ((token = xf86getSubToken(&comment)) == STRING) { + option = xf86newOption(name, val.str); + option->opt_comment = comment; + if ((token = xf86getToken(NULL)) == COMMENT) + option->opt_comment = xf86addComment(option->opt_comment, val.str); + else + xf86unGetToken(token); + } + else { + option = xf86newOption(name, NULL); + option->opt_comment = comment; + if (token == COMMENT) + option->opt_comment = xf86addComment(option->opt_comment, val.str); + else + xf86unGetToken(token); + } + + old = NULL; + + /* Don't allow duplicates */ + if (head != NULL && (old = xf86findOption(head, name)) != NULL) { + cnew = old; + xf86conffree(option->opt_name); + TestFree(option->opt_val); + TestFree(option->opt_comment); + xf86conffree(option); + } + else + cnew = option; + + if (old == NULL) + return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew)); + + return (head); +} + +void +xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs) +{ + int i; + + if (!list) + return; + while (list) { + for (i = 0; i < tabs; i++) + fputc('\t', fp); + if (list->opt_val) + fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val); + else + fprintf(fp, "Option \"%s\"", list->opt_name); + if (list->opt_comment) + fprintf(fp, "%s", list->opt_comment); + else + fputc('\n', fp); + list = list->list.next; + } +} diff --git a/xorg-server/hw/xfree86/parser/Input.c b/xorg-server/hw/xfree86/parser/Input.c new file mode 100644 index 000000000..3d9801968 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Input.c @@ -0,0 +1,217 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static +xf86ConfigSymTabRec InputTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {DRIVER, "driver"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeInputList + +XF86ConfInputPtr +xf86parseInputSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) + + while ((token = xf86getToken (InputTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->inp_identifier = val.str; + has_ident = TRUE; + break; + case DRIVER: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + if (strcmp(val.str, "keyboard") == 0) + ptr->inp_driver = "kbd"; + else + ptr->inp_driver = val.str; + break; + case OPTION: + ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("InputDevice section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr) +{ + while (ptr) + { + fprintf (cf, "Section \"InputDevice\"\n"); + if (ptr->inp_comment) + fprintf (cf, "%s", ptr->inp_comment); + if (ptr->inp_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier); + if (ptr->inp_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver); + xf86printOptionList(cf, ptr->inp_option_lst, 1); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeInputList (XF86ConfInputPtr ptr) +{ + XF86ConfInputPtr prev; + + while (ptr) + { + TestFree (ptr->inp_identifier); + TestFree (ptr->inp_driver); + TestFree (ptr->inp_comment); + xf86optionListFree (ptr->inp_option_lst); + + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +int +xf86validateInput (XF86ConfigPtr p) +{ + XF86ConfInputPtr input = p->conf_input_lst; + +#if 0 /* Enable this later */ + if (!input) { + xf86validationError ("At least one InputDevice section is required."); + return (FALSE); + } +#endif + + while (input) { + if (!input->inp_driver) { + xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier); + return (FALSE); + } + input = input->list.next; + } + return (TRUE); +} + +XF86ConfInputPtr +xf86findInput (const char *ident, XF86ConfInputPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->inp_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +XF86ConfInputPtr +xf86findInputByDriver (const char *driver, XF86ConfInputPtr p) +{ + while (p) + { + if (xf86nameCompare (driver, p->inp_driver) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c new file mode 100644 index 000000000..5d1348acb --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Layout.c @@ -0,0 +1,534 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include <string.h> + +extern LexRec val; + +static xf86ConfigSymTabRec LayoutTab[] = +{ + {ENDSECTION, "endsection"}, + {SCREEN, "screen"}, + {IDENTIFIER, "identifier"}, + {INACTIVE, "inactive"}, + {INPUTDEVICE, "inputdevice"}, + {OPTION, "option"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec AdjTab[] = +{ + {RIGHTOF, "rightof"}, + {LEFTOF, "leftof"}, + {ABOVE, "above"}, + {BELOW, "below"}, + {RELATIVE, "relative"}, + {ABSOLUTE, "absolute"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeLayoutList + +XF86ConfLayoutPtr +xf86parseLayoutSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec) + + while ((token = xf86getToken (LayoutTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->lay_identifier = val.str; + has_ident = TRUE; + break; + case INACTIVE: + { + XF86ConfInactivePtr iptr; + + iptr = xf86confcalloc (1, sizeof (XF86ConfInactiveRec)); + iptr->list.next = NULL; + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + xf86conffree (iptr); + Error (INACTIVE_MSG, NULL); + } + iptr->inactive_device_str = val.str; + ptr->lay_inactive_lst = (XF86ConfInactivePtr) + xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr); + } + break; + case SCREEN: + { + XF86ConfAdjacencyPtr aptr; + int absKeyword = 0; + + aptr = xf86confcalloc (1, sizeof (XF86ConfAdjacencyRec)); + aptr->list.next = NULL; + aptr->adj_scrnum = -1; + aptr->adj_where = CONF_ADJ_OBSOLETE; + aptr->adj_x = 0; + aptr->adj_y = 0; + aptr->adj_refscreen = NULL; + if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER) + aptr->adj_scrnum = val.num; + else + xf86unGetToken (token); + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != STRING) { + xf86conffree(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_screen_str = val.str; + + token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab); + switch (token) + { + case RIGHTOF: + aptr->adj_where = CONF_ADJ_RIGHTOF; + break; + case LEFTOF: + aptr->adj_where = CONF_ADJ_LEFTOF; + break; + case ABOVE: + aptr->adj_where = CONF_ADJ_ABOVE; + break; + case BELOW: + aptr->adj_where = CONF_ADJ_BELOW; + break; + case RELATIVE: + aptr->adj_where = CONF_ADJ_RELATIVE; + break; + case ABSOLUTE: + aptr->adj_where = CONF_ADJ_ABSOLUTE; + absKeyword = 1; + break; + case EOF_TOKEN: + xf86conffree(aptr); + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + xf86unGetToken (token); + token = xf86getSubToken(&(ptr->lay_comment)); + if (token == STRING) + aptr->adj_where = CONF_ADJ_OBSOLETE; + else + aptr->adj_where = CONF_ADJ_ABSOLUTE; + } + switch (aptr->adj_where) + { + case CONF_ADJ_ABSOLUTE: + if (absKeyword) + token = xf86getSubToken(&(ptr->lay_comment)); + if (token == NUMBER) + { + aptr->adj_x = val.num; + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != NUMBER) { + xf86conffree(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_y = val.num; + } else { + if (absKeyword) { + xf86conffree(aptr); + Error(INVALID_SCR_MSG, NULL); + } else + xf86unGetToken (token); + } + break; + case CONF_ADJ_RIGHTOF: + case CONF_ADJ_LEFTOF: + case CONF_ADJ_ABOVE: + case CONF_ADJ_BELOW: + case CONF_ADJ_RELATIVE: + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != STRING) { + xf86conffree(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_refscreen = val.str; + if (aptr->adj_where == CONF_ADJ_RELATIVE) + { + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != NUMBER) { + xf86conffree(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_x = val.num; + token = xf86getSubToken(&(ptr->lay_comment)); + if (token != NUMBER) { + xf86conffree(aptr); + Error(INVALID_SCR_MSG, NULL); + } + aptr->adj_y = val.num; + } + break; + case CONF_ADJ_OBSOLETE: + /* top */ + aptr->adj_top_str = val.str; + + /* bottom */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + xf86conffree(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_bottom_str = val.str; + + /* left */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + xf86conffree(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_left_str = val.str; + + /* right */ + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + xf86conffree(aptr); + Error (SCREEN_MSG, NULL); + } + aptr->adj_right_str = val.str; + + } + ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr) + xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr); + } + break; + case INPUTDEVICE: + { + XF86ConfInputrefPtr iptr; + + iptr = xf86confcalloc (1, sizeof (XF86ConfInputrefRec)); + iptr->list.next = NULL; + iptr->iref_option_lst = NULL; + if (xf86getSubToken (&(ptr->lay_comment)) != STRING) { + xf86conffree(iptr); + Error (INPUTDEV_MSG, NULL); + } + iptr->iref_inputdev_str = val.str; + while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING) + { + iptr->iref_option_lst = + xf86addNewOption (iptr->iref_option_lst, val.str, NULL); + } + xf86unGetToken (token); + ptr->lay_input_lst = (XF86ConfInputrefPtr) + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + } + break; + case OPTION: + ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Layout section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr) +{ + XF86ConfAdjacencyPtr aptr; + XF86ConfInactivePtr iptr; + XF86ConfInputrefPtr inptr; + XF86OptionPtr optr; + + while (ptr) + { + fprintf (cf, "Section \"ServerLayout\"\n"); + if (ptr->lay_comment) + fprintf (cf, "%s", ptr->lay_comment); + if (ptr->lay_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier); + + for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next) + { + fprintf (cf, "\tScreen "); + if (aptr->adj_scrnum >= 0) + fprintf (cf, "%2d", aptr->adj_scrnum); + else + fprintf (cf, " "); + fprintf (cf, " \"%s\"", aptr->adj_screen_str); + switch(aptr->adj_where) + { + case CONF_ADJ_OBSOLETE: + fprintf (cf, " \"%s\"", aptr->adj_top_str); + fprintf (cf, " \"%s\"", aptr->adj_bottom_str); + fprintf (cf, " \"%s\"", aptr->adj_right_str); + fprintf (cf, " \"%s\"\n", aptr->adj_left_str); + break; + case CONF_ADJ_ABSOLUTE: + if (aptr->adj_x != -1) + fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y); + else + fprintf (cf, "\n"); + break; + case CONF_ADJ_RIGHTOF: + fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_LEFTOF: + fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_ABOVE: + fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_BELOW: + fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen); + break; + case CONF_ADJ_RELATIVE: + fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen, + aptr->adj_x, aptr->adj_y); + break; + } + } + for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next) + fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str); + for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next) + { + fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str); + for (optr = inptr->iref_option_lst; optr; optr = optr->list.next) + { + fprintf(cf, " \"%s\"", optr->opt_name); + } + fprintf(cf, "\n"); + } + xf86printOptionList(cf, ptr->lay_option_lst, 1); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +static void +xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr) +{ + XF86ConfAdjacencyPtr prev; + + while (ptr) + { + TestFree (ptr->adj_screen_str); + TestFree (ptr->adj_top_str); + TestFree (ptr->adj_bottom_str); + TestFree (ptr->adj_left_str); + TestFree (ptr->adj_right_str); + + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } + +} + +static void +xf86freeInputrefList (XF86ConfInputrefPtr ptr) +{ + XF86ConfInputrefPtr prev; + + while (ptr) + { + TestFree (ptr->iref_inputdev_str); + xf86optionListFree (ptr->iref_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } + +} + +void +xf86freeLayoutList (XF86ConfLayoutPtr ptr) +{ + XF86ConfLayoutPtr prev; + + while (ptr) + { + TestFree (ptr->lay_identifier); + TestFree (ptr->lay_comment); + xf86freeAdjacencyList (ptr->lay_adjacency_lst); + xf86freeInputrefList (ptr->lay_input_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +#define CheckScreen(str, ptr)\ +if (str[0] != '\0') \ +{ \ +screen = xf86findScreen (str, p->conf_screen_lst); \ +if (!screen) \ +{ \ + xf86validationError (UNDEFINED_SCREEN_MSG, \ + str, layout->lay_identifier); \ + return (FALSE); \ +} \ +else \ + ptr = screen; \ +} + +int +xf86validateLayout (XF86ConfigPtr p) +{ + XF86ConfLayoutPtr layout = p->conf_layout_lst; + XF86ConfAdjacencyPtr adj; + XF86ConfInactivePtr iptr; + XF86ConfInputrefPtr inptr; + XF86ConfScreenPtr screen; + XF86ConfDevicePtr device; + XF86ConfInputPtr input; + + while (layout) + { + adj = layout->lay_adjacency_lst; + while (adj) + { + /* the first one can't be "" but all others can */ + screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst); + if (!screen) + { + xf86validationError (UNDEFINED_SCREEN_MSG, + adj->adj_screen_str, layout->lay_identifier); + return (FALSE); + } + else + adj->adj_screen = screen; + +#if 0 + CheckScreen (adj->adj_top_str, adj->adj_top); + CheckScreen (adj->adj_bottom_str, adj->adj_bottom); + CheckScreen (adj->adj_left_str, adj->adj_left); + CheckScreen (adj->adj_right_str, adj->adj_right); +#endif + + adj = adj->list.next; + } + iptr = layout->lay_inactive_lst; + while (iptr) + { + device = xf86findDevice (iptr->inactive_device_str, + p->conf_device_lst); + if (!device) + { + xf86validationError (UNDEFINED_DEVICE_LAY_MSG, + iptr->inactive_device_str, layout->lay_identifier); + return (FALSE); + } + else + iptr->inactive_device = device; + iptr = iptr->list.next; + } + inptr = layout->lay_input_lst; + while (inptr) + { + input = xf86findInput (inptr->iref_inputdev_str, + p->conf_input_lst); + if (!input) + { + xf86validationError (UNDEFINED_INPUT_MSG, + inptr->iref_inputdev_str, layout->lay_identifier); + return (FALSE); + } + else + inptr->iref_inputdev = input; + inptr = inptr->list.next; + } + layout = layout->list.next; + } + return (TRUE); +} + +XF86ConfLayoutPtr +xf86findLayout (const char *name, XF86ConfLayoutPtr list) +{ + while (list) + { + if (xf86nameCompare (list->lay_identifier, name) == 0) + return (list); + list = list->list.next; + } + return (NULL); +} + diff --git a/xorg-server/hw/xfree86/parser/Makefile.am b/xorg-server/hw/xfree86/parser/Makefile.am new file mode 100644 index 000000000..849ee8bab --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Makefile.am @@ -0,0 +1,41 @@ +if INSTALL_LIBXF86CONFIG +lib_LIBRARIES = libxf86config.a +LIBHEADERS = \ + xf86Optrec.h \ + xf86Parser.h +else +noinst_LIBRARIES = libxf86config.a +endif + +libxf86config_a_SOURCES = \ + Device.c \ + Files.c \ + Flags.c \ + Input.c \ + Layout.c \ + Module.c \ + Video.c \ + Monitor.c \ + Pointer.c \ + Screen.c \ + Vendor.c \ + read.c \ + scan.c \ + write.c \ + DRI.c \ + Extensions.c + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +EXTRA_DIST = \ + Configint.h \ + configProcs.h \ + xf86Optrec.h \ + xf86Parser.h \ + xf86tokens.h \ + cpconfig.c + +sdk_HEADERS = \ + $(LIBHEADERS) \ + xf86Parser.h \ + xf86Optrec.h diff --git a/xorg-server/hw/xfree86/parser/Makefile.in b/xorg-server/hw/xfree86/parser/Makefile.in new file mode 100644 index 000000000..1298ecdbc --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Makefile.in @@ -0,0 +1,759 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/parser +DIST_COMMON = $(am__sdk_HEADERS_DIST) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(sdkdir)" +libLIBRARIES_INSTALL = $(INSTALL_DATA) +LIBRARIES = $(lib_LIBRARIES) $(noinst_LIBRARIES) +ARFLAGS = cru +libxf86config_a_AR = $(AR) $(ARFLAGS) +libxf86config_a_LIBADD = +am_libxf86config_a_OBJECTS = Device.$(OBJEXT) Files.$(OBJEXT) \ + Flags.$(OBJEXT) Input.$(OBJEXT) Layout.$(OBJEXT) \ + Module.$(OBJEXT) Video.$(OBJEXT) Monitor.$(OBJEXT) \ + Pointer.$(OBJEXT) Screen.$(OBJEXT) Vendor.$(OBJEXT) \ + read.$(OBJEXT) scan.$(OBJEXT) write.$(OBJEXT) DRI.$(OBJEXT) \ + Extensions.$(OBJEXT) +libxf86config_a_OBJECTS = $(am_libxf86config_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxf86config_a_SOURCES) +DIST_SOURCES = $(libxf86config_a_SOURCES) +am__sdk_HEADERS_DIST = xf86Optrec.h xf86Parser.h +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +@INSTALL_LIBXF86CONFIG_TRUE@lib_LIBRARIES = libxf86config.a +@INSTALL_LIBXF86CONFIG_TRUE@LIBHEADERS = \ +@INSTALL_LIBXF86CONFIG_TRUE@ xf86Optrec.h \ +@INSTALL_LIBXF86CONFIG_TRUE@ xf86Parser.h + +@INSTALL_LIBXF86CONFIG_FALSE@noinst_LIBRARIES = libxf86config.a +libxf86config_a_SOURCES = \ + Device.c \ + Files.c \ + Flags.c \ + Input.c \ + Layout.c \ + Module.c \ + Video.c \ + Monitor.c \ + Pointer.c \ + Screen.c \ + Vendor.c \ + read.c \ + scan.c \ + write.c \ + DRI.c \ + Extensions.c + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +EXTRA_DIST = \ + Configint.h \ + configProcs.h \ + xf86Optrec.h \ + xf86Parser.h \ + xf86tokens.h \ + cpconfig.c + +sdk_HEADERS = \ + $(LIBHEADERS) \ + xf86Parser.h \ + xf86Optrec.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/parser/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/parser/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libLIBRARIES: $(lib_LIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(libLIBRARIES_INSTALL) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(libLIBRARIES_INSTALL) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + @$(POST_INSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + p=$(am__strip_dir) \ + echo " $(RANLIB) '$(DESTDIR)$(libdir)/$$p'"; \ + $(RANLIB) "$(DESTDIR)$(libdir)/$$p"; \ + else :; fi; \ + done + +uninstall-libLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLIBRARIES: + -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libxf86config.a: $(libxf86config_a_OBJECTS) $(libxf86config_a_DEPENDENCIES) + -rm -f libxf86config.a + $(libxf86config_a_AR) libxf86config.a $(libxf86config_a_OBJECTS) $(libxf86config_a_LIBADD) + $(RANLIB) libxf86config.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DRI.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Device.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Extensions.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Files.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flags.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Input.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Layout.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Module.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Monitor.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Pointer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Screen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vendor.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Video.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLIBRARIES clean-libtool \ + clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: install-libLIBRARIES + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLIBRARIES clean-libtool clean-noinstLIBRARIES ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-libLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-sdkHEADERS \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-libLIBRARIES uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/parser/Module.c b/xorg-server/hw/xfree86/parser/Module.c new file mode 100644 index 000000000..2012ce6d2 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Module.c @@ -0,0 +1,279 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec SubModuleTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {OPTION, "option"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ModuleTab[] = +{ + {ENDSECTION, "endsection"}, + {LOAD, "load"}, + {DISABLE, "disable"}, + {LOAD_DRIVER, "loaddriver"}, + {SUBSECTION, "subsection"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeModules + +static XF86LoadPtr +xf86parseModuleSubSection (XF86LoadPtr head, char *name) +{ + int token; + parsePrologue (XF86LoadPtr, XF86LoadRec) + + ptr->load_name = name; + ptr->load_type = XF86_LOAD_MODULE; + ptr->ignore = 0; + ptr->load_opt = NULL; + ptr->list.next = NULL; + + while ((token = xf86getToken (SubModuleTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->load_comment = xf86addComment(ptr->load_comment, val.str); + break; + case OPTION: + ptr->load_opt = xf86parseOption(ptr->load_opt); + break; + case EOF_TOKEN: + xf86parseError (UNEXPECTED_EOF_MSG, NULL); + xf86conffree(ptr); + return NULL; + default: + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); + xf86conffree(ptr); + return NULL; + break; + } + + } + + return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) ptr)); +} + +XF86ConfModulePtr +xf86parseModuleSection (void) +{ + int token; + parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec) + + while ((token = xf86getToken (ModuleTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->mod_comment = xf86addComment(ptr->mod_comment, val.str); + break; + case LOAD: + if (xf86getSubToken (&(ptr->mod_comment)) != STRING) + Error (QUOTE_MSG, "Load"); + ptr->mod_load_lst = + xf86addNewLoadDirective (ptr->mod_load_lst, val.str, + XF86_LOAD_MODULE, NULL); + break; + case DISABLE: + if (xf86getSubToken (&(ptr->mod_comment)) != STRING) + Error (QUOTE_MSG, "Disable"); + ptr->mod_disable_lst = + xf86addNewLoadDirective (ptr->mod_disable_lst, val.str, + XF86_DISABLE_MODULE, NULL); + break; + case LOAD_DRIVER: + if (xf86getSubToken (&(ptr->mod_comment)) != STRING) + Error (QUOTE_MSG, "LoadDriver"); + ptr->mod_load_lst = + xf86addNewLoadDirective (ptr->mod_load_lst, val.str, + XF86_LOAD_DRIVER, NULL); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->mod_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + ptr->mod_load_lst = + xf86parseModuleSubSection (ptr->mod_load_lst, val.str); + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Module section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printModuleSection (FILE * cf, XF86ConfModulePtr ptr) +{ + XF86LoadPtr lptr; + + if (ptr == NULL) + return; + + if (ptr->mod_comment) + fprintf(cf, "%s", ptr->mod_comment); + for (lptr = ptr->mod_load_lst; lptr; lptr = lptr->list.next) + { + switch (lptr->load_type) + { + case XF86_LOAD_MODULE: + if( lptr->load_opt == NULL ) { + fprintf (cf, "\tLoad \"%s\"", lptr->load_name); + if (lptr->load_comment) + fprintf(cf, "%s", lptr->load_comment); + else + fputc('\n', cf); + } + else + { + fprintf (cf, "\tSubSection \"%s\"\n", lptr->load_name); + if (lptr->load_comment) + fprintf(cf, "%s", lptr->load_comment); + xf86printOptionList(cf, lptr->load_opt, 2); + fprintf (cf, "\tEndSubSection\n"); + } + break; + case XF86_LOAD_DRIVER: + fprintf (cf, "\tLoadDriver \"%s\"", lptr->load_name); + if (lptr->load_comment) + fprintf(cf, "%s", lptr->load_comment); + else + fputc('\n', cf); + break; +#if 0 + default: + fprintf (cf, "#\tUnknown type \"%s\"\n", lptr->load_name); + break; +#endif + } + } +} + +XF86LoadPtr +xf86addNewLoadDirective (XF86LoadPtr head, char *name, int type, XF86OptionPtr opts) +{ + XF86LoadPtr new; + int token; + + new = xf86confcalloc (1, sizeof (XF86LoadRec)); + new->load_name = name; + new->load_type = type; + new->load_opt = opts; + new->ignore = 0; + new->list.next = NULL; + + if ((token = xf86getToken(NULL)) == COMMENT) + new->load_comment = xf86addComment(new->load_comment, val.str); + else + xf86unGetToken(token); + + return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) new)); +} + +void +xf86freeModules (XF86ConfModulePtr ptr) +{ + XF86LoadPtr lptr; + XF86LoadPtr prev; + + if (ptr == NULL) + return; + lptr = ptr->mod_load_lst; + while (lptr) + { + TestFree (lptr->load_name); + TestFree (lptr->load_comment); + prev = lptr; + lptr = lptr->list.next; + xf86conffree (prev); + } + lptr = ptr->mod_disable_lst; + while (lptr) + { + TestFree (lptr->load_name); + TestFree (lptr->load_comment); + prev = lptr; + lptr = lptr->list.next; + xf86conffree (prev); + } + TestFree (ptr->mod_comment); + xf86conffree (ptr); +} diff --git a/xorg-server/hw/xfree86/parser/Monitor.c b/xorg-server/hw/xfree86/parser/Monitor.c new file mode 100644 index 000000000..9d533125e --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Monitor.c @@ -0,0 +1,904 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec MonitorTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {VENDOR, "vendorname"}, + {MODEL, "modelname"}, + {USEMODES, "usemodes"}, + {MODELINE, "modeline"}, + {DISPLAYSIZE, "displaysize"}, + {HORIZSYNC, "horizsync"}, + {VERTREFRESH, "vertrefresh"}, + {MODE, "mode"}, + {GAMMA, "gamma"}, + {OPTION, "option"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ModesTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {MODELINE, "modeline"}, + {MODE, "mode"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec TimingTab[] = +{ + {TT_INTERLACE, "interlace"}, + {TT_PHSYNC, "+hsync"}, + {TT_NHSYNC, "-hsync"}, + {TT_PVSYNC, "+vsync"}, + {TT_NVSYNC, "-vsync"}, + {TT_CSYNC, "composite"}, + {TT_PCSYNC, "+csync"}, + {TT_NCSYNC, "-csync"}, + {TT_DBLSCAN, "doublescan"}, + {TT_HSKEW, "hskew"}, + {TT_BCAST, "bcast"}, + {TT_VSCAN, "vscan"}, + {TT_CUSTOM, "CUSTOM"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ModeTab[] = +{ + {DOTCLOCK, "dotclock"}, + {HTIMINGS, "htimings"}, + {VTIMINGS, "vtimings"}, + {FLAGS, "flags"}, + {HSKEW, "hskew"}, + {BCAST, "bcast"}, + {VSCAN, "vscan"}, + {ENDMODE, "endmode"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeModeLineList + +static void +xf86freeModeLineList (XF86ConfModeLinePtr ptr) +{ + XF86ConfModeLinePtr prev; + while (ptr) + { + TestFree (ptr->ml_identifier); + TestFree (ptr->ml_comment); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +static XF86ConfModeLinePtr +xf86parseModeLine (void) +{ + int token; + parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) + + /* Identifier */ + if (xf86getSubToken (&(ptr->ml_comment)) != STRING) + Error ("ModeLine identifier expected", NULL); + ptr->ml_identifier = val.str; + + /* DotClock */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine dotclock expected", NULL); + ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); + + /* HDisplay */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine Hdisplay expected", NULL); + ptr->ml_hdisplay = val.num; + + /* HSyncStart */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine HSyncStart expected", NULL); + ptr->ml_hsyncstart = val.num; + + /* HSyncEnd */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine HSyncEnd expected", NULL); + ptr->ml_hsyncend = val.num; + + /* HTotal */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine HTotal expected", NULL); + ptr->ml_htotal = val.num; + + /* VDisplay */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine Vdisplay expected", NULL); + ptr->ml_vdisplay = val.num; + + /* VSyncStart */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine VSyncStart expected", NULL); + ptr->ml_vsyncstart = val.num; + + /* VSyncEnd */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine VSyncEnd expected", NULL); + ptr->ml_vsyncend = val.num; + + /* VTotal */ + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("ModeLine VTotal expected", NULL); + ptr->ml_vtotal = val.num; + + token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab); + while ((token == TT_INTERLACE) || (token == TT_PHSYNC) || + (token == TT_NHSYNC) || (token == TT_PVSYNC) || + (token == TT_NVSYNC) || (token == TT_CSYNC) || + (token == TT_PCSYNC) || (token == TT_NCSYNC) || + (token == TT_DBLSCAN) || (token == TT_HSKEW) || + (token == TT_VSCAN) || (token == TT_BCAST)) + { + switch (token) + { + + case TT_INTERLACE: + ptr->ml_flags |= XF86CONF_INTERLACE; + break; + case TT_PHSYNC: + ptr->ml_flags |= XF86CONF_PHSYNC; + break; + case TT_NHSYNC: + ptr->ml_flags |= XF86CONF_NHSYNC; + break; + case TT_PVSYNC: + ptr->ml_flags |= XF86CONF_PVSYNC; + break; + case TT_NVSYNC: + ptr->ml_flags |= XF86CONF_NVSYNC; + break; + case TT_CSYNC: + ptr->ml_flags |= XF86CONF_CSYNC; + break; + case TT_PCSYNC: + ptr->ml_flags |= XF86CONF_PCSYNC; + break; + case TT_NCSYNC: + ptr->ml_flags |= XF86CONF_NCSYNC; + break; + case TT_DBLSCAN: + ptr->ml_flags |= XF86CONF_DBLSCAN; + break; + case TT_HSKEW: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error (NUMBER_MSG, "Hskew"); + ptr->ml_hskew = val.num; + ptr->ml_flags |= XF86CONF_HSKEW; + break; + case TT_BCAST: + ptr->ml_flags |= XF86CONF_BCAST; + break; + case TT_VSCAN: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error (NUMBER_MSG, "Vscan"); + ptr->ml_vscan = val.num; + ptr->ml_flags |= XF86CONF_VSCAN; + break; + case TT_CUSTOM: + ptr->ml_flags |= XF86CONF_CUSTOM; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab); + } + xf86unGetToken (token); + +#ifdef DEBUG + printf ("ModeLine parsed\n"); +#endif + return (ptr); +} + +static XF86ConfModeLinePtr +xf86parseVerboseMode (void) +{ + int token, token2; + int had_dotclock = 0, had_htimings = 0, had_vtimings = 0; + parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) + + if (xf86getSubToken (&(ptr->ml_comment)) != STRING) + Error ("Mode name expected", NULL); + ptr->ml_identifier = val.str; + while ((token = xf86getToken (ModeTab)) != ENDMODE) + { + switch (token) + { + case COMMENT: + ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str); + break; + case DOTCLOCK: + if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER) + Error (NUMBER_MSG, "DotClock"); + ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); + had_dotclock = 1; + break; + case HTIMINGS: + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_hdisplay = val.num; + else + Error ("Horizontal display expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_hsyncstart = val.num; + else + Error ("Horizontal sync start expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_hsyncend = val.num; + else + Error ("Horizontal sync end expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_htotal = val.num; + else + Error ("Horizontal total expected", NULL); + had_htimings = 1; + break; + case VTIMINGS: + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vdisplay = val.num; + else + Error ("Vertical display expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vsyncstart = val.num; + else + Error ("Vertical sync start expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vsyncend = val.num; + else + Error ("Vertical sync end expected", NULL); + + if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER) + ptr->ml_vtotal = val.num; + else + Error ("Vertical total expected", NULL); + had_vtimings = 1; + break; + case FLAGS: + token = xf86getSubToken (&(ptr->ml_comment)); + if (token != STRING) + Error (QUOTE_MSG, "Flags"); + while (token == STRING) + { + token2 = xf86getStringToken (TimingTab); + switch (token2) + { + case TT_INTERLACE: + ptr->ml_flags |= XF86CONF_INTERLACE; + break; + case TT_PHSYNC: + ptr->ml_flags |= XF86CONF_PHSYNC; + break; + case TT_NHSYNC: + ptr->ml_flags |= XF86CONF_NHSYNC; + break; + case TT_PVSYNC: + ptr->ml_flags |= XF86CONF_PVSYNC; + break; + case TT_NVSYNC: + ptr->ml_flags |= XF86CONF_NVSYNC; + break; + case TT_CSYNC: + ptr->ml_flags |= XF86CONF_CSYNC; + break; + case TT_PCSYNC: + ptr->ml_flags |= XF86CONF_PCSYNC; + break; + case TT_NCSYNC: + ptr->ml_flags |= XF86CONF_NCSYNC; + break; + case TT_DBLSCAN: + ptr->ml_flags |= XF86CONF_DBLSCAN; + break; + case TT_CUSTOM: + ptr->ml_flags |= XF86CONF_CUSTOM; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error ("Unknown flag string", NULL); + break; + } + token = xf86getSubToken (&(ptr->ml_comment)); + } + xf86unGetToken (token); + break; + case HSKEW: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("Horizontal skew expected", NULL); + ptr->ml_flags |= XF86CONF_HSKEW; + ptr->ml_hskew = val.num; + break; + case VSCAN: + if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER) + Error ("Vertical scan count expected", NULL); + ptr->ml_flags |= XF86CONF_VSCAN; + ptr->ml_vscan = val.num; + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL); + } + } + if (!had_dotclock) + Error ("the dotclock is missing", NULL); + if (!had_htimings) + Error ("the horizontal timings are missing", NULL); + if (!had_vtimings) + Error ("the vertical timings are missing", NULL); + +#ifdef DEBUG + printf ("Verbose Mode parsed\n"); +#endif + return (ptr); +} + +#undef CLEANUP + +#define CLEANUP xf86freeMonitorList + +XF86ConfMonitorPtr +xf86parseMonitorSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) + + while ((token = xf86getToken (MonitorTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->mon_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->mon_identifier = val.str; + has_ident = TRUE; + break; + case VENDOR: + if (xf86getSubToken (&(ptr->mon_comment)) != STRING) + Error (QUOTE_MSG, "Vendor"); + ptr->mon_vendor = val.str; + break; + case MODEL: + if (xf86getSubToken (&(ptr->mon_comment)) != STRING) + Error (QUOTE_MSG, "ModelName"); + ptr->mon_modelname = val.str; + break; + case MODE: + HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, + XF86ConfModeLinePtr); + break; + case MODELINE: + HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, + XF86ConfModeLinePtr); + break; + case DISPLAYSIZE: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (DISPLAYSIZE_MSG, NULL); + ptr->mon_width = val.realnum; + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (DISPLAYSIZE_MSG, NULL); + ptr->mon_height = val.realnum; + break; + + case HORIZSYNC: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (HORIZSYNC_MSG, NULL); + do { + if (ptr->mon_n_hsync >= CONF_MAX_HSYNC) + Error ("Sorry. Too many horizontal sync intervals.", NULL); + ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum; + switch (token = xf86getSubToken (&(ptr->mon_comment))) + { + case COMMA: + ptr->mon_hsync[ptr->mon_n_hsync].hi = + ptr->mon_hsync[ptr->mon_n_hsync].lo; + break; + case DASH: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER || + (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo) + Error (HORIZSYNC_MSG, NULL); + ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum; + if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA) + break; + ptr->mon_n_hsync++; + goto HorizDone; + default: + /* We cannot currently know if a '\n' was found, + * or this is a real error + */ + ptr->mon_hsync[ptr->mon_n_hsync].hi = + ptr->mon_hsync[ptr->mon_n_hsync].lo; + ptr->mon_n_hsync++; + goto HorizDone; + } + ptr->mon_n_hsync++; + } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER); +HorizDone: + xf86unGetToken (token); + break; + + case VERTREFRESH: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER) + Error (VERTREFRESH_MSG, NULL); + do { + ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum; + switch (token = xf86getSubToken (&(ptr->mon_comment))) + { + case COMMA: + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = + ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; + break; + case DASH: + if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER || + (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo) + Error (VERTREFRESH_MSG, NULL); + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum; + if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA) + break; + ptr->mon_n_vrefresh++; + goto VertDone; + default: + /* We cannot currently know if a '\n' was found, + * or this is a real error + */ + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = + ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; + ptr->mon_n_vrefresh++; + goto VertDone; + } + if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH) + Error ("Sorry. Too many vertical refresh intervals.", NULL); + ptr->mon_n_vrefresh++; + } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER); +VertDone: + xf86unGetToken (token); + break; + + case GAMMA: + if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER ) + { + Error (INVALID_GAMMA_MSG, NULL); + } + else + { + ptr->mon_gamma_red = ptr->mon_gamma_green = + ptr->mon_gamma_blue = val.realnum; + if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER ) + { + ptr->mon_gamma_green = val.realnum; + if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER ) + { + ptr->mon_gamma_blue = val.realnum; + } + else + { + Error (INVALID_GAMMA_MSG, NULL); + } + } + else + xf86unGetToken (token); + } + break; + case OPTION: + ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst); + break; + case USEMODES: + { + XF86ConfModesLinkPtr mptr; + + if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING) + Error (QUOTE_MSG, "UseModes"); + + /* add to the end of the list of modes sections + referenced here */ + mptr = xf86confcalloc (1, sizeof (XF86ConfModesLinkRec)); + mptr->list.next = NULL; + mptr->ml_modes_str = val.str; + mptr->ml_modes = NULL; + ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr) + xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst, + (GenericListPtr)mptr); + } + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); + CLEANUP (ptr); + return NULL; + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Monitor section parsed\n"); +#endif + return ptr; +} + +#undef CLEANUP +#define CLEANUP xf86freeModesList + +XF86ConfModesPtr +xf86parseModesSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfModesPtr, XF86ConfModesRec) + + while ((token = xf86getToken (ModesTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->modes_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->modes_identifier = val.str; + has_ident = TRUE; + break; + case MODE: + HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, + XF86ConfModeLinePtr); + break; + case MODELINE: + HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, + XF86ConfModeLinePtr); + break; + default: + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); + CLEANUP (ptr); + return NULL; + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Modes section parsed\n"); +#endif + return ptr; +} + +#undef CLEANUP + +void +xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr) +{ + int i; + XF86ConfModeLinePtr mlptr; + XF86ConfModesLinkPtr mptr; + + while (ptr) + { + mptr = ptr->mon_modes_sect_lst; + fprintf (cf, "Section \"Monitor\"\n"); + if (ptr->mon_comment) + fprintf (cf, "%s", ptr->mon_comment); + if (ptr->mon_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier); + if (ptr->mon_vendor) + fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor); + if (ptr->mon_modelname) + fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname); + while (mptr) { + fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str); + mptr = mptr->list.next; + } + if (ptr->mon_width) + fprintf (cf, "\tDisplaySize %d\t%d\n", + ptr->mon_width, + ptr->mon_height); + for (i = 0; i < ptr->mon_n_hsync; i++) + { + fprintf (cf, "\tHorizSync %2.1f - %2.1f\n", + ptr->mon_hsync[i].lo, + ptr->mon_hsync[i].hi); + } + for (i = 0; i < ptr->mon_n_vrefresh; i++) + { + fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n", + ptr->mon_vrefresh[i].lo, + ptr->mon_vrefresh[i].hi); + } + if (ptr->mon_gamma_red) { + if (ptr->mon_gamma_red == ptr->mon_gamma_green + && ptr->mon_gamma_red == ptr->mon_gamma_blue) + { + fprintf (cf, "\tGamma %.4g\n", + ptr->mon_gamma_red); + } else { + fprintf (cf, "\tGamma %.4g %.4g %.4g\n", + ptr->mon_gamma_red, + ptr->mon_gamma_green, + ptr->mon_gamma_blue); + } + } + for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) + { + fprintf (cf, "\tModeLine \"%s\" %2.1f ", + mlptr->ml_identifier, mlptr->ml_clock / 1000.0); + fprintf (cf, "%d %d %d %d %d %d %d %d", + mlptr->ml_hdisplay, mlptr->ml_hsyncstart, + mlptr->ml_hsyncend, mlptr->ml_htotal, + mlptr->ml_vdisplay, mlptr->ml_vsyncstart, + mlptr->ml_vsyncend, mlptr->ml_vtotal); + if (mlptr->ml_flags & XF86CONF_PHSYNC) + fprintf (cf, " +hsync"); + if (mlptr->ml_flags & XF86CONF_NHSYNC) + fprintf (cf, " -hsync"); + if (mlptr->ml_flags & XF86CONF_PVSYNC) + fprintf (cf, " +vsync"); + if (mlptr->ml_flags & XF86CONF_NVSYNC) + fprintf (cf, " -vsync"); + if (mlptr->ml_flags & XF86CONF_INTERLACE) + fprintf (cf, " interlace"); + if (mlptr->ml_flags & XF86CONF_CSYNC) + fprintf (cf, " composite"); + if (mlptr->ml_flags & XF86CONF_PCSYNC) + fprintf (cf, " +csync"); + if (mlptr->ml_flags & XF86CONF_NCSYNC) + fprintf (cf, " -csync"); + if (mlptr->ml_flags & XF86CONF_DBLSCAN) + fprintf (cf, " doublescan"); + if (mlptr->ml_flags & XF86CONF_HSKEW) + fprintf (cf, " hskew %d", mlptr->ml_hskew); + if (mlptr->ml_flags & XF86CONF_BCAST) + fprintf (cf, " bcast"); + fprintf (cf, "\n"); + } + xf86printOptionList(cf, ptr->mon_option_lst, 1); + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr) +{ + XF86ConfModeLinePtr mlptr; + + while (ptr) + { + fprintf (cf, "Section \"Modes\"\n"); + if (ptr->modes_comment) + fprintf (cf, "%s", ptr->modes_comment); + if (ptr->modes_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier); + for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next) + { + fprintf (cf, "\tModeLine \"%s\" %2.1f ", + mlptr->ml_identifier, mlptr->ml_clock / 1000.0); + fprintf (cf, "%d %d %d %d %d %d %d %d", + mlptr->ml_hdisplay, mlptr->ml_hsyncstart, + mlptr->ml_hsyncend, mlptr->ml_htotal, + mlptr->ml_vdisplay, mlptr->ml_vsyncstart, + mlptr->ml_vsyncend, mlptr->ml_vtotal); + if (mlptr->ml_flags & XF86CONF_PHSYNC) + fprintf (cf, " +hsync"); + if (mlptr->ml_flags & XF86CONF_NHSYNC) + fprintf (cf, " -hsync"); + if (mlptr->ml_flags & XF86CONF_PVSYNC) + fprintf (cf, " +vsync"); + if (mlptr->ml_flags & XF86CONF_NVSYNC) + fprintf (cf, " -vsync"); + if (mlptr->ml_flags & XF86CONF_INTERLACE) + fprintf (cf, " interlace"); + if (mlptr->ml_flags & XF86CONF_CSYNC) + fprintf (cf, " composite"); + if (mlptr->ml_flags & XF86CONF_PCSYNC) + fprintf (cf, " +csync"); + if (mlptr->ml_flags & XF86CONF_NCSYNC) + fprintf (cf, " -csync"); + if (mlptr->ml_flags & XF86CONF_DBLSCAN) + fprintf (cf, " doublescan"); + if (mlptr->ml_flags & XF86CONF_HSKEW) + fprintf (cf, " hskew %d", mlptr->ml_hskew); + if (mlptr->ml_flags & XF86CONF_VSCAN) + fprintf (cf, " vscan %d", mlptr->ml_vscan); + if (mlptr->ml_flags & XF86CONF_BCAST) + fprintf (cf, " bcast"); + if (mlptr->ml_comment) + fprintf (cf, "%s", mlptr->ml_comment); + else + fprintf (cf, "\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeMonitorList (XF86ConfMonitorPtr ptr) +{ + XF86ConfMonitorPtr prev; + + while (ptr) + { + TestFree (ptr->mon_identifier); + TestFree (ptr->mon_vendor); + TestFree (ptr->mon_modelname); + TestFree (ptr->mon_comment); + xf86optionListFree (ptr->mon_option_lst); + xf86freeModeLineList (ptr->mon_modeline_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeModesList (XF86ConfModesPtr ptr) +{ + XF86ConfModesPtr prev; + + while (ptr) + { + TestFree (ptr->modes_identifier); + TestFree (ptr->modes_comment); + xf86freeModeLineList (ptr->mon_modeline_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +XF86ConfMonitorPtr +xf86findMonitor (const char *ident, XF86ConfMonitorPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->mon_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +XF86ConfModesPtr +xf86findModes (const char *ident, XF86ConfModesPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->modes_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +XF86ConfModeLinePtr +xf86findModeLine (const char *ident, XF86ConfModeLinePtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->ml_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + +int +xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen) +{ + XF86ConfMonitorPtr monitor = screen->scrn_monitor; + XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst; + XF86ConfModesPtr modes; + while(modeslnk) + { + modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst); + if (!modes) + { + xf86validationError (UNDEFINED_MODES_MSG, + modeslnk->ml_modes_str, + screen->scrn_identifier); + return (FALSE); + } + modeslnk->ml_modes = modes; + modeslnk = modeslnk->list.next; + } + return (TRUE); +} diff --git a/xorg-server/hw/xfree86/parser/Pointer.c b/xorg-server/hw/xfree86/parser/Pointer.c new file mode 100644 index 000000000..eeb0834bf --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Pointer.c @@ -0,0 +1,237 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec PointerTab[] = +{ + {PROTOCOL, "protocol"}, + {EMULATE3, "emulate3buttons"}, + {EM3TIMEOUT, "emulate3timeout"}, + {ENDSUBSECTION, "endsubsection"}, + {ENDSECTION, "endsection"}, + {PDEVICE, "device"}, + {PDEVICE, "port"}, + {BAUDRATE, "baudrate"}, + {SAMPLERATE, "samplerate"}, + {CLEARDTR, "cleardtr"}, + {CLEARRTS, "clearrts"}, + {CHORDMIDDLE, "chordmiddle"}, + {PRESOLUTION, "resolution"}, + {DEVICE_NAME, "devicename"}, + {ALWAYSCORE, "alwayscore"}, + {PBUTTONS, "buttons"}, + {ZAXISMAPPING, "zaxismapping"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ZMapTab[] = +{ + {XAXIS, "x"}, + {YAXIS, "y"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeInputList + +XF86ConfInputPtr +xf86parsePointerSection (void) +{ + char *s, *s1, *s2; + int l; + int token; + parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) + + while ((token = xf86getToken (PointerTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str); + break; + case PROTOCOL: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Protocol"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Protocol"), + val.str); + break; + case PDEVICE: + if (xf86getSubToken (&(ptr->inp_comment)) != STRING) + Error (QUOTE_MSG, "Device"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Device"), + val.str); + break; + case EMULATE3: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Emulate3Buttons"), + NULL); + break; + case EM3TIMEOUT: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "Emulate3Timeout"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Emulate3Timeout"), + s); + break; + case CHORDMIDDLE: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ChordMiddle"), + NULL); + break; + case PBUTTONS: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "Buttons"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Buttons"), s); + break; + case BAUDRATE: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "BaudRate"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("BaudRate"), s); + break; + case SAMPLERATE: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "SampleRate"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("SampleRate"), s); + break; + case PRESOLUTION: + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) + Error (POSITIVE_INT_MSG, "Resolution"); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Resolution"), s); + break; + case CLEARDTR: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ClearDTR"), NULL); + break; + case CLEARRTS: + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ClearRTS"), NULL); + break; + case ZAXISMAPPING: + switch (xf86getToken(ZMapTab)) { + case NUMBER: + if (val.num < 0) + Error (ZAXISMAPPING_MSG, NULL); + s1 = xf86uLongToString(val.num); + if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) { + xf86conffree(s1); + Error (ZAXISMAPPING_MSG, NULL); + } + s2 = xf86uLongToString(val.num); + l = strlen(s1) + 1 + strlen(s2) + 1; + s = xf86confmalloc(l); + sprintf(s, "%s %s", s1, s2); + xf86conffree(s1); + xf86conffree(s2); + break; + case XAXIS: + s = xf86configStrdup("x"); + break; + case YAXIS: + s = xf86configStrdup("y"); + break; + default: + Error (ZAXISMAPPING_MSG, NULL); + break; + } + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ZAxisMapping"), + s); + break; + case ALWAYSCORE: + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_POINTER); + ptr->inp_driver = xf86configStrdup("mouse"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("CorePointer"), NULL); + +#ifdef DEBUG + printf ("Pointer section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c new file mode 100644 index 000000000..dfc02bb72 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Screen.c @@ -0,0 +1,569 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec DisplayTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {MODES, "modes"}, + {VIEWPORT, "viewport"}, + {VIRTUAL, "virtual"}, + {VISUAL, "visual"}, + {BLACK_TOK, "black"}, + {WHITE_TOK, "white"}, + {DEPTH, "depth"}, + {BPP, "fbbpp"}, + {WEIGHT, "weight"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeDisplayList + +static XF86ConfDisplayPtr +xf86parseDisplaySubSection (void) +{ + int token; + parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec) + + ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1; + ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1; + ptr->disp_frameX0 = ptr->disp_frameY0 = -1; + while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str); + break; + case VIEWPORT: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIEWPORT_MSG, NULL); + ptr->disp_frameX0 = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIEWPORT_MSG, NULL); + ptr->disp_frameY0 = val.num; + break; + case VIRTUAL: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIRTUAL_MSG, NULL); + ptr->disp_virtualX = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (VIRTUAL_MSG, NULL); + ptr->disp_virtualY = val.num; + break; + case DEPTH: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (NUMBER_MSG, "Display"); + ptr->disp_depth = val.num; + break; + case BPP: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (NUMBER_MSG, "Display"); + ptr->disp_bpp = val.num; + break; + case VISUAL: + if (xf86getSubToken (&(ptr->disp_comment)) != STRING) + Error (QUOTE_MSG, "Display"); + ptr->disp_visual = val.str; + break; + case WEIGHT: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WEIGHT_MSG, NULL); + ptr->disp_weight.red = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WEIGHT_MSG, NULL); + ptr->disp_weight.green = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WEIGHT_MSG, NULL); + ptr->disp_weight.blue = val.num; + break; + case BLACK_TOK: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (BLACK_MSG, NULL); + ptr->disp_black.red = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (BLACK_MSG, NULL); + ptr->disp_black.green = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (BLACK_MSG, NULL); + ptr->disp_black.blue = val.num; + break; + case WHITE_TOK: + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WHITE_MSG, NULL); + ptr->disp_white.red = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WHITE_MSG, NULL); + ptr->disp_white.green = val.num; + if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER) + Error (WHITE_MSG, NULL); + ptr->disp_white.blue = val.num; + break; + case MODES: + { + XF86ModePtr mptr; + + while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING) + { + mptr = xf86confcalloc (1, sizeof (XF86ModeRec)); + mptr->mode_name = val.str; + mptr->list.next = NULL; + ptr->disp_mode_lst = (XF86ModePtr) + xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr); + } + xf86unGetToken (token); + } + break; + case OPTION: + ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Display subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +static xf86ConfigSymTabRec ScreenTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {OBSDRIVER, "driver"}, + {MDEVICE, "device"}, + {MONITOR, "monitor"}, + {VIDEOADAPTOR, "videoadaptor"}, + {SCREENNO, "screenno"}, + {SUBSECTION, "subsection"}, + {DEFAULTDEPTH, "defaultcolordepth"}, + {DEFAULTDEPTH, "defaultdepth"}, + {DEFAULTBPP, "defaultbpp"}, + {DEFAULTFBBPP, "defaultfbbpp"}, + {VIRTUAL, "virtual"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeScreenList +XF86ConfScreenPtr +xf86parseScreenSection (void) +{ + int has_ident = FALSE; + int has_driver= FALSE; + int token; + + parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec) + + while ((token = xf86getToken (ScreenTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + ptr->scrn_identifier = val.str; + if (has_ident || has_driver) + Error (ONLY_ONE_MSG,"Identifier or Driver"); + has_ident = TRUE; + break; + case OBSDRIVER: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + ptr->scrn_obso_driver = val.str; + if (has_ident || has_driver) + Error (ONLY_ONE_MSG,"Identifier or Driver"); + has_driver = TRUE; + break; + case DEFAULTDEPTH: + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (NUMBER_MSG, "DefaultDepth"); + ptr->scrn_defaultdepth = val.num; + break; + case DEFAULTBPP: + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (NUMBER_MSG, "DefaultBPP"); + ptr->scrn_defaultbpp = val.num; + break; + case DEFAULTFBBPP: + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (NUMBER_MSG, "DefaultFbBPP"); + ptr->scrn_defaultfbbpp = val.num; + break; + case MDEVICE: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Device"); + ptr->scrn_device_str = val.str; + break; + case MONITOR: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "Monitor"); + ptr->scrn_monitor_str = val.str; + break; + case VIDEOADAPTOR: + { + XF86ConfAdaptorLinkPtr aptr; + + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "VideoAdaptor"); + + /* Don't allow duplicates */ + for (aptr = ptr->scrn_adaptor_lst; aptr; + aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next) + if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0) + break; + + if (aptr == NULL) + { + aptr = xf86confcalloc (1, sizeof (XF86ConfAdaptorLinkRec)); + aptr->list.next = NULL; + aptr->al_adaptor_str = val.str; + ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr) + xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr); + } + } + break; + case VIRTUAL: + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (VIRTUAL_MSG, NULL); + ptr->scrn_virtualX = val.num; + if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER) + Error (VIRTUAL_MSG, NULL); + ptr->scrn_virtualY = val.num; + break; + case OPTION: + ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->scrn_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + xf86conffree(val.str); + HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection, + XF86ConfDisplayPtr); + } + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + if (!has_ident && !has_driver) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Screen section parsed\n"); +#endif + + return ptr; +} + +void +xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr) +{ + XF86ConfAdaptorLinkPtr aptr; + XF86ConfDisplayPtr dptr; + XF86ModePtr mptr; + + while (ptr) + { + fprintf (cf, "Section \"Screen\"\n"); + if (ptr->scrn_comment) + fprintf (cf, "%s", ptr->scrn_comment); + if (ptr->scrn_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier); + if (ptr->scrn_obso_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver); + if (ptr->scrn_device_str) + fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str); + if (ptr->scrn_monitor_str) + fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str); + if (ptr->scrn_defaultdepth) + fprintf (cf, "\tDefaultDepth %d\n", + ptr->scrn_defaultdepth); + if (ptr->scrn_defaultbpp) + fprintf (cf, "\tDefaultBPP %d\n", + ptr->scrn_defaultbpp); + if (ptr->scrn_defaultfbbpp) + fprintf (cf, "\tDefaultFbBPP %d\n", + ptr->scrn_defaultfbbpp); + xf86printOptionList(cf, ptr->scrn_option_lst, 1); + for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next) + { + fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str); + } + if (ptr->scrn_virtualX && ptr->scrn_virtualY) + fprintf (cf, "\tVirtual %d %d\n", + ptr->scrn_virtualX, + ptr->scrn_virtualY); + for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next) + { + fprintf (cf, "\tSubSection \"Display\"\n"); + if (dptr->disp_comment) + fprintf (cf, "%s", dptr->disp_comment); + if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0) + { + fprintf (cf, "\t\tViewport %d %d\n", + dptr->disp_frameX0, dptr->disp_frameY0); + } + if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0) + { + fprintf (cf, "\t\tVirtual %d %d\n", + dptr->disp_virtualX, dptr->disp_virtualY); + } + if (dptr->disp_depth) + { + fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth); + } + if (dptr->disp_bpp) + { + fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp); + } + if (dptr->disp_visual) + { + fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual); + } + if (dptr->disp_weight.red != 0) + { + fprintf (cf, "\t\tWeight %d %d %d\n", + dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue); + } + if (dptr->disp_black.red != -1) + { + fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n", + dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue); + } + if (dptr->disp_white.red != -1) + { + fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n", + dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue); + } + if (dptr->disp_mode_lst) + { + fprintf (cf, "\t\tModes "); + } + for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next) + { + fprintf (cf, " \"%s\"", mptr->mode_name); + } + if (dptr->disp_mode_lst) + { + fprintf (cf, "\n"); + } + xf86printOptionList(cf, dptr->disp_option_lst, 2); + fprintf (cf, "\tEndSubSection\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } + +} + +void +xf86freeScreenList (XF86ConfScreenPtr ptr) +{ + XF86ConfScreenPtr prev; + + while (ptr) + { + TestFree (ptr->scrn_identifier); + TestFree (ptr->scrn_monitor_str); + TestFree (ptr->scrn_device_str); + TestFree (ptr->scrn_comment); + xf86optionListFree (ptr->scrn_option_lst); + xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst); + xf86freeDisplayList (ptr->scrn_display_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr) +{ + XF86ConfAdaptorLinkPtr prev; + + while (ptr) + { + TestFree (ptr->al_adaptor_str); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeDisplayList (XF86ConfDisplayPtr ptr) +{ + XF86ConfDisplayPtr prev; + + while (ptr) + { + xf86freeModeList (ptr->disp_mode_lst); + xf86optionListFree (ptr->disp_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +void +xf86freeModeList (XF86ModePtr ptr) +{ + XF86ModePtr prev; + + while (ptr) + { + TestFree (ptr->mode_name); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +int +xf86validateScreen (XF86ConfigPtr p) +{ + XF86ConfScreenPtr screen = p->conf_screen_lst; + XF86ConfMonitorPtr monitor; + XF86ConfAdaptorLinkPtr adaptor; + + while (screen) + { + if (screen->scrn_obso_driver && !screen->scrn_identifier) + screen->scrn_identifier = screen->scrn_obso_driver; + + monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst); + if (screen->scrn_monitor_str) + { + if (monitor) + { + screen->scrn_monitor = monitor; + if (!xf86validateMonitor(p, screen)) + return (FALSE); + } + } + + screen->scrn_device= xf86findDevice (screen->scrn_device_str, p->conf_device_lst); + + adaptor = screen->scrn_adaptor_lst; + while (adaptor) + { + adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst); + if (!adaptor->al_adaptor) + { + xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier); + return (FALSE); + } + else if (adaptor->al_adaptor->va_fwdref) + { + xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str, + adaptor->al_adaptor->va_fwdref); + return (FALSE); + } + + adaptor->al_adaptor->va_fwdref = xf86configStrdup(screen->scrn_identifier); + adaptor = adaptor->list.next; + } + + screen = screen->list.next; + } + + return (TRUE); +} + +XF86ConfScreenPtr +xf86findScreen (const char *ident, XF86ConfScreenPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->scrn_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} + diff --git a/xorg-server/hw/xfree86/parser/Vendor.c b/xorg-server/hw/xfree86/parser/Vendor.c new file mode 100644 index 000000000..d1e608067 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Vendor.c @@ -0,0 +1,244 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec VendorSubTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVendorSubList + +static XF86ConfVendSubPtr +xf86parseVendorSubSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfVendSubPtr, XF86ConfVendSubRec) + + while ((token = xf86getToken (VendorSubTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->vs_comment = xf86addComment(ptr->vs_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->vs_comment))) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->vs_identifier = val.str; + has_ident = TRUE; + break; + case OPTION: + ptr->vs_option_lst = xf86parseOption(ptr->vs_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Vendor subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +static xf86ConfigSymTabRec VendorTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {SUBSECTION, "subsection"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVendorList + +XF86ConfVendorPtr +xf86parseVendorSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfVendorPtr, XF86ConfVendorRec) + + while ((token = xf86getToken (VendorTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->vnd_comment = xf86addComment(ptr->vnd_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->vnd_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->vnd_identifier = val.str; + has_ident = TRUE; + break; + case OPTION: + ptr->vnd_option_lst = xf86parseOption(ptr->vnd_option_lst); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->vnd_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + HANDLE_LIST (vnd_sub_lst, xf86parseVendorSubSection, + XF86ConfVendSubPtr); + } + break; + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("Vendor section parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +void +xf86printVendorSection (FILE * cf, XF86ConfVendorPtr ptr) +{ + XF86ConfVendSubPtr pptr; + + while (ptr) + { + fprintf (cf, "Section \"Vendor\"\n"); + if (ptr->vnd_comment) + fprintf (cf, "%s", ptr->vnd_comment); + if (ptr->vnd_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->vnd_identifier); + + xf86printOptionList(cf, ptr->vnd_option_lst, 1); + for (pptr = ptr->vnd_sub_lst; pptr; pptr = pptr->list.next) + { + fprintf (cf, "\tSubSection \"Vendor\"\n"); + if (pptr->vs_comment) + fprintf (cf, "%s", pptr->vs_comment); + if (pptr->vs_identifier) + fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vs_identifier); + xf86printOptionList(cf, pptr->vs_option_lst, 2); + fprintf (cf, "\tEndSubSection\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } +} + +void +xf86freeVendorList (XF86ConfVendorPtr p) +{ + if (p == NULL) + return; + xf86freeVendorSubList (p->vnd_sub_lst); + TestFree (p->vnd_identifier); + TestFree (p->vnd_comment); + xf86optionListFree (p->vnd_option_lst); + xf86conffree (p); +} + +void +xf86freeVendorSubList (XF86ConfVendSubPtr ptr) +{ + XF86ConfVendSubPtr prev; + + while (ptr) + { + TestFree (ptr->vs_identifier); + TestFree (ptr->vs_name); + TestFree (ptr->vs_comment); + xf86optionListFree (ptr->vs_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} diff --git a/xorg-server/hw/xfree86/parser/Video.c b/xorg-server/hw/xfree86/parser/Video.c new file mode 100644 index 000000000..a8912cf44 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/Video.c @@ -0,0 +1,296 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec VideoPortTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVideoPortList + +static void +xf86freeVideoPortList (XF86ConfVideoPortPtr ptr) +{ + XF86ConfVideoPortPtr prev; + + while (ptr) + { + TestFree (ptr->vp_identifier); + TestFree (ptr->vp_comment); + xf86optionListFree (ptr->vp_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +static XF86ConfVideoPortPtr +xf86parseVideoPortSubSection (void) +{ + int has_ident = FALSE; + int token; + parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec) + + while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION) + { + switch (token) + { + case COMMENT: + ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->vp_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + ptr->vp_identifier = val.str; + has_ident = TRUE; + break; + case OPTION: + ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst); + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("VideoPort subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + +static xf86ConfigSymTabRec VideoAdaptorTab[] = +{ + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {VENDOR, "vendorname"}, + {BOARD, "boardname"}, + {BUSID, "busid"}, + {DRIVER, "driver"}, + {OPTION, "option"}, + {SUBSECTION, "subsection"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVideoAdaptorList + +XF86ConfVideoAdaptorPtr +xf86parseVideoAdaptorSection (void) +{ + int has_ident = FALSE; + int token; + + parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec) + + while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION) + { + switch (token) + { + case COMMENT: + ptr->va_comment = xf86addComment(ptr->va_comment, val.str); + break; + case IDENTIFIER: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Identifier"); + ptr->va_identifier = val.str; + if (has_ident == TRUE) + Error (MULTIPLE_MSG, "Identifier"); + has_ident = TRUE; + break; + case VENDOR: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Vendor"); + ptr->va_vendor = val.str; + break; + case BOARD: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Board"); + ptr->va_board = val.str; + break; + case BUSID: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "BusID"); + ptr->va_busid = val.str; + break; + case DRIVER: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "Driver"); + ptr->va_driver = val.str; + break; + case OPTION: + ptr->va_option_lst = xf86parseOption(ptr->va_option_lst); + break; + case SUBSECTION: + if (xf86getSubToken (&(ptr->va_comment)) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection, + XF86ConfVideoPortPtr); + } + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + + if (!has_ident) + Error (NO_IDENT_MSG, NULL); + +#ifdef DEBUG + printf ("VideoAdaptor section parsed\n"); +#endif + + return ptr; +} + +void +xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr) +{ + XF86ConfVideoPortPtr pptr; + + while (ptr) + { + fprintf (cf, "Section \"VideoAdaptor\"\n"); + if (ptr->va_comment) + fprintf (cf, "%s", ptr->va_comment); + if (ptr->va_identifier) + fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier); + if (ptr->va_vendor) + fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor); + if (ptr->va_board) + fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board); + if (ptr->va_busid) + fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid); + if (ptr->va_driver) + fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver); + xf86printOptionList(cf, ptr->va_option_lst, 1); + for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next) + { + fprintf (cf, "\tSubSection \"VideoPort\"\n"); + if (pptr->vp_comment) + fprintf (cf, "%s", pptr->vp_comment); + if (pptr->vp_identifier) + fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier); + xf86printOptionList(cf, pptr->vp_option_lst, 2); + fprintf (cf, "\tEndSubSection\n"); + } + fprintf (cf, "EndSection\n\n"); + ptr = ptr->list.next; + } + +} + +void +xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr) +{ + XF86ConfVideoAdaptorPtr prev; + + while (ptr) + { + TestFree (ptr->va_identifier); + TestFree (ptr->va_vendor); + TestFree (ptr->va_board); + TestFree (ptr->va_busid); + TestFree (ptr->va_driver); + TestFree (ptr->va_fwdref); + TestFree (ptr->va_comment); + xf86freeVideoPortList (ptr->va_port_lst); + xf86optionListFree (ptr->va_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + +XF86ConfVideoAdaptorPtr +xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p) +{ + while (p) + { + if (xf86nameCompare (ident, p->va_identifier) == 0) + return (p); + + p = p->list.next; + } + return (NULL); +} diff --git a/xorg-server/hw/xfree86/parser/configProcs.h b/xorg-server/hw/xfree86/parser/configProcs.h new file mode 100644 index 000000000..3c9ce7a83 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/configProcs.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1997-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* Private procs. Public procs are in xf86Parser.h and xf86Optrec.h */ + +/* Device.c */ +XF86ConfDevicePtr xf86parseDeviceSection(void); +void xf86printDeviceSection(FILE *cf, XF86ConfDevicePtr ptr); +void xf86freeDeviceList(XF86ConfDevicePtr ptr); +int xf86validateDevice(XF86ConfigPtr p); +/* Files.c */ +XF86ConfFilesPtr xf86parseFilesSection(void); +void xf86printFileSection(FILE *cf, XF86ConfFilesPtr ptr); +void xf86freeFiles(XF86ConfFilesPtr p); +/* Flags.c */ +XF86ConfFlagsPtr xf86parseFlagsSection(void); +void xf86printServerFlagsSection(FILE *f, XF86ConfFlagsPtr flags); +void xf86freeFlags(XF86ConfFlagsPtr flags); +/* Input.c */ +XF86ConfInputPtr xf86parseInputSection(void); +void xf86printInputSection(FILE *f, XF86ConfInputPtr ptr); +void xf86freeInputList(XF86ConfInputPtr ptr); +int xf86validateInput (XF86ConfigPtr p); +/* Layout.c */ +XF86ConfLayoutPtr xf86parseLayoutSection(void); +void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr); +void xf86freeLayoutList(XF86ConfLayoutPtr ptr); +int xf86validateLayout(XF86ConfigPtr p); +/* Module.c */ +XF86ConfModulePtr xf86parseModuleSection(void); +void xf86printModuleSection(FILE *cf, XF86ConfModulePtr ptr); +XF86LoadPtr xf86addNewLoadDirective(XF86LoadPtr head, char *name, int type, XF86OptionPtr opts); +void xf86freeModules(XF86ConfModulePtr ptr); +/* Monitor.c */ +XF86ConfMonitorPtr xf86parseMonitorSection(void); +XF86ConfModesPtr xf86parseModesSection(void); +void xf86printMonitorSection(FILE *cf, XF86ConfMonitorPtr ptr); +void xf86printModesSection(FILE *cf, XF86ConfModesPtr ptr); +void xf86freeMonitorList(XF86ConfMonitorPtr ptr); +void xf86freeModesList(XF86ConfModesPtr ptr); +int xf86validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen); +/* Pointer.c */ +XF86ConfInputPtr xf86parsePointerSection(void); +/* Screen.c */ +XF86ConfScreenPtr xf86parseScreenSection(void); +void xf86printScreenSection(FILE *cf, XF86ConfScreenPtr ptr); +void xf86freeScreenList(XF86ConfScreenPtr ptr); +void xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr ptr); +void xf86freeDisplayList(XF86ConfDisplayPtr ptr); +void xf86freeModeList(XF86ModePtr ptr); +int xf86validateScreen(XF86ConfigPtr p); +/* Vendor.c */ +XF86ConfVendorPtr xf86parseVendorSection(void); +void xf86freeVendorList(XF86ConfVendorPtr p); +void xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr); +void xf86freeVendorSubList (XF86ConfVendSubPtr ptr); +/* Video.c */ +XF86ConfVideoAdaptorPtr xf86parseVideoAdaptorSection(void); +void xf86printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr); +void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr); +/* scan.c */ +int xf86getToken(xf86ConfigSymTabRec *tab); +int xf86getSubToken(char **comment); +int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec *tab); +void xf86unGetToken(int token); +char *xf86tokenString(void); +void xf86parseError(char *format, ...); +void xf86validationError(char *format, ...); +void xf86setSection(char *section); +int xf86getStringToken(xf86ConfigSymTabRec *tab); +/* write.c */ +/* DRI.c */ +XF86ConfDRIPtr xf86parseDRISection (void); +void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr); +void xf86freeDRI (XF86ConfDRIPtr ptr); +/* Extensions.c */ +XF86ConfExtensionsPtr xf86parseExtensionsSection (void); +void xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr); +void xf86freeExtensions (XF86ConfExtensionsPtr ptr); + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef IN_XSERVER +/* Externally provided functions */ +void ErrorF(const char *f, ...); +void VErrorF(const char *f, va_list args); +#endif diff --git a/xorg-server/hw/xfree86/parser/cpconfig.c b/xorg-server/hw/xfree86/parser/cpconfig.c new file mode 100644 index 000000000..0347f7d2a --- /dev/null +++ b/xorg-server/hw/xfree86/parser/cpconfig.c @@ -0,0 +1,122 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <ctype.h> +#include "xf86Parser.h" +#include "configProcs.h" + +#ifdef MALLOC_FUNCTIONS +void +xfree (void *p) +{ + free (p); + return; +} + +void * +xalloc (int size) +{ + return malloc (size); +} + +void * +xrealloc (void *p, int size) +{ + return realloc (p, size); +} + +#endif + +#define CONFPATH "%A,%R,/etc/X11/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \ + "%P/etc/X11/%F,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \ + "%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X" + +int +main (int argc, char *argv[]) +{ + const char *filename; + char *cmdline = NULL; + XF86ConfigPtr conf; + + if (argc > 1) + { + cmdline = argv[1]; + } + if ((filename = xf86openConfigFile (CONFPATH, cmdline, NULL))) + { + fprintf (stderr, "Opened %s for the config file\n", filename); + } + else + { + fprintf (stderr, "Unable to open config file\n"); + exit (1); + } + + if ((conf = xf86readConfigFile ()) == NULL) + { + fprintf (stderr, "Problem when parsing config file\n"); + } + else + { + fprintf (stderr, "Config file parsed OK\n"); + } + xf86closeConfigFile (); + + if (argc > 2) { + fprintf(stderr, "Writing config file to `%s'\n", argv[2]); + xf86writeConfigFile (argv[2], conf); + } + exit(0); +} + +/* Functions that the parser requires */ + +_X_EXPORT void +VErrorF(const char *f, va_list args) +{ + vfprintf(stderr, f, args); +} + +_X_EXPORT void +ErrorF(const char *f, ...) +{ + va_list args; + + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); +} diff --git a/xorg-server/hw/xfree86/parser/read.c b/xorg-server/hw/xfree86/parser/read.c new file mode 100644 index 000000000..430da0a5a --- /dev/null +++ b/xorg-server/hw/xfree86/parser/read.c @@ -0,0 +1,311 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +extern LexRec val; + +static xf86ConfigSymTabRec TopLevelTab[] = +{ + {SECTION, "section"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeConfig + +/* + * This function resolves name references and reports errors if the named + * objects cannot be found. + */ +static int +xf86validateConfig (XF86ConfigPtr p) +{ + if (!xf86validateScreen (p)) + return FALSE; + if (!xf86validateInput (p)) + return FALSE; + if (!xf86validateLayout (p)) + return FALSE; + + return (TRUE); +} + +XF86ConfigPtr +xf86readConfigFile (void) +{ + int token; + XF86ConfigPtr ptr = NULL; + + if ((ptr = xf86confcalloc (1, sizeof (XF86ConfigRec))) == NULL) + { + return NULL; + } + memset (ptr, 0, sizeof (XF86ConfigRec)); + + while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN) + { + switch (token) + { + case COMMENT: + ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str); + break; + case SECTION: + if (xf86getSubToken (&(ptr->conf_comment)) != STRING) + { + xf86parseError (QUOTE_MSG, "Section"); + CLEANUP (ptr); + return (NULL); + } + xf86setSection (val.str); + if (xf86nameCompare (val.str, "files") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_files, xf86parseFilesSection ()); + } + else if (xf86nameCompare (val.str, "serverflags") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_flags, xf86parseFlagsSection ()); + } + else if (xf86nameCompare (val.str, "pointer") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_input_lst, xf86parsePointerSection, + XF86ConfInputPtr); + } + else if (xf86nameCompare (val.str, "videoadaptor") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection, + XF86ConfVideoAdaptorPtr); + } + else if (xf86nameCompare (val.str, "device") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_device_lst, xf86parseDeviceSection, + XF86ConfDevicePtr); + } + else if (xf86nameCompare (val.str, "monitor") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection, + XF86ConfMonitorPtr); + } + else if (xf86nameCompare (val.str, "modes") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_modes_lst, xf86parseModesSection, + XF86ConfModesPtr); + } + else if (xf86nameCompare (val.str, "screen") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_screen_lst, xf86parseScreenSection, + XF86ConfScreenPtr); + } + else if (xf86nameCompare(val.str, "inputdevice") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_input_lst, xf86parseInputSection, + XF86ConfInputPtr); + } + else if (xf86nameCompare (val.str, "module") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_modules, xf86parseModuleSection ()); + } + else if (xf86nameCompare (val.str, "serverlayout") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection, + XF86ConfLayoutPtr); + } + else if (xf86nameCompare (val.str, "vendor") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection, + XF86ConfVendorPtr); + } + else if (xf86nameCompare (val.str, "dri") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_dri, xf86parseDRISection ()); + } + else if (xf86nameCompare (val.str, "extensions") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ()); + } + else + { + Error (INVALID_SECTION_MSG, xf86tokenString ()); + xf86conffree(val.str); + val.str = NULL; + } + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + xf86conffree(val.str); + val.str = NULL; + } + } + + if (xf86validateConfig (ptr)) + return (ptr); + else + { + CLEANUP (ptr); + return (NULL); + } +} + +#undef CLEANUP + +/* + * adds an item to the end of the linked list. Any record whose first field + * is a GenericListRec can be cast to this type and used with this function. + * A pointer to the head of the list is returned to handle the addition of + * the first item. + */ +GenericListPtr +xf86addListItem (GenericListPtr head, GenericListPtr new) +{ + GenericListPtr p = head; + GenericListPtr last = NULL; + + while (p) + { + last = p; + p = p->next; + } + + if (last) + { + last->next = new; + return (head); + } + else + return (new); +} + +/* + * Test if one chained list contains the other. + * In this case both list have the same endpoint (provided they don't loop) + */ +int +xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2) +{ + GenericListPtr p = list_1; + GenericListPtr last_1 = NULL, last_2 = NULL; + + while (p) { + last_1 = p; + p = p->next; + } + + p = list_2; + while (p) { + last_2 = p; + p = p->next; + } + + return (!(last_1 == last_2)); +} + +void +xf86freeConfig (XF86ConfigPtr p) +{ + if (p == NULL) + return; + + xf86freeFiles (p->conf_files); + xf86freeModules (p->conf_modules); + xf86freeFlags (p->conf_flags); + xf86freeMonitorList (p->conf_monitor_lst); + xf86freeModesList (p->conf_modes_lst); + xf86freeVideoAdaptorList (p->conf_videoadaptor_lst); + xf86freeDeviceList (p->conf_device_lst); + xf86freeScreenList (p->conf_screen_lst); + xf86freeLayoutList (p->conf_layout_lst); + xf86freeInputList (p->conf_input_lst); + xf86freeVendorList (p->conf_vendor_lst); + xf86freeDRI (p->conf_dri); + xf86freeExtensions (p->conf_extensions); + TestFree(p->conf_comment); + + xf86conffree (p); +} diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c new file mode 100644 index 000000000..851b91161 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/scan.c @@ -0,0 +1,1031 @@ +/* + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdarg.h> +#include <X11/Xfuncproto.h> + +#if !defined(X_NOT_POSIX) +#if defined(_POSIX_SOURCE) +#include <limits.h> +#else +#define _POSIX_SOURCE +#include <limits.h> +#undef _POSIX_SOURCE +#endif /* _POSIX_SOURCE */ +#endif /* !X_NOT_POSIX */ +#if !defined(PATH_MAX) +#if defined(MAXPATHLEN) +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif /* MAXPATHLEN */ +#endif /* !PATH_MAX */ + +#if !defined(MAXHOSTNAMELEN) +#define MAXHOSTNAMELEN 32 +#endif /* !MAXHOSTNAMELEN */ + +#include "Configint.h" +#include "xf86tokens.h" + +#define CONFIG_BUF_LEN 1024 + +static int StringToToken (char *, xf86ConfigSymTabRec *); + +static FILE *configFile = NULL; +static const char **builtinConfig = NULL; +static int builtinIndex = 0; +static int configPos = 0; /* current readers position */ +static int configLineNo = 0; /* linenumber */ +static char *configBuf, *configRBuf; /* buffer for lines */ +static char *configPath; /* path to config file */ +static char *configSection = NULL; /* name of current section being parsed */ +static int pushToken = LOCK_TOKEN; +static int eol_seen = 0; /* private state to handle comments */ +LexRec val; + +/* + * xf86strToUL -- + * + * A portable, but restricted, version of strtoul(). It only understands + * hex, octal, and decimal. But it's good enough for our needs. + */ +static unsigned int +xf86strToUL (char *str) +{ + int base = 10; + char *p = str; + unsigned int tot = 0; + + if (*p == '0') + { + p++; + if ((*p == 'x') || (*p == 'X')) + { + p++; + base = 16; + } + else + base = 8; + } + while (*p) + { + if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9'))) + { + tot = tot * base + (*p - '0'); + } + else if ((base == 16) && (*p >= 'a') && (*p <= 'f')) + { + tot = tot * base + 10 + (*p - 'a'); + } + else if ((base == 16) && (*p >= 'A') && (*p <= 'F')) + { + tot = tot * base + 10 + (*p - 'A'); + } + else + { + return (tot); + } + p++; + } + return (tot); +} + +/* + * xf86getNextLine -- + * + * read from the configFile FILE stream until we encounter a new + * line; this is effectively just a big wrapper for fgets(3). + * + * xf86getToken() assumes that we will read up to the next + * newline; we need to grow configBuf and configRBuf as needed to + * support that. + */ + +static char* +xf86getNextLine(void) +{ + static int configBufLen = CONFIG_BUF_LEN; + char *tmpConfigBuf, *tmpConfigRBuf; + int c, i, pos = 0, eolFound = 0; + char *ret = NULL; + + /* + * reallocate the string if it was grown last time (i.e., is no + * longer CONFIG_BUF_LEN); we malloc the new strings first, so + * that if either of the mallocs fail, we can fall back on the + * existing buffer allocations + */ + + if (configBufLen != CONFIG_BUF_LEN) { + + tmpConfigBuf = xf86confmalloc(CONFIG_BUF_LEN); + tmpConfigRBuf = xf86confmalloc(CONFIG_BUF_LEN); + + if (!tmpConfigBuf || !tmpConfigRBuf) { + + /* + * at least one of the mallocs failed; keep the old buffers + * and free any partial allocations + */ + + xf86conffree(tmpConfigBuf); + xf86conffree(tmpConfigRBuf); + + } else { + + /* + * malloc succeeded; free the old buffers and use the new + * buffers + */ + + configBufLen = CONFIG_BUF_LEN; + + xf86conffree(configBuf); + xf86conffree(configRBuf); + + configBuf = tmpConfigBuf; + configRBuf = tmpConfigRBuf; + } + } + + /* read in another block of chars */ + + do { + ret = fgets(configBuf + pos, configBufLen - pos - 1, configFile); + + if (!ret) break; + + /* search for EOL in the new block of chars */ + + for (i = pos; i < (configBufLen - 1); i++) { + c = configBuf[i]; + + if (c == '\0') break; + + if ((c == '\n') || (c == '\r')) { + eolFound = 1; + break; + } + } + + /* + * if we didn't find EOL, then grow the string and + * read in more + */ + + if (!eolFound) { + + tmpConfigBuf = xf86confrealloc(configBuf, configBufLen + CONFIG_BUF_LEN); + tmpConfigRBuf = xf86confrealloc(configRBuf, configBufLen + CONFIG_BUF_LEN); + + if (!tmpConfigBuf || !tmpConfigRBuf) { + + /* + * at least one of the reallocations failed; use the + * new allocation that succeeded, but we have to + * fallback to the previous configBufLen size and use + * the string we have, even though we don't have an + * EOL + */ + + if (tmpConfigBuf) configBuf = tmpConfigBuf; + if (tmpConfigRBuf) configRBuf = tmpConfigRBuf; + + break; + + } else { + + /* reallocation succeeded */ + + configBuf = tmpConfigBuf; + configRBuf = tmpConfigRBuf; + pos = i; + configBufLen += CONFIG_BUF_LEN; + } + } + + } while (!eolFound); + + return (ret); +} + +/* + * xf86getToken -- + * Read next Token from the config file. Handle the global variable + * pushToken. + */ +int +xf86getToken (xf86ConfigSymTabRec * tab) +{ + int c, i; + + /* + * First check whether pushToken has a different value than LOCK_TOKEN. + * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the + * oth * case the next token must be read from the input. + */ + if (pushToken == EOF_TOKEN) + return (EOF_TOKEN); + else if (pushToken == LOCK_TOKEN) + { + /* + * eol_seen is only set for the first token after a newline. + */ + eol_seen = 0; + + c = configBuf[configPos]; + + /* + * Get start of next Token. EOF is handled, + * whitespaces are skipped. + */ + +again: + if (!c) + { + char *ret; + if (configFile) + ret = xf86getNextLine(); + else { + if (builtinConfig[builtinIndex] == NULL) + ret = NULL; + else { + ret = strncpy(configBuf, builtinConfig[builtinIndex], + CONFIG_BUF_LEN); + builtinIndex++; + } + } + if (ret == NULL) + { + return (pushToken = EOF_TOKEN); + } + configLineNo++; + configPos = 0; + eol_seen = 1; + } + + i = 0; + for (;;) { + c = configBuf[configPos++]; + configRBuf[i++] = c; + switch (c) { + case ' ': + case '\t': + case '\r': + continue; + case '\n': + i = 0; + continue; + } + break; + } + if (c == '\0') + goto again; + + if (c == '#') + { + do + { + configRBuf[i++] = (c = configBuf[configPos++]); + } + while ((c != '\n') && (c != '\r') && (c != '\0')); + configRBuf[i] = '\0'; + /* XXX no private copy. + * Use xf86addComment when setting a comment. + */ + val.str = configRBuf; + return (COMMENT); + } + + /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */ + else if ((c == ',') && !isalpha (configBuf[configPos])) + { + return COMMA; + } + else if ((c == '-') && !isalpha (configBuf[configPos])) + { + return DASH; + } + + /* + * Numbers are returned immediately ... + */ + if (isdigit (c)) + { + int base; + + if (c == '0') + if ((configBuf[configPos] == 'x') || + (configBuf[configPos] == 'X')) + { + base = 16; + val.numType = PARSE_HEX; + } + else + { + base = 8; + val.numType = PARSE_OCTAL; + } + else + { + base = 10; + val.numType = PARSE_DECIMAL; + } + + configRBuf[0] = c; + i = 1; + while (isdigit (c = configBuf[configPos++]) || + (c == '.') || (c == 'x') || (c == 'X') || + ((base == 16) && (((c >= 'a') && (c <= 'f')) || + ((c >= 'A') && (c <= 'F'))))) + configRBuf[i++] = c; + configPos--; /* GJA -- one too far */ + configRBuf[i] = '\0'; + val.num = xf86strToUL (configRBuf); + val.realnum = atof (configRBuf); + return (NUMBER); + } + + /* + * All Strings START with a \" ... + */ + else if (c == '\"') + { + i = -1; + do + { + configRBuf[++i] = (c = configBuf[configPos++]); + } + while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0')); + configRBuf[i] = '\0'; + val.str = xf86confmalloc (strlen (configRBuf) + 1); + strcpy (val.str, configRBuf); /* private copy ! */ + return (STRING); + } + + /* + * ... and now we MUST have a valid token. The search is + * handled later along with the pushed tokens. + */ + else + { + configRBuf[0] = c; + i = 0; + do + { + configRBuf[++i] = (c = configBuf[configPos++]);; + } + while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#')); + --configPos; + configRBuf[i] = '\0'; + i = 0; + } + + } + else + { + + /* + * Here we deal with pushed tokens. Reinitialize pushToken again. If + * the pushed token was NUMBER || STRING return them again ... + */ + int temp = pushToken; + pushToken = LOCK_TOKEN; + + if (temp == COMMA || temp == DASH) + return (temp); + if (temp == NUMBER || temp == STRING) + return (temp); + } + + /* + * Joop, at last we have to lookup the token ... + */ + if (tab) + { + i = 0; + while (tab[i].token != -1) + if (xf86nameCompare (configRBuf, tab[i].name) == 0) + return (tab[i].token); + else + i++; + } + + return (ERROR_TOKEN); /* Error catcher */ +} + +int +xf86getSubToken (char **comment) +{ + int token; + + for (;;) { + token = xf86getToken(NULL); + if (token == COMMENT) { + if (comment) + *comment = xf86addComment(*comment, val.str); + } + else + return (token); + } + /*NOTREACHED*/ +} + +int +xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab) +{ + int token; + + for (;;) { + token = xf86getToken(tab); + if (token == COMMENT) { + if (comment) + *comment = xf86addComment(*comment, val.str); + } + else + return (token); + } + /*NOTREACHED*/ +} + +void +xf86unGetToken (int token) +{ + pushToken = token; +} + +char * +xf86tokenString (void) +{ + return configRBuf; +} + +int +xf86pathIsAbsolute(const char *path) +{ + if (path && path[0] == '/') + return 1; + return 0; +} + +/* A path is "safe" if it is relative and if it contains no ".." elements. */ +int +xf86pathIsSafe(const char *path) +{ + if (xf86pathIsAbsolute(path)) + return 0; + + /* Compare with ".." */ + if (!strcmp(path, "..")) + return 0; + + /* Look for leading "../" */ + if (!strncmp(path, "../", 3)) + return 0; + + /* Look for trailing "/.." */ + if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/..")) + return 0; + + /* Look for "/../" */ + if (strstr(path, "/../")) + return 0; + + return 1; +} + +/* + * This function substitutes the following escape sequences: + * + * %A cmdline argument as an absolute path (must be absolute to match) + * %R cmdline argument as a relative path + * %S cmdline argument as a "safe" path (relative, and no ".." elements) + * %X default config file name ("xorg.conf") + * %H hostname + * %E config file environment ($XORGCONFIG) as an absolute path + * %F config file environment ($XORGCONFIG) as a relative path + * %G config file environment ($XORGCONFIG) as a safe path + * %P projroot + * %M major version number + * %% % + */ + +#ifndef XCONFIGFILE +#define XCONFIGFILE "xorg.conf" +#endif +#ifndef PROJECTROOT +#define PROJECTROOT "/usr/X11R6" +#endif +#ifndef XCONFENV +#define XCONFENV "XORGCONFIG" +#endif +#define XFREE86CFGFILE "XF86Config" +#ifndef XF86_VERSION_MAJOR +#ifdef XVERSION +#if XVERSION > 40000000 +#define XF86_VERSION_MAJOR (XVERSION / 10000000) +#else +#define XF86_VERSION_MAJOR (XVERSION / 1000) +#endif +#else +#define XF86_VERSION_MAJOR 4 +#endif +#endif + +#define BAIL_OUT do { \ + xf86conffree(result); \ + return NULL; \ + } while (0) + +#define CHECK_LENGTH do { \ + if (l > PATH_MAX) { \ + BAIL_OUT; \ + } \ + } while (0) + +#define APPEND_STR(s) do { \ + if (strlen(s) + l > PATH_MAX) { \ + BAIL_OUT; \ + } else { \ + strcpy(result + l, s); \ + l += strlen(s); \ + } \ + } while (0) + +static char * +DoSubstitution(const char *template, const char *cmdline, const char *projroot, + int *cmdlineUsed, int *envUsed, char *XConfigFile) +{ + char *result; + int i, l; + static const char *env = NULL; + static char *hostname = NULL; + static char majorvers[3] = ""; + + if (!template) + return NULL; + + if (cmdlineUsed) + *cmdlineUsed = 0; + if (envUsed) + *envUsed = 0; + + result = xf86confmalloc(PATH_MAX + 1); + l = 0; + for (i = 0; template[i]; i++) { + if (template[i] != '%') { + result[l++] = template[i]; + CHECK_LENGTH; + } else { + switch (template[++i]) { + case 'A': + if (cmdline && xf86pathIsAbsolute(cmdline)) { + APPEND_STR(cmdline); + if (cmdlineUsed) + *cmdlineUsed = 1; + } else + BAIL_OUT; + break; + case 'R': + if (cmdline && !xf86pathIsAbsolute(cmdline)) { + APPEND_STR(cmdline); + if (cmdlineUsed) + *cmdlineUsed = 1; + } else + BAIL_OUT; + break; + case 'S': + if (cmdline && xf86pathIsSafe(cmdline)) { + APPEND_STR(cmdline); + if (cmdlineUsed) + *cmdlineUsed = 1; + } else + BAIL_OUT; + break; + case 'X': + APPEND_STR(XConfigFile); + break; + case 'H': + if (!hostname) { + if ((hostname = xf86confmalloc(MAXHOSTNAMELEN + 1))) { + if (gethostname(hostname, MAXHOSTNAMELEN) == 0) { + hostname[MAXHOSTNAMELEN] = '\0'; + } else { + xf86conffree(hostname); + hostname = NULL; + } + } + } + if (hostname) + APPEND_STR(hostname); + break; + case 'E': + if (!env) + env = getenv(XCONFENV); + if (env && xf86pathIsAbsolute(env)) { + APPEND_STR(env); + if (envUsed) + *envUsed = 1; + } else + BAIL_OUT; + break; + case 'F': + if (!env) + env = getenv(XCONFENV); + if (env && !xf86pathIsAbsolute(env)) { + APPEND_STR(env); + if (envUsed) + *envUsed = 1; + } else + BAIL_OUT; + break; + case 'G': + if (!env) + env = getenv(XCONFENV); + if (env && xf86pathIsSafe(env)) { + APPEND_STR(env); + if (envUsed) + *envUsed = 1; + } else + BAIL_OUT; + break; + case 'P': + if (projroot && xf86pathIsAbsolute(projroot)) + APPEND_STR(projroot); + else + BAIL_OUT; + break; + case 'M': + if (!majorvers[0]) { + if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) { + fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n"); + BAIL_OUT; + } else + sprintf(majorvers, "%d", XF86_VERSION_MAJOR); + } + APPEND_STR(majorvers); + break; + case '%': + result[l++] = '%'; + CHECK_LENGTH; + break; + default: + fprintf(stderr, "invalid escape %%%c found in path template\n", + template[i]); + BAIL_OUT; + break; + } + } + } +#ifdef DEBUG + fprintf(stderr, "Converted `%s' to `%s'\n", template, result); +#endif + return result; +} + +/* + * xf86openConfigFile -- + * + * This function take a config file search path (optional), a command-line + * specified file name (optional) and the ProjectRoot path (optional) and + * locates and opens a config file based on that information. If a + * command-line file name is specified, then this function fails if none + * of the located files. + * + * The return value is a pointer to the actual name of the file that was + * opened. When no file is found, the return value is NULL. + * + * The escape sequences allowed in the search path are defined above. + * + */ + +#ifndef DEFAULT_CONF_PATH +#define DEFAULT_CONF_PATH "/etc/X11/%S," \ + "%P/etc/X11/%S," \ + "/etc/X11/%G," \ + "%P/etc/X11/%G," \ + "/etc/X11/%X-%M," \ + "/etc/X11/%X," \ + "/etc/%X," \ + "%P/etc/X11/%X.%H," \ + "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," \ + "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" +#endif + +const char * +xf86openConfigFile(const char *path, const char *cmdline, const char *projroot) +{ + char *pathcopy; + const char *template; + int cmdlineUsed = 0; + + configFile = NULL; + configPos = 0; /* current readers position */ + configLineNo = 0; /* linenumber */ + pushToken = LOCK_TOKEN; + + if (!path || !path[0]) + path = DEFAULT_CONF_PATH; + pathcopy = xf86confmalloc(strlen(path) + 1); + strcpy(pathcopy, path); + if (!projroot || !projroot[0]) + projroot = PROJECTROOT; + + template = strtok(pathcopy, ","); + + /* First, search for a config file. */ + while (template && !configFile) { + if ((configPath = DoSubstitution(template, cmdline, projroot, + &cmdlineUsed, NULL, + XCONFIGFILE))) { + if ((configFile = fopen(configPath, "r")) != 0) { + if (cmdline && !cmdlineUsed) { + fclose(configFile); + configFile = NULL; + } + } + } + if (configPath && !configFile) { + xf86conffree(configPath); + configPath = NULL; + } + template = strtok(NULL, ","); + } + + /* Then search for fallback */ + if (!configFile) { + strcpy(pathcopy, path); + template = strtok(pathcopy, ","); + + while (template && !configFile) { + if ((configPath = DoSubstitution(template, cmdline, projroot, + &cmdlineUsed, NULL, + XFREE86CFGFILE))) { + if ((configFile = fopen(configPath, "r")) != 0) { + if (cmdline && !cmdlineUsed) { + fclose(configFile); + configFile = NULL; + } + } + } + if (configPath && !configFile) { + xf86conffree(configPath); + configPath = NULL; + } + template = strtok(NULL, ","); + } + } + + xf86conffree(pathcopy); + if (!configFile) { + + return NULL; + } + + configBuf = xf86confmalloc (CONFIG_BUF_LEN); + configRBuf = xf86confmalloc (CONFIG_BUF_LEN); + configBuf[0] = '\0'; /* sanity ... */ + + return configPath; +} + +void +xf86closeConfigFile (void) +{ + xf86conffree (configPath); + configPath = NULL; + xf86conffree (configRBuf); + configRBuf = NULL; + xf86conffree (configBuf); + configBuf = NULL; + + if (configFile) { + fclose (configFile); + configFile = NULL; + } else { + builtinConfig = NULL; + builtinIndex = 0; + } +} + +void +xf86setBuiltinConfig(const char *config[]) +{ + builtinConfig = config; + configPath = xf86configStrdup("<builtin configuration>"); + configBuf = xf86confmalloc (CONFIG_BUF_LEN); + configRBuf = xf86confmalloc (CONFIG_BUF_LEN); + configBuf[0] = '\0'; /* sanity ... */ + +} + +void +xf86parseError (char *format,...) +{ + va_list ap; + + ErrorF ("Parse error on line %d of section %s in file %s\n\t", + configLineNo, configSection, configPath); + va_start (ap, format); + VErrorF (format, ap); + va_end (ap); + + ErrorF ("\n"); +} + +void +xf86validationError (char *format,...) +{ + va_list ap; + + ErrorF ("Data incomplete in file %s\n\t", configPath); + va_start (ap, format); + VErrorF (format, ap); + va_end (ap); + + ErrorF ("\n"); +} + +void +xf86setSection (char *section) +{ + if (configSection) + xf86conffree(configSection); + configSection = xf86confmalloc(strlen (section) + 1); + strcpy (configSection, section); +} + +/* + * xf86getToken -- + * Lookup a string if it is actually a token in disguise. + */ +int +xf86getStringToken (xf86ConfigSymTabRec * tab) +{ + return StringToToken (val.str, tab); +} + +static int +StringToToken (char *str, xf86ConfigSymTabRec * tab) +{ + int i; + + for (i = 0; tab[i].token != -1; i++) + { + if (!xf86nameCompare (tab[i].name, str)) + return tab[i].token; + } + return (ERROR_TOKEN); +} + + +/* + * Compare two names. The characters '_', ' ', and '\t' are ignored + * in the comparison. + */ +_X_EXPORT int +xf86nameCompare (const char *s1, const char *s2) +{ + char c1, c2; + + if (!s1 || *s1 == 0) { + if (!s2 || *s2 == 0) + return (0); + else + return (1); + } + + while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') + s1++; + while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') + s2++; + c1 = (isupper (*s1) ? tolower (*s1) : *s1); + c2 = (isupper (*s2) ? tolower (*s2) : *s2); + while (c1 == c2) + { + if (c1 == '\0') + return (0); + s1++; + s2++; + while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') + s1++; + while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') + s2++; + c1 = (isupper (*s1) ? tolower (*s1) : *s1); + c2 = (isupper (*s2) ? tolower (*s2) : *s2); + } + return (c1 - c2); +} + +char * +xf86addComment(char *cur, char *add) +{ + char *str; + int len, curlen, iscomment, hasnewline = 0, endnewline; + + if (add == NULL || add[0] == '\0') + return (cur); + + if (cur) { + curlen = strlen(cur); + if (curlen) + hasnewline = cur[curlen - 1] == '\n'; + eol_seen = 0; + } + else + curlen = 0; + + str = add; + iscomment = 0; + while (*str) { + if (*str != ' ' && *str != '\t') + break; + ++str; + } + iscomment = (*str == '#'); + + len = strlen(add); + endnewline = add[len - 1] == '\n'; + len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen; + + if ((str = xf86confrealloc(cur, len + curlen)) == NULL) + return (cur); + + cur = str; + + if (eol_seen || (curlen && !hasnewline)) + cur[curlen++] = '\n'; + if (!iscomment) + cur[curlen++] = '#'; + strcpy(cur + curlen, add); + if (!endnewline) + strcat(cur, "\n"); + + return (cur); +} diff --git a/xorg-server/hw/xfree86/parser/write.c b/xorg-server/hw/xfree86/parser/write.c new file mode 100644 index 000000000..6589fdc72 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/write.c @@ -0,0 +1,227 @@ +/* + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* View/edit this file with tab stops set to 4 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" + +#include <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> +#include <errno.h> + +#if ((defined(sun) && !defined(SVR4)) || defined(macII)) && !defined(__GLIBC__) +#ifndef strerror +extern char *sys_errlist[]; +extern int sys_nerr; +#define strerror(n) \ + (((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error") +#endif +#endif + +#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) +#define HAS_SAVED_IDS_AND_SETEUID +#endif +#if defined(WIN32) +#define HAS_NO_UIDS +#endif + +#ifdef HAS_NO_UIDS +#define doWriteConfigFile xf86writeConfigFile +#define Local /**/ +#else +#define Local static +#endif + +Local int +doWriteConfigFile (const char *filename, XF86ConfigPtr cptr) +{ + FILE *cf; + + if ((cf = fopen (filename, "w")) == NULL) + { + return 0; + } + + if (cptr->conf_comment) + fprintf (cf, "%s\n", cptr->conf_comment); + + xf86printLayoutSection (cf, cptr->conf_layout_lst); + + if (cptr->conf_files != NULL) + { + fprintf (cf, "Section \"Files\"\n"); + xf86printFileSection (cf, cptr->conf_files); + fprintf (cf, "EndSection\n\n"); + } + + if (cptr->conf_modules != NULL) + { + fprintf (cf, "Section \"Module\"\n"); + xf86printModuleSection (cf, cptr->conf_modules); + fprintf (cf, "EndSection\n\n"); + } + + xf86printVendorSection (cf, cptr->conf_vendor_lst); + + xf86printServerFlagsSection (cf, cptr->conf_flags); + + xf86printInputSection (cf, cptr->conf_input_lst); + + xf86printVideoAdaptorSection (cf, cptr->conf_videoadaptor_lst); + + xf86printModesSection (cf, cptr->conf_modes_lst); + + xf86printMonitorSection (cf, cptr->conf_monitor_lst); + + xf86printDeviceSection (cf, cptr->conf_device_lst); + + xf86printScreenSection (cf, cptr->conf_screen_lst); + + xf86printDRISection (cf, cptr->conf_dri); + + xf86printExtensionsSection (cf, cptr->conf_extensions); + + fclose(cf); + return 1; +} + +#ifndef HAS_NO_UIDS + +int +xf86writeConfigFile (const char *filename, XF86ConfigPtr cptr) +{ + int ret; + +#if !defined(HAS_SAVED_IDS_AND_SETEUID) + int pid, p; + int status; + void (*csig)(int); +#else + int ruid, euid; +#endif + + if (getuid() != geteuid()) + { + +#if !defined(HAS_SAVED_IDS_AND_SETEUID) + /* Need to fork to change ruid without loosing euid */ +#ifdef SIGCHLD + csig = signal(SIGCHLD, SIG_DFL); +#endif + switch ((pid = fork())) + { + case -1: + ErrorF("xf86writeConfigFile(): fork failed (%s)\n", + strerror(errno)); + return 0; + case 0: /* child */ + if (setuid(getuid()) == -1) + FatalError("xf86writeConfigFile(): " + "setuid failed(%s)\n", + strerror(errno)); + ret = doWriteConfigFile(filename, cptr); + exit(ret); + break; + default: /* parent */ + do + { + p = waitpid(pid, &status, 0); + } while (p == -1 && errno == EINTR); + } +#ifdef SIGCHLD + signal(SIGCHLD, csig); +#endif + if (p != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0) + return 1; /* success */ + else + return 0; + +#else /* HAS_SAVED_IDS_AND_SETEUID */ + + ruid = getuid(); + euid = geteuid(); + + if (seteuid(ruid) == -1) + { + ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n", + ruid, strerror(errno)); + return 0; + } + ret = doWriteConfigFile(filename, cptr); + + if (seteuid(euid) == -1) + { + ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n", + euid, strerror(errno)); + } + return ret; + +#endif /* HAS_SAVED_IDS_AND_SETEUID */ + + } + else + { + return doWriteConfigFile(filename, cptr); + } +} + +#endif /* !HAS_NO_UIDS */ diff --git a/xorg-server/hw/xfree86/parser/xf86Optrec.h b/xorg-server/hw/xfree86/parser/xf86Optrec.h new file mode 100644 index 000000000..183b85720 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/xf86Optrec.h @@ -0,0 +1,112 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* + * This file contains the Option Record that is passed between the Parser, + * and Module setup procs. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _xf86Optrec_h_ +#define _xf86Optrec_h_ +#include <stdio.h> + +/* + * all records that need to be linked lists should contain a GenericList as + * their first field. + */ +typedef struct generic_list_rec +{ + void *next; +} +GenericListRec, *GenericListPtr, *glp; + +/* + * All options are stored using this data type. + */ +typedef struct +{ + GenericListRec list; + char *opt_name; + char *opt_val; + int opt_used; + char *opt_comment; +} +XF86OptionRec, *XF86OptionPtr; + + +XF86OptionPtr xf86addNewOption(XF86OptionPtr head, char *name, char *val); +XF86OptionPtr xf86optionListDup(XF86OptionPtr opt); +void xf86optionListFree(XF86OptionPtr opt); +char *xf86optionName(XF86OptionPtr opt); +char *xf86optionValue(XF86OptionPtr opt); +XF86OptionPtr xf86newOption(char *name, char *value); +XF86OptionPtr xf86nextOption(XF86OptionPtr list); +XF86OptionPtr xf86findOption(XF86OptionPtr list, const char *name); +char *xf86findOptionValue(XF86OptionPtr list, const char *name); +int xf86findOptionBoolean (XF86OptionPtr, const char *, int); +XF86OptionPtr xf86optionListCreate(const char **options, int count, int used); +XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail); +char *xf86configStrdup (const char *s); +int xf86nameCompare (const char *s1, const char *s2); +char *xf86uLongToString(unsigned long i); +void xf86debugListOptions(XF86OptionPtr); +XF86OptionPtr xf86parseOption(XF86OptionPtr head); +void xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs); + + +#endif /* _xf86Optrec_h_ */ diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h new file mode 100644 index 000000000..fd6cc530b --- /dev/null +++ b/xorg-server/hw/xfree86/parser/xf86Parser.h @@ -0,0 +1,484 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +/* + * This file contains the external interfaces for the XFree86 configuration + * file parser. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _xf86Parser_h_ +#define _xf86Parser_h_ + +#include "xf86Optrec.h" + +#define HAVE_PARSER_DECLS + +typedef struct +{ + char *file_logfile; + char *file_modulepath; + char *file_inputdevs; + char *file_fontpath; + char *file_comment; +} +XF86ConfFilesRec, *XF86ConfFilesPtr; + +/* Values for load_type */ +#define XF86_LOAD_MODULE 0 +#define XF86_LOAD_DRIVER 1 +#define XF86_DISABLE_MODULE 2 + +typedef struct +{ + GenericListRec list; + int load_type; + char *load_name; + XF86OptionPtr load_opt; + char *load_comment; + int ignore; +} +XF86LoadRec, *XF86LoadPtr; + +typedef struct +{ + XF86LoadPtr mod_load_lst; + XF86LoadPtr mod_disable_lst; + char *mod_comment; +} +XF86ConfModuleRec, *XF86ConfModulePtr; + +#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard" + +#define CONF_IMPLICIT_POINTER "Implicit Core Pointer" + +#define XF86CONF_PHSYNC 0x0001 +#define XF86CONF_NHSYNC 0x0002 +#define XF86CONF_PVSYNC 0x0004 +#define XF86CONF_NVSYNC 0x0008 +#define XF86CONF_INTERLACE 0x0010 +#define XF86CONF_DBLSCAN 0x0020 +#define XF86CONF_CSYNC 0x0040 +#define XF86CONF_PCSYNC 0x0080 +#define XF86CONF_NCSYNC 0x0100 +#define XF86CONF_HSKEW 0x0200 /* hskew provided */ +#define XF86CONF_BCAST 0x0400 +#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */ +#define XF86CONF_VSCAN 0x1000 + +typedef struct +{ + GenericListRec list; + char *ml_identifier; + int ml_clock; + int ml_hdisplay; + int ml_hsyncstart; + int ml_hsyncend; + int ml_htotal; + int ml_vdisplay; + int ml_vsyncstart; + int ml_vsyncend; + int ml_vtotal; + int ml_vscan; + int ml_flags; + int ml_hskew; + char *ml_comment; +} +XF86ConfModeLineRec, *XF86ConfModeLinePtr; + +typedef struct +{ + GenericListRec list; + char *vp_identifier; + XF86OptionPtr vp_option_lst; + char *vp_comment; +} +XF86ConfVideoPortRec, *XF86ConfVideoPortPtr; + +typedef struct +{ + GenericListRec list; + char *va_identifier; + char *va_vendor; + char *va_board; + char *va_busid; + char *va_driver; + XF86OptionPtr va_option_lst; + XF86ConfVideoPortPtr va_port_lst; + char *va_fwdref; + char *va_comment; +} +XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr; + +#define CONF_MAX_HSYNC 8 +#define CONF_MAX_VREFRESH 8 + +typedef struct +{ + float hi, lo; +} +parser_range; + +typedef struct +{ + int red, green, blue; +} +parser_rgb; + +typedef struct +{ + GenericListRec list; + char *modes_identifier; + XF86ConfModeLinePtr mon_modeline_lst; + char *modes_comment; +} +XF86ConfModesRec, *XF86ConfModesPtr; + +typedef struct +{ + GenericListRec list; + char *ml_modes_str; + XF86ConfModesPtr ml_modes; +} +XF86ConfModesLinkRec, *XF86ConfModesLinkPtr; + +typedef struct +{ + GenericListRec list; + char *mon_identifier; + char *mon_vendor; + char *mon_modelname; + int mon_width; /* in mm */ + int mon_height; /* in mm */ + XF86ConfModeLinePtr mon_modeline_lst; + int mon_n_hsync; + parser_range mon_hsync[CONF_MAX_HSYNC]; + int mon_n_vrefresh; + parser_range mon_vrefresh[CONF_MAX_VREFRESH]; + float mon_gamma_red; + float mon_gamma_green; + float mon_gamma_blue; + XF86OptionPtr mon_option_lst; + XF86ConfModesLinkPtr mon_modes_sect_lst; + char *mon_comment; +} +XF86ConfMonitorRec, *XF86ConfMonitorPtr; + +#define CONF_MAXDACSPEEDS 4 +#define CONF_MAXCLOCKS 128 + +typedef struct +{ + GenericListRec list; + char *dev_identifier; + char *dev_vendor; + char *dev_board; + char *dev_chipset; + char *dev_busid; + char *dev_card; + char *dev_driver; + char *dev_ramdac; + int dev_dacSpeeds[CONF_MAXDACSPEEDS]; + int dev_videoram; + int dev_textclockfreq; + unsigned long dev_bios_base; + unsigned long dev_mem_base; + unsigned long dev_io_base; + char *dev_clockchip; + int dev_clocks; + int dev_clock[CONF_MAXCLOCKS]; + int dev_chipid; + int dev_chiprev; + int dev_irq; + int dev_screen; + XF86OptionPtr dev_option_lst; + char *dev_comment; +} +XF86ConfDeviceRec, *XF86ConfDevicePtr; + +typedef struct +{ + GenericListRec list; + char *mode_name; +} +XF86ModeRec, *XF86ModePtr; + +typedef struct +{ + GenericListRec list; + int disp_frameX0; + int disp_frameY0; + int disp_virtualX; + int disp_virtualY; + int disp_depth; + int disp_bpp; + char *disp_visual; + parser_rgb disp_weight; + parser_rgb disp_black; + parser_rgb disp_white; + XF86ModePtr disp_mode_lst; + XF86OptionPtr disp_option_lst; + char *disp_comment; +} +XF86ConfDisplayRec, *XF86ConfDisplayPtr; + +typedef struct +{ + XF86OptionPtr flg_option_lst; + char *flg_comment; +} +XF86ConfFlagsRec, *XF86ConfFlagsPtr; + +typedef struct +{ + GenericListRec list; + char *al_adaptor_str; + XF86ConfVideoAdaptorPtr al_adaptor; +} +XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr; + +typedef struct +{ + GenericListRec list; + char *scrn_identifier; + char *scrn_obso_driver; + int scrn_defaultdepth; + int scrn_defaultbpp; + int scrn_defaultfbbpp; + char *scrn_monitor_str; + XF86ConfMonitorPtr scrn_monitor; + char *scrn_device_str; + XF86ConfDevicePtr scrn_device; + XF86ConfAdaptorLinkPtr scrn_adaptor_lst; + XF86ConfDisplayPtr scrn_display_lst; + XF86OptionPtr scrn_option_lst; + char *scrn_comment; + int scrn_virtualX, scrn_virtualY; +} +XF86ConfScreenRec, *XF86ConfScreenPtr; + +typedef struct +{ + GenericListRec list; + char *inp_identifier; + char *inp_driver; + XF86OptionPtr inp_option_lst; + char *inp_comment; +} +XF86ConfInputRec, *XF86ConfInputPtr; + +typedef struct +{ + GenericListRec list; + XF86ConfInputPtr iref_inputdev; + char *iref_inputdev_str; + XF86OptionPtr iref_option_lst; +} +XF86ConfInputrefRec, *XF86ConfInputrefPtr; + +/* Values for adj_where */ +#define CONF_ADJ_OBSOLETE -1 +#define CONF_ADJ_ABSOLUTE 0 +#define CONF_ADJ_RIGHTOF 1 +#define CONF_ADJ_LEFTOF 2 +#define CONF_ADJ_ABOVE 3 +#define CONF_ADJ_BELOW 4 +#define CONF_ADJ_RELATIVE 5 + +typedef struct +{ + GenericListRec list; + int adj_scrnum; + XF86ConfScreenPtr adj_screen; + char *adj_screen_str; + XF86ConfScreenPtr adj_top; + char *adj_top_str; + XF86ConfScreenPtr adj_bottom; + char *adj_bottom_str; + XF86ConfScreenPtr adj_left; + char *adj_left_str; + XF86ConfScreenPtr adj_right; + char *adj_right_str; + int adj_where; + int adj_x; + int adj_y; + char *adj_refscreen; +} +XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr; + +typedef struct +{ + GenericListRec list; + char *inactive_device_str; + XF86ConfDevicePtr inactive_device; +} +XF86ConfInactiveRec, *XF86ConfInactivePtr; + +typedef struct +{ + GenericListRec list; + char *lay_identifier; + XF86ConfAdjacencyPtr lay_adjacency_lst; + XF86ConfInactivePtr lay_inactive_lst; + XF86ConfInputrefPtr lay_input_lst; + XF86OptionPtr lay_option_lst; + char *lay_comment; +} +XF86ConfLayoutRec, *XF86ConfLayoutPtr; + +typedef struct +{ + GenericListRec list; + char *vs_name; + char *vs_identifier; + XF86OptionPtr vs_option_lst; + char *vs_comment; +} +XF86ConfVendSubRec, *XF86ConfVendSubPtr; + +typedef struct +{ + GenericListRec list; + char *vnd_identifier; + XF86OptionPtr vnd_option_lst; + XF86ConfVendSubPtr vnd_sub_lst; + char *vnd_comment; +} +XF86ConfVendorRec, *XF86ConfVendorPtr; + +typedef struct +{ + GenericListRec list; + int buf_count; + int buf_size; + char *buf_flags; + char *buf_comment; +} +XF86ConfBuffersRec, *XF86ConfBuffersPtr; + +typedef struct +{ + char *dri_group_name; + int dri_group; + int dri_mode; + XF86ConfBuffersPtr dri_buffers_lst; + char *dri_comment; +} +XF86ConfDRIRec, *XF86ConfDRIPtr; + +typedef struct +{ + XF86OptionPtr ext_option_lst; + char *extensions_comment; +} +XF86ConfExtensionsRec, *XF86ConfExtensionsPtr; + +typedef struct +{ + XF86ConfFilesPtr conf_files; + XF86ConfModulePtr conf_modules; + XF86ConfFlagsPtr conf_flags; + XF86ConfVideoAdaptorPtr conf_videoadaptor_lst; + XF86ConfModesPtr conf_modes_lst; + XF86ConfMonitorPtr conf_monitor_lst; + XF86ConfDevicePtr conf_device_lst; + XF86ConfScreenPtr conf_screen_lst; + XF86ConfInputPtr conf_input_lst; + XF86ConfLayoutPtr conf_layout_lst; + XF86ConfVendorPtr conf_vendor_lst; + XF86ConfDRIPtr conf_dri; + XF86ConfExtensionsPtr conf_extensions; + char *conf_comment; +} +XF86ConfigRec, *XF86ConfigPtr; + +typedef struct +{ + int token; /* id of the token */ + char *name; /* pointer to the LOWERCASED name */ +} +xf86ConfigSymTabRec, *xf86ConfigSymTabPtr; + +/* + * prototypes for public functions + */ +extern const char *xf86openConfigFile (const char *, const char *, + const char *); +extern void xf86setBuiltinConfig(const char *config[]); +extern XF86ConfigPtr xf86readConfigFile (void); +extern void xf86closeConfigFile (void); +extern void xf86freeConfig (XF86ConfigPtr p); +extern int xf86writeConfigFile (const char *, XF86ConfigPtr); +XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p); +XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list); +XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p); +XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p); +XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p); +XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p); +XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p); +XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p); +XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident, + XF86ConfVideoAdaptorPtr p); + +GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new); +int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2); + +int xf86pathIsAbsolute(const char *path); +int xf86pathIsSafe(const char *path); +char *xf86addComment(char *cur, char *add); + +#endif /* _xf86Parser_h_ */ diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h new file mode 100644 index 000000000..6e4fdeab5 --- /dev/null +++ b/xorg-server/hw/xfree86/parser/xf86tokens.h @@ -0,0 +1,278 @@ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _xf86_tokens_h +#define _xf86_tokens_h + +/* Undefine symbols that some OSs might define */ +#undef IOBASE + +/* + * Each token should have a unique value regardless of the section + * it is used in. + */ + +typedef enum { + /* errno-style tokens */ + EOF_TOKEN = -4, + LOCK_TOKEN = -3, + ERROR_TOKEN = -2, + + /* value type tokens */ + NUMBER = 1, + STRING, + + /* Tokens that can appear in many sections */ + SECTION, + SUBSECTION, + ENDSECTION, + ENDSUBSECTION, + IDENTIFIER, + VENDOR, + DASH, + COMMA, + OPTION, + COMMENT, + + /* Frequency units */ + HRZ, + KHZ, + MHZ, + + /* File tokens */ + FONTPATH, + MODULEPATH, + INPUTDEVICES, + LOGFILEPATH, + + /* Server Flag tokens. These are deprecated in favour of generic Options */ + NOTRAPSIGNALS, + DONTZAP, + DONTZOOM, + DISABLEVIDMODE, + ALLOWNONLOCAL, + DISABLEMODINDEV, + MODINDEVALLOWNONLOCAL, + ALLOWMOUSEOPENFAIL, + BLANKTIME, + STANDBYTIME, + SUSPENDTIME, + OFFTIME, + DEFAULTLAYOUT, + + /* Monitor tokens */ + MODEL, + MODELINE, + DISPLAYSIZE, + HORIZSYNC, + VERTREFRESH, + MODE, + GAMMA, + USEMODES, + + /* Modes tokens */ + /* no new ones */ + + /* Mode tokens */ + DOTCLOCK, + HTIMINGS, + VTIMINGS, + FLAGS, + HSKEW, + BCAST, + VSCAN, + ENDMODE, + + /* Screen tokens */ + OBSDRIVER, + MDEVICE, + MONITOR, + SCREENNO, + DEFAULTDEPTH, + DEFAULTBPP, + DEFAULTFBBPP, + + /* VideoAdaptor tokens */ + VIDEOADAPTOR, + + /* Mode timing tokens */ + TT_INTERLACE, + TT_PHSYNC, + TT_NHSYNC, + TT_PVSYNC, + TT_NVSYNC, + TT_CSYNC, + TT_PCSYNC, + TT_NCSYNC, + TT_DBLSCAN, + TT_HSKEW, + TT_BCAST, + TT_VSCAN, + TT_CUSTOM, + + /* Module tokens */ + LOAD, + LOAD_DRIVER, + DISABLE, + + /* Device tokens */ + DRIVER, + CHIPSET, + CLOCKS, + VIDEORAM, + BOARD, + IOBASE, + RAMDAC, + DACSPEED, + BIOSBASE, + MEMBASE, + CLOCKCHIP, + CHIPID, + CHIPREV, + CARD, + BUSID, + TEXTCLOCKFRQ, + IRQ, + + /* Keyboard tokens */ + AUTOREPEAT, + XLEDS, + KPROTOCOL, + XKBKEYMAP, + XKBCOMPAT, + XKBTYPES, + XKBKEYCODES, + XKBGEOMETRY, + XKBSYMBOLS, + XKBDISABLE, + PANIX106, + XKBRULES, + XKBMODEL, + XKBLAYOUT, + XKBVARIANT, + XKBOPTIONS, + /* The next two have become ServerFlags options */ + VTSYSREQ, + /* Obsolete keyboard tokens */ + SERVERNUM, + LEFTALT, + RIGHTALT, + SCROLLLOCK_TOK, + RIGHTCTL, + /* arguments for the above obsolete tokens */ + CONF_KM_META, + CONF_KM_COMPOSE, + CONF_KM_MODESHIFT, + CONF_KM_MODELOCK, + CONF_KM_SCROLLLOCK, + CONF_KM_CONTROL, + + /* Pointer tokens */ + EMULATE3, + BAUDRATE, + SAMPLERATE, + PRESOLUTION, + CLEARDTR, + CLEARRTS, + CHORDMIDDLE, + PROTOCOL, + PDEVICE, + EM3TIMEOUT, + DEVICE_NAME, + ALWAYSCORE, + PBUTTONS, + ZAXISMAPPING, + + /* Pointer Z axis mapping tokens */ + XAXIS, + YAXIS, + + /* Display tokens */ + MODES, + VIEWPORT, + VIRTUAL, + VISUAL, + BLACK_TOK, + WHITE_TOK, + DEPTH, + BPP, + WEIGHT, + + /* Layout Tokens */ + SCREEN, + INACTIVE, + INPUTDEVICE, + + /* Adjaceny Tokens */ + RIGHTOF, + LEFTOF, + ABOVE, + BELOW, + RELATIVE, + ABSOLUTE, + + /* Vendor Tokens */ + VENDORNAME, + + /* DRI Tokens */ + GROUP, + BUFFERS +} ParserTokens; + +#endif /* _xf86_tokens_h */ diff --git a/xorg-server/hw/xfree86/rac/Makefile.am b/xorg-server/hw/xfree86/rac/Makefile.am new file mode 100644 index 000000000..b25068271 --- /dev/null +++ b/xorg-server/hw/xfree86/rac/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = librac.a +librac_a_SOURCES = xf86RAC.c + +sdk_HEADERS = xf86RAC.h + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xfree86/rac/Makefile.in b/xorg-server/hw/xfree86/rac/Makefile.in new file mode 100644 index 000000000..03a1c920b --- /dev/null +++ b/xorg-server/hw/xfree86/rac/Makefile.in @@ -0,0 +1,674 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/rac +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +librac_a_AR = $(AR) $(ARFLAGS) +librac_a_LIBADD = +am_librac_a_OBJECTS = xf86RAC.$(OBJEXT) +librac_a_OBJECTS = $(am_librac_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(librac_a_SOURCES) +DIST_SOURCES = $(librac_a_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = librac.a +librac_a_SOURCES = xf86RAC.c +sdk_HEADERS = xf86RAC.h +INCLUDES = $(XORG_INCS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/rac/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/rac/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +librac.a: $(librac_a_OBJECTS) $(librac_a_DEPENDENCIES) + -rm -f librac.a + $(librac_a_AR) librac.a $(librac_a_OBJECTS) $(librac_a_LIBADD) + $(RANLIB) librac.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86RAC.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/rac/xf86RAC.c b/xorg-server/hw/xfree86/rac/xf86RAC.c new file mode 100644 index 000000000..8985f38b0 --- /dev/null +++ b/xorg-server/hw/xfree86/rac/xf86RAC.c @@ -0,0 +1,1157 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "colormapst.h" +#include "scrnintstr.h" +#include "screenint.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "pixmap.h" +#include "windowstr.h" +#include "window.h" +#include "xf86str.h" +#include "xf86RAC.h" +#include "mipointer.h" +#include "mipointrst.h" +#ifdef RENDER +# include "picturestr.h" +#endif + +#ifdef DEBUG +#define DPRINT_S(x,y) ErrorF(x ": %i\n",y); +#define DPRINT(x) ErrorF(x "\n"); +#else +#define DPRINT_S(x,y) +#define DPRINT(x) +#endif + +#define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x;\ + pScreen->x = y;} +#define WRAP_SCREEN_COND(x,y,cond) \ + {pScreenPriv->x = pScreen->x;\ + if (flag & (cond))\ + pScreen->x = y;} +#define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x + +#define SCREEN_PROLOG(x) pScreen->x = ((RACScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->x +#define SCREEN_EPILOG(x,y) pScreen->x = y; + +#define WRAP_PICT_COND(x,y,cond) if (ps)\ + {pScreenPriv->x = ps->x;\ + if (flag & (cond))\ + ps->x = y;} +#define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;} + +#define PICTURE_PROLOGUE(field) ps->field = \ + ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->field +#define PICTURE_EPILOGUE(field, wrap) \ + ps->field = wrap + +#define WRAP_SCREEN_INFO(x,y) {pScreenPriv->x = pScrn->x;\ + pScrn->x = y;} +#define WRAP_SCREEN_INFO_COND(x,y,cond) \ + {pScreenPriv->x = pScrn->x;\ + if (flag & (cond))\ + pScrn->x = y;} +#define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x + +#define SPRITE_PROLOG miPointerScreenPtr PointPriv = \ + (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); \ + RACScreenPtr pScreenPriv = \ + ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey));\ + PointPriv->spriteFuncs = pScreenPriv->miSprite; +#define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\ + PointPriv->spriteFuncs = &RACSpriteFuncs; +#define WRAP_SPRITE_COND(cond){pScreenPriv->miSprite = PointPriv->spriteFuncs;\ + if(flag & (cond))\ + PointPriv->spriteFuncs = &RACSpriteFuncs;} +#define UNWRAP_SPRITE PointPriv->spriteFuncs = pScreenPriv->miSprite + + +#define GC_WRAP(x) pGCPriv->wrapOps = (x)->ops;\ + pGCPriv->wrapFuncs = (x)->funcs;\ + (x)->ops = &RACGCOps;\ + (x)->funcs = &RACGCFuncs; +#define GC_UNWRAP(x)\ + RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&(x)->devPrivates, RACGCKey);\ + (x)->ops = pGCPriv->wrapOps;\ + (x)->funcs = pGCPriv->wrapFuncs; + +#define GC_SCREEN register ScrnInfoPtr pScrn \ + = xf86Screens[pGC->pScreen->myNum] + +#define ENABLE xf86EnableAccess(xf86Screens[pScreen->myNum]) +#define ENABLE_GC xf86EnableAccess(xf86Screens[pGC->pScreen->myNum]) + +typedef struct _RACScreen { + CreateGCProcPtr CreateGC; + CloseScreenProcPtr CloseScreen; + GetImageProcPtr GetImage; + GetSpansProcPtr GetSpans; + SourceValidateProcPtr SourceValidate; + CopyWindowProcPtr CopyWindow; + ClearToBackgroundProcPtr ClearToBackground; + CreatePixmapProcPtr CreatePixmap; + SaveScreenProcPtr SaveScreen; + /* Colormap */ + StoreColorsProcPtr StoreColors; + /* Cursor */ + DisplayCursorProcPtr DisplayCursor; + RealizeCursorProcPtr RealizeCursor; + UnrealizeCursorProcPtr UnrealizeCursor; + RecolorCursorProcPtr RecolorCursor; + SetCursorPositionProcPtr SetCursorPosition; + void (*AdjustFrame)(int,int,int,int); + Bool (*SwitchMode)(int, DisplayModePtr,int); + Bool (*EnterVT)(int, int); + void (*LeaveVT)(int, int); + void (*FreeScreen)(int, int); + miPointerSpriteFuncPtr miSprite; +#ifdef RENDER + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; + CompositeRectsProcPtr CompositeRects; +#endif +} RACScreenRec, *RACScreenPtr; + +typedef struct _RACGC { + GCOps *wrapOps; + GCFuncs *wrapFuncs; +} RACGCRec, *RACGCPtr; + +/* Screen funcs */ +static Bool RACCloseScreen (int i, ScreenPtr pScreen); +static void RACGetImage (DrawablePtr pDrawable, int sx, int sy, + int w, int h, unsigned int format, + unsigned long planemask, char *pdstLine); +static void RACGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, + int *pwidth, int nspans, char *pdstStart); +static void RACSourceValidate (DrawablePtr pDrawable, + int x, int y, int width, int height ); +static void RACCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, + RegionPtr prgnSrc ); +static void RACClearToBackground (WindowPtr pWin, int x, int y, + int w, int h, Bool generateExposures ); +static PixmapPtr RACCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, + unsigned usage_hint); +static Bool RACCreateGC(GCPtr pGC); +static Bool RACSaveScreen(ScreenPtr pScreen, Bool unblank); +static void RACStoreColors (ColormapPtr pmap, int ndef, xColorItem *pdefs); +static void RACRecolorCursor (ScreenPtr pScreen, CursorPtr pCurs, + Bool displayed); +static Bool RACRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor); +static Bool RACUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor); +static Bool RACDisplayCursor (ScreenPtr pScreen, CursorPtr pCursor); +static Bool RACSetCursorPosition (ScreenPtr pScreen, int x, int y, + Bool generateEvent); +static void RACAdjustFrame(int index, int x, int y, int flags); +static Bool RACSwitchMode(int index, DisplayModePtr mode, int flags); +static Bool RACEnterVT(int index, int flags); +static void RACLeaveVT(int index, int flags); +static void RACFreeScreen(int index, int flags); +/* GC funcs */ +static void RACValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw); +static void RACChangeGC(GCPtr pGC, unsigned long mask); +static void RACCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); +static void RACDestroyGC(GCPtr pGC); +static void RACChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects); +static void RACDestroyClip(GCPtr pGC); +static void RACCopyClip(GCPtr pgcDst, GCPtr pgcSrc); +/* GC ops */ +static void RACFillSpans( DrawablePtr pDraw, GC *pGC, int nInit, + DDXPointPtr pptInit, int *pwidthInit, int fSorted ); +static void RACSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc, + register DDXPointPtr ppt, int *pwidth, int nspans, + int fSorted ); +static void RACPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, + int x, int y, int w, int h, int leftPad, + int format, char *pImage ); +static RegionPtr RACCopyArea(DrawablePtr pSrc, DrawablePtr pDst, + GC *pGC, int srcx, int srcy, + int width, int height, + int dstx, int dsty ); +static RegionPtr RACCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, + GCPtr pGC, int srcx, int srcy, + int width, int height, int dstx, int dsty, + unsigned long bitPlane ); +static void RACPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode, + int npt, xPoint *pptInit ); +static void RACPolylines(DrawablePtr pDraw, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit ); +static void RACPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg, + xSegment *pSeg ); +static void RACPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nRectsInit, + xRectangle *pRectsInit ); +static void RACPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, + xArc *parcs ); +static void RACFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape, int mode, + int count, DDXPointPtr ptsIn ); +static void RACPolyFillRect( DrawablePtr pDraw, GCPtr pGC, int nrectFill, + xRectangle *prectInit ); +static void RACPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs, + xArc *parcs ); +static int RACPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, char *chars ); +static int RACPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars ); +static void RACImageText8(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, char *chars ); +static void RACImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars ); +static void RACImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase ); +static void RACPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase ); +static void RACPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg ); +/* miSpriteFuncs */ +static Bool RACSpriteRealizeCursor(ScreenPtr pScreen, CursorPtr pCur); +static Bool RACSpriteUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCur); +static void RACSpriteSetCursor(ScreenPtr pScreen, CursorPtr pCur, + int x, int y); +static void RACSpriteMoveCursor(ScreenPtr pScreen, int x, int y); +#ifdef RENDER +static void RACComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, + PicturePtr pDst, INT16 xSrc, INT16 ySrc, + INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height); +static void RACGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int nlist, GlyphListPtr list, GlyphPtr *glyphs); +static void RACCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, + int nRect, xRectangle *rects); +#endif + +static GCFuncs RACGCFuncs = { + RACValidateGC, RACChangeGC, RACCopyGC, RACDestroyGC, + RACChangeClip, RACDestroyClip, RACCopyClip +}; + +static GCOps RACGCOps = { + RACFillSpans, RACSetSpans, RACPutImage, RACCopyArea, + RACCopyPlane, RACPolyPoint, RACPolylines, RACPolySegment, + RACPolyRectangle, RACPolyArc, RACFillPolygon, RACPolyFillRect, + RACPolyFillArc, RACPolyText8, RACPolyText16, RACImageText8, + RACImageText16, RACImageGlyphBlt, RACPolyGlyphBlt, RACPushPixels, + {NULL} /* devPrivate */ +}; + +static miPointerSpriteFuncRec RACSpriteFuncs = { + RACSpriteRealizeCursor, RACSpriteUnrealizeCursor, RACSpriteSetCursor, + RACSpriteMoveCursor +}; + +static DevPrivateKey RACScreenKey = &RACScreenKey; +static DevPrivateKey RACGCKey = &RACGCKey; + + +Bool +xf86RACInit(ScreenPtr pScreen, unsigned int flag) +{ + ScrnInfoPtr pScrn; + RACScreenPtr pScreenPriv; + miPointerScreenPtr PointPriv; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + pScrn = xf86Screens[pScreen->myNum]; + PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miPointerScreenKey); + DPRINT_S("RACInit",pScreen->myNum); + + if (!dixRequestPrivate(RACGCKey, sizeof(RACGCRec))) + return FALSE; + + if (!(pScreenPriv = xalloc(sizeof(RACScreenRec)))) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, RACScreenKey, pScreenPriv); + + WRAP_SCREEN(CloseScreen, RACCloseScreen); + WRAP_SCREEN(SaveScreen, RACSaveScreen); + WRAP_SCREEN_COND(CreateGC, RACCreateGC, RAC_FB); + WRAP_SCREEN_COND(GetImage, RACGetImage, RAC_FB); + WRAP_SCREEN_COND(GetSpans, RACGetSpans, RAC_FB); + WRAP_SCREEN_COND(SourceValidate, RACSourceValidate, RAC_FB); + WRAP_SCREEN_COND(CopyWindow, RACCopyWindow, RAC_FB); + WRAP_SCREEN_COND(ClearToBackground, RACClearToBackground, RAC_FB); + WRAP_SCREEN_COND(CreatePixmap, RACCreatePixmap, RAC_FB); + WRAP_SCREEN_COND(StoreColors, RACStoreColors, RAC_COLORMAP); + WRAP_SCREEN_COND(DisplayCursor, RACDisplayCursor, RAC_CURSOR); + WRAP_SCREEN_COND(RealizeCursor, RACRealizeCursor, RAC_CURSOR); + WRAP_SCREEN_COND(UnrealizeCursor, RACUnrealizeCursor, RAC_CURSOR); + WRAP_SCREEN_COND(RecolorCursor, RACRecolorCursor, RAC_CURSOR); + WRAP_SCREEN_COND(SetCursorPosition, RACSetCursorPosition, RAC_CURSOR); +#ifdef RENDER + WRAP_PICT_COND(Composite,RACComposite,RAC_FB); + WRAP_PICT_COND(Glyphs,RACGlyphs,RAC_FB); + WRAP_PICT_COND(CompositeRects,RACCompositeRects,RAC_FB); +#endif + WRAP_SCREEN_INFO_COND(AdjustFrame, RACAdjustFrame, RAC_VIEWPORT); + WRAP_SCREEN_INFO(SwitchMode, RACSwitchMode); + WRAP_SCREEN_INFO(EnterVT, RACEnterVT); + WRAP_SCREEN_INFO(LeaveVT, RACLeaveVT); + WRAP_SCREEN_INFO(FreeScreen, RACFreeScreen); + WRAP_SPRITE_COND(RAC_CURSOR); + + return TRUE; +} + +/* Screen funcs */ +static Bool +RACCloseScreen (int i, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + DPRINT_S("RACCloseScreen",pScreen->myNum); + UNWRAP_SCREEN(CreateGC); + UNWRAP_SCREEN(CloseScreen); + UNWRAP_SCREEN(GetImage); + UNWRAP_SCREEN(GetSpans); + UNWRAP_SCREEN(SourceValidate); + UNWRAP_SCREEN(CopyWindow); + UNWRAP_SCREEN(ClearToBackground); + UNWRAP_SCREEN(SaveScreen); + UNWRAP_SCREEN(StoreColors); + UNWRAP_SCREEN(DisplayCursor); + UNWRAP_SCREEN(RealizeCursor); + UNWRAP_SCREEN(UnrealizeCursor); + UNWRAP_SCREEN(RecolorCursor); + UNWRAP_SCREEN(SetCursorPosition); +#ifdef RENDER + UNWRAP_PICT(Composite); + UNWRAP_PICT(Glyphs); + UNWRAP_PICT(CompositeRects); +#endif + UNWRAP_SCREEN_INFO(AdjustFrame); + UNWRAP_SCREEN_INFO(SwitchMode); + UNWRAP_SCREEN_INFO(EnterVT); + UNWRAP_SCREEN_INFO(LeaveVT); + UNWRAP_SCREEN_INFO(FreeScreen); + UNWRAP_SPRITE; + + xfree ((pointer) pScreenPriv); + + if (xf86Screens[pScreen->myNum]->vtSema) { + xf86EnterServerState(SETUP); + ENABLE; + } + return (*pScreen->CloseScreen) (i, pScreen); +} + +static void +RACGetImage ( + DrawablePtr pDrawable, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planemask, + char *pdstLine + ) +{ + ScreenPtr pScreen = pDrawable->pScreen; + DPRINT_S("RACGetImage",pScreen->myNum); + SCREEN_PROLOG(GetImage); + if (xf86Screens[pScreen->myNum]->vtSema) { + ENABLE; + } + (*pScreen->GetImage) (pDrawable, sx, sy, w, h, + format, planemask, pdstLine); + SCREEN_EPILOG (GetImage, RACGetImage); +} + +static void +RACGetSpans ( + DrawablePtr pDrawable, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pdstStart + ) +{ + ScreenPtr pScreen = pDrawable->pScreen; + + DPRINT_S("RACGetSpans",pScreen->myNum); + SCREEN_PROLOG (GetSpans); + ENABLE; + (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); + SCREEN_EPILOG (GetSpans, RACGetSpans); +} + +static void +RACSourceValidate ( + DrawablePtr pDrawable, + int x, int y, int width, int height ) +{ + ScreenPtr pScreen = pDrawable->pScreen; + DPRINT_S("RACSourceValidate",pScreen->myNum); + SCREEN_PROLOG (SourceValidate); + ENABLE; + if (pScreen->SourceValidate) + (*pScreen->SourceValidate) (pDrawable, x, y, width, height); + SCREEN_EPILOG (SourceValidate, RACSourceValidate); +} + +static void +RACCopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc ) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + DPRINT_S("RACCopyWindow",pScreen->myNum); + SCREEN_PROLOG (CopyWindow); + ENABLE; + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); + SCREEN_EPILOG (CopyWindow, RACCopyWindow); +} + +static void +RACClearToBackground ( + WindowPtr pWin, + int x, int y, + int w, int h, + Bool generateExposures ) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + DPRINT_S("RACClearToBackground",pScreen->myNum); + SCREEN_PROLOG ( ClearToBackground); + ENABLE; + (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures); + SCREEN_EPILOG (ClearToBackground, RACClearToBackground); +} + +static PixmapPtr +RACCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint) +{ + PixmapPtr pPix; + + DPRINT_S("RACCreatePixmap",pScreen->myNum); + SCREEN_PROLOG ( CreatePixmap); + ENABLE; + pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint); + SCREEN_EPILOG (CreatePixmap, RACCreatePixmap); + + return pPix; +} + +static Bool +RACSaveScreen(ScreenPtr pScreen, Bool unblank) +{ + Bool val; + + DPRINT_S("RACSaveScreen",pScreen->myNum); + SCREEN_PROLOG (SaveScreen); + ENABLE; + val = (*pScreen->SaveScreen) (pScreen, unblank); + SCREEN_EPILOG (SaveScreen, RACSaveScreen); + + return val; +} + +static void +RACStoreColors ( + ColormapPtr pmap, + int ndef, + xColorItem *pdefs) +{ + ScreenPtr pScreen = pmap->pScreen; + + DPRINT_S("RACStoreColors",pScreen->myNum); + SCREEN_PROLOG (StoreColors); + ENABLE; + (*pScreen->StoreColors) (pmap,ndef,pdefs); + + SCREEN_EPILOG ( StoreColors, RACStoreColors); +} + +static void +RACRecolorCursor ( + ScreenPtr pScreen, + CursorPtr pCurs, + Bool displayed + ) +{ + DPRINT_S("RACRecolorCursor",pScreen->myNum); + SCREEN_PROLOG (RecolorCursor); + ENABLE; + (*pScreen->RecolorCursor) (pScreen,pCurs,displayed); + + SCREEN_EPILOG ( RecolorCursor, RACRecolorCursor); +} + +static Bool +RACRealizeCursor ( + ScreenPtr pScreen, + CursorPtr pCursor + ) +{ + Bool val; + + DPRINT_S("RACRealizeCursor",pScreen->myNum); + SCREEN_PROLOG (RealizeCursor); + ENABLE; + val = (*pScreen->RealizeCursor) (pScreen,pCursor); + + SCREEN_EPILOG ( RealizeCursor, RACRealizeCursor); + return val; +} + +static Bool +RACUnrealizeCursor ( + ScreenPtr pScreen, + CursorPtr pCursor + ) +{ + Bool val; + + DPRINT_S("RACUnrealizeCursor",pScreen->myNum); + SCREEN_PROLOG (UnrealizeCursor); + ENABLE; + val = (*pScreen->UnrealizeCursor) (pScreen,pCursor); + + SCREEN_EPILOG ( UnrealizeCursor, RACUnrealizeCursor); + return val; +} + +static Bool +RACDisplayCursor ( + ScreenPtr pScreen, + CursorPtr pCursor + ) +{ + Bool val; + + DPRINT_S("RACDisplayCursor",pScreen->myNum); + SCREEN_PROLOG (DisplayCursor); + ENABLE; + val = (*pScreen->DisplayCursor) (pScreen,pCursor); + + SCREEN_EPILOG ( DisplayCursor, RACDisplayCursor); + return val; +} + +static Bool +RACSetCursorPosition ( + ScreenPtr pScreen, + int x, int y, + Bool generateEvent) +{ + Bool val; + + DPRINT_S("RACSetCursorPosition",pScreen->myNum); + SCREEN_PROLOG (SetCursorPosition); + ENABLE; + val = (*pScreen->SetCursorPosition) (pScreen,x,y,generateEvent); + + SCREEN_EPILOG ( SetCursorPosition, RACSetCursorPosition); + return val; +} + +static void +RACAdjustFrame(int index, int x, int y, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + + DPRINT_S("RACAdjustFrame",index); + xf86EnableAccess(xf86Screens[index]); + + (*pScreenPriv->AdjustFrame)(index, x, y, flags); +} + +static Bool +RACSwitchMode(int index, DisplayModePtr mode, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + + DPRINT_S("RACSwitchMode",index); + xf86EnableAccess(xf86Screens[index]); + + return (*pScreenPriv->SwitchMode)(index, mode, flags); +} + +static Bool +RACEnterVT(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + + DPRINT_S("RACEnterVT",index); + xf86EnableAccess(xf86Screens[index]); + + return (*pScreenPriv->EnterVT)(index, flags); +} + +static void +RACLeaveVT(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + + DPRINT_S("RACLeaveVT",index); + xf86EnableAccess(xf86Screens[index]); + + (*pScreenPriv->LeaveVT)(index, flags); +} + +static void +RACFreeScreen(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + + DPRINT_S("RACFreeScreen",index); + xf86EnableAccess(xf86Screens[index]); + + (*pScreenPriv->FreeScreen)(index, flags); +} + +static Bool +RACCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&pGC->devPrivates, RACGCKey); + Bool ret; + + DPRINT_S("RACCreateGC",pScreen->myNum); + SCREEN_PROLOG(CreateGC); + + ret = (*pScreen->CreateGC)(pGC); + + GC_WRAP(pGC); + SCREEN_EPILOG(CreateGC,RACCreateGC); + + return ret; +} + +/* GC funcs */ +static void +RACValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + GC_UNWRAP(pGC); + DPRINT("RACValidateGC"); + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + GC_WRAP(pGC); +} + + +static void +RACDestroyGC(GCPtr pGC) +{ + GC_UNWRAP (pGC); + DPRINT("RACDestroyGC"); + (*pGC->funcs->DestroyGC)(pGC); + GC_WRAP (pGC); +} + +static void +RACChangeGC ( + GCPtr pGC, + unsigned long mask) +{ + GC_UNWRAP (pGC); + DPRINT("RACChangeGC"); + (*pGC->funcs->ChangeGC) (pGC, mask); + GC_WRAP (pGC); +} + +static void +RACCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst) +{ + GC_UNWRAP (pGCDst); + DPRINT("RACCopyGC"); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + GC_WRAP (pGCDst); +} + +static void +RACChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects ) +{ + GC_UNWRAP (pGC); + DPRINT("RACChangeClip"); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + GC_WRAP (pGC); +} + +static void +RACCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + GC_UNWRAP (pgcDst); + DPRINT("RACCopyClip"); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + GC_WRAP (pgcDst); +} + +static void +RACDestroyClip(GCPtr pGC) +{ + GC_UNWRAP (pGC); + DPRINT("RACDestroyClip"); + (* pGC->funcs->DestroyClip)(pGC); + GC_WRAP (pGC); +} + +/* GC Ops */ +static void +RACFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted ) +{ + GC_UNWRAP(pGC); + DPRINT("RACFillSpans"); + ENABLE_GC; + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + GC_WRAP(pGC); +} + +static void +RACSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted ) +{ + GC_UNWRAP(pGC); + DPRINT("RACSetSpans"); + ENABLE_GC; + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + GC_WRAP(pGC); +} + +static void +RACPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPutImage"); + ENABLE_GC; + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + GC_WRAP(pGC); +} + +static RegionPtr +RACCopyArea( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty ) +{ + RegionPtr ret; + + GC_UNWRAP(pGC); + DPRINT("RACCopyArea"); + ENABLE_GC; + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + GC_WRAP(pGC); + return ret; +} + +static RegionPtr +RACCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane ) +{ + RegionPtr ret; + + GC_UNWRAP(pGC); + DPRINT("RACCopyPlane"); + ENABLE_GC; + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy, + width, height, dstx, dsty, bitPlane); + GC_WRAP(pGC); + return ret; +} + +static void +RACPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolyPoint"); + ENABLE_GC; + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + GC_WRAP(pGC); +} + + +static void +RACPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolylines"); + ENABLE_GC; + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + GC_WRAP(pGC); +} + +static void +RACPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolySegment"); + ENABLE_GC; + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + GC_WRAP(pGC); +} + +static void +RACPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolyRectangle"); + ENABLE_GC; + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + GC_WRAP(pGC); +} + +static void +RACPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolyArc"); + ENABLE_GC; + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + GC_WRAP(pGC); +} + +static void +RACFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn ) +{ + GC_UNWRAP(pGC); + DPRINT("RACFillPolygon"); + ENABLE_GC; + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + GC_WRAP(pGC); +} + + +static void +RACPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolyFillRect"); + ENABLE_GC; + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + GC_WRAP(pGC); +} + + +static void +RACPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolyFillArc"); + ENABLE_GC; + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + GC_WRAP(pGC); +} + +static int +RACPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars ) +{ + int ret; + + GC_UNWRAP(pGC); + DPRINT("RACPolyText8"); + ENABLE_GC; + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + GC_WRAP(pGC); + return ret; +} + +static int +RACPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars ) +{ + int ret; + + GC_UNWRAP(pGC); + DPRINT("RACPolyText16"); + ENABLE_GC; + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + GC_WRAP(pGC); + return ret; +} + +static void +RACImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars ) +{ + GC_UNWRAP(pGC); + DPRINT("RACImageText8"); + ENABLE_GC; + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + GC_WRAP(pGC); +} + +static void +RACImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars ) +{ + GC_UNWRAP(pGC); + DPRINT("RACImageText16"); + ENABLE_GC; + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + GC_WRAP(pGC); +} + + +static void +RACImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + GC_UNWRAP(pGC); + DPRINT("RACImageGlyphBlt"); + ENABLE_GC; + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, + nglyph, ppci, pglyphBase); + GC_WRAP(pGC); +} + +static void +RACPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPolyGlyphBlt"); + ENABLE_GC; + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, + nglyph, ppci, pglyphBase); + GC_WRAP(pGC); +} + +static void +RACPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg ) +{ + GC_UNWRAP(pGC); + DPRINT("RACPushPixels"); + ENABLE_GC; + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + GC_WRAP(pGC); +} + + +/* miSpriteFuncs */ +static Bool +RACSpriteRealizeCursor(ScreenPtr pScreen, CursorPtr pCur) +{ + Bool val; + SPRITE_PROLOG; + DPRINT_S("RACSpriteRealizeCursor",pScreen->myNum); + ENABLE; + val = PointPriv->spriteFuncs->RealizeCursor(pScreen, pCur); + SPRITE_EPILOG; + return val; +} + +static Bool +RACSpriteUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCur) +{ + Bool val; + SPRITE_PROLOG; + DPRINT_S("RACSpriteUnrealizeCursor",pScreen->myNum); + ENABLE; + val = PointPriv->spriteFuncs->UnrealizeCursor(pScreen, pCur); + SPRITE_EPILOG; + return val; +} + +static void +RACSpriteSetCursor(ScreenPtr pScreen, CursorPtr pCur, int x, int y) +{ + SPRITE_PROLOG; + DPRINT_S("RACSpriteSetCursor",pScreen->myNum); + ENABLE; + PointPriv->spriteFuncs->SetCursor(pScreen, pCur, x, y); + SPRITE_EPILOG; +} + +static void +RACSpriteMoveCursor(ScreenPtr pScreen, int x, int y) +{ + SPRITE_PROLOG; + DPRINT_S("RACSpriteMoveCursor",pScreen->myNum); + ENABLE; + PointPriv->spriteFuncs->MoveCursor(pScreen, x, y); + SPRITE_EPILOG; +} + +#ifdef RENDER +static void +RACComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, + PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, + INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + + PICTURE_PROLOGUE(Composite); + + ENABLE; + (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, + yDst, width, height); + + PICTURE_EPILOGUE(Composite, RACComposite); +} + +static void +RACGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, + GlyphListPtr list, GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + + PICTURE_PROLOGUE(Glyphs); + + ENABLE; + (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); + + PICTURE_EPILOGUE (Glyphs, RACGlyphs); +} + +static void +RACCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect, + xRectangle *rects) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + + PICTURE_PROLOGUE(CompositeRects); + + ENABLE; + (*ps->CompositeRects)(op, pDst, color, nRect, rects); + + PICTURE_EPILOGUE (CompositeRects, RACCompositeRects); +} +#endif + diff --git a/xorg-server/hw/xfree86/rac/xf86RAC.h b/xorg-server/hw/xfree86/rac/xf86RAC.h new file mode 100644 index 000000000..366c21485 --- /dev/null +++ b/xorg-server/hw/xfree86/rac/xf86RAC.h @@ -0,0 +1,17 @@ + +#ifndef __XF86RAC_H +#define __XF86RAC_H 1 + +#include "screenint.h" +#include "misc.h" +#include "xf86.h" + +Bool xf86RACInit(ScreenPtr pScreen, unsigned int flag); + +/* flags */ +#define RAC_FB 0x01 +#define RAC_CURSOR 0x02 +#define RAC_COLORMAP 0x04 +#define RAC_VIEWPORT 0x08 + +#endif /* __XF86RAC_H */ diff --git a/xorg-server/hw/xfree86/ramdac/BT.c b/xorg-server/hw/xfree86/ramdac/BT.c new file mode 100644 index 000000000..5aa27a1f8 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/BT.c @@ -0,0 +1,165 @@ +/* + * Copyright 1998 by Alan Hourihane, Wigan, England. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> + * + * BT RAMDAC routines. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86_OSproc.h" + +#define INIT_BT_RAMDAC_INFO +#include "BTPriv.h" +#include "xf86RamDacPriv.h" + +void +BTramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg) +{ + int i; + + /* Here we pass a short, so that we can evaluate a mask too */ + /* So that the mask is the high byte and the data the low byte */ + /* Just the command/status registers */ + for (i=0x06;i<0x0A;i++) + (*ramdacPtr->WriteDAC) + (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8, + ramdacReg->DacRegs[i]); +} + +void +BTramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg) +{ + int i; + + (*ramdacPtr->ReadAddress)(pScrn, 0); /* Start at index 0 */ + for (i=0;i<768;i++) + ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn); + + /* Just the command/status registers */ + for (i=0x06;i<0x0A;i++) + ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i); +} + +RamDacHelperRecPtr +BTramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/*, RamDacRecPtr ramdacPtr*/) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + Bool RamDacIsSupported = FALSE; + RamDacHelperRecPtr ramdacHelperPtr = NULL; + int BTramdac_ID = -1; + int i, status, cmd0; + + /* Save COMMAND Register 0 */ + cmd0 = (*ramdacPtr->ReadDAC)(pScrn, BT_COMMAND_REG_0); + /* Ensure were going to access the STATUS Register on next read */ + (*ramdacPtr->WriteDAC)(pScrn, BT_COMMAND_REG_0, 0x7F, 0x00); + + status = (*ramdacPtr->ReadDAC)(pScrn, BT_STATUS_REG); + switch (status) { + case 0x40: + BTramdac_ID = ATT20C504_RAMDAC; + break; + case 0xD0: + BTramdac_ID = ATT20C505_RAMDAC; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Unknown BT RAMDAC type (0x%x), assuming BT485\n", + status); + case 0x80: + case 0x90: + case 0xA0: + case 0xB0: + case 0x28: /* This is for the DEC TGA - Questionable ? */ + BTramdac_ID = BT485_RAMDAC; + break; + } + + /* Restore COMMAND Register 0 */ + (*ramdacPtr->WriteDAC)(pScrn, BT_COMMAND_REG_0, 0x00, cmd0); + + if (BTramdac_ID == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Cannot determine BT RAMDAC type, aborting\n"); + return NULL; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached RAMDAC is %s\n", BTramdacDeviceInfo[BTramdac_ID&0xFFFF].DeviceName); + } + + for (i=0;ramdacs[i].token != -1;i++) { + if (ramdacs[i].token == BTramdac_ID) + RamDacIsSupported = TRUE; + } + + if (!RamDacIsSupported) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "This BT RAMDAC is NOT supported by this driver, aborting\n"); + return NULL; + } + + ramdacHelperPtr = RamDacHelperCreateInfoRec(); + switch(BTramdac_ID) { + case BT485_RAMDAC: + ramdacHelperPtr->SetBpp = BTramdacSetBpp; + break; + } + ramdacPtr->RamDacType = BTramdac_ID; + ramdacHelperPtr->RamDacType = BTramdac_ID; + ramdacHelperPtr->Save = BTramdacSave; + ramdacHelperPtr->Restore = BTramdacRestore; + + return ramdacHelperPtr; +} + +void +BTramdacSetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) +{ + /* We need to deal with Direct Colour visuals for 8bpp and other + * good stuff for colours */ + switch (pScrn->bitsPerPixel) { + case 32: + ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x10; + break; + case 24: + ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x10; + break; + case 16: + ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x38; + break; + case 15: + ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x30; + break; + case 8: + ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x40; + break; + case 4: + ramdacReg->DacRegs[BT_COMMAND_REG_1] = 0x60; + break; + } +} diff --git a/xorg-server/hw/xfree86/ramdac/BT.h b/xorg-server/hw/xfree86/ramdac/BT.h new file mode 100644 index 000000000..b3426bada --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/BT.h @@ -0,0 +1,32 @@ + +#include "xf86RamDac.h" + +RamDacHelperRecPtr BTramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs); +void BTramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec); +void BTramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec); +void BTramdacSetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec); + +#define ATT20C504_RAMDAC (VENDOR_BT << 16) | 0x00 +#define ATT20C505_RAMDAC (VENDOR_BT << 16) | 0x01 +#define BT485_RAMDAC (VENDOR_BT << 16) | 0x02 + +/* + * BT registers + */ + +#define BT_WRITE_ADDR 0x00 +#define BT_RAMDAC_DATA 0x01 +#define BT_PIXEL_MASK 0x02 +#define BT_READ_ADDR 0x03 +#define BT_CURS_WR_ADDR 0x04 +#define BT_CURS_DATA 0x05 +#define BT_COMMAND_REG_0 0x06 +#define BT_CURS_RD_ADDR 0x07 +#define BT_COMMAND_REG_1 0x08 +#define BT_COMMAND_REG_2 0x09 +#define BT_STATUS_REG 0x0A +#define BT_CURS_RAM_DATA 0x0B +#define BT_CURS_X_LOW 0x0C +#define BT_CURS_X_HIGH 0x0D +#define BT_CURS_Y_LOW 0x0E +#define BT_CURS_Y_HIGH 0x0F diff --git a/xorg-server/hw/xfree86/ramdac/BTPriv.h b/xorg-server/hw/xfree86/ramdac/BTPriv.h new file mode 100644 index 000000000..184b4811c --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/BTPriv.h @@ -0,0 +1,20 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "BT.h" + +typedef struct { + char *DeviceName; +} xf86BTramdacInfo; + +extern xf86BTramdacInfo BTramdacDeviceInfo[]; + +#ifdef INIT_BT_RAMDAC_INFO +xf86BTramdacInfo BTramdacDeviceInfo[] = { + {"AT&T 20C504"}, + {"AT&T 20C505"}, + {"BT485/484"} +}; +#endif diff --git a/xorg-server/hw/xfree86/ramdac/CURSOR.NOTES b/xorg-server/hw/xfree86/ramdac/CURSOR.NOTES new file mode 100644 index 000000000..726e2edc1 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/CURSOR.NOTES @@ -0,0 +1,191 @@ + CURSOR.NOTES + + This file describes how to add hardware cursor support to a chipset +driver. Though the cursor support itself is in the ramdac module, +cursor management is separate from the rest of the module. + + +1) CURSOR INITIALIZATION AND SHUTDOWN + + All relevant prototypes and defines are in xf86Cursor.h. + + To initialize the cursor, the driver should allocate an +xf86CursorInfoRec via xf86CreateCursorInfoRec(), fill it out as described +later in this document and pass it to xf86InitCursor(). xf86InitCursor() +must be called _after_ the software cursor initialization (usually +miDCInitialize). + + When shutting down, the driver should free the xf86CursorInfoRec +structure in its CloseScreen function via xf86DestroyCursorInfoRec(). + + +2) FILLING OUT THE xf86CursorInfoRec + + The driver informs the ramdac module of it's hardware cursor capablities by +filling out an xf86CursorInfoRec structure and passing it to xf86InitCursor(). +The xf86CursorInfoRec contains the following function pointers: + + +/**** These functions are required ****/ + +void ShowCursor(ScrnInfoPtr pScrn) + + ShowCursor should display the current cursor. + +void HideCursor(ScrnInfoPtr pScrn) + + HideCursor should hide the current cursor. + +void SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) + + Set the cursor position to (x,y). X and/or y may be negative + indicating that the cursor image is partially offscreen on + the left and/or top edges of the screen. It is up to the + driver to trap for this and deal with that situation. + +void SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) + + Set the cursor foreground and background colors. In 8bpp, fg and + bg are indicies into the current colormap unless the + HARDWARE_CURSOR_TRUECOLOR_AT_8BPP flag is set. In that case + and in all other bpps the fg and bg are in 8-8-8 RGB format. + +void LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits) + + LoadCursorImage is how the hardware cursor bits computed by the + RealizeCursor function will be passed to the driver when the cursor + shape needs to be changed. + + +/**** These functions are optional ****/ + + +unsigned char* RealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) + + If RealizeCursor is not provided by the driver, one will be provided + for you based on the Flags field described below. The driver must + provide this function if the hardware cursor format is not one of + the common ones supported by this module. + + +Bool UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) + + If the driver is unable to use a hardware cursor for reasons + other than the cursor being larger than the maximum specified + in the MaxWidth or MaxHeight field below, it can supply the + UseHWCursor function. If UseHWCursor is provided by the driver, + it will be called whenever the cursor shape changes or the video + mode changes. This is useful for when the hardware cursor cannot + be used in interlaced or doublescan modes. + + +/**** The following fields are required ****/ + +MaxWidth +MaxHeight + + These indicate the largest sized cursor that can be a hardware + cursor. It will fall back to a software cursor when a cursor + exceeding this size needs to be used. + + +Flags + + /* Color related flags */ + + HARDWARE_CURSOR_TRUECOLOR_AT_8BPP + + This indicates that the colors passed to the SetCursorColors + function should not be in 8-8-8 RGB format in 8bpp but rather, + they should be the pixel values from the current colormap. + + + /* Cursor data loading flags */ + + HARDWARE_CURSOR_SHOW_TRANSPARENT + + The HideCursor entry will normally be called instead of displaying a + completely transparent cursor, or when a switch to a software cursor + needs to occur. This flag prevents this behaviour, thus causing the + LoadCursorImage entry to be called with transparent cursor data. + NOTE: If you use this flag and provide your own RealizeCursor() entry, + ensure this entry returns transparent cursor data when called + with a NULL pCurs parameter. + + HARDWARE_CURSOR_UPDATE_UNHIDDEN + + This flag prevents the HideCursor call that would normally occur just before + the LoadCursorImage entry is to be called to load a new hardware cursor + image. + + + /* Cursor data packing flags */ + + Hardware cursor data consists of two pieces, a source and a mask. + The mask is a bitmap indicating which parts of the cursor are + transparent and which parts are drawn. The source is a bitmap + indicating which parts of the non-transparent portion of the the + cursor should be painted in the foreground color and which should + be painted in the background color. + + HARDWARE_CURSOR_INVERT_MASK + + By default, set bits indicate the opaque part of the mask bitmap + and clear bits indicate the transparent part. If your hardware + wants this the opposite way, this flag will invert the mask. + + HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK + + By default, RealizeCursor will store the source first and then + the mask. If the hardware needs this order reversed then this + flag should be set. + + HARDWARE_CURSOR_AND_SOURCE_WITH_MASK + + This flag will have the module logical AND the source with the mask to make + sure there are no source bits set if the corresponding mask bits + aren't set. Some hardware will not care if source bits are set where + there are supposed to be transparent areas, but some hardware will + interpret this as a third cursor color or similar. That type of + hardware will need this flag set. + + HARDWARE_CURSOR_BIT_ORDER_MSBFIRST + + By default, it is assumed that the least significant bit in each byte + corresponds to the leftmost pixel on the screen. If your hardware + has this reversed you should set this flag. + + HARDWARE_CURSOR_NIBBLE_SWAPPED + + If your hardware requires byte swapping of the hardware cursor, enable + this option. + + + /* Source-Mask interleaving flags */ + + By default the source and mask data are inlined (source first unless + the HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK flag is set). Some hardware + will require the source and mask to be interleaved, that is, X number + of source bits should packed and then X number of mask bits repeating + until the entire pattern is stored. The following flags describe the + bit interleave. + + HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED + + This one is the default. + + The following are for interleaved cursors. + + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 + + And once again, if your hardware requires something different than + these packing styles, your driver can supply its own RealizeCursor + function. + + + +$XFree86: xc/programs/Xserver/hw/xfree86/ramdac/CURSOR.NOTES,v 1.4tsi Exp $ diff --git a/xorg-server/hw/xfree86/ramdac/IBM.c b/xorg-server/hw/xfree86/ramdac/IBM.c new file mode 100644 index 000000000..2d9fe4d8f --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/IBM.c @@ -0,0 +1,639 @@ +/* + * Copyright 1998 by Alan Hourihane, Wigan, England. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> + * + * IBM RAMDAC routines. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "xf86Cursor.h" + +#define INIT_IBM_RAMDAC_INFO +#include "IBMPriv.h" +#include "xf86RamDacPriv.h" + +#define INITIALFREQERR 100000 + +unsigned long +IBMramdac640CalculateMNPCForClock( + unsigned long RefClock, /* In 100Hz units */ + unsigned long ReqClock, /* In 100Hz units */ + char IsPixClock, /* boolean, is this the pixel or the sys clock */ + unsigned long MinClock, /* Min VCO rating */ + unsigned long MaxClock, /* Max VCO rating */ + unsigned long *rM, /* M Out */ + unsigned long *rN, /* N Out */ + unsigned long *rP, /* Min P In, P Out */ + unsigned long *rC /* C Out */ +) +{ + unsigned long M, N, P, iP = *rP; + unsigned long IntRef, VCO, Clock; + long freqErr, lowestFreqErr = INITIALFREQERR; + unsigned long ActualClock = 0; + + for (N = 0; N <= 63; N++) + { + IntRef = RefClock / (N + 1); + if (IntRef < 10000) + break; /* IntRef needs to be >= 1MHz */ + for (M = 2; M <= 127; M++) + { + VCO = IntRef * (M + 1); + if ((VCO < MinClock) || (VCO > MaxClock)) + continue; + for (P = iP; P <= 4; P++) + { + if (P != 0) + Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P); + else + Clock = (RefClock * (M + 1)) / (N + 1); + + freqErr = (Clock - ReqClock); + + if (freqErr < 0) + { + /* PixelClock gets rounded up always so monitor reports + correct frequency. */ + if (IsPixClock) + continue; + freqErr = -freqErr; + } + + if (freqErr < lowestFreqErr) + { + *rM = M; + *rN = N; + *rP = P; + *rC = (VCO <= 1280000 ? 1 : 2); + ActualClock = Clock; + + lowestFreqErr = freqErr; + /* Return if we found an exact match */ + if (freqErr == 0) + return (ActualClock); + } + } + } + } + + return (ActualClock); +} + +unsigned long +IBMramdac526CalculateMNPCForClock( + unsigned long RefClock, /* In 100Hz units */ + unsigned long ReqClock, /* In 100Hz units */ + char IsPixClock, /* boolean, is this the pixel or the sys clock */ + unsigned long MinClock, /* Min VCO rating */ + unsigned long MaxClock, /* Max VCO rating */ + unsigned long *rM, /* M Out */ + unsigned long *rN, /* N Out */ + unsigned long *rP, /* Min P In, P Out */ + unsigned long *rC /* C Out */ +) +{ + unsigned long M, N, P, iP = *rP; + unsigned long IntRef, VCO, Clock; + long freqErr, lowestFreqErr = INITIALFREQERR; + unsigned long ActualClock = 0; + + for (N = 0; N <= 63; N++) + { + IntRef = RefClock / (N + 1); + if (IntRef < 10000) + break; /* IntRef needs to be >= 1MHz */ + for (M = 0; M <= 63; M++) + { + VCO = IntRef * (M + 1); + if ((VCO < MinClock) || (VCO > MaxClock)) + continue; + for (P = iP; P <= 4; P++) + { + if (P) + Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P); + else + Clock = VCO; + + freqErr = (Clock - ReqClock); + + if (freqErr < 0) + { + /* PixelClock gets rounded up always so monitor reports + correct frequency. */ + if (IsPixClock) + continue; + freqErr = -freqErr; + } + + if (freqErr < lowestFreqErr) + { + *rM = M; + *rN = N; + *rP = P; + *rC = (VCO <= 1280000 ? 1 : 2); + ActualClock = Clock; + + lowestFreqErr = freqErr; + /* Return if we found an exact match */ + if (freqErr == 0) + return (ActualClock); + } + } + } + } + + return (ActualClock); +} + +void +IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg) +{ + int i, maxreg, dacreg; + + switch (ramdacPtr->RamDacType) { + case IBM640_RAMDAC: + maxreg = 0x300; + dacreg = 1024; + break; + default: + maxreg = 0x100; + dacreg = 768; + break; + } + + /* Here we pass a short, so that we can evaluate a mask too */ + /* So that the mask is the high byte and the data the low byte */ + for (i=0;i<maxreg;i++) + (*ramdacPtr->WriteDAC) + (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8, + ramdacReg->DacRegs[i]); + + (*ramdacPtr->WriteAddress)(pScrn, 0); + for (i=0;i<dacreg;i++) + (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]); +} + +void +IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg) +{ + int i, maxreg, dacreg; + + switch (ramdacPtr->RamDacType) { + case IBM640_RAMDAC: + maxreg = 0x300; + dacreg = 1024; + break; + default: + maxreg = 0x100; + dacreg = 768; + break; + } + + (*ramdacPtr->ReadAddress)(pScrn, 0); + for (i=0;i<dacreg;i++) + ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn); + + for (i=0;i<maxreg;i++) + ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i); +} + +RamDacHelperRecPtr +IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRecPtr ramdacPtr*/) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + RamDacHelperRecPtr ramdacHelperPtr = NULL; + Bool RamDacIsSupported = FALSE; + int IBMramdac_ID = -1; + int i; + unsigned char id, rev, id2, rev2; + + /* read ID and revision */ + rev = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev); + id = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id); + + /* check if ID and revision are read only */ + (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, IBMRGB_rev); + (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, IBMRGB_id); + rev2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev); + id2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id); + + switch (id) { + case 0x30: + if (rev == 0xc0) IBMramdac_ID = IBM624_RAMDAC; + if (rev == 0x80) IBMramdac_ID = IBM624DB_RAMDAC; + break; + case 0x12: + if (rev == 0x1c) IBMramdac_ID = IBM640_RAMDAC; + break; + case 0x01: + IBMramdac_ID = IBM525_RAMDAC; + break; + case 0x02: + if (rev == 0xf0) IBMramdac_ID = IBM524_RAMDAC; + if (rev == 0xe0) IBMramdac_ID = IBM524A_RAMDAC; + if (rev == 0xc0) IBMramdac_ID = IBM526_RAMDAC; + if (rev == 0x80) IBMramdac_ID = IBM526DB_RAMDAC; + break; + } + + if (id == 1 || id == 2) { + if (id == id2 && rev == rev2) { /* IBM RGB52x found */ + /* check for 128bit VRAM -> RGB528 */ + if (((*ramdacPtr->ReadDAC)(pScrn, IBMRGB_misc1) & 0x03) == 0x03) { + IBMramdac_ID = IBM528_RAMDAC; /* 128bit DAC found */ + if (rev == 0xe0) + IBMramdac_ID = IBM528A_RAMDAC; + } + } + } + + (*ramdacPtr->WriteDAC)(pScrn, rev, 0, IBMRGB_rev); + (*ramdacPtr->WriteDAC)(pScrn, id, 0, IBMRGB_id); + + if (IBMramdac_ID == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Cannot determine IBM RAMDAC type, aborting\n"); + return NULL; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached RAMDAC is %s\n", IBMramdacDeviceInfo[IBMramdac_ID&0xFFFF].DeviceName); + } + + for (i=0;ramdacs[i].token != -1;i++) { + if (ramdacs[i].token == IBMramdac_ID) + RamDacIsSupported = TRUE; + } + + if (!RamDacIsSupported) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "This IBM RAMDAC is NOT supported by this driver, aborting\n"); + return NULL; + } + + ramdacHelperPtr = RamDacHelperCreateInfoRec(); + switch (IBMramdac_ID) { + case IBM526_RAMDAC: + case IBM526DB_RAMDAC: + ramdacHelperPtr->SetBpp = IBMramdac526SetBpp; + ramdacHelperPtr->HWCursorInit = IBMramdac526HWCursorInit; + break; + case IBM640_RAMDAC: + ramdacHelperPtr->SetBpp = IBMramdac640SetBpp; + ramdacHelperPtr->HWCursorInit = IBMramdac640HWCursorInit; + break; + } + ramdacPtr->RamDacType = IBMramdac_ID; + ramdacHelperPtr->RamDacType = IBMramdac_ID; + ramdacHelperPtr->Save = IBMramdacSave; + ramdacHelperPtr->Restore = IBMramdacRestore; + + return ramdacHelperPtr; +} + +void +IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) +{ + ramdacReg->DacRegs[IBMRGB_key_control] = 0x00; /* Disable Chroma Key */ + + switch (pScrn->bitsPerPixel) { + case 32: + ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_32BPP; + ramdacReg->DacRegs[IBMRGB_32bpp] = B32_DCOL_DIRECT; + ramdacReg->DacRegs[IBMRGB_24bpp] = 0; + ramdacReg->DacRegs[IBMRGB_16bpp] = 0; + ramdacReg->DacRegs[IBMRGB_8bpp] = 0; + if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { + ramdacReg->DacRegs[IBMRGB_key_control] = 0x01; /* Enable Key */ + ramdacReg->DacRegs[IBMRGB_key] = 0xFF; + ramdacReg->DacRegs[IBMRGB_key_mask] = 0xFF; + } + break; + case 24: + ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_24BPP; + ramdacReg->DacRegs[IBMRGB_32bpp] = 0; + ramdacReg->DacRegs[IBMRGB_24bpp] = B24_DCOL_DIRECT; + ramdacReg->DacRegs[IBMRGB_16bpp] = 0; + ramdacReg->DacRegs[IBMRGB_8bpp] = 0; + break; + case 16: + if (pScrn->depth == 16) { + ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP; + ramdacReg->DacRegs[IBMRGB_32bpp] = 0; + ramdacReg->DacRegs[IBMRGB_24bpp] = 0; + ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR | + B16_CONTIGUOUS | B16_565; + ramdacReg->DacRegs[IBMRGB_8bpp] = 0; + } else { + ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP; + ramdacReg->DacRegs[IBMRGB_32bpp] = 0; + ramdacReg->DacRegs[IBMRGB_24bpp] = 0; + ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR | + B16_CONTIGUOUS | B16_555; + ramdacReg->DacRegs[IBMRGB_8bpp] = 0; + } + break; + case 8: + ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_8BPP; + ramdacReg->DacRegs[IBMRGB_32bpp] = 0; + ramdacReg->DacRegs[IBMRGB_24bpp] = 0; + ramdacReg->DacRegs[IBMRGB_16bpp] = 0; + ramdacReg->DacRegs[IBMRGB_8bpp] = B8_DCOL_INDIRECT; + break; + case 4: + ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_4BPP; + ramdacReg->DacRegs[IBMRGB_32bpp] = 0; + ramdacReg->DacRegs[IBMRGB_24bpp] = 0; + ramdacReg->DacRegs[IBMRGB_16bpp] = 0; + ramdacReg->DacRegs[IBMRGB_8bpp] = 0; + } +} + +IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void) { + return IBMramdac526SetBpp; +} + +void +IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) +{ + unsigned char bpp = 0x00; + unsigned char overlaybpp = 0x00; + unsigned char offset = 0x00; + unsigned char dispcont = 0x44; + + ramdacReg->DacRegs[RGB640_SER_WID_03_00] = 0x00; + ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x00; + ramdacReg->DacRegs[RGB640_DIAGS] = 0x07; + + switch (pScrn->depth) { + case 8: + ramdacReg->DacRegs[RGB640_SER_07_00] = 0x00; + ramdacReg->DacRegs[RGB640_SER_15_08] = 0x00; + ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00; + ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00; + ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_16_1; /*16:1 Mux*/ + ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ + bpp = 0x03; + break; + case 15: + ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10; + ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11; + ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00; + ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00; + ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/ + ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ + bpp = 0x0E; + break; + case 16: + ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10; + ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11; + ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00; + ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00; + ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/ + ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ + bpp = 0x05; + break; + case 24: + ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30; + ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31; + ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32; + ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33; + ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/ + ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */ + bpp = 0x09; + if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { + ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x04; + ramdacReg->DacRegs[RGB640_CHROMA_KEY0] = 0xFF; + ramdacReg->DacRegs[RGB640_CHROMA_MASK0] = 0xFF; + offset = 0x04; + overlaybpp = 0x04; + dispcont = 0x48; + } + break; + case 30: /* 10 bit dac */ + ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30; + ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31; + ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32; + ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33; + ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/ + ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PSIZE10 | + IBM640_PCLK_8; /* pll / 8 */ + bpp = 0x0D; + break; + } + + { + int i; + for (i=0x100;i<0x140;i+=4) { + /* Initialize FrameBuffer Window Attribute Table */ + ramdacReg->DacRegs[i+0] = bpp; + ramdacReg->DacRegs[i+1] = offset; + ramdacReg->DacRegs[i+2] = 0x00; + ramdacReg->DacRegs[i+3] = 0x00; + /* Initialize Overlay Window Attribute Table */ + ramdacReg->DacRegs[i+0x100] = overlaybpp; + ramdacReg->DacRegs[i+0x101] = 0x00; + ramdacReg->DacRegs[i+0x102] = 0x00; + ramdacReg->DacRegs[i+0x103] = dispcont; + } + } +} + +static void +IBMramdac526ShowCursor(ScrnInfoPtr pScrn) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + /* Enable cursor - X11 mode */ + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x07); +} + +static void +IBMramdac640ShowCursor(ScrnInfoPtr pScrn) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + /* Enable cursor - mode2 (x11 mode) */ + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x0B); + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CROSSHAIR_CONTROL, 0x00, 0x00); +} + +static void +IBMramdac526HideCursor(ScrnInfoPtr pScrn) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + /* Disable cursor - X11 mode */ + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x24); +} + +static void +IBMramdac640HideCursor(ScrnInfoPtr pScrn) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + /* Disable cursor - mode2 (x11 mode) */ + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x08); +} + +static void +IBMramdac526SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + x += 64; + y += 64; + + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_x, 0x00, 0x3f); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_y, 0x00, 0x3f); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xl, 0x00, x & 0xff); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xh, 0x00, (x>>8) & 0xf); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yl, 0x00, y & 0xff); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yh, 0x00, (y>>8) & 0xf); +} + +static void +IBMramdac640SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + x += 64; + y += 64; + + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETX, 0x00, 0x3f); + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETY, 0x00, 0x3f); + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_LOW, 0x00, x & 0xff); + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_HIGH, 0x00, (x>>8) & 0xf); + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_LOW, 0x00, y & 0xff); + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_HIGH, 0x00, (y>>8) & 0xf); +} + +static void +IBMramdac526SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_r, 0x00, bg >> 16); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_g, 0x00, bg >> 8); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_b, 0x00, bg); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_r, 0x00, fg >> 16); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_g, 0x00, fg >> 8); + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_b, 0x00, fg); +} + +static void +IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_COL0, 0x00, 0); + (*ramdacPtr->WriteData)(pScrn, fg>>16); + (*ramdacPtr->WriteData)(pScrn, fg>>8); + (*ramdacPtr->WriteData)(pScrn, fg); + (*ramdacPtr->WriteData)(pScrn, bg>>16); + (*ramdacPtr->WriteData)(pScrn, bg>>8); + (*ramdacPtr->WriteData)(pScrn, bg); + (*ramdacPtr->WriteData)(pScrn, fg>>16); + (*ramdacPtr->WriteData)(pScrn, fg>>8); + (*ramdacPtr->WriteData)(pScrn, fg); + (*ramdacPtr->WriteData)(pScrn, bg>>16); + (*ramdacPtr->WriteData)(pScrn, bg>>8); + (*ramdacPtr->WriteData)(pScrn, bg); +} + +static void +IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + int i; + /* + * Output the cursor data. The realize function has put the planes into + * their correct order, so we can just blast this out. + */ + for (i = 0; i < 1024; i++) + (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_array + i, 0x00, (*src++)); +} + +static void +IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + int i; + /* + * Output the cursor data. The realize function has put the planes into + * their correct order, so we can just blast this out. + */ + for (i = 0; i < 1024; i++) + (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++)); +} + +static Bool +IBMramdac526UseHWCursor(ScreenPtr pScr, CursorPtr pCurs) +{ + return TRUE; +} + +static Bool +IBMramdac640UseHWCursor(ScreenPtr pScr, CursorPtr pCurs) +{ + return TRUE; +} + +void +IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr) +{ + infoPtr->MaxWidth = 64; + infoPtr->MaxHeight = 64; + infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | + HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; + infoPtr->SetCursorColors = IBMramdac526SetCursorColors; + infoPtr->SetCursorPosition = IBMramdac526SetCursorPosition; + infoPtr->LoadCursorImage = IBMramdac526LoadCursorImage; + infoPtr->HideCursor = IBMramdac526HideCursor; + infoPtr->ShowCursor = IBMramdac526ShowCursor; + infoPtr->UseHWCursor = IBMramdac526UseHWCursor; +} + +void +IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr) +{ + infoPtr->MaxWidth = 64; + infoPtr->MaxHeight = 64; + infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | + HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; + infoPtr->SetCursorColors = IBMramdac640SetCursorColors; + infoPtr->SetCursorPosition = IBMramdac640SetCursorPosition; + infoPtr->LoadCursorImage = IBMramdac640LoadCursorImage; + infoPtr->HideCursor = IBMramdac640HideCursor; + infoPtr->ShowCursor = IBMramdac640ShowCursor; + infoPtr->UseHWCursor = IBMramdac640UseHWCursor; +} diff --git a/xorg-server/hw/xfree86/ramdac/IBM.h b/xorg-server/hw/xfree86/ramdac/IBM.h new file mode 100644 index 000000000..fdb0f5ad1 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/IBM.h @@ -0,0 +1,385 @@ + +#include <xf86RamDac.h> + +RamDacHelperRecPtr IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs); +void IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec); +void IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec); +void IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec); +void IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec); +unsigned long IBMramdac526CalculateMNPCForClock(unsigned long RefClock, + unsigned long ReqClock, char IsPixClock, unsigned long MinClock, + unsigned long MaxClock, unsigned long *rM, unsigned long *rN, + unsigned long *rP, unsigned long *rC); +unsigned long IBMramdac640CalculateMNPCForClock(unsigned long RefClock, + unsigned long ReqClock, char IsPixClock, unsigned long MinClock, + unsigned long MaxClock, unsigned long *rM, unsigned long *rN, + unsigned long *rP, unsigned long *rC); +void IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr); +void IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr); + +typedef void IBMramdac526SetBppProc(ScrnInfoPtr, RamDacRegRecPtr); +IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void); + +#define IBM524_RAMDAC ((VENDOR_IBM << 16) | 0x00) +#define IBM524A_RAMDAC ((VENDOR_IBM << 16) | 0x01) +#define IBM525_RAMDAC ((VENDOR_IBM << 16) | 0x02) +#define IBM526_RAMDAC ((VENDOR_IBM << 16) | 0x03) +#define IBM526DB_RAMDAC ((VENDOR_IBM << 16) | 0x04) +#define IBM528_RAMDAC ((VENDOR_IBM << 16) | 0x05) +#define IBM528A_RAMDAC ((VENDOR_IBM << 16) | 0x06) +#define IBM624_RAMDAC ((VENDOR_IBM << 16) | 0x07) +#define IBM624DB_RAMDAC ((VENDOR_IBM << 16) | 0x08) +#define IBM640_RAMDAC ((VENDOR_IBM << 16) | 0x09) + +/* + * IBM Ramdac registers + */ + +#define IBMRGB_REF_FREQ_1 14.31818 +#define IBMRGB_REF_FREQ_2 50.00000 + +#define IBMRGB_rev 0x00 +#define IBMRGB_id 0x01 +#define IBMRGB_misc_clock 0x02 +#define IBMRGB_sync 0x03 +#define IBMRGB_hsync_pos 0x04 +#define IBMRGB_pwr_mgmt 0x05 +#define IBMRGB_dac_op 0x06 +#define IBMRGB_pal_ctrl 0x07 +#define IBMRGB_sysclk 0x08 /* not RGB525 */ +#define IBMRGB_pix_fmt 0x0a +#define IBMRGB_8bpp 0x0b +#define IBMRGB_16bpp 0x0c +#define IBMRGB_24bpp 0x0d +#define IBMRGB_32bpp 0x0e +#define IBMRGB_pll_ctrl1 0x10 +#define IBMRGB_pll_ctrl2 0x11 +#define IBMRGB_pll_ref_div_fix 0x14 +#define IBMRGB_sysclk_ref_div 0x15 /* not RGB525 */ +#define IBMRGB_sysclk_vco_div 0x16 /* not RGB525 */ +/* #define IBMRGB_f0 0x20 */ + +#define IBMRGB_sysclk_n 0x15 +#define IBMRGB_sysclk_m 0x16 +#define IBMRGB_sysclk_p 0x17 +#define IBMRGB_sysclk_c 0x18 + +#define IBMRGB_m0 0x20 +#define IBMRGB_n0 0x21 +#define IBMRGB_p0 0x22 +#define IBMRGB_c0 0x23 +#define IBMRGB_m1 0x24 +#define IBMRGB_n1 0x25 +#define IBMRGB_p1 0x26 +#define IBMRGB_c1 0x27 +#define IBMRGB_m2 0x28 +#define IBMRGB_n2 0x29 +#define IBMRGB_p2 0x2a +#define IBMRGB_c2 0x2b +#define IBMRGB_m3 0x2c +#define IBMRGB_n3 0x2d +#define IBMRGB_p3 0x2e +#define IBMRGB_c3 0x2f + +#define IBMRGB_curs 0x30 +#define IBMRGB_curs_xl 0x31 +#define IBMRGB_curs_xh 0x32 +#define IBMRGB_curs_yl 0x33 +#define IBMRGB_curs_yh 0x34 +#define IBMRGB_curs_hot_x 0x35 +#define IBMRGB_curs_hot_y 0x36 +#define IBMRGB_curs_col1_r 0x40 +#define IBMRGB_curs_col1_g 0x41 +#define IBMRGB_curs_col1_b 0x42 +#define IBMRGB_curs_col2_r 0x43 +#define IBMRGB_curs_col2_g 0x44 +#define IBMRGB_curs_col2_b 0x45 +#define IBMRGB_curs_col3_r 0x46 +#define IBMRGB_curs_col3_g 0x47 +#define IBMRGB_curs_col3_b 0x48 +#define IBMRGB_border_col_r 0x60 +#define IBMRGB_border_col_g 0x61 +#define IBMRGB_botder_col_b 0x62 +#define IBMRGB_key 0x68 +#define IBMRGB_key_mask 0x6C +#define IBMRGB_misc1 0x70 +#define IBMRGB_misc2 0x71 +#define IBMRGB_misc3 0x72 +#define IBMRGB_misc4 0x73 /* not RGB525 */ +#define IBMRGB_key_control 0x78 +#define IBMRGB_dac_sense 0x82 +#define IBMRGB_misr_r 0x84 +#define IBMRGB_misr_g 0x86 +#define IBMRGB_misr_b 0x88 +#define IBMRGB_pll_vco_div_in 0x8e +#define IBMRGB_pll_ref_div_in 0x8f +#define IBMRGB_vram_mask_0 0x90 +#define IBMRGB_vram_mask_1 0x91 +#define IBMRGB_vram_mask_2 0x92 +#define IBMRGB_vram_mask_3 0x93 +#define IBMRGB_curs_array 0x100 + + + +/* Constants rgb525.h */ + +/* RGB525_REVISION_LEVEL */ +#define RGB525_PRODUCT_REV_LEVEL 0xf0 + +/* RGB525_ID */ +#define RGB525_PRODUCT_ID 0x01 + +/* RGB525_MISC_CTRL_1 */ +#define MISR_CNTL_ENABLE 0x80 +#define VMSK_CNTL_ENABLE 0x40 +#define PADR_RDMT_RDADDR 0x0 +#define PADR_RDMT_PAL_STATE 0x20 +#define SENS_DSAB_DISABLE 0x10 +#define SENS_SEL_BIT3 0x0 +#define SENS_SEL_BIT7 0x08 +#define VRAM_SIZE_32 0x0 +#define VRAM_SIZE_64 0x01 + +/* RGB525_MISC_CTRL_2 */ +#define PCLK_SEL_LCLK 0x0 +#define PCLK_SEL_PLL 0x40 +#define PCLK_SEL_EXT 0x80 +#define INTL_MODE_ENABLE 0x20 +#define BLANK_CNTL_ENABLE 0x10 +#define COL_RES_6BIT 0x0 +#define COL_RES_8BIT 0x04 +#define PORT_SEL_VGA 0x0 +#define PORT_SEL_VRAM 0x01 + +/* RGB525_MISC_CTRL_3 */ +#define SWAP_RB 0x80 +#define SWAP_WORD_LOHI 0x0 +#define SWAP_WORD_HILO 0x10 +#define SWAP_NIB_HILO 0x0 +#define SWAP_NIB_LOHI 0x02 + +/* RGB525_MISC_CLK_CTRL */ +#define DDOT_CLK_ENABLE 0x0 +#define DDOT_CLK_DISABLE 0x80 +#define SCLK_ENABLE 0x0 +#define SCLK_DISABLE 0x40 +#define B24P_DDOT_PLL 0x0 +#define B24P_DDOT_SCLK 0x20 +#define DDOT_DIV_PLL_1 0x0 +#define DDOT_DIV_PLL_2 0x02 +#define DDOT_DIV_PLL_4 0x04 +#define DDOT_DIV_PLL_8 0x06 +#define DDOT_DIV_PLL_16 0x08 +#define PLL_DISABLE 0x0 +#define PLL_ENABLE 0x01 + +/* RGB525_SYNC_CTRL */ +#define DLY_CNTL_ADD 0x0 +#define DLY_SYNC_NOADD 0x80 +#define CSYN_INVT_DISABLE 0x0 +#define CSYN_INVT_ENABLE 0x40 +#define VSYN_INVT_DISABLE 0x0 +#define VSYN_INVT_ENABLE 0x20 +#define HSYN_INVT_DISABLE 0x0 +#define HSYN_INVT_ENABLE 0x10 +#define VSYN_CNTL_NORMAL 0x0 +#define VSYN_CNTL_HIGH 0x04 +#define VSYN_CNTL_LOW 0x08 +#define VSYN_CNTL_DISABLE 0x0C +#define HSYN_CNTL_NORMAL 0x0 +#define HSYN_CNTL_HIGH 0x01 +#define HSYN_CNTL_LOW 0x02 +#define HSYN_CNTL_DISABLE 0x03 + +/* RGB525_HSYNC_CTRL */ +#define HSYN_POS(n) (n) + +/* RGB525_POWER_MANAGEMENT */ +#define SCLK_PWR_NORMAL 0x0 +#define SCLK_PWR_DISABLE 0x10 +#define DDOT_PWR_NORMAL 0x0 +#define DDOT_PWR_DISABLE 0x08 +#define SYNC_PWR_NORMAL 0x0 +#define SYNC_PWR_DISABLE 0x04 +#define ICLK_PWR_NORMAL 0x0 +#define ICLK_PWR_DISABLE 0x02 +#define DAC_PWR_NORMAL 0x0 +#define DAC_PWR_DISABLE 0x01 + +/* RGB525_DAC_OPERATION */ +#define SOG_DISABLE 0x0 +#define SOG_ENABLE 0x08 +#define BRB_NORMAL 0x0 +#define BRB_ALWAYS 0x04 +#define DSR_DAC_SLOW 0x02 +#define DSR_DAC_FAST 0x0 +#define DPE_DISABLE 0x0 +#define DPE_ENABLE 0x01 + +/* RGB525_PALETTE_CTRL */ +#define SIXBIT_LINEAR_ENABLE 0x0 +#define SIXBIT_LINEAR_DISABLE 0x80 +#define PALETTE_PARITION(n) (n) + +/* RGB525_PIXEL_FORMAT */ +#define PIXEL_FORMAT_4BPP 0x02 +#define PIXEL_FORMAT_8BPP 0x03 +#define PIXEL_FORMAT_16BPP 0x04 +#define PIXEL_FORMAT_24BPP 0x05 +#define PIXEL_FORMAT_32BPP 0x06 + +/* RGB525_8BPP_CTRL */ +#define B8_DCOL_INDIRECT 0x0 +#define B8_DCOL_DIRECT 0x01 + +/* RGB525_16BPP_CTRL */ +#define B16_DCOL_INDIRECT 0x0 +#define B16_DCOL_DYNAMIC 0x40 +#define B16_DCOL_DIRECT 0xC0 +#define B16_POL_FORCE_BYPASS 0x0 +#define B16_POL_FORCE_LOOKUP 0x20 +#define B16_ZIB 0x0 +#define B16_LINEAR 0x04 +#define B16_555 0x0 +#define B16_565 0x02 +#define B16_SPARSE 0x0 +#define B16_CONTIGUOUS 0x01 + +/* RGB525_24BPP_CTRL */ +#define B24_DCOL_INDIRECT 0x0 +#define B24_DCOL_DIRECT 0x01 + +/* RGB525_32BPP_CTRL */ +#define B32_POL_FORCE_BYPASS 0x0 +#define B32_POL_FORCE_LOOKUP 0x04 +#define B32_DCOL_INDIRECT 0x0 +#define B32_DCOL_DYNAMIC 0x01 +#define B32_DCOL_DIRECT 0x03 + +/* RGB525_PLL_CTRL_1 */ +#define REF_SRC_REFCLK 0x0 +#define REF_SRC_EXTCLK 0x10 +#define PLL_EXT_FS_3_0 0x0 +#define PLL_EXT_FS_2_0 0x01 +#define PLL_CNTL2_3_0 0x02 +#define PLL_CNTL2_2_0 0x03 + +/* RGB525_PLL_CTRL_2 */ +#define PLL_INT_FS_3_0(n) (n) +#define PLL_INT_FS_2_0(n) (n) + +/* RGB525_PLL_REF_DIV_COUNT */ +#define REF_DIV_COUNT(n) (n) + +/* RGB525_F0 - RGB525_F15 */ +#define VCO_DIV_COUNT(n) (n) + +/* RGB525_PLL_REFCLK values */ +#define RGB525_PLL_REFCLK_MHz(n) ((n)/2) + +/* RGB525_CURSOR_CONTROL */ +#define SMLC_PART_0 0x0 +#define SMLC_PART_1 0x40 +#define SMLC_PART_2 0x80 +#define SMLC_PART_3 0xC0 +#define PIX_ORDER_RL 0x0 +#define PIX_ORDER_LR 0x20 +#define LOC_READ_LAST 0x0 +#define LOC_READ_ACTUAL 0x10 +#define UPDT_CNTL_DELAYED 0x0 +#define UPDT_CNTL_IMMEDIATE 0x08 +#define CURSOR_SIZE_32 0x0 +#define CURSOR_SIZE_64 0x40 +#define CURSOR_MODE_OFF 0x0 +#define CURSOR_MODE_3_COLOR 0x01 +#define CURSOR_MODE_2_COLOR_HL 0x02 +#define CURSOR_MODE_2_COLOR 0x03 + +/* RGB525_REVISION_LEVEL */ +#define REVISION_LEVEL 0xF0 /* predefined */ + +/* RGB525_ID */ +#define ID_CODE 0x01 /* predefined */ + +/* MISR status */ +#define RGB525_MISR_DONE 0x01 + +/* the IBMRGB640 is rather different from the rest of the RAMDACs, + so we define a completely new set of register names for it */ +#define RGB640_SER_07_00 0x02 +#define RGB640_SER_15_08 0x03 +#define RGB640_SER_23_16 0x04 +#define RGB640_SER_31_24 0x05 +#define RGB640_SER_WID_03_00 0x06 +#define RGB640_SER_WID_07_04 0x07 +#define RGB640_SER_MODE 0x08 +#define IBM640_SER_2_1 0x00 +#define IBM640_SER_4_1 0x01 +#define IBM640_SER_8_1 0x02 +#define IBM640_SER_16_1 0x03 +#define IBM640_SER_16_3 0x05 +#define IBM640_SER_5_1 0x06 +#define RGB640_PIXEL_INTERLEAVE 0x09 +#define RGB640_MISC_CONF 0x0a +#define IBM640_PCLK 0x00 +#define IBM640_PCLK_2 0x40 +#define IBM640_PCLK_4 0x80 +#define IBM640_PCLK_8 0xc0 +#define IBM640_PSIZE10 0x10 +#define IBM640_LCI 0x08 +#define IBM640_WIDCTL_MASK 0x07 +#define RGB640_VGA_CONTROL 0x0b +#define IBM640_RDBK 0x04 +#define IBM640_PSIZE8 0x02 +#define IBM640_VRAM 0x01 +#define RGB640_DAC_CONTROL 0x0d +#define IBM640_MONO 0x08 +#define IBM640_DACENBL 0x04 +#define IBM640_SHUNT 0x02 +#define IBM640_SLOWSLEW 0x01 +#define RGB640_OUTPUT_CONTROL 0x0e +#define IBM640_RDAI 0x04 +#define IBM640_WDAI 0x02 +#define IBM640_WATCTL 0x01 +#define RGB640_SYNC_CONTROL 0x0f +#define IBM640_PWR 0x20 +#define IBM640_VSP 0x10 +#define IBM640_HSP 0x08 +#define IBM640_CSE 0x04 +#define IBM640_CSG 0x02 +#define IBM640_BPE 0x01 +#define RGB640_PLL_N 0x10 +#define RGB640_PLL_M 0x11 +#define RGB640_PLL_P 0x12 +#define RGB640_PLL_CTL 0x13 +#define IBM640_PLL_EN 0x04 +#define IBM640_PLL_HIGH 0x10 +#define IBM640_PLL_LOW 0x01 +#define RGB640_AUX_PLL_CTL 0x17 +#define IBM640_AUXPLL 0x04 +#define IBM640_AUX_HI 0x02 +#define IBM640_AUX_LO 0x01 +#define RGB640_CHROMA_KEY0 0x20 +#define RGB640_CHROMA_MASK0 0x21 +#define RGB640_CURS_X_LOW 0x40 +#define RGB640_CURS_X_HIGH 0x41 +#define RGB640_CURS_Y_LOW 0x42 +#define RGB640_CURS_Y_HIGH 0x43 +#define RGB640_CURS_OFFSETX 0x44 +#define RGB640_CURS_OFFSETY 0x45 +#define RGB640_CURSOR_CONTROL 0x4B +#define IBM640_CURS_OFF 0x00 +#define IBM640_CURS_MODE0 0x01 +#define IBM640_CURS_MODE1 0x02 +#define IBM640_CURS_MODE2 0x03 +#define IBM640_CURS_ADV 0x04 +#define RGB640_CROSSHAIR_CONTROL 0x57 +#define RGB640_VRAM_MASK0 0xf0 +#define RGB640_VRAM_MASK1 0xf1 +#define RGB640_VRAM_MASK2 0xf2 +#define RGB640_DIAGS 0xfa +#define RGB640_CURS_WRITE 0x1000 +#define RGB640_CURS_COL0 0x4800 +#define RGB640_CURS_COL1 0x4801 +#define RGB640_CURS_COL2 0x4802 +#define RGB640_CURS_COL3 0x4803 diff --git a/xorg-server/hw/xfree86/ramdac/IBMPriv.h b/xorg-server/hw/xfree86/ramdac/IBMPriv.h new file mode 100644 index 000000000..a33da9106 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/IBMPriv.h @@ -0,0 +1,27 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "IBM.h" + +typedef struct { + char *DeviceName; +} xf86IBMramdacInfo; + +extern xf86IBMramdacInfo IBMramdacDeviceInfo[]; + +#ifdef INIT_IBM_RAMDAC_INFO +xf86IBMramdacInfo IBMramdacDeviceInfo[] = { + {"IBM 524"}, + {"IBM 524A"}, + {"IBM 525"}, + {"IBM 526"}, + {"IBM 526DB(DoubleBuffer)"}, + {"IBM 528"}, + {"IBM 528A"}, + {"IBM 624"}, + {"IBM 624DB(DoubleBuffer)"}, + {"IBM 640"} +}; +#endif diff --git a/xorg-server/hw/xfree86/ramdac/Makefile.am b/xorg-server/hw/xfree86/ramdac/Makefile.am new file mode 100644 index 000000000..2b84cb4dd --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/Makefile.am @@ -0,0 +1,19 @@ +noinst_LIBRARIES = libramdac.a + +libramdac_a_SOURCES = xf86RamDac.c xf86RamDacCmap.c \ + xf86Cursor.c xf86HWCurs.c IBM.c BT.c TI.c \ + xf86BitOrder.c + +sdk_HEADERS = BT.h IBM.h TI.h xf86Cursor.h xf86RamDac.h + +DISTCLEANFILES = xf86BitOrder.c +EXTRA_DIST = BTPriv.h IBMPriv.h TIPriv.h xf86CursorPriv.h xf86RamDacPriv.h \ + CURSOR.NOTES + +AM_CFLAGS = -DXAAReverseBitOrder=xf86ReverseBitOrder -DRAMDAC_MODULE \ + $(DIX_CFLAGS) $(XORG_CFLAGS) +INCLUDES = $(XORG_INCS) + +xf86BitOrder.c: + echo "#define XAAReverseBitOrder xf86ReverseBitOrder" > $@ + echo "#include \"$(srcdir)/../xaa/xaaBitOrder.c\"" >> $@ diff --git a/xorg-server/hw/xfree86/ramdac/Makefile.in b/xorg-server/hw/xfree86/ramdac/Makefile.in new file mode 100644 index 000000000..dc47ab102 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/Makefile.in @@ -0,0 +1,697 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/ramdac +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libramdac_a_AR = $(AR) $(ARFLAGS) +libramdac_a_LIBADD = +am_libramdac_a_OBJECTS = xf86RamDac.$(OBJEXT) xf86RamDacCmap.$(OBJEXT) \ + xf86Cursor.$(OBJEXT) xf86HWCurs.$(OBJEXT) IBM.$(OBJEXT) \ + BT.$(OBJEXT) TI.$(OBJEXT) xf86BitOrder.$(OBJEXT) +libramdac_a_OBJECTS = $(am_libramdac_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libramdac_a_SOURCES) +DIST_SOURCES = $(libramdac_a_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(sdkdir)" +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = libramdac.a +libramdac_a_SOURCES = xf86RamDac.c xf86RamDacCmap.c \ + xf86Cursor.c xf86HWCurs.c IBM.c BT.c TI.c \ + xf86BitOrder.c + +sdk_HEADERS = BT.h IBM.h TI.h xf86Cursor.h xf86RamDac.h +DISTCLEANFILES = xf86BitOrder.c +EXTRA_DIST = BTPriv.h IBMPriv.h TIPriv.h xf86CursorPriv.h xf86RamDacPriv.h \ + CURSOR.NOTES + +AM_CFLAGS = -DXAAReverseBitOrder=xf86ReverseBitOrder -DRAMDAC_MODULE \ + $(DIX_CFLAGS) $(XORG_CFLAGS) + +INCLUDES = $(XORG_INCS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/ramdac/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/ramdac/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libramdac.a: $(libramdac_a_OBJECTS) $(libramdac_a_DEPENDENCIES) + -rm -f libramdac.a + $(libramdac_a_AR) libramdac.a $(libramdac_a_OBJECTS) $(libramdac_a_LIBADD) + $(RANLIB) libramdac.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BT.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IBM.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TI.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86BitOrder.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Cursor.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86HWCurs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86RamDac.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86RamDacCmap.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sdkHEADERS install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-sdkHEADERS + + +xf86BitOrder.c: + echo "#define XAAReverseBitOrder xf86ReverseBitOrder" > $@ + echo "#include \"$(srcdir)/../xaa/xaaBitOrder.c\"" >> $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/ramdac/TI.c b/xorg-server/hw/xfree86/ramdac/TI.c new file mode 100644 index 000000000..f421fc39a --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/TI.c @@ -0,0 +1,719 @@ +/* + * Copyright 1998 by Alan Hourihane, Wigan, England. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> + * + * Modified from IBM.c to support TI RAMDAC routines + * by Jens Owen, <jens@tungstengraphics.com>. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "xf86Cursor.h" + +#define INIT_TI_RAMDAC_INFO +#include "TIPriv.h" +#include "xf86RamDacPriv.h" + +/* The following values are in kHz */ +#define TI_MIN_VCO_FREQ 110000 +#define TI_MAX_VCO_FREQ 220000 + +unsigned long +TIramdacCalculateMNPForClock( + unsigned long RefClock, /* In 100Hz units */ + unsigned long ReqClock, /* In 100Hz units */ + char IsPixClock, /* boolean, is this the pixel or the sys clock */ + unsigned long MinClock, /* Min VCO rating */ + unsigned long MaxClock, /* Max VCO rating */ + unsigned long *rM, /* M Out */ + unsigned long *rN, /* N Out */ + unsigned long *rP /* Min P In, P Out */ +) +{ + unsigned long n, p; + unsigned long best_m = 0, best_n = 0; + double VCO, IntRef = (double)RefClock; + double m_err, inc_m, calc_m; + unsigned long ActualClock; + + /* Make sure that MinClock <= ReqClock <= MaxClock */ + if ( ReqClock < MinClock) + ReqClock = MinClock; + if ( ReqClock > MaxClock ) + ReqClock = MaxClock; + + /* + * ActualClock = VCO / 2 ^ p + * Choose p so that TI_MIN_VCO_FREQ <= VCO <= TI_MAX_VCO_FREQ + * Note that since TI_MAX_VCO_FREQ = 2 * TI_MIN_VCO_FREQ + * we don't have to bother checking for this maximum limit. + */ + VCO = (double)ReqClock; + for ( p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ ) + VCO *= 2.0; + + /* + * We avoid doing multiplications by ( 65 - n ), + * and add an increment instead - this keeps any error small. + */ + inc_m = VCO / ( IntRef * 8.0 ); + + /* Initial value of calc_m for the loop */ + calc_m = inc_m + inc_m + inc_m; + + /* Initial amount of error for an integer - impossibly large */ + m_err = 2.0; + + /* Search for the closest INTEGER value of ( 65 - m ) */ + for ( n = 3; n <= 25; ( n )++, calc_m += inc_m ) { + + /* Ignore values of ( 65 - m ) which we can't use */ + if ( calc_m < 3.0 || calc_m > 64.0 ) + continue; + + /* + * Pick the closest INTEGER (has smallest fractional part). + * The optimizer should clean this up for us. + */ + if (( calc_m - ( int ) calc_m ) < m_err ) { + m_err = calc_m - ( int ) calc_m; + best_m = ( int ) calc_m; + best_n = n; + } + } + + /* 65 - ( 65 - x ) = x */ + *rM = 65 - best_m; + *rN = 65 - best_n; + *rP = p; + + /* Now all the calculations can be completed */ + VCO = 8.0 * IntRef * best_m / best_n; + ActualClock = VCO / ( 1 << p ); + +#ifdef DEBUG + ErrorF( "f_out=%ld f_vco=%.1f n=%d m=%d p=%d\n", + ActualClock, VCO, *rN, *rM, *rP); +#endif + + return (ActualClock); +} + +void +TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg) +{ + int i; + unsigned long status; + + /* Here we pass a short, so that we can evaluate a mask too + * So that the mask is the high byte and the data the low byte + * Order is important + */ + TIRESTORE(TIDAC_latch_ctrl); + TIRESTORE(TIDAC_true_color_ctrl); + TIRESTORE(TIDAC_multiplex_ctrl); + TIRESTORE(TIDAC_clock_select); + TIRESTORE(TIDAC_palette_page); + TIRESTORE(TIDAC_general_ctrl); + TIRESTORE(TIDAC_misc_ctrl); + /* 0x2A & 0x2B are reserved */ + TIRESTORE(TIDAC_key_over_low); + TIRESTORE(TIDAC_key_over_high); + TIRESTORE(TIDAC_key_red_low); + TIRESTORE(TIDAC_key_red_high); + TIRESTORE(TIDAC_key_green_low); + TIRESTORE(TIDAC_key_green_high); + TIRESTORE(TIDAC_key_blue_low); + TIRESTORE(TIDAC_key_blue_high); + TIRESTORE(TIDAC_key_ctrl); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x30); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x38); + TIRESTORE(TIDAC_clock_ctrl); + TIRESTORE(TIDAC_sense_test); + TIRESTORE(TIDAC_ind_curs_ctrl); + + /* only restore clocks if they were valid to begin with */ + + if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) { + /* Reset pixel clock */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, 0x3c); + + /* Restore N, M & P values for pixel clocks */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, + ramdacReg->DacRegs[TIDAC_PIXEL_N]); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, + ramdacReg->DacRegs[TIDAC_PIXEL_M]); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, + ramdacReg->DacRegs[TIDAC_PIXEL_P]); + + /* wait for pixel clock to lock */ + i = 1000000; + do { + status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); + } while ((!(status & 0x40)) && (--i)); + if (!(status & 0x40)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Pixel clock setup timed out\n"); + return; + } + } + + if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) { + /* Reset loop clock */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, 0x70); + + /* Restore N, M & P values for pixel clocks */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, + ramdacReg->DacRegs[TIDAC_LOOP_N]); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, + ramdacReg->DacRegs[TIDAC_LOOP_M]); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, + ramdacReg->DacRegs[TIDAC_LOOP_P]); + + /* wait for loop clock to lock */ + i = 1000000; + do { + status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); + } while ((!(status & 0x40)) && (--i)); + if (!(status & 0x40)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Loop clock setup timed out\n"); + return; + } + } + + /* restore palette */ + (*ramdacPtr->WriteAddress)(pScrn, 0); +#ifndef NOT_DONE + for (i=0;i<768;i++) + (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]); +#else + (*ramdacPtr->WriteData)(pScrn, 0); + (*ramdacPtr->WriteData)(pScrn, 0); + (*ramdacPtr->WriteData)(pScrn, 0); + for (i=0;i<765;i++) + (*ramdacPtr->WriteData)(pScrn, 0xff); +#endif +} + +void +TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg) +{ + int i; + + (*ramdacPtr->ReadAddress)(pScrn, 0); + for (i=0;i<768;i++) + ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn); + + /* Read back N,M and P values for pixel clock */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); + ramdacReg->DacRegs[TIDAC_PIXEL_N] = + (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11); + ramdacReg->DacRegs[TIDAC_PIXEL_M] = + (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); + ramdacReg->DacRegs[TIDAC_PIXEL_P] = + (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data); + + /* Read back N,M and P values for loop clock */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0); + ramdacReg->DacRegs[TIDAC_LOOP_N] = + (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11); + ramdacReg->DacRegs[TIDAC_LOOP_M] = + (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22); + ramdacReg->DacRegs[TIDAC_LOOP_P] = + (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data); + + /* Order is important */ + TISAVE(TIDAC_latch_ctrl); + TISAVE(TIDAC_true_color_ctrl); + TISAVE(TIDAC_multiplex_ctrl); + TISAVE(TIDAC_clock_select); + TISAVE(TIDAC_palette_page); + TISAVE(TIDAC_general_ctrl); + TISAVE(TIDAC_misc_ctrl); + /* 0x2A & 0x2B are reserved */ + TISAVE(TIDAC_key_over_low); + TISAVE(TIDAC_key_over_high); + TISAVE(TIDAC_key_red_low); + TISAVE(TIDAC_key_red_high); + TISAVE(TIDAC_key_green_low); + TISAVE(TIDAC_key_green_high); + TISAVE(TIDAC_key_blue_low); + TISAVE(TIDAC_key_blue_high); + TISAVE(TIDAC_key_ctrl); + TISAVE(TIDAC_clock_ctrl); + TISAVE(TIDAC_sense_test); + TISAVE(TIDAC_ind_curs_ctrl); +} + +RamDacHelperRecPtr +TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + RamDacHelperRecPtr ramdacHelperPtr = NULL; + Bool RamDacIsSupported = FALSE; + int TIramdac_ID = -1; + int i; + unsigned char id, rev, rev2, id2; + + /* read ID and revision */ + rev = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev); + id = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id); + + /* check if ID and revision are read only */ + (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, TIDAC_rev); + (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, TIDAC_id); + rev2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev); + id2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id); + + switch (id) { + case TIDAC_TVP_3030_ID: + if (id == id2 && rev == rev2) /* check for READ ONLY */ + TIramdac_ID = TI3030_RAMDAC; + break; + case TIDAC_TVP_3026_ID: + if (id == id2 && rev == rev2) /* check for READ ONLY */ + TIramdac_ID = TI3026_RAMDAC; + break; + } + + (*ramdacPtr->WriteDAC)(pScrn, rev, 0, TIDAC_rev); + (*ramdacPtr->WriteDAC)(pScrn, id, 0, TIDAC_id); + + if (TIramdac_ID == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Cannot determine TI RAMDAC type, aborting\n"); + return NULL; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Attached RAMDAC is %s\n", TIramdacDeviceInfo[TIramdac_ID&0xFFFF].DeviceName); + } + + for (i=0;ramdacs[i].token != -1;i++) { + if (ramdacs[i].token == TIramdac_ID) + RamDacIsSupported = TRUE; + } + + if (!RamDacIsSupported) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "This TI RAMDAC is NOT supported by this driver, aborting\n"); + return NULL; + } + + ramdacHelperPtr = RamDacHelperCreateInfoRec(); + switch (TIramdac_ID) { + case TI3030_RAMDAC: + ramdacHelperPtr->SetBpp = TIramdac3030SetBpp; + ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit; + break; + case TI3026_RAMDAC: + ramdacHelperPtr->SetBpp = TIramdac3026SetBpp; + ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit; + break; + } + ramdacPtr->RamDacType = TIramdac_ID; + ramdacHelperPtr->RamDacType = TIramdac_ID; + ramdacHelperPtr->Save = TIramdacSave; + ramdacHelperPtr->Restore = TIramdacRestore; + + return ramdacHelperPtr; +} + +void +TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) +{ + switch (pScrn->bitsPerPixel) { + case 32: + /* order is important */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46; + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01; + } + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + case 24: + /* order is important */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56; + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x25; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + case 16: + /* order is important */ +#if 0 + /* Matrox driver uses this */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07; +#else + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; +#endif + if (pScrn->depth == 16) { + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45; + } else { + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44; + } +#if 0 + /* Matrox driver uses this */ + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x15; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; +#else + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; +#endif + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + case 8: + /* order is important */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80; + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4c; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + } +} + +void +TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) +{ + switch (pScrn->bitsPerPixel) { + case 32: + /* order is important */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46; + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5D; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01; + } + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + case 24: + /* order is important */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56; + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x25; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + case 16: + /* order is important */ +#if 0 + /* Matrox driver uses this */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07; +#else + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; +#endif + if (pScrn->depth == 16) { + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45; + } else { + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44; + } +#if 0 + /* Matrox driver uses this */ + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x15; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00; +#else + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x85; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; +#endif + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + case 8: + /* order is important */ + ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06; + ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80; + ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4d; + ramdacReg->DacRegs[TIDAC_clock_select] = 0x05; + ramdacReg->DacRegs[TIDAC_palette_page] = 0x00; + ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10; + ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C; + /* 0x2A & 0x2B are reserved */ + ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF; + ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00; + ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00; + ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00; + ramdacReg->DacRegs[TIDAC_sense_test] = 0x00; + ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00; + break; + } +} + +static void +TIramdacShowCursor(ScrnInfoPtr pScrn) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + /* Enable cursor - X11 mode */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x03); +} + +static void +TIramdacHideCursor(ScrnInfoPtr pScrn) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + /* Disable cursor - X11 mode */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00); +} + +static void +TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + x += 64; + y += 64; + + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XLOW, 0, x & 0xff); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XHIGH, 0, (x >> 8) & 0x0f); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YLOW, 0, y & 0xff); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YHIGH, 0, (y >> 8) & 0x0f); +} + +static void +TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + + /* Background color */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 1); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x00ff0000) >> 16)); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x0000ff00) >> 8)); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (bg&0x000000ff) ); + + /* Foreground color */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 2); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x00ff0000) >> 16)); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x0000ff00) >> 8)); + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (fg&0x000000ff) ); +} + +static void +TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) +{ + RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); + int i = 1024; + + /* reset A9,A8 */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00); + /* reset cursor RAM load address A7..A0 */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_INDEX, 0x00, 0x00); + + while(i--) { + /* NOT_DONE: might need a delay here */ + (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++)); + } +} + +static Bool +TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs) +{ + return TRUE; +} + +void +TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr) +{ + infoPtr->MaxWidth = 64; + infoPtr->MaxHeight = 64; + infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | + HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | + HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED; + infoPtr->SetCursorColors = TIramdacSetCursorColors; + infoPtr->SetCursorPosition = TIramdacSetCursorPosition; + infoPtr->LoadCursorImage = TIramdacLoadCursorImage; + infoPtr->HideCursor = TIramdacHideCursor; + infoPtr->ShowCursor = TIramdacShowCursor; + infoPtr->UseHWCursor = TIramdacUseHWCursor; +} + +void TIramdacLoadPalette( + ScrnInfoPtr pScrn, + int numColors, + int *indices, + LOCO *colors, + VisualPtr pVisual +){ + RamDacRecPtr hwp = RAMDACSCRPTR(pScrn); + int i, index, shift; + + if (pScrn->depth == 16) { + for(i = 0; i < numColors; i++) { + index = indices[i]; + (*hwp->WriteAddress)(pScrn, index << 2); + (*hwp->WriteData)(pScrn, colors[index >> 1].red); + (*hwp->WriteData)(pScrn, colors[index].green); + (*hwp->WriteData)(pScrn, colors[index >> 1].blue); + + if(index <= 31) { + (*hwp->WriteAddress)(pScrn, index << 3); + (*hwp->WriteData)(pScrn, colors[index].red); + (*hwp->WriteData)(pScrn, colors[(index << 1) + 1].green); + (*hwp->WriteData)(pScrn, colors[index].blue); + } + } +} else { + shift = (pScrn->depth == 15) ? 3 : 0; + + for(i = 0; i < numColors; i++) { + index = indices[i]; + (*hwp->WriteAddress)(pScrn, index << shift); + (*hwp->WriteData)(pScrn, colors[index].red); + (*hwp->WriteData)(pScrn, colors[index].green); + (*hwp->WriteData)(pScrn, colors[index].blue); + } +} +} + +TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void) { + return TIramdacLoadPalette; +} diff --git a/xorg-server/hw/xfree86/ramdac/TI.h b/xorg-server/hw/xfree86/ramdac/TI.h new file mode 100644 index 000000000..bc807f40c --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/TI.h @@ -0,0 +1,95 @@ + +#include <xf86RamDac.h> + +unsigned long TIramdacCalculateMNPForClock(unsigned long RefClock, + unsigned long ReqClock, char IsPixClock, unsigned long MinClock, + unsigned long MaxClock, unsigned long *rM, unsigned long *rN, + unsigned long *rP); +RamDacHelperRecPtr TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs); +void TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec); +void TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec, RamDacRegRecPtr RamDacRegRec); +void TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec); +void TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr RamDacRegRec); +unsigned long TIramdac3030CalculateMNPForClock(unsigned long RefClock, + unsigned long ReqClock, char IsPixClock, unsigned long MinClock, + unsigned long MaxClock, unsigned long *rM, unsigned long *rN, + unsigned long *rP); +void TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr); +void TIramdacLoadPalette( ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual); + +typedef void TIramdacLoadPaletteProc(ScrnInfoPtr, int, int *, LOCO *, + VisualPtr); +TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void); + +#define TI3030_RAMDAC (VENDOR_TI << 16) | 0x00 +#define TI3026_RAMDAC (VENDOR_TI << 16) | 0x01 + +/* + * TI Ramdac registers + */ + +#define TIDAC_rev 0x01 +#define TIDAC_ind_curs_ctrl 0x06 +#define TIDAC_byte_router_ctrl 0x07 +#define TIDAC_latch_ctrl 0x0f +#define TIDAC_true_color_ctrl 0x18 +#define TIDAC_multiplex_ctrl 0x19 +#define TIDAC_clock_select 0x1a +#define TIDAC_palette_page 0x1c +#define TIDAC_general_ctrl 0x1d +#define TIDAC_misc_ctrl 0x1e +#define TIDAC_pll_addr 0x2c +#define TIDAC_pll_pixel_data 0x2d +#define TIDAC_pll_memory_data 0x2e +#define TIDAC_pll_loop_data 0x2f +#define TIDAC_key_over_low 0x30 +#define TIDAC_key_over_high 0x31 +#define TIDAC_key_red_low 0x32 +#define TIDAC_key_red_high 0x33 +#define TIDAC_key_green_low 0x34 +#define TIDAC_key_green_high 0x35 +#define TIDAC_key_blue_low 0x36 +#define TIDAC_key_blue_high 0x37 +#define TIDAC_key_ctrl 0x38 +#define TIDAC_clock_ctrl 0x39 +#define TIDAC_sense_test 0x3a +#define TIDAC_test_mode_data 0x3b +#define TIDAC_crc_remain_lsb 0x3c +#define TIDAC_crc_remain_msb 0x3d +#define TIDAC_crc_bit_select 0x3e +#define TIDAC_id 0x3f + +/* These are pll values that are accessed via TIDAC_pll_pixel_data */ +#define TIDAC_PIXEL_N 0x80 +#define TIDAC_PIXEL_M 0x81 +#define TIDAC_PIXEL_P 0x82 +#define TIDAC_PIXEL_VALID 0x83 + +/* These are pll values that are accessed via TIDAC_pll_loop_data */ +#define TIDAC_LOOP_N 0x90 +#define TIDAC_LOOP_M 0x91 +#define TIDAC_LOOP_P 0x92 +#define TIDAC_LOOP_VALID 0x93 + +/* Direct mapping addresses */ +#define TIDAC_INDEX 0xa0 +#define TIDAC_PALETTE_DATA 0xa1 +#define TIDAC_READ_MASK 0xa2 +#define TIDAC_READ_ADDR 0xa3 +#define TIDAC_CURS_WRITE_ADDR 0xa4 +#define TIDAC_CURS_COLOR 0xa5 +#define TIDAC_CURS_READ_ADDR 0xa7 +#define TIDAC_CURS_CTL 0xa9 +#define TIDAC_INDEXED_DATA 0xaa +#define TIDAC_CURS_RAM_DATA 0xab +#define TIDAC_CURS_XLOW 0xac +#define TIDAC_CURS_XHIGH 0xad +#define TIDAC_CURS_YLOW 0xae +#define TIDAC_CURS_YHIGH 0xaf + +#define TIDAC_sw_reset 0xff + +/* Constants */ +#define TIDAC_TVP_3026_ID 0x26 +#define TIDAC_TVP_3030_ID 0x30 diff --git a/xorg-server/hw/xfree86/ramdac/TIPriv.h b/xorg-server/hw/xfree86/ramdac/TIPriv.h new file mode 100644 index 000000000..191c9b5ce --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/TIPriv.h @@ -0,0 +1,29 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "TI.h" + +typedef struct { + char *DeviceName; +} xf86TIramdacInfo; + +extern xf86TIramdacInfo TIramdacDeviceInfo[]; + +#ifdef INIT_TI_RAMDAC_INFO +xf86TIramdacInfo TIramdacDeviceInfo[] = { + {"TI TVP3030"}, + {"TI TVP3026"} +}; +#endif + +#define TISAVE(_reg) do { \ + ramdacReg->DacRegs[_reg] = (*ramdacPtr->ReadDAC)(pScrn, _reg); \ +} while (0) + +#define TIRESTORE(_reg) do { \ + (*ramdacPtr->WriteDAC)(pScrn, _reg, \ + (ramdacReg->DacRegs[_reg] & 0xFF00) >> 8, \ + ramdacReg->DacRegs[_reg]); \ +} while (0) diff --git a/xorg-server/hw/xfree86/ramdac/xf86BitOrder.c b/xorg-server/hw/xfree86/ramdac/xf86BitOrder.c new file mode 100644 index 000000000..713934d3b --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86BitOrder.c @@ -0,0 +1,2 @@ +#define XAAReverseBitOrder xf86ReverseBitOrder +#include "./../xaa/xaaBitOrder.c" diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c new file mode 100644 index 000000000..5b1ce5e1f --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c @@ -0,0 +1,403 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86CursorPriv.h" +#include "colormapst.h" +#include "cursorstr.h" + +DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKey; + +/* sprite functions */ + +static Bool xf86CursorRealizeCursor(ScreenPtr, CursorPtr); +static Bool xf86CursorUnrealizeCursor(ScreenPtr, CursorPtr); +static void xf86CursorSetCursor(ScreenPtr, CursorPtr, int, int); +static void xf86CursorMoveCursor(ScreenPtr, int, int); + +static miPointerSpriteFuncRec xf86CursorSpriteFuncs = { + xf86CursorRealizeCursor, + xf86CursorUnrealizeCursor, + xf86CursorSetCursor, + xf86CursorMoveCursor +}; + +/* Screen functions */ + +static void xf86CursorInstallColormap(ColormapPtr); +static void xf86CursorRecolorCursor(ScreenPtr, CursorPtr, Bool); +static Bool xf86CursorCloseScreen(int, ScreenPtr); +static void xf86CursorQueryBestSize(int, unsigned short*, unsigned short*, + ScreenPtr); + +/* ScrnInfoRec functions */ + +static void xf86CursorEnableDisableFBAccess(int, Bool); +static Bool xf86CursorSwitchMode(int, DisplayModePtr,int); + +Bool +xf86InitCursor( + ScreenPtr pScreen, + xf86CursorInfoPtr infoPtr +) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CursorScreenPtr ScreenPriv; + miPointerScreenPtr PointPriv; + + if (!xf86InitHardwareCursor(pScreen, infoPtr)) + return FALSE; + + ScreenPriv = xcalloc(1, sizeof(xf86CursorScreenRec)); + if (!ScreenPriv) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv); + + ScreenPriv->SWCursor = TRUE; + ScreenPriv->isUp = FALSE; + ScreenPriv->CurrentCursor = NULL; + ScreenPriv->CursorInfoPtr = infoPtr; + ScreenPriv->PalettedCursor = FALSE; + ScreenPriv->pInstalledMap = NULL; + + ScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = xf86CursorCloseScreen; + ScreenPriv->QueryBestSize = pScreen->QueryBestSize; + pScreen->QueryBestSize = xf86CursorQueryBestSize; + ScreenPriv->RecolorCursor = pScreen->RecolorCursor; + pScreen->RecolorCursor = xf86CursorRecolorCursor; + + if ((infoPtr->pScrn->bitsPerPixel == 8) && + !(infoPtr->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP)) { + ScreenPriv->InstallColormap = pScreen->InstallColormap; + pScreen->InstallColormap = xf86CursorInstallColormap; + ScreenPriv->PalettedCursor = TRUE; + } + + PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); + + ScreenPriv->showTransparent = PointPriv->showTransparent; + if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) + PointPriv->showTransparent = TRUE; + else + PointPriv->showTransparent = FALSE; + ScreenPriv->spriteFuncs = PointPriv->spriteFuncs; + PointPriv->spriteFuncs = &xf86CursorSpriteFuncs; + + ScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; + ScreenPriv->SwitchMode = pScrn->SwitchMode; + + ScreenPriv->ForceHWCursorCount = 0; + ScreenPriv->HWCursorForced = FALSE; + + pScrn->EnableDisableFBAccess = xf86CursorEnableDisableFBAccess; + if (pScrn->SwitchMode) + pScrn->SwitchMode = xf86CursorSwitchMode; + + return TRUE; +} + +/***** Screen functions *****/ + +static Bool +xf86CursorCloseScreen(int i, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + if (ScreenPriv->isUp && pScrn->vtSema) + xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); + + pScreen->CloseScreen = ScreenPriv->CloseScreen; + pScreen->QueryBestSize = ScreenPriv->QueryBestSize; + pScreen->RecolorCursor = ScreenPriv->RecolorCursor; + if (ScreenPriv->InstallColormap) + pScreen->InstallColormap = ScreenPriv->InstallColormap; + + PointPriv->spriteFuncs = ScreenPriv->spriteFuncs; + PointPriv->showTransparent = ScreenPriv->showTransparent; + + pScrn->EnableDisableFBAccess = ScreenPriv->EnableDisableFBAccess; + pScrn->SwitchMode = ScreenPriv->SwitchMode; + + xfree(ScreenPriv->transparentData); + xfree(ScreenPriv); + + return (*pScreen->CloseScreen)(i, pScreen); +} + +static void +xf86CursorQueryBestSize( + int class, + unsigned short *width, + unsigned short *height, + ScreenPtr pScreen) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + if (class == CursorShape) { + if(*width > ScreenPriv->CursorInfoPtr->MaxWidth) + *width = ScreenPriv->CursorInfoPtr->MaxWidth; + if(*height > ScreenPriv->CursorInfoPtr->MaxHeight) + *height = ScreenPriv->CursorInfoPtr->MaxHeight; + } else + (*ScreenPriv->QueryBestSize)(class, width, height, pScreen); +} + +static void +xf86CursorInstallColormap(ColormapPtr pMap) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pMap->pScreen->devPrivates, xf86CursorScreenKey); + + ScreenPriv->pInstalledMap = pMap; + + (*ScreenPriv->InstallColormap)(pMap); +} + +static void +xf86CursorRecolorCursor( + ScreenPtr pScreen, + CursorPtr pCurs, + Bool displayed) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + if (!displayed) + return; + + if (ScreenPriv->SWCursor) + (*ScreenPriv->RecolorCursor)(pScreen, pCurs, displayed); + else + xf86RecolorCursor(pScreen, pCurs, displayed); +} + +/***** ScrnInfoRec functions *********/ + +static void +xf86CursorEnableDisableFBAccess( + int index, + Bool enable) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + if (!enable && ScreenPriv->CurrentCursor != NullCursor) { + CursorPtr currentCursor = ScreenPriv->CurrentCursor; + xf86CursorSetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); + ScreenPriv->isUp = FALSE; + ScreenPriv->SWCursor = TRUE; + ScreenPriv->SavedCursor = currentCursor; + } + + if (ScreenPriv->EnableDisableFBAccess) + (*ScreenPriv->EnableDisableFBAccess)(index, enable); + + if (enable && ScreenPriv->SavedCursor) + { + /* + * Re-set current cursor so drivers can react to FB access having been + * temporarily disabled. + */ + xf86CursorSetCursor(pScreen, ScreenPriv->SavedCursor, + ScreenPriv->x, ScreenPriv->y); + ScreenPriv->SavedCursor = NULL; + } +} + +static Bool +xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags) +{ + Bool ret; + ScreenPtr pScreen = screenInfo.screens[index]; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); + + if (ScreenPriv->isUp) { + xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); + ScreenPriv->isUp = FALSE; + } + + ret = (*ScreenPriv->SwitchMode)(index, mode, flags); + + /* + * Cannot restore cursor here because the new frame[XY][01] haven't been + * calculated yet. However, because the hardware cursor was removed above, + * ensure the cursor is repainted by miPointerWarpCursor(). + */ + ScreenPriv->CursorToRestore = ScreenPriv->CurrentCursor; + PointPriv->waitForUpdate = FALSE; /* Force cursor repaint */ + + return ret; +} + +/****** miPointerSpriteFunctions *******/ + +static Bool +xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + if (pCurs->refcnt <= 1) + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); + + return (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCurs); +} + +static Bool +xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + if (pCurs->refcnt <= 1) { + xfree(dixLookupPrivate(&pCurs->devPrivates, pScreen)); + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); + } + + return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCurs); +} + +static void +xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; + miPointerScreenPtr PointPriv; + + ScreenPriv->CurrentCursor = pCurs; + ScreenPriv->x = x; + ScreenPriv->y = y; + ScreenPriv->CursorToRestore = NULL; + + if (!infoPtr->pScrn->vtSema) + ScreenPriv->SavedCursor = pCurs; + + if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */ + if (ScreenPriv->SWCursor) + (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, NullCursor, x, y); + else if (ScreenPriv->isUp) { + xf86SetCursor(pScreen, NullCursor, x, y); + ScreenPriv->isUp = FALSE; + } + return; + } + + ScreenPriv->HotX = pCurs->bits->xhot; + ScreenPriv->HotY = pCurs->bits->yhot; + + PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miPointerScreenKey); + if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || (( +#ifdef ARGB_CURSOR + pCurs->bits->argb && infoPtr->UseHWCursorARGB && + (*infoPtr->UseHWCursorARGB) (pScreen, pCurs) ) || ( + pCurs->bits->argb == 0 && +#endif + (pCurs->bits->height <= infoPtr->MaxHeight) && + (pCurs->bits->width <= infoPtr->MaxWidth) && + (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor)(pScreen, pCurs)))))) + { + + if (ScreenPriv->SWCursor) /* remove the SW cursor */ + (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, NullCursor, x, y); + + xf86SetCursor(pScreen, pCurs, x, y); + ScreenPriv->SWCursor = FALSE; + ScreenPriv->isUp = TRUE; + PointPriv->waitForUpdate = !infoPtr->pScrn->silkenMouse; + return; + } + + PointPriv->waitForUpdate = TRUE; + + if (ScreenPriv->isUp) { + /* Remove the HW cursor, or make it transparent */ + if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) { + xf86SetTransparentCursor(pScreen); + } else { + xf86SetCursor(pScreen, NullCursor, x, y); + ScreenPriv->isUp = FALSE; + } + } + + ScreenPriv->SWCursor = TRUE; + + if (pCurs->bits->emptyMask && !ScreenPriv->showTransparent) + pCurs = NullCursor; + (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCurs, x, y); +} + +static void +xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + ScreenPriv->x = x; + ScreenPriv->y = y; + + if (ScreenPriv->CursorToRestore) + xf86CursorSetCursor(pScreen, ScreenPriv->CursorToRestore, + ScreenPriv->x, ScreenPriv->y); + else if (ScreenPriv->SWCursor) + (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y); + else if (ScreenPriv->isUp) + xf86MoveCursor(pScreen, x, y); +} + +void +xf86ForceHWCursor (ScreenPtr pScreen, Bool on) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + + if (on) + { + if (ScreenPriv->ForceHWCursorCount++ == 0) + { + if (ScreenPriv->SWCursor && ScreenPriv->CurrentCursor) + { + ScreenPriv->HWCursorForced = TRUE; + xf86CursorSetCursor (pScreen, ScreenPriv->CurrentCursor, + ScreenPriv->x, ScreenPriv->y); + } + else + ScreenPriv->HWCursorForced = FALSE; + } + } + else + { + if (--ScreenPriv->ForceHWCursorCount == 0) + { + if (ScreenPriv->HWCursorForced && ScreenPriv->CurrentCursor) + xf86CursorSetCursor (pScreen, ScreenPriv->CurrentCursor, + ScreenPriv->x, ScreenPriv->y); + } + } +} + +xf86CursorInfoPtr +xf86CreateCursorInfoRec(void) +{ + return xcalloc(1, sizeof(xf86CursorInfoRec)); +} + +void +xf86DestroyCursorInfoRec(xf86CursorInfoPtr infoPtr) +{ + xfree(infoPtr); +} diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.h b/xorg-server/hw/xfree86/ramdac/xf86Cursor.h new file mode 100644 index 000000000..469f48f01 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.h @@ -0,0 +1,51 @@ + +#ifndef _XF86CURSOR_H +#define _XF86CURSOR_H + +#include "xf86str.h" +#include "mipointer.h" + +typedef struct _xf86CursorInfoRec { + ScrnInfoPtr pScrn; + int Flags; + int MaxWidth; + int MaxHeight; + void (*SetCursorColors)(ScrnInfoPtr pScrn, int bg, int fg); + void (*SetCursorPosition)(ScrnInfoPtr pScrn, int x, int y); + void (*LoadCursorImage)(ScrnInfoPtr pScrn, unsigned char *bits); + void (*HideCursor)(ScrnInfoPtr pScrn); + void (*ShowCursor)(ScrnInfoPtr pScrn); + unsigned char* (*RealizeCursor)(struct _xf86CursorInfoRec *, CursorPtr); + Bool (*UseHWCursor)(ScreenPtr, CursorPtr); + +#ifdef ARGB_CURSOR + Bool (*UseHWCursorARGB) (ScreenPtr, CursorPtr); + void (*LoadCursorARGB) (ScrnInfoPtr, CursorPtr); +#endif + +} xf86CursorInfoRec, *xf86CursorInfoPtr; + +Bool xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr); +xf86CursorInfoPtr xf86CreateCursorInfoRec(void); +void xf86DestroyCursorInfoRec(xf86CursorInfoPtr); +void xf86ForceHWCursor (ScreenPtr pScreen, Bool on); + +#define HARDWARE_CURSOR_INVERT_MASK 0x00000001 +#define HARDWARE_CURSOR_AND_SOURCE_WITH_MASK 0x00000002 +#define HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK 0x00000004 +#define HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED 0x00000008 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 0x00000010 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 0x00000020 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 0x00000040 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 0x00000080 +#define HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 0x00000100 +#define HARDWARE_CURSOR_TRUECOLOR_AT_8BPP 0x00000200 +#define HARDWARE_CURSOR_BIT_ORDER_MSBFIRST 0x00000400 +#define HARDWARE_CURSOR_NIBBLE_SWAPPED 0x00000800 +#define HARDWARE_CURSOR_SHOW_TRANSPARENT 0x00001000 +#define HARDWARE_CURSOR_UPDATE_UNHIDDEN 0x00002000 +#ifdef ARGB_CURSOR +#define HARDWARE_CURSOR_ARGB 0x00004000 +#endif + +#endif /* _XF86CURSOR_H */ diff --git a/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h b/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h new file mode 100644 index 000000000..f82be2edc --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h @@ -0,0 +1,50 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _XF86CURSORPRIV_H +#define _XF86CURSORPRIV_H + +#include "xf86Cursor.h" +#include "mipointrst.h" + +typedef struct { + Bool SWCursor; + Bool isUp; + Bool showTransparent; + short HotX; + short HotY; + short x; + short y; + CursorPtr CurrentCursor, CursorToRestore; + xf86CursorInfoPtr CursorInfoPtr; + CloseScreenProcPtr CloseScreen; + RecolorCursorProcPtr RecolorCursor; + InstallColormapProcPtr InstallColormap; + QueryBestSizeProcPtr QueryBestSize; + miPointerSpriteFuncPtr spriteFuncs; + Bool PalettedCursor; + ColormapPtr pInstalledMap; + Bool (*SwitchMode)(int, DisplayModePtr,int); + xf86EnableDisableFBAccessProc *EnableDisableFBAccess; + CursorPtr SavedCursor; + + /* Number of requests to force HW cursor */ + int ForceHWCursorCount; + Bool HWCursorForced; + + pointer transparentData; +} xf86CursorScreenRec, *xf86CursorScreenPtr; + +void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y); +void xf86SetTransparentCursor(ScreenPtr pScreen); +void xf86MoveCursor(ScreenPtr pScreen, int x, int y); +void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed); +Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr); + +CARD32 xf86ReverseBitOrder(CARD32 data); + +extern DevPrivateKey xf86CursorScreenKey; + +#endif /* _XF86CURSORPRIV_H */ diff --git a/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c b/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c new file mode 100644 index 000000000..d10e283d7 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86HWCurs.c @@ -0,0 +1,527 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "cursorstr.h" +#include "mi.h" +#include "mipointer.h" +#include "xf86CursorPriv.h" + +#include "servermd.h" + +#if BITMAP_SCANLINE_PAD == 64 + +#if 1 +/* Cursors might be only 32 wide. Give'em a chance */ +#define SCANLINE CARD32 +#define CUR_BITMAP_SCANLINE_PAD 32 +#define CUR_LOG2_BITMAP_PAD 5 +#define REVERSE_BIT_ORDER(w) xf86ReverseBitOrder(w) +#else +#define SCANLINE CARD64 +#define CUR_BITMAP_SCANLINE_PAD BITMAP_SCANLINE_PAD +#define CUR_LOG2_BITMAP_PAD LOG2_BITMAP_PAD +#define REVERSE_BIT_ORDER(w) xf86CARD64ReverseBits(w) +static CARD64 xf86CARD64ReverseBits(CARD64 w); + +static CARD64 +xf86CARD64ReverseBits(CARD64 w) +{ + unsigned char *p = (unsigned char *)&w; + + p[0] = byte_reversed[p[0]]; + p[1] = byte_reversed[p[1]]; + p[2] = byte_reversed[p[2]]; + p[3] = byte_reversed[p[3]]; + p[4] = byte_reversed[p[4]]; + p[5] = byte_reversed[p[5]]; + p[6] = byte_reversed[p[6]]; + p[7] = byte_reversed[p[7]]; + + return w; +} +#endif + +#else + +#define SCANLINE CARD32 +#define CUR_BITMAP_SCANLINE_PAD BITMAP_SCANLINE_PAD +#define CUR_LOG2_BITMAP_PAD LOG2_BITMAP_PAD +#define REVERSE_BIT_ORDER(w) xf86ReverseBitOrder(w) + +#endif /* BITMAP_SCANLINE_PAD == 64 */ + +static unsigned char* RealizeCursorInterleave0(xf86CursorInfoPtr, CursorPtr); +static unsigned char* RealizeCursorInterleave1(xf86CursorInfoPtr, CursorPtr); +static unsigned char* RealizeCursorInterleave8(xf86CursorInfoPtr, CursorPtr); +static unsigned char* RealizeCursorInterleave16(xf86CursorInfoPtr, CursorPtr); +static unsigned char* RealizeCursorInterleave32(xf86CursorInfoPtr, CursorPtr); +static unsigned char* RealizeCursorInterleave64(xf86CursorInfoPtr, CursorPtr); + +Bool +xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr) +{ + if ((infoPtr->MaxWidth <= 0) || (infoPtr->MaxHeight <= 0)) + return FALSE; + + /* These are required for now */ + if (!infoPtr->SetCursorPosition || + !infoPtr->LoadCursorImage || + !infoPtr->HideCursor || + !infoPtr->ShowCursor || + !infoPtr->SetCursorColors) + return FALSE; + + if (infoPtr->RealizeCursor) { + /* Don't overwrite a driver provided Realize Cursor function */ + } else + if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 & infoPtr->Flags) { + infoPtr->RealizeCursor = RealizeCursorInterleave1; + } else + if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 & infoPtr->Flags) { + infoPtr->RealizeCursor = RealizeCursorInterleave8; + } else + if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 & infoPtr->Flags) { + infoPtr->RealizeCursor = RealizeCursorInterleave16; + } else + if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 & infoPtr->Flags) { + infoPtr->RealizeCursor = RealizeCursorInterleave32; + } else + if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 & infoPtr->Flags) { + infoPtr->RealizeCursor = RealizeCursorInterleave64; + } else { /* not interleaved */ + infoPtr->RealizeCursor = RealizeCursorInterleave0; + } + + infoPtr->pScrn = xf86Screens[pScreen->myNum]; + + return TRUE; +} + +void +xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; + unsigned char *bits; + + if (pCurs == NullCursor) { + (*infoPtr->HideCursor)(infoPtr->pScrn); + return; + } + + bits = (unsigned char *)dixLookupPrivate(&pCurs->devPrivates, pScreen); + + x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX; + y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY; + +#ifdef ARGB_CURSOR + if (!pCurs->bits->argb || !infoPtr->LoadCursorARGB) +#endif + if (!bits) { + bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs); + dixSetPrivate(&pCurs->devPrivates, pScreen, bits); + } + + if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) + (*infoPtr->HideCursor)(infoPtr->pScrn); + +#ifdef ARGB_CURSOR + if (pCurs->bits->argb && infoPtr->LoadCursorARGB) + (*infoPtr->LoadCursorARGB) (infoPtr->pScrn, pCurs); + else +#endif + if (bits) + (*infoPtr->LoadCursorImage)(infoPtr->pScrn, bits); + + xf86RecolorCursor(pScreen, pCurs, 1); + + (*infoPtr->SetCursorPosition)(infoPtr->pScrn, x, y); + + (*infoPtr->ShowCursor)(infoPtr->pScrn); +} + +void +xf86SetTransparentCursor(ScreenPtr pScreen) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; + + if (!ScreenPriv->transparentData) + ScreenPriv->transparentData = + (*infoPtr->RealizeCursor)(infoPtr, NullCursor); + + if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) + (*infoPtr->HideCursor)(infoPtr->pScrn); + + if (ScreenPriv->transparentData) + (*infoPtr->LoadCursorImage)(infoPtr->pScrn, + ScreenPriv->transparentData); + + (*infoPtr->ShowCursor)(infoPtr->pScrn); +} + +void +xf86MoveCursor(ScreenPtr pScreen, int x, int y) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; + + x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX; + y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY; + + (*infoPtr->SetCursorPosition)(infoPtr->pScrn, x, y); +} + +void +xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed) +{ + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; + +#ifdef ARGB_CURSOR + /* recoloring isn't applicable to ARGB cursors and drivers + shouldn't have to ignore SetCursorColors requests */ + if (pCurs->bits->argb) + return; +#endif + + if (ScreenPriv->PalettedCursor) { + xColorItem sourceColor, maskColor; + ColormapPtr pmap = ScreenPriv->pInstalledMap; + + if (!pmap) + return; + + sourceColor.red = pCurs->foreRed; + sourceColor.green = pCurs->foreGreen; + sourceColor.blue = pCurs->foreBlue; + FakeAllocColor(pmap, &sourceColor); + maskColor.red = pCurs->backRed; + maskColor.green = pCurs->backGreen; + maskColor.blue = pCurs->backBlue; + FakeAllocColor(pmap, &maskColor); + FakeFreeColor(pmap, sourceColor.pixel); + FakeFreeColor(pmap, maskColor.pixel); + (*infoPtr->SetCursorColors)(infoPtr->pScrn, + maskColor.pixel, sourceColor.pixel); + } else { /* Pass colors in 8-8-8 RGB format */ + (*infoPtr->SetCursorColors)(infoPtr->pScrn, + (pCurs->backBlue >> 8) | + ((pCurs->backGreen >> 8) << 8) | + ((pCurs->backRed >> 8) << 16), + (pCurs->foreBlue >> 8) | + ((pCurs->foreGreen >> 8) << 8) | + ((pCurs->foreRed >> 8) << 16) + ); + } +} + +/* These functions assume that MaxWidth is a multiple of 32 */ +static unsigned char* +RealizeCursorInterleave0(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + + SCANLINE *SrcS, *SrcM, *DstS, *DstM; + SCANLINE *pSrc, *pMsk; + unsigned char *mem; + int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2; + int SrcPitch, DstPitch, Pitch, y, x; + /* how many words are in the source or mask */ + int words = size / (CUR_BITMAP_SCANLINE_PAD / 4); + + + if (!(mem = xcalloc(1, size))) + return NULL; + + if (pCurs == NullCursor) { + if (infoPtr->Flags & HARDWARE_CURSOR_INVERT_MASK) { + DstM = (SCANLINE*)mem; + if (!(infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)) + DstM += words; + (void)memset(DstM, -1, words * sizeof(SCANLINE)); + } + return mem; + } + + /* SrcPitch == the number of scanlines wide the cursor image is */ + SrcPitch = (pCurs->bits->width + (BITMAP_SCANLINE_PAD - 1)) >> + CUR_LOG2_BITMAP_PAD; + + /* DstPitch is the width of the hw cursor in scanlines */ + DstPitch = infoPtr->MaxWidth >> CUR_LOG2_BITMAP_PAD; + Pitch = SrcPitch < DstPitch ? SrcPitch : DstPitch; + + SrcS = (SCANLINE*)pCurs->bits->source; + SrcM = (SCANLINE*)pCurs->bits->mask; + DstS = (SCANLINE*)mem; + DstM = DstS + words; + + if (infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK) { + SCANLINE *tmp; + tmp = DstS; DstS = DstM; DstM = tmp; + } + + if (infoPtr->Flags & HARDWARE_CURSOR_AND_SOURCE_WITH_MASK) { + for(y = pCurs->bits->height, pSrc = DstS, pMsk = DstM; + y--; + pSrc+=DstPitch, pMsk+=DstPitch, SrcS+=SrcPitch, SrcM+=SrcPitch) { + for(x = 0; x < Pitch; x++) { + pSrc[x] = SrcS[x] & SrcM[x]; + pMsk[x] = SrcM[x]; + } + } + } else { + for(y = pCurs->bits->height, pSrc = DstS, pMsk = DstM; + y--; + pSrc+=DstPitch, pMsk+=DstPitch, SrcS+=SrcPitch, SrcM+=SrcPitch) { + for(x = 0; x < Pitch; x++) { + pSrc[x] = SrcS[x]; + pMsk[x] = SrcM[x]; + } + } + } + + if (infoPtr->Flags & HARDWARE_CURSOR_NIBBLE_SWAPPED) { + int count = size; + unsigned char* pntr1 = (unsigned char *)DstS; + unsigned char* pntr2 = (unsigned char *)DstM; + unsigned char a, b; + while (count) { + + a = *pntr1; + b = *pntr2; + *pntr1 = ((a & 0xF0) >> 4) | ((a & 0x0F) << 4); + *pntr2 = ((b & 0xF0) >> 4) | ((b & 0x0F) << 4); + pntr1++; pntr2++; + count-=2; + } + } + + /* + * Must be _after_ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK to avoid wiping + * out entire source mask. + */ + if (infoPtr->Flags & HARDWARE_CURSOR_INVERT_MASK) { + int count = words; + SCANLINE* pntr = DstM; + while (count--) { + *pntr = ~(*pntr); + pntr++; + } + } + + if (infoPtr->Flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) { + for(y = pCurs->bits->height, pSrc = DstS, pMsk = DstM; + y--; + pSrc+=DstPitch, pMsk+=DstPitch) { + for(x = 0; x < Pitch; x++) { + pSrc[x] = REVERSE_BIT_ORDER(pSrc[x]); + pMsk[x] = REVERSE_BIT_ORDER(pMsk[x]); + } + } + } + + return mem; +} + +static unsigned char* +RealizeCursorInterleave1(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + unsigned char *DstS, *DstM; + unsigned char *pntr; + unsigned char *mem, *mem2; + int count; + int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2; + + /* Realize the cursor without interleaving */ + if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs))) + return NULL; + + if (!(mem = xcalloc(1, size))) { + xfree(mem2); + return NULL; + } + + /* 1 bit interleave */ + DstS = mem2; + DstM = DstS + (size >> 1); + pntr = mem; + count = size; + while (count) { + *pntr++ = ((*DstS&0x01) ) | ((*DstM&0x01) << 1) | + ((*DstS&0x02) << 1) | ((*DstM&0x02) << 2) | + ((*DstS&0x04) << 2) | ((*DstM&0x04) << 3) | + ((*DstS&0x08) << 3) | ((*DstM&0x08) << 4); + *pntr++ = ((*DstS&0x10) >> 4) | ((*DstM&0x10) >> 3) | + ((*DstS&0x20) >> 3) | ((*DstM&0x20) >> 2) | + ((*DstS&0x40) >> 2) | ((*DstM&0x40) >> 1) | + ((*DstS&0x80) >> 1) | ((*DstM&0x80) ); + DstS++; + DstM++; + count-=2; + } + + /* Free the uninterleaved cursor */ + xfree(mem2); + + return mem; +} + +static unsigned char* +RealizeCursorInterleave8(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + unsigned char *DstS, *DstM; + unsigned char *pntr; + unsigned char *mem, *mem2; + int count; + int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2; + + /* Realize the cursor without interleaving */ + if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs))) + return NULL; + + if (!(mem = xcalloc(1, size))) { + xfree(mem2); + return NULL; + } + + /* 8 bit interleave */ + DstS = mem2; + DstM = DstS + (size >> 1); + pntr = mem; + count = size; + while (count) { + *pntr++ = *DstS++; + *pntr++ = *DstM++; + count-=2; + } + + /* Free the uninterleaved cursor */ + xfree(mem2); + + return mem; +} + +static unsigned char* +RealizeCursorInterleave16(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + unsigned short *DstS, *DstM; + unsigned short *pntr; + unsigned char *mem, *mem2; + int count; + int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2; + + /* Realize the cursor without interleaving */ + if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs))) + return NULL; + + if (!(mem = xcalloc(1, size))) { + xfree(mem2); + return NULL; + } + + /* 16 bit interleave */ + DstS = (pointer)mem2; + DstM = DstS + (size >> 2); + pntr = (pointer)mem; + count = (size >> 1); + while (count) { + *pntr++ = *DstS++; + *pntr++ = *DstM++; + count-=2; + } + + /* Free the uninterleaved cursor */ + xfree(mem2); + + return mem; +} + +static unsigned char* +RealizeCursorInterleave32(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + CARD32 *DstS, *DstM; + CARD32 *pntr; + unsigned char *mem, *mem2; + int count; + int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2; + + /* Realize the cursor without interleaving */ + if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs))) + return NULL; + + if (!(mem = xcalloc(1, size))) { + xfree(mem2); + return NULL; + } + + /* 32 bit interleave */ + DstS = (pointer)mem2; + DstM = DstS + (size >> 3); + pntr = (pointer)mem; + count = (size >> 2); + while (count) { + *pntr++ = *DstS++; + *pntr++ = *DstM++; + count-=2; + } + + /* Free the uninterleaved cursor */ + xfree(mem2); + + return mem; +} + +static unsigned char* +RealizeCursorInterleave64(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + CARD32 *DstS, *DstM; + CARD32 *pntr; + unsigned char *mem, *mem2; + int count; + int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2; + + /* Realize the cursor without interleaving */ + if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs))) + return NULL; + + if (!(mem = xcalloc(1, size))) { + xfree(mem2); + return NULL; + } + + /* 64 bit interleave */ + DstS = (pointer)mem2; + DstM = DstS + (size >> 3); + pntr = (pointer)mem; + count = (size >> 2); + while (count) { + *pntr++ = *DstS++; + *pntr++ = *DstS++; + *pntr++ = *DstM++; + *pntr++ = *DstM++; + count-=4; + } + + /* Free the uninterleaved cursor */ + xfree(mem2); + + return mem; +} diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDac.c b/xorg-server/hw/xfree86/ramdac/xf86RamDac.c new file mode 100644 index 000000000..1dd3daf1b --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86RamDac.c @@ -0,0 +1,154 @@ +/* + * Copyright 1998 by Alan Hourihane, Wigan, England. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> + * + * Generic RAMDAC access routines. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "xf86RamDacPriv.h" + +int RamDacHWPrivateIndex = -1; +int RamDacScreenPrivateIndex = -1; + +RamDacRecPtr +RamDacCreateInfoRec() +{ + RamDacRecPtr infoRec; + + infoRec = xcalloc(1, sizeof(RamDacRec)); + + return infoRec; +} + +RamDacHelperRecPtr +RamDacHelperCreateInfoRec() +{ + RamDacHelperRecPtr infoRec; + + infoRec = xcalloc(1, sizeof(RamDacHelperRec)); + + return infoRec; +} + +void +RamDacDestroyInfoRec(RamDacRecPtr infoRec) +{ + xfree(infoRec); +} + +void +RamDacHelperDestroyInfoRec(RamDacHelperRecPtr infoRec) +{ + xfree(infoRec); +} + +Bool +RamDacInit(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPriv) +{ + RamDacScreenRecPtr ramdacScrPtr; + + /* + * make sure the RamDacRec is allocated + */ + if (!RamDacGetRec(pScrn)) + return FALSE; + ramdacScrPtr = + ((RamDacScreenRecPtr) (pScrn)->privates[RamDacGetScreenIndex()].ptr); + ramdacScrPtr->RamDacRec = ramdacPriv; + + return(TRUE); +} + +void +RamDacGetRecPrivate() +{ + if (RamDacHWPrivateIndex < 0) + RamDacHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + if (RamDacScreenPrivateIndex < 0) + RamDacScreenPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + return; +} + +Bool +RamDacGetRec(ScrnInfoPtr scrp) +{ + RamDacGetRecPrivate(); + /* + * New privates are always set to NULL, so we can check if the allocation + * has already been done. + */ + if (scrp->privates[RamDacHWPrivateIndex].ptr != NULL) + return TRUE; + if (scrp->privates[RamDacScreenPrivateIndex].ptr != NULL) + return TRUE; + + scrp->privates[RamDacHWPrivateIndex].ptr = + xnfcalloc(sizeof(RamDacHWRec), 1); + scrp->privates[RamDacScreenPrivateIndex].ptr = + xnfcalloc(sizeof(RamDacScreenRec), 1); + + return TRUE; +} + +void +RamDacFreeRec(ScrnInfoPtr pScrn) +{ + RamDacHWRecPtr ramdacHWPtr; + RamDacScreenRecPtr ramdacScrPtr; + + if (RamDacHWPrivateIndex < 0) + return; + + if (RamDacScreenPrivateIndex < 0) + return; + + ramdacHWPtr = RAMDACHWPTR(pScrn); + ramdacScrPtr = ((RamDacScreenRecPtr) + (pScrn)->privates[RamDacGetScreenIndex()].ptr); + + if (ramdacHWPtr) + xfree(ramdacHWPtr); + ramdacHWPtr = NULL; + + if (ramdacScrPtr) + xfree(ramdacScrPtr); + ramdacScrPtr = NULL; +} + +int +RamDacGetHWIndex() +{ + return RamDacHWPrivateIndex; +} + +int +RamDacGetScreenIndex() +{ + return RamDacScreenPrivateIndex; +} diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDac.h b/xorg-server/hw/xfree86/ramdac/xf86RamDac.h new file mode 100644 index 000000000..1f03dfb99 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86RamDac.h @@ -0,0 +1,123 @@ + +#ifndef _XF86RAMDAC_H +#define _XF86RAMDAC_H 1 + +#include "colormapst.h" +#include "xf86Cursor.h" + +/* Define unique vendor codes for RAMDAC's */ +#define VENDOR_IBM 0x0000 +#define VENDOR_BT 0x0001 +#define VENDOR_TI 0x0002 + +typedef struct _RamDacRegRec { +/* This is probably the nastiest assumption, we allocate 1024 slots for + * ramdac registers, should be enough. I've checked IBM and TVP series + * and they seem o.k + * Then we allocate 768 entries for the DAC too. IBM640 needs 1024 -FIXME + */ + unsigned short DacRegs[0x400]; /* register set */ + unsigned char DAC[0x300]; /* colour map */ + Bool Overlay; +} RamDacRegRec, *RamDacRegRecPtr; + +typedef struct _RamDacHWRegRec { + RamDacRegRec SavedReg; + RamDacRegRec ModeReg; +} RamDacHWRec, *RamDacHWRecPtr; + +typedef struct _RamDacRec { + CARD32 RamDacType; + + void (*LoadPalette)( + ScrnInfoPtr pScrn, + int numColors, + int *indices, + LOCO *colors, + VisualPtr pVisual + ); + + unsigned char (*ReadDAC)( + ScrnInfoPtr pScrn, + CARD32 + ); + + void (*WriteDAC)( + ScrnInfoPtr pScrn, + CARD32, + unsigned char, + unsigned char + ); + + void (*WriteAddress)( + ScrnInfoPtr pScrn, + CARD32 + ); + + void (*WriteData)( + ScrnInfoPtr pScrn, + unsigned char + ); + + void (*ReadAddress)( + ScrnInfoPtr pScrn, + CARD32 + ); + + unsigned char (*ReadData)( + ScrnInfoPtr pScrn + ); +} RamDacRec, *RamDacRecPtr; + +typedef struct _RamDacHelperRec { + CARD32 RamDacType; + + void (*Restore)( + ScrnInfoPtr pScrn, + RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg + ); + + void (*Save)( + ScrnInfoPtr pScrn, + RamDacRecPtr ramdacPtr, + RamDacRegRecPtr ramdacReg + ); + + void (*SetBpp)( + ScrnInfoPtr pScrn, + RamDacRegRecPtr ramdacReg + ); + + void (*HWCursorInit)( + xf86CursorInfoPtr infoPtr + ); +} RamDacHelperRec, *RamDacHelperRecPtr; + +#define RAMDACHWPTR(p) ((RamDacHWRecPtr)((p)->privates[RamDacGetHWIndex()].ptr)) + +typedef struct _RamdacScreenRec { + RamDacRecPtr RamDacRec; +} RamDacScreenRec, *RamDacScreenRecPtr; +#define RAMDACSCRPTR(p) ((RamDacScreenRecPtr)((p)->privates[RamDacGetScreenIndex()].ptr))->RamDacRec + +extern int RamDacHWPrivateIndex; +extern int RamDacScreenPrivateIndex; + +typedef struct { + int token; +} RamDacSupportedInfoRec, *RamDacSupportedInfoRecPtr; + +RamDacRecPtr RamDacCreateInfoRec(void); +RamDacHelperRecPtr RamDacHelperCreateInfoRec(void); +void RamDacDestroyInfoRec(RamDacRecPtr RamDacRec); +void RamDacHelperDestroyInfoRec(RamDacHelperRecPtr RamDacRec); +Bool RamDacInit(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec); +void RamDacSetGamma(ScrnInfoPtr pScrn, Bool Real8BitDac); +void RamDacRestoreDACValues(ScrnInfoPtr pScrn); +Bool RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits, + unsigned int flags); +void RamDacFreeRec(ScrnInfoPtr pScrn); +int RamDacGetHWIndex(void); + +#endif /* _XF86RAMDAC_H */ diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c b/xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c new file mode 100644 index 000000000..600fe3f07 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86RamDacCmap.c @@ -0,0 +1,74 @@ +/* + * Copyright 1998 by Alan Hourihane, Wigan, England. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> + * + * Generic RAMDAC access to colormaps. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "windowstr.h" +#include "mipointer.h" +#include "micmap.h" + +#include "xf86.h" +#include "compiler.h" +#include "colormapst.h" +#include "xf86RamDacPriv.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +void +RamDacLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, + VisualPtr pVisual) +{ + RamDacRecPtr hwp = RAMDACSCRPTR(pScrn); + int i, index; + + for (i = 0; i < numColors; i++) { + index = indices[i]; + (*hwp->WriteAddress)(pScrn, index); + (*hwp->WriteData)(pScrn, colors[index].red); + (*hwp->WriteData)(pScrn, colors[index].green); + (*hwp->WriteData)(pScrn, colors[index].blue); + } +} + +Bool +RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits, + unsigned int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RamDacRecPtr hwp = RAMDACSCRPTR(pScrn); + + if (hwp->LoadPalette == NULL) + return xf86HandleColormaps(pScreen, maxColors, sigRGBbits, + RamDacLoadPalette, NULL, flags); + else + return xf86HandleColormaps(pScreen, maxColors, sigRGBbits, + hwp->LoadPalette, NULL, flags); +} diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDacPriv.h b/xorg-server/hw/xfree86/ramdac/xf86RamDacPriv.h new file mode 100644 index 000000000..f68e588f5 --- /dev/null +++ b/xorg-server/hw/xfree86/ramdac/xf86RamDacPriv.h @@ -0,0 +1,13 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86RamDac.h" +#include "xf86cmap.h" + +void RamDacGetRecPrivate(void); +Bool RamDacGetRec(ScrnInfoPtr pScrn); +int RamDacGetScreenIndex(void); +void RamDacLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual); diff --git a/xorg-server/hw/xfree86/shadowfb/Makefile.am b/xorg-server/hw/xfree86/shadowfb/Makefile.am new file mode 100644 index 000000000..02d2dd4ea --- /dev/null +++ b/xorg-server/hw/xfree86/shadowfb/Makefile.am @@ -0,0 +1,9 @@ +module_LTLIBRARIES = libshadowfb.la +libshadowfb_la_LDFLAGS = -avoid-version +libshadowfb_la_SOURCES = sfbmodule.c shadow.c + +sdk_HEADERS = shadowfb.h + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xfree86/shadowfb/Makefile.in b/xorg-server/hw/xfree86/shadowfb/Makefile.in new file mode 100644 index 000000000..ad684bff8 --- /dev/null +++ b/xorg-server/hw/xfree86/shadowfb/Makefile.in @@ -0,0 +1,701 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/shadowfb +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libshadowfb_la_LIBADD = +am_libshadowfb_la_OBJECTS = sfbmodule.lo shadow.lo +libshadowfb_la_OBJECTS = $(am_libshadowfb_la_OBJECTS) +libshadowfb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libshadowfb_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libshadowfb_la_SOURCES) +DIST_SOURCES = $(libshadowfb_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libshadowfb.la +libshadowfb_la_LDFLAGS = -avoid-version +libshadowfb_la_SOURCES = sfbmodule.c shadow.c +sdk_HEADERS = shadowfb.h +INCLUDES = $(XORG_INCS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/shadowfb/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/shadowfb/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libshadowfb.la: $(libshadowfb_la_OBJECTS) $(libshadowfb_la_DEPENDENCIES) + $(libshadowfb_la_LINK) -rpath $(moduledir) $(libshadowfb_la_OBJECTS) $(libshadowfb_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfbmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shadow.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/shadowfb/sfbmodule.c b/xorg-server/hw/xfree86/shadowfb/sfbmodule.c new file mode 100644 index 000000000..ec37a1f8f --- /dev/null +++ b/xorg-server/hw/xfree86/shadowfb/sfbmodule.c @@ -0,0 +1,21 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static XF86ModuleVersionInfo VersRec = +{ + "shadowfb", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData shadowfbModuleData = { &VersRec, NULL, NULL }; diff --git a/xorg-server/hw/xfree86/shadowfb/shadow.c b/xorg-server/hw/xfree86/shadowfb/shadow.c new file mode 100644 index 000000000..74beefb67 --- /dev/null +++ b/xorg-server/hw/xfree86/shadowfb/shadow.c @@ -0,0 +1,1746 @@ +/* + Copyright (C) 1999. The XFree86 Project Inc. + + Written by Mark Vojkovich (mvojkovi@ucsd.edu) + + Pre-fb-write callbacks and RENDER support - Nolan Leake (nolan@vmware.com) +*/ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "pixmapstr.h" +#include "input.h" +#include <X11/fonts/font.h> +#include "mi.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "gcstruct.h" +#include "dixfontstr.h" +#include <X11/fonts/fontstruct.h> +#include "xf86.h" +#include "xf86str.h" +#include "shadowfb.h" + +#ifdef RENDER +# include "picturestr.h" +#endif + +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +static Bool ShadowCloseScreen (int i, ScreenPtr pScreen); +static void ShadowCopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgn +); +static Bool ShadowCreateGC(GCPtr pGC); +static Bool ShadowModifyPixmapHeader( + PixmapPtr pPixmap, + int width, + int height, + int depth, + int bitsPerPixel, + int devKind, + pointer pPixData +); + +static Bool ShadowEnterVT(int index, int flags); +static void ShadowLeaveVT(int index, int flags); + +#ifdef RENDER +static void ShadowComposite( + CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height +); +#endif /* RENDER */ + + +typedef struct { + ScrnInfoPtr pScrn; + RefreshAreaFuncPtr preRefresh; + RefreshAreaFuncPtr postRefresh; + CloseScreenProcPtr CloseScreen; + CopyWindowProcPtr CopyWindow; + CreateGCProcPtr CreateGC; + ModifyPixmapHeaderProcPtr ModifyPixmapHeader; +#ifdef RENDER + CompositeProcPtr Composite; +#endif /* RENDER */ + Bool (*EnterVT)(int, int); + void (*LeaveVT)(int, int); + Bool vtSema; +} ShadowScreenRec, *ShadowScreenPtr; + +typedef struct { + GCOps *ops; + GCFuncs *funcs; +} ShadowGCRec, *ShadowGCPtr; + + +static DevPrivateKey ShadowScreenKey = &ShadowScreenKey; +static DevPrivateKey ShadowGCKey = &ShadowGCKey; + +#define GET_SCREEN_PRIVATE(pScreen) \ + (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey) +#define GET_GC_PRIVATE(pGC) \ + (ShadowGCPtr)dixLookupPrivate(&(pGC)->devPrivates, ShadowGCKey); + +#define SHADOW_GC_FUNC_PROLOGUE(pGC)\ + ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\ + (pGC)->funcs = pGCPriv->funcs;\ + if(pGCPriv->ops)\ + (pGC)->ops = pGCPriv->ops + +#define SHADOW_GC_FUNC_EPILOGUE(pGC)\ + pGCPriv->funcs = (pGC)->funcs;\ + (pGC)->funcs = &ShadowGCFuncs;\ + if(pGCPriv->ops) {\ + pGCPriv->ops = (pGC)->ops;\ + (pGC)->ops = &ShadowGCOps;\ + } + +#define SHADOW_GC_OP_PROLOGUE(pGC)\ + ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pGC->pScreen); \ + ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\ + GCFuncs *oldFuncs = pGC->funcs;\ + pGC->funcs = pGCPriv->funcs;\ + pGC->ops = pGCPriv->ops + + +#define SHADOW_GC_OP_EPILOGUE(pGC)\ + pGCPriv->ops = pGC->ops;\ + pGC->funcs = oldFuncs;\ + pGC->ops = &ShadowGCOps + +#define IS_VISIBLE(pWin) (pPriv->vtSema && \ + (((WindowPtr)pWin)->visibility != VisibilityFullyObscured)) + +#define TRIM_BOX(box, pGC) { \ + BoxPtr extents = &pGC->pCompositeClip->extents;\ + if(box.x1 < extents->x1) box.x1 = extents->x1; \ + if(box.x2 > extents->x2) box.x2 = extents->x2; \ + if(box.y1 < extents->y1) box.y1 = extents->y1; \ + if(box.y2 > extents->y2) box.y2 = extents->y2; \ + } + +#define TRANSLATE_BOX(box, pDraw) { \ + box.x1 += pDraw->x; \ + box.x2 += pDraw->x; \ + box.y1 += pDraw->y; \ + box.y2 += pDraw->y; \ + } + +#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \ + TRANSLATE_BOX(box, pDraw); \ + TRIM_BOX(box, pGC); \ + } + +#define BOX_NOT_EMPTY(box) \ + (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) + + + +Bool +ShadowFBInit2 ( + ScreenPtr pScreen, + RefreshAreaFuncPtr preRefreshArea, + RefreshAreaFuncPtr postRefreshArea +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ShadowScreenPtr pPriv; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif /* RENDER */ + + if(!preRefreshArea && !postRefreshArea) return FALSE; + + if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec))) + return FALSE; + + if(!(pPriv = (ShadowScreenPtr)xalloc(sizeof(ShadowScreenRec)))) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, ShadowScreenKey, pPriv); + + pPriv->pScrn = pScrn; + pPriv->preRefresh = preRefreshArea; + pPriv->postRefresh = postRefreshArea; + pPriv->vtSema = TRUE; + + pPriv->CloseScreen = pScreen->CloseScreen; + pPriv->CopyWindow = pScreen->CopyWindow; + pPriv->CreateGC = pScreen->CreateGC; + pPriv->ModifyPixmapHeader = pScreen->ModifyPixmapHeader; + + pPriv->EnterVT = pScrn->EnterVT; + pPriv->LeaveVT = pScrn->LeaveVT; + + pScreen->CloseScreen = ShadowCloseScreen; + pScreen->CopyWindow = ShadowCopyWindow; + pScreen->CreateGC = ShadowCreateGC; + pScreen->ModifyPixmapHeader = ShadowModifyPixmapHeader; + + pScrn->EnterVT = ShadowEnterVT; + pScrn->LeaveVT = ShadowLeaveVT; + +#ifdef RENDER + if(ps) { + pPriv->Composite = ps->Composite; + ps->Composite = ShadowComposite; + } +#endif /* RENDER */ + + return TRUE; +} + +Bool +ShadowFBInit ( + ScreenPtr pScreen, + RefreshAreaFuncPtr refreshArea +){ + return ShadowFBInit2(pScreen, NULL, refreshArea); +} + +/**********************************************************/ + +static Bool +ShadowEnterVT(int index, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScrn->pScreen); + + if((*pPriv->EnterVT)(index, flags)) { + pPriv->vtSema = TRUE; + return TRUE; + } + + return FALSE; +} + +static void +ShadowLeaveVT(int index, int flags) +{ + ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(xf86Screens[index]->pScreen); + + pPriv->vtSema = FALSE; + + (*pPriv->LeaveVT)(index, flags); +} + +/**********************************************************/ + + +static Bool +ShadowCloseScreen (int i, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen); +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif /* RENDER */ + + pScreen->CloseScreen = pPriv->CloseScreen; + pScreen->CopyWindow = pPriv->CopyWindow; + pScreen->CreateGC = pPriv->CreateGC; + pScreen->ModifyPixmapHeader = pPriv->ModifyPixmapHeader; + + pScrn->EnterVT = pPriv->EnterVT; + pScrn->LeaveVT = pPriv->LeaveVT; + +#ifdef RENDER + if(ps) { + ps->Composite = pPriv->Composite; + } +#endif /* RENDER */ + + xfree((pointer)pPriv); + + return (*pScreen->CloseScreen) (i, pScreen); +} + +static void +ShadowCopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgn +){ + ScreenPtr pScreen = pWin->drawable.pScreen; + ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen); + int num = 0; + RegionRec rgnDst; + + if (pPriv->vtSema) { + REGION_NULL(pWin->drawable.pScreen, &rgnDst); + REGION_COPY(pWin->drawable.pScreen, &rgnDst, prgn); + + REGION_TRANSLATE(pWin->drawable.pScreen, &rgnDst, + pWin->drawable.x - ptOldOrg.x, + pWin->drawable.y - ptOldOrg.y); + REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, &rgnDst); + if ((num = REGION_NUM_RECTS(&rgnDst))) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst)); + } else { + REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); + } + } + + pScreen->CopyWindow = pPriv->CopyWindow; + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgn); + pScreen->CopyWindow = ShadowCopyWindow; + + if (num) { + if (pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst)); + REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); + } +} + +static Bool +ShadowModifyPixmapHeader( + PixmapPtr pPixmap, + int width, + int height, + int depth, + int bitsPerPixel, + int devKind, + pointer pPixData +) +{ + ScreenPtr pScreen; + ScrnInfoPtr pScrn; + ShadowScreenPtr pPriv; + Bool retval; + PixmapPtr pScreenPix; + + if (!pPixmap) + return FALSE; + + pScreen = pPixmap->drawable.pScreen; + pScrn = xf86Screens[pScreen->myNum]; + + pScreenPix = (*pScreen->GetScreenPixmap)(pScreen); + + if (pPixmap == pScreenPix && !pScrn->vtSema) + pScreenPix->devPrivate = pScrn->pixmapPrivate; + + pPriv = GET_SCREEN_PRIVATE(pScreen); + + pScreen->ModifyPixmapHeader = pPriv->ModifyPixmapHeader; + retval = (*pScreen->ModifyPixmapHeader)(pPixmap, + width, height, depth, bitsPerPixel, devKind, pPixData); + pScreen->ModifyPixmapHeader = ShadowModifyPixmapHeader; + + if (pPixmap == pScreenPix && !pScrn->vtSema) + { + pScrn->pixmapPrivate = pScreenPix->devPrivate; + pScreenPix->devPrivate.ptr = 0; + } + return retval; +} + +#ifdef RENDER +static void +ShadowComposite( + CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height +){ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen); + PictureScreenPtr ps = GetPictureScreen(pScreen); + BoxRec box; + BoxPtr extents; + Bool boxNotEmpty = FALSE; + + if (pPriv->vtSema + && pDst->pDrawable->type == DRAWABLE_WINDOW) { + + box.x1 = pDst->pDrawable->x + xDst; + box.y1 = pDst->pDrawable->y + yDst; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + + extents = &pDst->pCompositeClip->extents; + if(box.x1 < extents->x1) box.x1 = extents->x1; + if(box.x2 > extents->x2) box.x2 = extents->x2; + if(box.y1 < extents->y1) box.y1 = extents->y1; + if(box.y2 > extents->y2) box.y2 = extents->y2; + + if (BOX_NOT_EMPTY(box)) { + if (pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + ps->Composite = pPriv->Composite; + (*ps->Composite)(op, pSrc, pMask, pDst, xSrc, ySrc, + xMask, yMask, xDst, yDst, width, height); + ps->Composite = ShadowComposite; + + if (pPriv->postRefresh && boxNotEmpty) { + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + } +} +#endif /* RENDER */ + +/**********************************************************/ + +static void ShadowValidateGC(GCPtr, unsigned long, DrawablePtr); +static void ShadowChangeGC(GCPtr, unsigned long); +static void ShadowCopyGC(GCPtr, unsigned long, GCPtr); +static void ShadowDestroyGC(GCPtr); +static void ShadowChangeClip(GCPtr, int, pointer, int); +static void ShadowDestroyClip(GCPtr); +static void ShadowCopyClip(GCPtr, GCPtr); + +GCFuncs ShadowGCFuncs = { + ShadowValidateGC, ShadowChangeGC, ShadowCopyGC, ShadowDestroyGC, + ShadowChangeClip, ShadowDestroyClip, ShadowCopyClip +}; + + +extern GCOps ShadowGCOps; + +static Bool +ShadowCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen); + ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC); + Bool ret; + + pScreen->CreateGC = pPriv->CreateGC; + if((ret = (*pScreen->CreateGC) (pGC))) { + pGCPriv->ops = NULL; + pGCPriv->funcs = pGC->funcs; + pGC->funcs = &ShadowGCFuncs; + } + pScreen->CreateGC = ShadowCreateGC; + + return ret; +} + + +static void +ShadowValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + SHADOW_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + if(pDraw->type == DRAWABLE_WINDOW) + pGCPriv->ops = pGC->ops; /* just so it's not NULL */ + else + pGCPriv->ops = NULL; + SHADOW_GC_FUNC_EPILOGUE (pGC); +} + + +static void +ShadowDestroyGC(GCPtr pGC) +{ + SHADOW_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->DestroyGC)(pGC); + SHADOW_GC_FUNC_EPILOGUE (pGC); +} + +static void +ShadowChangeGC ( + GCPtr pGC, + unsigned long mask +){ + SHADOW_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + SHADOW_GC_FUNC_EPILOGUE (pGC); +} + +static void +ShadowCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst +){ + SHADOW_GC_FUNC_PROLOGUE (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + SHADOW_GC_FUNC_EPILOGUE (pGCDst); +} + +static void +ShadowChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects +){ + SHADOW_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + SHADOW_GC_FUNC_EPILOGUE (pGC); +} + +static void +ShadowCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + SHADOW_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + SHADOW_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +ShadowDestroyClip(GCPtr pGC) +{ + SHADOW_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + SHADOW_GC_FUNC_EPILOGUE (pGC); +} + + + + +/**********************************************************/ + + +static void +ShadowFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted +){ + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nInit) { + DDXPointPtr ppt = pptInit; + int *pwidth = pwidthInit; + int i = nInit; + BoxRec box; + Bool boxNotEmpty = FALSE; + + box.x1 = ppt->x; + box.x2 = box.x1 + *pwidth; + box.y2 = box.y1 = ppt->y; + + while(--i) { + ppt++; + pwidth++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + if(box.x2 < (ppt->x + *pwidth)) + box.x2 = ppt->x + *pwidth; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + + box.y2++; + + if(!pGC->miTranslate) { + TRANSLATE_BOX(box, pDraw); + } + TRIM_BOX(box, pGC); + + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + } else + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + DDXPointPtr pptInit, + int *pwidthInit, + int nspans, + int fSorted +){ + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nspans) { + DDXPointPtr ppt = pptInit; + int *pwidth = pwidthInit; + int i = nspans; + BoxRec box; + Bool boxNotEmpty = FALSE; + + box.x1 = ppt->x; + box.x2 = box.x1 + *pwidth; + box.y2 = box.y1 = ppt->y; + + while(--i) { + ppt++; + pwidth++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + if(box.x2 < (ppt->x + *pwidth)) + box.x2 = ppt->x + *pwidth; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + + box.y2++; + + if(!pGC->miTranslate) { + TRANSLATE_BOX(box, pDraw); + } + TRIM_BOX(box, pGC); + + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, + pwidthInit, nspans, fSorted); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + } else + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, + pwidthInit, nspans, fSorted); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw)) { + box.x1 = x + pDraw->x; + box.x2 = box.x1 + w; + box.y1 = y + pDraw->y; + box.y2 = box.y1 + h; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); + +} + +static RegionPtr +ShadowCopyArea( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + RegionPtr ret; + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDst)) { + box.x1 = dstx + pDst->x; + box.x2 = box.x1 + width; + box.y1 = dsty + pDst->y; + box.y2 = box.y1 + height; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); + + return ret; +} + +static RegionPtr +ShadowCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + RegionPtr ret; + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDst)) { + box.x1 = dstx + pDst->x; + box.x2 = box.x1 + width; + box.y1 = dsty + pDst->y; + box.y2 = box.y1 + height; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); + + return ret; +} + +static void +ShadowPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int nptInit, + xPoint *pptInit +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nptInit) { + xPoint *ppt = pptInit; + int npt = nptInit; + + box.x2 = box.x1 = pptInit->x; + box.y2 = box.y1 = pptInit->y; + + /* this could be slow if the points were spread out */ + + while(--npt) { + ppt++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + else if(box.x2 < ppt->x) box.x2 = ppt->x; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + + box.x2++; + box.y2++; + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, nptInit, pptInit); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int nptInit, + DDXPointPtr pptInit +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nptInit) { + DDXPointPtr ppt = pptInit; + int npt = nptInit; + int extra = pGC->lineWidth >> 1; + + box.x2 = box.x1 = pptInit->x; + box.y2 = box.y1 = pptInit->y; + + if(npt > 1) { + if(pGC->joinStyle == JoinMiter) + extra = 6 * pGC->lineWidth; + else if(pGC->capStyle == CapProjecting) + extra = pGC->lineWidth; + } + + if(mode == CoordModePrevious) { + int x = box.x1; + int y = box.y1; + while(--npt) { + ppt++; + x += ppt->x; + y += ppt->y; + if(box.x1 > x) box.x1 = x; + else if(box.x2 < x) box.x2 = x; + if(box.y1 > y) box.y1 = y; + else if(box.y2 < y) box.y2 = y; + } + } else { + while(--npt) { + ppt++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + else if(box.x2 < ppt->x) box.x2 = ppt->x; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + } + + box.x2++; + box.y2++; + + if(extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->Polylines)(pDraw, pGC, mode, nptInit, pptInit); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nsegInit, + xSegment *pSegInit +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nsegInit) { + int extra = pGC->lineWidth; + xSegment *pSeg = pSegInit; + int nseg = nsegInit; + + if(pGC->capStyle != CapProjecting) + extra >>= 1; + + if(pSeg->x2 > pSeg->x1) { + box.x1 = pSeg->x1; + box.x2 = pSeg->x2; + } else { + box.x2 = pSeg->x1; + box.x1 = pSeg->x2; + } + + if(pSeg->y2 > pSeg->y1) { + box.y1 = pSeg->y1; + box.y2 = pSeg->y2; + } else { + box.y2 = pSeg->y1; + box.y1 = pSeg->y2; + } + + while(--nseg) { + pSeg++; + if(pSeg->x2 > pSeg->x1) { + if(pSeg->x1 < box.x1) box.x1 = pSeg->x1; + if(pSeg->x2 > box.x2) box.x2 = pSeg->x2; + } else { + if(pSeg->x2 < box.x1) box.x1 = pSeg->x2; + if(pSeg->x1 > box.x2) box.x2 = pSeg->x1; + } + if(pSeg->y2 > pSeg->y1) { + if(pSeg->y1 < box.y1) box.y1 = pSeg->y1; + if(pSeg->y2 > box.y2) box.y2 = pSeg->y2; + } else { + if(pSeg->y2 < box.y1) box.y1 = pSeg->y2; + if(pSeg->y1 > box.y2) box.y2 = pSeg->y1; + } + } + + box.x2++; + box.y2++; + + if(extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->PolySegment)(pDraw, pGC, nsegInit, pSegInit); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + BoxRec box; + BoxPtr pBoxInit = NULL; + Bool boxNotEmpty = FALSE; + int num = 0; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nRectsInit) { + xRectangle *pRects = pRectsInit; + int nRects = nRectsInit; + + if(nRects >= 32) { + int extra = pGC->lineWidth >> 1; + + box.x1 = pRects->x; + box.x2 = box.x1 + pRects->width; + box.y1 = pRects->y; + box.y2 = box.y1 + pRects->height; + + while(--nRects) { + pRects++; + if(box.x1 > pRects->x) box.x1 = pRects->x; + if(box.x2 < (pRects->x + pRects->width)) + box.x2 = pRects->x + pRects->width; + if(box.y1 > pRects->y) box.y1 = pRects->y; + if(box.y2 < (pRects->y + pRects->height)) + box.y2 = pRects->y + pRects->height; + } + + if(extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + box.x2++; + box.y2++; + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } else { + BoxPtr pbox; + int offset1, offset2, offset3; + + offset2 = pGC->lineWidth; + if(!offset2) offset2 = 1; + offset1 = offset2 >> 1; + offset3 = offset2 - offset1; + + pBoxInit = (BoxPtr)xalloc(nRects * 4 * sizeof(BoxRec)); + pbox = pBoxInit; + + while(nRects--) { + pbox->x1 = pRects->x - offset1; + pbox->y1 = pRects->y - offset1; + pbox->x2 = pbox->x1 + pRects->width + offset2; + pbox->y2 = pbox->y1 + offset2; + TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC); + if(BOX_NOT_EMPTY((*pbox))) { + num++; + pbox++; + } + + pbox->x1 = pRects->x - offset1; + pbox->y1 = pRects->y + offset3; + pbox->x2 = pbox->x1 + offset2; + pbox->y2 = pbox->y1 + pRects->height - offset2; + TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC); + if(BOX_NOT_EMPTY((*pbox))) { + num++; + pbox++; + } + + pbox->x1 = pRects->x + pRects->width - offset1; + pbox->y1 = pRects->y + offset3; + pbox->x2 = pbox->x1 + offset2; + pbox->y2 = pbox->y1 + pRects->height - offset2; + TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC); + if(BOX_NOT_EMPTY((*pbox))) { + num++; + pbox++; + } + + pbox->x1 = pRects->x - offset1; + pbox->y1 = pRects->y + pRects->height - offset1; + pbox->x2 = pbox->x1 + pRects->width + offset2; + pbox->y2 = pbox->y1 + offset2; + TRIM_AND_TRANSLATE_BOX((*pbox), pDraw, pGC); + if(BOX_NOT_EMPTY((*pbox))) { + num++; + pbox++; + } + + pRects++; + } + + if(num) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, num, pBoxInit); + } else { + xfree(pBoxInit); + } + } + } + + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + + if(boxNotEmpty && pPriv->postRefresh) { + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + } else if(num) { + if(pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, num, pBoxInit); + xfree(pBoxInit); + } + + SHADOW_GC_OP_EPILOGUE(pGC); + +} + +static void +ShadowPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcsInit, + xArc *parcsInit +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && narcsInit) { + int narcs = narcsInit; + xArc *parcs = parcsInit; + int extra = pGC->lineWidth >> 1; + + box.x1 = parcs->x; + box.x2 = box.x1 + parcs->width; + box.y1 = parcs->y; + box.y2 = box.y1 + parcs->height; + + /* should I break these up instead ? */ + + while(--narcs) { + parcs++; + if(box.x1 > parcs->x) box.x1 = parcs->x; + if(box.x2 < (parcs->x + parcs->width)) + box.x2 = parcs->x + parcs->width; + if(box.y1 > parcs->y) box.y1 = parcs->y; + if(box.y2 < (parcs->y + parcs->height)) + box.y2 = parcs->y + parcs->height; + } + + if(extra) { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + box.x2++; + box.y2++; + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->PolyArc)(pDraw, pGC, narcsInit, parcsInit); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); + +} + +static void +ShadowFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr pptInit +){ + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && (count > 2)) { + DDXPointPtr ppt = pptInit; + int i = count; + BoxRec box; + Bool boxNotEmpty = FALSE; + + box.x2 = box.x1 = ppt->x; + box.y2 = box.y1 = ppt->y; + + if(mode != CoordModeOrigin) { + int x = box.x1; + int y = box.y1; + while(--i) { + ppt++; + x += ppt->x; + y += ppt->y; + if(box.x1 > x) box.x1 = x; + else if(box.x2 < x) box.x2 = x; + if(box.y1 > y) box.y1 = y; + else if(box.y2 < y) box.y2 = y; + } + } else { + while(--i) { + ppt++; + if(box.x1 > ppt->x) box.x1 = ppt->x; + else if(box.x2 < ppt->x) box.x2 = ppt->x; + if(box.y1 > ppt->y) box.y1 = ppt->y; + else if(box.y2 < ppt->y) box.y2 = ppt->y; + } + } + + box.x2++; + box.y2++; + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + } else + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + + +static void +ShadowPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nRectsInit) { + BoxRec box; + Bool boxNotEmpty = FALSE; + xRectangle *pRects = pRectsInit; + int nRects = nRectsInit; + + box.x1 = pRects->x; + box.x2 = box.x1 + pRects->width; + box.y1 = pRects->y; + box.y2 = box.y1 + pRects->height; + + while(--nRects) { + pRects++; + if(box.x1 > pRects->x) box.x1 = pRects->x; + if(box.x2 < (pRects->x + pRects->width)) + box.x2 = pRects->x + pRects->width; + if(box.y1 > pRects->y) box.y1 = pRects->y; + if(box.y2 < (pRects->y + pRects->height)) + box.y2 = pRects->y + pRects->height; + } + + /* cfb messes with the pRectsInit so we have to do our + calculations first */ + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + + (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + } else + (*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + + +static void +ShadowPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcsInit, + xArc *parcsInit +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && narcsInit) { + xArc *parcs = parcsInit; + int narcs = narcsInit; + + box.x1 = parcs->x; + box.x2 = box.x1 + parcs->width; + box.y1 = parcs->y; + box.y2 = box.y1 + parcs->height; + + /* should I break these up instead ? */ + + while(--narcs) { + parcs++; + if(box.x1 > parcs->x) box.x1 = parcs->x; + if(box.x2 < (parcs->x + parcs->width)) + box.x2 = parcs->x + parcs->width; + if(box.y1 > parcs->y) box.y1 = parcs->y; + if(box.y2 < (parcs->y + parcs->height)) + box.y2 = parcs->y + parcs->height; + } + + TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcsInit, parcsInit); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowTextExtent(FontPtr pFont, int count, char* chars, + FontEncoding fontEncoding, BoxPtr box) +{ + unsigned long n, i; + int w; + CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */ + + GetGlyphs(pFont, (unsigned long)count, (unsigned char *)chars, + fontEncoding, &n, charinfo); + w = 0; + for (i=0; i < n; i++) { + w += charinfo[i]->metrics.characterWidth; + } + if (i) { + w += charinfo[i - 1]->metrics.rightSideBearing; + } + + box->x1 = 0; + if (n) { + if (charinfo[0]->metrics.leftSideBearing < 0) { + box->x1 = charinfo[0]->metrics.leftSideBearing; + } + } + box->x2 = w; + box->y1 = -FONTMAXBOUNDS(pFont,ascent); + box->y2 = FONTMAXBOUNDS(pFont,descent); +} + + + +static void +ShadowFontToBox(BoxPtr BB, DrawablePtr pDrawable, GCPtr pGC, int x, int y, + int count, char *chars, int wide) +{ + FontPtr pFont; + + pFont = pGC->font; + if (pFont->info.constantWidth) { + int ascent, descent, left, right = 0; + + ascent = MAX(pFont->info.fontAscent, pFont->info.maxbounds.ascent); + descent = MAX(pFont->info.fontDescent, pFont->info.maxbounds.descent); + left = pFont->info.maxbounds.leftSideBearing; + if (count > 0) { + right = (count - 1) * pFont->info.maxbounds.characterWidth; + } + right += pFont->info.maxbounds.rightSideBearing; + BB->x1 = + MAX(pDrawable->x + x - left, (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->x1); + BB->y1 = + MAX(pDrawable->y + y - ascent, + (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->y1); + BB->x2 = + MIN(pDrawable->x + x + right, + (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->x2); + BB->y2 = + MIN(pDrawable->y + y + descent, + (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->y2); + } else { + ShadowTextExtent(pFont, count, chars, wide ? (FONTLASTROW(pFont) == 0) + ? Linear16Bit : TwoD16Bit : Linear8Bit, BB); + BB->x1 = + MAX(pDrawable->x + x + BB->x1, (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->x1); + BB->y1 = + MAX(pDrawable->y + y + BB->y1, + (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->y1); + BB->x2 = + MIN(pDrawable->x + x + BB->x2, + (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->x2); + BB->y2 = + MIN(pDrawable->y + y + BB->y2, + (REGION_EXTENTS(pGC->pScreen, + &((WindowPtr) pDrawable)->winSize))->y2); + } +} + +static int +ShadowPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + int width; + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw)) { + ShadowFontToBox(&box, pDraw, pGC, x, y, count, chars, 0); + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); + + return width; +} + +static int +ShadowPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + int width; + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw)) { + ShadowFontToBox(&box, pDraw, pGC, x, y, count, (char*)chars, 1); + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); + + return width; +} + +static void +ShadowImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && count) { + int top, bot, Min, Max; + + top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); + bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); + + Min = count * FONTMINBOUNDS(pGC->font, characterWidth); + if(Min > 0) Min = 0; + Max = count * FONTMAXBOUNDS(pGC->font, characterWidth); + if(Max < 0) Max = 0; + + /* ugh */ + box.x1 = pDraw->x + x + Min + + FONTMINBOUNDS(pGC->font, leftSideBearing); + box.x2 = pDraw->x + x + Max + + FONTMAXBOUNDS(pGC->font, rightSideBearing); + + box.y1 = pDraw->y + y - top; + box.y2 = pDraw->y + y + bot; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} +static void +ShadowImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && count) { + int top, bot, Min, Max; + + top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); + bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); + + Min = count * FONTMINBOUNDS(pGC->font, characterWidth); + if(Min > 0) Min = 0; + Max = count * FONTMAXBOUNDS(pGC->font, characterWidth); + if(Max < 0) Max = 0; + + /* ugh */ + box.x1 = pDraw->x + x + Min + + FONTMINBOUNDS(pGC->font, leftSideBearing); + box.x2 = pDraw->x + x + Max + + FONTMAXBOUNDS(pGC->font, rightSideBearing); + + box.y1 = pDraw->y + y - top; + box.y2 = pDraw->y + y + bot; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + + +static void +ShadowImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + unsigned int nglyphInit, + CharInfoPtr *ppciInit, + pointer pglyphBase +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nglyphInit) { + CharInfoPtr *ppci = ppciInit; + unsigned int nglyph = nglyphInit; + int top, bot, width = 0; + + top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font)); + bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font)); + + box.x1 = ppci[0]->metrics.leftSideBearing; + if(box.x1 > 0) box.x1 = 0; + box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing - + ppci[nglyph - 1]->metrics.characterWidth; + if(box.x2 < 0) box.x2 = 0; + + box.x2 += pDraw->x + x; + box.x1 += pDraw->x + x; + + while(nglyph--) { + width += (*ppci)->metrics.characterWidth; + ppci++; + } + + if(width > 0) + box.x2 += width; + else + box.x1 += width; + + box.y1 = pDraw->y + y - top; + box.y2 = pDraw->y + y + bot; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyphInit, + ppciInit, pglyphBase); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + unsigned int nglyphInit, + CharInfoPtr *ppciInit, + pointer pglyphBase +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw) && nglyphInit) { + CharInfoPtr *ppci = ppciInit; + unsigned int nglyph = nglyphInit; + + /* ugh */ + box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing; + box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing; + + if(nglyph > 1) { + int width = 0; + + while(--nglyph) { + width += (*ppci)->metrics.characterWidth; + ppci++; + } + + if(width > 0) box.x2 += width; + else box.x1 += width; + } + + box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent); + box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent); + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyphInit, + ppciInit, pglyphBase); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + +static void +ShadowPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg +){ + BoxRec box; + Bool boxNotEmpty = FALSE; + + SHADOW_GC_OP_PROLOGUE(pGC); + + if(IS_VISIBLE(pDraw)) { + box.x1 = xOrg; + box.y1 = yOrg; + + if(!pGC->miTranslate) { + box.x1 += pDraw->x; + box.y1 += pDraw->y; + } + + box.x2 = box.x1 + dx; + box.y2 = box.y1 + dy; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) { + if(pPriv->preRefresh) + (*pPriv->preRefresh)(pPriv->pScrn, 1, &box); + boxNotEmpty = TRUE; + } + } + + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + + if(boxNotEmpty && pPriv->postRefresh) + (*pPriv->postRefresh)(pPriv->pScrn, 1, &box); + + SHADOW_GC_OP_EPILOGUE(pGC); +} + + +GCOps ShadowGCOps = { + ShadowFillSpans, ShadowSetSpans, + ShadowPutImage, ShadowCopyArea, + ShadowCopyPlane, ShadowPolyPoint, + ShadowPolylines, ShadowPolySegment, + ShadowPolyRectangle, ShadowPolyArc, + ShadowFillPolygon, ShadowPolyFillRect, + ShadowPolyFillArc, ShadowPolyText8, + ShadowPolyText16, ShadowImageText8, + ShadowImageText16, ShadowImageGlyphBlt, + ShadowPolyGlyphBlt, ShadowPushPixels, + {NULL} /* devPrivate */ +}; + diff --git a/xorg-server/hw/xfree86/shadowfb/shadowfb.h b/xorg-server/hw/xfree86/shadowfb/shadowfb.h new file mode 100644 index 000000000..6c9635879 --- /dev/null +++ b/xorg-server/hw/xfree86/shadowfb/shadowfb.h @@ -0,0 +1,43 @@ + +#ifndef _SHADOWFB_H +#define _SHADOWFB_H + +#include "xf86str.h" + +/* + * User defined callback function. Passed a pointer to the ScrnInfo struct, + * the number of dirty rectangles, and a pointer to the first dirty rectangle + * in the array. + */ +typedef void (*RefreshAreaFuncPtr)(ScrnInfoPtr, int, BoxPtr); + +/* + * ShadowFBInit initializes the shadowfb subsystem. refreshArea is a pointer + * to a user supplied callback function. This function will be called after + * any operation that modifies the framebuffer. The newly dirtied rectangles + * are passed to the callback. + * + * Returns FALSE in the event of an error. + */ +Bool +ShadowFBInit ( + ScreenPtr pScreen, + RefreshAreaFuncPtr refreshArea +); + +/* + * ShadowFBInit2 is a more featureful refinement of the original shadowfb. + * ShadowFBInit2 allows you to specify two callbacks, one to be called + * immediately before an operation that modifies the framebuffer, and another + * to be called immediately after. + * + * Returns FALSE in the event of an error + */ +Bool +ShadowFBInit2 ( + ScreenPtr pScreen, + RefreshAreaFuncPtr preRefreshArea, + RefreshAreaFuncPtr postRefreshArea +); + +#endif /* _SHADOWFB_H */ diff --git a/xorg-server/hw/xfree86/utils/Makefile.am b/xorg-server/hw/xfree86/utils/Makefile.am new file mode 100644 index 000000000..e3e7a6177 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = \ + gtf \ + cvt \ + ioport \ + kbd_mode \ + xorgcfg \ + xorgconfig diff --git a/xorg-server/hw/xfree86/utils/Makefile.in b/xorg-server/hw/xfree86/utils/Makefile.in new file mode 100644 index 000000000..1a7c5f3b2 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/Makefile.in @@ -0,0 +1,697 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/utils +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +SUBDIRS = \ + gtf \ + cvt \ + ioport \ + kbd_mode \ + xorgcfg \ + xorgconfig + +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/utils/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/utils/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + ctags ctags-recursive distclean distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/utils/cvt/Makefile.am b/xorg-server/hw/xfree86/utils/cvt/Makefile.am new file mode 100644 index 000000000..4db175fbd --- /dev/null +++ b/xorg-server/hw/xfree86/utils/cvt/Makefile.am @@ -0,0 +1,47 @@ +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +bin_PROGRAMS = cvt + +INCLUDES = $(XORG_INCS) \ + -I$(top_srcdir)/hw/xfree86/ddc \ + -I$(top_srcdir)/hw/xfree86/parser +DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib + +# gah +cvt_SOURCES = cvt.c $(top_srcdir)/hw/xfree86/modes/xf86cvt.c +cvt_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +cvt_LDADD = $(top_builddir)/hw/xfree86/dummylib/libdummy-nonserver.a + +man1_MANS = cvt.man + +CLEANFILES = $(man1_MANS) + +include $(top_srcdir)/cpprules.in + +EXTRA_DIST = cvt.man.pre diff --git a/xorg-server/hw/xfree86/utils/cvt/Makefile.in b/xorg-server/hw/xfree86/utils/cvt/Makefile.in new file mode 100644 index 000000000..9c1b9c585 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/cvt/Makefile.in @@ -0,0 +1,836 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = cvt$(EXEEXT) +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/cpprules.in +subdir = hw/xfree86/utils/cvt +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_cvt_OBJECTS = cvt-cvt.$(OBJEXT) cvt-xf86cvt.$(OBJEXT) +cvt_OBJECTS = $(am_cvt_OBJECTS) +cvt_DEPENDENCIES = \ + $(top_builddir)/hw/xfree86/dummylib/libdummy-nonserver.a +cvt_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(cvt_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(cvt_SOURCES) +DIST_SOURCES = $(cvt_SOURCES) +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man1_MANS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +INCLUDES = $(XORG_INCS) \ + -I$(top_srcdir)/hw/xfree86/ddc \ + -I$(top_srcdir)/hw/xfree86/parser + +DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib + +# gah +cvt_SOURCES = cvt.c $(top_srcdir)/hw/xfree86/modes/xf86cvt.c +cvt_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +cvt_LDADD = $(top_builddir)/hw/xfree86/dummylib/libdummy-nonserver.a +man1_MANS = cvt.man +CLEANFILES = $(man1_MANS) +SUFFIXES = .pre .man .man.pre + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + +EXTRA_DIST = cvt.man.pre +all: all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/utils/cvt/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/utils/cvt/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +cvt$(EXEEXT): $(cvt_OBJECTS) $(cvt_DEPENDENCIES) + @rm -f cvt$(EXEEXT) + $(cvt_LINK) $(cvt_OBJECTS) $(cvt_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvt-cvt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvt-xf86cvt.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +cvt-cvt.o: cvt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -MT cvt-cvt.o -MD -MP -MF $(DEPDIR)/cvt-cvt.Tpo -c -o cvt-cvt.o `test -f 'cvt.c' || echo '$(srcdir)/'`cvt.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cvt-cvt.Tpo $(DEPDIR)/cvt-cvt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cvt.c' object='cvt-cvt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -c -o cvt-cvt.o `test -f 'cvt.c' || echo '$(srcdir)/'`cvt.c + +cvt-cvt.obj: cvt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -MT cvt-cvt.obj -MD -MP -MF $(DEPDIR)/cvt-cvt.Tpo -c -o cvt-cvt.obj `if test -f 'cvt.c'; then $(CYGPATH_W) 'cvt.c'; else $(CYGPATH_W) '$(srcdir)/cvt.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cvt-cvt.Tpo $(DEPDIR)/cvt-cvt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cvt.c' object='cvt-cvt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -c -o cvt-cvt.obj `if test -f 'cvt.c'; then $(CYGPATH_W) 'cvt.c'; else $(CYGPATH_W) '$(srcdir)/cvt.c'; fi` + +cvt-xf86cvt.o: $(top_srcdir)/hw/xfree86/modes/xf86cvt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -MT cvt-xf86cvt.o -MD -MP -MF $(DEPDIR)/cvt-xf86cvt.Tpo -c -o cvt-xf86cvt.o `test -f '$(top_srcdir)/hw/xfree86/modes/xf86cvt.c' || echo '$(srcdir)/'`$(top_srcdir)/hw/xfree86/modes/xf86cvt.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cvt-xf86cvt.Tpo $(DEPDIR)/cvt-xf86cvt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/hw/xfree86/modes/xf86cvt.c' object='cvt-xf86cvt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -c -o cvt-xf86cvt.o `test -f '$(top_srcdir)/hw/xfree86/modes/xf86cvt.c' || echo '$(srcdir)/'`$(top_srcdir)/hw/xfree86/modes/xf86cvt.c + +cvt-xf86cvt.obj: $(top_srcdir)/hw/xfree86/modes/xf86cvt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -MT cvt-xf86cvt.obj -MD -MP -MF $(DEPDIR)/cvt-xf86cvt.Tpo -c -o cvt-xf86cvt.obj `if test -f '$(top_srcdir)/hw/xfree86/modes/xf86cvt.c'; then $(CYGPATH_W) '$(top_srcdir)/hw/xfree86/modes/xf86cvt.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/hw/xfree86/modes/xf86cvt.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cvt-xf86cvt.Tpo $(DEPDIR)/cvt-xf86cvt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/hw/xfree86/modes/xf86cvt.c' object='cvt-xf86cvt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cvt_CFLAGS) $(CFLAGS) -c -o cvt-xf86cvt.obj `if test -f '$(top_srcdir)/hw/xfree86/modes/xf86cvt.c'; then $(CYGPATH_W) '$(top_srcdir)/hw/xfree86/modes/xf86cvt.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/hw/xfree86/modes/xf86cvt.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man1dir)/$$inst"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(MANS) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-man + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: install-man1 + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-man + +uninstall-man: uninstall-man1 + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-man1 install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-man \ + uninstall-man1 + + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c new file mode 100644 index 000000000..fee4f7c3e --- /dev/null +++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c @@ -0,0 +1,236 @@ +/* + * Copyright 2005-2006 Luc Verhaegen. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +/* Standalone VESA CVT standard timing modelines generator. */ + +#include "xf86.h" + +/* + * Quickly check wether this is a CVT standard mode. + */ +static Bool +CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, + Bool Verbose) +{ + Bool IsCVT = TRUE; + + if ((!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) || + (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) || + (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) || + (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) || + (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay))) + ; + else { + if (Verbose) + fprintf(stderr, "Warning: Aspect Ratio is not CVT standard.\n"); + IsCVT = FALSE; + } + + if ((VRefresh != 50.0) && (VRefresh != 60.0) && + (VRefresh != 75.0) && (VRefresh != 85.0)) { + if (Verbose) + fprintf(stderr, "Warning: Refresh Rate is not CVT standard " + "(50, 60, 75 or 85Hz).\n"); + IsCVT = FALSE; + } + + return IsCVT; +} + + +/* + * I'm not documenting --interlaced for obvious reasons, even though I did + * implement it. I also can't deny having looked at gtf here. + */ +static void +PrintUsage(char *Name) +{ + fprintf(stderr, "\n"); + fprintf(stderr, "usage: %s [-v|--verbose] [-r|--reduced] X Y [refresh]\n", + Name); + fprintf(stderr, "\n"); + fprintf(stderr, " -v|--verbose : Warn about CVT standard adherance.\n"); + fprintf(stderr, " -r|--reduced : Create a mode with reduced blanking " + "(default: normal blanking).\n"); + fprintf(stderr, " X : Desired horizontal resolution " + "(multiple of 8, required).\n"); + fprintf(stderr, " Y : Desired vertical resolution (required).\n"); + fprintf(stderr, " refresh : Desired refresh rate (default: 60.0Hz).\n"); + fprintf(stderr, "\n"); + + fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines" + " for use with X.\n"); +} + + +/* + * + */ +static void +PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced) +{ + printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh); + + if (CVT) { + printf("(CVT %.2fM", + ((float) Mode->HDisplay * Mode->VDisplay) / 1000000.0); + + if (!(Mode->VDisplay % 3) && + ((Mode->VDisplay * 4 / 3) == Mode->HDisplay)) + printf("3"); + else if (!(Mode->VDisplay % 9) && + ((Mode->VDisplay * 16 / 9) == Mode->HDisplay)) + printf("9"); + else if (!(Mode->VDisplay % 10) && + ((Mode->VDisplay * 16 / 10) == Mode->HDisplay)) + printf("A"); + else if (!(Mode->VDisplay % 4) && + ((Mode->VDisplay * 5 / 4) == Mode->HDisplay)) + printf("4"); + else if (!(Mode->VDisplay % 9) && + ((Mode->VDisplay * 15 / 9) == Mode->HDisplay)) + printf("9"); + + if (Reduced) + printf("-R"); + + printf(") "); + } else + printf("(CVT) "); + + printf("hsync: %.2f kHz; ", Mode->HSync); + printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0); + + printf("\n"); +} + + +/* + * Originally grabbed from xf86Mode.c. + * + * Ignoring the actual Mode->name, as the user will want something solid + * to grab hold of. + */ +static void +PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh, + Bool Reduced) +{ + if (Reduced) + printf("Modeline \"%dx%dR\" ", HDisplay, VDisplay); + else + printf("Modeline \"%dx%d_%.2f\" ", HDisplay, VDisplay, VRefresh); + + printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock/1000., Mode->HDisplay, + Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal, Mode->VDisplay, + Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal); + + if (Mode->Flags & V_INTERLACE) + printf(" interlace"); + if (Mode->Flags & V_PHSYNC) + printf(" +hsync"); + if (Mode->Flags & V_NHSYNC) + printf(" -hsync"); + if (Mode->Flags & V_PVSYNC) + printf(" +vsync"); + if (Mode->Flags & V_NVSYNC) + printf(" -vsync"); + + printf("\n"); +} + + +/* + * + */ +int +main (int argc, char *argv[]) +{ + DisplayModeRec *Mode; + int HDisplay = 0, VDisplay = 0; + float VRefresh = 0.0; + Bool Reduced = FALSE, Verbose = FALSE, IsCVT; + Bool Interlaced = FALSE; + int n; + + if ((argc < 3) || (argc > 7)) { + PrintUsage(argv[0]); + return 0; + } + + /* This doesn't filter out bad flags properly. Bad flags get passed down + * to atoi/atof, which then return 0, so that these variables can get + * filled next time round. So this is just a cosmetic problem. + */ + for (n = 1; n < argc; n++) { + if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced")) + Reduced = TRUE; + else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced")) + Interlaced = TRUE; + else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose")) + Verbose = TRUE; + else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) { + PrintUsage(argv[0]); + return 0; + } else if (!HDisplay) + HDisplay = atoi(argv[n]); + else if (!VDisplay) + VDisplay = atoi(argv[n]); + else if (!VRefresh) + VRefresh = atof(argv[n]); + else { + PrintUsage(argv[0]); + return 0; + } + } + + if (!HDisplay || !VDisplay) { + PrintUsage(argv[0]); + return 0; + } + + /* Default to 60.0Hz */ + if (!VRefresh) + VRefresh = 60.0; + + /* Horizontal timing is always a multiple of 8: round up. */ + if (HDisplay & 0x07) { + HDisplay &= ~0x07; + HDisplay += 8; + } + + if (Reduced && (VRefresh != 60.0)) { + fprintf(stderr, "\nERROR: 60Hz refresh rate required for reduced" + " blanking.\n"); + PrintUsage(argv[0]); + return 0; + } + + IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose); + + Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced); + + PrintComment(Mode, IsCVT, Reduced); + PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced); + + return 0; +} diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.man.pre b/xorg-server/hw/xfree86/utils/cvt/cvt.man.pre new file mode 100644 index 000000000..8a292eed8 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/cvt/cvt.man.pre @@ -0,0 +1,42 @@ +.\" $XFree86$ +.TH CVT 1 __vendorversion__ +.SH NAME +cvt - calculate VESA CVT mode lines +.SH SYNOPSIS +.B cvt +.RB [ \-v | \-\-verbose ] +.RB [ \-r | \-\-reduced ] +.I h-resolution +.I v-resolution +.RB [ refresh ] +.SH DESCRIPTION +.I Cvt +is a utility for calculating VESA Coordinated Video Timing modes. Given the +desired horizontal and vertical resolutions, a modeline adhering to the CVT +standard is printed. This modeline can be included in __xservername__ +.B __xconfigfile__(__filemansuffix__) +. + +.SH OPTIONS +.TP 8 +.BR refresh +Provide a vertical refresh rate in kHz. The CVT standard prefers either 50.0, +60.0, 75.0 or 85.0kHz. The default is 60.0kHz. +.TP 8 +.BR \-v | \-\-verbose +Warn verbosely when a given mode does not completely correspond with CVT +standards. +.TP 8 +.BR \-r | \-\-reduced +Create a mode with reduced blanking. This allows for higher frequency signals, +with a lower or equal dotclock. Not for Cathode Ray Tube based displays though. + +.SH "SEE ALSO" +__xconfigfile__(__filemansuffix__) +.SH AUTHOR +Luc Verhaegen. +.PP +This program is based on the Coordinated Video Timing sample +implementation written by Graham Loveridge. This file is publicly +available at <http://www.vesa.org/Public/CVT/CVTd6r1.xls>. CVT is a +VESA trademark. diff --git a/xorg-server/hw/xfree86/utils/gtf/Makefile.am b/xorg-server/hw/xfree86/utils/gtf/Makefile.am new file mode 100644 index 000000000..b14d0c13c --- /dev/null +++ b/xorg-server/hw/xfree86/utils/gtf/Makefile.am @@ -0,0 +1,50 @@ +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +bin_PROGRAMS = gtf + +gtf_SOURCES = gtf.c +gtf_CFLAGS = $(XORG_CFLAGS) +gtf_LDADD = -lm + +appmandir = $(APP_MAN_DIR) + +appman_PRE = gtf.man +appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) + +include $(top_srcdir)/cpprules.in + +EXTRA_DIST = gtf.man.pre +BUILT_SOURCES = $(appman_PRE) +CLEANFILES = $(appman_PRE) $(appman_DATA) + +SUFFIXES += .$(APP_MAN_SUFFIX) .man + +.man.$(APP_MAN_SUFFIX): + -rm -f $@ + $(LN_S) $< $@ diff --git a/xorg-server/hw/xfree86/utils/gtf/Makefile.in b/xorg-server/hw/xfree86/utils/gtf/Makefile.in new file mode 100644 index 000000000..2dd8c08f5 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/gtf/Makefile.in @@ -0,0 +1,800 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = gtf$(EXEEXT) +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/cpprules.in +subdir = hw/xfree86/utils/gtf +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appmandir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_gtf_OBJECTS = gtf-gtf.$(OBJEXT) +gtf_OBJECTS = $(am_gtf_OBJECTS) +gtf_DEPENDENCIES = +gtf_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(gtf_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(gtf_SOURCES) +DIST_SOURCES = $(gtf_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +appmanDATA_INSTALL = $(INSTALL_DATA) +DATA = $(appman_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +gtf_SOURCES = gtf.c +gtf_CFLAGS = $(XORG_CFLAGS) +gtf_LDADD = -lm +appmandir = $(APP_MAN_DIR) +appman_PRE = gtf.man +appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) +SUFFIXES = .pre .man .man.pre .$(APP_MAN_SUFFIX) .man + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + +EXTRA_DIST = gtf.man.pre +BUILT_SOURCES = $(appman_PRE) +CLEANFILES = $(appman_PRE) $(appman_DATA) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .$(APP_MAN_SUFFIX) .man .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/utils/gtf/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/utils/gtf/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +gtf$(EXEEXT): $(gtf_OBJECTS) $(gtf_DEPENDENCIES) + @rm -f gtf$(EXEEXT) + $(gtf_LINK) $(gtf_OBJECTS) $(gtf_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtf-gtf.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +gtf-gtf.o: gtf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtf_CFLAGS) $(CFLAGS) -MT gtf-gtf.o -MD -MP -MF $(DEPDIR)/gtf-gtf.Tpo -c -o gtf-gtf.o `test -f 'gtf.c' || echo '$(srcdir)/'`gtf.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gtf-gtf.Tpo $(DEPDIR)/gtf-gtf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gtf.c' object='gtf-gtf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtf_CFLAGS) $(CFLAGS) -c -o gtf-gtf.o `test -f 'gtf.c' || echo '$(srcdir)/'`gtf.c + +gtf-gtf.obj: gtf.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtf_CFLAGS) $(CFLAGS) -MT gtf-gtf.obj -MD -MP -MF $(DEPDIR)/gtf-gtf.Tpo -c -o gtf-gtf.obj `if test -f 'gtf.c'; then $(CYGPATH_W) 'gtf.c'; else $(CYGPATH_W) '$(srcdir)/gtf.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gtf-gtf.Tpo $(DEPDIR)/gtf-gtf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gtf.c' object='gtf-gtf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gtf_CFLAGS) $(CFLAGS) -c -o gtf-gtf.obj `if test -f 'gtf.c'; then $(CYGPATH_W) 'gtf.c'; else $(CYGPATH_W) '$(srcdir)/gtf.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-appmanDATA: $(appman_DATA) + @$(NORMAL_INSTALL) + test -z "$(appmandir)" || $(MKDIR_P) "$(DESTDIR)$(appmandir)" + @list='$(appman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(appmanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appmandir)/$$f'"; \ + $(appmanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appmandir)/$$f"; \ + done + +uninstall-appmanDATA: + @$(NORMAL_UNINSTALL) + @list='$(appman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(appmandir)/$$f'"; \ + rm -f "$(DESTDIR)$(appmandir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appmandir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-appmanDATA + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-appmanDATA uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-appmanDATA install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-appmanDATA \ + uninstall-binPROGRAMS + + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.$(APP_MAN_SUFFIX): + -rm -f $@ + $(LN_S) $< $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/utils/gtf/gtf.c b/xorg-server/hw/xfree86/utils/gtf/gtf.c new file mode 100644 index 000000000..fd4a4f23c --- /dev/null +++ b/xorg-server/hw/xfree86/utils/gtf/gtf.c @@ -0,0 +1,746 @@ +/* gtf.c Generate mode timings using the GTF Timing Standard + * + * gcc gtf.c -o gtf -lm -Wall + * + * Copyright (c) 2001, Andy Ritger aritger@nvidia.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * o Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * o Neither the name of NVIDIA nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * + * This program is based on the Generalized Timing Formula(GTF TM) + * Standard Version: 1.0, Revision: 1.0 + * + * The GTF Document contains the following Copyright information: + * + * Copyright (c) 1994, 1995, 1996 - Video Electronics Standards + * Association. Duplication of this document within VESA member + * companies for review purposes is permitted. All other rights + * reserved. + * + * While every precaution has been taken in the preparation + * of this standard, the Video Electronics Standards Association and + * its contributors assume no responsibility for errors or omissions, + * and make no warranties, expressed or implied, of functionality + * of suitability for any purpose. The sample code contained within + * this standard may be used without restriction. + * + * + * + * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive) + * implementation of the GTF Timing Standard, is available at: + * + * ftp://ftp.vesa.org/pub/GTF/GTF_V1R1.xls + * + * + * + * This program takes a desired resolution and vertical refresh rate, + * and computes mode timings according to the GTF Timing Standard. + * These mode timings can then be formatted as an XServer modeline + * or a mode description for use by fbset(8). + * + * + * + * NOTES: + * + * The GTF allows for computation of "margins" (the visible border + * surrounding the addressable video); on most non-overscan type + * systems, the margin period is zero. I've implemented the margin + * computations but not enabled it because 1) I don't really have + * any experience with this, and 2) neither XServer modelines nor + * fbset fb.modes provide an obvious way for margin timings to be + * included in their mode descriptions (needs more investigation). + * + * The GTF provides for computation of interlaced mode timings; + * I've implemented the computations but not enabled them, yet. + * I should probably enable and test this at some point. + * + * + * + * TODO: + * + * o Add support for interlaced modes. + * + * o Implement the other portions of the GTF: compute mode timings + * given either the desired pixel clock or the desired horizontal + * frequency. + * + * o It would be nice if this were more general purpose to do things + * outside the scope of the GTF: like generate double scan mode + * timings, for example. + * + * o Printing digits to the right of the decimal point when the + * digits are 0 annoys me. + * + * o Error checking. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +# include <xorg-config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + + +#if defined(__Lynx__) +#define rint(x) floor(x) +#endif + +#define MARGIN_PERCENT 1.8 /* % of active vertical image */ +#define CELL_GRAN 8.0 /* assumed character cell granularity */ +#define MIN_PORCH 1 /* minimum front porch */ +#define V_SYNC_RQD 3 /* width of vsync in lines */ +#define H_SYNC_PERCENT 8.0 /* width of hsync as % of total line */ +#define MIN_VSYNC_PLUS_BP 550.0 /* min time of vsync + back porch (microsec) */ +#define M 600.0 /* blanking formula gradient */ +#define C 40.0 /* blanking formula offset */ +#define K 128.0 /* blanking formula scaling factor */ +#define J 20.0 /* blanking formula scaling factor */ + +/* C' and M' are part of the Blanking Duty Cycle computation */ + +#define C_PRIME (((C - J) * K/256.0) + J) +#define M_PRIME (K/256.0 * M) + + +/* struct definitions */ + +typedef struct __mode +{ + int hr, hss, hse, hfl; + int vr, vss, vse, vfl; + float pclk, h_freq, v_freq; +} mode; + + +typedef struct __options +{ + int x, y; + int xorgmode, fbmode; + float v_freq; +} options; + + + + +/* prototypes */ + +void print_value(int n, char *name, float val); +void print_xf86_mode (mode *m); +void print_fb_mode (mode *m); +mode *vert_refresh (int h_pixels, int v_lines, float freq, + int interlaced, int margins); +options *parse_command_line (int argc, char *argv[]); + + + + +/* + * print_value() - print the result of the named computation; this is + * useful when comparing against the GTF EXCEL spreadsheet. + */ + +int global_verbose = 0; + +void print_value(int n, char *name, float val) +{ + if (global_verbose) { + printf("%2d: %-27s: %15f\n", n, name, val); + } +} + + + +/* print_xf86_mode() - print the XServer modeline, given mode timings. */ + +void print_xf86_mode (mode *m) +{ + printf ("\n"); + printf (" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n", + m->hr, m->vr, m->v_freq, m->h_freq, m->pclk); + + printf (" Modeline \"%dx%d_%.2f\" %.2f" + " %d %d %d %d" + " %d %d %d %d" + " -HSync +Vsync\n\n", + m->hr, m->vr, m->v_freq, m->pclk, + m->hr, m->hss, m->hse, m->hfl, + m->vr, m->vss, m->vse, m->vfl); + +} + + + +/* + * print_fb_mode() - print a mode description in fbset(8) format; + * see the fb.modes(8) manpage. The timing description used in + * this is rather odd; they use "left and right margin" to refer + * to the portion of the hblank before and after the sync pulse + * by conceptually wrapping the portion of the blank after the pulse + * to infront of the visible region; ie: + * + * + * Timing description I'm accustomed to: + * + * + * + * <--------1--------> <--2--> <--3--> <--4--> + * _________ + * |-------------------|_______| |_______ + * + * R SS SE FL + * + * 1: visible image + * 2: blank before sync (aka front porch) + * 3: sync pulse + * 4: blank after sync (aka back porch) + * R: Resolution + * SS: Sync Start + * SE: Sync End + * FL: Frame Length + * + * + * But the fb.modes format is: + * + * + * <--4--> <--------1--------> <--2--> <--3--> + * _________ + * _______|-------------------|_______| | + * + * The fb.modes(8) manpage refers to <4> and <2> as the left and + * right "margin" (as well as upper and lower margin in the vertical + * direction) -- note that this has nothing to do with the term + * "margin" used in the GTF Timing Standard. + * + * XXX always prints the 32 bit mode -- should I provide a command + * line option to specify the bpp? It's simple enough for a user + * to edit the mode description after it's generated. + */ + +void print_fb_mode (mode *m) +{ + printf ("\n"); + printf ("mode \"%dx%d %.2fHz 32bit (GTF)\"\n", + m->hr, m->vr, m->v_freq); + printf (" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n", + m->pclk, m->h_freq, m->v_freq); + printf (" geometry %d %d %d %d 32\n", + m->hr, m->vr, m->hr, m->vr); + printf (" timings %d %d %d %d %d %d %d\n", + (int) rint(1000000.0/m->pclk),/* pixclock in picoseconds */ + m->hfl - m->hse, /* left margin (in pixels) */ + m->hss - m->hr, /* right margin (in pixels) */ + m->vfl - m->vse, /* upper margin (in pixel lines) */ + m->vss - m->vr, /* lower margin (in pixel lines) */ + m->hse - m->hss, /* horizontal sync length (pixels) */ + m->vse - m->vss); /* vert sync length (pixel lines) */ + printf (" hsync low\n"); + printf (" vsync high\n"); + printf ("endmode\n\n"); + +} + + + + +/* + * vert_refresh() - as defined by the GTF Timing Standard, compute the + * Stage 1 Parameters using the vertical refresh frequency. In other + * words: input a desired resolution and desired refresh rate, and + * output the GTF mode timings. + * + * XXX All the code is in place to compute interlaced modes, but I don't + * feel like testing it right now. + * + * XXX margin computations are implemented but not tested (nor used by + * XServer of fbset mode descriptions, from what I can tell). + */ + +mode *vert_refresh (int h_pixels, int v_lines, float freq, + int interlaced, int margins) +{ + float h_pixels_rnd; + float v_lines_rnd; + float v_field_rate_rqd; + float top_margin; + float bottom_margin; + float interlace; + float h_period_est; + float vsync_plus_bp; + float v_back_porch; + float total_v_lines; + float v_field_rate_est; + float h_period; + float v_field_rate; + float v_frame_rate; + float left_margin; + float right_margin; + float total_active_pixels; + float ideal_duty_cycle; + float h_blank; + float total_pixels; + float pixel_freq; + float h_freq; + + float h_sync; + float h_front_porch; + float v_odd_front_porch_lines; + + mode *m = (mode*) malloc (sizeof (mode)); + + + /* 1. In order to give correct results, the number of horizontal + * pixels requested is first processed to ensure that it is divisible + * by the character size, by rounding it to the nearest character + * cell boundary: + * + * [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND]) + */ + + h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN; + + print_value(1, "[H PIXELS RND]", h_pixels_rnd); + + + /* 2. If interlace is requested, the number of vertical lines assumed + * by the calculation must be halved, as the computation calculates + * the number of vertical lines per field. In either case, the + * number of lines is rounded to the nearest integer. + * + * [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0), + * ROUND([V LINES],0)) + */ + + v_lines_rnd = interlaced ? + rint((float) v_lines) / 2.0 : + rint((float) v_lines); + + print_value(2, "[V LINES RND]", v_lines_rnd); + + + /* 3. Find the frame rate required: + * + * [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2, + * [I/P FREQ RQD]) + */ + + v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq); + + print_value(3, "[V FIELD RATE RQD]", v_field_rate_rqd); + + + /* 4. Find number of lines in Top margin: + * + * [TOP MARGIN (LINES)] = IF([MARGINS RQD?]="Y", + * ROUND(([MARGIN%]/100*[V LINES RND]),0), + * 0) + */ + + top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0); + + print_value(4, "[TOP MARGIN (LINES)]", top_margin); + + + /* 5. Find number of lines in Bottom margin: + * + * [BOT MARGIN (LINES)] = IF([MARGINS RQD?]="Y", + * ROUND(([MARGIN%]/100*[V LINES RND]),0), + * 0) + */ + + bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0); + + print_value(5, "[BOT MARGIN (LINES)]", bottom_margin); + + + /* 6. If interlace is required, then set variable [INTERLACE]=0.5: + * + * [INTERLACE]=(IF([INT RQD?]="y",0.5,0)) + */ + + interlace = interlaced ? 0.5 : 0.0; + + print_value(6, "[INTERLACE]", interlace); + + + /* 7. Estimate the Horizontal period + * + * [H PERIOD EST] = ((1/[V FIELD RATE RQD]) - [MIN VSYNC+BP]/1000000) / + * ([V LINES RND] + (2*[TOP MARGIN (LINES)]) + + * [MIN PORCH RND]+[INTERLACE]) * 1000000 + */ + + h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0)) + / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace) + * 1000000.0); + + print_value(7, "[H PERIOD EST]", h_period_est); + + + /* 8. Find the number of lines in V sync + back porch: + * + * [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0) + */ + + vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est); + + print_value(8, "[V SYNC+BP]", vsync_plus_bp); + + + /* 9. Find the number of lines in V back porch alone: + * + * [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND] + * + * XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]? + */ + + v_back_porch = vsync_plus_bp - V_SYNC_RQD; + + print_value(9, "[V BACK PORCH]", v_back_porch); + + + /* 10. Find the total number of lines in Vertical field period: + * + * [TOTAL V LINES] = [V LINES RND] + [TOP MARGIN (LINES)] + + * [BOT MARGIN (LINES)] + [V SYNC+BP] + [INTERLACE] + + * [MIN PORCH RND] + */ + + total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp + + interlace + MIN_PORCH; + + print_value(10, "[TOTAL V LINES]", total_v_lines); + + + /* 11. Estimate the Vertical field frequency: + * + * [V FIELD RATE EST] = 1 / [H PERIOD EST] / [TOTAL V LINES] * 1000000 + */ + + v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0; + + print_value(11, "[V FIELD RATE EST]", v_field_rate_est); + + + /* 12. Find the actual horizontal period: + * + * [H PERIOD] = [H PERIOD EST] / ([V FIELD RATE RQD] / [V FIELD RATE EST]) + */ + + h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est); + + print_value(12, "[H PERIOD]", h_period); + + + /* 13. Find the actual Vertical field frequency: + * + * [V FIELD RATE] = 1 / [H PERIOD] / [TOTAL V LINES] * 1000000 + */ + + v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0; + + print_value(13, "[V FIELD RATE]", v_field_rate); + + + /* 14. Find the Vertical frame frequency: + * + * [V FRAME RATE] = (IF([INT RQD?]="y", [V FIELD RATE]/2, [V FIELD RATE])) + */ + + v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate; + + print_value(14, "[V FRAME RATE]", v_frame_rate); + + + /* 15. Find number of pixels in left margin: + * + * [LEFT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y", + * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 / + * [CELL GRAN RND]),0)) * [CELL GRAN RND], + * 0)) + */ + + left_margin = margins ? + rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN : + 0.0; + + print_value(15, "[LEFT MARGIN (PIXELS)]", left_margin); + + + /* 16. Find number of pixels in right margin: + * + * [RIGHT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y", + * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 / + * [CELL GRAN RND]),0)) * [CELL GRAN RND], + * 0)) + */ + + right_margin = margins ? + rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN : + 0.0; + + print_value(16, "[RIGHT MARGIN (PIXELS)]", right_margin); + + + /* 17. Find total number of active pixels in image and left and right + * margins: + * + * [TOTAL ACTIVE PIXELS] = [H PIXELS RND] + [LEFT MARGIN (PIXELS)] + + * [RIGHT MARGIN (PIXELS)] + */ + + total_active_pixels = h_pixels_rnd + left_margin + right_margin; + + print_value(17, "[TOTAL ACTIVE PIXELS]", total_active_pixels); + + + /* 18. Find the ideal blanking duty cycle from the blanking duty cycle + * equation: + * + * [IDEAL DUTY CYCLE] = [C'] - ([M']*[H PERIOD]/1000) + */ + + ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0); + + print_value(18, "[IDEAL DUTY CYCLE]", ideal_duty_cycle); + + + /* 19. Find the number of pixels in the blanking time to the nearest + * double character cell: + * + * [H BLANK (PIXELS)] = (ROUND(([TOTAL ACTIVE PIXELS] * + * [IDEAL DUTY CYCLE] / + * (100-[IDEAL DUTY CYCLE]) / + * (2*[CELL GRAN RND])), 0)) + * * (2*[CELL GRAN RND]) + */ + + h_blank = rint(total_active_pixels * + ideal_duty_cycle / + (100.0 - ideal_duty_cycle) / + (2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN); + + print_value(19, "[H BLANK (PIXELS)]", h_blank); + + + /* 20. Find total number of pixels: + * + * [TOTAL PIXELS] = [TOTAL ACTIVE PIXELS] + [H BLANK (PIXELS)] + */ + + total_pixels = total_active_pixels + h_blank; + + print_value(20, "[TOTAL PIXELS]", total_pixels); + + + /* 21. Find pixel clock frequency: + * + * [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD] + */ + + pixel_freq = total_pixels / h_period; + + print_value(21, "[PIXEL FREQ]", pixel_freq); + + + /* 22. Find horizontal frequency: + * + * [H FREQ] = 1000 / [H PERIOD] + */ + + h_freq = 1000.0 / h_period; + + print_value(22, "[H FREQ]", h_freq); + + + + /* Stage 1 computations are now complete; I should really pass + the results to another function and do the Stage 2 + computations, but I only need a few more values so I'll just + append the computations here for now */ + + + + /* 17. Find the number of pixels in the horizontal sync period: + * + * [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] / + * [CELL GRAN RND]),0))*[CELL GRAN RND] + */ + + h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN; + + print_value(17, "[H SYNC (PIXELS)]", h_sync); + + + /* 18. Find the number of pixels in the horizontal front porch period: + * + * [H FRONT PORCH (PIXELS)] = ([H BLANK (PIXELS)]/2)-[H SYNC (PIXELS)] + */ + + h_front_porch = (h_blank / 2.0) - h_sync; + + print_value(18, "[H FRONT PORCH (PIXELS)]", h_front_porch); + + + /* 36. Find the number of lines in the odd front porch period: + * + * [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE]) + */ + + v_odd_front_porch_lines = MIN_PORCH + interlace; + + print_value(36, "[V ODD FRONT PORCH(LINES)]", v_odd_front_porch_lines); + + + /* finally, pack the results in the mode struct */ + + m->hr = (int) (h_pixels_rnd); + m->hss = (int) (h_pixels_rnd + h_front_porch); + m->hse = (int) (h_pixels_rnd + h_front_porch + h_sync); + m->hfl = (int) (total_pixels); + + m->vr = (int) (v_lines_rnd); + m->vss = (int) (v_lines_rnd + v_odd_front_porch_lines); + m->vse = (int) (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD); + m->vfl = (int) (total_v_lines); + + m->pclk = pixel_freq; + m->h_freq = h_freq; + m->v_freq = freq; + + return (m); + +} + + + + +/* + * parse_command_line() - parse the command line and return an + * alloced structure containing the results. On error print usage + * and return NULL. + */ + +options *parse_command_line (int argc, char *argv[]) +{ + int n; + + options *o = (options *) calloc (1, sizeof (options)); + + if (argc < 4) goto bad_option; + + o->x = atoi (argv[1]); + o->y = atoi (argv[2]); + o->v_freq = atof (argv[3]); + + /* XXX should check for errors in the above */ + + n = 4; + + while (n < argc) { + if ((strcmp (argv[n], "-v") == 0) || + (strcmp (argv[n], "--verbose") == 0)) { + global_verbose = 1; + } else if ((strcmp (argv[n], "-f") == 0) || + (strcmp (argv[n], "--fbmode") == 0)) { + o->fbmode = 1; + } else if ((strcmp (argv[n], "-x") == 0) || + (strcmp (argv[n], "--xorgmode") == 0) || + (strcmp (argv[n], "--xf86mode") == 0)) { + o->xorgmode = 1; + } else { + goto bad_option; + } + + n++; + } + + /* if neither xorgmode nor fbmode were requested, default to + xorgmode */ + + if (!o->fbmode && !o->xorgmode) o->xorgmode = 1; + + return (o); + + bad_option: + + fprintf (stderr, "\n"); + fprintf (stderr, "usage: %s x y refresh [-v|--verbose] " + "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]); + + fprintf (stderr, "\n"); + + fprintf (stderr, " x : the desired horizontal " + "resolution (required)\n"); + fprintf (stderr, " y : the desired vertical " + "resolution (required)\n"); + fprintf (stderr, " refresh : the desired refresh " + "rate (required)\n"); + fprintf (stderr, " -v|--verbose : enable verbose printouts " + "(traces each step of the computation)\n"); + fprintf (stderr, " -f|--fbmode : output an fbset(8)-style mode " + "description\n"); + fprintf (stderr, " -x|--xorgmode : output an "__XSERVERNAME__"-style mode " + "description (this is the default\n" + " if no mode description is requested)\n"); + + fprintf (stderr, "\n"); + + free (o); + return (NULL); + +} + + + +int main (int argc, char *argv[]) +{ + mode *m; + options *o; + + o = parse_command_line (argc, argv); + if (!o) exit (1); + + m = vert_refresh (o->x, o->y, o->v_freq, 0, 0); + if (!m) exit (1); + + if (o->xorgmode) + print_xf86_mode(m); + + if (o->fbmode) + print_fb_mode(m); + + return 0; + +} diff --git a/xorg-server/hw/xfree86/utils/gtf/gtf.man.pre b/xorg-server/hw/xfree86/utils/gtf/gtf.man.pre new file mode 100644 index 000000000..74ade74cb --- /dev/null +++ b/xorg-server/hw/xfree86/utils/gtf/gtf.man.pre @@ -0,0 +1,45 @@ +.\" $XFree86$ +.TH GTF 1 __vendorversion__ +.SH NAME +gtf - calculate VESA GTF mode lines +.SH SYNOPSIS +.B gtf +.I h-resolution +.I v-resolution +.I refresh +.RB [ \-v | \-\-verbose ] +.RB [ \-f | \-\-fbmode ] +.RB [ \-x | \-\-xorgmode ] +.SH DESCRIPTION +.I Gtf +is a utility for calculating VESA GTF modes. Given the desired +horizontal and vertical resolutions and refresh rate (in Hz), the parameters +for a matching VESA GTF mode are printed out. Two output formats are +supported: mode lines suitable for the __xservername__ +.B __xconfigfile__(__filemansuffix__) +file, and mode parameters suitable for the Linux +.B fbset(8) +utility. + +.SH OPTIONS +.TP 8 +.BR \-v | \-\-verbose +Enable verbose printouts This shows a trace for each step of the +computation. +.TP 8 +.BR \-x | \-\-xorgmode +Print the mode parameters as __xservername__-style mode lines. This is the +default format. +.TP 8 +.BR \-f | \-\-fbset +Print the mode parameters in a format suitable for +.BR fbset(8) . +.SH "SEE ALSO" +__xconfigfile__(__filemansuffix__) +.SH AUTHOR +Andy Ritger. +.PP +This program is based on the Generalized Timing Formula (GTF(TM)) Standard +Version: 1.0, Revision: 1.0. The GTF Excel(TM) spreadsheet, a sample +(and the definitive) implementation of the GTF Timing Standard is +available at <ftp://ftp.vesa.org/pub/GTF/VTF_V1R1.xls>. diff --git a/xorg-server/hw/xfree86/utils/ioport/Makefile.am b/xorg-server/hw/xfree86/utils/ioport/Makefile.am new file mode 100644 index 000000000..12f861372 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/ioport/Makefile.am @@ -0,0 +1,58 @@ +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +bin_PROGRAMS = ioport + +XFREE86_SRCDIR = $(top_srcdir)/hw/xfree86 +DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib + +INCLUDES = $(XORG_INCS) -I$(DUMMYLIB_SRCDIR) + +ioport_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +ioport_LDADD = \ + ../../os-support/libxorgos.la \ + ../../dummylib/libdummy-nonserver.a \ + ${UTILS_SYS_LIBS} ${PCIACCESS_LIBS} + + +ioport_SOURCES = \ + ioport.c + +ioport_PROGRAM_LINKS = inb inw inl outb outw outl + +all-local: + @for i in $(ioport_PROGRAM_LINKS); do (set -x; \ + rm -f $$i; $(LN_S) ioport $$i); \ + done + +install-exec-hook: + @for i in $(ioport_PROGRAM_LINKS); do (set -x; \ + rm -f $(DESTDIR)$(bindir)/$$i; \ + (cd $(DESTDIR)$(bindir); $(LN_S) ioport $$i)); \ + done + diff --git a/xorg-server/hw/xfree86/utils/ioport/Makefile.in b/xorg-server/hw/xfree86/utils/ioport/Makefile.in new file mode 100644 index 000000000..f2afaa3cc --- /dev/null +++ b/xorg-server/hw/xfree86/utils/ioport/Makefile.in @@ -0,0 +1,739 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = ioport$(EXEEXT) +subdir = hw/xfree86/utils/ioport +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_ioport_OBJECTS = ioport-ioport.$(OBJEXT) +ioport_OBJECTS = $(am_ioport_OBJECTS) +am__DEPENDENCIES_1 = +ioport_DEPENDENCIES = ../../os-support/libxorgos.la \ + ../../dummylib/libdummy-nonserver.a $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +ioport_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(ioport_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(ioport_SOURCES) +DIST_SOURCES = $(ioport_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +XFREE86_SRCDIR = $(top_srcdir)/hw/xfree86 +DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dummylib +INCLUDES = $(XORG_INCS) -I$(DUMMYLIB_SRCDIR) +ioport_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +ioport_LDADD = \ + ../../os-support/libxorgos.la \ + ../../dummylib/libdummy-nonserver.a \ + ${UTILS_SYS_LIBS} ${PCIACCESS_LIBS} + +ioport_SOURCES = \ + ioport.c + +ioport_PROGRAM_LINKS = inb inw inl outb outw outl +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/utils/ioport/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/utils/ioport/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ioport$(EXEEXT): $(ioport_OBJECTS) $(ioport_DEPENDENCIES) + @rm -f ioport$(EXEEXT) + $(ioport_LINK) $(ioport_OBJECTS) $(ioport_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioport-ioport.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +ioport-ioport.o: ioport.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ioport_CFLAGS) $(CFLAGS) -MT ioport-ioport.o -MD -MP -MF $(DEPDIR)/ioport-ioport.Tpo -c -o ioport-ioport.o `test -f 'ioport.c' || echo '$(srcdir)/'`ioport.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ioport-ioport.Tpo $(DEPDIR)/ioport-ioport.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ioport.c' object='ioport-ioport.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ioport_CFLAGS) $(CFLAGS) -c -o ioport-ioport.o `test -f 'ioport.c' || echo '$(srcdir)/'`ioport.c + +ioport-ioport.obj: ioport.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ioport_CFLAGS) $(CFLAGS) -MT ioport-ioport.obj -MD -MP -MF $(DEPDIR)/ioport-ioport.Tpo -c -o ioport-ioport.obj `if test -f 'ioport.c'; then $(CYGPATH_W) 'ioport.c'; else $(CYGPATH_W) '$(srcdir)/ioport.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ioport-ioport.Tpo $(DEPDIR)/ioport-ioport.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ioport.c' object='ioport-ioport.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ioport_CFLAGS) $(CFLAGS) -c -o ioport-ioport.obj `if test -f 'ioport.c'; then $(CYGPATH_W) 'ioport.c'; else $(CYGPATH_W) '$(srcdir)/ioport.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) all-local +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-exec-am install-strip + +.PHONY: CTAGS GTAGS all all-am all-local check check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-exec-hook install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS + + +all-local: + @for i in $(ioport_PROGRAM_LINKS); do (set -x; \ + rm -f $$i; $(LN_S) ioport $$i); \ + done + +install-exec-hook: + @for i in $(ioport_PROGRAM_LINKS); do (set -x; \ + rm -f $(DESTDIR)$(bindir)/$$i; \ + (cd $(DESTDIR)$(bindir); $(LN_S) ioport $$i)); \ + done +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/utils/ioport/ioport.c b/xorg-server/hw/xfree86/utils/ioport/ioport.c new file mode 100644 index 000000000..737043462 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/ioport/ioport.c @@ -0,0 +1,491 @@ +/* + * Copyright 2002 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE 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 "compiler.h" +#include "xf86_OSproc.h" + +#include <errno.h> + +static char *MyName; +static int Port = -1, Index = -1; +static unsigned int Value; + +static void +inb_usage +( +#ifdef __STDC__ + void +#endif +) +{ + fprintf(stderr, "inb [-i <index>] <port>\n"); +} + +static void +inw_usage +( +#ifdef __STDC__ + void +#endif +) +{ + fprintf(stderr, "inw [-i <index>] <port>\n"); +} + +static void +inl_usage +( +#ifdef __STDC__ + void +#endif +) +{ + fprintf(stderr, "inl [-i <index>] <port>\n"); +} + + +static void +outb_usage +( +#ifdef __STDC__ + void +#endif +) +{ + fprintf(stderr, "outb [-i <index>] <port> <value>\n"); +} + +static void +outw_usage +( +#ifdef __STDC__ + void +#endif +) +{ + fprintf(stderr, "outw [-i <index>] <port> <value>\n"); +} + +static void +outl_usage +( +#ifdef __STDC__ + void +#endif +) +{ + fprintf(stderr, "outl [-i <index>] <port> <value>\n"); +} + +static int +#ifdef __STDC__ +parse_number +( + const char *String, + void (* Usage)(void), + unsigned int Maximum) +#else +parse_number(String, Usage, Maximum) + const char *String; + void (* Usage)(); + unsigned int Maximum; +#endif +{ + char *BadString = (char *)0; + unsigned int Number = strtoul(String, &BadString, 0); + if ((Number > Maximum) || errno || + (BadString && *BadString)) + { + (*Usage)(); + exit(1); + } + + return (Number); +} + +static void +#ifdef __STDC__ +input_parse +( + int argc, + char **argv, + void (* Usage)(void)) +#else +input_parse(argc, argv, Usage) + int argc; + char **argv; + void (* Usage)(); +#endif +{ + if ((argc < 2) || (argc > 4)) + { + (*Usage)(); + exit(1); + } + + for(; (++argv, --argc); ) + { + if ((Index < 0) && + (argv[0][0] == '-') && + (argv[0][1] == 'i')) + { + if ((++argv[0], *(++argv[0])) || (++argv, --argc)) + Index = parse_number(argv[0], Usage, 0xFFU); + else + { + (*Usage)(); + exit(1); + } + } + else if (Port < 0) + { + Port = parse_number(argv[0], Usage, 0xFFFFU); + } + else + { + (*Usage)(); + exit(1); + } + } +} + +static void +#ifdef __STDC__ +output_parse +( + int argc, + char **argv, + void (* Usage)(void), + unsigned int Maximum +) +#else +output_parse(argc, argv, Usage, Maximum) + int argc; + char **argv; + void (* Usage)(); + unsigned int Maximum; +#endif +{ + char ValueSpecified = 0; + + if ((argc < 3) || (argc > 5)) + { + (*Usage)(); + exit(1); + } + + for (; (++argv, --argc); ) + { + if ((Index < 0) && + (argv[0][0] == '-') && + (argv[0][1] == 'i')) + { + if ((++argv[0], *(++argv[0])) || (++argv, --argc)) + Index = parse_number(argv[0], Usage, 0xFFU); + else + { + (*Usage)(); + exit(1); + } + } + else if (Port < 0) + { + Port = parse_number(argv[0], Usage, 0xFFFFU); + } + else if (!ValueSpecified) + { + Value = parse_number(argv[0], Usage, Maximum); + ValueSpecified = 1; + } + else + { + (*Usage)(); + exit(1); + } + } + + if (!ValueSpecified) + { + (*Usage)(); + exit(1); + } +} + +static void +#ifdef __STDC__ +do_inb +( + int argc, + char **argv +) +#else +do_inb(argc, argv) + int argc; + char **argv; +#endif +{ + input_parse(argc, argv, inb_usage); + + xf86EnableIO(); + + if (Index >= 0) + { + if (Port == 0x03C0U) + { /* Attribute Controller is different */ + unsigned short gens1; + + gens1 = ((inb(0x03CCU) & 0x01U) << 5) + 0x03BA; + (void) inb(gens1); + Index = (Index & 0x1FU) | 0x20U; + } + outb(Port, Index); + Port++; + } + Value = inb(Port); + + xf86DisableIO(); + + printf("0x%02X\n", Value); +} + +static void +#ifdef __STDC__ +do_inw +( + int argc, + char **argv +) +#else +do_inw(argc, argv) + int argc; + char **argv; +#endif +{ + input_parse(argc, argv, inw_usage); + + xf86EnableIO(); + + if (Index >= 0) + { + outb(Port, Index); + Port++; + } + Value = inw(Port); + + xf86DisableIO(); + + printf("0x%04X\n", Value); +} + +static void +#ifdef __STDC__ +do_inl +( + int argc, + char **argv +) +#else +do_inl(argc, argv) + int argc; + char **argv; +#endif +{ + input_parse(argc, argv, inl_usage); + + xf86EnableIO(); + + if (Index >= 0) + { + outb(Port, Index); + Port++; + } + Value = inl(Port); + + xf86DisableIO(); + + printf("0x%08X\n", Value); +} + +static void +#ifdef __STDC__ +do_outb +( + int argc, + char **argv +) +#else +do_outb(argc, argv) + int argc; + char **argv; +#endif +{ + output_parse(argc, argv, outb_usage, 0xFFU); + + xf86EnableIO(); + + if (Index >= 0) + { + if (Port == 0x03C0U) + { /* Attribute controller is different */ + unsigned short gens1; + + gens1 = ((inb(0x03CCU) & 0x01U) << 5) + 0x03BA; + (void) inb(gens1); + outb(0x03C0U, (Index & 0x1FU) | 0x20U); + } + else + { + outb(Port, Index); + Port++; + } + } + outb(Port, Value); + + xf86DisableIO(); + +} + +static void +#ifdef __STDC__ +do_outw +( + int argc, + char **argv +) +#else +do_outw(argc, argv) + int argc; + char **argv; +#endif +{ + output_parse(argc, argv, outw_usage, 0xFFFFU); + + xf86EnableIO(); + + if (Index >= 0) + { + outb(Port, Index); + Port++; + } + outw(Port, Value); + + xf86DisableIO(); + +} + +static void +#ifdef __STDC__ +do_outl +( + int argc, + char **argv +) +#else +do_outl(argc, argv) + int argc; + char **argv; +#endif +{ + output_parse(argc, argv, outl_usage, 0xFFFFFFFFU); + + xf86EnableIO(); + + if (Index >= 0) + { + outb(Port, Index); + Port++; + } + outl(Port, Value); + + xf86DisableIO(); + +} + +static void +usage +( +#ifdef __STDC__ + void +#endif +) +{ + inb_usage(); + inw_usage(); + inl_usage(); + outb_usage(); + outw_usage(); + outl_usage(); + exit(1); +} + +int +#ifdef __STDC__ +main +( + int argc, + char **argv +) +#else +main(argc, argv) + int argc; + char **argv; +#endif +{ + struct + { + char *Name; +#ifdef __STDC__ + void (* Function)(int, char **); +#else + void (* Function)(); +#endif + } + *Function_Entry, Function_Table[] = + { + {"inb", do_inb}, + {"inw", do_inw}, + {"inl", do_inl}, + {"outb", do_outb}, + {"outw", do_outw}, + {"outl", do_outl}, +#ifdef __STDC__ + {(char *)0, (void (*)(int, char **))usage} +#else + {(char *)0, usage} +#endif + }; + + /* Get name by which we were invoked */ + for (MyName = argv[0]; argv[0][0]; ) + if (*(argv[0]++) == '/') + MyName = argv[0]; + + /* Look up name in table and call corresponding function */ + for (Function_Entry = Function_Table; + Function_Entry->Name && + strcmp(MyName, Function_Entry->Name); + Function_Entry++); + (*Function_Entry->Function)(argc, argv); + + return (0); +} + diff --git a/xorg-server/hw/xfree86/utils/kbd_mode/Makefile.am b/xorg-server/hw/xfree86/utils/kbd_mode/Makefile.am new file mode 100644 index 000000000..1b28411cf --- /dev/null +++ b/xorg-server/hw/xfree86/utils/kbd_mode/Makefile.am @@ -0,0 +1,70 @@ +# $Id$ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +if BUILD_KBD_MODE +bin_PROGRAMS = kbd_mode + +if BSD_KBD_MODE +INCLUDES = $(XORG_INCS) +kbd_mode_CFLAGS = $(XORG_CFLAGS) +kbd_mode_SOURCES = bsd-kbd_mode.c +MAN_SRC = bsd-kbd_mode.man.pre +endif + +if SUN_KBD_MODE +kbd_mode_SOURCES = sun-kbd_mode.c +MAN_SRC = sun-kbd_mode.man.pre +endif + +appmandir = $(APP_MAN_DIR) + +appman_PRE = kbd_mode.man +appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) +BUILT_SOURCES = $(appman_PRE) +CLEANFILES = $(appman_PRE) $(appman_DATA) + +all-local: kbd_mode.man.pre $(appman_DATA) + +kbd_mode.man.pre: $(MAN_SRC) + $(LN_S) $(MAN_SRC) kbd_mode.man.pre + +else +all-local: +endif + +include $(top_srcdir)/cpprules.in + +SUFFIXES += .$(APP_MAN_SUFFIX) .man + +.man.$(APP_MAN_SUFFIX): + -rm -f $@ + $(LN_S) $< $@ + +EXTRA_DIST = bsd-kbd_mode.man.pre sun-kbd_mode.man.pre diff --git a/xorg-server/hw/xfree86/utils/kbd_mode/Makefile.in b/xorg-server/hw/xfree86/utils/kbd_mode/Makefile.in new file mode 100644 index 000000000..2de3e8eaa --- /dev/null +++ b/xorg-server/hw/xfree86/utils/kbd_mode/Makefile.in @@ -0,0 +1,829 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# $Id$ +# +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@BUILD_KBD_MODE_TRUE@bin_PROGRAMS = kbd_mode$(EXEEXT) +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/cpprules.in +subdir = hw/xfree86/utils/kbd_mode +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appmandir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am__kbd_mode_SOURCES_DIST = bsd-kbd_mode.c sun-kbd_mode.c +@BSD_KBD_MODE_FALSE@@BUILD_KBD_MODE_TRUE@@SUN_KBD_MODE_TRUE@am_kbd_mode_OBJECTS = kbd_mode-sun-kbd_mode.$(OBJEXT) +@BSD_KBD_MODE_TRUE@@BUILD_KBD_MODE_TRUE@am_kbd_mode_OBJECTS = kbd_mode-bsd-kbd_mode.$(OBJEXT) +kbd_mode_OBJECTS = $(am_kbd_mode_OBJECTS) +kbd_mode_LDADD = $(LDADD) +kbd_mode_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(kbd_mode_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(kbd_mode_SOURCES) +DIST_SOURCES = $(am__kbd_mode_SOURCES_DIST) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +appmanDATA_INSTALL = $(INSTALL_DATA) +DATA = $(appman_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +@BSD_KBD_MODE_TRUE@@BUILD_KBD_MODE_TRUE@INCLUDES = $(XORG_INCS) +@BSD_KBD_MODE_TRUE@@BUILD_KBD_MODE_TRUE@kbd_mode_CFLAGS = $(XORG_CFLAGS) +@BSD_KBD_MODE_TRUE@@BUILD_KBD_MODE_TRUE@kbd_mode_SOURCES = bsd-kbd_mode.c +@BUILD_KBD_MODE_TRUE@@SUN_KBD_MODE_TRUE@kbd_mode_SOURCES = sun-kbd_mode.c +@BSD_KBD_MODE_TRUE@@BUILD_KBD_MODE_TRUE@MAN_SRC = bsd-kbd_mode.man.pre +@BUILD_KBD_MODE_TRUE@@SUN_KBD_MODE_TRUE@MAN_SRC = sun-kbd_mode.man.pre +@BUILD_KBD_MODE_TRUE@appmandir = $(APP_MAN_DIR) +@BUILD_KBD_MODE_TRUE@appman_PRE = kbd_mode.man +@BUILD_KBD_MODE_TRUE@appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) +@BUILD_KBD_MODE_TRUE@BUILT_SOURCES = $(appman_PRE) +@BUILD_KBD_MODE_TRUE@CLEANFILES = $(appman_PRE) $(appman_DATA) +SUFFIXES = .pre .man .man.pre .$(APP_MAN_SUFFIX) .man + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + +EXTRA_DIST = bsd-kbd_mode.man.pre sun-kbd_mode.man.pre +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .$(APP_MAN_SUFFIX) .man .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/utils/kbd_mode/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/utils/kbd_mode/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +kbd_mode$(EXEEXT): $(kbd_mode_OBJECTS) $(kbd_mode_DEPENDENCIES) + @rm -f kbd_mode$(EXEEXT) + $(kbd_mode_LINK) $(kbd_mode_OBJECTS) $(kbd_mode_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbd_mode-bsd-kbd_mode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbd_mode-sun-kbd_mode.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +kbd_mode-bsd-kbd_mode.o: bsd-kbd_mode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -MT kbd_mode-bsd-kbd_mode.o -MD -MP -MF $(DEPDIR)/kbd_mode-bsd-kbd_mode.Tpo -c -o kbd_mode-bsd-kbd_mode.o `test -f 'bsd-kbd_mode.c' || echo '$(srcdir)/'`bsd-kbd_mode.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kbd_mode-bsd-kbd_mode.Tpo $(DEPDIR)/kbd_mode-bsd-kbd_mode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bsd-kbd_mode.c' object='kbd_mode-bsd-kbd_mode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -c -o kbd_mode-bsd-kbd_mode.o `test -f 'bsd-kbd_mode.c' || echo '$(srcdir)/'`bsd-kbd_mode.c + +kbd_mode-bsd-kbd_mode.obj: bsd-kbd_mode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -MT kbd_mode-bsd-kbd_mode.obj -MD -MP -MF $(DEPDIR)/kbd_mode-bsd-kbd_mode.Tpo -c -o kbd_mode-bsd-kbd_mode.obj `if test -f 'bsd-kbd_mode.c'; then $(CYGPATH_W) 'bsd-kbd_mode.c'; else $(CYGPATH_W) '$(srcdir)/bsd-kbd_mode.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kbd_mode-bsd-kbd_mode.Tpo $(DEPDIR)/kbd_mode-bsd-kbd_mode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bsd-kbd_mode.c' object='kbd_mode-bsd-kbd_mode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -c -o kbd_mode-bsd-kbd_mode.obj `if test -f 'bsd-kbd_mode.c'; then $(CYGPATH_W) 'bsd-kbd_mode.c'; else $(CYGPATH_W) '$(srcdir)/bsd-kbd_mode.c'; fi` + +kbd_mode-sun-kbd_mode.o: sun-kbd_mode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -MT kbd_mode-sun-kbd_mode.o -MD -MP -MF $(DEPDIR)/kbd_mode-sun-kbd_mode.Tpo -c -o kbd_mode-sun-kbd_mode.o `test -f 'sun-kbd_mode.c' || echo '$(srcdir)/'`sun-kbd_mode.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kbd_mode-sun-kbd_mode.Tpo $(DEPDIR)/kbd_mode-sun-kbd_mode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sun-kbd_mode.c' object='kbd_mode-sun-kbd_mode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -c -o kbd_mode-sun-kbd_mode.o `test -f 'sun-kbd_mode.c' || echo '$(srcdir)/'`sun-kbd_mode.c + +kbd_mode-sun-kbd_mode.obj: sun-kbd_mode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -MT kbd_mode-sun-kbd_mode.obj -MD -MP -MF $(DEPDIR)/kbd_mode-sun-kbd_mode.Tpo -c -o kbd_mode-sun-kbd_mode.obj `if test -f 'sun-kbd_mode.c'; then $(CYGPATH_W) 'sun-kbd_mode.c'; else $(CYGPATH_W) '$(srcdir)/sun-kbd_mode.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kbd_mode-sun-kbd_mode.Tpo $(DEPDIR)/kbd_mode-sun-kbd_mode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sun-kbd_mode.c' object='kbd_mode-sun-kbd_mode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(kbd_mode_CFLAGS) $(CFLAGS) -c -o kbd_mode-sun-kbd_mode.obj `if test -f 'sun-kbd_mode.c'; then $(CYGPATH_W) 'sun-kbd_mode.c'; else $(CYGPATH_W) '$(srcdir)/sun-kbd_mode.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-appmanDATA: $(appman_DATA) + @$(NORMAL_INSTALL) + test -z "$(appmandir)" || $(MKDIR_P) "$(DESTDIR)$(appmandir)" + @list='$(appman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(appmanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appmandir)/$$f'"; \ + $(appmanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appmandir)/$$f"; \ + done + +uninstall-appmanDATA: + @$(NORMAL_UNINSTALL) + @list='$(appman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(appmandir)/$$f'"; \ + rm -f "$(DESTDIR)$(appmandir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) $(DATA) all-local +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appmandir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-appmanDATA + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-appmanDATA uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am all-local check check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-appmanDATA install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-appmanDATA \ + uninstall-binPROGRAMS + + +@BUILD_KBD_MODE_TRUE@all-local: kbd_mode.man.pre $(appman_DATA) + +@BUILD_KBD_MODE_TRUE@kbd_mode.man.pre: $(MAN_SRC) +@BUILD_KBD_MODE_TRUE@ $(LN_S) $(MAN_SRC) kbd_mode.man.pre + +@BUILD_KBD_MODE_FALSE@all-local: + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.$(APP_MAN_SUFFIX): + -rm -f $@ + $(LN_S) $< $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c b/xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c new file mode 100644 index 000000000..5f8bdbd7f --- /dev/null +++ b/xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c @@ -0,0 +1,91 @@ +/* Keyboard mode control program for 386BSD */ + +#include <sys/types.h> +#include <fcntl.h> +#include <errno.h> +#include <unistd.h> +#include <stdio.h> +#include <ctype.h> +#include <stdlib.h> +#include <string.h> + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static int fd; + +void +msg (char* s) +{ + perror (s); + close (fd); + exit (-1); +} + +int +main(int argc, char** argv) +{ +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + vtmode_t vtmode; +#endif + Bool syscons = FALSE; + + if ((fd = open("/dev/vga",O_RDONLY,0)) <0) + msg ("Cannot open /dev/vga"); + +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + /* Check if syscons */ + if (ioctl(fd, VT_GETMODE, &vtmode) >= 0) + syscons = TRUE; +#endif + + if (0 == strcmp (argv[1], "-u")) + { + if (syscons) + { +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + ioctl (fd, KDSKBMODE, K_RAW); +#endif + } + else + { + if (ioctl (fd, CONSOLE_X_MODE_ON, 0) < 0) + { + close (fd); + exit (0); /* Assume codrv, so nothing to do */ + } + } + } + else if (0 == strcmp (argv[1], "-a")) + { + if (syscons) + { +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + ioctl (fd, KDSKBMODE, K_XLATE); +#endif + } + else + { + if (ioctl (fd, CONSOLE_X_MODE_OFF, 0) < 0) + { + close (fd); + exit (0); /* Assume codrv, so nothing to do */ + } + } + } + else + { + close (fd); + fprintf (stderr,"Usage: %s [-u|-a]\n",argv[0]); + fprintf (stderr,"-u for sending up down key events in x mode.\n"); + fprintf (stderr,"-a for sending ascii keys in normal use.\n"); + exit (-1); + } + close (fd); + exit (0); +} diff --git a/xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre b/xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre new file mode 100644 index 000000000..3f7842cfd --- /dev/null +++ b/xorg-server/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre @@ -0,0 +1,36 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/etc/kbd_mode.man,v 3.4 1998/04/05 02:28:42 dawes Exp $ +.TH KBD_MODE 1 __vendorversion__ +.SH NAME +kbd_mode \- recover the PC console keyboard +.SH SYNOPSIS +.B kbd_mode +[ -a -u ] +.SH DESCRIPTION +.I Kbd_mode +resets the PC console keyboard to a rational state. +.SH OPTIONS +The following options are supported: +.TP 8 +.B \-a +Set the keyboard so that ASCII characters are read from the console. +.TP 8 +.B \-u +Set the keyboard so that undecoded keyboard values are read from the +console. +.SH EXAMPLES +If the server crashes or otherwise fails to put the keyboard back in +ascii mode when it exits, it can leave your keyboard dead. If you are +able to login remotely, you can reset it typing: +.sp + kbd_mode -a +.sp +.PP +Conversely, changing the keyboard to ascii mode while the server is +running will make the keyboard appear to be dead while the the mouse +continues to work. Again, if you are able to login remotely, you can +reset it typing: +.sp + kbd_mode -u +.sp + +.\" $TOG: kbd_mode.man /main/6 1997/07/19 10:37:14 kaleb $ diff --git a/xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c b/xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c new file mode 100644 index 000000000..f2802a6b8 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c @@ -0,0 +1,152 @@ +/************************************************************ +Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright no- +tice appear in all copies and that both that copyright no- +tice and this permission notice appear in supporting docu- +mentation, and that the names of Sun or The Open Group +not be used in advertising or publicity pertaining to +distribution of the software without specific prior +written permission. Sun and The Open Group make no +representations about the suitability of this software for +any purpose. It is provided "as is" without any express or +implied warranty. + +SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- +NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- +ABLE 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. + +********************************************************/ + +/* +static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13"; + */ + +/* + * Copyright 1986 by Sun Microsystems, Inc. + * + * kbd_mode: set keyboard encoding mode + */ + +#include <sys/types.h> +#include <sys/file.h> +#include <sys/ioctl.h> +#if defined(SVR4) || defined(__SVR4) || defined(__bsdi__) +#include <fcntl.h> +#ifndef __bsdi__ +#include <sys/kbio.h> +#include <sys/kbd.h> +#else +#include <unistd.h> +#include </sys/sparc/dev/kbio.h> +#include </sys/sparc/dev/kbd.h> +#endif +#else +#ifndef CSRG_BASED +#include <sundev/kbio.h> +#include <sundev/kbd.h> +#else +#include <machine/kbio.h> +#include <machine/kbd.h> +#endif +#endif +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +static void die(char*); +static void usage(void); +static int kbd_fd; + +int +main(argc, argv) + int argc; + char** argv; +{ + int code = 0, translate, direct = -1; + char led; + int click; + + if ((kbd_fd = open("/dev/kbd", O_RDONLY, 0)) < 0) { + die("Couldn't open /dev/kbd"); + } + argc--; argv++; + if (argc-- && **argv == '-') { + code = *(++*argv); + } else { + usage(); + } + switch (code) { + case 'a': + case 'A': + translate = TR_ASCII; + direct = 0; + break; + case 'e': + case 'E': + translate = TR_EVENT; + break; + case 'n': + case 'N': + translate = TR_NONE; + break; + case 'u': + case 'U': + translate = TR_UNTRANS_EVENT; + break; + default: + usage(); + } +#ifdef KIOCSLED + led = 0; + if (ioctl(kbd_fd, KIOCSLED, &led)) + die("Couldn't set LEDs"); +#endif +#ifdef KIOCCMD + click = KBD_CMD_NOCLICK; + if (ioctl(kbd_fd, KIOCCMD, &click)) + die("Couldn't set click"); +#endif + if (ioctl(kbd_fd, KIOCTRANS, (caddr_t) &translate)) + die("Couldn't set translation"); + if (direct != -1 && ioctl(kbd_fd, KIOCSDIRECT, (caddr_t) &direct)) + die("Couldn't set redirect"); + return 0; +} + +static void +die(char *msg) +{ + fprintf(stderr, "%s\n", msg); + exit(1); +} + +static void +usage(void) +{ + int translate; + + if (ioctl(kbd_fd, KIOCGTRANS, (caddr_t) &translate)) { + die("Couldn't inquire current translation"); + } + fprintf(stderr, "kbd_mode {-a | -e | -n | -u }\n"); + fprintf(stderr, "\tfor ascii, encoded (normal) SunView events,\n"); + fprintf(stderr, " \tnon-encoded, or unencoded SunView events, resp.\n"); + fprintf(stderr, "Current mode is %s.\n", + ( translate == 0 ? "n (non-translated bytes)" : + ( translate == 1 ? "a (ascii bytes)" : + ( translate == 2 ? "e (encoded events)" : + /* translate == 3 */ "u (unencoded events)")))); + exit(1); +} + + diff --git a/xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre b/xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre new file mode 100644 index 000000000..367b4fc9a --- /dev/null +++ b/xorg-server/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre @@ -0,0 +1,53 @@ +.\" $Xorg: kbd_mode.man,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $ +.\" Copyright 1987 Sun Microsystems, Inc. +.\" Copyright 1993, 1998 The Open Group +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and its +.\" documentation for any purpose is hereby granted without fee, provided that +.\" the above copyright notice appear in all copies and that both that +.\" copyright notice and this permission notice appear in supporting +.\" documentation. +.\" +.\" The above copyright notice and this permission notice shall be included +.\" in all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +.\" OTHER DEALINGS IN THE SOFTWARE. +.\" +.\" Except as contained in this notice, the name of The Open Group shall +.\" not be used in advertising or otherwise to promote the sale, use or +.\" other dealings in this Software without prior written authorization +.\" from The Open Group. +.\" +.\" $XFree86: xc/programs/Xserver/hw/sun/kbd_mode.man,v 1.6 2001/01/27 18:20:41 dawes Exp $ +.\" +.TH KBD_MODE 1 __xorgversion__ +.SH NAME +kbd_mode \- recover the Sun console keyboard +.SH SYNOPSIS +.B kbd_mode +[ -a -e -n -u ] +.SH DESCRIPTION +.I Kbd_mode +resets the Sun console keyboard to a rational state. +.SH OPTIONS +The following options are supported, see \fIkb(4S)\fP for details: +.TP 8 +.B \-a +Causes ASCII to be reported. +.TP 8 +.B \-e +Causes \fIFirm_events\fP to be reported. +.TP 8 +.B \-n +Causes up/down key codes to be reported. +.TP 8 +.B \-u +Causes undecoded keyboard values to be reported. +.SH SEE ALSO +kb(4S) diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/Makefile.am b/xorg-server/hw/xfree86/utils/xorgcfg/Makefile.am new file mode 100644 index 000000000..31d1b3f00 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/Makefile.am @@ -0,0 +1,164 @@ +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +if BUILD_XORGCFG +bin_PROGRAMS = xorgcfg + +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/hw/xfree86/parser + +OPTIONSPATH=$(libdir)/X11 + +xorgcfg_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(CURSESDEFINES) \ + $(XORGCFG_DEP_CFLAGS) -DXKB_RULES_DIR=\"$(XKB_BASE_DIRECTORY)/rules\" \ + -DPROJECT_ROOT=\"$(PROJECTROOT)\" -DOPTIONSPATH=\"$(OPTIONSPATH)\" +xorgcfg_LDADD = $(XORGCFG_DEP_LIBS) ../../parser/libxf86config.a $(LOADERLIB) \ + ../../os-support/libxorgos.la ../../dummylib/libdummy-nonserver.a \ + ${SYS_LIBS} + +#if DoLoadableServer +LDSRCS = \ + loader.c loadmod.c +LOADERLIB = ../../loader/libloader.a +#endif + +if USE_CURSES +TEXTSRC = text-mode.c +TEXTOBJ = text-mode.o +CURSESDEFINES = -DHAS_NCURSES +endif + +if NEED_STRLCAT +STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c +endif +endif BUILD_XORGCFG + +xorgcfg_SOURCES = \ + accessx.c \ + card-cfg.c \ + cards.c \ + config.c \ + expert.c \ + help.c \ + interface.c \ + keyboard-cfg.c \ + $(LDSRCS) \ + monitor-cfg.c \ + mouse-cfg.c \ + options.c \ + screen-cfg.c \ + screen.c \ + $(SNPRINTFSRCS) \ + startx.c \ + $(STRLSRCS) \ + stubs.c \ + $(TEXTSRC) \ + vidmode.c \ + xf86config.c \ + card-cfg.h \ + cards.h \ + config.h \ + help.h \ + keyboard-cfg.h \ + loader.h \ + monitor-cfg.h \ + mouse-cfg.h \ + options.h \ + screen-cfg.h \ + screen.h \ + stubs.h \ + vidmode.h \ + xf86config.h \ + $(STRL_SRCS) + +BITMAPS = \ + card.xbm \ + keyboard.xbm \ + monitor.xbm \ + mouse.xbm \ + left.xbm \ + right.xbm \ + up.xbm \ + down.xbm \ + wider.xbm \ + narrower.xbm \ + shorter.xbm \ + taller.xbm + +PIXMAPS = \ + card.xpm \ + computer.xpm \ + keyboard.xpm \ + monitor.xpm \ + mouse.xpm + +# Rules needed to cpp man page & app-defaults +include $(top_srcdir)/cpprules.in + +if BUILD_XORGCFG +XBMdir = $(includedir)/X11/bitmaps +XPMdir = $(includedir)/X11/pixmaps + +XBM_DATA = $(BITMAPS) +XPM_DATA = $(PIXMAPS) + +# App default files (*.ad) + +appdefaultdir = @APPDEFAULTDIR@ + +APPDEFAULTFILES = XOrgCfg + +appdefault_DATA = $(APPDEFAULTFILES) + +CPP_FILES_FLAGS = -D__VENDORNAME__="@VENDOR_STRING_SHORT@" \ + -D__VENDORVERS__="@VENDOR_MAN_VERSION@" + +# dear automake: it would be really nice if you would actually put things into +# .SUFFIXES so i wouldnt' have to do this. +XOrgCfg: XOrgCfg.pre + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < XOrgCfg.pre | $(CPP_SED_MAGIC) > $@ + +# Man page +appmandir = $(APP_MAN_DIR) + +appman_PRE = xorgcfg.man +appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) + +all-local: $(appman_PRE) $(appman_DATA) + +BUILT_SOURCES = $(appman_PRE) +CLEANFILES = $(APPDEFAULTFILES) $(BUILT_SOURCES) $(appman_DATA) + +SUFFIXES += .$(APP_MAN_SUFFIX) .man + +.man.$(APP_MAN_SUFFIX): + -rm -f $@ + $(LN_S) $< $@ + +endif BUILD_XORGCFG + +EXTRA_DIST = $(BITMAPS) $(PIXMAPS) XOrgCfg.pre xorgcfg.man.pre diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/Makefile.in b/xorg-server/hw/xfree86/utils/xorgcfg/Makefile.in new file mode 100644 index 000000000..df043f868 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/Makefile.in @@ -0,0 +1,1305 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@BUILD_XORGCFG_TRUE@bin_PROGRAMS = xorgcfg$(EXEEXT) +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/cpprules.in TODO +@BUILD_XORGCFG_TRUE@am__append_1 = .$(APP_MAN_SUFFIX) .man +subdir = hw/xfree86/utils/xorgcfg +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(XBMdir)" \ + "$(DESTDIR)$(XPMdir)" "$(DESTDIR)$(appdefaultdir)" \ + "$(DESTDIR)$(appmandir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am__xorgcfg_SOURCES_DIST = accessx.c card-cfg.c cards.c config.c \ + expert.c help.c interface.c keyboard-cfg.c loader.c loadmod.c \ + monitor-cfg.c mouse-cfg.c options.c screen-cfg.c screen.c \ + startx.c stubs.c text-mode.c vidmode.c xf86config.c card-cfg.h \ + cards.h config.h help.h keyboard-cfg.h loader.h monitor-cfg.h \ + mouse-cfg.h options.h screen-cfg.h screen.h stubs.h vidmode.h \ + xf86config.h $(top_srcdir)/os/strlcat.c \ + $(top_srcdir)/os/strlcpy.c +@BUILD_XORGCFG_TRUE@am__objects_1 = xorgcfg-loader.$(OBJEXT) \ +@BUILD_XORGCFG_TRUE@ xorgcfg-loadmod.$(OBJEXT) +@BUILD_XORGCFG_TRUE@@USE_CURSES_TRUE@am__objects_2 = xorgcfg-text-mode.$(OBJEXT) +@BUILD_XORGCFG_TRUE@@NEED_STRLCAT_TRUE@am__objects_3 = xorgcfg-strlcat.$(OBJEXT) \ +@BUILD_XORGCFG_TRUE@@NEED_STRLCAT_TRUE@ xorgcfg-strlcpy.$(OBJEXT) +am_xorgcfg_OBJECTS = xorgcfg-accessx.$(OBJEXT) \ + xorgcfg-card-cfg.$(OBJEXT) xorgcfg-cards.$(OBJEXT) \ + xorgcfg-config.$(OBJEXT) xorgcfg-expert.$(OBJEXT) \ + xorgcfg-help.$(OBJEXT) xorgcfg-interface.$(OBJEXT) \ + xorgcfg-keyboard-cfg.$(OBJEXT) $(am__objects_1) \ + xorgcfg-monitor-cfg.$(OBJEXT) xorgcfg-mouse-cfg.$(OBJEXT) \ + xorgcfg-options.$(OBJEXT) xorgcfg-screen-cfg.$(OBJEXT) \ + xorgcfg-screen.$(OBJEXT) xorgcfg-startx.$(OBJEXT) \ + xorgcfg-stubs.$(OBJEXT) $(am__objects_2) \ + xorgcfg-vidmode.$(OBJEXT) xorgcfg-xf86config.$(OBJEXT) \ + $(am__objects_3) +xorgcfg_OBJECTS = $(am_xorgcfg_OBJECTS) +am__DEPENDENCIES_1 = +@BUILD_XORGCFG_TRUE@xorgcfg_DEPENDENCIES = $(am__DEPENDENCIES_1) \ +@BUILD_XORGCFG_TRUE@ ../../parser/libxf86config.a $(LOADERLIB) \ +@BUILD_XORGCFG_TRUE@ ../../os-support/libxorgos.la \ +@BUILD_XORGCFG_TRUE@ ../../dummylib/libdummy-nonserver.a +xorgcfg_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(xorgcfg_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(xorgcfg_SOURCES) +DIST_SOURCES = $(am__xorgcfg_SOURCES_DIST) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +XBMDATA_INSTALL = $(INSTALL_DATA) +XPMDATA_INSTALL = $(INSTALL_DATA) +appdefaultDATA_INSTALL = $(INSTALL_DATA) +appmanDATA_INSTALL = $(INSTALL_DATA) +DATA = $(XBM_DATA) $(XPM_DATA) $(appdefault_DATA) $(appman_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +@BUILD_XORGCFG_TRUE@INCLUDES = $(XORG_INCS) -I$(top_srcdir)/hw/xfree86/parser +@BUILD_XORGCFG_TRUE@OPTIONSPATH = $(libdir)/X11 +@BUILD_XORGCFG_TRUE@xorgcfg_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(CURSESDEFINES) \ +@BUILD_XORGCFG_TRUE@ $(XORGCFG_DEP_CFLAGS) -DXKB_RULES_DIR=\"$(XKB_BASE_DIRECTORY)/rules\" \ +@BUILD_XORGCFG_TRUE@ -DPROJECT_ROOT=\"$(PROJECTROOT)\" -DOPTIONSPATH=\"$(OPTIONSPATH)\" + +@BUILD_XORGCFG_TRUE@xorgcfg_LDADD = $(XORGCFG_DEP_LIBS) ../../parser/libxf86config.a $(LOADERLIB) \ +@BUILD_XORGCFG_TRUE@ ../../os-support/libxorgos.la ../../dummylib/libdummy-nonserver.a \ +@BUILD_XORGCFG_TRUE@ ${SYS_LIBS} + + +#if DoLoadableServer +@BUILD_XORGCFG_TRUE@LDSRCS = \ +@BUILD_XORGCFG_TRUE@ loader.c loadmod.c + +@BUILD_XORGCFG_TRUE@LOADERLIB = ../../loader/libloader.a +#endif +@BUILD_XORGCFG_TRUE@@USE_CURSES_TRUE@TEXTSRC = text-mode.c +@BUILD_XORGCFG_TRUE@@USE_CURSES_TRUE@TEXTOBJ = text-mode.o +@BUILD_XORGCFG_TRUE@@USE_CURSES_TRUE@CURSESDEFINES = -DHAS_NCURSES +@BUILD_XORGCFG_TRUE@@NEED_STRLCAT_TRUE@STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c +xorgcfg_SOURCES = \ + accessx.c \ + card-cfg.c \ + cards.c \ + config.c \ + expert.c \ + help.c \ + interface.c \ + keyboard-cfg.c \ + $(LDSRCS) \ + monitor-cfg.c \ + mouse-cfg.c \ + options.c \ + screen-cfg.c \ + screen.c \ + $(SNPRINTFSRCS) \ + startx.c \ + $(STRLSRCS) \ + stubs.c \ + $(TEXTSRC) \ + vidmode.c \ + xf86config.c \ + card-cfg.h \ + cards.h \ + config.h \ + help.h \ + keyboard-cfg.h \ + loader.h \ + monitor-cfg.h \ + mouse-cfg.h \ + options.h \ + screen-cfg.h \ + screen.h \ + stubs.h \ + vidmode.h \ + xf86config.h \ + $(STRL_SRCS) + +BITMAPS = \ + card.xbm \ + keyboard.xbm \ + monitor.xbm \ + mouse.xbm \ + left.xbm \ + right.xbm \ + up.xbm \ + down.xbm \ + wider.xbm \ + narrower.xbm \ + shorter.xbm \ + taller.xbm + +PIXMAPS = \ + card.xpm \ + computer.xpm \ + keyboard.xpm \ + monitor.xpm \ + mouse.xpm + +SUFFIXES = .pre .man .man.pre $(am__append_1) + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + + +# Rules needed to cpp man page & app-defaults +@BUILD_XORGCFG_TRUE@XBMdir = $(includedir)/X11/bitmaps +@BUILD_XORGCFG_TRUE@XPMdir = $(includedir)/X11/pixmaps +@BUILD_XORGCFG_TRUE@XBM_DATA = $(BITMAPS) +@BUILD_XORGCFG_TRUE@XPM_DATA = $(PIXMAPS) + +# App default files (*.ad) +@BUILD_XORGCFG_TRUE@appdefaultdir = @APPDEFAULTDIR@ +@BUILD_XORGCFG_TRUE@APPDEFAULTFILES = XOrgCfg +@BUILD_XORGCFG_TRUE@appdefault_DATA = $(APPDEFAULTFILES) +@BUILD_XORGCFG_TRUE@CPP_FILES_FLAGS = -D__VENDORNAME__="@VENDOR_STRING_SHORT@" \ +@BUILD_XORGCFG_TRUE@ -D__VENDORVERS__="@VENDOR_MAN_VERSION@" + + +# Man page +@BUILD_XORGCFG_TRUE@appmandir = $(APP_MAN_DIR) +@BUILD_XORGCFG_TRUE@appman_PRE = xorgcfg.man +@BUILD_XORGCFG_TRUE@appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) +@BUILD_XORGCFG_TRUE@BUILT_SOURCES = $(appman_PRE) +@BUILD_XORGCFG_TRUE@CLEANFILES = $(APPDEFAULTFILES) $(BUILT_SOURCES) $(appman_DATA) +EXTRA_DIST = $(BITMAPS) $(PIXMAPS) XOrgCfg.pre xorgcfg.man.pre +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .$(APP_MAN_SUFFIX) .man .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/utils/xorgcfg/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/utils/xorgcfg/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +xorgcfg$(EXEEXT): $(xorgcfg_OBJECTS) $(xorgcfg_DEPENDENCIES) + @rm -f xorgcfg$(EXEEXT) + $(xorgcfg_LINK) $(xorgcfg_OBJECTS) $(xorgcfg_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-accessx.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-card-cfg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-cards.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-config.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-expert.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-help.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-interface.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-keyboard-cfg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-loader.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-loadmod.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-monitor-cfg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-mouse-cfg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-options.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-screen-cfg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-screen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-startx.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-strlcat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-strlcpy.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-stubs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-text-mode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-vidmode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgcfg-xf86config.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +xorgcfg-accessx.o: accessx.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-accessx.o -MD -MP -MF $(DEPDIR)/xorgcfg-accessx.Tpo -c -o xorgcfg-accessx.o `test -f 'accessx.c' || echo '$(srcdir)/'`accessx.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-accessx.Tpo $(DEPDIR)/xorgcfg-accessx.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='accessx.c' object='xorgcfg-accessx.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-accessx.o `test -f 'accessx.c' || echo '$(srcdir)/'`accessx.c + +xorgcfg-accessx.obj: accessx.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-accessx.obj -MD -MP -MF $(DEPDIR)/xorgcfg-accessx.Tpo -c -o xorgcfg-accessx.obj `if test -f 'accessx.c'; then $(CYGPATH_W) 'accessx.c'; else $(CYGPATH_W) '$(srcdir)/accessx.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-accessx.Tpo $(DEPDIR)/xorgcfg-accessx.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='accessx.c' object='xorgcfg-accessx.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-accessx.obj `if test -f 'accessx.c'; then $(CYGPATH_W) 'accessx.c'; else $(CYGPATH_W) '$(srcdir)/accessx.c'; fi` + +xorgcfg-card-cfg.o: card-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-card-cfg.o -MD -MP -MF $(DEPDIR)/xorgcfg-card-cfg.Tpo -c -o xorgcfg-card-cfg.o `test -f 'card-cfg.c' || echo '$(srcdir)/'`card-cfg.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-card-cfg.Tpo $(DEPDIR)/xorgcfg-card-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='card-cfg.c' object='xorgcfg-card-cfg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-card-cfg.o `test -f 'card-cfg.c' || echo '$(srcdir)/'`card-cfg.c + +xorgcfg-card-cfg.obj: card-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-card-cfg.obj -MD -MP -MF $(DEPDIR)/xorgcfg-card-cfg.Tpo -c -o xorgcfg-card-cfg.obj `if test -f 'card-cfg.c'; then $(CYGPATH_W) 'card-cfg.c'; else $(CYGPATH_W) '$(srcdir)/card-cfg.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-card-cfg.Tpo $(DEPDIR)/xorgcfg-card-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='card-cfg.c' object='xorgcfg-card-cfg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-card-cfg.obj `if test -f 'card-cfg.c'; then $(CYGPATH_W) 'card-cfg.c'; else $(CYGPATH_W) '$(srcdir)/card-cfg.c'; fi` + +xorgcfg-cards.o: cards.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-cards.o -MD -MP -MF $(DEPDIR)/xorgcfg-cards.Tpo -c -o xorgcfg-cards.o `test -f 'cards.c' || echo '$(srcdir)/'`cards.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-cards.Tpo $(DEPDIR)/xorgcfg-cards.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cards.c' object='xorgcfg-cards.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-cards.o `test -f 'cards.c' || echo '$(srcdir)/'`cards.c + +xorgcfg-cards.obj: cards.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-cards.obj -MD -MP -MF $(DEPDIR)/xorgcfg-cards.Tpo -c -o xorgcfg-cards.obj `if test -f 'cards.c'; then $(CYGPATH_W) 'cards.c'; else $(CYGPATH_W) '$(srcdir)/cards.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-cards.Tpo $(DEPDIR)/xorgcfg-cards.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cards.c' object='xorgcfg-cards.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-cards.obj `if test -f 'cards.c'; then $(CYGPATH_W) 'cards.c'; else $(CYGPATH_W) '$(srcdir)/cards.c'; fi` + +xorgcfg-config.o: config.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-config.o -MD -MP -MF $(DEPDIR)/xorgcfg-config.Tpo -c -o xorgcfg-config.o `test -f 'config.c' || echo '$(srcdir)/'`config.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-config.Tpo $(DEPDIR)/xorgcfg-config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config.c' object='xorgcfg-config.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-config.o `test -f 'config.c' || echo '$(srcdir)/'`config.c + +xorgcfg-config.obj: config.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-config.obj -MD -MP -MF $(DEPDIR)/xorgcfg-config.Tpo -c -o xorgcfg-config.obj `if test -f 'config.c'; then $(CYGPATH_W) 'config.c'; else $(CYGPATH_W) '$(srcdir)/config.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-config.Tpo $(DEPDIR)/xorgcfg-config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config.c' object='xorgcfg-config.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-config.obj `if test -f 'config.c'; then $(CYGPATH_W) 'config.c'; else $(CYGPATH_W) '$(srcdir)/config.c'; fi` + +xorgcfg-expert.o: expert.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-expert.o -MD -MP -MF $(DEPDIR)/xorgcfg-expert.Tpo -c -o xorgcfg-expert.o `test -f 'expert.c' || echo '$(srcdir)/'`expert.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-expert.Tpo $(DEPDIR)/xorgcfg-expert.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='expert.c' object='xorgcfg-expert.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-expert.o `test -f 'expert.c' || echo '$(srcdir)/'`expert.c + +xorgcfg-expert.obj: expert.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-expert.obj -MD -MP -MF $(DEPDIR)/xorgcfg-expert.Tpo -c -o xorgcfg-expert.obj `if test -f 'expert.c'; then $(CYGPATH_W) 'expert.c'; else $(CYGPATH_W) '$(srcdir)/expert.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-expert.Tpo $(DEPDIR)/xorgcfg-expert.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='expert.c' object='xorgcfg-expert.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-expert.obj `if test -f 'expert.c'; then $(CYGPATH_W) 'expert.c'; else $(CYGPATH_W) '$(srcdir)/expert.c'; fi` + +xorgcfg-help.o: help.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-help.o -MD -MP -MF $(DEPDIR)/xorgcfg-help.Tpo -c -o xorgcfg-help.o `test -f 'help.c' || echo '$(srcdir)/'`help.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-help.Tpo $(DEPDIR)/xorgcfg-help.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='help.c' object='xorgcfg-help.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-help.o `test -f 'help.c' || echo '$(srcdir)/'`help.c + +xorgcfg-help.obj: help.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-help.obj -MD -MP -MF $(DEPDIR)/xorgcfg-help.Tpo -c -o xorgcfg-help.obj `if test -f 'help.c'; then $(CYGPATH_W) 'help.c'; else $(CYGPATH_W) '$(srcdir)/help.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-help.Tpo $(DEPDIR)/xorgcfg-help.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='help.c' object='xorgcfg-help.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-help.obj `if test -f 'help.c'; then $(CYGPATH_W) 'help.c'; else $(CYGPATH_W) '$(srcdir)/help.c'; fi` + +xorgcfg-interface.o: interface.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-interface.o -MD -MP -MF $(DEPDIR)/xorgcfg-interface.Tpo -c -o xorgcfg-interface.o `test -f 'interface.c' || echo '$(srcdir)/'`interface.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-interface.Tpo $(DEPDIR)/xorgcfg-interface.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='interface.c' object='xorgcfg-interface.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-interface.o `test -f 'interface.c' || echo '$(srcdir)/'`interface.c + +xorgcfg-interface.obj: interface.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-interface.obj -MD -MP -MF $(DEPDIR)/xorgcfg-interface.Tpo -c -o xorgcfg-interface.obj `if test -f 'interface.c'; then $(CYGPATH_W) 'interface.c'; else $(CYGPATH_W) '$(srcdir)/interface.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-interface.Tpo $(DEPDIR)/xorgcfg-interface.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='interface.c' object='xorgcfg-interface.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-interface.obj `if test -f 'interface.c'; then $(CYGPATH_W) 'interface.c'; else $(CYGPATH_W) '$(srcdir)/interface.c'; fi` + +xorgcfg-keyboard-cfg.o: keyboard-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-keyboard-cfg.o -MD -MP -MF $(DEPDIR)/xorgcfg-keyboard-cfg.Tpo -c -o xorgcfg-keyboard-cfg.o `test -f 'keyboard-cfg.c' || echo '$(srcdir)/'`keyboard-cfg.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-keyboard-cfg.Tpo $(DEPDIR)/xorgcfg-keyboard-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='keyboard-cfg.c' object='xorgcfg-keyboard-cfg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-keyboard-cfg.o `test -f 'keyboard-cfg.c' || echo '$(srcdir)/'`keyboard-cfg.c + +xorgcfg-keyboard-cfg.obj: keyboard-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-keyboard-cfg.obj -MD -MP -MF $(DEPDIR)/xorgcfg-keyboard-cfg.Tpo -c -o xorgcfg-keyboard-cfg.obj `if test -f 'keyboard-cfg.c'; then $(CYGPATH_W) 'keyboard-cfg.c'; else $(CYGPATH_W) '$(srcdir)/keyboard-cfg.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-keyboard-cfg.Tpo $(DEPDIR)/xorgcfg-keyboard-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='keyboard-cfg.c' object='xorgcfg-keyboard-cfg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-keyboard-cfg.obj `if test -f 'keyboard-cfg.c'; then $(CYGPATH_W) 'keyboard-cfg.c'; else $(CYGPATH_W) '$(srcdir)/keyboard-cfg.c'; fi` + +xorgcfg-loader.o: loader.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-loader.o -MD -MP -MF $(DEPDIR)/xorgcfg-loader.Tpo -c -o xorgcfg-loader.o `test -f 'loader.c' || echo '$(srcdir)/'`loader.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-loader.Tpo $(DEPDIR)/xorgcfg-loader.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='loader.c' object='xorgcfg-loader.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-loader.o `test -f 'loader.c' || echo '$(srcdir)/'`loader.c + +xorgcfg-loader.obj: loader.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-loader.obj -MD -MP -MF $(DEPDIR)/xorgcfg-loader.Tpo -c -o xorgcfg-loader.obj `if test -f 'loader.c'; then $(CYGPATH_W) 'loader.c'; else $(CYGPATH_W) '$(srcdir)/loader.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-loader.Tpo $(DEPDIR)/xorgcfg-loader.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='loader.c' object='xorgcfg-loader.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-loader.obj `if test -f 'loader.c'; then $(CYGPATH_W) 'loader.c'; else $(CYGPATH_W) '$(srcdir)/loader.c'; fi` + +xorgcfg-loadmod.o: loadmod.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-loadmod.o -MD -MP -MF $(DEPDIR)/xorgcfg-loadmod.Tpo -c -o xorgcfg-loadmod.o `test -f 'loadmod.c' || echo '$(srcdir)/'`loadmod.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-loadmod.Tpo $(DEPDIR)/xorgcfg-loadmod.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='loadmod.c' object='xorgcfg-loadmod.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-loadmod.o `test -f 'loadmod.c' || echo '$(srcdir)/'`loadmod.c + +xorgcfg-loadmod.obj: loadmod.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-loadmod.obj -MD -MP -MF $(DEPDIR)/xorgcfg-loadmod.Tpo -c -o xorgcfg-loadmod.obj `if test -f 'loadmod.c'; then $(CYGPATH_W) 'loadmod.c'; else $(CYGPATH_W) '$(srcdir)/loadmod.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-loadmod.Tpo $(DEPDIR)/xorgcfg-loadmod.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='loadmod.c' object='xorgcfg-loadmod.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-loadmod.obj `if test -f 'loadmod.c'; then $(CYGPATH_W) 'loadmod.c'; else $(CYGPATH_W) '$(srcdir)/loadmod.c'; fi` + +xorgcfg-monitor-cfg.o: monitor-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-monitor-cfg.o -MD -MP -MF $(DEPDIR)/xorgcfg-monitor-cfg.Tpo -c -o xorgcfg-monitor-cfg.o `test -f 'monitor-cfg.c' || echo '$(srcdir)/'`monitor-cfg.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-monitor-cfg.Tpo $(DEPDIR)/xorgcfg-monitor-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='monitor-cfg.c' object='xorgcfg-monitor-cfg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-monitor-cfg.o `test -f 'monitor-cfg.c' || echo '$(srcdir)/'`monitor-cfg.c + +xorgcfg-monitor-cfg.obj: monitor-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-monitor-cfg.obj -MD -MP -MF $(DEPDIR)/xorgcfg-monitor-cfg.Tpo -c -o xorgcfg-monitor-cfg.obj `if test -f 'monitor-cfg.c'; then $(CYGPATH_W) 'monitor-cfg.c'; else $(CYGPATH_W) '$(srcdir)/monitor-cfg.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-monitor-cfg.Tpo $(DEPDIR)/xorgcfg-monitor-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='monitor-cfg.c' object='xorgcfg-monitor-cfg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-monitor-cfg.obj `if test -f 'monitor-cfg.c'; then $(CYGPATH_W) 'monitor-cfg.c'; else $(CYGPATH_W) '$(srcdir)/monitor-cfg.c'; fi` + +xorgcfg-mouse-cfg.o: mouse-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-mouse-cfg.o -MD -MP -MF $(DEPDIR)/xorgcfg-mouse-cfg.Tpo -c -o xorgcfg-mouse-cfg.o `test -f 'mouse-cfg.c' || echo '$(srcdir)/'`mouse-cfg.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-mouse-cfg.Tpo $(DEPDIR)/xorgcfg-mouse-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mouse-cfg.c' object='xorgcfg-mouse-cfg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-mouse-cfg.o `test -f 'mouse-cfg.c' || echo '$(srcdir)/'`mouse-cfg.c + +xorgcfg-mouse-cfg.obj: mouse-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-mouse-cfg.obj -MD -MP -MF $(DEPDIR)/xorgcfg-mouse-cfg.Tpo -c -o xorgcfg-mouse-cfg.obj `if test -f 'mouse-cfg.c'; then $(CYGPATH_W) 'mouse-cfg.c'; else $(CYGPATH_W) '$(srcdir)/mouse-cfg.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-mouse-cfg.Tpo $(DEPDIR)/xorgcfg-mouse-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mouse-cfg.c' object='xorgcfg-mouse-cfg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-mouse-cfg.obj `if test -f 'mouse-cfg.c'; then $(CYGPATH_W) 'mouse-cfg.c'; else $(CYGPATH_W) '$(srcdir)/mouse-cfg.c'; fi` + +xorgcfg-options.o: options.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-options.o -MD -MP -MF $(DEPDIR)/xorgcfg-options.Tpo -c -o xorgcfg-options.o `test -f 'options.c' || echo '$(srcdir)/'`options.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-options.Tpo $(DEPDIR)/xorgcfg-options.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='options.c' object='xorgcfg-options.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-options.o `test -f 'options.c' || echo '$(srcdir)/'`options.c + +xorgcfg-options.obj: options.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-options.obj -MD -MP -MF $(DEPDIR)/xorgcfg-options.Tpo -c -o xorgcfg-options.obj `if test -f 'options.c'; then $(CYGPATH_W) 'options.c'; else $(CYGPATH_W) '$(srcdir)/options.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-options.Tpo $(DEPDIR)/xorgcfg-options.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='options.c' object='xorgcfg-options.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-options.obj `if test -f 'options.c'; then $(CYGPATH_W) 'options.c'; else $(CYGPATH_W) '$(srcdir)/options.c'; fi` + +xorgcfg-screen-cfg.o: screen-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-screen-cfg.o -MD -MP -MF $(DEPDIR)/xorgcfg-screen-cfg.Tpo -c -o xorgcfg-screen-cfg.o `test -f 'screen-cfg.c' || echo '$(srcdir)/'`screen-cfg.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-screen-cfg.Tpo $(DEPDIR)/xorgcfg-screen-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='screen-cfg.c' object='xorgcfg-screen-cfg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-screen-cfg.o `test -f 'screen-cfg.c' || echo '$(srcdir)/'`screen-cfg.c + +xorgcfg-screen-cfg.obj: screen-cfg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-screen-cfg.obj -MD -MP -MF $(DEPDIR)/xorgcfg-screen-cfg.Tpo -c -o xorgcfg-screen-cfg.obj `if test -f 'screen-cfg.c'; then $(CYGPATH_W) 'screen-cfg.c'; else $(CYGPATH_W) '$(srcdir)/screen-cfg.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-screen-cfg.Tpo $(DEPDIR)/xorgcfg-screen-cfg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='screen-cfg.c' object='xorgcfg-screen-cfg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-screen-cfg.obj `if test -f 'screen-cfg.c'; then $(CYGPATH_W) 'screen-cfg.c'; else $(CYGPATH_W) '$(srcdir)/screen-cfg.c'; fi` + +xorgcfg-screen.o: screen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-screen.o -MD -MP -MF $(DEPDIR)/xorgcfg-screen.Tpo -c -o xorgcfg-screen.o `test -f 'screen.c' || echo '$(srcdir)/'`screen.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-screen.Tpo $(DEPDIR)/xorgcfg-screen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='screen.c' object='xorgcfg-screen.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-screen.o `test -f 'screen.c' || echo '$(srcdir)/'`screen.c + +xorgcfg-screen.obj: screen.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-screen.obj -MD -MP -MF $(DEPDIR)/xorgcfg-screen.Tpo -c -o xorgcfg-screen.obj `if test -f 'screen.c'; then $(CYGPATH_W) 'screen.c'; else $(CYGPATH_W) '$(srcdir)/screen.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-screen.Tpo $(DEPDIR)/xorgcfg-screen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='screen.c' object='xorgcfg-screen.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-screen.obj `if test -f 'screen.c'; then $(CYGPATH_W) 'screen.c'; else $(CYGPATH_W) '$(srcdir)/screen.c'; fi` + +xorgcfg-startx.o: startx.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-startx.o -MD -MP -MF $(DEPDIR)/xorgcfg-startx.Tpo -c -o xorgcfg-startx.o `test -f 'startx.c' || echo '$(srcdir)/'`startx.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-startx.Tpo $(DEPDIR)/xorgcfg-startx.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='startx.c' object='xorgcfg-startx.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-startx.o `test -f 'startx.c' || echo '$(srcdir)/'`startx.c + +xorgcfg-startx.obj: startx.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-startx.obj -MD -MP -MF $(DEPDIR)/xorgcfg-startx.Tpo -c -o xorgcfg-startx.obj `if test -f 'startx.c'; then $(CYGPATH_W) 'startx.c'; else $(CYGPATH_W) '$(srcdir)/startx.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-startx.Tpo $(DEPDIR)/xorgcfg-startx.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='startx.c' object='xorgcfg-startx.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-startx.obj `if test -f 'startx.c'; then $(CYGPATH_W) 'startx.c'; else $(CYGPATH_W) '$(srcdir)/startx.c'; fi` + +xorgcfg-stubs.o: stubs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-stubs.o -MD -MP -MF $(DEPDIR)/xorgcfg-stubs.Tpo -c -o xorgcfg-stubs.o `test -f 'stubs.c' || echo '$(srcdir)/'`stubs.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-stubs.Tpo $(DEPDIR)/xorgcfg-stubs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='stubs.c' object='xorgcfg-stubs.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-stubs.o `test -f 'stubs.c' || echo '$(srcdir)/'`stubs.c + +xorgcfg-stubs.obj: stubs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-stubs.obj -MD -MP -MF $(DEPDIR)/xorgcfg-stubs.Tpo -c -o xorgcfg-stubs.obj `if test -f 'stubs.c'; then $(CYGPATH_W) 'stubs.c'; else $(CYGPATH_W) '$(srcdir)/stubs.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-stubs.Tpo $(DEPDIR)/xorgcfg-stubs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='stubs.c' object='xorgcfg-stubs.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-stubs.obj `if test -f 'stubs.c'; then $(CYGPATH_W) 'stubs.c'; else $(CYGPATH_W) '$(srcdir)/stubs.c'; fi` + +xorgcfg-text-mode.o: text-mode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-text-mode.o -MD -MP -MF $(DEPDIR)/xorgcfg-text-mode.Tpo -c -o xorgcfg-text-mode.o `test -f 'text-mode.c' || echo '$(srcdir)/'`text-mode.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-text-mode.Tpo $(DEPDIR)/xorgcfg-text-mode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='text-mode.c' object='xorgcfg-text-mode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-text-mode.o `test -f 'text-mode.c' || echo '$(srcdir)/'`text-mode.c + +xorgcfg-text-mode.obj: text-mode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-text-mode.obj -MD -MP -MF $(DEPDIR)/xorgcfg-text-mode.Tpo -c -o xorgcfg-text-mode.obj `if test -f 'text-mode.c'; then $(CYGPATH_W) 'text-mode.c'; else $(CYGPATH_W) '$(srcdir)/text-mode.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-text-mode.Tpo $(DEPDIR)/xorgcfg-text-mode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='text-mode.c' object='xorgcfg-text-mode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-text-mode.obj `if test -f 'text-mode.c'; then $(CYGPATH_W) 'text-mode.c'; else $(CYGPATH_W) '$(srcdir)/text-mode.c'; fi` + +xorgcfg-vidmode.o: vidmode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-vidmode.o -MD -MP -MF $(DEPDIR)/xorgcfg-vidmode.Tpo -c -o xorgcfg-vidmode.o `test -f 'vidmode.c' || echo '$(srcdir)/'`vidmode.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-vidmode.Tpo $(DEPDIR)/xorgcfg-vidmode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='vidmode.c' object='xorgcfg-vidmode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-vidmode.o `test -f 'vidmode.c' || echo '$(srcdir)/'`vidmode.c + +xorgcfg-vidmode.obj: vidmode.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-vidmode.obj -MD -MP -MF $(DEPDIR)/xorgcfg-vidmode.Tpo -c -o xorgcfg-vidmode.obj `if test -f 'vidmode.c'; then $(CYGPATH_W) 'vidmode.c'; else $(CYGPATH_W) '$(srcdir)/vidmode.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-vidmode.Tpo $(DEPDIR)/xorgcfg-vidmode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='vidmode.c' object='xorgcfg-vidmode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-vidmode.obj `if test -f 'vidmode.c'; then $(CYGPATH_W) 'vidmode.c'; else $(CYGPATH_W) '$(srcdir)/vidmode.c'; fi` + +xorgcfg-xf86config.o: xf86config.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-xf86config.o -MD -MP -MF $(DEPDIR)/xorgcfg-xf86config.Tpo -c -o xorgcfg-xf86config.o `test -f 'xf86config.c' || echo '$(srcdir)/'`xf86config.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-xf86config.Tpo $(DEPDIR)/xorgcfg-xf86config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xf86config.c' object='xorgcfg-xf86config.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-xf86config.o `test -f 'xf86config.c' || echo '$(srcdir)/'`xf86config.c + +xorgcfg-xf86config.obj: xf86config.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-xf86config.obj -MD -MP -MF $(DEPDIR)/xorgcfg-xf86config.Tpo -c -o xorgcfg-xf86config.obj `if test -f 'xf86config.c'; then $(CYGPATH_W) 'xf86config.c'; else $(CYGPATH_W) '$(srcdir)/xf86config.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-xf86config.Tpo $(DEPDIR)/xorgcfg-xf86config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xf86config.c' object='xorgcfg-xf86config.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-xf86config.obj `if test -f 'xf86config.c'; then $(CYGPATH_W) 'xf86config.c'; else $(CYGPATH_W) '$(srcdir)/xf86config.c'; fi` + +xorgcfg-strlcat.o: $(top_srcdir)/os/strlcat.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-strlcat.o -MD -MP -MF $(DEPDIR)/xorgcfg-strlcat.Tpo -c -o xorgcfg-strlcat.o `test -f '$(top_srcdir)/os/strlcat.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcat.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-strlcat.Tpo $(DEPDIR)/xorgcfg-strlcat.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcat.c' object='xorgcfg-strlcat.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-strlcat.o `test -f '$(top_srcdir)/os/strlcat.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcat.c + +xorgcfg-strlcat.obj: $(top_srcdir)/os/strlcat.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-strlcat.obj -MD -MP -MF $(DEPDIR)/xorgcfg-strlcat.Tpo -c -o xorgcfg-strlcat.obj `if test -f '$(top_srcdir)/os/strlcat.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcat.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcat.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-strlcat.Tpo $(DEPDIR)/xorgcfg-strlcat.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcat.c' object='xorgcfg-strlcat.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-strlcat.obj `if test -f '$(top_srcdir)/os/strlcat.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcat.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcat.c'; fi` + +xorgcfg-strlcpy.o: $(top_srcdir)/os/strlcpy.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-strlcpy.o -MD -MP -MF $(DEPDIR)/xorgcfg-strlcpy.Tpo -c -o xorgcfg-strlcpy.o `test -f '$(top_srcdir)/os/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcpy.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-strlcpy.Tpo $(DEPDIR)/xorgcfg-strlcpy.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcpy.c' object='xorgcfg-strlcpy.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-strlcpy.o `test -f '$(top_srcdir)/os/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/os/strlcpy.c + +xorgcfg-strlcpy.obj: $(top_srcdir)/os/strlcpy.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -MT xorgcfg-strlcpy.obj -MD -MP -MF $(DEPDIR)/xorgcfg-strlcpy.Tpo -c -o xorgcfg-strlcpy.obj `if test -f '$(top_srcdir)/os/strlcpy.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcpy.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcpy.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgcfg-strlcpy.Tpo $(DEPDIR)/xorgcfg-strlcpy.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/os/strlcpy.c' object='xorgcfg-strlcpy.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgcfg_CFLAGS) $(CFLAGS) -c -o xorgcfg-strlcpy.obj `if test -f '$(top_srcdir)/os/strlcpy.c'; then $(CYGPATH_W) '$(top_srcdir)/os/strlcpy.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/os/strlcpy.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-XBMDATA: $(XBM_DATA) + @$(NORMAL_INSTALL) + test -z "$(XBMdir)" || $(MKDIR_P) "$(DESTDIR)$(XBMdir)" + @list='$(XBM_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(XBMDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(XBMdir)/$$f'"; \ + $(XBMDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(XBMdir)/$$f"; \ + done + +uninstall-XBMDATA: + @$(NORMAL_UNINSTALL) + @list='$(XBM_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(XBMdir)/$$f'"; \ + rm -f "$(DESTDIR)$(XBMdir)/$$f"; \ + done +install-XPMDATA: $(XPM_DATA) + @$(NORMAL_INSTALL) + test -z "$(XPMdir)" || $(MKDIR_P) "$(DESTDIR)$(XPMdir)" + @list='$(XPM_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(XPMDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(XPMdir)/$$f'"; \ + $(XPMDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(XPMdir)/$$f"; \ + done + +uninstall-XPMDATA: + @$(NORMAL_UNINSTALL) + @list='$(XPM_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(XPMdir)/$$f'"; \ + rm -f "$(DESTDIR)$(XPMdir)/$$f"; \ + done +install-appdefaultDATA: $(appdefault_DATA) + @$(NORMAL_INSTALL) + test -z "$(appdefaultdir)" || $(MKDIR_P) "$(DESTDIR)$(appdefaultdir)" + @list='$(appdefault_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(appdefaultDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appdefaultdir)/$$f'"; \ + $(appdefaultDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appdefaultdir)/$$f"; \ + done + +uninstall-appdefaultDATA: + @$(NORMAL_UNINSTALL) + @list='$(appdefault_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(appdefaultdir)/$$f'"; \ + rm -f "$(DESTDIR)$(appdefaultdir)/$$f"; \ + done +install-appmanDATA: $(appman_DATA) + @$(NORMAL_INSTALL) + test -z "$(appmandir)" || $(MKDIR_P) "$(DESTDIR)$(appmandir)" + @list='$(appman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(appmanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appmandir)/$$f'"; \ + $(appmanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appmandir)/$$f"; \ + done + +uninstall-appmanDATA: + @$(NORMAL_UNINSTALL) + @list='$(appman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(appmandir)/$$f'"; \ + rm -f "$(DESTDIR)$(appmandir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +@BUILD_XORGCFG_FALSE@all-local: +all-am: Makefile $(PROGRAMS) $(DATA) all-local +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(XBMdir)" "$(DESTDIR)$(XPMdir)" "$(DESTDIR)$(appdefaultdir)" "$(DESTDIR)$(appmandir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-XBMDATA install-XPMDATA \ + install-appdefaultDATA install-appmanDATA + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-XBMDATA uninstall-XPMDATA \ + uninstall-appdefaultDATA uninstall-appmanDATA \ + uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am all-local check check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-XBMDATA install-XPMDATA install-am \ + install-appdefaultDATA install-appmanDATA install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-XBMDATA uninstall-XPMDATA \ + uninstall-am uninstall-appdefaultDATA uninstall-appmanDATA \ + uninstall-binPROGRAMS + + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ + +# dear automake: it would be really nice if you would actually put things into +# .SUFFIXES so i wouldnt' have to do this. +@BUILD_XORGCFG_TRUE@XOrgCfg: XOrgCfg.pre +@BUILD_XORGCFG_TRUE@ $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < XOrgCfg.pre | $(CPP_SED_MAGIC) > $@ + +@BUILD_XORGCFG_TRUE@all-local: $(appman_PRE) $(appman_DATA) + +@BUILD_XORGCFG_TRUE@.man.$(APP_MAN_SUFFIX): +@BUILD_XORGCFG_TRUE@ -rm -f $@ +@BUILD_XORGCFG_TRUE@ $(LN_S) $< $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/TODO b/xorg-server/hw/xfree86/utils/xorgcfg/TODO new file mode 100644 index 000000000..d8d1cd5ee --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/TODO @@ -0,0 +1,33 @@ +$XFree86$ + +o Have code to fetch the SymTabRec chipset list from a video driver. + This is mostly useful for the testing tool/interface, so that the + Cards file "uptodate" state can also be verified. + Probably it is better to forgot about the Cards file, and + either parse the output of scanpci, or link libscanpci.a + (and whatever else be required) in xorgcfg. + +o Check if a module is "certified", there was some talk about a + certification process in the past. + +o Rewrite mouse driver to use the same code as video drivers, so that + it is possible to store all available options in a single place. + This would also require rewriting all existing input device modules. + (Probably most of this can be made with cpp macros). + +o Create a protocol to allow 3rd part xorgcfg modules. + +o Write an interface for testing extensions/accel, maybe a frontend to + xdpyinfo, x11perf, glxinfo, etc. + +o Write a "wizard" mode, as several users find the graphical interface + too complicated, but find the text one easier to user. + +o Write code to use a Monitors database, either update the old Monitors + file or use RedHat MonitorsDB. + Chris Morgan is writting code to use MonitorsDB. + If xorgcfg could be changed to ddcprobe (in all supported platforms), + it would be even be a better solution than using a database. + +o Add interface to allow changing comments without the need of editing + config file with a text editor. diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/XOrgCfg.pre b/xorg-server/hw/xfree86/utils/xorgcfg/XOrgCfg.pre new file mode 100644 index 000000000..0e7148de6 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/XOrgCfg.pre @@ -0,0 +1,1852 @@ +!! $XdotOrg: $ +!! +!! Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) +!! +!! 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 +!! CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +!! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +!! OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +!! SOFTWARE. +!! +!! Except as contained in this notice, the name of Conectiva Linux shall +!! not be used in advertising or otherwise to promote the sale, use or other +!! dealings in this Software without prior written authorization from +!! Conectiva Linux. +!! +!! Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> +!! +!! $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad,v 1.13 2001/05/15 18:22:23 paulo Exp $ +!! + +*Form.background: gray85 +*Label.background: gray85 +!! keyboard +*Core.background: gray85 +*Label.foreground: gray20 +*Command.background: gray80 +*Command.foreground: gray20 +*Command.borderWidth: 0 +*Command.displayList:\ +foreground gray60;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray90;\ +lines -1,0,0,0,0,-1 + +*Text.?.foreground: gray20 +*Text.borderWidth: 0 +*Text.background: gray96 +*Text.?.cursorColor: rgb:d/5/5 +*Text.displayList:\ +foreground white;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray40;\ +lines -1,0,0,0,0,-1 + +*baseTranslations: #override \ +<Key>Escape: vidmode-restore() + +*List.background: gray96 +*List.foreground: gray20 +*Viewport.borderColor: gray40 +*List.borderColor: gray40 + +*MenuButton.background: gray80 +*MenuButton.foreground: gray20 +*MenuButton.borderWidth: 0 +*MenuButton.displayList:\ +line-style solid;\ +foreground gray40;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray90;\ +lines -1,0,0,0,0,-1;\ +line-style onoffdash;\ +foreground gray80;\ +draw-rect 1,1,-2,-2 + +*SimpleMenu.background: gray80 +*SimpleMenu.?.foreground: gray20 +*SimpleMenu.borderWidth: 0 +*SimpleMenu.displayList:\ +foreground gray40;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray90;\ +lines -1,0,0,0,0,-1 + +*Dialog.displayList:\ +foreground gray40;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray90;\ +lines -1,0,0,0,0,-1 + +*Toggle.background: gray80 +*Toggle.foreground: gray20 +*Toggle.borderWidth: 0 +*Toggle.displayList:\ +foreground gray90;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray40;\ +lines -1,0,0,0,0,-1 + +*mouse.bitmap: mouse.xbm +*keyboard.bitmap: keyboard.xbm +*card.bitmap: card.xbm +*monitor.bitmap: monitor.xbm + +*Label.borderWidth: 0 +*Viewport.forceBars: True +*Viewport.allowVert: True +*Viewport.useRight: True + +.xorgcfg.geometry: 320x400 +.xorgcfg.minWidth: 320 +.xorgcfg.minHeight: 400 +.xorgcfg.maxWidth: 320 +.xorgcfg.maxHeight: 400 + +.xorgcfg.config.geometry: 320x369 +.xorgcfg.config.minWidth: 320 +.xorgcfg.config.maxWidth: 320 +.xorgcfg.config.minHeight: 369 +.xorgcfg.config.maxHeight: 369 + +*work.width: 320 +*work.height: 240 + +*error.label.label:\ +Not all required fields\n\ +were filled, or the specified\n\ +identifier is duplicated. +*error.label.vertDistance: 30 +*error.label.borderWidth: 0 +*error.label.leftBitmap: Excl +*error.command.fromVert: label +*error.command.label: Ok +*error.command.vertDistance: 20 + +*Scrollbar.translations:\ +<BtnDown>: StartScroll(Continuous) MoveThumb() NotifyThumb()\n\ +<BtnMotion>: MoveThumb() NotifyThumb()\n\ +<BtnUp>: NotifyScroll(Proportional) EndScroll() + +*Scrollbar.background: gray80 +*Scrollbar.foreground: rgb:a/5/5 +*Scrollbar.borderWidth: 0 +*Scrollbar.thumb: vlines2 +*Scrollbar.displayList:\ +foreground gray90;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray40;\ +lines -1,0,0,0,0,-1 + +*Text.Translations: #override \ +<Enter>: no-op()\n\ +<Leave>: no-op()\n\ +<Btn1Down>: set-keyboard-focus() select-start() + +*top.identifier.Translations: #override \ +<Enter>: no-op()\n\ +<Leave>: no-op()\n\ +<Key>Return: no-op()\n\ +<Btn1Down>: set-keyboard-focus() select-start() + +*List.showCurrent: True +*Tip.timeout: 100 +*Tip.background: rgb:f/f/8 +*Tip.foreground: gray20 +*Tip.borderWidth: 0 +*Tip.displayList:\ +foreground rgb:8/8/4;\ +lines 1,-1,-1,-1,-1,1;\ +foreground rgb:f/f/c;\ +lines -1,0,0,0,0,-1 + +*Toggle.internalHeight: 2 +*Toggle.internalWidth: 2 +*mouse.label: Mouse +*keyboard.label: Keyboard +*card.label: Card +*monitor.label: Monitor + +*commands.borderWidth: 0 +*commands.defaultDistance: 2 +*commands.?.bottom: chainTop +*commands.height: 50 + +*commands.keyboard.fromHoriz: mouse +*card.fromHoriz: keyboard +*monitor.fromHoriz: card + +*commands.mouse*new.label: Add new mouse +*commands.keyboard*new.label: Add new keyboard +*commands.card*new.label: Add new video card +*commands.monitor*new.label: Add new monitor +*commands.mouse*configure.label: Configure mouse(s) +*commands.keyboard*configure.label: Configure keyboard(s) +*commands.card*configure.label: Configure video card(s) +*commands.monitor*configure.label: Configure monitor(s) +*commands.mouse*SimpleMenu*newMouse.label: New mouse +*commands.keyboard*SimpleMenu*newKeyboard.label:New keyboard +*commands.card*SimpleMenu*newcard.label: New card +*commands.monitor*SimpleMenu*newMonitor.label: New monitor + +*commands.MenuButton.translations: \ +<Enter>: highlight()\n\ +<Leave>: reset()\n\ +Any<BtnDown>: highlight() set() PopupMenu() + +*hpane.showGrip: False +*hpane.expert.label: Expert Mode +*topM.min: 200 +*topM.max: 200 +*topM.justify: left +*topM.label: Configure Layout +*topM*layout.label: Configure Layout +*topM*screen.label: Configure Screen +*topM*modeline.label: Configure Modeline +*topM*accessx.label: Configure AccessX +*topM.showGrip: False +*work.showGrip: False + +*MenuButton.leftBitmap: menu10 +*SmeBSB.HorizontalMargins: 18 + +*back.label: << Back +*next.label: Next >> +*ok.label: Ok +*cancel.label: Cancel +*yes.label: Yes +*no.label: No + +*help.label: Help +*quit.label: Quit +*next.fromHoriz: back +*config*ok.fromHoriz: next +*bottom*cancel.fromHoriz: ok +*top.displayList:\ +foreground gray60;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 +*bottom.displayList:\ +foreground gray60;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 +*work.displayList:\ +foreground gray60;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 +*options.pane.Form.displayList:\ +foreground gray60;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 + +*top.label.label: Identifier: +*top.label.borderWidth: 0 +*top.identifier.fromHoriz: label +*top.label.internalHeight: 3 +*top.label.justify: left +*top.label.left: chainLeft +*top.label.right: chainLeft +*top.identifier.left: chainLeft +*top.identifier.right: chainRight + +*bottom.layout.translations: #override \ +<Key>Return: rename-layout() +*bottom.layout.label: New server layout +*bottom.layout.tip: Type a text and press Return to rename this layout +*bottom.Command.height: 19 +*bottom.Text.height: 19 +*bottom.MenuButton.height: 19 +*bottom*new.label: New server layout +*layout.fromHoriz: select +*help.fromHoriz: layout +*bottom.layout.justify: left +*bottom.select.label: Layout +*bottom.select.left: chainLeft +*bottom.select.right: chainLeft +*bottom.layout.left: chainLeft +*quit.fromHoriz: help +*bottom.?.left: chainRight +*bottom.?.right: chainRight +*bottom.?.top: chainBottom +*bottom.?.bottom: chainBottom + +*pane.bottom.min: 30 +*pane.bottom.max: 30 +*pane.bottom.showGrip: False +*pane.bottom.defaultDistance: 5 + +!! Wellcome message +*work.wellcome.borderWidth: 0 +*work.wellcome.label: Welcome to __VENDORNAME__ __VENDORVERS__ setup program +*work.?.borderWidth: 0 +!*work.?.width: 310 +*work.?.height: 290 + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! mouseDP widget +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*mouseDP*Label.internalHeight: 0 +*mouseDP*Label.borderWidth: 0 +*mouseDP.labelD.vertDistance: 0 +*mouseDP.labelD.label: Select mouse device +*mouseDP.device.fromVert: labelD +*mouseDP.viewportD.fromVert: device +*mouseDP.device.width: 302 +*mouseDP.viewportD.vertDistance: 2 +*mouseDP.viewportD.listD.longest: 135 +*mouseDP.viewportD.width: 302 +*mouseDP.viewportD.height: 87 +*mouseDP.labelP.label: Select mouse protocol +*mouseDP.labelP.vertDistance: 10 +*mouseDP.labelP.fromVert: viewportD +*mouseDP.viewportP.fromVert: labelP +*mouseDP.viewportP.forceBars: True +*mouseDP.viewportP.allowVert: True +*mouseDP.viewportP.useRight: True +*mouseDP.viewportP.listP.longest: 135 +*mouseDP.viewportP.width: 302 +*mouseDP.viewportP.height: 110 +*mouseDP.viewportP.vertDistance: 6 +*mouseDP*List.verticalList: True +*mouseDP.emulate3.fromVert: viewportP +*mouseDP.emulate3.width: 180 +*mouseDP.apply.label: Apply changes +*mouseDP.apply.fromVert: viewportP +*mouseDP.apply.fromHoriz: emulate3 +*mouseDP.apply.width: 116 +*mouseDP.emulate3.vertDistance: 10 +*mouseDP.apply.vertDistance: 10 +*mouseDP.emulate3.label: Emulate 3 buttons +*mouseDP.emulate3.tip: Select if your mouse has only two buttons + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! keyboardML widget +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*keyboardML.Label.vertDistance: 8 +*keyboardML.MenuButton.vertDistance: 8 +*keyboardML.keyboard.vertDistance: 10 +*keyboardML.Label.borderWidth: 0 +*keyboardML.Label.width: 115 +*keyboardML.MenuButton.width: 185 +*keyboardML.MenuButton.justify: left +*keyboardML.Label.internalWidth: 0 +*keyboardML.Label.justify: right +*keyboardML.labelR.label: Xkb rules: +*keyboardML.rules.left: chainRight +*keyboardML.rules.right: chainRight +*keyboardML.rules.fromHoriz: labelR +*keyboardML.model.fromVert: rules +*keyboardML.labelM.fromVert: rules +*keyboardML.model.left: chainRight +*keyboardML.model.right: chainRight +*keyboardML.model.fromHoriz: labelM +*keyboardML.labelM.label: Keyboard model: +*keyboardML.layout.left: chainRight +*keyboardML.layout.right: chainRight +*keyboardML.layout.fromVert: model +*keyboardML.labelL.fromVert: model +*keyboardML.layout.fromHoriz: labelL +*keyboardML.labelL.label: Keyboard layout: +*keyboardML.variant.fromVert: labelL +*keyboardML.variant.fromHoriz: labelV +*keyboardML.labelV.fromVert: labelL +*keyboardML.labelV.label: Xkb variant: +*keyboardML.options.fromVert: labelV +*keyboardML.options.fromHoriz: labelO +*keyboardML.labelO.fromVert: labelV +*keyboardML.labelO.label: Xkb options: +*keyboardML.keyboard.fromVert: labelO +*keyboardML.keyboard.borderWidth: 0 +*keyboardML.keyboard.width: 305 +*keyboardML.keyboard.height: 121 +*keyboardML.apply.vertDistance: 16 +*keyboardML.apply.fromVert: keyboard +*keyboardML.apply.label: Apply changes + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! cardModel widget +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*cardModel.label.internalHeight: 0 +*cardModel.keyboard.borderWidth: 0 +*cardModel.label.label: Card model filter +*cardModel.label.internalHeight: 2 +*cardModel.label.borderWidth: 0 +*cardModel.viewport.vertDistance: 2 +*cardModel.viewport.fromVert: filter +*cardModel.filter.fromHoriz: label +*cardModel.filter.width: 171 +*cardModel.viewport.width: 302 +*cardModel.viewport.height: 212 +*cardModel.driver.justify: left +*cardModel.driverL.label: Driver +*cardModel.driverL.fromVert: viewport +*cardModel.driverL.width: 50 +*cardModel.driverL.justify: right +*cardModel.driver.fromVert: viewport +*cardModel.driver.fromHoriz: driverL +*cardModel.driver.width: 250 +*cardModel.driver.left: chainRight +*cardModel.driver.right: chainRight +*cardModel.busidL.label: BusID +*cardModel.busidL.fromVert: driver +*cardModel.busidL.width: 50 +*cardModel.busidL.justify: right +*cardModel.busid.fromVert: driver +*cardModel.busid.fromHoriz: busidL +*cardModel.busid.width: 250 +*cardModel.busid.left: chainRight +*cardModel.busid.right: chainRight +*cardModel.viewport.forceBars: True +*cardModel.viewport.allowVert: True +*cardModel.viewport.useRight: True +*cardModel.viewport.list.longest: 277 +*cardModel.filter.tip: Type name or vendor of your card and press enter +*cardModel.filter.translations: #override \ +<Key>Return: filter-card() + + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! main widget +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*work.cpu.backgroundPixmap: computer.xpm +*work.mouse.backgroundPixmap: mouse.xpm +*work.keyboard.backgroundPixmap: keyboard.xpm +*work.card.backgroundPixmap: card.xpm +*work.monitor.backgroundPixmap: monitor.xpm + +*work.cpu.x: 130 +*work.cpu.y: 160 +*work.cpu.width: 30 +*work.cpu.height: 50 +*work.mouse.width: 26 +*work.mouse.height: 35 +*work.keyboard.width: 60 +*work.keyboard.height: 28 +*work.card.width: 41 +*work.card.height: 40 +*work.monitor.width: 47 +*work.monitor.height: 40 + +.xorgcfg.pane.work.Simple.borderWidth: 1 +.xorgcfg.pane.work.Simple.translations:\ +Any<Btn1Down>: select-device()\n\ +Any<Btn1Motion>: move-device()\n\ +Any<Btn1Up>: unselect-device()\n\ +Any<Btn3Down>: device-popup()\n\ +Any<Btn3Up>: device-popdown() + +.xorgcfg.pane.work.screen.translations:\ +Any<Btn1Down>: select-device()\n\ +Any<Btn1Motion>: move-device()\n\ +Any<Btn1Up>: unselect-device()\n\ +Any<Btn3Down>: device-popup()\n\ +Any<Btn3Up>: device-popdown() + +Xorgcfg.translations: #override \ +<Message>WM_PROTOCOLS: quit() +.xorgcfg.config.translations: #override \ +<Message>WM_PROTOCOLS: config-cancel() +.xorgcfg.options.translations: #override \ +<Message>WM_PROTOCOLS: options-cancel() +.xorgcfg.quit.translations: #override \ +<Message>WM_PROTOCOLS: quit-cancel() +.xorgcfg.error.translations: #override \ +<Message>WM_PROTOCOLS: error-cancel() +.xorgcfg.force.translations: #override \ +<Message>WM_PROTOCOLS: addmode-cancel() +.xorgcfg.addMode.translations: #override \ +<Message>WM_PROTOCOLS: addmode-cancel() +.xorgcfg.accessx.translations: #override \ +<Message>WM_PROTOCOLS: accessx-close() +.xorgcfg.test.translations: #override \ +<Message>WM_PROTOCOLS: testmode-cancel() +.xorgcfg.Expert.translations: #override \ +<Message>WM_PROTOCOLS: expert-close() +.xorgcfg.options.moduleOptions.translations: #override \ +<Message>WM_PROTOCOLS: module-options-close() + + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! Options +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.xorgcfg.options.geometry: 400x176 +.xorgcfg.options.minWidth: 400 +.xorgcfg.options.maxWidth: 400 +.xorgcfg.options.minHeight: 176 +.xorgcfg.options.maxHeight: 176 + +*options*commands.remove.fromHoriz: add +*options*commands.update.fromHoriz: remove +*options*commands.help.fromHoriz: update +*options*commands.min: 30 +*options*commands.max: 30 +*options*commands.showGrip: False +*options*commands.defaultDistance: 4 +*options*commands.?.width: 100 +*options*commands.?.height: 20 + +*options*name.fromHoriz: label1 +*options*label2.fromHoriz: name +*options*value.fromHoriz: label2 +*options*label3.fromHoriz: value +*options*viewport.fromVert: name +*options*Label.borderWidth: 0 +*options.pane.form.Label.internalWidth: 0 +*options.pane.form.Label.height: 21 +*options.pane.form.Text.height: 19 +*options.pane.form.Label.top: chainTop +*options.pane.form.Text.top: chainTop +*options.pane.form.Label.bottom: chainTop +*options.pane.form.Text.bottom: chainTop +*options.pane.form.Label.horizDistance: 0 +*options.pane.form.Text.horizDistance: 0 +*options.pane.form.Label.vertDistance: 8 +*options.pane.form.Text.vertDistance: 8 +*options.pane.form.Text.width: 147 +*options*viewport.width: 390 +*options*viewport.height: 50 + +*options*viewport.horizDistance: 7 +*options*label1.horizDistance: 5 +*options*viewport.left: chainLeft +*options*viewport.right: chainRight +*options*list.longest: 376 + +*options*driverOpts.label: Options for module +*options*driverOpts.justify: left +*options*driverOpts.width: 278 +*options*popdown.label: Popdown dialog +*options*driverOpts.tip: This menu shows:\n\ + o option name\n\ + o option type + +.xorgcfg*options.moduleOptions.geometry: 360x245 +.xorgcfg*options.moduleOptions.minWidth: 360 +.xorgcfg*options.moduleOptions.maxWidth: 360 +.xorgcfg*options.moduleOptions.minHeight: 245 +.xorgcfg*options.moduleOptions.maxHeight: 245 +*options.moduleOptions*descriptions*labelType.label: Select option +*options.moduleOptions*descriptions*labelType.width: 348 +*options.moduleOptions*descriptions*module.fromVert: labelType +*options.moduleOptions*descriptions*module.label: Module +*options.moduleOptions*descriptions*Label.horizDistance: 8 +*options.moduleOptions*descriptions*option.fromVert: labelType +*options.moduleOptions*descriptions*option.label: Option +*options.moduleOptions*descriptions*option.fromHoriz: viewM +*options.moduleOptions*descriptions*viewM.fromVert: module +*options.moduleOptions*descriptions*viewM.width: 120 +*options.moduleOptions*descriptions*viewM.height: 94 +*options.moduleOptions*descriptions*modL.longest: 100 +*options.moduleOptions*descriptions*viewO.fromHoriz: viewM +*options.moduleOptions*descriptions*viewO.fromVert: option +*options.moduleOptions*descriptions*viewO.width: 220 +*options.moduleOptions*descriptions*viewO.height: 94 +*options.moduleOptions*descriptions*optL.longest: 220 +*options.moduleOptions*descriptions*desc.horizDistance: 4 +*options.moduleOptions*descriptions*desc.fromVert: viewM +*options.moduleOptions*descriptions*desc.width: 348 +*options.moduleOptions*descriptions*desc.height: 62 +*options.moduleOptions*descriptions*desc.wrap: word +*options.moduleOptions*descriptions*desc.scrollVertical: Always +*options.moduleOptions*descriptions*desc.Scrollbar.foreground: rgb:a/5/5 +*options.moduleOptions*descriptions*desc.Scrollbar.borderWidth: 1 +*options.moduleOptions*descriptions*desc.Scrollbar.borderColor: gray60 +*options.moduleOptions*descriptions.showGrip: False +*options.moduleOptions*popdown.label: Popdown dialog + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! monitor +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*monitorl*Viewport.width: 302 +*monitorl*Text.width: 160 +*monitorl*Text.tip:\ +Select standard value from the list\n\ +below, or enter specific value here. + +*monitorl*hlabel.justify: right +*monitorl*hlabel.width: 138 +*monitorl*hlabel.label: Horizontal sync +*monitorl*hsync.fromHoriz: hlabel +*monitorl*hviewport.fromVert: hsync +*monitorl*hviewport.height: 156 +*monitorl*hlist.longest: 288 + +*monitorl*vlabel.justify: right +*monitorl*vlabel.width: 138 +*monitorl*vlabel.vertDistance: 12 +*monitorl*vsync.vertDistance: 12 +*monitorl*vlabel.fromVert: hviewport +*monitorl*vsync.fromVert: hviewport +*monitorl*vlabel.label: Vertical sync +*monitorl*vsync.fromHoriz: vlabel +*monitorl*vviewport.fromVert: vsync +*monitorl*vviewport.height: 20 +*monitorl*vlist.longest: 64 + +*monitorl*clabel.vertDistance: 12 +*monitorl*clabel.fromVert: vviewport +*monitorl*clabel.label: Select card connected to monitor +*monitorl*cmenu.fromVert: clabel +*monitorl*cmenu.width: 302 +*monitorl*cmenu.justify: left +*monitorl*none.label: None + +!! vidtune +*vidtune.Repeater.borderWidth: 1 +*vidtune.Repeater.borderColor: gray90 +*vidtune.Repeater.shapeStyle: ellipse +*vidtune.Repeater.foreground: gray30 +*vidtune.Repeater.background: gray80 +*vidtune.Repeater.width: 31 +*vidtune.Repeater.height: 29 +*vidtune.Repeater.repeatDelay: 200 +*vidtune.Repeater.decay: 0 +*vidtune.Repeater.displayList:\ +line-width 2;\ +foreground gray65;\ +draw-arc 0,0,-0,-0,230,180;\ +foreground gray95;\ +draw-arc 0,0,-0,-0,40,180;\ +foreground gray80;\ +draw-arc 0,0,-0,-0,220,10;\ +draw-arc 0,0,-0,-0,40,10 +*vidtune.Repeater.translations:\ +<Enter>: set-values(1, borderColor, gray50)\n\ +<Leave>: set-values(1, borderColor, gray90)\n\ +<Btn1Down>: set-values(1, borderColor, gray90) set() start()\n\ +<Btn1Up>: stop() unset() +*vidtune.left.bitmap: left.xbm +*vidtune.right.bitmap: right.xbm +*vidtune.up.bitmap: up.xbm +*vidtune.down.bitmap: down.xbm +*vidtune.wider.bitmap: wider.xbm +*vidtune.narrower.bitmap: narrower.xbm +*vidtune.shorter.bitmap: shorter.xbm +*vidtune.taller.bitmap: taller.xbm + +*vidtune.vesaB.label: Add standard VESA mode to current screen +*vidtune.vesaB.width: 312 + +*vidtune.screenB.fromVert: mode +*vidtune.screenB.width: 160 +*vidtune.screenB.horizDistance: 80 +*vidtune.prev.fromVert: vesaB +*vidtune.mode.fromVert: vesaB +*vidtune.next.fromVert: vesaB +*vidtune.prev.horizDistance: 54 +*vidtune.prev.label: << +*vidtune.mode.fromHoriz: prev +*vidtune.mode.width: 160 +*vidtune.next.label: >> +*vidtune.next.fromHoriz: mode + +*vidtune.up.fromVert: screenB +*vidtune.up.horizDistance: 143 +*vidtune.left.horizDistance: 98 +*vidtune.left.vertDistance: 16 +*vidtune.left.fromVert: up +*vidtune.monitor.fromVert: up +*vidtune.monitor.vertDistance: 0 +*vidtune.monitor.fromHoriz: left +*vidtune.right.vertDistance: 16 +*vidtune.right.fromVert: up +*vidtune.right.fromHoriz: monitor +*vidtune.down.horizDistance: 143 +*vidtune.down.fromVert: monitor +*vidtune.wider.fromVert: left +*vidtune.wider.horizDistance: 91 +*vidtune.narrower.fromVert: down +*vidtune.narrower.fromHoriz: wider +*vidtune.shorter.fromVert: down +*vidtune.shorter.fromHoriz: narrower +*vidtune.taller.fromVert: right +*vidtune.taller.fromHoriz: shorter +*vidtune.monitor.width: 47 +*vidtune.monitor.height: 40 +*vidtune.monitor.backgroundPixmap: monitor.xpm +*vidtune.narrower.horizDistance: 0 +*vidtune.shorter.horizDistance: 2 +*vidtune.taller.horizDistance: 0 +*vidtune.wider.vertDistance: 20 +*vidtune.taller.vertDistance: 20 +*vidtune.narrower.vertDistance: 0 +*vidtune.shorter.vertDistance: 0 +*vidtune.down.vertDistance: 0 + +*vidtune.monitor.tip:\ +\ WARNING\n\ +\ Using the controls here may damage your\n\ +monitor. You can safely skip this section\n\ +of the configuration process.\n\ +\n\ +Press ESC if your monitor goes out of sync. + +*vidtune.background: white +*vidtune.form.borderWidth: 0 +*vidtune.form.background: white +*vidtune.form.defaultDistance: 0 +*vidtune.form.vertDistance: 3 +*vidtune.form.horizDistance: 4 +*vidtune.form.Label.foreground: gray20 +*vidtune.form.Label.background: white +*vidtune.form.Label.font: -*-fixed-*-*-*-*-10-*-*-*-*-*-*-1 +*vidtune.form.Label.vertDistance: 0 +*vidtune*Label.justify: right + +*vidtune.form.fromVert: auto +*vidtune*hsyncstart.label: HSyncStart: +*vidtune*hsyncstart.width: 95 +*vidtune*v-hsyncstart.width: 40 +*vidtune*v-hsyncstart.fromHoriz: hsyncstart +*vidtune*vsyncstart.fromHoriz: v-hsyncstart +*vidtune*v-vsyncstart.fromHoriz: vsyncstart +*vidtune*vsyncstart.label: VSyncStart: +*vidtune*vsyncstart.width: 95 +*vidtune*v-vsyncstart.width: 40 +*vidtune*hsyncend.label: HSyncEnd: +*vidtune*hsyncend.width: 95 +*vidtune*v-hsyncend.width: 40 +*vidtune*v-hsyncend.fromHoriz: hsyncend +*vidtune*hsyncend.fromVert: hsyncstart +*vidtune*v-hsyncend.fromVert: v-hsyncstart +*vidtune*vsyncend.label: VSyncEnd: +*vidtune*vsyncend.width: 95 +*vidtune*v-vsyncend.width: 40 +*vidtune*vsyncend.fromHoriz: v-hsyncend +*vidtune*v-vsyncend.fromHoriz: vsyncend +*vidtune*vsyncend.fromVert: hsyncstart +*vidtune*v-vsyncend.fromVert: v-vsyncstart +*vidtune*htotal.label: HTotal: +*vidtune*htotal.width: 95 +*vidtune*v-htotal.width: 40 +*vidtune*v-htotal.fromHoriz: htotal +*vidtune*htotal.fromVert: hsyncend +*vidtune*v-htotal.fromVert: v-hsyncend +*vidtune*vtotal.label: VTotal: +*vidtune*vtotal.width: 95 +*vidtune*v-vtotal.width: 40 +*vidtune*vtotal.fromHoriz: v-htotal +*vidtune*v-vtotal.fromHoriz: vtotal +*vidtune*vtotal.fromVert: vsyncend +*vidtune*v-vtotal.fromVert: v-vsyncend +*vidtune*flags.label: Flags: +*vidtune*flags.width: 142 +*vidtune*v-flags.width: 156 +*vidtune*v-flags.justify: left +*vidtune*v-flags.fromHoriz: flags +*vidtune*flags.fromVert: vtotal +*vidtune*v-flags.fromVert: v-vtotal +*vidtune*clock.label: Pixel Clock (MHz): +*vidtune*clock.width: 142 +*vidtune*v-clock.width: 48 +*vidtune*v-clock.fromHoriz: clock +*vidtune*clock.fromVert: flags +*vidtune*v-clock.fromVert: v-flags +*vidtune*hsync.label: Horizontal Sync (kHz): +*vidtune*hsync.width: 142 +*vidtune*v-hsync.width: 48 +*vidtune*v-hsync.fromHoriz: hsync +*vidtune*hsync.fromVert: clock +*vidtune*v-hsync.fromVert: v-clock +*vidtune*vsync.label: Vertical Sync (Hz): +*vidtune*vsync.width: 142 +*vidtune*v-vsync.width: 48 +*vidtune*v-vsync.fromHoriz: vsync +*vidtune*vsync.fromVert: hsync +*vidtune*v-vsync.fromVert: v-hsync + +*vidtune.auto.horizDistance: 43 +*vidtune.auto.fromVert: narrower +*vidtune.auto.label: Auto +!*vidtune.auto.state: True +*vidtune.apply.fromVert: narrower +*vidtune.apply.fromHoriz: auto +*vidtune.apply.label: Apply +*vidtune.restore.fromHoriz: apply +*vidtune.restore.horizDistance: 4 +*vidtune.restore.fromVert: narrower +*vidtune.restore.label: Restore +*vidtune.update.fromVert: narrower +*vidtune.update.fromHoriz: restore +*vidtune.update.label: Update +*vidtune.test.fromVert: narrower +*vidtune.test.fromHoriz: update +*vidtune.test.label: Test + +*vidtune.Label.background: white +*vidtune.addto.vertDistance: 4 +*vidtune.addto.fromHoriz: add +*vidtune.addto.fromVert: form +*vidtune.addto.label: mode to +*vidtune.addto.horizDistance: 0 +*vidtune.ident.vertDistance: 4 +*vidtune.ident.horizDistance: 0 +*vidtune.ident.fromVert: form +*vidtune.ident.fromHoriz: addto +*vidtune.ident.width: 98 +*vidtune.ident.justify: left +*vidtune.as.vertDistance: 4 +*vidtune.as.horizDistance: 0 +*vidtune.as.fromVert: form +*vidtune.as.fromHoriz: ident +*vidtune.as.label: as: +*vidtune.text.vertDistance: 4 +*vidtune.text.horizDistance: 0 +*vidtune.text.fromVert: form +*vidtune.text.fromHoriz: as +*vidtune.text.width: 98 +*vidtune.add.vertDistance: 4 +*vidtune.add.fromVert: form +*vidtune.add.label: Add +.xorgcfg.force.geometry: 268x58 +.xorgcfg.force.minWidth: 268 +.xorgcfg.force.maxWidth: 268 +.xorgcfg.force.minHeight: 58 +.xorgcfg.force.maxHeight: 58 +.xorgcfg.force.?.label: There is already a modeline with the\n\ +specified identifier. Add anyway? + +.xorgcfg.addMode.geometry: 350x80 +.xorgcfg.addMode.minWidth: 350 +.xorgcfg.addMode.maxWidth: 350 +.xorgcfg.addMode.minHeight: 80 +.xorgcfg.addMode.maxHeight: 80 +.xorgcfg.addMode.?.label: XF86VidModeAddModeLine returned True,\n\ +but no modeline was added to the current Screen.\n\ +Do you want to add it to the Monitor section? + +.xorgcfg.test.?.label: \ Testing modeline...\n\n\ +Press ESC or stop button to quit. +.xorgcfg.test.geometry: 250x72 +.xorgcfg.test.minWidth: 250 +.xorgcfg.test.maxWidth: 250 +.xorgcfg.test.minHeight: 72 +.xorgcfg.test.maxHeight: 72 + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! screen +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*screenD*depthL.label: Default color depth: +*screenD*depthL.height: 20 +*screenD*1.fromHoriz: depthL +*screenD*4.fromHoriz: 1 +*screenD*8.fromHoriz: 4 +*screenD*16.fromHoriz: 8 +*screenD*24.fromHoriz: 16 +*screenD*1.width: 24 +*screenD*4.width: 24 +*screenD*8.width: 24 +*screenD*16.width: 24 +*screenD*24.width: 24 +*screenD*1.horizDistance: 5 +*screenD*4.horizDistance: 5 +*screenD*8.horizDistance: 5 +*screenD*16.horizDistance: 5 +*screenD*24.horizDistance: 5 +*screenD*modeL.fromVert: depthL +*screenD*modeL.vertDistance: 14 +*screenD*modeL.label: Select resolution(s): +*screenD*viewL.fromVert: modeL +*screenD*select.fromHoriz: viewL +*screenD*unselect.fromHoriz: viewL +*screenD*select.fromVert: modeL +*screenD*unselect.fromVert: select +*screenD*up.fromHoriz: viewL +*screenD*down.fromHoriz: viewL +*screenD*up.fromVert: unselect +*screenD*down.fromVert: up +*screenD*viewR.fromHoriz: select +*screenD*viewR.fromVert: modeL +*screenD*select.bitmap: right.xbm +*screenD*unselect.bitmap: left.xbm +*screenD*up.bitmap: up.xbm +*screenD*down.bitmap: down.xbm +*screenD*viewL.width: 133 +*screenD*viewR.width: 133 +*screenD*viewL.height: 184 +*screenD*viewR.height: 184 +*screenD*listLeft.longest: 128 +*screenD*listRight.longest: 128 +*screenD*rotate.tip: Don't select any option if\n\ +your monitor is not rotated. +*screenD*rotate.vertDistance: 14 +*screenD*rotate.fromVert: viewL +*screenD*rotate.label: Rotate screen: +*screenD*CW.tip: Clock wise +*screenD*CW.vertDistance: 14 +*screenD*CW.fromVert: viewL +*screenD*CW.fromHoriz: rotate +*screenD*CW.label: CW +*screenD*CW.width: 40 +*screenD*CCW.tip: Counter-clock wise +*screenD*CCW.vertDistance: 14 +*screenD*CCW.fromVert: viewL +*screenD*CCW.fromHoriz: CW +*screenD*CCW.label: CCW +*screenD*CCW.width: 40 + +*work.screen.width: 100 +*work.screen.height: 80 + + +*Dialog.background: gray85 +*quit.ask.label: Write configuration to +*quit.ask.value.translations: #override \ +<Key>Return: write-config() +*quit.ask.label.justify: left +*quit.ask.value.width: 222 +*quit.ask.icon: Excl +.xorgcfg.quit.geometry: 230x92 +.xorgcfg.quit.minWidth: 230 +.xorgcfg.quit.maxWidth: 230 +.xorgcfg.quit.minHeight: 92 +.xorgcfg.quit.maxHeight: 92 + +*error.notice.label: Failed to write configuration file. +.xorgcfg.error.geometry: 280x50 +.xorgcfg.error.minWidth: 260 +.xorgcfg.error.maxWidth: 260 +.xorgcfg.error.minHeight: 50 +.xorgcfg.error.maxHeight: 50 + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! accessx +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*Accessx*Label.font: -*-fixed-medium-r-*-*-13-*-*-*-*-*-iso8859-1 +*Accessx.Form.Toggle.font: -*-fixed-medium-r-*-*-13-*-*-*-*-*-iso8859-1 +*Accessx*Label.background: white +*Accessx*Label.justify: left +*Accessx*Label.internalHeight: 0 +*Accessx*Label.internalWidth: 0 +*Accessx*Label.foreground: gray35 +*Accessx*Toggle.internalHeight: 0 +*Accessx.Toggle.internalWidth: 18 +*Accessx.Toggle.justify: left +*Accessx.Toggle.foreground: gray30 +*Accessx.Toggle.background: white +*Accessx*Toggle.highlightThickness: 0 +*Accessx.Toggle.foreground: rgb:f/7/7 +*Accessx.Toggle.displayList:\ +foreground white;\ +points 0,0,-1,0;\ +foreground rgb:f/7/7;\ +fill-poly 0,2,0,-3,8,6 +*Accessx.Toggle.translations: \ +<Btn1Down>,<Btn1Up>: toggle() notify()\n\ +<Enter>: set-values(1, displayList, "foreground white;points 0,0,-1,0;fill-poly 0,1,10,6,0,-2;foreground rgb:7/7/f;fill-poly 0,2,0,-3,8,6")\n\ +<Leave>: set-values(1, displayList, "foreground white;points 0,0,-1,0;foreground rgb:f/7/7;fill-poly 0,2,0,-3,8,6") +*Accessx.Form.borderWidth: 1 +*Accessx.Form.borderColor: rgb:f/a/a +*Accessx.Form.vertDistance: 0 +*Accessx.Form.defaultDistance: 2 +*Accessx.borderWidth: 0 +*accessxForm.background: white +*Accessx*Form.background: white +*Accessx.background: white +*accessxForm.enable.label: Enable AccessX +*accessxForm.enable.width: 208 +*accessxForm.apply.fromHoriz: enable +*accessxForm.apply.label: Apply changes +*accessxForm.Accessx.fromVert: enable +*Accessx.timeoutToggle.background: white +*Accessx.timeoutToggle.foreground: rgb:7/7/f +*Accessx.timeoutToggle.displayList:\ +foreground rgb:a/a/f;\ +lines 1,-1,-1,-1,-1,1;\ +foreground rgb:2/2/a;\ +lines -1,0,0,0,0,-1 + +*Accessx.Form.Toggle.background: white +*Accessx.Form.Toggle.foreground: rgb:7/7/f +*Accessx.Form.Toggle.displayList:\ +foreground rgb:a/a/f;\ +lines 1,-1,-1,-1,-1,1;\ +foreground rgb:2/2/a;\ +lines -1,0,0,0,0,-1 +*Accessx.Form.Toggle.translations: \ +<Btn1Down>,<Btn1Up>: toggle() notify()\n\ +<Enter>: set-values(1, displayList, "foreground rgb:a/a/f;lines 1,-1,-1,-1,-1,1;foreground rgb:2/2/a;lines -1,0,0,0,0,-1;foreground rgb:f/7/7;draw-rect 1,1,-2,-2")\n\ +<Leave>: set-values(1, displayList, "foreground rgb:a/a/f;lines 1,-1,-1,-1,-1,1;foreground rgb:2/2/a;lines -1,0,0,0,0,-1") + +*Accessx.timeoutToggle.internalWidth: 4 +*Accessx.timeoutToggle.translations:\ +<Btn1Down>,<Btn1Up>: toggle() notify() +*Accessx.timeoutToggle.internalWidth: 4 +*Accessx.timeoutToggle.internalHeight: 1 +*Accessx.timeoutToggle.vertDistance: 6 +*Accessx.timeoutToggle.label: Time Out +*Accessx.timeoutLabel.fromHoriz: timeoutToggle +*Accessx.timeoutLabel.vertDistance: 7 +*Accessx.timeoutLabel.label: Time (min) +*Accessx.Label.background: white +*Accessx.timeoutNumber.vertDistance: 1 +*Accessx.timeoutNumber.fromHoriz: timeoutLabel +*Accessx.timeoutNumber.font: 6x9 +*Accessx.timeoutNumber.label: ?? +*Accessx.timeoutScroller.fromVert: timeoutNumber +*Accessx.timeoutScroller.fromHoriz: timeoutLabel +*Accessx.timeoutScroller.width: 133 +*Accessx.timeoutScroller.horizDistance: 31 +*Accessx*Scrollbar.vertDistance: 0 +*Accessx*Scrollbar.orientation: horizontal +*Accessx*Scrollbar.thumb: black +*Accessx*Scrollbar.height: 8 +*Accessx*Scrollbar.minimumThumb: 5 +*Accessx*Scrollbar.borderWidth: 1 +*Accessx*Scrollbar.borderColor: white +*Accessx*Scrollbar.foreground: rgb:f/7/7 +*Accessx*Scrollbar.background: gray95 +*Accessx*Scrollbar.displayList:\ +foreground gray80;\ +lines 1,-1,-1,-1,-1,1;\ +foreground gray90;\ +lines -1,0,0,0,0,-1 +*Accessx.sticky.fromVert: timeoutToggle +*Accessx.sticky.vertDistance: 6 +*Accessx.sticky.label: Enable StickyKeys +*Accessx.sticky.width: 304 +*Accessx.stickyForm.fromVert: sticky +*Accessx.stickyForm.Toggle.width: 148 +*Accessx.stickyForm.Toggle.internalHeight: 1 +*Accessx.stickyForm.auto.label: Auto off +*Accessx.stickyForm.beep.fromHoriz: auto +*Accessx.stickyForm.beep.label: Modifiers beep +*Accessx.mouseKeys.fromVert: stickyForm +*Accessx.mouseKeys.width: 304 +*Accessx.mouseKeys.vertDistance: 6 +*Accessx.mouseKeys.label: Enable MouseKeys +*Accessx.mouseForm.fromVert: mouseKeys +*Accessx.mouseForm.speedLabel.vertDistance: 7 +*Accessx.mouseForm.speedLabel.label: Peak speed (pixels/sec) +*Accessx.mouseForm.speedNumber.fromHoriz: speedLabel +*Accessx.mouseForm.speedNumber.font: 6x9 +*Accessx.mouseForm.speedNumber.label: ??? +*Accessx.mouseForm.speedScroller.fromHoriz: speedLabel +*Accessx.mouseForm.speedScroller.fromVert: speedNumber +*Accessx.mouseForm.speedScroller.width: 133 +*Accessx.mouseForm.timeLabel.fromVert: speedScroller +*Accessx.mouseForm.timeLabel.label: Time to peak (sec) +*Accessx.mouseForm.timeLabel.vertDistance: 7 +*Accessx.mouseForm.timeNumber.label: ??? +*Accessx.mouseForm.timeNumber.fromVert: speedScroller +*Accessx.mouseForm.timeNumber.fromHoriz: timeLabel +*Accessx.mouseForm.timeNumber.font: 6x9 +*Accessx.mouseForm.timeScroller.fromHoriz: timeLabel +*Accessx.mouseForm.timeScroller.fromVert: timeNumber +*Accessx.mouseForm.timeScroller.width: 133 +*Accessx.mouseForm.timeScroller.horizDistance: 37 +*Accessx.mouseForm.delayLabel.fromVert: timeScroller +*Accessx.mouseForm.delayLabel.label: Motion delay (sec) +*Accessx.mouseForm.delayLabel.tip:\ +Time between the initial key press\n\ +and the first repeated motion event +*Accessx.mouseForm.delayLabel.vertDistance: 7 +*Accessx.mouseForm.delayNumber.label: ??? +*Accessx.mouseForm.delayNumber.fromVert: timeScroller +*Accessx.mouseForm.delayNumber.fromHoriz: delayLabel +*Accessx.mouseForm.delayNumber.font: 6x9 +*Accessx.mouseForm.delayScroller.fromHoriz: delayLabel +*Accessx.mouseForm.delayScroller.fromVert: delayNumber +*Accessx.mouseForm.delayScroller.width: 133 +*Accessx.mouseForm.delayScroller.horizDistance: 37 +*Accessx.repeatKeys.fromVert: mouseForm +*Accessx.repeatKeys.width: 304 +*Accessx.repeatKeys.vertDistance: 6 +*Accessx.repeatKeys.label: Enable RepeatKeys +*Accessx.repeatForm.fromVert: repeatKeys +*Accessx.repeatForm.rateLabel.vertDistance: 7 +*Accessx.repeatForm.rateLabel.label: Repeat rate (sec/key) +*Accessx.repeatForm.rateNumber.fromHoriz: rateLabel +*Accessx.repeatForm.rateNumber.font: 6x9 +*Accessx.repeatForm.rateNumber.label: ???? +*Accessx.repeatForm.rateScroller.fromHoriz: rateLabel +*Accessx.repeatForm.rateScroller.fromVert: rateNumber +*Accessx.repeatForm.rateScroller.width: 133 +*Accessx.repeatForm.rateScroller.horizDistance: 16 +*Accessx.repeatForm.delayLabel.fromVert: rateScroller +*Accessx.repeatForm.delayLabel.label: Repeat delay (sec) +*Accessx.repeatForm.delayLabel.vertDistance: 7 +*Accessx.repeatForm.delayNumber.label: ???? +*Accessx.repeatForm.delayNumber.fromVert: rateScroller +*Accessx.repeatForm.delayNumber.fromHoriz: delayLabel +*Accessx.repeatForm.delayNumber.font: 6x9 +*Accessx.repeatForm.delayScroller.fromHoriz: delayLabel +*Accessx.repeatForm.delayScroller.fromVert: delayNumber +*Accessx.repeatForm.delayScroller.width: 133 +*Accessx.repeatForm.delayScroller.horizDistance: 37 +*Accessx.slow.fromVert: repeatForm +*Accessx.slow.vertDistance: 6 +*Accessx.slow.label: Enable SlowKeys +*Accessx.slow.width: 304 +*Accessx.slowForm.fromVert: slow +*Accessx.slowForm.Toggle.horizDistance: 4 +*Accessx.slowForm.Toggle.internalWidth: 4 +*Accessx.slowForm.Toggle.internalHeight: 1 +*Accessx.slowForm.beep.label: Beep when key is +*Accessx.slowForm.beep.vertDistance: 3 +*Accessx.slowForm.pressed.fromHoriz: beep +*Accessx.slowForm.pressed.label: pressed +*Accessx.slowForm.accepted.fromHoriz: pressed +*Accessx.slowForm.accepted.label: accepted +*Accessx.slowForm.slowLabel.fromVert: accepted +*Accessx.slowForm.slowLabel.label: Key delay (sec) +*Accessx.slowForm.slowLabel.vertDistance: 7 +*Accessx.slowForm.slowNumber.label: ??? +*Accessx.slowForm.slowNumber.fromVert: accepted +*Accessx.slowForm.slowNumber.fromHoriz: slowLabel +*Accessx.slowForm.slowNumber.font: 6x9 +*Accessx.slowForm.slowScroller.fromHoriz: slowLabel +*Accessx.slowForm.slowScroller.fromVert: slowNumber +*Accessx.slowForm.slowScroller.width: 133 +*Accessx.slowForm.slowScroller.horizDistance: 58 +*Accessx.bounce.fromVert: slowForm +*Accessx.bounce.vertDistance: 6 +*Accessx.bounce.label: Enable BounceKeys +*Accessx.bounce.width: 304 +*Accessx.bounceForm.fromVert: bounce +*Accessx.bounceForm.bounceLabel.label: Debounce time (sec) +*Accessx.bounceForm.bounceLabel.vertDistance: 7 +*Accessx.bounceForm.bounceNumber.label: ??? +*Accessx.bounceForm.bounceNumber.fromHoriz: bounceLabel +*Accessx.bounceForm.bounceNumber.font: 6x9 +*Accessx.bounceForm.bounceScroller.fromHoriz: bounceLabel +*Accessx.bounceForm.bounceScroller.fromVert: bounceNumber +*Accessx.bounceForm.bounceScroller.width: 133 +*Accessx.bounceForm.bounceScroller.horizDistance: 30 + +*accessx.geometry: 220x253 +*accessx.minWidth: 220 +*accessx.maxWidth: 220 +*accessx.minHeight: 253 +*accessx.maxHeight: 253 +*accessx*lock.fromVert: label +*accessx*div.fromVert: label +*accessx*div.fromHoriz: lock +*accessx*mul.fromVert: label +*accessx*mul.fromHoriz: div +*accessx*minus.fromVert: label +*accessx*minus.fromHoriz: mul +*accessx*7.fromVert: lock +*accessx*8.fromVert: div +*accessx*8.fromHoriz: 7 +*accessx*9.fromVert: mul +*accessx*9.fromHoriz: 8 +*accessx*plus.fromVert: minus +*accessx*plus.fromHoriz: 9 +*accessx*4.fromVert: 7 +*accessx*5.fromVert: 8 +*accessx*5.fromHoriz: 4 +*accessx*6.fromVert: 9 +*accessx*6.fromHoriz: 5 +*accessx*1.fromVert: 4 +*accessx*2.fromVert: 5 +*accessx*2.fromHoriz: 1 +*accessx*3.fromVert: 6 +*accessx*3.fromHoriz: 2 +*accessx*enter.fromVert: plus +*accessx*enter.fromHoriz: 3 +*accessx*0.fromVert: 2 +*accessx*del.fromVert: 3 +*accessx*del.fromHoriz: 0 +*accessx.form.background: gray80 +*accessx*Label.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1 +*accessx*label.font: fixed +*accessx*Label.font: -*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1 +*accessx*Label.width: 50 +*accessx*Label.height: 35 +*accessx*label.width: 212 +*accessx*label.height: 50 +*accessx*plus.height: 74 +*accessx*enter.height: 74 +*accessx*0.width: 104 +*accessx*lock.label: Num\nLock +*accessx*div.label: /\n +*accessx*mul.label: *\n +*accessx*minus.label: -\n +*accessx*7.label: 7\n +*accessx*8.label: 8\n +*accessx*9.label: 9\n +*accessx*plus.label: +\n\ \n\ \n\ \n +*accessx*4.label: 4\n +*accessx*5.label: 5\n +*accessx*6.label: 6\n +*accessx*1.label: 1\n +*accessx*2.label: 2\n +*accessx*3.label: 3\n +*accessx*enter.label: Enter\n\ \n\ \n\ \n +*accessx*0.label: 0\n +*accessx*del.label: .\n\ \n +*accessx*label.displayList:\ +foreground white;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground gray20;\ +lines -1,0,0,0,0,-1 +*accessx*label.label:\ +If your mouse does not work, use\n\ +the numeric keypad, following\n\ +the diagram bellow. +*accessx*div.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\ +draw-string 4,30, "Button 1" +*accessx*mul.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\ +draw-string 4,30, "Button 2" +*accessx*minus.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\ +draw-string 4,30, "Button 3" +*accessx*7.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 20,20,20,30,30,20 +*accessx*8.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 30,20,20,30,40,30 +*accessx*9.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 20,20,30,30,30,20 +*accessx*plus.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\ +draw-string 9,46, "Double";\ +draw-string 14,60, "Click" +*accessx*4.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 22,22,30,30,30,14 +*accessx*5.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-10*-*-*-*-*-*-1;\ +draw-string 14,30, "Click" +*accessx*6.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 30,22,22,30,22,14 +*accessx*1.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 20,20,20,30,30,30 +*accessx*2.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 28,30,20,22,36,22 +*accessx*3.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +fill-poly 20,30,30,30,30,20 +*accessx*enter.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\ +draw-string 9,46, "Toggle";\ +draw-string 10,60, "Speed" +*accessx*0.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-10-*-*-*-*-*-*-1;\ +draw-string 26,30, "Button Lock" +*accessx*del.displayList:\ +foreground gray20;\ +lines +1,-1,-1,-1,-1,+1;\ +foreground white;\ +lines -1,0,0,0,0,-1;\ +foreground red;\ +font -*-helvetica-bold-o-*-*-8-*-*-*-*-*-*-1;\ +draw-string 12,21, "Button";\ +draw-string 9,30, "Release" + +*panner.width: 100 +*panner.height: 100 + +*help*text.properties:\ +default?family=Times&weight=Medium&slant=R&pixelsize=12®istry=ISO8859&encoding=1,\ +b?weight=Bold,\ +strong?weight=Bold,\ +i?slant=I,\ +em?slant=I,\ +address?slant=I,\ +h1?pixelsize=24&weight=Bold,\ +h2?pixelsize=20&weight=Bold,\ +h3?pixelsize=17&weight=Bold,\ +h4?pixelsize=14&weight=Bold,\ +h5?pixelsize=12&weight=Bold,\ +h6?pixelsize=10&weight=Bold,\ +pre?family=Courier&pixelsize=10,\ +kbd?family=Courier&pixelsize=10,\ +code?family=Courier&pixelsize=10,\ +samp?family=Courier&pixelsize=10,\ +tt?family=Courier&pixelsize=10 +*help*commands.min: 22 +*help*commands.max: 22 +*help*commands.showGrip:False +*help*wrap: word +*help*commands.close.label: Close +.xorgcfg.help.geometry: 320x369 +.xorgcfg.help.minWidth: 320 +.xorgcfg.help.maxWidth: 320 +.xorgcfg.help.minHeight: 369 +.xorgcfg.help.maxHeight: 369 +.xorgcfg.help.translations: #override \ +<Message>WM_PROTOCOLS: help-close() +*help*text.translations:\ +<Key>Up: scroll-one-line-down()\n\ +<Key>Down: scroll-one-line-up()\n\ +<Key>Next: next-page()\n\ +<Key>Prior: previous-page()\n\ +<Key>space: next-page()\n\ +<Key>BackSpace: previous-page()\n\ +<Key>Home: beginning-of-file()\n\ +<Key>End: end-of-file() +*help*text*displayCaret: False +*help*text.leftMargin: 10 +*help*text.rightMargin: 10 + +*help.helpDevices:\ +<h2>Configuring devices</h2>\ +You can arrange the icons pressing the <i>left mouse button</i> \ +and dragging them.\ +<p>\ +To configure a device, press the <i>right mouse button</i> and choose the \ +<tt>configure</tt> option.\ + +*help.helpScreen:\ +<h2>Configuring screens</h2>\ +You can drag the monitors to set the screen layout form <b>Xinerama</b> \ +pressing the <i>left mouse button</i> and moving them.\ +<p>\ +Press the <i>right mouse button</i> to set configure or set options for \ +the given screen. + +*help.helpModeline:\ +<h2>Configuring modelines</h2>\ +<b><font size=+1 color=red>The controls here may damage your \ +monitor.</font></b> \ +<p>\ +You can safelly skip this stage of the configuration process.\ +<p>\ +When not running in <b>Xinerama</b> mode, you can configure modelines \ +for every configured monitor. Set the <b>Auto</b> toggle to see the changes \ +while the <i>control buttons</i> are pressed.\ +<p>\ +Note that the <i>arrow</i> buttons are repeaters. Press they only once \ +and they will show the changes in the <i>text labels</i>.\ +<p>\ +<font color=forestgreen>Press <b>ESC</b> if the monitor goes out of sync.</font> + +*help.helpAccessX:\ +<h2>Configuring accessx</h2>\ +This interface is expected to allow customizing most of the <b>accessx</b> \ +options.\ +<p>\ +Press in the <b>Enable ???</b> label to set specific options.\ +<p>\ +<font color=red>Note</font>: currently, if you press the \ +<tt><b>Apply changes</b></tt> button there is no way to undo your changes.</font> + + +*Expert.geometry: 640x460 +*Expert*vpane.min: 64 +*Expert*vpane.max: 64 +*Expert*vpane.showGrip: False +*Expert*vpane.close.showGrip: False +*Expert*vpane.close.min: 26 +*Expert*vpane.close.max: 26 +*panner.internalSpace: 1 +*panner.shadowThickness: 0 +*panner.shadowColor: gray60 +*panner.backgroundStipple: black +*panner.borderColor: gray40 + +*expert*tree.hSpace: 12 +*expert*tree*Box.hSpace: 4 +*expert*tree*vSpace: 4 +*expert*tree*LogFile.Text.width: 192 +*expert*tree*RgbPath.Text.width: 192 +*expert*tree*ModulePath.Text.width: 192 + +*expert*tree*Form.defaultDistance: 4 + +*expert*tree.backgroundPixmap: xlogo64?foreground=gray90&background=gray92 +*expert*tree.foreground: gray45 + +*expert*tree*Label.backgroundPixmap: ParentRelative + +*expert*tree*Box.backgroundPixmap: gradient:vertical?dimension=3&start=gray85&end=gray95 +*expert*tree*Box.borderWidth: 0 +*expert*tree*Box.background: gray85 +*expert*Box.displayList:\ +foreground gray40;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 + +*expert*tree*Form.backgroundPixmap: gradient:vertical?dimension=3&start=gray85&end=gray95 +*expert*tree*Form.borderWidth: 0 +*expert*tree*Form.background: gray85 +*expert*Form.displayList:\ +foreground gray40;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 + +*expert*tree*Text.width: 160 + +*expert*tree*fontpath.Text.width: 228 +*expert*tree*fontpath.up.fromHoriz: remove +*expert*tree*fontpath.down.fromHoriz: up +*expert*tree*fontpath.value.fromVert: remove +*expert*tree*fontpath.valueNew.fromVert: new + +*expert*tree*modulepath.Text.width: 228 +*expert*tree*modulepath.value.fromVert: remove +*expert*tree*modulepath.valueNew.fromVert: new + +*expert*tree*module.options.fromHoriz: remove +*expert*tree*module.label.fromVert: remove +*expert*tree*module.value.fromHoriz: new +*expert*tree*module.value.width: 78 + +*expert*tree*video*Label.justify: left +*expert*tree*video.options.fromHoriz: remove +*expert*tree*video.adaptor.fromHoriz: options +*expert*tree*video.vendorL.width: 78 +*expert*tree*video.vendorL.label: VendorName +*expert*tree*video.vendorL.fromVert: remove +*expert*tree*video.vendor.fromVert: remove +*expert*tree*video.vendor.fromHoriz: vendorL +*expert*tree*video.boardL.width: 78 +*expert*tree*video.boardL.label: BoardName +*expert*tree*video.boardL.fromVert: vendor +*expert*tree*video.board.fromVert: vendor +*expert*tree*video.board.fromHoriz: boardL +*expert*tree*video.busidL.width: 78 +*expert*tree*video.busidL.label: BusID +*expert*tree*video.busidL.fromVert: board +*expert*tree*video.busid.fromVert: board +*expert*tree*video.busid.fromHoriz: busidL +*expert*tree*video.driverL.width: 78 +*expert*tree*video.driverL.label: Driver +*expert*tree*video.driverL.fromVert: busid +*expert*tree*video.driver.fromVert: busid +*expert*tree*video.driver.fromHoriz: driverL +*expert*tree*video.value.fromHoriz: new +*expert*tree*video.value.width: 78 +*expert*tree*VideoPort.fromVert: driver +*expert*tree*VideoPort.horizDistance: 120 +*expert*tree*video.value.width: 149 + +*expert*tree*port.value.fromHoriz: new +*expert*tree*port.options.fromHoriz: remove +*expert*tree*port.label.fromVert: remove +*expert*tree*port.value.width: 78 + +*expert*tree*modes.mode.fromHoriz: remove +*expert*tree*modes.value.fromHoriz: new +*expert*tree*modes.value.width: 78 + +*expert*tree*modeline.label.fromHoriz: remove +*expert*tree*modeline.modeline.fromVert: remove +*expert*tree*modeline.modeline.width: 480 +*expert*tree*modeline.value.fromHoriz: new +*expert*tree*modeline.value.width: 120 +*expert*tree*modeline.modelineNew.fromVert: value +*expert*tree*modeline.modelineNew.width: 480 + +*expert*tree*monitor.options.fromHoriz: remove +*expert*tree*monitor.label.fromHoriz: options + +*expert*tree*monitor.Label.justify: left +*expert*tree*monitor.Text.width: 120 +*expert*tree*monitor.vendorL.width: 100 +*expert*tree*monitor.vendorL.label: VendorName +*expert*tree*monitor.vendorL.fromVert: remove +*expert*tree*monitor.vendor.fromVert: remove +*expert*tree*monitor.vendor.fromHoriz: vendorL +*expert*tree*monitor.modelnameL.width: 100 +*expert*tree*monitor.modelnameL.label: ModelName +*expert*tree*monitor.modelnameL.fromVert: vendor +*expert*tree*monitor.modelname.fromVert: vendor +*expert*tree*monitor.modelname.fromHoriz: modelnameL +*expert*tree*monitor.widthL.width: 100 +*expert*tree*monitor.widthL.label: Width (mm) +*expert*tree*monitor.widthL.fromVert: modelname +*expert*tree*monitor.width.fromVert: modelname +*expert*tree*monitor.width.fromHoriz: widthL +*expert*tree*monitor.heightL.width: 100 +*expert*tree*monitor.heightL.label: Height (mm) +*expert*tree*monitor.heightL.fromVert: width +*expert*tree*monitor.height.fromVert: width +*expert*tree*monitor.height.fromHoriz: heightL +*expert*tree*monitor.hsyncL.width: 100 +*expert*tree*monitor.hsyncL.label: Hsync +*expert*tree*monitor.hsyncL.fromVert: heightL +*expert*tree*monitor.hsync.fromVert: height +*expert*tree*monitor.hsync.fromHoriz: hsyncL +*expert*tree*monitor.vrefreshL.width: 100 +*expert*tree*monitor.vrefreshL.label: Vrefresh +*expert*tree*monitor.vrefreshL.fromVert: hsync +*expert*tree*monitor.vrefresh.fromVert: hsync +*expert*tree*monitor.vrefresh.fromHoriz: vrefreshL +*expert*tree*monitor.gammaRedL.width: 100 +*expert*tree*monitor.gammaRedL.label: Gamma (red) +*expert*tree*monitor.gammaRedL.fromVert: vrefresh +*expert*tree*monitor.gammaRed.fromVert: vrefresh +*expert*tree*monitor.gammaRed.fromHoriz: gammaRedL +*expert*tree*monitor.gammaGreenL.width: 100 +*expert*tree*monitor.gammaGreenL.label: Gamma (green) +*expert*tree*monitor.gammaGreenL.fromVert: gammaRed +*expert*tree*monitor.gammaGreen.fromVert: gammaRed +*expert*tree*monitor.gammaGreen.fromHoriz: gammaGreenL +*expert*tree*monitor.gammaBlueL.width: 100 +*expert*tree*monitor.gammaBlueL.label: Gamma (blue) +*expert*tree*monitor.gammaBlueL.fromVert: gammaGreen +*expert*tree*monitor.gammaBlue.fromVert: gammaGreen +*expert*tree*monitor.gammaBlue.fromHoriz: gammaBlueL +*expert*tree*monitor.value.width: 191 +*expert*tree*monitor.value.fromHoriz: new + +*expert*tree*device.Label.justify: left +*expert*tree*device.options.fromHoriz: remove +*expert*tree*device.label.fromHoriz: options +*expert*tree*device.vendorL.label: VendorName +*expert*tree*device.vendorL.width: 100 +*expert*tree*device.vendorL.fromVert: remove +*expert*tree*device.vendor.fromVert: remove +*expert*tree*device.vendor.fromHoriz: vendorL +*expert*tree*device.boardL.label: BoardName +*expert*tree*device.boardL.width: 100 +*expert*tree*device.boardL.fromVert: vendor +*expert*tree*device.board.fromVert: vendor +*expert*tree*device.board.fromHoriz: boardL +*expert*tree*device.chipsetL.label: Chipset +*expert*tree*device.chipsetL.width: 100 +*expert*tree*device.chipsetL.fromVert: board +*expert*tree*device.chipset.fromVert: board +*expert*tree*device.chipset.fromHoriz: chipsetL +*expert*tree*device.busidL.label: BusID +*expert*tree*device.busidL.width: 100 +*expert*tree*device.busidL.fromVert: chipset +*expert*tree*device.busid.fromVert: chipset +*expert*tree*device.busid.fromHoriz: chipsetL +*expert*tree*device.cardL.label: Card +*expert*tree*device.cardL.width: 100 +*expert*tree*device.cardL.fromVert: busid +*expert*tree*device.card.fromVert: busid +*expert*tree*device.card.fromHoriz: cardL +*expert*tree*device.driverL.label: Driver +*expert*tree*device.driverL.width: 100 +*expert*tree*device.driverL.fromVert: card +*expert*tree*device.driver.fromVert: card +*expert*tree*device.driver.fromHoriz: driverL +*expert*tree*device.ramdacL.label: Ramdac +*expert*tree*device.ramdacL.width: 100 +*expert*tree*device.ramdacL.fromVert: driverL +*expert*tree*device.ramdac.fromVert: driver +*expert*tree*device.ramdac.fromHoriz: ramdacL +*expert*tree*device.dacSpeedL.label: DacSpeed +*expert*tree*device.dacSpeedL.width: 100 +*expert*tree*device.dacSpeedL.fromVert: ramdac +*expert*tree*device.dacSpeed.fromVert: ramdac +*expert*tree*device.dacSpeed.fromHoriz: dacSpeedL +*expert*tree*device.videoRamL.label: VideoRam +*expert*tree*device.videoRamL.width: 100 +*expert*tree*device.videoRamL.fromVert: dacSpeed +*expert*tree*device.videoRam.fromVert: dacSpeed +*expert*tree*device.videoRam.fromHoriz: videoRamL +*expert*tree*device.textClockFreqL.label: TextClockFreq +*expert*tree*device.textClockFreqL.width: 100 +*expert*tree*device.textClockFreqL.fromVert: videoRam +*expert*tree*device.textClockFreq.fromVert: videoRam +*expert*tree*device.textClockFreq.fromHoriz: textClockFreqL +*expert*tree*device.biosBaseL.label: BiosBase +*expert*tree*device.biosBaseL.width: 100 +*expert*tree*device.biosBaseL.fromVert: textClockFreq +*expert*tree*device.biosBase.fromVert: textClockFreq +*expert*tree*device.biosBase.fromHoriz: biosBaseL +*expert*tree*device.memBaseL.label: MemBase +*expert*tree*device.memBaseL.width: 100 +*expert*tree*device.memBaseL.fromVert: biosBase +*expert*tree*device.memBase.fromVert: biosBase +*expert*tree*device.memBase.fromHoriz: memBaseL +*expert*tree*device.ioBaseL.label: IOBase +*expert*tree*device.ioBaseL.width: 100 +*expert*tree*device.ioBaseL.fromVert: memBase +*expert*tree*device.ioBase.fromVert: memBase +*expert*tree*device.ioBase.fromHoriz: ioBaseL +*expert*tree*device.clockChipL.label: ClockChip +*expert*tree*device.clockChipL.width: 100 +*expert*tree*device.clockChipL.fromVert: ioBase +*expert*tree*device.clockChip.fromVert: ioBase +*expert*tree*device.clockChip.fromHoriz: clockChipL +*expert*tree*device.devClockL.label: Clocks +*expert*tree*device.devClockL.width: 100 +*expert*tree*device.devClockL.fromVert: clockChip +*expert*tree*device.devClock.fromVert: clockChip +*expert*tree*device.devClock.fromHoriz: devClockL +*expert*tree*device.chipIdL.label: ChipId +*expert*tree*device.chipIdL.width: 100 +*expert*tree*device.chipIdL.fromVert: devClock +*expert*tree*device.chipId.fromVert: devClock +*expert*tree*device.chipId.fromHoriz: chipIdL +*expert*tree*device.chipRevL.label: ChipRev +*expert*tree*device.chipRevL.width: 100 +*expert*tree*device.chipRevL.fromVert: chipId +*expert*tree*device.chipRev.fromVert: chipId +*expert*tree*device.chipRev.fromHoriz: chipRevL +*expert*tree*device.irqL.label: IRQ +*expert*tree*device.irqL.width: 100 +*expert*tree*device.irqL.fromVert: chipRev +*expert*tree*device.irq.fromVert: chipRev +*expert*tree*device.irq.fromHoriz: irqL +*expert*tree*device.screenL.label: Screen +*expert*tree*device.screenL.width: 100 +*expert*tree*device.screenL.fromVert: irq +*expert*tree*device.screen.fromVert: irq +*expert*tree*device.screen.fromHoriz: screenL +*expert*tree*device.value.fromHoriz: new + +*expert*tree*screen.Label.justify: left +*expert*tree*screen.options.fromHoriz: remove +*expert*tree*screen.label.fromHoriz: options +*expert*tree*screen.defaultDepthL.label: DefaultDepth +*expert*tree*screen.defaultDepthL.width: 92 +*expert*tree*screen.defaultDepthL.fromVert: remove +*expert*tree*screen.defaultDepth.fromVert: remove +*expert*tree*screen.defaultDepth.fromHoriz: defaultDepthL +*expert*tree*screen.defaultBppL.label: DefaultBpp +*expert*tree*screen.defaultBppL.width: 92 +*expert*tree*screen.defaultBppL.fromVert: defaultDepth +*expert*tree*screen.defaultBpp.fromVert: defaultDepth +*expert*tree*screen.defaultBpp.fromHoriz: defaultBppL +*expert*tree*screen.defaultFbBppL.label: DefaultFbBpp +*expert*tree*screen.defaultFbBppL.width: 92 +*expert*tree*screen.defaultFbBppL.fromVert: defaultBpp +*expert*tree*screen.defaultFbBpp.fromVert: defaultBpp +*expert*tree*screen.defaultFbBpp.fromHoriz: defaultFbBppL +*expert*tree*screen.monitorL.label: Monitor +*expert*tree*screen.monitorL.width: 92 +*expert*tree*screen.monitorL.fromVert: defaultFbBpp +*expert*tree*screen.monitor.fromVert: defaultFbBpp +*expert*tree*screen.monitor.fromHoriz: monitorL +*expert*tree*screen.deviceL.label: Device +*expert*tree*screen.deviceL.width: 92 +*expert*tree*screen.deviceL.fromVert: monitor +*expert*tree*screen.device.fromVert: monitor +*expert*tree*screen.device.fromHoriz: deviceL +*expert*tree*screen.value.fromHoriz: new + +*expert*tree*adaptor.label.fromHoriz: remove + +*expert*tree*display.Label.width: 64 +*expert*tree*display.Label.justify: left +*expert*tree*display.options.fromHoriz: remove +*expert*tree*display.viewportL.label: Viewport +*expert*tree*display.viewportL.fromVert: remove +*expert*tree*display.viewport.fromVert: remove +*expert*tree*display.viewport.fromHoriz: viewportL +*expert*tree*display.virtualL.label: Virtual +*expert*tree*display.virtualL.fromVert: viewport +*expert*tree*display.virtual.fromVert: viewport +*expert*tree*display.virtual.fromHoriz: virtualL +*expert*tree*display.depthL.label: Depth +*expert*tree*display.depthL.fromVert: virtual +*expert*tree*display.depth.fromVert: virtual +*expert*tree*display.depth.fromHoriz: depthL +*expert*tree*display.bppL.label: FbBPP +*expert*tree*display.bppL.fromVert: depth +*expert*tree*display.bpp.fromVert: depth +*expert*tree*display.bpp.fromHoriz: bppL +*expert*tree*display.visualL.label: Visual +*expert*tree*display.visualL.fromVert: bpp +*expert*tree*display.visual.fromVert: bpp +*expert*tree*display.visual.fromHoriz: visualL +*expert*tree*display.weightL.label: Weight +*expert*tree*display.weightL.fromVert: visual +*expert*tree*display.weight.fromVert: visual +*expert*tree*display.weight.fromHoriz: weightL +*expert*tree*display.blackL.label: Black +*expert*tree*display.blackL.fromVert: weight +*expert*tree*display.black.fromVert: weight +*expert*tree*display.black.fromHoriz: blackL +*expert*tree*display.whiteL.label: White +*expert*tree*display.whiteL.fromVert: black +*expert*tree*display.white.fromVert: black +*expert*tree*display.white.fromHoriz: whiteL + +*expert*tree*mode.label.fromHoriz: remove +*expert*tree*mode.value.fromHoriz: new +*expert*tree*mode.value.width: 100 + +*expert*tree*input.options.fromHoriz: remove +*expert*tree*input.label.fromHoriz: options +*expert*tree*input.driverL.label: Driver +*expert*tree*input.driverL.fromVert: remove +*expert*tree*input.driver.fromVert: remove +*expert*tree*input.driver.fromHoriz: driverL +*expert*tree*input.value.fromHoriz: new + +*expert*tree*layout.options.fromHoriz: remove +*expert*tree*layout.label.fromHoriz: options +*expert*tree*layout.value.fromHoriz: new + +*expert*tree*adjacency.Text.width: 46 +*expert*tree*adjacency.MenuButton.width: 122 +*expert*tree*adjacency.label.fromHoriz: remove +*expert*tree*adjacency.scrnumL.label: Screen number +*expert*tree*adjacency.scrnumL.horizDistance: 50 +*expert*tree*adjacency.scrnum.width: 32 +*expert*tree*adjacency.scrnumL.fromVert: remove +*expert*tree*adjacency.scrnum.fromVert: remove +*expert*tree*adjacency.scrnum.fromHoriz: scrnumL +*expert*tree*adjacency.above.label: Above +*expert*tree*adjacency.above.fromVert: scrnumL +*expert*tree*adjacency.above.vertDistance: 20 +*expert*tree*adjacency.above.horizDistance: 96 +*expert*tree*adjacency.below.label: Below +*expert*tree*adjacency.below.horizDistance: 96 +*expert*tree*adjacency.leftOf.label: LeftOf +*expert*tree*adjacency.leftOf.fromVert: above +*expert*tree*adjacency.screen.fromVert: above +*expert*tree*adjacency.screen.fromHoriz: leftOf +*expert*tree*adjacency.rightOf.label: RightOf +*expert*tree*adjacency.rightOf.fromVert: above +*expert*tree*adjacency.rightOf.fromHoriz: screen +*expert*tree*adjacency.below.fromVert: screen +*expert*tree*adjacency.relative.label: Relative +*expert*tree*adjacency.relative.horizDistance: 53 +*expert*tree*adjacency.relative.fromVert: below +*expert*tree*adjacency.absolute.fromVert: below +*expert*tree*adjacency*absolute.label: Absolute +*expert*tree*adjacency*absolute.fromHoriz: relative +*expert*tree*adjacency*adjxL.label: X +*expert*tree*adjacency*adjxL.horizDistance: 42 +*expert*tree*adjacency*adjxL.fromVert: absolute +*expert*tree*adjacency*adjx.fromVert: absolute +*expert*tree*adjacency*adjx.fromHoriz: adjxL +*expert*tree*adjacency*adjyL.label: Y +*expert*tree*adjacency*adjyL.horizDistance: 12 +*expert*tree*adjacency*adjyL.fromVert: absolute +*expert*tree*adjacency*adjyL.fromHoriz: adjx +*expert*tree*adjacency*adjy.fromVert: absolute +*expert*tree*adjacency*adjy.fromHoriz: adjyL + +*expert*tree*inputref.options.fromHoriz: remove +*expert*tree*inputref.label.fromHoriz: options + +*expert*tree*vendor.Text.width: 100 +*expert*tree*vendor.options.fromHoriz: remove +*expert*tree*vendor.label.fromHoriz: options +*expert*tree*vendor.value.fromHoriz: new + +*expert*tree*vendorSub.Text.width: 140 +*expert*tree*vendorSub.options.fromHoriz: remove +*expert*tree*vendorSub.label.fromHoriz: options +*expert*tree*vendorSub.nameL.label: Name +*expert*tree*vendorSub.nameL.fromVert: remove +*expert*tree*vendorSub.name.fromVert: remove +*expert*tree*vendorSub.name.fromHoriz: nameL +*expert*tree*vendorSub.value.fromHoriz: new + +*expert*tree*dri.Text.width: 100 +*expert*tree*dri.Label.width: 78 +*expert*tree*dri.Label.justify: left +*expert*tree*dri.nameL.label: Group name +*expert*tree*dri.name.fromHoriz: nameL +*expert*tree*dri.groupL.label: Group +*expert*tree*dri.groupL.fromVert: name +*expert*tree*dri.group.fromVert: name +*expert*tree*dri.group.fromHoriz: groupL +*expert*tree*dri.modeL.label: Mode +*expert*tree*dri.modeL.fromVert: group +*expert*tree*dri.mode.fromVert: group +*expert*tree*dri.mode.fromHoriz: modeL + +*expert*tree*buffers.Label.width: 50 +*expert*tree*buffers.Text.width: 100 +*expert*tree*buffers.countL.label: Count +*expert*tree*buffers.countL.fromVert: remove +*expert*tree*buffers.count.fromVert: remove +*expert*tree*buffers.count.fromHoriz: countL +*expert*tree*buffers.sizeL.label: Size +*expert*tree*buffers.sizeL.fromVert: count +*expert*tree*buffers.size.fromVert: count +*expert*tree*buffers.size.fromHoriz: sizeL +*expert*tree*buffers.flagsL.label: Flags +*expert*tree*buffers.flagsL.fromVert: size +*expert*tree*buffers.flags.fromVert: size +*expert*tree*buffers.flags.fromHoriz: flagsL +*Expert*close.label: Close diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/accessx.c b/xorg-server/hw/xfree86/utils/xorgcfg/accessx.c new file mode 100644 index 000000000..38bda383a --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/accessx.c @@ -0,0 +1,681 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> +#include <X11/XKBlib.h> +#include <X11/Shell.h> +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/Scrollbar.h> +#include <X11/Xaw/Toggle.h> +#include "keyboard-cfg.h" + +#define MAX_TIMEOUT 20 +#define MAX_MOUSE_SPEED 500 +#define MAX_MOUSE_TIME 4 +#define MAX_MOUSE_DELAY 2.09 +#define MAX_REPEAT_RATE 8.04 +#define MAX_REPEAT_DELAY 6.04 +#define MAX_SLOW_TIME 4 +#define MAX_BOUNCE_TIME 4 + +/* + * Types + */ +typedef struct { + Widget label, number, scroller; + double min, max, value, resolution; + Bool integer; +} Scale; + +/* + * Initialization + */ +static Widget shell, accessx, enable, timeoutToggle, form, apply; +static Widget sticky, stickyAuto, stickyBeep; +static Widget mouse; +static Widget repeat; +static Widget slowToggle, slowPressed, slowAccepted; +static Widget bounceToggle; +static Scale *timeout, *mouseSpeed, *mouseTime, *mouseDelay, *slow, + *repeatRate, *repeatDelay, *bounce; +extern Widget work; + +/* + * Prototypes + */ +static void CreateAccessXHelpDialog(void); +static void EnableCallback(Widget, XtPointer, XtPointer); +static void ScaleEnableCallback(Widget, XtPointer, XtPointer); +static void ScaleJumpCallback(Widget, XtPointer, XtPointer); + +static void ApplyCallback(Widget, XtPointer, XtPointer); +static void AccessXInitialize(void); + +void CloseAccessXAction(Widget, XEvent*, String*, Cardinal*); +void AccessXConfigureStart(void); +void AccessXConfigureEnd(void); + +/* + * Implementation + */ +void +startaccessx(void) +{ + InitializeKeyboard(); + + if (xkb_info->xkb) { + XkbGetControls(DPY, XkbAllControlsMask, xkb_info->xkb); + if (xkb_info->xkb->ctrls == NULL) + xkb_info->xkb->ctrls = (XkbControlsPtr) + XtCalloc(1, sizeof(XkbControlsRec)); + + xkb_info->xkb->ctrls->enabled_ctrls |= XkbMouseKeysMask | + XkbMouseKeysAccelMask; + xkb_info->xkb->ctrls->mk_delay = 40; + xkb_info->xkb->ctrls->mk_interval = 10; + xkb_info->xkb->ctrls->mk_time_to_max = 1000; + xkb_info->xkb->ctrls->mk_max_speed = 500; + xkb_info->xkb->ctrls->mk_curve = 0; + XkbSetControls(DPY, XkbAllControlsMask, xkb_info->xkb); + (void)UpdateKeyboard(True); + CreateAccessXHelpDialog(); + } +} + +void +CreateAccessXHelpDialog() +{ + Widget form; + + shell = XtVaCreatePopupShell("accessx", transientShellWidgetClass, toplevel, + XtNx, toplevel->core.x + toplevel->core.width, + XtNy, toplevel->core.y, NULL); + form = XtCreateManagedWidget("form", formWidgetClass, shell, NULL, 0); + XtCreateManagedWidget("label", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("lock", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("div", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("mul", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("minus", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("7", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("8", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("9", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("plus", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("4", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("5", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("6", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("1", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("2", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("3", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("enter", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("0", labelWidgetClass, form, NULL, 0); + XtCreateManagedWidget("del", labelWidgetClass, form, NULL, 0); + + XtRealizeWidget(shell); + XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1); + XtPopup(shell, XtGrabNone); +} + +/*ARGSUSED*/ +void +CloseAccessXAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + XtPopdown(shell); +} + +static void +AccessXInitialize(void) +{ + static int first = 1; + Arg args[1]; + Boolean state; + Widget stickyForm, mouseForm, repeatForm, slowForm, bounceForm; + float val, tmp; + + if (!first) + return; + first = 0; + + InitializeKeyboard(); + + XkbGetControls(DPY, XkbAllControlsMask, xkb_info->xkb); + if (xkb_info->xkb->ctrls == NULL) + xkb_info->xkb->ctrls = (XkbControlsPtr) + XtCalloc(1, sizeof(XkbControlsRec)); + + timeout = XtNew(Scale); + accessx = XtCreateWidget("accessxForm", formWidgetClass, work, NULL, 0); + enable = XtVaCreateManagedWidget("enable", toggleWidgetClass, accessx, + XtNstate, + (xkb_info->xkb->ctrls->enabled_ctrls & + (XkbAccessXKeysMask | XkbStickyKeysMask | + XkbSlowKeysMask | XkbBounceKeysMask)) != 0, NULL); + + apply = XtCreateManagedWidget("apply", commandWidgetClass, accessx, NULL, 0); + XtAddCallback(apply, XtNcallback, ApplyCallback, NULL); + + form = XtCreateManagedWidget("Accessx", formWidgetClass, accessx, NULL, 0); + timeoutToggle = XtVaCreateManagedWidget("timeoutToggle", toggleWidgetClass, + form, XtNstate, + xkb_info->xkb->ctrls->ax_timeout > 60 + && xkb_info->xkb->ctrls->ax_timeout + < 30000, NULL); + XtAddCallback(timeoutToggle, XtNcallback, ScaleEnableCallback, + (XtPointer)timeout); + timeout->label = XtCreateManagedWidget("timeoutLabel", labelWidgetClass, + form, NULL, 0); + timeout->number = XtCreateManagedWidget("timeoutNumber", labelWidgetClass, + form, NULL, 0); + timeout->scroller = XtCreateManagedWidget("timeoutScroller", + scrollbarWidgetClass, + form, NULL, 0); + XtAddCallback(timeout->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)timeout); + timeout->min = 1; + timeout->max = MAX_TIMEOUT; + timeout->resolution = 1; + timeout->integer = True; + + sticky = XtVaCreateManagedWidget("sticky", toggleWidgetClass, form, + XtNstate, + (xkb_info->xkb->ctrls->enabled_ctrls & + XkbStickyKeysMask) != 0, NULL); + stickyForm = XtCreateManagedWidget("stickyForm", formWidgetClass, + form, NULL, 0); + XtAddCallback(sticky, XtNcallback, EnableCallback, (XtPointer)stickyForm); + stickyAuto = XtVaCreateManagedWidget("auto", toggleWidgetClass, stickyForm, + XtNstate, + (xkb_info->xkb->ctrls->ax_options & + XkbAX_LatchToLockMask) == 0, NULL); + stickyBeep = XtVaCreateManagedWidget("beep", toggleWidgetClass, stickyForm, + XtNstate, + (xkb_info->xkb->ctrls->ax_options & + XkbAX_StickyKeysFBMask) != 0, NULL); + + mouse = XtVaCreateManagedWidget("mouseKeys", toggleWidgetClass, form, + XtNstate, + (xkb_info->xkb->ctrls->enabled_ctrls & + (XkbMouseKeysMask | XkbMouseKeysAccelMask)) + != 0, NULL); + mouseForm = XtCreateManagedWidget("mouseForm", formWidgetClass, + form, NULL, 0); + XtAddCallback(mouse, XtNcallback, EnableCallback, (XtPointer)mouseForm); + mouseSpeed = XtNew(Scale); + mouseSpeed->label = XtCreateManagedWidget("speedLabel", labelWidgetClass, + mouseForm, NULL, 0); + mouseSpeed->number = XtCreateManagedWidget("speedNumber", labelWidgetClass, + mouseForm, NULL, 0); + mouseSpeed->scroller = XtCreateManagedWidget("speedScroller", + scrollbarWidgetClass, + mouseForm, NULL, 0); + XtAddCallback(mouseSpeed->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)mouseSpeed); + mouseSpeed->min = 10; + mouseSpeed->max = MAX_MOUSE_SPEED; + mouseSpeed->resolution = 10; + mouseSpeed->integer = True; + mouseTime = XtNew(Scale); + mouseTime->label = XtCreateManagedWidget("timeLabel", labelWidgetClass, + mouseForm, NULL, 0); + mouseTime->number = XtCreateManagedWidget("timeNumber", labelWidgetClass, + mouseForm, NULL, 0); + mouseTime->scroller = XtCreateManagedWidget("timeScroller", + scrollbarWidgetClass, + mouseForm, NULL, 0); + XtAddCallback(mouseTime->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)mouseTime); + mouseTime->min = .1; + mouseTime->max = MAX_MOUSE_TIME; + mouseTime->resolution = .1; + mouseTime->integer = False; + mouseDelay = XtNew(Scale); + mouseDelay->label = XtCreateManagedWidget("delayLabel", labelWidgetClass, + mouseForm, NULL, 0); + mouseDelay->number = XtCreateManagedWidget("delayNumber", labelWidgetClass, + mouseForm, NULL, 0); + mouseDelay->scroller = XtCreateManagedWidget("delayScroller", + scrollbarWidgetClass, + mouseForm, NULL, 0); + XtAddCallback(mouseDelay->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)mouseDelay); + mouseDelay->min = .1; + mouseDelay->max = MAX_MOUSE_DELAY; + mouseDelay->resolution = .1; + mouseDelay->integer = False; + + repeat = XtVaCreateManagedWidget("repeatKeys", toggleWidgetClass, form, + XtNstate, + (xkb_info->xkb->ctrls->enabled_ctrls & + XkbRepeatKeysMask) != 0, NULL); + repeatForm = XtCreateManagedWidget("repeatForm", formWidgetClass, + form, NULL, 0); + XtAddCallback(repeat, XtNcallback, EnableCallback, (XtPointer)repeatForm); + repeatRate = XtNew(Scale); + repeatRate->label = XtCreateManagedWidget("rateLabel", labelWidgetClass, + repeatForm, NULL, 0); + repeatRate->number = XtCreateManagedWidget("rateNumber", labelWidgetClass, + repeatForm, NULL, 0); + repeatRate->scroller = XtCreateManagedWidget("rateScroller", + scrollbarWidgetClass, + repeatForm, NULL, 0); + XtAddCallback(repeatRate->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)repeatRate); + repeatRate->min = .05; + repeatRate->max = MAX_REPEAT_RATE; + repeatRate->resolution = .05; + repeatRate->integer = False; + repeatDelay = XtNew(Scale); + repeatDelay->label = XtCreateManagedWidget("delayLabel", labelWidgetClass, + repeatForm, NULL, 0); + repeatDelay->number = XtCreateManagedWidget("delayNumber", labelWidgetClass, + repeatForm, NULL, 0); + repeatDelay->scroller = XtCreateManagedWidget("delayScroller", + scrollbarWidgetClass, + repeatForm, NULL, 0); + XtAddCallback(repeatDelay->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)repeatDelay); + repeatDelay->min = .05; + repeatDelay->max = MAX_REPEAT_DELAY; + repeatDelay->resolution = .05; + repeatDelay->integer = False; + + slowToggle = XtVaCreateManagedWidget("slow", toggleWidgetClass, + form, XtNstate, + (xkb_info->xkb->ctrls->enabled_ctrls & + XkbSlowKeysMask) != 0, NULL); + slowForm = XtCreateManagedWidget("slowForm", formWidgetClass, + form, NULL, 0); + XtAddCallback(slowToggle, XtNcallback, EnableCallback, (XtPointer)slowForm); + XtCreateManagedWidget("beep", labelWidgetClass, slowForm, NULL, 0); + slowPressed = XtVaCreateManagedWidget("pressed", toggleWidgetClass, + slowForm, XtNstate, + (xkb_info->xkb->ctrls->ax_options & + XkbAX_SKPressFBMask) != 0, + NULL); + slowAccepted = XtVaCreateManagedWidget("accepted", toggleWidgetClass, + slowForm, XtNstate, + (xkb_info->xkb->ctrls->ax_options & + XkbAX_SKAcceptFBMask) != 0, + NULL); + slow = XtNew(Scale); + slow->label = XtCreateManagedWidget("slowLabel", labelWidgetClass, + slowForm, NULL, 0); + slow->number = XtCreateManagedWidget("slowNumber", labelWidgetClass, + slowForm, NULL, 0); + slow->scroller = XtCreateManagedWidget("slowScroller", + scrollbarWidgetClass, + slowForm, NULL, 0); + XtAddCallback(slow->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)slow); + slow->min = 0.1; + slow->max = MAX_SLOW_TIME; + slow->resolution = 0.1; + slow->integer = False; + + bounceToggle = XtVaCreateManagedWidget("bounce", toggleWidgetClass, + form, XtNstate, + (xkb_info->xkb->ctrls->enabled_ctrls & + XkbBounceKeysMask) != 0, + NULL); + bounceForm = XtCreateManagedWidget("bounceForm", formWidgetClass, + form, NULL, 0); + XtAddCallback(bounceToggle, XtNcallback, EnableCallback, (XtPointer)bounceForm); + bounce = XtNew(Scale); + bounce->label = XtCreateManagedWidget("bounceLabel", labelWidgetClass, + bounceForm, NULL, 0); + bounce->number = XtCreateManagedWidget("bounceNumber", labelWidgetClass, + bounceForm, NULL, 0); + bounce->scroller = XtCreateManagedWidget("bounceScroller", + scrollbarWidgetClass, + bounceForm, NULL, 0); + XtAddCallback(bounce->scroller, XtNjumpProc, ScaleJumpCallback, + (XtPointer)bounce); + bounce->min = 0.1; + bounce->max = MAX_BOUNCE_TIME; + bounce->resolution = 0.1; + bounce->integer = False; + + XtRealizeWidget(accessx); + + XtSetArg(args[0], XtNstate, &state); + XtGetValues(timeoutToggle, args, 1); + ScaleEnableCallback(enable, (XtPointer)timeout, (XtPointer)(long)state); + if (xkb_info->xkb->ctrls->ax_timeout > 60) + val = (float)(xkb_info->xkb->ctrls->ax_timeout - 60) / + (float)(MAX_TIMEOUT * 60); + else + val = 0; + ScaleJumpCallback(timeout->scroller, (XtPointer)timeout, (XtPointer)&val); + + XtSetArg(args[0], XtNstate, &state); + XtGetValues(sticky, args, 1); + EnableCallback(sticky, (XtPointer)stickyForm, (XtPointer)(long)state); + + XtSetArg(args[0], XtNstate, &state); + XtGetValues(mouse, args, 1); + EnableCallback(mouse, (XtPointer)mouseForm, (XtPointer)(long)state); + if (xkb_info->xkb->ctrls->mk_time_to_max > 10) + val = (float)((xkb_info->xkb->ctrls->mk_time_to_max * (40. / 10.))) / + (float)(MAX_MOUSE_TIME * 100); + else + val = 10.0 / (float)(MAX_MOUSE_TIME * 100); + ScaleJumpCallback(mouseTime->scroller, (XtPointer)mouseTime, + (XtPointer)&val); + tmp = mouseTime->value; + if (xkb_info->xkb->ctrls->mk_max_speed != 0) + val = (float)(xkb_info->xkb->ctrls->mk_max_speed / tmp - 10) / + (float)MAX_MOUSE_SPEED; + else + val = 10.0 / (float)MAX_MOUSE_SPEED; + ScaleJumpCallback(mouseSpeed->scroller, (XtPointer)mouseSpeed, + (XtPointer)&val); + if (xkb_info->xkb->ctrls->mk_delay > 10) + val = (float)(xkb_info->xkb->ctrls->mk_delay - 10) / + (float)(MAX_MOUSE_DELAY * 100); + else + val = 10.0 / (float)(MAX_MOUSE_DELAY * 100); + ScaleJumpCallback(mouseDelay->scroller, (XtPointer)mouseDelay, + (XtPointer)&val); + + XtSetArg(args[0], XtNstate, &state); + XtGetValues(repeat, args, 1); + EnableCallback(repeat, (XtPointer)repeatForm, (XtPointer)(long)state); + if (xkb_info->xkb->ctrls->repeat_interval > 5) + val = (float)(xkb_info->xkb->ctrls->repeat_interval - 5) / + (float)(MAX_REPEAT_RATE * 1000); + else + val = 5.0 / (float)(MAX_REPEAT_RATE * 1000); + ScaleJumpCallback(repeatRate->scroller, (XtPointer)repeatRate, + (XtPointer)&val); + if (xkb_info->xkb->ctrls->repeat_delay > 5) + val = (float)(xkb_info->xkb->ctrls->repeat_delay - 5) / + (float)(MAX_REPEAT_DELAY * 1000); + else + val = 5.0 / (float)(MAX_REPEAT_DELAY * 1000); + ScaleJumpCallback(repeatDelay->scroller, (XtPointer)repeatDelay, + (XtPointer)&val); + + XtSetArg(args[0], XtNstate, &state); + XtGetValues(slowToggle, args, 1); + EnableCallback(slowToggle, (XtPointer)slowForm, (XtPointer)(long)state); + if (xkb_info->xkb->ctrls->slow_keys_delay > 10) + val = (float)(xkb_info->xkb->ctrls->repeat_delay - 10) / + (float)(MAX_SLOW_TIME * 1000); + else + val = 10.0 / (float)(MAX_SLOW_TIME * 1000); + ScaleJumpCallback(slow->scroller, (XtPointer)slow, (XtPointer)&val); + + XtSetArg(args[0], XtNstate, &state); + XtGetValues(bounceToggle, args, 1); + EnableCallback(bounceToggle, (XtPointer)bounceForm, (XtPointer)(long)state); + if (xkb_info->xkb->ctrls->debounce_delay > 10) + val = (float)(xkb_info->xkb->ctrls->debounce_delay - 10) / + (float)(MAX_BOUNCE_TIME * 1000); + else + val = 10.0 / (float)(MAX_BOUNCE_TIME * 1000); + ScaleJumpCallback(bounce->scroller, (XtPointer)bounce, (XtPointer)&val); + + XtSetArg(args[0], XtNstate, &state); + XtGetValues(enable, args, 1); +} + +void +AccessXConfigureStart(void) +{ + AccessXInitialize(); + + XtMapWidget(accessx); +} + +void +AccessXConfigureEnd(void) +{ + XtUnmapWidget(accessx); +} + +/*ARGSUSED*/ +static void +EnableCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XtSetSensitive((Widget)user_data, (long)call_data); +} + +/*ARGSUSED*/ +static void +ScaleEnableCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Scale *scale = (Scale*)user_data; + + XtSetSensitive(scale->label, (long)call_data); + XtSetSensitive(scale->number, (long)call_data); + XtSetSensitive(scale->scroller, (long)call_data); +} + +static void +ScaleJumpCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Scale *scale = (Scale*)user_data; + float percent = *(float *)call_data, timeout = percent * scale->max; + int x; + char str[8]; + Arg args[1]; + + if (timeout >= scale->max - scale->min) + timeout = scale->max - scale->min; + + if (scale->integer) { + int tm = timeout + scale->min; + + tm -= tm % (int)scale->resolution; + XmuSnprintf(str, sizeof(str), "%i", tm); + scale->value = tm; + } + else { + long tm = (timeout + scale->min) * 1e+6; + + tm -= tm % (long)(scale->resolution * 1e+6); + scale->value = (double)tm / 1e+6; + XmuSnprintf(str, sizeof(str), "%f", scale->value); + } + + XtSetArg(args[0], XtNlabel, str); + XtSetValues(scale->number, args, 1); + x = w->core.x + w->core.border_width; + x += ((double)(w->core.width - scale->number->core.width) / scale->max) * timeout; + XtMoveWidget(scale->number, x, scale->number->core.y); + XawScrollbarSetThumb(w, timeout / (scale->max - scale->min), + scale->resolution / (scale->max - scale->min)); +} + +/*ARGSUSED*/ +static void +ApplyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + Boolean state; + + XkbGetControls(DPY, XkbAllControlsMask, xkb_info->xkb); + + /* Enable AccessX */ + XtSetArg(args[0], XtNstate, &state); + XtGetValues(enable, args, 1); + if (state) { + xkb_info->config.initial_ctrls |= XkbAccessXKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls |= XkbAccessXKeysMask; + } + else { + xkb_info->config.initial_ctrls &= ~XkbAccessXKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls &= ~XkbAccessXKeysMask; + } + + /* Timeout */ + XtSetArg(args[0], XtNstate, &state); + XtGetValues(timeoutToggle, args, 1); + if (state) + xkb_info->config.ax_timeout = + xkb_info->xkb->ctrls->ax_timeout = timeout->value * 60; + else + xkb_info->config.ax_timeout = + xkb_info->xkb->ctrls->ax_timeout = 65535; + + /* Enable StickyKeys */ + XtSetArg(args[0], XtNstate, &state); + XtGetValues(sticky, args, 1); + if (state) { + xkb_info->config.initial_ctrls |= XkbStickyKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls |= XkbStickyKeysMask; + } + else { + xkb_info->config.initial_ctrls &= ~XkbStickyKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls &= ~XkbStickyKeysMask; + } + XtSetArg(args[0], XtNstate, &state); + XtGetValues(stickyAuto, args, 1); + if (state) { + xkb_info->config.initial_opts &= ~XkbAX_TwoKeysMask; + xkb_info->config.initial_opts &= ~XkbAX_LatchToLockMask; + xkb_info->xkb->ctrls->ax_options &= ~XkbAX_TwoKeysMask; + xkb_info->xkb->ctrls->ax_options &= ~XkbAX_LatchToLockMask; + } + else { + xkb_info->config.initial_opts &= ~XkbAX_TwoKeysMask; + xkb_info->config.initial_opts |= XkbAX_LatchToLockMask; + xkb_info->xkb->ctrls->ax_options &= ~XkbAX_TwoKeysMask; + xkb_info->xkb->ctrls->ax_options |= XkbAX_LatchToLockMask; + } + XtSetArg(args[0], XtNstate, &state); + XtGetValues(stickyBeep, args, 1); + if (state) { + xkb_info->config.initial_opts |= XkbAX_StickyKeysFBMask; + xkb_info->xkb->ctrls->ax_options |= XkbAX_StickyKeysFBMask; + } + else { + xkb_info->config.initial_opts &= ~XkbAX_StickyKeysFBMask; + xkb_info->xkb->ctrls->ax_options &= ~XkbAX_StickyKeysFBMask; + } + + /* Enable MouseKeys */ + XtSetArg(args[0], XtNstate, &state); + XtGetValues(mouse, args, 1); + if (state) { + xkb_info->config.initial_ctrls |= XkbMouseKeysAccelMask; + xkb_info->xkb->ctrls->enabled_ctrls |= XkbMouseKeysMask | + XkbMouseKeysAccelMask; + xkb_info->config.mk_delay = + xkb_info->xkb->ctrls->mk_delay = mouseDelay->value * 100; + xkb_info->config.mk_interval = + xkb_info->xkb->ctrls->mk_interval = 40; + xkb_info->config.mk_time_to_max = + xkb_info->xkb->ctrls->mk_time_to_max = + (mouseTime->value * 1000) / xkb_info->xkb->ctrls->mk_interval; + xkb_info->config.mk_max_speed = + xkb_info->xkb->ctrls->mk_max_speed = + mouseSpeed->value * mouseTime->value; + xkb_info->config.mk_curve = xkb_info->xkb->ctrls->mk_curve = 0; + } + else { + xkb_info->config.initial_ctrls &= ~(XkbMouseKeysMask | + XkbMouseKeysAccelMask); + xkb_info->xkb->ctrls->enabled_ctrls &= ~(XkbMouseKeysMask | + XkbMouseKeysAccelMask); + } + + /* Enable RepeatKeys */ + XtSetArg(args[0], XtNstate, &state); + XtGetValues(repeat, args, 1); + if (state) { + xkb_info->config.initial_ctrls |= XkbRepeatKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls |= XkbRepeatKeysMask; + xkb_info->config.repeat_interval = + xkb_info->xkb->ctrls->repeat_interval = repeatRate->value * 1000; + xkb_info->config.repeat_delay = + xkb_info->xkb->ctrls->repeat_delay = repeatDelay->value * 1000; + } + else { + xkb_info->config.initial_ctrls &= ~XkbRepeatKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls &= ~XkbRepeatKeysMask; + } + + /* Enable SlowKeys */ + XtSetArg(args[0], XtNstate, &state); + XtGetValues(slowToggle, args, 1); + if (state) { + xkb_info->config.initial_ctrls |= XkbSlowKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls |= XkbSlowKeysMask; + xkb_info->config.slow_keys_delay = + xkb_info->xkb->ctrls->slow_keys_delay = slow->value * 1000; + } + else { + xkb_info->config.initial_ctrls &= ~XkbSlowKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls &= ~XkbSlowKeysMask; + } + XtSetArg(args[0], XtNstate, &state); + XtGetValues(slowPressed, args, 1); + if (state) { + xkb_info->config.initial_opts |= XkbAX_SKPressFBMask; + xkb_info->xkb->ctrls->ax_options |= XkbAX_SKPressFBMask; + } + else { + xkb_info->config.initial_opts &= ~XkbAX_SKPressFBMask; + xkb_info->xkb->ctrls->ax_options &= ~XkbAX_SKPressFBMask; + } + XtSetArg(args[0], XtNstate, &state); + XtGetValues(slowAccepted, args, 1); + if (state) { + xkb_info->config.initial_opts |= XkbAX_SKAcceptFBMask; + xkb_info->xkb->ctrls->ax_options |= XkbAX_SKAcceptFBMask; + } + else { + xkb_info->config.initial_opts &= ~XkbAX_SKAcceptFBMask; + xkb_info->xkb->ctrls->ax_options &= ~XkbAX_SKAcceptFBMask; + } + + /* Enable BounceKeys */ + XtSetArg(args[0], XtNstate, &state); + XtGetValues(bounceToggle, args, 1); + if (state) { + xkb_info->config.initial_ctrls |= XkbBounceKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls |= XkbBounceKeysMask; + xkb_info->config.debounce_delay = + xkb_info->xkb->ctrls->debounce_delay = bounce->value * 1000; + } + else { + xkb_info->config.initial_ctrls &= ~XkbBounceKeysMask; + xkb_info->xkb->ctrls->enabled_ctrls &= ~XkbBounceKeysMask; + } + + XkbSetControls(DPY, XkbAllControlsMask, xkb_info->xkb); + XSync(DPY, False); + (void)UpdateKeyboard(True); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.c b/xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.c new file mode 100644 index 000000000..1f3b7555e --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.c @@ -0,0 +1,433 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "xf86config.h" +#include "mouse-cfg.h" +#include "cards.h" +#include "card-cfg.h" +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/List.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/SimpleMenu.h> +#include <X11/Xaw/Viewport.h> +#ifdef USE_MODULES +#include "loader.h" +#endif + +/* + * Prototypes + */ +static Bool CardConfigCheck(void); +static void CardModelCallback(Widget, XtPointer, XtPointer); +#ifdef USE_MODULES +static void DriverCallback(Widget, XtPointer, XtPointer); +#endif + +/* + * Initialization + */ +static CardsEntry *card_entry; +static XF86ConfDevicePtr current_device; +static Widget filter, list, driver, busid; +static char **cards = NULL; +static int ncards; +#ifdef USE_MODULES +static char *driver_str; +#endif + +/* + * Implementation + */ +/*ARGSUSED*/ +XtPointer +CardConfig(XtPointer config) +{ + XF86ConfDevicePtr card = (XF86ConfDevicePtr)config; +/* XF86OptionPtr option;*/ + char card_name[32]; + Arg args[1]; + char *bus, *drv_nam; + + xf86info.cur_list = CARD; + XtSetSensitive(back, xf86info.lists[CARD].cur_function > 0); + XtSetSensitive(next, xf86info.lists[CARD].cur_function < + xf86info.lists[CARD].num_functions - 1); + (xf86info.lists[CARD].functions[xf86info.lists[CARD].cur_function]) + (&xf86info); + + card_entry = NULL; + current_device = card; + XawListUnhighlight(list); + XtSetArg(args[0], XtNstring, ""); + XtSetValues(filter, args, 1); + + if (card != NULL) { + if (card->dev_card != NULL) { + int i; + + for (i = 0; i < ncards; i++) { + if (strcasecmp(cards[i], card->dev_card) == 0) { + card_entry = LookupCard(cards[i]); + XawListHighlight(list, i); + XtSetArg(args[0], XtNstring, cards[i]); + XtSetValues(filter, args, 1); + break; + } + } + } + XtSetArg(args[0], XtNstring, card->dev_identifier); + XtSetValues(ident_widget, args, 1); + XtSetArg(args[0], XtNstring, card->dev_busid); + XtSetValues(busid, args, 1); +#ifdef USE_MODULES + if (!nomodules) + XtSetArg(args[0], XtNlabel, driver_str = XtNewString(card->dev_driver)); + else +#endif + XtSetArg(args[0], XtNstring, card->dev_driver); + XtSetValues(driver, args, 1); + } + else { + XF86ConfDevicePtr device = XF86Config->conf_device_lst; + int ndevices = 0; + + while (device != NULL) { + ++ndevices; + device = (XF86ConfDevicePtr)(device->list.next); + } + do { + XmuSnprintf(card_name, sizeof(card_name), "Card%d", ndevices); + ++ndevices; + } while (xf86findDevice(card_name, + XF86Config->conf_device_lst)); + + XtSetArg(args[0], XtNstring, card_name); + XtSetValues(ident_widget, args, 1); + XtSetArg(args[0], XtNstring, ""); + XtSetValues(busid, args, 1); +#ifdef USE_MODULES + if (!nomodules) + XtSetArg(args[0], XtNlabel, driver_str = XtNewString("vga")); + else +#endif + XtSetArg(args[0], XtNstring, "vga"); + XtSetValues(driver, args, 1); + } + + if (ConfigLoop(CardConfigCheck) == True) { + if (card_entry != NULL && card_entry->driver == NULL) { + fprintf(stderr, "No driver field in Cards database.\n" + "Please make sure you have the correct files installed.\n"); + exit(1); + } + if (card == NULL) { + card = (XF86ConfDevicePtr)XtCalloc(1, sizeof(XF86ConfDeviceRec)); + card->dev_identifier = XtNewString(ident_string); + if (card_entry) { + card->dev_driver = XtNewString(card_entry->driver); + card->dev_card = XtNewString(card_entry->name); + if (card_entry->chipset) + card->dev_chipset = XtNewString(card_entry->chipset); + if (card_entry->ramdac) + card->dev_ramdac = XtNewString(card_entry->ramdac); + if (card_entry->clockchip) + card->dev_clockchip = XtNewString(card_entry->clockchip); + } + /* else will fallback to "vga" */ + } + else if (card_entry != NULL) { + XtFree(card->dev_driver); + card->dev_driver = XtNewString(card_entry->driver); + if (card_entry->chipset) { + XtFree(card->dev_chipset); + card->dev_chipset = XtNewString(card_entry->chipset); + } + if (card_entry->ramdac) { + XtFree(card->dev_ramdac); + card->dev_ramdac = XtNewString(card_entry->ramdac); + } + if (card_entry->clockchip) { + XtFree(card->dev_clockchip); + card->dev_clockchip = XtNewString(card_entry->clockchip); + } + } + if (strcasecmp(card->dev_identifier, ident_string)) + xf86renameDevice(XF86Config, card, ident_string); + XtSetArg(args[0], XtNstring, &bus); + XtGetValues(busid, args, 1); + XtFree(card->dev_busid); + card->dev_busid = XtNewString(bus); + +#ifdef USE_MODULES + if (!nomodules) + drv_nam = driver_str; + else +#endif + { + XtSetArg(args[0], XtNstring, &drv_nam); + XtGetValues(driver, args, 1); + } + + XtFree(card->dev_driver); + card->dev_driver = XtNewString(drv_nam); + +#ifdef USE_MODULES + if (!nomodules) + XtFree(driver_str); +#endif + + return ((XtPointer)card); + } +#ifdef USE_MODULES + if (!nomodules) + XtFree(driver_str); +#endif + + return (NULL); +} + +static Bool +CardConfigCheck(void) +{ + XF86ConfDevicePtr device = XF86Config->conf_device_lst; + char *drv_nam; + +#ifdef USE_MODULES + if (!nomodules) + drv_nam = driver_str; + else +#endif + { + Arg args[1]; + + XtSetArg(args[0], XtNstring, &drv_nam); + XtGetValues(driver, args, 1); + } + + if (ident_string == NULL || strlen(ident_string) == 0 || +#if 0 + /* not all available cards are in the Cards database */ + (current_device == NULL && card_entry == NULL) || +#endif + drv_nam == NULL || *drv_nam == '\0') + return (False); + + while (device != NULL) { + if (device != current_device && + strcasecmp(ident_string, device->dev_identifier) == 0) + return (False); + device = (XF86ConfDevicePtr)(device->list.next); + } + + return (True); +} + +static void +CardModelCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + char tip[4096]; + int len; + + XtSetArg(args[0], XtNstring, info->string); + XtSetValues(filter, args, 1); + card_entry = LookupCard(info->string); + + if (card_entry == NULL) + return; + + len = XmuSnprintf(tip, sizeof(tip), "Name: %s\n", card_entry->name); + if (card_entry->flags & F_UNSUPPORTED) + len += XmuSnprintf(tip + len, sizeof(tip) - len, + "**THIS CARD IS UNSUPPORTED**\n"); + if (card_entry->chipset != NULL) + len += XmuSnprintf(tip + len, sizeof(tip) - len, + "Chipset: %s\n", card_entry->chipset); + if (card_entry->driver != NULL) { +#ifdef USE_MODULES + if (!nomodules) { + XtFree(driver_str); + driver_str = XtNewString(card_entry->driver); + XtVaSetValues(driver, XtNlabel, driver_str, NULL); + } +#endif + len += XmuSnprintf(tip + len, sizeof(tip) - len, + "Driver: %s\n", card_entry->driver); + } + if (card_entry->ramdac != NULL) + len += XmuSnprintf(tip + len, sizeof(tip), + "Ramdac: %s\n", card_entry->ramdac); + if (card_entry->clockchip != NULL) + len += XmuSnprintf(tip + len, sizeof(tip) - len, + "Clockchip: %s\n", card_entry->clockchip); + if (card_entry->dacspeed != NULL) + len += XmuSnprintf(tip + len, sizeof(tip) - len, + "Dacspeed: %s\n", card_entry->dacspeed); + if (card_entry->lines != NULL) + len += XmuSnprintf(tip + len, sizeof(tip) - len, + "\n%s\n", card_entry->lines); + +#ifndef USE_MODULES + XtSetArg(args[0], XtNstring, + card_entry->driver ? card_entry->driver : "vga"); + XtSetValues(driver, args, 1); +#endif + + XtSetArg(args[0], XtNtip, tip); + XtSetValues(filter, args, 1); +} + +/*ARGSUSED*/ +void +CardFilterAction(Widget w, XEvent *ev, String *params, Cardinal *num_params) +{ + char **cards, *pattern, **old_cards; + int ncards, old_ncards; + Arg args[2]; + + XtSetArg(args[0], XtNstring, &pattern); + XtGetValues(w, args, 1); + + XtSetArg(args[0], XtNlist, &old_cards); + XtSetArg(args[1], XtNnumberStrings, &old_ncards); + XtGetValues(list, args, 2); + + cards = FilterCardNames(pattern, &ncards); + + if (ncards == 0) { + cards = (char**)XtMalloc(sizeof(char*)); + cards[0] = XtNewString(""); + ncards = 1; + } + + XtSetArg(args[0], XtNlist, cards); + XtSetArg(args[1], XtNnumberStrings, ncards); + XtSetValues(list, args, 2); + + if (old_ncards > 1 || (XtName(list) != old_cards[0])) { + while (--old_ncards > -1) + XtFree(old_cards[old_ncards]); + XtFree((char*)old_cards); + } + + /* force relayout */ + XtUnmanageChild(list); + XtManageChild(list); +} + +#ifdef USE_MODULES +/*ARGSUSED*/ +static void +DriverCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + + XtFree(driver_str); + driver_str = XtNewString(XtName(w)); + XtSetArg(args[0], XtNlabel, driver_str); + XtSetValues(driver, args, 1); +} +#endif + +void +CardModel(XF86SetupInfo *info) +{ + static int first = 1; + static Widget model; + + if (first) { + Widget viewport; + + first = 0; + + cards = GetCardNames(&ncards); + + model = XtCreateWidget("cardModel", formWidgetClass, + configp, NULL, 0); + (void) XtCreateManagedWidget("label", labelWidgetClass, + model, NULL, 0); + filter = XtVaCreateManagedWidget("filter", asciiTextWidgetClass, + model, + XtNeditType, XawtextEdit, + NULL); + viewport = XtCreateManagedWidget("viewport", viewportWidgetClass, + model, NULL, 0); + list = XtVaCreateManagedWidget("list", listWidgetClass, + viewport, + XtNlist, cards, + XtNnumberStrings, ncards, + NULL); + XtAddCallback(list, XtNcallback, CardModelCallback, + (XtPointer)info); + XtCreateManagedWidget("driverL", labelWidgetClass, model, NULL, 0); +#ifdef USE_MODULES + if (!nomodules) { + driver = XtVaCreateManagedWidget("driver", menuButtonWidgetClass, + model, + XtNmenuName, "driverM", + NULL); + { + Widget menu, sme; + xf86cfgModuleOptions *opts = module_options; + + menu = XtCreatePopupShell("driverM", simpleMenuWidgetClass, + driver, NULL, 0); + while (opts) { + if (opts->type == VideoModule) { + sme = XtCreateManagedWidget(opts->name, smeBSBObjectClass, + menu, NULL, 0); + XtAddCallback(sme, XtNcallback, DriverCallback, NULL); + } + opts = opts->next; + } + } + } + else +#endif + driver = XtVaCreateManagedWidget("driver", asciiTextWidgetClass, + model, + XtNeditType, XawtextEdit, + NULL); + + XtCreateManagedWidget("busidL", labelWidgetClass, model, NULL, 0); + busid = XtVaCreateManagedWidget("busid", asciiTextWidgetClass, + model, + XtNeditType, XawtextEdit, + NULL); + + XtRealizeWidget(model); + } + XtChangeManagedSet(¤t, 1, NULL, NULL, &model, 1); + current = model; +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.h b/xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.h new file mode 100644 index 000000000..fbb02a7ab --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/card-cfg.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" + +#ifndef _xf86cfg_card_h +#define _xf86cfg_card_h + +/* + * Prototypes + */ +XtPointer CardConfig(XtPointer); +void CardModel(XF86SetupInfo*); +void CardFilterAction(Widget, XEvent*, String*, Cardinal*); + +#endif /* _xf86cfg_card_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/card.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/card.xbm new file mode 100644 index 000000000..aad07a90a --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/card.xbm @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +#define card_width 50 +#define card_height 44 +static unsigned char card_bits[] = { + 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xfd, 0xff, 0xff, 0xff, 0x07, + 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x80, 0x07, 0x00, 0x00, + 0x00, 0x1c, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x80, 0x01, + 0x00, 0x00, 0xf8, 0x19, 0x00, 0x80, 0xf9, 0x00, 0x00, 0xf8, 0x19, 0x00, + 0x80, 0xf9, 0xf8, 0x7f, 0x98, 0x19, 0x00, 0x80, 0x01, 0xf8, 0x7f, 0x98, + 0x19, 0x00, 0x80, 0x01, 0x18, 0x60, 0xf8, 0x19, 0x00, 0x80, 0xf9, 0x18, + 0x60, 0xf8, 0x19, 0x00, 0x80, 0xf9, 0x18, 0x60, 0x00, 0x18, 0x00, 0x80, + 0x01, 0x18, 0x60, 0xf8, 0x19, 0x00, 0x80, 0x01, 0x18, 0x60, 0xf8, 0x19, + 0x00, 0x80, 0xf9, 0x18, 0x60, 0x98, 0x19, 0x00, 0x80, 0xf9, 0x18, 0x60, + 0x98, 0x19, 0x00, 0x80, 0x01, 0x18, 0x60, 0xf8, 0x19, 0x00, 0x80, 0x01, + 0xf8, 0x7f, 0xf8, 0x19, 0x00, 0x80, 0xf9, 0xf8, 0x7f, 0x00, 0x18, 0x00, + 0x80, 0xf9, 0x00, 0x00, 0xf8, 0x19, 0x00, 0x80, 0x01, 0x00, 0x00, 0xf8, + 0x19, 0x00, 0x80, 0x01, 0x30, 0x33, 0x98, 0x19, 0x00, 0x80, 0xf9, 0x30, + 0x33, 0x98, 0x19, 0x00, 0x80, 0xf9, 0x30, 0x33, 0xf8, 0x19, 0x00, 0x80, + 0x01, 0x30, 0x33, 0xf8, 0x19, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x80, 0xff, 0x07, 0x00, + 0x80, 0x0f, 0x00, 0x80, 0xfd, 0x0f, 0x00, 0xc0, 0x07, 0x00, 0x80, 0x01, + 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x80, 0x01, 0xcc, 0xcc, 0xcc, 0x00, 0x00, + 0x80, 0x01, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x80, 0x01, 0xcc, 0xcc, 0xcc, + 0x00, 0x00, 0x80, 0x01, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x80, 0x01, 0xf8, + 0xff, 0x7f, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/card.xpm b/xorg-server/hw/xfree86/utils/xorgcfg/card.xpm new file mode 100644 index 000000000..32bccb689 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/card.xpm @@ -0,0 +1,81 @@ +/* XPM */ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +static char * card_xpm[] = { +"41 40 8 1", +" c none", +"A c #B6DABAEAB6DA", +"X c #0000AAAA0000", +"o c #000071C60000", +"O c #000041030000", +"+ c #618561856185", +"@ c #186118611861", +"# c #CF3CA2892081", +"AAA ", +" A ", +" A ", +" A ", +" A ", +" A ", +" A ", +" AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ", +" AooooooooooooooooooooooooooooooooooooO", +" AooooooooooooooooooooooooooooooooooooO", +" AooooooooooooooooooooooooooooooooooooO", +" AooooooooooooooooooooooooOOOOOOOOOOOOO", +" AooooooooooooooooooAoAoAoAooAAAAAAA+oO", +" AooooooooooooooooooAoAoAoAooA++++++@oO", +" AooooooooooooooooooAoAoAoAooA+oooo+@oO", +" AoooooooooooooooooooooooooooA+AAAA+@oO", +" AoooooooooooooooooooooooooooA+oooo+@oO", +" AoooooooooooooooooooooooooooA++++++@oO", +" Aooooooooooooooooooooooooooo+@@@@@@@oO", +" AooooooooooooooooooooooooooooooooooooO", +" AoooooooooooooooooooooooooooAAAAAAA+oO", +" +AoooooooooooooooooAAAAAAAA@oA++++++@oO", +" AoooooooooooooooooA+++++++@oA+oooo+@oO", +" AoooooooooooooooooA+++++++@oA+AAAA+@oO", +" ++AoooooooooooooooooA+++++++@oA+oooo+@oO", +" ++AoooooooooooooooooA+++++++@oA++++++@oO", +" ++Aooooooooooooooooo@@@@@@@@@o+@@@@@@@oO", +" ++AooooooooooooooooooooooooooooooooooooO", +" AooooooooooooooooooooooooooooooooooooO", +" AooooooooooooooooooooooooooooooooooooO", +" +AooooooooooooooooooooooooooooooooooooO", +" AooooooooooooooooooooooooooooooooooooO", +" AoooOOOOooooooooooooooooooooOoooooOOO ", +" AooO X#o#o#o#o#o#o#o#o#oO X#o#O ", +" AOO X#o#o#o#o#o#o#o#o#oO X#o#O ", +" A X#o#o#o#o#o#o#o#o#oO X#o#O ", +" A X#o#o#o#o#o#o#o#o#oO X#o#O ", +" A OOOOOOOOOOOOOOOOOO OOO ", +" A ", +" A "}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/cards.c b/xorg-server/hw/xfree86/utils/xorgcfg/cards.c new file mode 100644 index 000000000..dcd5828cb --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/cards.c @@ -0,0 +1,695 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#define CARDS_PRIVATE +#include "cards.h" + +#undef SERVER /* defined in config.h, but of no use here */ + +/* return values from ReadCardsLine. */ +#define ERROR -3 +#define UNKNOWN -2 +#define END -1 +#define NOTUSEFUL 0 +#define NAME 1 +#define CHIPSET 2 +#define SERVER 3 +#define DRIVER 4 +#define RAMDAC 5 +#define CLOCKCHIP 6 +#define DACSPEED 7 +#define NOCLOCKPROBE 8 +#define UNSUPPORTED 9 +#define SEE 10 +#define LINE 11 + +/* + * Prototypes + */ +static int ReadCardsLine(FILE*, char*); /* must have 256 bytes */ +static int CompareCards(_Xconst void *left, _Xconst void *right); +static int BCompareCards(_Xconst void *left, _Xconst void *right); +static void DoReadCardsDatabase(void); +static char **DoFilterCardNames(char *pattern, int *result); + +#ifdef USE_MODULES + +typedef struct { + int ivendor; + unsigned short vendor; + unsigned short valid_vendor; + char *chipsets; + int num_chipsets; +} chipset_check; +#endif + +/* + * Initialization + */ +static int linenum = 0; +static char *Cards = "lib/X11/Cards"; +CardsEntry **CardsDB; +int NumCardsEntry; + +/* + * Implementation + */ +#ifdef USE_MODULES +const pciVendorInfo *xf86PCIVendorInfo; +#endif + +#ifdef USE_MODULES +void +InitializePciInfo(void) +{ + xf86PCIVendorInfo = pciVendorInfoList; +} + +void +CheckChipsets(xf86cfgModuleOptions *opts, int *err) +{ + int i, j, ichk, ivnd = 0, vendor = -1, device; + const pciDeviceInfo **pDev; + SymTabPtr chips = opts->chipsets; + chipset_check *check = NULL; + int num_check = 0; + + if (!chips) { + CheckMsg(CHECKER_NO_CHIPSETS, "WARNING No chipsets specified.\n"); + ++*err; + return; + } + + while (chips->name) { + device = chips->token & 0xffff; + vendor = (chips->token & 0xffff0000) >> 16; + if (vendor == 0) + vendor = opts->vendor; + + for (ichk = 0; ichk < num_check; ichk++) + if (check[ichk].vendor == vendor) + break; + if (ichk >= num_check) { + check = (chipset_check*) + XtRealloc((XtPointer)check, + sizeof(chipset_check) * (num_check + 1)); + check[num_check].vendor = vendor; + memset(&check[num_check], 0, sizeof(chipset_check)); + ++num_check; + } + + /* Search for vendor in xf86PCIVendorInfo */ + if (xf86PCIVendorInfo) { + for (ivnd = 0; xf86PCIVendorInfo[ivnd].VendorID; ivnd++) + if (vendor == xf86PCIVendorInfo[ivnd].VendorID) + break; + } + if (xf86PCIVendorInfo && xf86PCIVendorInfo[ivnd].VendorID) { + check[ichk].valid_vendor = 1; + check[ichk].ivendor = ivnd; + } + else { + CheckMsg(CHECKER_CANNOT_VERIFY_CHIPSET, + "WARNING Cannot verify chipset \"%s\" (0x%x)\n", + chips->name, device); + ++*err; + ++chips; + continue; + } + + if (xf86PCIVendorInfo && + (pDev = xf86PCIVendorInfo[ivnd].Device) != NULL) { + if (check[ichk].chipsets == NULL) { + for (j = 0; pDev[j]; j++) + ; + check[ichk].chipsets = (char*)XtCalloc(1, j); + } + for (j = 0; pDev[j]; j++) { + if (device == pDev[j]->DeviceID) { + if (strcmp(chips->name, pDev[j]->DeviceName)) { + CheckMsg(CHECKER_NOMATCH_CHIPSET_STRINGS, + "WARNING chipset strings don't match: \"%s\" \"%s\" (0x%x)\n", + chips->name, xf86PCIVendorInfo[ivnd].Device[j]->DeviceName, + device); + ++*err; + } + break; + } + } + if (!pDev[j]) { + CheckMsg(CHECKER_CHIPSET_NOT_LISTED, + "WARNING chipset \"%s\" (0x%x) not in list.\n", chips->name, device); + ++*err; + } + else + check[ichk].chipsets[j] = 1; + } + ++chips; + } + + for (i = 0; i < num_check; i++) { + if (!check[i].valid_vendor) { + CheckMsg(CHECKER_CHIPSET_NO_VENDOR, + "WARNING No such vendor 0x%x\n", vendor); + ++*err; + } + for (j = 0; j < check[i].num_chipsets; j++) { + if (xf86PCIVendorInfo && !check[i].chipsets[j]) { + CheckMsg(CHECKER_CHIPSET_NOT_SUPPORTED, + "NOTICE chipset \"%s\" (0x%x) not listed as supported.\n", + xf86PCIVendorInfo[check[i].ivendor].Device[j]->DeviceName, + xf86PCIVendorInfo[check[i].ivendor].Device[j]->DeviceID); + } + } + XtFree(check[i].chipsets); + } + + XtFree((XtPointer)check); +} +#endif + +void +ReadCardsDatabase(void) +{ +#ifdef USE_MODULES + if (!nomodules) { + int i, j, ivendor, idevice; + char name[256]; + _Xconst char *vendor, *device; + CardsEntry *entry = NULL, *tmp; + xf86cfgModuleOptions *opts = module_options; + const pciDeviceInfo **pDev; + + /* Only list cards that have a driver installed */ + while (opts) { + if (opts->chipsets) { + SymTabPtr chips = opts->chipsets; + + while (chips->name) { + vendor = opts->name; + device = chips->name; + ivendor = (chips->token & 0xffff0000) >> 16; + idevice = chips->token & 0xffff0; + if (ivendor == 0) + ivendor = opts->vendor; + + if (xf86PCIVendorInfo) { + for (i = 0; xf86PCIVendorInfo[i].VendorName; i++) + if (ivendor == xf86PCIVendorInfo[i].VendorID) { + vendor = xf86PCIVendorInfo[i].VendorName; + break; + } + if (xf86PCIVendorInfo[i].VendorName) { + if ((pDev = xf86PCIVendorInfo[i].Device)) { + for (j = 0; pDev[j]; j++) + if (idevice == pDev[j]->DeviceID) { + device = pDev[j]->DeviceName; + break; + } + } + } + } + + /* Since frequently there is more than one driver for a + * single vendor, it is required to avoid duplicates. + */ + XmuSnprintf(name, sizeof(name), "%s %s", vendor, device); + tmp = LookupCard(name); + + if (tmp == NULL || strcmp(tmp->chipset, chips->name) || + strcmp(tmp->driver, opts->name)) { + entry = (CardsEntry*)XtCalloc(1, sizeof(CardsEntry)); + if (NumCardsEntry % 16 == 0) { + CardsDB = (CardsEntry**)XtRealloc((XtPointer)CardsDB, + sizeof(CardsEntry*) * (NumCardsEntry + 16)); + } + CardsDB[NumCardsEntry++] = entry; + entry->name = XtNewString(name); + + /* XXX no private copy of strings */ + entry->chipset = (char*)chips->name; + entry->driver = opts->name; + + /* better than linear searchs to find duplicates */ + qsort(CardsDB, NumCardsEntry, sizeof(CardsEntry*), + CompareCards); + } + ++chips; + } + } + opts = opts->next; + } + + /* fix entries with the same name */ + for (i = 0; i < NumCardsEntry - 2;) { + for (j = i + 1; j < NumCardsEntry - 1 && + strcmp(CardsDB[i]->name, CardsDB[j]->name) == 0; j++) + ; + + if (i + 1 != j) { + while (i < j) { + char *str; + + if (strcmp(CardsDB[i]->chipset, CardsDB[j]->chipset)) + str = CardsDB[i]->chipset; + else + str = CardsDB[i]->driver; + + XmuSnprintf(name, sizeof(name), "%s (%s)", + CardsDB[i]->name, str); + XtFree(CardsDB[i]->name); + CardsDB[i]->name = XtNewString(name); + + ++i; + } + } + else + ++i; + } + + /* make sure data is valid to bsearch in */ + qsort(CardsDB, NumCardsEntry, sizeof(CardsEntry*), CompareCards); + } + else +#endif + DoReadCardsDatabase(); +} + +static void +DoReadCardsDatabase(void) +{ + char buffer[256]; + FILE *fp = fopen(Cards, "r"); + int i, result; + CardsEntry *entry = NULL; + static char *CardsError = "Error reading Cards database, at line %d (%s).\n"; + + if (fp == NULL) { + fprintf(stderr, "Cannot open Cards database.\n"); + exit(1); + } + + while ((result = ReadCardsLine(fp, buffer)) != END) { + switch (result) { + case ERROR: + fprintf(stderr, CardsError, linenum, buffer); + break; + case UNKNOWN: + fprintf(stderr, + "Unknown field type in Cards database, at line %d (%s).\n", + linenum, buffer); + break; + case NAME: + entry = calloc(1, sizeof(CardsEntry)); + if (NumCardsEntry % 16 == 0) { + CardsDB = realloc(CardsDB, sizeof(CardsEntry*) * + (NumCardsEntry + 16)); + if (CardsDB == NULL) { + fprintf(stderr, "Out of memory reading Cards database.\n"); + exit(1); + } + } + CardsDB[NumCardsEntry++] = entry; + entry->name = strdup(buffer); + break; + case CHIPSET: + if (entry == NULL || entry->chipset != NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } +#if 0 + else + entry->chipset = strdup(buffer); +#endif + break; + case SERVER: + if (entry == NULL || entry->server != NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->server = strdup(buffer); + break; + case DRIVER: + if (entry == NULL || entry->driver != NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->driver = strdup(buffer); + break; + case RAMDAC: + if (entry == NULL || entry->ramdac != NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->ramdac = strdup(buffer); + break; + case CLOCKCHIP: + if (entry == NULL || entry->clockchip != NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->clockchip = strdup(buffer); + break; + case DACSPEED: + if (entry == NULL || entry->dacspeed != NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->dacspeed = strdup(buffer); + break; + case NOCLOCKPROBE: + if (entry == NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->flags |= F_NOCLOCKPROBE; + break; + case UNSUPPORTED: + if (entry == NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->flags |= F_UNSUPPORTED; + break; + case SEE: + if (entry == NULL || entry->see != NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else + entry->see = strdup(buffer); + break; + case LINE: + if (entry == NULL) { + fprintf(stderr, CardsError, linenum, buffer); + } + else if (entry->lines == NULL) + entry->lines = strdup(buffer); + else { + char *str = malloc(strlen(entry->lines) + strlen(buffer) + 2); + + sprintf(str, "%s\n%s", entry->lines, buffer); + free(entry->lines); + entry->lines = str; + } + break; + } + } + + fclose(fp); + + qsort(CardsDB, NumCardsEntry, sizeof(CardsEntry*), CompareCards); + +#ifdef DEBUG + for (i = 0; i < NumCardsEntry - 1; i++) { + if (strcmp(CardsDB[i]->name, CardsDB[i+1]->name) == 0) + fprintf(stderr, "Duplicate entry in Cards database: (%s).\n", + CardsDB[i]->name); + } +#endif + + for (i = 0; i < NumCardsEntry - 1; i++) { + if (CardsDB[i]->see != NULL) { + if ((entry = LookupCard(CardsDB[i]->see)) == NULL) { + fprintf(stderr, "Cannot find card '%s' for filling defaults.\n", + CardsDB[i]->see); + continue; + } + if (CardsDB[i]->chipset == NULL && entry->chipset != NULL) + CardsDB[i]->chipset = strdup(entry->chipset); + if (CardsDB[i]->server == NULL && entry->server != NULL) + CardsDB[i]->server = strdup(entry->server); + if (CardsDB[i]->driver == NULL && entry->driver != NULL) + CardsDB[i]->driver = strdup(entry->driver); + if (CardsDB[i]->ramdac == NULL && entry->ramdac != NULL) + CardsDB[i]->ramdac = strdup(entry->ramdac); + if (CardsDB[i]->clockchip == NULL && entry->clockchip != NULL) + CardsDB[i]->clockchip = strdup(entry->clockchip); + if (CardsDB[i]->dacspeed == NULL && entry->dacspeed != NULL) + CardsDB[i]->dacspeed = strdup(entry->dacspeed); + if (CardsDB[i]->flags & F_NOCLOCKPROBE) + CardsDB[i]->flags |= F_NOCLOCKPROBE; + if (CardsDB[i]->flags & F_UNSUPPORTED) + CardsDB[i]->flags |= F_UNSUPPORTED; + if (entry->lines != NULL) { + if (CardsDB[i]->lines == NULL) + CardsDB[i]->lines = strdup(entry->lines); + else { + char *str = malloc(strlen(entry->lines) + + strlen(CardsDB[i]->lines) + 2); + + sprintf(str, "%s\n%s", CardsDB[i]->lines, entry->lines); + free(CardsDB[i]->lines); + CardsDB[i]->lines = str; + } + } + if (entry->see != NULL) { +#ifdef DEBUG + fprintf(stderr, "Nested SEE entry: %s -> %s -> %s\n", + CardsDB[i]->name, CardsDB[i]->see, entry->see); +#endif + CardsDB[i]->see = strdup(entry->see); + --i; + continue; + } + free(CardsDB[i]->see); + CardsDB[i]->see = NULL; + } + } +} + +CardsEntry * +LookupCard(char *name) +{ + CardsEntry **ptr; + + if (NumCardsEntry == 0 || CardsDB == 0) + return NULL; + + ptr = (CardsEntry**)bsearch(name, CardsDB, NumCardsEntry, + sizeof(CardsEntry*), BCompareCards); + + return (ptr != NULL ? *ptr : NULL); +} + +char ** +GetCardNames(int *result) +{ + char **cards = NULL; + int ncards; + + for (ncards = 0; ncards < NumCardsEntry; ncards++) { + if (ncards % 16 == 0) { + if ((cards = (char**)realloc(cards, sizeof(char*) * + (ncards + 16))) == NULL) { + fprintf(stderr, "Out of memory.\n"); + exit(1); + } + } + cards[ncards] = strdup(CardsDB[ncards]->name); + } + + *result = ncards; + + return (cards); +} + +char ** +FilterCardNames(char *pattern, int *result) +{ +#ifdef USE_MODULES + if (!nomodules) { + char **cards = NULL; + int i, ncards = 0; + + for (i = 0; i < NumCardsEntry; i++) { + if (strstr(CardsDB[i]->name, pattern) == NULL) + continue; + if (ncards % 16 == 0) { + if ((cards = (char**)realloc(cards, sizeof(char*) * + (ncards + 16))) == NULL) { + fprintf(stderr, "Out of memory.\n"); + exit(1); + } + } + cards[ncards] = strdup(CardsDB[i]->name); + ++ncards; + } + + *result = ncards; + + return (cards); + } +#endif + return (DoFilterCardNames(pattern, result)); +} + +static char ** +DoFilterCardNames(char *pattern, int *result) +{ + FILE *fp; + char **cards = NULL; + int len, ncards = 0; + char *cmd, *ptr, buffer[256]; + + cmd = malloc(32 + (strlen(pattern) * 2) + strlen(Cards)); + + strcpy(cmd, "egrep -i '^NAME\\ .*"); + len = strlen(cmd); + ptr = pattern; + while (*ptr) { + if (!isalnum(*ptr)) { + cmd[len++] = '\\'; + } + cmd[len++] = *ptr++; + } + cmd[len] = '\0'; + strcat(cmd, ".*$' "); + strcat(cmd, Cards); + strcat(cmd, " | sort"); + /*sprintf(cmd, "egrep -i '^NAME\\ .*%s.*$' %s | sort", pattern, Cards);*/ + + if ((fp = popen(cmd, "r")) == NULL) { + fprintf(stderr, "Cannot read Cards database.\n"); + exit(1); + } + while (fgets(buffer, sizeof(buffer), fp) != NULL) { + ptr = buffer + strlen(buffer) - 1; + while (isspace(*ptr) && ptr > buffer) + --ptr; + if (!isspace(*ptr) && ptr > buffer) + ptr[1] = '\0'; + ptr = buffer; + while (!isspace(*ptr) && *ptr) /* skip NAME */ + ++ptr; + while (isspace(*ptr) && *ptr) + ++ptr; + if (ncards % 16 == 0) { + if ((cards = (char**)realloc(cards, sizeof(char*) * + (ncards + 16))) == NULL) { + fprintf(stderr, "Out of memory.\n"); + exit(1); + } + } + cards[ncards++] = strdup(ptr); + } + free(cmd); + + *result = ncards; + + return (cards); +} + +static int +ReadCardsLine(FILE *fp, char *value) +{ + char name[32], buffer[256], *ptr, *end; + int result = NOTUSEFUL; + + ++linenum; + + if (fgets(buffer, sizeof(buffer), fp) == NULL) + return (END); + + ptr = buffer; + /* skip initial spaces; should'nt bother about this.. */ + while (isspace(*ptr) && *ptr) + ++ptr; + + if (*ptr == '#' || *ptr == '\0') + return (NOTUSEFUL); + + end = ptr; + while (!isspace(*end) && *end) + ++end; + if (end - ptr > sizeof(buffer) - 1) { + strncpy(value, buffer, 255); + value[255] = '\0'; + return (ERROR); + } + strncpy(name, ptr, end - ptr); + name[end - ptr] = '\0'; + + /* read the optional arguments */ + ptr = end; + while (isspace(*ptr) && *ptr) + ++ptr; + + end = ptr + strlen(ptr) - 1; + while (isspace(*end) && end > ptr) + --end; + if (!isspace(*end)) + ++end; + *end = '\0'; + + if (strcmp(name, "NAME") == 0) + result = NAME; + else if (strcmp(name, "CHIPSET") == 0) + result = CHIPSET; + else if (strcmp(name, "SERVER") == 0) + result = SERVER; + else if (strcmp(name, "DRIVER") == 0) + result = DRIVER; + else if (strcmp(name, "RAMDAC") == 0) + result = RAMDAC; + else if (strcmp(name, "CLOCKCHIP") == 0) + result = CLOCKCHIP; + else if (strcmp(name, "DACSPEED") == 0) + result = DACSPEED; + else if (strcmp(name, "NOCLOCKPROBE") == 0) + result = NOCLOCKPROBE; + else if (strcmp(name, "UNSUPPORTED") == 0) + result = UNSUPPORTED; + else if (strcmp(name, "SEE") == 0) + result = SEE; + else if (strcmp(name, "LINE") == 0) + result = LINE; + else if (strcmp(name, "END") == 0) + result = END; + else { + strcpy(value, name); + return (UNKNOWN); + } + + /* value *must* have at least 256 bytes */ + strcpy(value, ptr); + + return (result); +} + +static int +CompareCards(_Xconst void *left, _Xconst void *right) +{ + return strcasecmp((*(CardsEntry**)left)->name, (*(CardsEntry**)right)->name); +} + +static int +BCompareCards(_Xconst void *name, _Xconst void *card) +{ + return (strcasecmp((char*)name, (*(CardsEntry**)card)->name)); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/cards.h b/xorg-server/hw/xfree86/utils/xorgcfg/cards.h new file mode 100644 index 000000000..8557e96df --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/cards.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <X11/Xfuncproto.h> +#include <X11/Xmd.h> +#include <X11/Intrinsic.h> +#include <X11/Xmu/SysUtil.h> + +#ifndef _xf86cfg_cards_h +#define _xf86cfg_cards_h + +#ifdef USE_MODULES +#ifdef CARDS_PRIVATE +#include "loader.h" + +#include "xf86PciStr.h" +#include "xf86PciIds.h" +#endif /* CARDS_PRIVATE */ +#endif /* USE_MODULES */ + +/* Flags in CardsEntry */ +#define F_NOCLOCKPROBE 0x1 /* Never probe clocks of the card. */ +#define F_UNSUPPORTED 0x2 /* Card is not supported (only VGA). */ + +/* + * Types + */ +typedef struct { + char *name; /* Name of the card. */ + char *chipset; /* Chipset (decriptive). */ + char *server; /* Server identifier. */ + char *driver; /* Driver identifier. */ + char *ramdac; /* Ramdac identifier. */ + char *clockchip; /* Clockchip identifier. */ + char *dacspeed; /* DAC speed rating. */ + int flags; + char *lines; /* Additional Device section lines. */ + char *see; /* Must resolve in a last step. + * Allow more than one SEE entry? */ +} CardsEntry; + +extern CardsEntry **CardsDB; +extern int NumCardsEntry; + +/* + * Prototypes + */ +void ReadCardsDatabase(void); +CardsEntry *LookupCard(char*); +char **GetCardNames(int*); +char **FilterCardNames(char*, int*); +#ifdef USE_MODULES +void InitializePciInfo(void); +typedef struct _xf86cfgModuleOptions *xf86cfgModuleOptionsPtr; +void CheckChipsets(xf86cfgModuleOptionsPtr, int*); +#endif + +#endif /* _xf86cfg_cards_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/computer.xpm b/xorg-server/hw/xfree86/utils/xorgcfg/computer.xpm new file mode 100644 index 000000000..9167e3eaf --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/computer.xpm @@ -0,0 +1,91 @@ +/* XPM */ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +static char * computer_xpm[] = { +"30 50 8 1", +" c none", +". c #CF3CCF3CCF3C", +"X c #B6DABAEAB6DA", +"o c #8E388E388E38", +"O c #FFFFFFFFFFFF", +"+ c #FFFF00000000", +"@ c #514451445144", +"# c #0000FFFF0000", +" ............................ ", +"..XXXXXXXXXXXXXXXXXXXXXXXXXXXo", +".XXXXXXXXXXXXXXXXXXXXXXXXXXXXo", +".XXooooooooooooooooooooooooXXo", +".XXo.......................XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XX....XXXXXXXXXXXOoXo.XXo", +".XXo.XXooooXXXXXXXXXXXooXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.......................XXo", +".XXooooooooooooooooooooooooXXo", +".XXo.......................XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXooooooooooooooooooooooo.XXo", +".XXo.......................XXo", +".XXoooooooooooooo.XXXXXXXo.XXo", +".XXo..............XXXXXXXo.XXo", +".XXo.XXXXXXXXXXXX.XX.O.XXo.XXo", +".XXo.oooooooooooX.XXO+OXXo.XXo", +".XXo.XXXXXXXXXOOX.XX.O.XXo.XXo", +".XXo.XXXXXXXXXXXX.XXXXXXXo.XXo", +".XXo..............XXXXXXXo.XXo", +".XXooooooooooooooooooooooo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXX@@@@@@@@@XXX...XXo.XXo", +".XXo.XX@@+@@@@@#@@X.OXXoXo.XXo", +".XXo.XXX@@@@@@@@@XXXoooXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXXXXXXXXXXXXXX..XXXo.XXo", +".XXo.XXXXXXXXXXXXXX.OXoXXo.XXo", +".XXo.XXXXXXXXXXXXXXXooXXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXo.XXXXXXXXXXXXXXXXXXXXo.XXo", +".XXXo.XXXXXXXXXXXXXXXXXXo.XXXo", +".XXXo.XXXXXXXXXXXXXXXXXXo.XXXo", +".XXXo.XXXXXXXXXXXXXXXXXXo.XXXo", +".XXXo.oXXXoXXXoXXXoXXXoXo.XXXo", +".XXXXo.XXXXXXXXXXXXXXXXo.XXXXo", +".XXXXo..oXXXoXXXoXXoXXoo.XXXXo", +".XXXXXoo..XXXXXXXXXXoo..XXXXXo", +".XXXXXXXoo......oooo..XXXXXXXo", +".XXXXXXXXXoooooo....XXXXXXXXXo", +".XXXXXXXXXXXXXXXXXXXXXXXXXXXXo", +".XXXXXXXXXXXXXXXXXXXXXXXXXXXoo", +" oooooooooooooooooooooooooooo "}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/config.c b/xorg-server/hw/xfree86/utils/xorgcfg/config.c new file mode 100644 index 000000000..8c985bf34 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/config.c @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#include "mouse-cfg.h" +#include "keyboard-cfg.h" +#include "card-cfg.h" +#include "monitor-cfg.h" +#include "screen-cfg.h" +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Paned.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/Command.h> +#include <X11/Shell.h> + +/* + * Prototypes + */ +void BackCallback(Widget, XtPointer, XtPointer); +void NextCallback(Widget, XtPointer, XtPointer); +void ApplyCallback(Widget, XtPointer, XtPointer); +void CloseCallback(Widget, XtPointer, XtPointer); +void ErrorCallback(Widget, XtPointer, XtPointer); + +/* + * Initialization + */ +XF86SetupFunction mouse_functions[] = { + MouseDeviceAndProtocol, +}; + +XF86SetupFunction keyboard_functions[] = { + KeyboardModelAndLayout, +}; + +XF86SetupFunction card_functions[] = { + CardModel, +}; + +XF86SetupFunction monitor_functions[] = { + MonitorLayout, +}; + +XF86SetupFunction screen_functions[] = { + ScreenDialog, +}; + +XF86SetupFunctionList function_lists[] = { + {mouse_functions, sizeof(mouse_functions) / sizeof(mouse_functions[0]),}, + {keyboard_functions, sizeof(keyboard_functions) / sizeof(keyboard_functions[0]),}, + {card_functions, sizeof(card_functions) / sizeof(card_functions[0]),}, + {monitor_functions, sizeof(monitor_functions) / sizeof(monitor_functions[0]),}, + {screen_functions, sizeof(screen_functions) / sizeof(screen_functions[0]),}, +}; + +XF86SetupInfo xf86info = { + sizeof(function_lists) / sizeof(function_lists[0]), + MOUSE, + function_lists, +}; + +Widget configp, current, ok, back, next; +static Widget shell, errcurrent, oldcurrent; + +static int config_status, config_popped; + +static ConfigCheckFunction config_function; + +Widget ident_widget; +char *ident_string; +XF86ConfigPtr XF86Config; + +/* + * Implementation + */ +void +StartConfig(void) +{ + static int first = 1; + Widget pane, top, bottom, cancel; + const char *filename; + + if (!first) + return; + first = 0; + + /* Read initial configuration */ + if ((filename = xf86openConfigFile(getuid() == 0 ? CONFPATH : USER_CONFPATH, + XF86Config_path, NULL)) == NULL) { + int length = XF86Config_path ? strlen(XF86Config_path) : -1; + + if (length > 2 && + XF86Config_path[length - 2] == '-' && + XF86Config_path[length - 1] == '4') { + XF86Config_path[length - 2] = '\0'; + filename = xf86openConfigFile(getuid() == 0 ? + CONFPATH : USER_CONFPATH, + XF86Config_path, NULL); + } + + if (filename == NULL) { + fprintf(stderr, "Cannot open config file.\n"); + exit(1); + } + } + XF86Config_path = (char *)filename; + if ((XF86Config = xf86readConfigFile()) == NULL) { + fprintf(stderr, "Problem when parsing config file\n"); + exit(1); + } + + shell = XtCreatePopupShell("config", transientShellWidgetClass, + toplevel, NULL, 0); + pane = XtCreateManagedWidget("pane", panedWidgetClass, + shell, NULL, 0); + top = XtCreateManagedWidget("top", formWidgetClass, + pane, NULL, 0); + (void) XtCreateManagedWidget("label", labelWidgetClass, + top, NULL, 0); + ident_widget = XtVaCreateManagedWidget("identifier", asciiTextWidgetClass, + top, + XtNeditType, XawtextEdit, + NULL); + configp = XtCreateManagedWidget("work", formWidgetClass, + pane, NULL, 0); + current = XtCreateManagedWidget("wellcome", labelWidgetClass, + configp, NULL, 0); + bottom = XtCreateManagedWidget("bottom", formWidgetClass, + pane, NULL, 0); + back = XtCreateManagedWidget("back", commandWidgetClass, + bottom, NULL, 0); + XtAddCallback(back, XtNcallback, BackCallback, (XtPointer)&xf86info); + next = XtCreateManagedWidget("next", commandWidgetClass, + bottom, NULL, 0); + XtAddCallback(next, XtNcallback, NextCallback, (XtPointer)&xf86info); + ok = XtCreateManagedWidget("ok", commandWidgetClass, + bottom, NULL, 0); + XtAddCallback(ok, XtNcallback, ApplyCallback, (XtPointer)NULL); + cancel = XtCreateManagedWidget("cancel", commandWidgetClass, + bottom, NULL, 0); + XtAddCallback(cancel, XtNcallback, CloseCallback, (XtPointer)NULL); + + XtRealizeWidget(shell); + + XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1); +} + +/*ARGSUSED*/ +Bool +ConfigLoop(ConfigCheckFunction config_fn) +{ + Arg args[1]; + config_popped = True; + XtPopup(shell, XtGrabExclusive); + + config_function = config_fn; + while (config_popped) + XtAppProcessEvent(XtWidgetToApplicationContext(shell), XtIMAll); + + XtSetArg(args[0], XtNstring, &ident_string); + XtGetValues(ident_widget, args, 1); + + return (config_status); +} + +/*ARGSUSED*/ +void +ConfigError(void) +{ + static int first = 1; + + if (first) { + Widget command; + + errcurrent = XtCreateWidget("error", formWidgetClass, + configp, NULL, 0); + (void) XtCreateManagedWidget("label", labelWidgetClass, + errcurrent, NULL, 0); + command = XtCreateManagedWidget("command", commandWidgetClass, + errcurrent, NULL, 0); + XtAddCallback(command, XtNcallback, ErrorCallback, NULL); + + XtRealizeWidget(errcurrent); + } + + oldcurrent = current; + XtChangeManagedSet(¤t, 1, NULL, NULL, &errcurrent, 1); + current = errcurrent; + + XtSetSensitive(ok, False); +} + +/*ARGSUSED*/ +void +ErrorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XtChangeManagedSet(&errcurrent, 1, NULL, NULL, &oldcurrent, 1); + current = oldcurrent; + + XtSetSensitive(ok, True); +} + +/*ARGSUSED*/ +void +BackCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XF86SetupInfo *info = (XF86SetupInfo*)user_data; + int idx = info->lists[info->cur_list].cur_function - 1; + + if (idx >= 0 && info->lists[info->cur_list].num_functions > 0) { + info->lists[info->cur_list].cur_function = idx; + if (idx - 1 == -1) + XtSetSensitive(back, False); + if (!XtIsSensitive(next)) + XtSetSensitive(next, True); + (info->lists[info->cur_list].functions[idx])(info); + } +} + +/*ARGSUSED*/ +void +NextCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XF86SetupInfo *info = (XF86SetupInfo*)user_data; + int idx = info->lists[info->cur_list].cur_function + 1; + + if (idx < info->lists[info->cur_list].num_functions) { + info->lists[info->cur_list].cur_function = idx; + if (idx + 1 == info->lists[info->cur_list].num_functions) + XtSetSensitive(next, False); + if (!XtIsSensitive(back)) + XtSetSensitive(back, True); + (info->lists[info->cur_list].functions[idx])(info); + } +} + +/*ARGSUSED*/ +void +CloseCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XtPopdown(shell); + config_popped = False; + config_status = False; + /* make sure it is sensitive */ + XtSetSensitive(ok, True); + xf86info.lists[xf86info.cur_list].cur_function = 0; +} + +/*ARGSUSED*/ +void +ApplyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + + XtSetArg(args[0], XtNstring, &ident_string); + XtGetValues(ident_widget, args, 1); + + if (config_function == NULL || (*config_function)()) { + XtPopdown(shell); + config_popped = False; + config_status = True; + xf86info.lists[xf86info.cur_list].cur_function = 0; + } + else + ConfigError(); +} + +/*ARGSUSED*/ +void +ConfigCancelAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + CloseCallback(w, NULL, NULL); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/config.h b/xorg-server/hw/xfree86/utils/xorgcfg/config.h new file mode 100644 index 000000000..ea12e8879 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/config.h @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#ifdef HAVE_CONFIG_H +# include "xorg-config.h" +#endif + +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/Xmu/SysUtil.h> +#include <X11/Xos.h> +#include <stdio.h> +#include <stdlib.h> +#include <dirent.h> +#include <string.h> +#ifdef sun +#undef index +#undef rindex +#include <strings.h> +#endif +#include <unistd.h> + +#include <stdarg.h> + +/* Get PATH_MAX */ +#ifndef PATH_MAX +# if defined(_POSIX_SOURCE) +# include <limits.h> +# else +# define _POSIX_SOURCE +# include <limits.h> +# undef _POSIX_SOURCE +# endif +# ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 1024 +# endif +# endif +#endif + +#include <xf86Parser.h> +#include <X11/XKBlib.h> +#include <X11/extensions/XKBgeom.h> +#include <X11/extensions/XKM.h> +#include <X11/extensions/XKBfile.h> +#include <X11/extensions/XKBui.h> +#include <X11/extensions/XKBrules.h> + +#ifndef _xf86cfg_config_h +#define _xf86cfg_config_h + +/* Must match the offset in the xf86info structure at config.c, + * and is used also by interface.c + */ +#define MOUSE 0 +#define KEYBOARD 1 +#define CARD 2 +#define MONITOR 3 +#define SCREEN 4 +#define SERVER 5 + +#define UNUSED 0 +#define USED 1 + +#define CONFIG_LAYOUT 0 +#define CONFIG_SCREEN 1 +#define CONFIG_MODELINE 2 +#define CONFIG_ACCESSX 3 +extern int config_mode; + +#define CONFPATH "%A," "%R," \ + "/etc/X11/%R," "%P/etc/X11/%R," \ + "%E," "%F," \ + "/etc/X11/%F," "%P/etc/X11/%F," \ + "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" +#define USER_CONFPATH "/etc/X11/%S," "%P/etc/X11/%S," \ + "/etc/X11/%G," "%P/etc/X11/%G," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" + +/* + * Types + */ +typedef struct _XF86SetupInfo XF86SetupInfo; +typedef void (*XF86SetupFunction)(XF86SetupInfo*); + +typedef struct _XF86SetupFunctionList { + XF86SetupFunction *functions; + int num_functions; + int cur_function; +} XF86SetupFunctionList; + +struct _XF86SetupInfo { + int num_lists; + int cur_list; + XF86SetupFunctionList *lists; +}; + +typedef Bool (*ConfigCheckFunction)(void); + +typedef struct _xf86cfgDevice xf86cfgDevice; + +struct _xf86cfgDevice { + XtPointer config; + Widget widget; + int type, state, refcount; +}; + +typedef struct { + XF86ConfScreenPtr screen; + Widget widget; + int type, state, refcount; + xf86cfgDevice *card; + xf86cfgDevice *monitor; + short row, column; + XRectangle rect; + short rotate; +} xf86cfgScreen; + +/* this structure is used just to restore + properly the monitors layout in the + screen window configuration. + */ +typedef struct { + XF86ConfLayoutPtr layout; + xf86cfgScreen **screen; + XPoint *position; + int num_layouts; +} xf86cfgLayout; + +/* The vidmode extension usage is controlled by this structure. + * The information is read at startup, and added monitors cannot + * be configured, since they are not attached to a particular screen. + */ +typedef struct _xf86cfgVidMode xf86cfgVidmode; + +typedef struct { + XF86ConfLayoutPtr layout; /* current layout */ + Widget cpu; + xf86cfgLayout **layouts; + Cardinal num_layouts; + xf86cfgScreen **screens; + Cardinal num_screens; + xf86cfgDevice **devices; + Cardinal num_devices; + xf86cfgVidmode **vidmodes; + Cardinal num_vidmodes; +} xf86cfgComputer; + +/* + * Prototypes + */ +void StartConfig(void); +Bool ConfigLoop(ConfigCheckFunction); +void ConfigError(void); +void ChangeScreen(XF86ConfMonitorPtr, XF86ConfMonitorPtr, + XF86ConfDevicePtr, XF86ConfDevicePtr); +void SetTip(xf86cfgDevice*); +Bool startx(void); +void endx(void); +void startaccessx(void); +void ConfigCancelAction(Widget, XEvent*, String*, Cardinal*); +void ExpertConfigureStart(void); +void ExpertConfigureEnd(void); +void ExpertCloseAction(Widget, XEvent*, String*, Cardinal*); +void ExpertCallback(Widget, XtPointer, XtPointer); + +/* + * Initialization + */ +extern Widget toplevel, configp, current, back, next; +extern XtAppContext appcon; +extern XF86SetupInfo xf86info; +extern Widget ident_widget; +extern char *ident_string; +extern XF86ConfigPtr XF86Config; +extern char *XF86Config_path; +extern char *XF86Module_path; +extern char *XFree86_path; +extern char *XF86Font_path; +extern char *XF86RGB_path; +extern char *XFree86Dir; +extern xf86cfgComputer computer; +extern Atom wm_delete_window; +extern Display *DPY; +extern Pixmap menuPixmap; +#ifdef USE_MODULES +extern int nomodules; +#endif + +#endif /* _xf86cfg_config_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/down.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/down.xbm new file mode 100644 index 000000000..742adf202 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/down.xbm @@ -0,0 +1,8 @@ +#define down_width 19 +#define down_height 19 +static unsigned char down_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, + 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, + 0x80, 0x0f, 0x00, 0xfc, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xf0, 0x7f, 0x00, + 0xe0, 0x3f, 0x00, 0xc0, 0x1f, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x07, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/expert.c b/xorg-server/hw/xfree86/utils/xorgcfg/expert.c new file mode 100644 index 000000000..bb6960ce7 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/expert.c @@ -0,0 +1,4839 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#include "xf86config.h" +#include "options.h" +#include "screen.h" +#include "vidmode.h" +#include "monitor-cfg.h" +#include <X11/Shell.h> +#include <X11/CompositeP.h> +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Box.h> +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/Paned.h> +#include <X11/Xaw/Panner.h> +#include <X11/Xaw/Porthole.h> +#include <X11/Xaw/SimpleMenu.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/Toggle.h> +#include <X11/Xaw/Tree.h> +#include <ctype.h> + +/* + * Types + */ +typedef struct _TreeNode TreeNode; +typedef union _TreeData TreeData; +typedef void (*NodeDeleteFunc)(TreeNode*); +typedef void (*NodeUpdateFunc)(TreeNode*); + +union _TreeData { + struct { + Widget text; + } files; + struct { + Widget text; + XF86LoadPtr load; + } module; + struct { + Widget text; + XF86ConfModesPtr modes; + } modes; + struct { + Widget text, value; + XF86ConfModeLinePtr modeline; + } modeline; + struct { + Widget text, vendor, board, busid, driver; + XF86ConfVideoAdaptorPtr video; + } video; + struct { + Widget text; + XF86ConfVideoPortPtr port; + } port; + struct { + Widget text, vendor, model, width, height, hsync, vrefresh, + gammaRed, gammaGreen, gammaBlue; + XF86ConfMonitorPtr monitor; + } monitor; + struct { + Widget menu; + XF86ConfModesLinkPtr modeslink; + } modeslink; + struct { + Widget text, vendor, board, chipset, busid, card, driver, ramdac, + dacSpeed, videoRam, textClockFreq, biosBase, memBase, ioBase, + clockChip, devClock, chipId, chipRev, irq, screen; + XF86ConfDevicePtr device; + } device; + struct { + Widget text, defaultDepth, defaultBpp, defaultFbBpp, + monitor, device; + XF86ConfScreenPtr screen; + } screen; + struct { + Widget menu; + XF86ConfAdaptorLinkPtr adaptorlink; + } adaptorlink; + struct { + Widget viewport, c_virtual, depth, bpp, visual, weight, black, white; + XF86ConfDisplayPtr display; + } display; + struct { + Widget text; + XF86ModePtr mode; + } mode; + struct { + Widget text; + XF86ConfInputPtr input; + } input; + struct { + Widget text; + XF86ConfLayoutPtr layout; + } layout; + struct { + Widget menu, button, scrnum, adjx, adjy; + XF86ConfScreenPtr screen; + XF86ConfAdjacencyPtr adjacency; + } adjacency; + struct { + Widget menu; + XF86ConfInputrefPtr inputref; + } inputref; + struct { + Widget text; + XF86ConfVendorPtr vendor; + } vendor; + struct { + Widget text; + XF86ConfVendSubPtr vendsub; + } vendsub; + struct { + Widget name, group, mode; + XF86ConfDRIPtr dri; + } dri; + struct { + Widget count, size, flags; + XF86ConfBuffersPtr buffers; + } buffers; +}; + +struct _TreeNode { + Widget node, toggle, treeParent; + TreeNode *parent, *child, *next; + TreeData *data; + NodeDeleteFunc destroy; + NodeUpdateFunc update; +}; + +/* + * Prototypes + */ +static Bool ExpertInitialize(void); +static TreeNode *NewNode(TreeNode*, Widget, Widget, Widget, TreeData*); +static void DeleteNode(TreeNode*); +static void DestroyCallback(Widget, XtPointer, XtPointer); +static void PannerCallback(Widget, XtPointer, XtPointer); +static void PortholeCallback(Widget, XtPointer, XtPointer); +static void ToggleCallback(Widget, XtPointer, XtPointer); +static void ToggleNode(TreeNode*, Bool); +static void ToggleNodeRecursive(TreeNode*); +static void OptionsCallback(Widget, XtPointer, XtPointer); +static void RelayoutTree(void); +static void PopdownCallback(Widget, XtPointer, XtPointer); +static void UpdateConfig(TreeNode*); +static void DestroyTree(TreeNode*); + +static void CreateFiles(TreeNode*); +static void CreateFilesField(TreeNode*, char*, char*); +static void UpdateFiles(TreeNode*); + +static void CreateFontPath(TreeNode*, char*); +static Widget CreateFontPathField(TreeNode*, char*, Bool); +static void FontPathChanged(TreeNode*); +static void NewFontPathCallback(Widget, XtPointer, XtPointer); +static void FontPathCallback(Widget, XtPointer, XtPointer); + +static void CreateModulePath(TreeNode*, char*); +static Widget CreateModulePathField(TreeNode*, char*, Bool); +static void ModulePathChanged(TreeNode*); +static void NewModulePathCallback(Widget, XtPointer, XtPointer); + +static void CreateModule(TreeNode*, XF86LoadPtr); +static void CreateModuleField(TreeNode*, Bool); +static void ModuleDestroy(TreeNode*); +static void NewModuleCallback(Widget, XtPointer, XtPointer); + +static void CreateModes(TreeNode*, XF86ConfModesPtr); +static void CreateModesField(TreeNode*, Bool); +static void ModesDestroy(TreeNode*); +static void NewModesCallback(Widget, XtPointer, XtPointer); +static void CreateModesModeLine(TreeNode*, XF86ConfModeLinePtr); +static void ModesModeLineDestroy(TreeNode*); +static void NewModesModeLineCallback(Widget, XtPointer, XtPointer); + +static void CreateModeLineField(TreeNode*, Bool, Bool); +static XF86ConfModeLinePtr ParseModeLine(char*, char*); + +static void CreateVideoAdaptor(TreeNode*, XF86ConfVideoAdaptorPtr); +static void CreateVideoAdaptorField(TreeNode*, Bool); +static void VideoAdaptorDestroy(TreeNode*); +static void NewVideoAdaptorCallback(Widget, XtPointer, XtPointer); +static void VideoAdaptorUpdate(TreeNode*); +static void CreateVideoPort(TreeNode*, XF86ConfVideoPortPtr); +static void CreateVideoPortField(TreeNode*, Bool); +static void VideoPortDestroy(TreeNode*); +static void NewVideoPortCallback(Widget, XtPointer, XtPointer); + +static void CreateMonitor(TreeNode*, XF86ConfMonitorPtr); +static void CreateMonitorField(TreeNode*, Bool); +static void MonitorDestroy(TreeNode*); +static void NewMonitorCallback(Widget, XtPointer, XtPointer); +static void MonitorUpdate(TreeNode*); +static void CreateMonitorModeLine(TreeNode*, XF86ConfModeLinePtr); +static void MonitorModeLineDestroy(TreeNode*); +static void NewMonitorModeLineCallback(Widget, XtPointer, XtPointer); +static void CreateMonitorModes(TreeNode*, XF86ConfModesLinkPtr); +static void CreateMonitorModesField(TreeNode*, Bool); +static void MonitorModesLinkDestroy(TreeNode*); +static void NewMonitorModesCallback(Widget, XtPointer, XtPointer); + +static void CreateDevice(TreeNode*, XF86ConfDevicePtr); +static void CreateDeviceField(TreeNode*, Bool); +static void NewDeviceCallback(Widget, XtPointer, XtPointer); +static void DeviceDestroy(TreeNode*); +static void DeviceUpdate(TreeNode*); + +static void CreateScreen(TreeNode*, XF86ConfScreenPtr); +static void CreateScreenField(TreeNode*, Bool); +static void NewScreenCallback(Widget, XtPointer, XtPointer); +static void ScreenDestroy(TreeNode*); +static void ScreenUpdate(TreeNode*); +static void CreateScreenAdaptor(TreeNode*, XF86ConfAdaptorLinkPtr); +static void CreateScreenAdaptorField(TreeNode*, Bool); +static void NewScreenAdaptorCallback(Widget, XtPointer, XtPointer); +static void ScreenAdaptorDestroy(TreeNode*); +static void CreateScreenDisplay(TreeNode*, XF86ConfDisplayPtr); +static void CreateScreenDisplayField(TreeNode*, Bool); +static void NewScreenDisplayCallback(Widget, XtPointer, XtPointer); +static void ScreenDisplayDestroy(TreeNode*); +static void ScreenDisplayUpdate(TreeNode*); +static void CreateDisplayMode(TreeNode*, XF86ModePtr); +static void CreateDisplayModeField(TreeNode*, Bool); +static void NewDisplayModeCallback(Widget, XtPointer, XtPointer); +static void DisplayModeDestroy(TreeNode*); + +static void CreateInput(TreeNode*, XF86ConfInputPtr); +static void CreateInputField(TreeNode*, Bool); +static void InputDestroy(TreeNode*); +static void NewInputCallback(Widget, XtPointer, XtPointer); +static void InputUpdate(TreeNode*); + +static void CreateLayout(TreeNode*, XF86ConfLayoutPtr); +static void CreateLayoutField(TreeNode*, Bool); +static void LayoutDestroy(TreeNode*); +static void NewLayoutCallback(Widget, XtPointer, XtPointer); +static void CreateAdjacency(TreeNode*, XF86ConfAdjacencyPtr); +static void CreateAdjacencyField(TreeNode*, Bool); +static void AdjacencyDestroy(TreeNode*); +static void NewAdjacencyCallback(Widget, XtPointer, XtPointer); +static void AdjacencyMenuCallback(Widget, XtPointer, XtPointer); +static void AdjacencyToggleCallback(Widget, XtPointer, XtPointer); +static void CreateInputref(TreeNode*, XF86ConfInputrefPtr); +static void CreateInputrefField(TreeNode*, Bool); +static void InputrefDestroy(TreeNode*); +static void NewInputrefCallback(Widget, XtPointer, XtPointer); + +static void CreateVendor(TreeNode*, XF86ConfVendorPtr); +static void CreateVendorField(TreeNode*, Bool); +static void VendorDestroy(TreeNode*); +static void NewVendorCallback(Widget, XtPointer, XtPointer); +static void CreateVendorSub(TreeNode*, XF86ConfVendSubPtr); +static void CreateVendorSubField(TreeNode*, Bool); +static void NewVendorSubCallback(Widget, XtPointer, XtPointer); +static void VendorSubDestroy(TreeNode*); +static void VendorSubUpdate(TreeNode*); + +static void CreateDRI(TreeNode*, XF86ConfDRIPtr); +static void CreateDRIField(TreeNode*); +static void DRIUpdate(TreeNode*); + +static void CreateBuffers(TreeNode*, XF86ConfBuffersPtr); +static void CreateBuffersField(TreeNode*, Bool); +static void BuffersDestroy(TreeNode*); +static void NewBuffersCallback(Widget, XtPointer, XtPointer); +static void BuffersUpdate(TreeNode*); + +extern void RemoveDeviceCallback(Widget, XtPointer, XtPointer); + +/* interface.c */ +extern void InitializeDevices(void); +extern void SelectLayoutCallback(Widget, XtPointer, XtPointer); +extern void UpdateMenuDeviceList(int); +extern void SetConfigModeCallback(Widget, XtPointer, XtPointer); +extern void DefaultLayoutCallback(Widget, XtPointer, XtPointer); +extern void RemoveLayoutCallback(Widget, XtPointer, XtPointer); + +/* + * Initialization + */ +static Widget shell, expert, tree, panner; +extern Widget work, optionsShell, config, layoutp, topMenu; +extern xf86cfgDevice cpu_device; +static TreeNode *mainNode, *monitorTree, *screenTree, *layoutTree; + +/* + * Implementation + */ +void +ExpertConfigureStart(void) +{ + ExpertInitialize(); + + XtPopup(shell, XtGrabExclusive); + if (optionsShell == NULL) + CreateOptionsShell(); + XtVaSetValues(optionsShell, XtNtransientFor, shell, NULL); +} + +void +ExpertConfigureEnd(void) +{ + int i, save_config_mode = config_mode; + Widget sme, layopt, layoutsme = NULL; + XF86ConfLayoutPtr lay; + + XtVaSetValues(optionsShell, XtNtransientFor, toplevel, NULL); + XtPopdown(shell); + + /* Need to do this to avoid all code elsewhere needing to update the + * "expert" widget tree + */ + UpdateConfig(mainNode); + DestroyTree(mainNode); + XtDestroyWidget(shell); + expert = NULL; + + if (save_config_mode != CONFIG_LAYOUT) + SetConfigModeCallback(topMenu, (XtPointer)CONFIG_LAYOUT, NULL); + + /* Reset everything as the "expert" interface can do almost anything + * to the configuration. + */ + for (i = 0; i < computer.num_screens; i++) { + XtDestroyWidget(computer.screens[i]->widget); + XtFree((XtPointer)computer.screens[i]); + } + XtFree((XtPointer)computer.screens); + computer.screens = NULL; + computer.num_screens = 0; + + for (i = 0; i < computer.num_devices; i++) { + XtDestroyWidget(computer.devices[i]->widget); + XtFree((XtPointer)computer.devices[i]); + } + XtFree((XtPointer)computer.devices); + computer.devices = NULL; + computer.num_devices = 0; + + for (i = 0; i < computer.num_layouts; i++) { + XtFree((XtPointer)computer.layouts[i]->position); + XtFree((XtPointer)computer.layouts[i]); + } + XtFree((XtPointer)computer.layouts); + computer.layouts = NULL; + computer.num_layouts = 0; + + for (i = 0; i < computer.num_vidmodes; i++) + XtFree((XtPointer)computer.vidmodes[i]); + XtFree((XtPointer)computer.vidmodes); + computer.vidmodes = NULL; + computer.num_vidmodes = 0; + + /* Reinitialize devices/screens */ + InitializeDevices(); + UpdateMenuDeviceList(MOUSE); + UpdateMenuDeviceList(KEYBOARD); + UpdateMenuDeviceList(CARD); + UpdateMenuDeviceList(MONITOR); + + /* Update layout menu */ + /* first entry is "New server layout" */ + for (i = 1; i < ((CompositeWidget)layoutp)->composite.num_children; i++) + XtDestroyWidget(((CompositeWidget)layoutp)->composite.children[i]); + for (i = 0; i < layoutp->core.num_popups; i++) + XtDestroyWidget(layoutp->core.popup_list[i]); + lay = XF86Config->conf_layout_lst; + while (lay != NULL) { + sme = XtVaCreateManagedWidget("sme", smeBSBObjectClass, + layoutp, + XtNlabel, lay->lay_identifier, + XtNmenuName, lay->lay_identifier, + XtNleftBitmap, menuPixmap, + NULL); + XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay); + if (layoutsme == NULL) + layoutsme = sme; + layopt = XtCreatePopupShell(lay->lay_identifier, simpleMenuWidgetClass, + layoutp, NULL, 0); + sme = XtCreateManagedWidget("default", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL); + sme = XtCreateManagedWidget("remove", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL); + XtRealizeWidget(layopt); + + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + computer.layout = NULL; + SelectLayoutCallback(layoutsme, + XF86Config->conf_layout_lst, NULL); + + + if (XF86Config->conf_flags && XF86Config->conf_flags->flg_option_lst) + SetTip(&cpu_device); + for (i = 0; i < computer.num_devices; i++) + SetTip(computer.devices[i]); + + /* Reinitialize vidmodes */ + InitializeVidmodes(); + + if (save_config_mode != CONFIG_LAYOUT) + SetConfigModeCallback(topMenu, (XtPointer)(long)save_config_mode, NULL); +} + +/*ARGSUSED*/ +void +ExpertCloseAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + ExpertConfigureEnd(); +} + +/*ARGSUSED*/ +void +ExpertCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + ExpertConfigureStart(); +} + +/*ARGSUSED*/ +static void +PopdownCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + ExpertConfigureEnd(); +} + +/* Files */ +static void +CreateFiles(TreeNode *files) +{ + XF86ConfFilesPtr file = XF86Config->conf_files; + TreeNode *node, *fontpath, *modulepath; + Widget w; + char *value; + + value = file->file_logfile ? file->file_logfile : ""; + node = NewNode(files, NULL, NULL, files->node, + (TreeData*)XtCalloc(1, sizeof(TreeData))); + CreateFilesField(node, "LogFile", value); + files->child = node; + files->update = UpdateFiles; + + w = XtVaCreateManagedWidget("ModulePath", toggleWidgetClass, tree, + XtNtreeParent, files->node, NULL); + node->next = modulepath = NewNode(files, w, w, files->node, NULL); + node = node->next; + CreateModulePath(modulepath, NULL); + + w = XtVaCreateManagedWidget("FontPath", toggleWidgetClass, tree, + XtNtreeParent, files->node, NULL); + node->next = fontpath = NewNode(files, w, w, files->node, NULL); + node = node->next; + CreateFontPath(fontpath, NULL); +} + +static void +CreateFilesField(TreeNode *node, char *name, char *value) +{ + Widget box, text; + + box = XtVaCreateManagedWidget(name, boxWidgetClass, tree, + XtNtreeParent, node->node, NULL); + node->node = box; + (void) XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, name, NULL); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, value, + NULL); + node->data->files.text = text; +} + +static void +UpdateFiles(TreeNode *files) +{ + char *str; + + /* LogFile */ + files = files->child; + XtVaGetValues(files->data->files.text, XtNstring, &str, NULL); + XtFree(XF86Config->conf_files->file_logfile); + if (*str) + XF86Config->conf_files->file_logfile = XtNewString(str); + else + XF86Config->conf_files->file_logfile = NULL; +} + +/* FontPath */ +/* Don't need to set the update tree field, as it is already set + * as the destroy field */ +static void +CreateFontPath(TreeNode *fontpath, char *path) +{ + TreeNode *prev = NULL, *node; + + if (path == NULL) { + if (XF86Font_path) { + path = XtNewString(XF86Font_path); + if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath) { + XtFree(XF86Config->conf_files->file_fontpath); + XF86Config->conf_files->file_fontpath = XtNewString(path); + } + } + else if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath) + path = XtNewString(XF86Config->conf_files->file_fontpath); + } + else { + path = XtNewString(path); + if ((prev = fontpath->child) != NULL) + while (prev->next) + prev = prev->next; + } + + if (path) { + char *s; + + for (s = strtok(path, ","); s != NULL; s = strtok(NULL, ",")) { + node = NewNode(fontpath, NULL, NULL, fontpath->node, NULL); + node->destroy = FontPathChanged; + (void) CreateFontPathField(node, s, False); + if (fontpath->child == NULL) + fontpath->child = node; + else + prev->next = node; + prev = node; + } + XtFree(path); + } + + node = NewNode(fontpath, NULL, NULL, fontpath->node, NULL); + (void) CreateFontPathField(node, "", True); + if (fontpath->child == NULL) + fontpath->child = node; + else + prev->next = node; +} + +static Widget +CreateFontPathField(TreeNode *fontpath, char *value, Bool addnew) +{ + Widget box, command, text; + TreeData *data; + + box = XtVaCreateWidget("fontpath", formWidgetClass, tree, + XtNtreeParent, fontpath->treeParent, NULL); + fontpath->node = box; + if (!addnew) { + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, + (XtPointer)fontpath); + command = XtCreateManagedWidget("up", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, FontPathCallback, + (XtPointer)fontpath); + command = XtCreateManagedWidget("down", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, FontPathCallback, + (XtPointer)fontpath); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewFontPathCallback, + (XtPointer)fontpath); + text = XtVaCreateManagedWidget("valueNew", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->files.text = text; + fontpath->data = data; + + if (fontpath->treeParent && XtIsRealized(fontpath->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); + + return (box); +} + +static void +FontPathChanged(TreeNode *node) +{ + TreeNode *parent = node->parent; + char *fontpath = NULL, *str; + Arg args[1]; + int pos = 0, len; + + /* last node is the "new" */ + for (node = parent->child; node->next != NULL; node = node->next) { + if (pos) + fontpath[pos++] = ','; + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + len = strlen(str) + 2; + fontpath = XtRealloc(fontpath, pos + len); + strcpy(fontpath + pos, str); + pos += len - 2; + } + + if (XF86Config->conf_files->file_fontpath) + XtFree(XF86Config->conf_files->file_fontpath); + XF86Config->conf_files->file_fontpath = fontpath; +} + +static void +NewFontPathCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *fontpath, *node = (TreeNode*)user_data; + Arg args[1]; + char *str; + + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + if (*str == '\0') + return; + + fontpath = node->parent; + DeleteNode(node); + CreateFontPath(fontpath, str); + + FontPathChanged(fontpath->child); + RelayoutTree(); +} + +/*ARGSUSED*/ +static void +FontPathCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node, *fontpath = (TreeNode*)user_data; + char *t1, *t2; + Widget w1, w2; + + parent = fontpath->parent; + node = parent->child; + if (!node->next->next) + return; + if (strcmp(XtName(w), "up") == 0) { + if (node == fontpath) + while (node->next->next) + node = node->next; + else + while (node && node->next != fontpath) + node = node->next; + } + else { + if (fontpath->next->next) + node = fontpath->next; + /* else is already correct */ + } + + w1 = node->data->files.text; + w2 = fontpath->data->files.text; + + XtVaGetValues(w1, XtNstring, &t1, NULL); + XtVaGetValues(w2, XtNstring, &t2, NULL); + t1 = XtNewString(t1); + XtVaSetValues(w1, XtNstring, t2, NULL); + XtVaSetValues(w2, XtNstring, t1, NULL); + XtFree(t1); +} + + +/* ModulePath */ +/* Don't need to set the update tree field, as it is already set + * as the destroy field */ +static void +CreateModulePath(TreeNode *modulepath, char *path) +{ + TreeNode *prev = NULL, *node; + + if (path == NULL) { + if (XF86Module_path) { + path = XtNewString(XF86Module_path); + if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath) { + XtFree(XF86Config->conf_files->file_modulepath); + XF86Config->conf_files->file_modulepath = XtNewString(path); + } + } + else if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath) + path = XtNewString(XF86Config->conf_files->file_modulepath); + } + else { + path = XtNewString(path); + if ((prev = modulepath->child) != NULL) + while (prev->next) + prev = prev->next; + } + + if (path) { + char *s; + + for (s = strtok(path, ","); s != NULL; s = strtok(NULL, ",")) { + node = NewNode(modulepath, NULL, NULL, modulepath->node, NULL); + node->destroy = ModulePathChanged; + (void) CreateModulePathField(node, s, False); + if (modulepath->child == NULL) + modulepath->child = node; + else + prev->next = node; + prev = node; + } + XtFree(path); + } + + node = NewNode(modulepath, NULL, NULL, modulepath->node, NULL); + (void) CreateModulePathField(node, "", True); + if (modulepath->child == NULL) + modulepath->child = node; + else + prev->next = node; +} + +static Widget +CreateModulePathField(TreeNode *modulepath, char *value, Bool addnew) +{ + Widget box, command, text; + TreeData *data; + + box = XtVaCreateWidget("modulepath", formWidgetClass, tree, + XtNtreeParent, modulepath->treeParent, NULL); + modulepath->node = box; + if (!addnew) { + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, + (XtPointer)modulepath); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewModulePathCallback, + (XtPointer)modulepath); + text = XtVaCreateManagedWidget("valueNew", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->files.text = text; + modulepath->data = data; + + if (modulepath->treeParent && XtIsRealized(modulepath->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); + + return (box); +} + +static void +ModulePathChanged(TreeNode *node) +{ + TreeNode *parent = node->parent; + char *modulepath = NULL, *str; + Arg args[1]; + int pos = 0, len; + + /* last node is the "new" */ + for (node = parent->child; node->next != NULL; node = node->next) { + if (pos) + modulepath[pos++] = ','; + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + len = strlen(str) + 2; + modulepath = XtRealloc(modulepath, pos + len); + strcpy(modulepath + pos, str); + pos += len - 2; + } + + if (XF86Config->conf_files->file_modulepath) + XtFree(XF86Config->conf_files->file_modulepath); + XF86Config->conf_files->file_modulepath = modulepath; +} + +static void +NewModulePathCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *modulepath, *node = (TreeNode*)user_data; + Arg args[1]; + char *str; + + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + if (*str == '\0') + return; + + modulepath = node->parent; + DeleteNode(node); + CreateModulePath(modulepath, str); + + ModulePathChanged(modulepath->child); + RelayoutTree(); +} + +/* Module */ +static void +CreateModule(TreeNode *module, XF86LoadPtr load) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = module->child) != NULL) + while (prev->next) + prev = prev->next; + + while (load) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->module.load = load; + node = NewNode(module, NULL, NULL, module->node, data); + node->destroy = ModuleDestroy; + CreateModuleField(node, False); + if (module->child == NULL) + module->child = node; + else + prev->next = node; + prev = node; + load = (XF86LoadPtr)(load->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(module, NULL, NULL, module->node, data); + CreateModuleField(node, True); + if (module->child == NULL) + module->child = node; + else + prev->next = node; +} + +static void +CreateModuleField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("module", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86LoadPtr load = node->data->module.load; + + options = &(load->load_opt); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, load->load_name, NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewModuleCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->module.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +ModuleDestroy(TreeNode *node) +{ + if (node->data->module.load) + xf86removeModule(XF86Config, node->data->module.load); +} + +/*ARGSUSED*/ +static void +NewModuleCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *module, *node = (TreeNode*)user_data; + XF86LoadPtr load; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->module.text, args, 1); + if (*label == '\0') + return; + + module = node->parent; + DeleteNode(node); + load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec)); + load->load_name = XtNewString(label); + XF86Config->conf_modules->mod_load_lst = + xf86addModule(XF86Config->conf_modules->mod_load_lst, load); + + CreateModule(module, load); + RelayoutTree(); +} + +/* Modes */ +static void +CreateModes(TreeNode *parent, XF86ConfModesPtr modes) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modes) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modes.modes = modes; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ModesDestroy; + CreateModesField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + + modes = (XF86ConfModesPtr)(modes->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateModesField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateModesField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("modes", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86ConfModesPtr modes = node->data->modes.modes; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("mode", toggleWidgetClass, box, + XtNlabel, modes->modes_identifier, + XtNstate, True, + NULL); + node->toggle = label; + XtAddCallback(label, XtNcallback, ToggleCallback, (XtPointer)node); + CreateModesModeLine(node, node->data->modes.modes->mon_modeline_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewModesCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->modes.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +ModesDestroy(TreeNode *node) +{ + if (node->data->modes.modes) { + int i; + TreeNode *mon = monitorTree->child; + + /* last one is the "new" entry */ + while (mon && mon->next) { + /* UseModes is the second entry */ + TreeNode *mod = mon->child->next->child; + CompositeWidget composite; + + while (mod && mod->next) { + TreeNode *next = mod->next; + + if (mod && strcmp(mod->data->modeslink.modeslink->ml_modes_str, + node->data->modes.modes->modes_identifier) == 0) + /* Needs to do string comparison because may be deleting + * a "test" Modes section, with no Modelines. + */ + DeleteNode(mod); + mod = next; + } + composite = (CompositeWidget)mod->data->modeslink.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->modes.modes->modes_identifier) == 0) + XtDestroyWidget(composite->composite.children[i]); + + mon = mon->next; + } + + xf86removeModes(XF86Config, node->data->modes.modes); + } +} + +/*ARGSUSED*/ +static void +NewModesCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModesPtr modes; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->modes.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + modes = (XF86ConfModesPtr)XtCalloc(1, sizeof(XF86ConfModesRec)); + modes->modes_identifier = XtNewString(label); + XF86Config->conf_modes_lst = + xf86addModes(XF86Config->conf_modes_lst, modes); + + { + TreeNode *mon = monitorTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (mon && mon->next) { + /* UseModes is the second entry */ + TreeNode *mod = mon->child->next->child; + + while (mod && mod->next) + mod = mod->next; + + sme = XtCreateManagedWidget(modes->modes_identifier, + smeBSBObjectClass, + mod->data->modeslink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewMonitorModesCallback, + (XtPointer)mod); + + mon = mon->next; + } + } + + CreateModes(parent, modes); + RelayoutTree(); +} + +static void +CreateModesModeLine(TreeNode *parent, XF86ConfModeLinePtr modeline) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modeline) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modeline.modeline = modeline; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ModesModeLineDestroy; + CreateModeLineField(node, False, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + modeline = (XF86ConfModeLinePtr)(modeline->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateModeLineField(node, True, False); +} + +/* This function should allow creating modelines for the + Mode and Monitor section */ +static void +CreateModeLineField(TreeNode *node, Bool addnew, Bool monitor) +{ + Widget box, command; + char buf[512], tmp[32]; + + box = XtVaCreateWidget("modeline", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86ConfModeLinePtr mod = node->data->modeline.modeline; + + command = XtCreateManagedWidget("remove", commandWidgetClass, + box, NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, mod->ml_identifier, NULL); + + XmuSnprintf(buf, sizeof(buf), "%g %d %d %d %d %d %d %d %d", + mod->ml_clock / 1000., mod->ml_hdisplay, mod->ml_hsyncstart, + mod->ml_hsyncend, mod->ml_htotal, mod->ml_vdisplay, + mod->ml_vsyncstart, mod->ml_vsyncend, mod->ml_vtotal); + if (mod->ml_flags & XF86CONF_INTERLACE) + strcat(buf, " interlace"); + if (mod->ml_flags & XF86CONF_PHSYNC) + strcat(buf, " +hsync"); + if (mod->ml_flags & XF86CONF_NHSYNC) + strcat(buf, " -hsync"); + if (mod->ml_flags & XF86CONF_PVSYNC) + strcat(buf, " +vsync"); + if (mod->ml_flags & XF86CONF_NVSYNC) + strcat(buf, " -vsync"); + if (mod->ml_flags & XF86CONF_CSYNC) + strcat(buf, " composite"); + if (mod->ml_flags & XF86CONF_PCSYNC) + strcat(buf, " +csync"); + if (mod->ml_flags & XF86CONF_NCSYNC) + strcat(buf, " -csync"); + if (mod->ml_flags & XF86CONF_DBLSCAN) + strcat(buf, " doublescan"); + if (mod->ml_flags & XF86CONF_BCAST) + strcat(buf, " bcast"); + if (mod->ml_flags & XF86CONF_HSKEW) { + XmuSnprintf(tmp, sizeof(tmp), " hskew %d", mod->ml_hskew); + strcat(buf, tmp); + } + if (mod->ml_flags & XF86CONF_VSCAN) { + XmuSnprintf(tmp, sizeof(tmp), " vscan %d", mod->ml_vscan); + strcat(buf, tmp); + } + if (mod->ml_flags & XF86CONF_CUSTOM) + strcat(buf, " custom"); + node->data->modeline.value = + XtVaCreateManagedWidget("modeline", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + } + else { + *buf = '\0'; + command = XtCreateManagedWidget("new", commandWidgetClass, + box, NULL, 0); + XtAddCallback(command, XtNcallback, monitor ? + NewMonitorModeLineCallback : NewModesModeLineCallback, + (XtPointer)node); + node->data->modeline.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL); + node->data->modeline.value = + XtVaCreateManagedWidget("modelineNew", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +ModesModeLineDestroy(TreeNode *node) +{ + if (node->data->modeline.modeline) + xf86removeModesModeLine(node->parent->data->modes.modes, + node->data->modeline.modeline); +} + +/*ARGSUSED*/ +static void +NewModesModeLineCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModeLinePtr modeline; + Arg args[1]; + char *ident, *value; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->modeline.text, args, 1); + XtSetArg(args[0], XtNstring, &value); + XtGetValues(node->data->modeline.value, args, 1); + if (*ident == '\0' || *value == '\0') + return; + + parent = node->parent; + DeleteNode(node); + modeline = ParseModeLine(ident, value); + parent->data->modes.modes->mon_modeline_lst = + xf86addModeLine(parent->data->modes.modes->mon_modeline_lst, modeline); + + CreateModesModeLine(parent, modeline); + RelayoutTree(); +} + +static XF86ConfModeLinePtr +ParseModeLine(char *identifier, char *modeline) +{ + XF86ConfModeLinePtr ml = (XF86ConfModeLinePtr) + XtCalloc(1, sizeof(XF86ConfModeLineRec)); + char *s, *ptr = modeline; + + /* Identifier */ + ml->ml_identifier = XtNewString(identifier); + + ml->ml_clock = (int)(strtod(ptr, &ptr) * 1000.0 + 0.5); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_hdisplay = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_hsyncstart = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_hsyncend = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_htotal = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vdisplay = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vsyncstart = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vsyncend = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vtotal = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + s = ptr; + while (*s) { + *s = tolower(*s); + ++s; + } + s = ptr; + + while (*ptr) { + while (*s && isspace(*s)) + s++; + ptr = s; + while (*s && !isspace(*s)) + s++; + + if (s != ptr) { + Bool done = *s == '\0'; + + *s = '\0'; + if (strcmp(ptr, "interlace") == 0) + ml->ml_flags |= XF86CONF_INTERLACE; + else if (strcmp(ptr, "+hsync") == 0) + ml->ml_flags |= XF86CONF_PHSYNC; + else if (strcmp(ptr, "-hsync") == 0) + ml->ml_flags |= XF86CONF_NHSYNC; + else if (strcmp(ptr, "+vsync") == 0) + ml->ml_flags |= XF86CONF_PVSYNC; + else if (strcmp(ptr, "-vsync") == 0) + ml->ml_flags |= XF86CONF_NVSYNC; + else if (strcmp(ptr, "composite") == 0) + ml->ml_flags |= XF86CONF_CSYNC; + else if (strcmp(ptr, "+csync") == 0) + ml->ml_flags |= XF86CONF_PCSYNC; + else if (strcmp(ptr, "-csync") == 0) + ml->ml_flags |= XF86CONF_NCSYNC; + else if (strcmp(ptr, "doublescan") == 0) + ml->ml_flags |= XF86CONF_DBLSCAN; + else if (strcmp(ptr, "bcast") == 0) + ml->ml_flags |= XF86CONF_BCAST; + else if (strcmp(ptr, "hskew") == 0) { + ++s; + while (*s && isspace(*s)) + ++s; + ptr = s; + while (*s && !isspace(*s)) + ++s; + if (ptr != s) { + ml->ml_hskew = strtol(ptr, &s, 10); + ml->ml_flags |= XF86CONF_HSKEW; + --s; + } + } + else if (strcmp(ptr, "vscan") == 0) { + ++s; + while (*s && isspace(*s)) + ++s; + ptr = s; + while (*s && !isspace(*s)) + ++s; + if (ptr != s) { + ml->ml_vscan = strtol(ptr, &s, 10); + ml->ml_flags |= XF86CONF_VSCAN; + --s; + } + } + else if (strcmp(ptr, "custom") == 0) + ml->ml_flags |= XF86CONF_CUSTOM; + ++s; + if (done) + break; + ptr = s; + } + } + + return (ml); +} + +/* VideoAdpator */ +static void +CreateVideoAdaptor(TreeNode *parent, XF86ConfVideoAdaptorPtr video) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (video) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->video.video = video; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VideoAdaptorDestroy; + node->update = VideoAdaptorUpdate; + CreateVideoAdaptorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + + video = (XF86ConfVideoAdaptorPtr)(video->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVideoAdaptorField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVideoAdaptorField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("video", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + char *str; + TreeNode *port; + XF86ConfVideoAdaptorPtr video = node->data->video.video; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, + (XtPointer)&(video->va_option_lst)); + label = XtVaCreateManagedWidget("adaptor", labelWidgetClass, box, + XtNlabel, video->va_identifier, + NULL); + + XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0); + str = video->va_vendor ? video->va_vendor : ""; + node->data->video.vendor = + XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("boardL", labelWidgetClass, box, NULL, 0); + str = video->va_board ? video->va_board : ""; + node->data->video.board = + XtVaCreateManagedWidget("board", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("busidL", labelWidgetClass, box, NULL, 0); + str = video->va_busid ? video->va_busid : ""; + node->data->video.busid = + XtVaCreateManagedWidget("busid", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0); + str = video->va_driver ? video->va_driver : ""; + node->data->video.driver = + XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + label = XtVaCreateManagedWidget("VideoPort", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, + NULL); + port = NewNode(node, label, label, node->node, NULL); + node->child = port; + CreateVideoPort(port, video->va_port_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVideoAdaptorCallback, + (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->video.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +VideoAdaptorDestroy(TreeNode *node) +{ + if (node->data->video.video) { + int i; + TreeNode *scrn = screenTree->child; + + /* last one is the "new" entry */ + while (scrn && scrn->next) { + /* VideoAdator is the first entry */ + TreeNode *ad = scrn->child->child; + CompositeWidget composite; + + while (ad && ad->next) { + TreeNode *next = ad->next; + + if (ad && strcmp(ad->data->adaptorlink.adaptorlink->al_adaptor_str, + node->data->video.video->va_identifier) == 0) + DeleteNode(ad); + ad = next; + } + composite = (CompositeWidget)ad->data->adaptorlink.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->video.video->va_identifier) == 0) + XtDestroyWidget(composite->composite.children[i]); + + scrn = scrn->next; + } + + xf86removeVideoAdaptor(XF86Config, node->data->video.video); + } +} + +/*ARGSUSED*/ +static void +NewVideoAdaptorCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfVideoAdaptorPtr video; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->video.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + video = (XF86ConfVideoAdaptorPtr) + XtCalloc(1, sizeof(XF86ConfVideoAdaptorRec)); + video->va_identifier = XtNewString(label); + XF86Config->conf_videoadaptor_lst = + xf86addVideoAdaptor(XF86Config->conf_videoadaptor_lst, video); + + { + TreeNode *scrn = screenTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (scrn && scrn->next) { + /* VideoAdaptor is the first entry */ + TreeNode *ad = scrn->child->child; + + while (ad && ad->next) + ad = ad->next; + + sme = XtCreateManagedWidget(video->va_identifier, + smeBSBObjectClass, + ad->data->adaptorlink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewScreenAdaptorCallback, + (XtPointer)ad); + + scrn = scrn->next; + } + } + + CreateVideoAdaptor(parent, video); + RelayoutTree(); +} + +static void +VideoAdaptorUpdate(TreeNode *node) +{ + char *str; + + /* vendor */ + XtVaGetValues(node->data->video.vendor, XtNstring, &str, NULL); + XtFree(node->data->video.video->va_vendor); + if (*str) + node->data->video.video->va_vendor = XtNewString(str); + else + node->data->video.video->va_vendor = NULL; + + /* board */ + XtVaGetValues(node->data->video.board, XtNstring, &str, NULL); + XtFree(node->data->video.video->va_board); + if (*str) + node->data->video.video->va_board = XtNewString(str); + else + node->data->video.video->va_board = NULL; + + /* busid */ + XtVaGetValues(node->data->video.busid, XtNstring, &str, NULL); + XtFree(node->data->video.video->va_busid); + if (*str) + node->data->video.video->va_busid = XtNewString(str); + else + node->data->video.video->va_busid = NULL; + + /* driver */ + XtVaGetValues(node->data->video.driver, XtNstring, &str, NULL); + XtFree(node->data->video.video->va_driver); + if (*str) + node->data->video.video->va_driver = XtNewString(str); + else + node->data->video.video->va_driver = NULL; +} + +static void +CreateVideoPort(TreeNode *parent, XF86ConfVideoPortPtr port) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (port) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->port.port = port; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VideoPortDestroy; + CreateVideoPortField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + port = (XF86ConfVideoPortPtr)(port->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVideoPortField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVideoPortField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("port", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86ConfVideoPortPtr port = node->data->port.port; + + options = &(port->vp_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, port->vp_identifier, NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVideoPortCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->port.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +VideoPortDestroy(TreeNode *node) +{ + if (node->data->port.port) + xf86removeVideoPort(node->parent->parent->data->video.video, + node->data->port.port); +} + +/*ARGSUSED*/ +static void +NewVideoPortCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *video, *node = (TreeNode*)user_data; + XF86ConfVideoPortPtr port; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->port.text, args, 1); + if (*label == '\0') + return; + + video = node->parent->parent; + DeleteNode(node); + port = (XF86ConfVideoPortPtr)XtCalloc(1, sizeof(XF86ConfVideoPortRec)); + port->vp_identifier = XtNewString(label); + video->data->video.video->va_port_lst = + xf86addVideoPort(video->data->video.video->va_port_lst, port); + + CreateVideoPort(video, port); + RelayoutTree(); +} + +/* Monitor */ +static void +CreateMonitor(TreeNode *parent, XF86ConfMonitorPtr mon) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (mon) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->monitor.monitor = mon; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = MonitorDestroy; + node->update = MonitorUpdate; + CreateMonitorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + mon = (XF86ConfMonitorPtr)(mon->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateMonitorField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateMonitorField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("monitor", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + char *str, buf[256]; + XF86OptionPtr *options; + XF86ConfMonitorPtr mon = node->data->monitor.monitor; + Widget useModes; + TreeNode *modeline, *modes, *prev; + + options = &(mon->mon_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, mon->mon_identifier, NULL); + + XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0); + str = mon->mon_vendor ? mon->mon_vendor : ""; + node->data->monitor.vendor = + XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("modelnameL", labelWidgetClass, box, NULL, 0); + str = mon->mon_modelname ? mon->mon_modelname : ""; + node->data->monitor.model = + XtVaCreateManagedWidget("modelname", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("widthL", labelWidgetClass, box, NULL, 0); + if (mon->mon_width) + XmuSnprintf(buf, sizeof(buf), "%d", mon->mon_width); + else + *buf = '\0'; + node->data->monitor.width = + XtVaCreateManagedWidget("width", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("heightL", labelWidgetClass, box, NULL, 0); + if (mon->mon_height) + XmuSnprintf(buf, sizeof(buf), "%d", mon->mon_height); + else + *buf = '\0'; + node->data->monitor.height = + XtVaCreateManagedWidget("height", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("hsyncL", labelWidgetClass, box, NULL, 0); + if (mon->mon_n_hsync > 0) + parser_range_to_string(buf, &(mon->mon_hsync[0]), + mon->mon_n_hsync); + else + *buf = '\0'; + node->data->monitor.hsync = + XtVaCreateManagedWidget("hsync", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("vrefreshL", labelWidgetClass, box, NULL, 0); + if (mon->mon_n_vrefresh > 0) + parser_range_to_string(buf, &(mon->mon_vrefresh[0]), + mon->mon_n_vrefresh); + else + *buf = '\0'; + node->data->monitor.vrefresh = + XtVaCreateManagedWidget("vrefresh", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("gammaRedL", labelWidgetClass, box, NULL, 0); + if (mon->mon_gamma_red) + XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_red); + else + *buf = '\0'; + node->data->monitor.gammaRed = + XtVaCreateManagedWidget("gammaRed", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("gammaGreenL", labelWidgetClass, box, NULL, 0); + if (mon->mon_gamma_green) + XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_green); + else + *buf = '\0'; + node->data->monitor.gammaGreen = + XtVaCreateManagedWidget("gammaGreen", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("gammaBlueL", labelWidgetClass, box, NULL, 0); + if (mon->mon_gamma_blue) + XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_blue); + else + *buf = '\0'; + node->data->monitor.gammaBlue = + XtVaCreateManagedWidget("gammaBlue", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + if ((prev = node->child) != NULL) + while (prev->next) + prev = prev->next; + command = XtVaCreateManagedWidget("ModeLine", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, NULL); + modeline = NewNode(node, command, command, node->node, NULL); + CreateMonitorModeLine(modeline, + node->data->monitor.monitor->mon_modeline_lst); + if (prev == NULL) + prev = node->child = modeline; + else { + prev->next = modeline; + prev = prev->next; + } + + useModes = XtVaCreateManagedWidget("UseModes", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, NULL); + prev->next = modes = NewNode(node, useModes, useModes, node->node, NULL); + CreateMonitorModes(modes, + node->data->monitor.monitor->mon_modes_sect_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewMonitorCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->monitor.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +MonitorDestroy(TreeNode *node) +{ + int i; + TreeNode *sc = screenTree; + + for (i = 0; i < computer.num_devices; i++) + if ((XF86ConfMonitorPtr)(computer.devices[i]->config) == + node->data->monitor.monitor) { + config = computer.devices[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + + if (sc) { + TreeNode *prev; + + sc = prev = sc->child; + while (sc->next) { + TreeNode *next = sc->next; + + if (sc->data->screen.screen->scrn_monitor == + node->data->monitor.monitor) { + XtDestroyWidget(sc->node); + + if (sc->child) + DestroyTree(sc->child); + if (sc->data) + XtFree((XtPointer)sc->data); + XtFree((XtPointer)sc); + + if (sc == screenTree->child) + sc = prev = next = screenTree->child = next; + else + prev->next = sc = next; + continue; + } + prev = sc; + sc = next; + } + } +} + +static void +NewMonitorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfMonitorPtr mon; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->monitor.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + mon = (XF86ConfMonitorPtr)XtCalloc(1, sizeof(XF86ConfMonitorRec)); + mon->mon_identifier = XtNewString(label); + XF86Config->conf_monitor_lst = + xf86addMonitor(XF86Config->conf_monitor_lst, mon); + + CreateMonitor(parent, mon); + + RelayoutTree(); +} + +static void +MonitorUpdate(TreeNode *node) +{ + char *str; + + /* vendor */ + XtVaGetValues(node->data->monitor.vendor, XtNstring, &str, NULL); + XtFree(node->data->monitor.monitor->mon_vendor); + if (*str) + node->data->monitor.monitor->mon_vendor = XtNewString(str); + else + node->data->monitor.monitor->mon_vendor = NULL; + + /* model */ + XtVaGetValues(node->data->monitor.model, XtNstring, &str, NULL); + XtFree(node->data->monitor.monitor->mon_modelname); + if (*str) + node->data->monitor.monitor->mon_modelname = XtNewString(str); + else + node->data->monitor.monitor->mon_modelname = NULL; + + /* width */ + XtVaGetValues(node->data->monitor.width, XtNstring, &str, NULL); + node->data->monitor.monitor->mon_width = strtoul(str, NULL, 0); + + /* height */ + XtVaGetValues(node->data->monitor.height, XtNstring, &str, NULL); + node->data->monitor.monitor->mon_height = strtoul(str, NULL, 0); + + /* hsync */ + XtVaGetValues(node->data->monitor.hsync, XtNstring, &str, NULL); + node->data->monitor.monitor->mon_n_hsync = + string_to_parser_range(str, + &(node->data->monitor.monitor->mon_hsync[0]), + CONF_MAX_HSYNC); + + /* vrefresh */ + XtVaGetValues(node->data->monitor.vrefresh, XtNstring, &str, NULL); + node->data->monitor.monitor->mon_n_vrefresh = + string_to_parser_range(str, + &(node->data->monitor.monitor->mon_vrefresh[0]), + CONF_MAX_VREFRESH); + + /* gammaRed */ + XtVaGetValues(node->data->monitor.gammaRed, XtNstring, &str, NULL); + node->data->monitor.monitor->mon_gamma_red = strtod(str, NULL); + + /* gammaGreen */ + XtVaGetValues(node->data->monitor.gammaGreen, XtNstring, &str, NULL); + node->data->monitor.monitor->mon_gamma_green = strtod(str, NULL); + + /* gammaBlue */ + XtVaGetValues(node->data->monitor.gammaBlue, XtNstring, &str, NULL); + node->data->monitor.monitor->mon_gamma_blue = strtod(str, NULL); +} + +static void +CreateMonitorModeLine(TreeNode *parent, XF86ConfModeLinePtr modeline) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modeline) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modeline.modeline = modeline; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = MonitorModeLineDestroy; + CreateModeLineField(node, False, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + modeline = (XF86ConfModeLinePtr)(modeline->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateModeLineField(node, True, True); +} + +/*ARGUSED*/ +static void +MonitorModeLineDestroy(TreeNode *node) +{ + if (node->data->modeline.modeline) + xf86removeMonitorModeLine(node->parent->parent->data->monitor.monitor, + node->data->modeline.modeline); +} + +/*ARGSUSED*/ +static void +NewMonitorModeLineCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModeLinePtr modeline; + Arg args[1]; + char *ident, *value; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->modeline.text, args, 1); + XtSetArg(args[0], XtNstring, &value); + XtGetValues(node->data->modeline.value, args, 1); + if (*ident == '\0' || *value == '\0') + return; + + parent = node->parent; + DeleteNode(node); + modeline = ParseModeLine(ident, value); + parent->parent->data->monitor.monitor->mon_modeline_lst = + xf86addModeLine(parent->parent->data->monitor.monitor->mon_modeline_lst, + modeline); + + CreateMonitorModeLine(parent, modeline); + RelayoutTree(); +} + +static void +CreateMonitorModes(TreeNode *parent, XF86ConfModesLinkPtr lnk) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (lnk) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modeslink.modeslink = lnk; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = MonitorModesLinkDestroy; + CreateMonitorModesField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + lnk = (XF86ConfModesLinkPtr)(lnk->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateMonitorModesField(node, True); +} + +static void +CreateMonitorModesField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("modes", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86ConfModesLinkPtr lnk = node->data->modeslink.modeslink; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + (void) XtVaCreateManagedWidget("mode", labelWidgetClass, box, + XtNlabel, lnk->ml_modes_str, NULL); + } + else { + Widget sme; + XF86ConfModesPtr ptr = XF86Config->conf_modes_lst; + + command = XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "modesMenu", NULL); + node->data->modeslink.menu = + XtVaCreatePopupShell("modesMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL); + while (ptr) { + sme = XtCreateManagedWidget(ptr->modes_identifier, smeBSBObjectClass, + node->data->modeslink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewMonitorModesCallback, + (XtPointer)node); + ptr = (XF86ConfModesPtr)(ptr->list.next); + } + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +MonitorModesLinkDestroy(TreeNode *node) +{ + if (node->data->modeslink.modeslink) + xf86removeMonitorModesLink(node->parent->parent->data->monitor.monitor, + node->data->modeslink.modeslink); +} + +/*ARGSUSED*/ +static void +NewMonitorModesCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModesLinkPtr link; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + link = (XF86ConfModesLinkPtr)XtCalloc(1, sizeof(XF86ConfModesLinkRec)); + link->ml_modes_str = XtNewString(ident); + parent->parent->data->monitor.monitor->mon_modes_sect_lst = + xf86addModesLink(parent->parent->data->monitor.monitor->mon_modes_sect_lst, + link); + + CreateMonitorModes(parent, link); + RelayoutTree(); +} + +/* Device */ +static void +CreateDevice(TreeNode *parent, XF86ConfDevicePtr dev) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (dev) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->device.device = dev; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = DeviceDestroy; + node->update = DeviceUpdate; + CreateDeviceField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + dev = (XF86ConfDevicePtr)(dev->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateDeviceField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateDeviceField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("device", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + int i, tmp, len; + char buf[1024], *str; + XF86OptionPtr *options; + XF86ConfDevicePtr dev = node->data->device.device; + + options = &(dev->dev_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, dev->dev_identifier, NULL); + + XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0); + str = dev->dev_vendor ? dev->dev_vendor : ""; + node->data->device.vendor = + XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("boardL", labelWidgetClass, box, NULL, 0); + str = dev->dev_board ? dev->dev_board : ""; + node->data->device.board = + XtVaCreateManagedWidget("board", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("chipsetL", labelWidgetClass, box, NULL, 0); + str = dev->dev_chipset ? dev->dev_chipset : ""; + node->data->device.chipset = + XtVaCreateManagedWidget("chipset", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("busidL", labelWidgetClass, box, NULL, 0); + str = dev->dev_busid ? dev->dev_busid : ""; + node->data->device.busid = + XtVaCreateManagedWidget("busid", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("cardL", labelWidgetClass, box, NULL, 0); + str = dev->dev_card ? dev->dev_card : ""; + node->data->device.card = + XtVaCreateManagedWidget("card", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0); + str = dev->dev_driver ? dev->dev_driver : ""; + node->data->device.driver = + XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("ramdacL", labelWidgetClass, box, NULL, 0); + str = dev->dev_ramdac ? dev->dev_ramdac : ""; + node->data->device.ramdac = + XtVaCreateManagedWidget("ramdac", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("dacSpeedL", labelWidgetClass, box, NULL, 0); + if (dev->dev_dacSpeeds[0] > 0) { + for (i = len = 0; i < CONF_MAXDACSPEEDS && + dev->dev_dacSpeeds[i] > 0; i++) { + tmp = XmuSnprintf(buf + len, sizeof(buf) - len, "%g ", + dev->dev_dacSpeeds[i] / 1000.); + len += tmp; + } + } + else + *buf = '\0'; + node->data->device.dacSpeed = + XtVaCreateManagedWidget("dacSpeed", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("videoRamL", labelWidgetClass, box, NULL, 0); + if (dev->dev_videoram) + XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_videoram); + else + *buf = '\0'; + node->data->device.videoRam = + XtVaCreateManagedWidget("videoRam", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("textClockFreqL", labelWidgetClass, box, NULL, 0); + if (dev->dev_textclockfreq) + XmuSnprintf(buf, sizeof(buf), "%.1f", + (double)dev->dev_textclockfreq / 1000.0); + else + *buf = '\0'; + node->data->device.textClockFreq = + XtVaCreateManagedWidget("textClockFreq", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("biosBaseL", labelWidgetClass, box, NULL, 0); + if (dev->dev_bios_base) + XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_bios_base); + else + *buf = '\0'; + node->data->device.biosBase = + XtVaCreateManagedWidget("biosBase", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("memBaseL", labelWidgetClass, box, NULL, 0); + if (dev->dev_mem_base) + XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_mem_base); + else + *buf = '\0'; + node->data->device.memBase = + XtVaCreateManagedWidget("memBase", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("ioBaseL", labelWidgetClass, box, NULL, 0); + if (dev->dev_io_base) + XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_io_base); + else + *buf = '\0'; + node->data->device.ioBase = + XtVaCreateManagedWidget("ioBase", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("clockChipL", labelWidgetClass, box, NULL, 0); + str = dev->dev_clockchip ? dev->dev_clockchip : ""; + node->data->device.clockChip = + XtVaCreateManagedWidget("clockChip", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + *buf = '\0'; + for (i = len = 0; i < dev->dev_clocks; i++) { + tmp = XmuSnprintf(buf + len, sizeof(buf) - len, "%.1f ", + (double)dev->dev_clock[i] / 1000.0); + len += tmp; + } + XtCreateManagedWidget("devClockL", labelWidgetClass, box, NULL, 0); + node->data->device.devClock = + XtVaCreateManagedWidget("devClock", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("chipIdL", labelWidgetClass, box, NULL, 0); + if (dev->dev_chipid != -1) + XmuSnprintf(buf, sizeof(buf), "0x%x", dev->dev_chipid); + else + *buf = '\0'; + node->data->device.chipId = + XtVaCreateManagedWidget("chipId", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("chipRevL", labelWidgetClass, box, NULL, 0); + if (dev->dev_chiprev != -1) + XmuSnprintf(buf, sizeof(buf), "0x%x", dev->dev_chiprev); + else + *buf = '\0'; + node->data->device.chipRev = + XtVaCreateManagedWidget("chipRev", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("irqL", labelWidgetClass, box, NULL, 0); + if (dev->dev_irq != -1) + XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_irq); + else + *buf = '\0'; + node->data->device.irq = + XtVaCreateManagedWidget("irq", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("screenL", labelWidgetClass, box, NULL, 0); + if (dev->dev_screen > 0) + XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_screen); + else + *buf = '\0'; + node->data->device.screen = + XtVaCreateManagedWidget("screen", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewDeviceCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->device.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +NewDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfDevicePtr dev; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->device.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + dev = (XF86ConfDevicePtr)XtCalloc(1, sizeof(XF86ConfDeviceRec)); + dev->dev_identifier = XtNewString(label); + dev->dev_chipid = -1; + dev->dev_chiprev = -1; + dev->dev_irq = -1; + + XF86Config->conf_device_lst = + xf86addDevice(XF86Config->conf_device_lst, dev); + + CreateDevice(parent, dev); + + RelayoutTree(); +} + +static void +DeviceDestroy(TreeNode *node) +{ + int i; + TreeNode *sc = screenTree; + + for (i = 0; i < computer.num_devices; i++) + if ((XF86ConfDevicePtr)(computer.devices[i]->config) == + node->data->device.device) { + config = computer.devices[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + + if (sc) { + TreeNode *prev; + + sc = prev = sc->child; + while (sc->next) { + TreeNode *next = sc->next; + + if (sc->data->screen.screen->scrn_monitor == + node->data->monitor.monitor) { + XtDestroyWidget(sc->node); + + if (sc->child) + DestroyTree(sc->child); + if (sc->data) + XtFree((XtPointer)sc->data); + XtFree((XtPointer)sc); + + if (sc == screenTree->child) + sc = prev = next = screenTree->child = next; + else + prev->next = sc = next; + continue; + } + prev = sc; + sc = next; + } + } +} + +static void +DeviceUpdate(TreeNode *node) +{ + int i; + char *str, *tmp; + + /* vendor */ + XtVaGetValues(node->data->device.vendor, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_vendor); + if (*str) + node->data->device.device->dev_vendor = XtNewString(str); + else + node->data->device.device->dev_vendor = NULL; + + /* board */ + XtVaGetValues(node->data->device.board, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_board); + if (*str) + node->data->device.device->dev_board = XtNewString(str); + else + node->data->device.device->dev_board = NULL; + + /* chipset */ + XtVaGetValues(node->data->device.chipset, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_chipset); + if (*str) + node->data->device.device->dev_chipset = XtNewString(str); + else + node->data->device.device->dev_chipset = NULL; + + /* busid */ + XtVaGetValues(node->data->device.busid, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_busid); + if (*str) + node->data->device.device->dev_busid = XtNewString(str); + else + node->data->device.device->dev_busid = NULL; + + /* card */ + XtVaGetValues(node->data->device.card, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_card); + if (*str) + node->data->device.device->dev_card = XtNewString(str); + else + node->data->device.device->dev_card = NULL; + + /* driver */ + XtVaGetValues(node->data->device.driver, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_driver); + if (*str) + node->data->device.device->dev_driver = XtNewString(str); + else + node->data->device.device->dev_driver = NULL; + + /* ramdac */ + XtVaGetValues(node->data->device.ramdac, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_ramdac); + if (*str) + node->data->device.device->dev_ramdac = XtNewString(str); + else + node->data->device.device->dev_ramdac = NULL; + + /* dacSpeed */ + tmp = NULL; + XtVaGetValues(node->data->device.dacSpeed, XtNstring, &str, NULL); + for (i = 0; i < CONF_MAXDACSPEEDS && str != tmp; i++) { + if ((node->data->device.device->dev_dacSpeeds[i] = + (strtod(str, &tmp) * 1000. + .5)) == 0) + break; + str = tmp; + while (isspace(*str)) + ++str; + } + + /* videoRam */ + XtVaGetValues(node->data->device.videoRam, XtNstring, &str, NULL); + node->data->device.device->dev_videoram = strtoul(str, NULL, 0); + + /* textClockFreq */ + XtVaGetValues(node->data->device.textClockFreq, XtNstring, &str, NULL); + node->data->device.device->dev_textclockfreq = + strtod(str, NULL) * 1000. + .5; + + /* biosBase */ + XtVaGetValues(node->data->device.biosBase, XtNstring, &str, NULL); + node->data->device.device->dev_bios_base = strtoul(str, NULL, 0); + + /* memBase */ + XtVaGetValues(node->data->device.memBase, XtNstring, &str, NULL); + node->data->device.device->dev_mem_base = strtoul(str, NULL, 0); + + /* ioBase */ + XtVaGetValues(node->data->device.ioBase, XtNstring, &str, NULL); + node->data->device.device->dev_io_base = strtoul(str, NULL, 0); + + /* clockChip */ + XtVaGetValues(node->data->device.clockChip, XtNstring, &str, NULL); + XtFree(node->data->device.device->dev_clockchip); + if (*str) + node->data->device.device->dev_clockchip = XtNewString(str); + else + node->data->device.device->dev_clockchip = NULL; + + /* devSpeed */ + tmp = NULL; + XtVaGetValues(node->data->device.devClock, XtNstring, &str, NULL); + for (i = 0; i < CONF_MAXCLOCKS && str != tmp; i++) { + if ((node->data->device.device->dev_clock[i] = + (strtod(str, &tmp) * 1000. + .5)) == 0) + break; + str = tmp; + while (isspace(*str)) + ++str; + } + node->data->device.device->dev_clocks = i; + + /* chipId */ + XtVaGetValues(node->data->device.chipId, XtNstring, &str, NULL); + if (*str) + node->data->device.device->dev_chipid = strtoul(str, NULL, 0); + else + node->data->device.device->dev_chipid = -1; + + /* chipRev */ + XtVaGetValues(node->data->device.chipRev, XtNstring, &str, NULL); + if (*str) + node->data->device.device->dev_chiprev = strtoul(str, NULL, 0); + else + node->data->device.device->dev_chiprev = -1; + + /* irq */ + XtVaGetValues(node->data->device.irq, XtNstring, &str, NULL); + if (*str) + node->data->device.device->dev_irq = strtoul(str, NULL, 0); + else + node->data->device.device->dev_irq = -1; + + /* screen */ + XtVaGetValues(node->data->device.screen, XtNstring, &str, NULL); + if (*str) + node->data->device.device->dev_screen = strtoul(str, NULL, 0); + else + node->data->device.device->dev_screen = -1; +} + +/* Screen */ +static void +CreateScreen(TreeNode *parent, XF86ConfScreenPtr scrn) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (scrn) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->screen.screen = scrn; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ScreenDestroy; + node->update = ScreenUpdate; + CreateScreenField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + scrn = (XF86ConfScreenPtr)(scrn->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateScreenField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateScreenField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("screen", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + char buf[256], *str; + XF86OptionPtr *options; + TreeNode *adaptor, *display; + XF86ConfScreenPtr scrn = node->data->screen.screen; + + options = &(scrn->scrn_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, scrn->scrn_identifier, NULL); + + XtCreateManagedWidget("defaultDepthL", labelWidgetClass, box, NULL, 0); + if (scrn->scrn_defaultdepth) + XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultdepth); + else + *buf = '\0'; + node->data->screen.defaultDepth = + XtVaCreateManagedWidget("defaultDepth", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("defaultBppL", labelWidgetClass, box, NULL, 0); + if (scrn->scrn_defaultbpp) + XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultbpp); + else + *buf = '\0'; + node->data->screen.defaultBpp = + XtVaCreateManagedWidget("defaultBpp", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("defaultFbBppL", labelWidgetClass, box, NULL, 0); + if (scrn->scrn_defaultfbbpp) + XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultfbbpp); + else + *buf = '\0'; + node->data->screen.defaultFbBpp = + XtVaCreateManagedWidget("defaultFbBpp", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL); + + XtCreateManagedWidget("monitorL", labelWidgetClass, box, NULL, 0); + str = scrn->scrn_monitor_str ? scrn->scrn_monitor_str : ""; + node->data->screen.monitor = + XtVaCreateManagedWidget("monitor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + XtCreateManagedWidget("deviceL", labelWidgetClass, box, NULL, 0); + str = scrn->scrn_device_str ? scrn->scrn_device_str : ""; + node->data->screen.device = + XtVaCreateManagedWidget("device", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL); + + command = XtVaCreateManagedWidget("videoAdaptor", toggleWidgetClass, + tree, XtNstate, True, + XtNtreeParent, box, NULL); + adaptor = NewNode(node, command, command, node->node, NULL); + CreateScreenAdaptor(adaptor, scrn->scrn_adaptor_lst); + node->child = adaptor; + + command = XtVaCreateManagedWidget("Display", toggleWidgetClass, + tree, XtNstate, True, + XtNtreeParent, box, NULL); + display = NewNode(node, command, command, node->node, NULL); + CreateScreenDisplay(display, scrn->scrn_display_lst); + adaptor->next = display; + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewScreenCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->screen.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +NewScreenCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfScreenPtr scrn; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->screen.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + scrn = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec)); + scrn->scrn_identifier = XtNewString(label); + XF86Config->conf_screen_lst = + xf86addScreen(XF86Config->conf_screen_lst, scrn); + + { + TreeNode *lay = layoutTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (lay && lay->next != NULL) { + /* Adjacency is the first entry */ + TreeNode *adj = lay->child->child; + + while (adj != NULL) { + sme = XtCreateManagedWidget(label, smeBSBObjectClass, + adj->data->adjacency.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, adj->next != NULL ? + AdjacencyMenuCallback : NewAdjacencyCallback, + (XtPointer)adj); + adj = adj->next; + } + lay = lay->next; + } + } + + CreateScreen(parent, scrn); + + RelayoutTree(); +} + +static void +ScreenDestroy(TreeNode *node) +{ + if (node->data->screen.screen) { + int i; + TreeNode *lay = layoutTree->child; + + /* last one is the "new" entry */ + while (lay && lay->next) { + /* Adjacency is the first entry */ + TreeNode *adj = lay->child->child; + CompositeWidget composite; + + while (adj) { + TreeNode *next = adj->next; + + composite = (CompositeWidget)adj->data->adjacency.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->screen.screen->scrn_identifier) == 0) { + XtDestroyWidget(composite->composite.children[i]); + break; + } + + if (adj->data->adjacency.screen == node->data->screen.screen) + DeleteNode(adj); + + adj = next; + } + + lay = lay->next; + } + + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == node->data->screen.screen) { + config = computer.screens[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + + /* for the case of screens added and removed in the expert dialog */ + xf86removeScreen(XF86Config, node->data->screen.screen); + } +} + +static void +ScreenUpdate(TreeNode *node) +{ + char *str; + + /* defautDepth */ + XtVaGetValues(node->data->screen.defaultDepth, XtNstring, &str, NULL); + node->data->screen.screen->scrn_defaultdepth = strtoul(str, NULL, 0); + + /* defautBpp */ + XtVaGetValues(node->data->screen.defaultBpp, XtNstring, &str, NULL); + node->data->screen.screen->scrn_defaultbpp = strtoul(str, NULL, 0); + + /* defautFbBpp */ + XtVaGetValues(node->data->screen.defaultFbBpp, XtNstring, &str, NULL); + node->data->screen.screen->scrn_defaultfbbpp = strtoul(str, NULL, 0); + + + /* XXX Monitor and Device should be changed to a menu interface */ + /* monitor */ + XtVaGetValues(node->data->screen.monitor, XtNstring, &str, NULL); + XtFree(node->data->screen.screen->scrn_monitor_str); + if (*str) + node->data->screen.screen->scrn_monitor_str = XtNewString(str); + else + node->data->screen.screen->scrn_monitor_str = NULL; + + /* XXX Monitor and Device should be changed to a menu interface */ + /* device */ + XtVaGetValues(node->data->screen.device, XtNstring, &str, NULL); + XtFree(node->data->screen.screen->scrn_device_str); + if (*str) + node->data->screen.screen->scrn_device_str = XtNewString(str); + else + node->data->screen.screen->scrn_device_str = NULL; +} + +static void +CreateScreenAdaptor(TreeNode *parent, XF86ConfAdaptorLinkPtr lnk) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (lnk) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->adaptorlink.adaptorlink = lnk; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ScreenAdaptorDestroy; + CreateScreenAdaptorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + lnk = (XF86ConfAdaptorLinkPtr)(lnk->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateScreenAdaptorField(node, True); +} + +static void +CreateScreenAdaptorField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("adaptor", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86ConfAdaptorLinkPtr lnk = node->data->adaptorlink.adaptorlink; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + (void) XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, lnk->al_adaptor_str, NULL); + } + else { + Widget sme; + XF86ConfVideoAdaptorPtr ptr = XF86Config->conf_videoadaptor_lst; + + command = XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "adaptorMenu", NULL); + node->data->adaptorlink.menu = + XtVaCreatePopupShell("adaptorMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL); + while (ptr) { + sme = XtCreateManagedWidget(ptr->va_identifier, smeBSBObjectClass, + node->data->adaptorlink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewScreenAdaptorCallback, + (XtPointer)node); + ptr = (XF86ConfVideoAdaptorPtr)(ptr->list.next); + } + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewScreenAdaptorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfAdaptorLinkPtr link; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + link = (XF86ConfAdaptorLinkPtr)XtCalloc(1, sizeof(XF86ConfAdaptorLinkRec)); + link->al_adaptor_str = XtNewString(ident); + parent->parent->data->screen.screen->scrn_adaptor_lst = + xf86addScreenAdaptor(parent->parent->data->screen.screen->scrn_adaptor_lst, + link); + + CreateScreenAdaptor(parent, link); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +ScreenAdaptorDestroy(TreeNode *node) +{ + if (node->data->adaptorlink.adaptorlink) + xf86removeScreenAdaptorLink(node->parent->parent->data->screen.screen, + node->data->adaptorlink.adaptorlink); +} + +static void +CreateScreenDisplay(TreeNode *parent, XF86ConfDisplayPtr dsp) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (dsp) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->display.display = dsp; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ScreenDisplayDestroy; + node->update = ScreenDisplayUpdate; + CreateScreenDisplayField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + dsp = (XF86ConfDisplayPtr)(dsp->list.next); + } + node = NewNode(parent, NULL, NULL, parent->node, NULL); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateScreenDisplayField(node, True); +} + +static void +CreateScreenDisplayField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("display", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + char *str, buf[256]; + XF86OptionPtr *options; + XF86ConfDisplayPtr dsp = node->data->display.display; + TreeNode *modes; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(dsp->disp_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + + XtCreateManagedWidget("viewportL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_frameX0 != 0 || dsp->disp_frameY0 != 0) + XmuSnprintf(buf, sizeof(buf), "%d %d", dsp->disp_frameX0, dsp->disp_frameY0); + else + *buf = '\0'; + node->data->display.viewport = + XtVaCreateManagedWidget("viewport", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtCreateManagedWidget("virtualL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_virtualX != 0 || dsp->disp_virtualY != 0) + XmuSnprintf(buf, sizeof(buf), "%d %d", dsp->disp_virtualX, dsp->disp_virtualY); + else + *buf = '\0'; + node->data->display.c_virtual = + XtVaCreateManagedWidget("virtual", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtCreateManagedWidget("depthL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_depth != 0) + XmuSnprintf(buf, sizeof(buf), "%d", dsp->disp_depth); + else + *buf = '\0'; + node->data->display.depth = + XtVaCreateManagedWidget("depth", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtCreateManagedWidget("bppL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_bpp != 0) + XmuSnprintf(buf, sizeof(buf), "%d", dsp->disp_bpp); + else + *buf = '\0'; + node->data->display.bpp = + XtVaCreateManagedWidget("bpp", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtCreateManagedWidget("visualL", labelWidgetClass, box, NULL, 0); + str = dsp->disp_visual != NULL ? dsp->disp_visual : ""; + node->data->display.visual = + XtVaCreateManagedWidget("visual", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, NULL); + + XtCreateManagedWidget("weightL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_weight.red > 0) + XmuSnprintf(buf, sizeof(buf), "%d %d %d", + dsp->disp_weight.red, dsp->disp_weight.green, dsp->disp_weight.blue); + else + *buf = '\0'; + node->data->display.weight = + XtVaCreateManagedWidget("weight", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtCreateManagedWidget("blackL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_black.red >= 0) + XmuSnprintf(buf, sizeof(buf), "0x%04x 0x%04x 0x%04x", + dsp->disp_black.red, dsp->disp_black.green, dsp->disp_black.blue); + else + *buf = '\0'; + node->data->display.black = + XtVaCreateManagedWidget("black", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtCreateManagedWidget("whiteL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_white.red >= 0) + XmuSnprintf(buf, sizeof(buf), "0x%04x 0x%04x 0x%04x", + dsp->disp_white.red, dsp->disp_white.green, dsp->disp_white.blue); + else + *buf = '\0'; + node->data->display.white = + XtVaCreateManagedWidget("white", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + command = XtVaCreateManagedWidget("Modes", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL); + modes = NewNode(node, command, command, node->node, NULL); + node->child = modes; + CreateDisplayMode(modes, dsp->disp_mode_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewScreenDisplayCallback, + (XtPointer)node); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewScreenDisplayCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfDisplayPtr dsp; + + parent = node->parent; + DeleteNode(node); + dsp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec)); + dsp->disp_black.red = dsp->disp_black.green = dsp->disp_black.blue = + dsp->disp_white.red = dsp->disp_white.green = dsp->disp_white.blue = -1; + parent->parent->data->screen.screen->scrn_display_lst = + xf86addScreenDisplay(parent->parent->data->screen.screen->scrn_display_lst, + dsp); + + CreateScreenDisplay(parent, dsp); + RelayoutTree(); +} + +static void +ScreenDisplayDestroy(TreeNode *node) +{ + if (node->data->display.display) + xf86removeScreenDisplay(node->parent->parent->data->screen.screen, + node->data->display.display); +} + +static void +ScreenDisplayUpdate(TreeNode *node) +{ + char *str, *tmp; + int x, y; + + /* viewport */ + XtVaGetValues(node->data->display.viewport, XtNstring, &str, NULL); + if (sscanf(str, "%d %d", &x, &y) == 2) { + node->data->display.display->disp_frameX0 = x; + node->data->display.display->disp_frameY0 = y; + } + + /* virtual */ + XtVaGetValues(node->data->display.c_virtual, XtNstring, &str, NULL); + if (sscanf(str, "%d %d", &x, &y) == 2) { + node->data->display.display->disp_virtualX = x; + node->data->display.display->disp_virtualY = y; + } + + /* depth */ + XtVaGetValues(node->data->display.depth, XtNstring, &str, NULL); + node->data->display.display->disp_depth = strtoul(str, NULL, 0); + + /* bpp */ + XtVaGetValues(node->data->display.bpp, XtNstring, &str, NULL); + node->data->display.display->disp_bpp = strtoul(str, NULL, 0); + + /* visual */ + XtVaGetValues(node->data->display.visual, XtNstring, &str, NULL); + XtFree(node->data->display.display->disp_visual); + if (*str) + node->data->display.display->disp_visual = XtNewString(str); + else + node->data->display.display->disp_visual = NULL; + + /* weight */ + XtVaGetValues(node->data->display.weight, XtNstring, &str, NULL); + node->data->display.display->disp_weight.red = strtoul(str, &tmp, 0); + if (str == tmp) + node->data->display.display->disp_weight.red = 0; + else { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_weight.green = strtoul(str, &tmp, 0); + if (str != tmp) { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_weight.blue = strtoul(str, &tmp, 0); + } + } + + /* black */ + XtVaGetValues(node->data->display.black, XtNstring, &str, NULL); + node->data->display.display->disp_black.red = strtoul(str, &tmp, 0); + if (str == tmp) + node->data->display.display->disp_black.red = -1; + else { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_black.green = strtoul(str, &tmp, 0); + if (str != tmp) { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_black.blue = strtoul(str, &tmp, 0); + } + } + + /* white */ + XtVaGetValues(node->data->display.white, XtNstring, &str, NULL); + node->data->display.display->disp_white.red = strtoul(str, &tmp, 0); + if (str == tmp) + node->data->display.display->disp_white.red = -1; + else { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_white.green = strtoul(str, &tmp, 0); + if (str != tmp) { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_white.blue = strtoul(str, &tmp, 0); + } + } +} + +static void +CreateDisplayMode(TreeNode *parent, XF86ModePtr modes) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modes) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->mode.mode = modes; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = DisplayModeDestroy; + CreateDisplayModeField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + modes = (XF86ModePtr)(modes->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateDisplayModeField(node, True); +} + +static void +CreateDisplayModeField(TreeNode *node, Bool addnew) +{ + Widget box, command, text; + + box = XtVaCreateWidget("mode", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + if (!addnew) { + XF86ModePtr mode = node->data->mode.mode; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, + (XtPointer)node); + text = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, mode->mode_name, NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewDisplayModeCallback, + (XtPointer)node); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL); + } + node->data->mode.text = text; + if (node->treeParent && XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewDisplayModeCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ModePtr mode; + Arg args[1]; + char *ident; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->mode.text, args, 1); + if (*ident == '\0') + return; + + parent = node->parent; + DeleteNode(node); + mode = (XF86ModePtr)XtCalloc(1, sizeof(XF86ModeRec)); + mode->mode_name = XtNewString(ident); + parent->parent->data->display.display->disp_mode_lst = + xf86addDisplayMode(parent->parent->data->display.display->disp_mode_lst, + mode); + + CreateDisplayMode(parent, mode); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +DisplayModeDestroy(TreeNode *node) +{ + if (node->data->mode.mode) + xf86removeDisplayMode(node->parent->parent->data->display.display, + node->data->mode.mode); +} + +/* Input */ +static void +CreateInput(TreeNode *parent, XF86ConfInputPtr input) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (input) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->input.input = input; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = InputDestroy; + node->update = InputUpdate; + CreateInputField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + input = (XF86ConfInputPtr)(input->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateInputField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateInputField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("input", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + char *str; + XF86OptionPtr *options; + XF86ConfInputPtr inp = node->data->input.input; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(inp->inp_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, inp->inp_identifier, NULL); + + XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0); + str = inp->inp_driver != NULL ? inp->inp_driver : ""; + node->data->input.text = + XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewInputCallback, + (XtPointer)node); + node->data->input.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewInputCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfInputPtr input; + Arg args[1]; + char *ident; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->input.text, args, 1); + if (*ident == '\0') + return; + + parent = node->parent; + DeleteNode(node); + input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec)); + input->inp_identifier = XtNewString(ident); + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, input); + + { + TreeNode *lay = layoutTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (lay && lay->next != NULL) { + /* Inputref is the second entry */ + TreeNode *iref = lay->child->next->child; + + while (iref && iref->next) + iref = iref->next; + sme = XtCreateManagedWidget(ident, smeBSBObjectClass, + iref->data->inputref.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewInputrefCallback, + (XtPointer)iref); + lay = lay->next; + } + } + + CreateInput(parent, input); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +InputDestroy(TreeNode *node) +{ + if (node->data->input.input) { + int i; + TreeNode *lay = layoutTree->child; + + /* last one is the "new" entry */ + while (lay && lay->next) { + /* Inputref is the second entry */ + TreeNode *iref = lay->child->next->child; + CompositeWidget composite; + + while (iref && iref->next) { + TreeNode *next = iref->next; + + if (iref && strcmp(iref->data->inputref.inputref->iref_inputdev_str, + node->data->input.input->inp_identifier) == 0) + DeleteNode(iref); + iref = next; + } + + composite = (CompositeWidget)iref->data->inputref.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->input.input->inp_identifier) == 0) + XtDestroyWidget(composite->composite.children[i]); + + lay = lay->next; + } + + for (i = 0; i < computer.num_devices; i++) + if ((XF86ConfInputPtr)(computer.devices[i]->config) == + node->data->input.input) { + config = computer.devices[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + } +} + +static void +InputUpdate(TreeNode *node) +{ + char *str; + + /* vendor */ + XtVaGetValues(node->data->input.text, XtNstring, &str, NULL); + XtFree(node->data->input.input->inp_driver); + if (*str) + node->data->input.input->inp_driver = XtNewString(str); + else + node->data->input.input->inp_driver = NULL; +} + +/* Layout */ +static void +CreateLayout(TreeNode *parent, XF86ConfLayoutPtr lay) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (lay) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->layout.layout = lay; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = LayoutDestroy; + CreateLayoutField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateLayoutField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateLayoutField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("layout", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + TreeNode *adjacency, *inputref; + XF86OptionPtr *options; + XF86ConfLayoutPtr lay = node->data->layout.layout; + + options = &(lay->lay_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, lay->lay_identifier, NULL); + + command = XtVaCreateManagedWidget("Adjacency", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL); + adjacency = NewNode(node, command, command, box, NULL); + node->child = adjacency; + CreateAdjacency(adjacency, lay->lay_adjacency_lst); + + command = XtVaCreateManagedWidget("Inputref", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL); + inputref = NewNode(node, command, command, box, NULL); + adjacency->next = inputref; + CreateInputref(inputref, lay->lay_input_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewLayoutCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL); + node->data->layout.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +LayoutDestroy(TreeNode *node) +{ + if (node->data->layout.layout) + xf86removeLayout(XF86Config, node->data->layout.layout); +} + +/*ARGSUSED*/ +static void +NewLayoutCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfLayoutPtr lay; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->layout.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + lay = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec)); + lay->lay_identifier = XtNewString(label); + XF86Config->conf_layout_lst = xf86addLayout(XF86Config->conf_layout_lst, lay); + + CreateLayout(parent, lay); + RelayoutTree(); +} + +static void +CreateAdjacency(TreeNode *parent, XF86ConfAdjacencyPtr adj) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (adj) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->adjacency.screen = adj ? adj->adj_screen : NULL; + data->adjacency.adjacency = adj; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = AdjacencyDestroy; + CreateAdjacencyField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateAdjacencyField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateAdjacencyField(TreeNode *node, Bool addnew) +{ + Widget box, command, sme; + XF86ConfScreenPtr ptr = XF86Config->conf_screen_lst; + + box = XtVaCreateWidget("adjacency", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + node->data->adjacency.menu = + XtVaCreatePopupShell("screenMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL); + while (ptr) { + sme = XtCreateManagedWidget(ptr->scrn_identifier, smeBSBObjectClass, + node->data->adjacency.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, !addnew ? + AdjacencyMenuCallback : NewAdjacencyCallback, + (XtPointer)node); + ptr = (XF86ConfScreenPtr)(ptr->list.next); + } + + if (!addnew) { + char buf[32]; + Cardinal width, height; + Widget left, right, above, below, relative, absolute; + XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + (void) XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, adj->adj_screen->scrn_identifier, + NULL); + + XtCreateManagedWidget("scrnumL", labelWidgetClass, box, NULL, 0); + if (adj->adj_scrnum >= 0) + XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_scrnum); + else + *buf = 0; + node->data->adjacency.scrnum = + XtVaCreateManagedWidget("scrnum", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + above = XtVaCreateManagedWidget("above", toggleWidgetClass, box, + XtNstate, adj->adj_where == CONF_ADJ_ABOVE ? + True : False, NULL); + XtAddCallback(above, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + left = XtVaCreateManagedWidget("leftOf", toggleWidgetClass, box, + XtNradioGroup, above, + XtNstate, adj->adj_where == CONF_ADJ_LEFTOF ? + True : False, NULL); + XtAddCallback(left, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + + node->data->adjacency.button = + XtVaCreateManagedWidget("screen", menuButtonWidgetClass, box, + XtNmenuName, "screenMenu", NULL); + + right = XtVaCreateManagedWidget("rightOf", toggleWidgetClass, box, + XtNradioGroup, left, + XtNstate, adj->adj_where == CONF_ADJ_RIGHTOF ? + True : False, NULL); + XtAddCallback(right, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + below = XtVaCreateManagedWidget("below", toggleWidgetClass, box, + XtNradioGroup, right, + XtNstate, adj->adj_where == CONF_ADJ_BELOW ? + True : False, NULL); + XtAddCallback(below, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + relative = XtVaCreateManagedWidget("relative", toggleWidgetClass, box, + XtNradioGroup, below, + XtNstate, adj->adj_where == CONF_ADJ_RELATIVE ? + True : False, NULL); + XtAddCallback(relative, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + absolute = XtVaCreateManagedWidget("absolute", toggleWidgetClass, box, + XtNradioGroup, relative, + XtNstate, adj->adj_where == CONF_ADJ_ABSOLUTE ? + True : False, NULL); + XtAddCallback(absolute, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + + XtCreateManagedWidget("adjxL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_x); + node->data->adjacency.adjx = + XtVaCreateManagedWidget("adjx", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtCreateManagedWidget("adjyL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_y); + node->data->adjacency.adjy = + XtVaCreateManagedWidget("adjy", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL); + + XtVaGetValues(node->data->adjacency.button, XtNwidth, &width, + XtNheight, &height, NULL); + if (adj->adj_where > CONF_ADJ_ABSOLUTE && + adj->adj_where <= CONF_ADJ_RELATIVE) + XtVaSetValues(node->data->adjacency.button, XtNlabel, + adj->adj_refscreen, XtNwidth, width, + XtNheight, height, NULL); + else + XtVaSetValues(node->data->adjacency.button, XtNlabel, "", + XtNwidth, width, XtNheight, height, NULL); + } + else + XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "screenMenu", NULL); + + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +AdjacencyDestroy(TreeNode *node) +{ + if (node->data->adjacency.adjacency) + xf86removeAdjacency(node->parent->parent->data->layout.layout, + node->data->adjacency.adjacency); +} + +/*ARGSUSED*/ +static void +NewAdjacencyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfAdjacencyPtr adj; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = xf86findScreen(ident, XF86Config->conf_screen_lst); + if (adj->adj_screen) + adj->adj_screen_str = XtNewString(adj->adj_screen->scrn_identifier); + parent->parent->data->layout.layout->lay_adjacency_lst = + xf86addAdjacency(parent->parent->data->layout.layout->lay_adjacency_lst, + adj); + + CreateAdjacency(parent, adj); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +AdjacencyMenuCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *node = (TreeNode*)user_data; + XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency; + + XtFree(adj->adj_refscreen); + adj->adj_refscreen = XtNewString(XtName(w)); + XtVaSetValues(node->data->adjacency.button, XtNlabel, XtName(w), NULL); +} + +static void +AdjacencyToggleCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *node = (TreeNode*)user_data; + XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency; + char *x, *y; + + if ((Bool)(long)call_data == False) + return; + + XtVaGetValues(node->data->adjacency.adjx, XtNstring, &x, NULL); + XtVaGetValues(node->data->adjacency.adjy, XtNstring, &y, NULL); + + adj->adj_x = strtol(x, NULL, 0); + adj->adj_y = strtol(y, NULL, 0); + + if (strcmp(XtName(w), "absolute") == 0) { + XtVaSetValues(node->data->adjacency.button, XtNlabel, "", NULL); + adj->adj_where = CONF_ADJ_ABSOLUTE; + return; + } + if (strcmp(XtName(w), "relative") == 0) + adj->adj_where = CONF_ADJ_RELATIVE; + else if (strcmp(XtName(w), "leftOf") == 0) + adj->adj_where = CONF_ADJ_LEFTOF; + else if (strcmp(XtName(w), "rightOf") == 0) + adj->adj_where = CONF_ADJ_RIGHTOF; + else if (strcmp(XtName(w), "above") == 0) + adj->adj_where = CONF_ADJ_ABOVE; + else if (strcmp(XtName(w), "below") == 0) + adj->adj_where = CONF_ADJ_BELOW; +} + +/* Inputref */ +static void +CreateInputref(TreeNode *parent, XF86ConfInputrefPtr input) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (input) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->inputref.inputref = input; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = InputrefDestroy; + CreateInputrefField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + input = (XF86ConfInputrefPtr)(input->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateInputrefField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateInputrefField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("inputref", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86ConfInputrefPtr inp = node->data->inputref.inputref; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(inp->iref_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, inp->iref_inputdev_str, NULL); + } + else { + Widget sme; + XF86ConfInputPtr ptr = XF86Config->conf_input_lst; + + XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "inputMenu", NULL); + node->data->inputref.menu = + XtVaCreatePopupShell("inputMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL); + + while (ptr) { + sme = XtCreateManagedWidget(ptr->inp_identifier, smeBSBObjectClass, + node->data->inputref.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewInputrefCallback, + (XtPointer)node); + ptr = (XF86ConfInputPtr)(ptr->list.next); + } + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewInputrefCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfInputrefPtr input; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + input = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec)); + input->iref_inputdev_str = XtNewString(ident); + parent->parent->data->layout.layout->lay_input_lst = + xf86addInputref(parent->parent->data->layout.layout->lay_input_lst, input); + + CreateInputref(parent, input); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +InputrefDestroy(TreeNode *node) +{ + if (node->data->inputref.inputref) + xf86removeInputRef(node->parent->parent->data->layout.layout, node->data->inputref.inputref->iref_inputdev); +} + +/* Vendor */ +static void +CreateVendor(TreeNode *parent, XF86ConfVendorPtr vendor) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (vendor) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->vendor.vendor = vendor; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VendorDestroy; + CreateVendorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + vendor = (XF86ConfVendorPtr)(vendor->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVendorField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVendorField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("vendor", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + TreeNode *sub; + XF86OptionPtr *options; + XF86ConfVendorPtr vendor = node->data->vendor.vendor; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(vendor->vnd_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, vendor->vnd_identifier, NULL); + + command = XtVaCreateManagedWidget("VendSub", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, + NULL); + sub = NewNode(node, command, command, box, NULL); + node->child = sub; + CreateVendorSub(sub, vendor->vnd_sub_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVendorCallback, (XtPointer)node); + node->data->vendor.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +VendorDestroy(TreeNode *node) +{ + if (node->data->vendor.vendor) + xf86removeVendor(XF86Config, node->data->vendor.vendor); +} + +static void +NewVendorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfVendorPtr vnd; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->vendor.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + vnd = (XF86ConfVendorPtr)XtCalloc(1, sizeof(XF86ConfVendorRec)); + vnd->vnd_identifier = XtNewString(label); + XF86Config->conf_vendor_lst = xf86addVendor(XF86Config->conf_vendor_lst, vnd); + + CreateVendor(parent, vnd); + RelayoutTree(); +} + +/* VendorSub */ +static void +CreateVendorSub(TreeNode *parent, XF86ConfVendSubPtr vendor) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (vendor) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->vendsub.vendsub = vendor; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VendorSubDestroy; + node->update = VendorSubUpdate; + CreateVendorSubField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + vendor = (XF86ConfVendSubPtr)(vendor->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVendorSubField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVendorSubField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("vendorSub", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86ConfVendSubPtr vendor = node->data->vendsub.vendsub; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(vendor->vs_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, vendor->vs_identifier, NULL); + + XtCreateManagedWidget("nameL", labelWidgetClass, box, NULL, 0); + node->data->vendsub.text = + XtVaCreateManagedWidget("name", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, + vendor->vs_name ? vendor->vs_name : "", + NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVendorSubCallback, (XtPointer)node); + node->data->vendsub.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +VendorSubDestroy(TreeNode *node) +{ + if (node->data->vendsub.vendsub) + xf86removeVendorSub(node->parent->parent->data->vendor.vendor, + node->data->vendsub.vendsub); +} + +static void +VendorSubUpdate(TreeNode *node) +{ + char *str; + + XtVaGetValues(node->data->vendsub.text, XtNstring, &str, NULL); + XtFree(node->data->vendsub.vendsub->vs_name); + if (*str) + node->data->vendsub.vendsub->vs_name = XtNewString(str); + else + node->data->vendsub.vendsub->vs_name = NULL; +} + +static void +NewVendorSubCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfVendSubPtr vnd; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->vendsub.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + vnd = (XF86ConfVendSubPtr)XtCalloc(1, sizeof(XF86ConfVendSubRec)); + vnd->vs_identifier = XtNewString(label); + parent->parent->data->vendor.vendor->vnd_sub_lst = + xf86addVendorSub(parent->parent->data->vendor.vendor->vnd_sub_lst, vnd); + + CreateVendorSub(parent, vnd); + RelayoutTree(); +} + +/* DRI */ +static void +CreateDRI(TreeNode *parent, XF86ConfDRIPtr dri) +{ + TreeNode *node; + TreeData *data; + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->dri.dri = dri; + node = NewNode(parent, NULL, NULL, parent->node, data); + parent->child = node; + node->update = DRIUpdate; + CreateDRIField(node); +} + +static void +CreateDRIField(TreeNode *node) +{ + Widget box, toggle; + XF86ConfDRIPtr dri = node->data->dri.dri; + TreeNode *buffers; + char buf[32]; + + box = XtVaCreateWidget("dri", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + XtCreateManagedWidget("nameL", labelWidgetClass, box, NULL, 0); + node->data->dri.name = + XtVaCreateManagedWidget("name", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, + dri->dri_group_name ? dri->dri_group_name : "", + NULL); + + XtCreateManagedWidget("groupL", labelWidgetClass, box, NULL, 0); + if (dri->dri_group >= 0) + XmuSnprintf(buf, sizeof(buf), "%d", dri->dri_group); + else + *buf = '\0'; + node->data->dri.group = + XtVaCreateManagedWidget("group", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, buf, + NULL); + + XtCreateManagedWidget("modeL", labelWidgetClass, box, NULL, 0); + if (dri->dri_mode > 0) + XmuSnprintf(buf, sizeof(buf), "0%o", dri->dri_mode); + else + *buf = '\0'; + node->data->dri.mode = + XtVaCreateManagedWidget("mode", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, buf, + NULL); + + toggle = XtVaCreateManagedWidget("Buffers", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL); + buffers = NewNode(node, toggle, toggle, box, NULL); + node->child = buffers; + CreateBuffers(buffers, dri->dri_buffers_lst); + + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +DRIUpdate(TreeNode *node) +{ + char *str; + + /* name */ + XtVaGetValues(node->data->dri.name, XtNstring, &str, NULL); + XtFree(node->data->dri.dri->dri_group_name); + if (*str) + node->data->dri.dri->dri_group_name = XtNewString(str); + else + node->data->dri.dri->dri_group_name = NULL; + + /* group */ + XtVaGetValues(node->data->dri.group, XtNstring, &str, NULL); + if (*str) + node->data->dri.dri->dri_group = strtoul(str, NULL, 0); + else + node->data->dri.dri->dri_group = -1; + + /* mode */ + XtVaGetValues(node->data->dri.mode, XtNstring, &str, NULL); + node->data->dri.dri->dri_mode = strtoul(str, NULL, 0); +} + +/* Buffers */ +static void +CreateBuffers(TreeNode *parent, XF86ConfBuffersPtr buf) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (buf) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->buffers.buffers = buf; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = BuffersDestroy; + node->update = BuffersUpdate; + CreateBuffersField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + + buf = (XF86ConfBuffersPtr)(buf->list.next); + } + node = NewNode(parent, NULL, NULL, parent->node, NULL); + CreateBuffersField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateBuffersField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("buffers", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL); + node->node = box; + + if (!addnew) { + char str[32]; + XF86ConfBuffersPtr buf = node->data->buffers.buffers; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + + XtCreateManagedWidget("countL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(str, sizeof(str), "%d", buf->buf_count); + node->data->buffers.count = + XtVaCreateManagedWidget("count", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, str, + NULL); + + XtCreateManagedWidget("sizeL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(str, sizeof(str), "%d", buf->buf_size); + node->data->buffers.size = + XtVaCreateManagedWidget("size", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, str, + NULL); + + XtCreateManagedWidget("flagsL", labelWidgetClass, box, NULL, 0); + node->data->buffers.flags = + XtVaCreateManagedWidget("flags", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, + buf->buf_flags ? buf->buf_flags : "", + NULL); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewBuffersCallback, (XtPointer)node); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +BuffersDestroy(TreeNode *node) +{ + if (node->data->buffers.buffers) + xf86removeBuffers(XF86Config->conf_dri, node->data->buffers.buffers); +} + +/*ARGSUSED*/ +static void +NewBuffersCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfBuffersPtr buf; + + parent = node->parent; + DeleteNode(node); + buf = (XF86ConfBuffersPtr)XtCalloc(1, sizeof(XF86ConfBuffersRec)); + XF86Config->conf_dri->dri_buffers_lst = + xf86addBuffers(XF86Config->conf_dri->dri_buffers_lst, buf); + + CreateBuffers(parent, buf); + RelayoutTree(); +} + +static void +BuffersUpdate(TreeNode *node) +{ + char *str; + + /* count */ + XtVaGetValues(node->data->buffers.count, XtNstring, &str, NULL); + node->data->buffers.buffers->buf_count = strtoul(str, NULL, 0); + + /* size */ + XtVaGetValues(node->data->buffers.size, XtNstring, &str, NULL); + node->data->buffers.buffers->buf_size = strtoul(str, NULL, 0); + + /* flags */ + XtVaGetValues(node->data->buffers.flags, XtNstring, &str, NULL); + if (*str) + node->data->buffers.buffers->buf_flags = XtNewString(str); + else + node->data->buffers.buffers->buf_flags = NULL; +} + +static TreeNode * +NewNode(TreeNode *parent, Widget node, Widget toggle, Widget treeParent, + TreeData *data) +{ + TreeNode *tree = (TreeNode*)XtCalloc(1, sizeof(TreeNode)); + + tree->parent = parent; + tree->node = node; + if ((tree->toggle = toggle) != NULL) + XtAddCallback(toggle, XtNcallback, ToggleCallback, (XtPointer)tree); + tree->treeParent = treeParent; + tree->data = data; + + return (tree); +} + +static void +DeleteNode(TreeNode *node) +{ + TreeNode *ptr = node->child; + + while (ptr != NULL) { + TreeNode *next = ptr->next; + + DeleteNode(ptr); + ptr = next; + } + + if (node->parent && node->parent->child == node) + node->parent->child = node->next; + else if (node->parent) { + for (ptr = node->parent->child; ptr && ptr->next != node; + ptr = ptr->next) + ; + if (ptr) + ptr->next = node->next; + } + + if (node->destroy) + (node->destroy)(node); + if (node->data) + XtFree((XtPointer)node->data); + + /* sets treeParent to NULL so that RelayoutTree works correctly, + * as the tree will properly calculate it's new size. + */ + XtVaSetValues(node->node, XtNtreeParent, NULL, NULL); + + XtDestroyWidget(node->node); + XtFree((XtPointer)node); +} + +/*ARGUSED*/ +static void +DestroyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *node = (TreeNode*)user_data; + + DeleteNode(node); + RelayoutTree(); +} + +static void +ToggleNodeRecursive(TreeNode *node) +{ + while (node) { + if (!XtIsRealized(node->node)) + XtRealizeWidget(node->node); + XtVaSetValues(node->node, XtNtreeParent, node->treeParent, NULL); + XtManageChild(node->node); + + if (node->child && !node->toggle) + ToggleNodeRecursive(node->child); + + node = node->next; + } +} + +static void +ToggleNode(TreeNode *node, Bool toggle) +{ + while (node) { + if (toggle) { + if (!XtIsRealized(node->node)) + XtRealizeWidget(node->node); + XtVaSetValues(node->node, XtNtreeParent, node->treeParent, NULL); + XtManageChild(node->node); + + if (node->child && !node->toggle) + ToggleNodeRecursive(node->child); + } + else { + if (node->child) + ToggleNode(node->child, False); + XtVaSetValues(node->node, XtNtreeParent, NULL, NULL); + XtUnmanageChild(node->node); + if (node->toggle) + XtVaSetValues(node->toggle, XtNstate, False, NULL); + } + node = node->next; + } +} + +/* + * XXX This callback can show side effects in the way it is called. If + * the structure holding the XF86OptionPtr is reallocated, a bogus pointer + * will be passed to this callback. + */ +static void +OptionsCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XF86OptionPtr *options = (XF86OptionPtr*)user_data; + +#ifdef USE_MODULES + OptionsPopup(options, NULL, NULL); +#else + OptionsPopup(options); +#endif +} + +static void +RelayoutTree(void) +{ + Arg args[4]; + Dimension sliderWidth, sliderHeight, canvasWidth, canvasHeight; + + XtSetArg(args[0], XtNwidth, &sliderWidth); + XtSetArg(args[1], XtNheight, &sliderHeight); + XtGetValues(shell, args, 2); + + XtSetArg(args[2], XtNwidth, &canvasWidth); + XtSetArg(args[3], XtNheight, &canvasHeight); + XtGetValues(tree, args + 2, 2); + + XtSetArg(args[0], XtNsliderWidth, sliderWidth); + XtSetArg(args[1], XtNsliderHeight, sliderHeight); + XtSetArg(args[2], XtNcanvasWidth, canvasWidth); + XtSetArg(args[3], XtNcanvasHeight, canvasHeight); + XtSetValues(panner, args, 4); +} + +static void +ToggleCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *nodeParent = (TreeNode*)user_data; + + if (nodeParent->child) { + if (XtIsRealized(tree)) + XtUnmapWidget(tree); + ToggleNode(nodeParent->child, (Bool)(long)call_data); + RelayoutTree(); + if (XtIsRealized(tree)) + XtMapWidget(tree); + } +} + +/*ARGSUSED*/ +static void +PannerCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[2]; + XawPannerReport *rep = (XawPannerReport *)call_data; + + XtSetArg (args[0], XtNx, -rep->slider_x); + XtSetArg (args[1], XtNy, -rep->slider_y); + XtSetValues(tree, args, 2); +} + +/*ARGSUSED*/ +static void +PortholeCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawPannerReport *rep = (XawPannerReport*)call_data; + Arg args[6]; + Cardinal n = 2; + + XtSetArg (args[0], XtNsliderX, rep->slider_x); + XtSetArg (args[1], XtNsliderY, rep->slider_y); + if (rep->changed != (XawPRSliderX | XawPRSliderY)) { + XtSetArg (args[2], XtNsliderWidth, rep->slider_width); + XtSetArg (args[3], XtNsliderHeight, rep->slider_height); + XtSetArg (args[4], XtNcanvasWidth, rep->canvas_width); + XtSetArg (args[5], XtNcanvasHeight, rep->canvas_height); + n = 6; + } + XtSetValues(panner, args, n); +} + +static void +DestroyTree(TreeNode *node) +{ + while (node) { + TreeNode *next = node->next; + if (node->child) + DestroyTree(node->child); + + if (node->data) + XtFree((XtPointer)node->data); + XtFree((XtPointer)node); + + node = next; + } +} + +static void +UpdateConfig(TreeNode *node) +{ + while (node) { + if (node->child) + UpdateConfig(node->child); + if (node->update) + (node->update)(node); + node = node->next; + } +} + +static Bool +ExpertInitialize(void) +{ + Widget paned, vpane, close, config, files, modules, flags, video, modes, + monitor, device, screen, input, layout, vendor, dri; + Arg args[4]; + Dimension width, height, canvasWidth, canvasHeight; + TreeNode *node; + + if (expert != NULL) + return (False); + + shell = XtCreatePopupShell("Expert", transientShellWidgetClass, + toplevel, NULL, 0); + paned = XtVaCreateManagedWidget("paned", panedWidgetClass, shell, + XtNorientation, XtorientHorizontal, NULL); + vpane = XtCreateManagedWidget("vpane", panedWidgetClass, paned, NULL, 0); + panner = XtCreateManagedWidget ("panner", pannerWidgetClass, vpane, NULL, 0); + close = XtCreateManagedWidget("close", commandWidgetClass, vpane, NULL, 0); + XtAddCallback(close, XtNcallback, PopdownCallback, NULL); + + expert = XtCreateManagedWidget("expert", portholeWidgetClass, paned, NULL, 0); + XtAddCallback(expert, XtNreportCallback, PortholeCallback, NULL); + XtAddCallback(panner, XtNreportCallback, PannerCallback, NULL); + tree = XtCreateManagedWidget("tree", treeWidgetClass, expert, NULL, 0); + + config = XtVaCreateManagedWidget(__XCONFIGFILE__, toggleWidgetClass, tree, + XtNstate, True, NULL); + mainNode = NewNode(NULL, config, config, NULL, NULL); + + files = XtVaCreateManagedWidget("Files", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node = NewNode(mainNode, files, files, config, NULL); + mainNode->child = node; + CreateFiles(node); + + modules = XtVaCreateManagedWidget("Module", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, modules, modules, config, NULL); + node = node->next; + CreateModule(node, XF86Config->conf_modules ? + XF86Config->conf_modules->mod_load_lst : NULL); + + flags = XtVaCreateManagedWidget("ServerFlags", commandWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, flags, NULL, config, NULL); + node = node->next; + if (XF86Config->conf_flags == NULL) + XF86Config->conf_flags = (XF86ConfFlagsPtr) + XtCalloc(1, sizeof(XF86ConfFlagsRec)); + XtAddCallback(flags, XtNcallback, OptionsCallback, + (XtPointer)&(XF86Config->conf_flags->flg_option_lst)); + + video = XtVaCreateManagedWidget("VideoAdaptor", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, video, video, config, NULL); + node = node->next; + CreateVideoAdaptor(node, XF86Config->conf_videoadaptor_lst); + + modes = XtVaCreateManagedWidget("Mode", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, modes, modes, config, NULL); + node = node->next; + CreateModes(node, XF86Config->conf_modes_lst); + + monitor = XtVaCreateManagedWidget("Monitor", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, monitor, monitor, config, NULL); + node = node->next; + CreateMonitor(monitorTree = node, XF86Config->conf_monitor_lst); + + device = XtVaCreateManagedWidget("Device", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, device, device, config, NULL); + node = node->next; + CreateDevice(node, XF86Config->conf_device_lst); + + screen = XtVaCreateManagedWidget("Screen", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, screen, screen, config, NULL); + node = node->next; + CreateScreen(screenTree = node, XF86Config->conf_screen_lst); + + input = XtVaCreateManagedWidget("Input", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, input, input, config, NULL); + node = node->next; + CreateInput(node, XF86Config->conf_input_lst); + + layout = XtVaCreateManagedWidget("Layout", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, layout, layout, config, NULL); + node = node->next; + CreateLayout(layoutTree = node, XF86Config->conf_layout_lst); + + vendor = XtVaCreateManagedWidget("Vendor", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, vendor, vendor, config, NULL); + node = node->next; + CreateVendor(node, XF86Config->conf_vendor_lst); + + dri = XtVaCreateManagedWidget("DRI", toggleWidgetClass, tree, + XtNtreeParent, config, NULL); + node->next = NewNode(mainNode, dri, dri, config, NULL); + node = node->next; + if (XF86Config->conf_dri == NULL) + XF86Config->conf_dri = (XF86ConfDRIPtr) + XtCalloc(1, sizeof(XF86ConfDRIRec)); + CreateDRI(node, XF86Config->conf_dri); + + XtRealizeWidget(shell); + + XtSetArg(args[0], XtNwidth, &width); + XtSetArg(args[1], XtNheight, &height); + XtGetValues(shell, args, 2); + XtSetArg(args[0], XtNwidth, width); + XtSetArg(args[1], XtNheight, height); + XtSetValues(expert, args, 2); + + XtSetArg(args[0], XtNsliderWidth, width); + XtSetArg(args[1], XtNsliderHeight, height); + XtSetArg(args[2], XtNwidth, &canvasWidth); + XtSetArg(args[3], XtNheight, &canvasHeight); + XtGetValues(tree, args + 2, 2); + XtSetArg(args[2], XtNcanvasWidth, canvasWidth); + XtSetArg(args[3], XtNcanvasHeight, canvasHeight); + XtSetValues(panner, args, 4); + + /* needs to do the apparently NOP code bellow to correctly layout the + * tree widget */ + + /* close all open entries */ + ToggleCallback(config, mainNode, (XtPointer)0); + /* open first level */ + ToggleCallback(config, mainNode, (XtPointer)1); + + XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1); + + return (True); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/help.c b/xorg-server/hw/xfree86/utils/xorgcfg/help.c new file mode 100644 index 000000000..cd5c2c2f4 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/help.c @@ -0,0 +1,1785 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/Shell.h> +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Paned.h> + +#include <X11/Xaw/Text.h> +#include <X11/Xaw/TextSinkP.h> +#include <X11/Xaw/TextSrcP.h> +#include <X11/Xmu/SysUtil.h> +#include <X11/Xmu/Xmu.h> +#include <stdlib.h> /* for bsearch() */ +#include <ctype.h> +#include "help.h" +#include "options.h" + +/* + * Prototypes + */ +static void CloseCallback(Widget, XtPointer, XtPointer); +static void StartHelp(void); +void Html_ModeStart(Widget); + +/* + * Initialization + */ +static Widget shell, text; +static Bool popped_up = False; + +/* + * Implementation + */ +void +Help(char *topic) +{ + Widget source; + char *str = NULL; + Bool error = False; + static char *def_text = "<h2>Help Error</h2>" + "No help available for the topic <b>%s</b>."; + XtResource resource = { + NULL, "HelpMessage", XtRString, sizeof(char*), + 0, XtRString, NULL + }; + + StartHelp(); + source = XawTextGetSource(text); + XawTextSourceClearEntities(source, 0, + XawTextSourceScan(source, 0, XawstAll, + XawsdRight, 1, True)); + if (topic != NULL) { + resource.resource_name = topic; + XtGetApplicationResources(shell, (XtPointer)&str, + &resource, 1, NULL, 0); + } + if (str == NULL) { + int len; + + error = True; + if (topic == NULL) + topic = "(null argument)"; + str = XtMalloc(len = strlen(topic) + strlen(def_text) + 1); + XmuSnprintf(str, len, def_text, topic); + } + XtVaSetValues(text, XtNstring, str, NULL); + if (error) + XtFree(str); + + Html_ModeStart(source); + _XawTextBuildLineTable((TextWidget)text, + XawTextTopPosition(text), True); + XawTextDisplay(text); + if (popped_up == False) { + popped_up = True; + XtPopup(shell, XtGrabNone); + XtSetKeyboardFocus(shell, text); + } +} + +static void +StartHelp(void) +{ + static XtResource resource = { + "properties", "Properties", XtRString, sizeof(char*), + 0, XtRString, NULL + }; + + if (shell == NULL) { + Widget pane, commands, close; + char *props; + XawTextPropertyList *propl; + + shell = XtCreatePopupShell("help", transientShellWidgetClass, + toplevel, NULL, 0); + pane = XtCreateManagedWidget("pane", panedWidgetClass, + shell, NULL, 0); + text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, + pane, XtNeditType, XawtextRead, NULL); + commands = XtCreateManagedWidget("commands", formWidgetClass, pane, + NULL, 0); + close = XtCreateManagedWidget("close", commandWidgetClass, + commands, NULL, 0); + XtAddCallback(close, XtNcallback, CloseCallback, NULL); + XtRealizeWidget(shell); + XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1); + XtGetApplicationResources(text, (XtPointer)&props, + &resource, 1, NULL, 0); + propl = XawTextSinkConvertPropertyList("html", props, + toplevel->core.screen, + toplevel->core.colormap, + toplevel->core.depth); + XtVaSetValues(XawTextGetSink(text), XawNtextProperties, propl, NULL); + } +} + +/*ARGSUSED*/ +static void +CloseCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XtPopdown(shell); + popped_up = False; +} + +/*ARGSUSED*/ +void +HelpCancelAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + CloseCallback(w, NULL, NULL); +} + + +/* bellow is a modified version of the html-mode.c I wrote for xedit + * (at least) temporarily dead. + */ + +/* + * Copyright (c) 1999 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + * + * Author: Paulo César Pereira de Andrade + */ + +#define Html_Peek(parser) ((parser)->next) + +/* + * Types + */ +typedef struct _Html_Parser Html_Parser; +typedef struct _Html_Item Html_Item; + +typedef struct _Html_TagInfo { + char *name; + unsigned int entity : 1; /* it changes the type of the text */ + unsigned int nest : 1; /* does not close tags automatically */ + unsigned int end : 1; /* need a close markup */ + unsigned int adnl : 1; /* add newline before/after tag contents */ + unsigned int para : 1; /* changes the paragraph formatting */ + unsigned long mask; /* enforce use of attributes of this tag-info */ + unsigned long xlfd_mask; + void (*parse_args)(Html_Parser*, Html_Item*); + XawTextProperty *override; + XrmQuark ident; +} Html_TagInfo; + +struct _Html_Item { + XrmQuark ident; + XawTextPosition start, end; + Html_TagInfo *info; + + XawTextProperty *combine; + Bool override; + int li; + + XtPointer replace; + + Html_Item *parent, *child, *next; +}; + +struct _Html_Parser { + Widget source; + XawTextBlock block, replace; + XawTextPosition position, offset, start, end, last; + XrmQuark quark; + int i, ch, next; + Html_Item *item, *head; + XmuScanline *mask; + int space, pre, adnl, list, desc, column; + Bool spc; + XawTextBlock *entity; + + Pixel alink; +}; + +typedef struct _Html_SourceInfo Html_SourceInfo; +struct _Html_SourceInfo { + Widget source; + XawTextBlock block; + XawTextPosition last; + Html_SourceInfo *next; +}; + +/* + * Proptotypes + */ +void Html_ModeEnd(Widget); +static void Html_ModeInit(void); +static void Html_ParseCallback(Widget, XtPointer, XtPointer); +static Html_TagInfo *Html_GetInfo(char*); +static int Html_Get(Html_Parser*); +static int Html_Parse1(Html_Parser*); +static int Html_Parse2(Html_Parser*); +static void Html_ParseTag(Html_Parser*); +static void Html_Commit(Html_Parser*); +static void Html_AddEntities(Html_Parser*, Html_Item*); + +static int Html_Put(Html_Parser*, int); +static void Html_Puts(Html_Parser*, char*); +static int Html_Format1(Html_Parser*); +static int Html_Format2(Html_Parser*); +static int Html_Format3(Html_Parser*); +static void Html_FormatTag(Html_Parser*); + +static void Html_AArgs(Html_Parser*, Html_Item*); +static void Html_FontArgs(Html_Parser*, Html_Item*); + +/* + * Initialization + */ +static XrmQuark + Qbr, + Qdefault, + Qdd, + Qdl, + Qdt, + Qentity, + Qetag, + Qhide, + Qli, + Qol, + Qp, + Qpre, + Qspace, + Qtag, + Qul; + +static Html_TagInfo tag_info[] = { + {"a", 1, 0, 1, 0, 0, + 0, 0, + Html_AArgs}, + {"address", 1, 0, 1, 0, 0, + 0, XAW_TPROP_SLANT, + }, + {"b", 1, 0, 1, 0, 0, + 0, XAW_TPROP_WEIGHT, + }, + {"blockquote", 0, 1, 1, 1, 1, + 0, 0, + }, + {"body", 0, 0, 1, 0, 0, + 0, 0, + }, + {"br", 0, 0, 0, 0, 0, + }, + {"code", 1, 0, 1, 0, 0, + 0, XAW_TPROP_FAMILY | XAW_TPROP_PIXELSIZE, + }, + {"dd", 0, 1, 1, 0, 1, + 0, 0}, + {"dl", 0, 1, 1, 0, 0, + 0, 0, + }, + {"dt", 0, 0, 1, 0, 0, + 0, 0}, + {"em", 1, 0, 1, 0, 0, + 0, XAW_TPROP_SLANT, + }, + {"font", 1, 1, 1, 0, 0, + 0, 0, + Html_FontArgs}, + {"h1", 1, 0, 1, 1, 0, + 0, XAW_TPROP_WEIGHT | XAW_TPROP_PIXELSIZE, + }, + {"h2", 1, 0, 1, 1, 0, + 0, XAW_TPROP_WEIGHT | XAW_TPROP_PIXELSIZE, + }, + {"h3", 1, 0, 1, 1, 0, + 0, XAW_TPROP_WEIGHT | XAW_TPROP_PIXELSIZE, + }, + {"h4", 1, 0, 1, 1, 0, + 0, XAW_TPROP_WEIGHT | XAW_TPROP_PIXELSIZE, + }, + {"h5", 1, 0, 1, 1, 0, + 0, XAW_TPROP_WEIGHT | XAW_TPROP_PIXELSIZE, + }, + {"h6", 1, 0, 1, 1, 0, + 0, XAW_TPROP_WEIGHT | XAW_TPROP_PIXELSIZE, + }, + {"head", 0, 0, 1, 0, 0, + 0, 0, + }, + {"html", 0, 0, 1, 0, 0, + 0, 0, + }, + {"i", 1, 0, 1, 0, 0, + 0, XAW_TPROP_SLANT, + }, + {"kbd", 1, 0, 1, 0, 0, + 0, XAW_TPROP_FAMILY | XAW_TPROP_PIXELSIZE, + }, + {"li", 0, 0, 0, 0, 0, + 0, 0}, + {"ol", 0, 1, 1, 0, 1, + 0, 0, + }, + {"p", 0, 0, 0, 1, 0, + }, + {"pre", 1, 0, 1, 1, 0, + 0, XAW_TPROP_FAMILY | XAW_TPROP_PIXELSIZE, + }, + {"samp", 1, 0, 1, 0, 0, + 0, XAW_TPROP_FAMILY | XAW_TPROP_PIXELSIZE, + }, + {"strong", 1, 0, 1, 0, 0, + 0, XAW_TPROP_WEIGHT, + }, + {"tt", 1, 0, 1, 0, 0, + 0, XAW_TPROP_FAMILY | XAW_TPROP_PIXELSIZE, + }, + {"ul", 0, 1, 1, 0, 1, + 0, 0, + }, +}; + +static char *pnl = "<p>\n", *nlpnl = "\n<p>\n"; +static Html_SourceInfo *source_info; + +/* + * Implementation + */ +static char * +Html_GetText(Widget src, XawTextPosition position) +{ + char *result, *tempResult; + XawTextPosition offset = 0; + XawTextBlock text; + + tempResult = result = XtMalloc((unsigned)(position + 1)); + + while (offset < position) { + offset = XawTextSourceRead(src, offset, &text, position - offset); + if (!text.length) + break; + memcpy(tempResult, text.ptr, (unsigned)text.length); + tempResult += text.length; + } + + *tempResult = '\0'; + + return (result); +} + +void +Html_ModeStart(Widget src) +{ + Html_Parser *parser = XtNew(Html_Parser); + Html_Item *next, *item; + XColor color, exact; + Html_SourceInfo *info = XtNew(Html_SourceInfo); + + if (XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, + "blue", &color, &exact)) + parser->alink = color.pixel; + else + parser->alink = 0L; + + XtVaSetValues(src, XtNeditType, XawtextEdit, NULL); + + Html_ModeInit(); + + /* initialize parser state */ + parser->source = src; + parser->position = XawTextSourceRead(parser->source, 0, + &parser->block, 4096); + parser->replace.ptr = NULL; + parser->replace.firstPos = 0; + parser->replace.length = 0; + parser->replace.format = FMT8BIT; + parser->offset = -1; + parser->quark = NULLQUARK; + parser->i = 0; + parser->i = parser->ch = parser->next = 0; + parser->last = XawTextSourceScan(src, 0, XawstAll, XawsdRight, 1, 1); + if (parser->block.length == 0) + parser->ch = parser->next = EOF; + else + (void)Html_Get(parser); + parser->pre = 0; + parser->adnl = 1; + parser->list = parser->desc = parser->column = 0; + parser->spc = True; + + info->source = src; + info->block.ptr = Html_GetText(src, parser->last); + info->block.length = parser->last; + info->block.format = FMT8BIT; + info->block.firstPos = 0; + info->next = NULL; + if (source_info == NULL) + source_info = info; + else { + Html_SourceInfo *tmp = source_info; + + while (tmp->next) + tmp = tmp->next; + tmp->next = info; + } + + while (Html_Format1(parser) != EOF) + ; + XawTextSourceReplace(parser->source, 0, parser->last, &parser->replace); + XtFree(parser->replace.ptr); + + /* re-initialize parser state */ + parser->position = XawTextSourceRead(parser->source, 0, + &parser->block, 4096); + parser->offset = -1; + parser->quark = NULLQUARK; + parser->i = parser->ch = parser->next = 0; + parser->last = XawTextSourceScan(src, 0, XawstAll, XawsdRight, 1, 1); + info->last = parser->last; + if (parser->block.length == 0) + parser->ch = parser->next = EOF; + else + (void)Html_Get(parser); + parser->adnl = 1; + parser->list = parser->desc = parser->column = 0; + parser->spc = True; + parser->head = parser->item = NULL; + + parser->mask = XmuNewScanline(0, 0, 0); + + /* build html structure information */ + while (Html_Parse1(parser) != EOF) + ; + + /* create top level entity mask */ + (void)XmuScanlineNot(parser->mask, 0, parser->last); + + item = parser->item; + while (item) { + next = item->next; + Html_AddEntities(parser, item); + if (item->combine) + XtFree((XtPointer)item->combine); + XtFree((XtPointer)item); + item = next; + } + XmuDestroyScanline(parser->mask); + + XtVaSetValues(src, XtNeditType, XawtextRead, NULL); + + XtFree((XtPointer)parser); + + /* add callbacks for interactive changes */ + XtAddCallback(src, XtNpropertyCallback, Html_ParseCallback, NULL); +} + +void +Html_ModeEnd(Widget src) +{ + Html_SourceInfo *info, *pinfo; + + XtRemoveCallback(src, XtNpropertyCallback, Html_ParseCallback, NULL); + for (pinfo = info = source_info; info; pinfo = info, info = info->next) + if (info->source == src) + break; + + if (info == NULL) + return; + + XawTextSourceClearEntities(src, 0, info->last); + XtVaSetValues(src, XtNeditType, XawtextEdit, NULL); + XawTextSourceReplace(src, 0, info->last, &info->block); + XtVaSetValues(src, XtNeditType, XawtextRead, NULL); + + if (info == source_info) + source_info = source_info->next; + else + pinfo->next = info->next; + XtFree(info->block.ptr); + XtFree((XtPointer)info); +} + +static void +Html_ParseCallback(Widget w, XtPointer client_data, XtPointer call_data) +{ +} + +static int +bcmp_tag_info(_Xconst void *left, _Xconst void *right) +{ + return (strcmp((char*)left, ((Html_TagInfo*)right)->name)); +} + +static Html_TagInfo * +Html_GetInfo(char *name) +{ + return (bsearch(name, tag_info, sizeof(tag_info) / sizeof(tag_info[0]), + sizeof(Html_TagInfo), bcmp_tag_info)); +} + +static int +Html_Get(Html_Parser *parser) +{ + if (parser->ch == EOF) + return (EOF); + if (parser->i >= parser->block.length) { + parser->i = 0; + parser->position = XawTextSourceRead(parser->source, parser->position, + &parser->block, 4096); + } + parser->ch = parser->next; + if (parser->block.length == 0) + parser->next = EOF; + else + parser->next = (unsigned char)parser->block.ptr[parser->i++]; + parser->offset++; + + return (parser->ch); +} + +static void +Html_ModeInit(void) +{ + static int initialized; + int i; + + if (initialized) + return; + + Qbr = XrmPermStringToQuark("br"); + Qdd = XrmPermStringToQuark("dd"); + Qdefault = XrmPermStringToQuark("default"); + Qdl = XrmPermStringToQuark("dl"); + Qdt = XrmPermStringToQuark("dt"); + Qentity = XrmPermStringToQuark("entity"); + Qetag = XrmPermStringToQuark("/tag"); + Qhide = XrmPermStringToQuark("hide"); + Qli = XrmPermStringToQuark("li"); + Qol = XrmPermStringToQuark("ol"); + Qp = XrmPermStringToQuark("p"); + Qpre = XrmPermStringToQuark("pre"); + Qspace = XrmPermStringToQuark("space"); + Qtag = XrmPermStringToQuark("tag"); + Qul = XrmPermStringToQuark("ul"); + + for (i = 0; i < sizeof(tag_info) / sizeof(tag_info[0]); i++) + tag_info[i].ident = XrmPermStringToQuark(tag_info[i].name); + + initialized = True; +} + +/************************************************************************/ +/* PARSE */ +/************************************************************************/ +static void +Html_AddEntities(Html_Parser *parser, Html_Item *item) +{ + Html_Item *parent, *next, *child = item->child; + XmuSegment segment, *ent; + XmuScanline *mask = XmuNewScanline(0, 0, 0); + XawTextProperty *tprop, *property = NULL; + Widget sink; + Bool changed = False; + + /* combine properties */ + if (item->info && + (item->info->entity || + (item->parent && item->parent->ident != item->parent->info->ident))) { + sink = XawTextGetSink(text); + parent = item->parent; + property = XawTextSinkCopyProperty(sink, item->ident); + property->mask = item->info->mask; + property->xlfd_mask = item->info->xlfd_mask; + if (parent) { + (void)XawTextSinkCombineProperty(sink, property, + XawTextSinkGetProperty(sink, parent->ident), False); + if (item->combine && parent->combine) + (void)XawTextSinkCombineProperty(sink, item->combine, + parent->combine, + item->override); + } + if (item->combine) + XawTextSinkCombineProperty(sink, property, item->combine, True); + tprop = property; + property = XawTextSinkAddProperty(sink, property); + XtFree((XtPointer)tprop); + if (property && item->ident != property->identifier) { + item->ident = property->identifier; + changed = True; + } + } + + if (item->end < 0) { + if (item->next) + item->end = item->next->start; + else if (item->parent) + item->end = item->parent->end; + else + item->end = parser->last; + } + + while (child) { + next = child->next; + segment.x1 = child->start; + segment.x2 = child->end; + (void)XmuScanlineOrSegment(mask, &segment); + Html_AddEntities(parser, child); + if (child->combine) + XtFree((XtPointer)child->combine); + XtFree((XtPointer)child); + child = next; + } + + /* build entity mask */ + (void)XmuScanlineNot(mask, item->start, item->end); + (void)XmuScanlineAnd(mask, parser->mask); + + /* add entities */ + if (item->info && changed) { + for (ent = mask->segment; ent; ent = ent->next) + (void)XawTextSourceAddEntity(parser->source, 0, 0, NULL, ent->x1, + ent->x2 - ent->x1, item->ident); + } + else if (item->info == NULL) + (void)XawTextSourceAddEntity(parser->source, 0, + XAW_TENTF_READ | XAW_TENTF_REPLACE, + item->replace, item->start, + item->end - item->start, + item->parent->ident); + + /* set mask for parent entities */ + (void)XmuScanlineOr(parser->mask, mask); + XmuDestroyScanline(mask); + +#if 0 + if (item->info && item->info->para) { + XawTextSourceSetParagraph(parser->source, item->start, item->end, + 40, /* arbitrary value, for testing */ + 0, 0); + } +#endif +} + +static void +Html_Commit(Html_Parser *parser) +{ + XawTextPosition position; + int length; + + position = parser->start; + length = parser->end - parser->start; + if (position < 0) { + length += position; + position = 0; + } + if (position + length > parser->last + 1) + length -= (position + length) - parser->last + 1; + + if (parser->quark != Qdefault && parser->quark != NULLQUARK && length > 0) { + XmuSegment segment; + Html_Item *head = parser->head; + XrmQuark quark = parser->quark; + + parser->quark = Qdefault; + + if (quark == Qli && head && + (head->info->ident == Qol || head->info->ident == Qul)) { + if (parser->head == NULL || head->info->ident != Qol) + XawTextSourceAddEntity(parser->source, 0, /*XAW_TENT_BULLET,*/ + XAW_TENTF_HIDE, NULL, + position, length, Qli); + else + XawTextSourceAddEntity(parser->source, 0, /*XAW_TENT_LITEM,*/ + XAW_TENTF_HIDE, + (XtPointer)(long)head->li++, + position, length, Qli); + } + else if (quark == Qhide) + XawTextSourceAddEntity(parser->source, 0, XAW_TENTF_HIDE, NULL, + position, length, quark); + else if (quark == Qentity) { + if (head && head->end == -1) { + Html_Item *item, *it; + + item = XtNew(Html_Item); + item->ident = Qentity; + item->start = position; + item->end = position + length; + item->info = NULL; + item->combine = NULL; + item->override = False; + item->replace = (XtPointer)parser->entity; + item->child = item->next = NULL; + + it = head->child; + + item->parent = head; + if (it == NULL) + head->child = item; + else { + while (it->next) + it = it->next; + it->next = item; + } + + return; + } + XawTextSourceAddEntity(parser->source, 0, + XAW_TENTF_READ | XAW_TENTF_REPLACE, + (XtPointer)parser->entity, + position, length, Qentity); + } + + segment.x1 = position; + segment.x2 = position + length; + (void)XmuScanlineOrSegment(parser->mask, &segment); + } +} + +static void +Html_ParseTag(Html_Parser *parser) +{ + int ch, sz; + char buf[32]; + Html_TagInfo *info; + Html_Item *item = NULL; + XawTextPosition offset = parser->offset - 1; + + switch (Html_Peek(parser)) { + case '!': + (void)Html_Get(parser); /* eat `!' */ + if (Html_Peek(parser) == '-') { + /* comment */ + (void)Html_Get(parser); /* eat `-' */ + if (Html_Peek(parser) == '-') { + int count = 0; + + (void)Html_Get(parser); + while ((ch = Html_Peek(parser)) != EOF) { + if (ch == '>' && count >= 2) + break; + else if (ch == '-') + ++count; + else + count = 0; + (void)Html_Get(parser); + } + } + } + break; + case '?': + break; + case '/': + (void)Html_Get(parser); /* eat `/' */ + sz = 0; + while (isalnum(Html_Peek(parser)) && + ((sz + 1) < sizeof(buf))) + buf[sz++] = tolower(Html_Get(parser)); + buf[sz] = '\0'; + if ((info = Html_GetInfo(buf)) != NULL) { + if (parser->head) { + Html_Item *it = parser->head; + + while (it) { + if (it->info == info) + break; + it = it->parent; + } + + if (it) { + if (it == parser->head) + parser->head->end = offset; + else { + it->end = offset; + do { + parser->head->end = offset; + parser->head = parser->head->parent; + } while (parser->head != it); + } + if (parser->head->parent) + parser->head = parser->head->parent; + else + parser->head = parser->item; + } + } + } + break; + default: + sz = 0; + while (isalnum(Html_Peek(parser)) && + ((sz + 1) < sizeof(buf))) + buf[sz++] = tolower(Html_Get(parser)); + buf[sz] = '\0'; + if ((info = Html_GetInfo(buf)) != NULL) { + if (info->end == False) { + if (info->ident == Qli) + parser->quark = Qli; + if (!info->para) + break; /* no more processing required */ + } + item = XtNew(Html_Item); + item->info = info; + item->ident = item->info->ident; + item->combine = NULL; + item->override = False; + item->start = item->end = -1; + if (info->ident == Qol) + item->li = 1; + else + item->li = 0; + item->parent = item->child = item->next = NULL; + if (parser->item == NULL) + parser->item = parser->head = item; + else if (parser->head->end == -1) { + if (parser->head->info != item->info || info->nest) { + Html_Item *it = parser->head; + + /* first, see if we need to close a long list of tags */ + if (info->ident == Qdd) { + if (parser->head && + parser->head->info->ident == Qdt) { + parser->head->end = offset; + parser->head = parser->head->parent; + } + } + else if (info->ident == Qdt) { + if (parser->head && + parser->head->info->ident == Qdd) { + parser->head->end = offset; + parser->head = parser->head->parent; + } + } + else if (!info->nest) { + while (it) { + if (it->info == info || it->info->end) + break; + it = it->parent; + } + if (it) { + /* close the items */ + while (parser->head != it) { + if (parser->head->info->ident == Qpre) + --parser->pre; + parser->head->end = offset; + parser->head = parser->head->parent; + } + } + } + + /* add child item */ + it = parser->head->child; + + item->parent = parser->head; + if (it == NULL) + parser->head->child = item; + else { + while (it->next) + it = it->next; + it->next = item; + } + parser->head = item; + } + else { + /* close the `head' item and start a new one */ + Html_Item *it; + + parser->head->end = offset; + if (parser->head->parent) + parser->head = parser->head->parent; + else + parser->head = parser->item; + + if ((it = parser->head->child) != NULL) { + item->parent = parser->head; + while (it->next) + it = it->next; + it->next = item; + parser->head = item; + } + else { + parser->head->child = item; + parser->head = item; + } + } + } + else { + /* this is not common, but handle it */ + Html_Item *it = parser->item; + + while (it->next) + it = it->next; + it->next = item; + parser->head = item; + } + if (info->parse_args) + (info->parse_args)(parser, item); + } + break; + } + + /* skip anything not processed */ + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) + (void)Html_Get(parser); + if (item && item->start == -1) + item->start = parser->offset + 1; +} + +/* tags */ +static int +Html_Parse2(Html_Parser *parser) +{ + int ch; + + for (;;) { + if ((ch = Html_Get(parser)) == '<') { + parser->end = parser->offset - 1; + Html_Commit(parser); + parser->quark = Qhide; + parser->start = parser->end; + + Html_ParseTag(parser); + + (void)Html_Get(parser); /* eat `>' */ + parser->end = parser->offset; + Html_Commit(parser); + } + else + return (ch); + } + /*NOTREACHED*/ +} + +/* entities */ +static int +Html_Parse1(Html_Parser *parser) +{ + static XawTextBlock *entities[256]; + static char chars[256]; + int ch; + + for (;;) { + if ((ch = Html_Parse2(parser)) == EOF) + return (EOF); + + if (ch == '&') { + unsigned char idx = '?'; + char buf[32]; + int sz = 0; + + /* the string comparisons need a big optmization! */ + parser->end = parser->offset - 1; + Html_Commit(parser); + parser->start = parser->end; + while ((ch = Html_Peek(parser)) != ';' + && ch != EOF && !isspace(ch)) { + ch = Html_Get(parser); + if (sz + 1 < sizeof(buf)) + buf[sz++] = ch; + } + buf[sz] = '\0'; + if (ch == ';') + (void)Html_Get(parser); + if (sz == 0) + idx = '&'; + else if (strcasecmp(buf, "lt") == 0) + idx = '<'; + else if (strcasecmp(buf, "gt") == 0) + idx = '>'; + else if (strcasecmp(buf, "nbsp") == 0) + idx = ' '; + else if (strcasecmp(buf, "amp") == 0) + idx = '&'; + else if (strcasecmp(buf, "quot") == 0) + idx = '"'; + else if (*buf == '#') { + if (sz == 1) + idx = '#'; + else { + char *tmp; + + idx = strtol(buf + 1, &tmp, 10); + if (*tmp) + idx = '?'; + } + } + else if (strcmp(buf + 1, "acute") == 0) { + switch (*buf) { + case 'a': idx = 0xe1; break; case 'e': idx = 0xe9; break; + case 'i': idx = 0xed; break; case 'o': idx = 0xf3; break; + case 'u': idx = 0xfa; break; case 'A': idx = 0xc1; break; + case 'E': idx = 0xc9; break; case 'I': idx = 0xcd; break; + case 'O': idx = 0xd3; break; case 'U': idx = 0xda; break; + case 'y': idx = 0xfd; break; case 'Y': idx = 0xdd; break; + } + } + else if (strcmp(buf + 1, "grave") == 0) { + switch (*buf) { + case 'a': idx = 0xe0; break; case 'e': idx = 0xe8; break; + case 'i': idx = 0xec; break; case 'o': idx = 0xf2; break; + case 'u': idx = 0xf9; break; case 'A': idx = 0xc0; break; + case 'E': idx = 0xc8; break; case 'I': idx = 0xcc; break; + case 'O': idx = 0xd2; break; case 'U': idx = 0xd9; break; + } + } + else if (strcmp(buf + 1, "tilde") == 0) { + switch (*buf) { + case 'a': idx = 0xe3; break; case 'o': idx = 0xf5; break; + case 'n': idx = 0xf1; break; case 'A': idx = 0xc3; break; + case 'O': idx = 0xd5; break; case 'N': idx = 0xd1; break; + } + } + else if (strcmp(buf + 1, "circ") == 0) { + switch (*buf) { + case 'a': idx = 0xe2; break; case 'e': idx = 0xea; break; + case 'i': idx = 0xee; break; case 'o': idx = 0xf4; break; + case 'u': idx = 0xfb; break; case 'A': idx = 0xc2; break; + case 'E': idx = 0xca; break; case 'I': idx = 0xce; break; + case 'O': idx = 0xd4; break; case 'U': idx = 0xdb; break; + } + } + else if (strcmp(buf + 1, "uml") == 0) { + switch (*buf) { + case 'a': idx = 0xe4; break; case 'e': idx = 0xeb; break; + case 'i': idx = 0xef; break; case 'o': idx = 0xf6; break; + case 'u': idx = 0xfc; break; case 'A': idx = 0xc4; break; + case 'E': idx = 0xcb; break; case 'I': idx = 0xfc; break; + case 'O': idx = 0xd6; break; case 'U': idx = 0xdc; break; + case 'y': idx = 0xff; break; + } + } + else if (strcmp(buf + 1, "cedil") == 0) { + switch (*buf) { + case 'c': idx = 0xe7; break; case 'C': idx = 0xc7; break; + } + } + else if (strcmp(buf + 1, "slash") == 0) { + switch (*buf) { + case 'o': idx = 0xf8; break; case 'O': idx = 0xd8; break; + } + } + else if (strcmp(buf + 1, "ring") == 0) { + switch (*buf) { + case 'a': idx = 0xe5; break; case 'A': idx = 0xc5; break; + } + } + else if (strcasecmp(buf, "iexcl") == 0) + idx = 0xa1; + else if (strcasecmp(buf, "cent") == 0) + idx = 0xa2; + else if (strcasecmp(buf, "pound") == 0) + idx = 0xa3; + else if (strcasecmp(buf, "curren") == 0) + idx = 0xa4; + else if (strcasecmp(buf, "yen") == 0) + idx = 0xa5; + else if (strcasecmp(buf, "brvbar") == 0) + idx = 0xa6; + else if (strcasecmp(buf, "sect") == 0) + idx = 0xa7; + else if (strcasecmp(buf, "uml") == 0) + idx = 0xa8; + else if (strcasecmp(buf, "copy") == 0) + idx = 0xa9; + else if (strcasecmp(buf, "ordf") == 0) + idx = 0xaa; + else if (strcasecmp(buf, "laquo") == 0) + idx = 0xab; + else if (strcasecmp(buf, "not") == 0) + idx = 0xac; + else if (strcasecmp(buf, "shy") == 0) + idx = 0xad; + else if (strcasecmp(buf, "reg") == 0) + idx = 0xae; + else if (strcasecmp(buf, "macr") == 0) + idx = 0xaf; + else if (strcasecmp(buf, "deg") == 0) + idx = 0xb0; + else if (strcasecmp(buf, "plusmn") == 0) + idx = 0xb1; + else if (strcasecmp(buf, "sup2") == 0) + idx = 0xb2; + else if (strcasecmp(buf, "sup3") == 0) + idx = 0xb3; + else if (strcasecmp(buf, "acute") == 0) + idx = 0xb4; + else if (strcasecmp(buf, "micro") == 0) + idx = 0xb5; + else if (strcasecmp(buf, "para") == 0) + idx = 0xb6; + else if (strcasecmp(buf, "middot") == 0) + idx = 0xb7; + else if (strcasecmp(buf, "cedil") == 0) + idx = 0xb8; + else if (strcasecmp(buf, "supl") == 0) + idx = 0xb9; + else if (strcasecmp(buf, "ordm") == 0) + idx = 0xba; + else if (strcasecmp(buf, "raquo") == 0) + idx = 0xbb; + else if (strcasecmp(buf, "frac14") == 0) + idx = 0xbc; + else if (strcasecmp(buf, "frac12") == 0) + idx = 0xbd; + else if (strcasecmp(buf, "frac34") == 0) + idx = 0xbe; + else if (strcasecmp(buf, "iquest") == 0) + idx = 0xbf; + else if (strcasecmp(buf, "AElig") == 0) + idx = 0xc6; + else if (strcasecmp(buf, "ETH") == 0) + idx = 0xd0; + else if (strcasecmp(buf, "THORN") == 0) + idx = 0xde; + else if (strcasecmp(buf, "szlig") == 0) + idx = 0xdf; + else if (strcasecmp(buf, "aelig") == 0) + idx = 0xe6; + else if (strcasecmp(buf, "eth") == 0) + idx = 0xf0; + else if (strcasecmp(buf, "thorn") == 0) + idx = 0xfe; + + parser->quark = Qentity; + if (entities[idx] == NULL) { + entities[idx] = XtNew(XawTextBlock); + entities[idx]->firstPos = 0; + entities[idx]->length = 1; + entities[idx]->ptr = chars + idx; + entities[idx]->format = FMT8BIT; + chars[idx] = idx; + } + parser->entity = entities[idx]; + parser->end = parser->offset; + Html_Commit(parser); + parser->start = parser->end; + } + } + /*NOTREACHED*/ +} + +/************************************************************************/ +/* FORMAT */ +/************************************************************************/ +static int +Html_Put(Html_Parser *parser, int ch) +{ + if (ch != '\r') { + if (parser->replace.length % 4096 == 0) + parser->replace.ptr = XtRealloc(parser->replace.ptr, + parser->replace.length + 4096); + parser->replace.ptr[parser->replace.length++] = ch; + } + + return (ch); +} + +static void +Html_Puts(Html_Parser *parser, char *str) +{ + int len = strlen(str); + + if (parser->replace.length % 4096 == 0 || + parser->replace.length + len > parser->replace.length + + (4096 - (parser->replace.length % 4096))) + parser->replace.ptr = XtRealloc(parser->replace.ptr, + parser->replace.length + 4096); + memcpy(parser->replace.ptr + parser->replace.length, str, len); + parser->replace.length += len; +} + +static void +Html_FormatTag(Html_Parser *parser) +{ + int ch = 0, sz = 0; + char buf[32]; + Html_TagInfo *info = NULL; + + switch (Html_Peek(parser)) { + case '!': + Html_Put(parser, '<'); + Html_Put(parser, Html_Get(parser)); /* eat `!' */ + if (Html_Peek(parser) == '-') { + /* comment */ + Html_Put(parser, Html_Get(parser)); /* eat `-' */ + if (Html_Peek(parser) == '-') { + int count = 0; + + Html_Put(parser, Html_Get(parser)); + while ((ch = Html_Peek(parser)) != EOF) { + if (ch == '>' && count >= 2) + break; + else if (ch == '-') + ++count; + else + count = 0; + Html_Put(parser, Html_Get(parser)); + } + (void)Html_Get(parser); /* eat `>' */ + Html_Put(parser, '>'); + return; + } + } + break; + case '?': + Html_Put(parser, '<'); + break; + case '/': + (void)Html_Get(parser); /* eat `/' */ + while (isalnum(Html_Peek(parser)) && + ((sz + 1) < sizeof(buf))) + buf[sz++] = ch = tolower(Html_Get(parser)); + buf[sz] = '\0'; + if ((info = Html_GetInfo(buf)) != NULL && info->adnl) { + if (info->ident == Qpre && parser->pre) { + if (--parser->pre == 0) + parser->column = 0; + } + parser->quark = Qetag; + parser->spc = True; + if (info->ident == Qp) { + while ((ch = Html_Peek(parser) != '>' && ch != EOF)) + (void)Html_Get(parser); + (void)Html_Get(parser); /* eat '>' */ + return; + } + } + else if (info) { + if (info->ident == Qol || info->ident == Qul) { + if (parser->list && --parser->list == 0 && + parser->desc == 0) { + parser->quark = Qetag; + Html_Put(parser, '\n'); + ++parser->adnl; + parser->column = 0; + } + } + else if (info->ident == Qdl) { + if (parser->desc && --parser->desc == 0 && + parser->list == 0) { + parser->quark = Qetag; + Html_Put(parser, '\n'); + ++parser->adnl; + parser->column = 0; + } + } + } + Html_Puts(parser, "</"); + Html_Puts(parser, buf); + break; + default: + while (isalnum(Html_Peek(parser)) && + ((sz + 1) < sizeof(buf))) + buf[sz++] = tolower(Html_Get(parser)); + buf[sz] = '\0'; + if ((info = Html_GetInfo(buf)) != NULL && info->adnl) { + if (info->ident == Qpre) + ++parser->pre; + if (parser->quark != Qtag) { + if (parser->adnl < 2) { + Html_Puts(parser, parser->adnl ? pnl : nlpnl); + parser->adnl = 2; + parser->spc = True; + parser->column = 0; + } + } + parser->quark = Qtag; + if (info->ident == Qp) { + while ((ch = Html_Peek(parser) != '>' && ch != EOF)) + (void)Html_Get(parser); + (void)Html_Get(parser); /* eat '>' */ + return; + } + } + else if (info) { + if (info->ident == Qol || info->ident == Qul) { + if (++parser->list == 1 && !parser->desc) { + if (parser->adnl < 2) { + Html_Puts(parser, parser->adnl ? pnl : nlpnl); + parser->adnl = 2; + parser->column = 0; + } + } + else if (parser->adnl == 0) { + Html_Put(parser, '\n'); + parser->adnl = 1; + parser->column = 0; + } + parser->spc = True; + } + else if (info->ident == Qli) { + if (parser->adnl == 0) { + Html_Put(parser, '\n'); + parser->adnl = 1; + parser->column = 0; + } + } + + else if (info->ident == Qdl) { + if (++parser->desc == 1 && !parser->list) { + if (parser->adnl < 2) { + Html_Puts(parser, parser->adnl ? pnl : nlpnl); + parser->adnl = 2; + parser->column = 0; + } + } + else if (parser->adnl == 0) { + Html_Put(parser, '\n'); + parser->adnl = 1; + parser->column = 0; + } + parser->spc = True; + } + else if (info->ident == Qdd) { + if (parser->desc == 0) { + if (parser->adnl < 2) { + Html_Puts(parser, parser->adnl ? pnl : nlpnl); + parser->adnl = 2; + parser->column = 0; + } + } + else if (parser->adnl == 0) { + Html_Put(parser, '\n'); + parser->adnl = 1; + parser->column = 0; + } + parser->spc = True; + } + else if (info->ident == Qdt) { + if (parser->adnl == 0) { + Html_Put(parser, '\n'); + parser->adnl = 1; + parser->spc = True; + parser->column = 0; + } + } + } + Html_Put(parser, '<'); + Html_Puts(parser, buf); + break; + } + + sz = 0; + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) { + if (isspace(ch)) { + (void)Html_Get(parser); + ++sz; + continue; + } + else if (sz) { + Html_Put(parser, ' '); + sz = 0; + } + Html_Put(parser, Html_Get(parser)); + } + Html_Put(parser, Html_Get(parser)); /* eat `>' */ + if (info && info->ident == Qbr) { + ++parser->adnl; + parser->spc = True; + Html_Put(parser, '\n'); + parser->quark = info->ident; + parser->column = 0; + } +} + +/* tags */ +static int +Html_Format3(Html_Parser *parser) +{ + int ch; + + for (;;) { + if ((ch = Html_Get(parser)) == '<') { + if (parser->quark == Qspace && parser->spc == False) { + Html_Put(parser, ' '); + parser->spc = True; + } + +/* parser->quark = Qhide;*/ + Html_FormatTag(parser); + } + else + return (ch); + } + /*NOTREACHED*/ +} + +/* entities */ +static int +Html_Format2(Html_Parser *parser) +{ + int ch; + + for (ch = Html_Format3(parser); ch == '&'; ch = Html_Format3(parser)) { + Html_Put(parser, '&'); + while ((ch = Html_Peek(parser)) != ';') { + if (isspace(ch) || ch == EOF) + break; + Html_Put(parser, Html_Get(parser)); + } + if (ch != EOF) + Html_Put(parser, Html_Get(parser)); + else + break; + if (parser->pre) + ++parser->column; + } + + return (ch); +} + +/* spaces */ +static int +Html_Format1(Html_Parser *parser) +{ + int ch; + + for (;;) { + if ((ch = Html_Format2(parser)) == EOF) + return (ch); + + if (parser->quark == Qetag) { + if (parser->adnl < 2) { + Html_Puts(parser, parser->adnl ? pnl : nlpnl); + parser->adnl = 2; + parser->spc = True; + } + } + else if (parser->quark == Qspace && parser->spc == False) { + Html_Put(parser, ' '); + parser->spc = True; + } + + if (!parser->pre && isspace(ch)) + parser->quark = Qspace; + else { + if (parser->pre) { + if (parser->spc) { + /* did not yet see any non space character */ + if (isspace(ch)) { + if (ch == '\n') { + parser->column = 0; + parser->spc = False; + parser->adnl = 1; + } + else if (ch == '\t') + parser->column += 8 - (parser->column % 8); + else + ++parser->column; + continue; + } + else { + int column = parser->column; + + while (column-- > 0) + Html_Put(parser, ' '); + parser->spc = False; + parser->adnl = 0; + } + } + else if (ch == '\n') { + ++parser->adnl; + parser->column = 0; + } + else if (ch == '\t') { + int column = parser->column + (8 - (parser->column % 8)); + + parser->adnl = 0; + while (parser->column < column) { + Html_Put(parser, ' '); + ++parser->column; + } + continue; + } + else { + parser->adnl = 0; + ++parser->column; + } + } + else + parser->adnl = 0; + Html_Put(parser, ch); + parser->quark = Qdefault; + parser->spc = False; + } + } +} + +/************************************************************************/ +/* ARGUMENTS */ +/************************************************************************/ +static void +Html_AArgs(Html_Parser *parser, Html_Item *item) +{ + int ch, sz; + char buf[32]; + + /*CONSTCOND*/ + while (True) { + sz = 0; + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) { + if (isalnum(ch)) + break; + else + (void)Html_Get(parser); + } + + if (ch == '>' || ch == EOF) + return; + buf[sz++] = tolower(Html_Get(parser)); + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) + if (isalnum(ch)) + buf[sz++] = tolower(Html_Get(parser)); + else + break; + buf[sz] = '\0'; + if (strcmp(buf, "href") == 0) { + item->combine = XawTextSinkCopyProperty(XawTextGetSink(text), + item->info->ident); + item->override = True; + item->combine->xlfd_mask = 0L; + item->combine->mask = XAW_TPROP_UNDERLINE | XAW_TPROP_FOREGROUND; + item->combine->foreground = parser->alink; + return; + } + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) { + if (isspace(ch)) + break; + else + (void)Html_Get(parser); + } + } +} + +static void +Html_FontArgs(Html_Parser *parser, Html_Item *item) +{ + int ch, sz; + char name[32], value[256], xlfd[128]; + + item->combine = XawTextSinkCopyProperty(XawTextGetSink(text), + Qdefault); + item->override = True; + item->combine->mask = item->combine->xlfd_mask = 0L; + + /*CONSTCOND*/ + while (True) { + /* skip white spaces */ + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) { + if (isalnum(ch)) + break; + else + (void)Html_Get(parser); + } + + if (ch == '>' || ch == EOF) + return; + + /* read option name */ + sz = 0; + name[sz++] = tolower(Html_Get(parser)); + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) + if (isalnum(ch) && (sz + 1 < sizeof(name))) + name[sz++] = tolower(Html_Get(parser)); + else + break; + name[sz] = '\0'; + + if (ch != '=') + continue; + (void)Html_Get(parser); /* skip `=' */ + if (Html_Peek(parser) == '"') + (void)Html_Get(parser); + + sz = 0; + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) { + if (!isspace(ch) && (sz + 1 < sizeof(value))) + value[sz++] = Html_Get(parser); + else + break; + } + value[sz] = '\0'; + if (sz > 0 && value[sz - 1] == '"') + value[--sz] = '\0'; + + if (strcmp(name, "color") == 0) { + XColor color, exact; + + if (XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, + value, &color, &exact)) { + item->combine->mask |= XAW_TPROP_FOREGROUND; + item->combine->foreground = color.pixel; + } + } + else if (strcmp(name, "face") == 0) { + int count = 0; + char *ptr, *family, **font_list; + + ptr = value; + do { + family = ptr; + ptr = strchr(ptr, ','); + if (ptr) + *ptr++ = '\0'; + XmuSnprintf(xlfd, sizeof(xlfd), "-*-%s-*-*-*-*-*-*-*-*-*-*-*-*", + family); + font_list = XListFonts(XtDisplay(toplevel), xlfd, 1, &count); + if (font_list) + XFreeFontNames(font_list); + if (count) + break; + } while (ptr); + if (count) { + item->combine->xlfd_mask |= XAW_TPROP_FAMILY; + item->combine->family = XrmStringToQuark(family); + } + } + else if (strcmp(name, "size") == 0) { + int size, sign = 0; + + if (isalnum(*value)) { + size = atoi(value); + sign = 0; + } + else { + char *str = XrmQuarkToString(item->combine->pixel_size); + + size = str ? atoi(str) : 12; + if (*value == '+') { + size += atoi(value + 1); + sign = 1; + } + else if (*value == '-') { + size -= atoi(value + 1); + sign = -1; + } + } + + if (item->combine->xlfd != NULLQUARK) { + int count, ucount, dcount, usize, dsize; + char **current, **result, **up, **down; + + current = result = up = down = NULL; + /* try to load an appropriate font */ + XmuSnprintf(value, sizeof(value), + "-*-%s-%s-%s-*--%%d-*-*-*-*-*-%s-%s", + XrmQuarkToString(item->combine->family), + XrmQuarkToString(item->combine->weight), + XrmQuarkToString(item->combine->slant), + XrmQuarkToString(item->combine->registry), + XrmQuarkToString(item->combine->encoding)); + XmuSnprintf(xlfd, sizeof(xlfd), value, + atoi(XrmQuarkToString(item->combine->pixel_size))); + current = XListFonts(XtDisplay(toplevel), xlfd, 1, &count); + if (count) { + ucount = dcount = usize = dsize = 0; + + XmuSnprintf(xlfd, sizeof(xlfd), value, size); + result = XListFonts(XtDisplay(toplevel), xlfd, 1, &count); + if (count == 0 || strstr(*result, "-0-")) { + if (sign <= 0) { + sz = dsize = size; + while (dcount == 0 && --sz > size - 8 && sz > 1) { + XmuSnprintf(xlfd, sizeof(xlfd), value, sz); + down = XListFonts(XtDisplay(toplevel), xlfd, + 1, &dcount); + if (dcount && strstr(*down, "-0-") != NULL) { + XFreeFontNames(down); + down = NULL; + dcount = 0; + } + } + if (dcount) + dsize = sz; + } + if (sign >= 0) { + sz = usize = size; + while (ucount == 0 && ++sz < size + 8) { + XmuSnprintf(xlfd, sizeof(xlfd), value, sz); + up = XListFonts(XtDisplay(toplevel), xlfd, + 1, &ucount); + if (ucount && strstr(*up, "-0-") != NULL) { + XFreeFontNames(up); + up = NULL; + ucount = 0; + } + } + if (ucount) + usize = sz; + } + if (ucount && dcount) + size = size - dsize < usize - size ? dsize : usize; + else if (ucount) + size = usize; + else if (dcount) + size = dsize; + } + if (current) + XFreeFontNames(current); + if (result) + XFreeFontNames(result); + if (up) + XFreeFontNames(up); + if (down) + XFreeFontNames(down); + } + } + + XmuSnprintf(value, sizeof(value), "%d", size); + item->combine->xlfd_mask |= XAW_TPROP_PIXELSIZE; + item->combine->pixel_size = XrmStringToQuark(value); + } + + while ((ch = Html_Peek(parser)) != '>' && ch != EOF) { + if (isspace(ch)) + break; + else + (void)Html_Get(parser); + } + } +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/help.h b/xorg-server/hw/xfree86/utils/xorgcfg/help.h new file mode 100644 index 000000000..141f50402 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/help.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + */ + +/* help string definitions */ +#define HELP_DEVICES "helpDevices" /* Configure Layout */ +#define HELP_SCREEN "helpScreen" /* Configure Screen */ +#define HELP_MODELINE "helpModeline" /* Configure Modeline */ +#define HELP_ACCESSX "helpAccessX" /* Configure AccessX */ + +/* + * Prototypes + */ +void Help(char*); +void HelpCancelAction(Widget, XEvent*, String*, Cardinal*); diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/interface.c b/xorg-server/hw/xfree86/utils/xorgcfg/interface.c new file mode 100644 index 000000000..cb39624ca --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/interface.c @@ -0,0 +1,2278 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include <X11/IntrinsicP.h> +#include <X11/StringDefs.h> +#include <X11/Composite.h> +#include <X11/Shell.h> +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Simple.h> +#include <X11/Xaw/Paned.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Command.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/SmeLine.h> +#include <X11/Xaw/SimpleMenP.h> +#include <X11/Xaw/Dialog.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <time.h> +#include "xf86config.h" +#include "mouse-cfg.h" +#include "keyboard-cfg.h" +#include "card-cfg.h" +#include "monitor-cfg.h" +#include "screen-cfg.h" +#include "screen.h" +#include "cards.h" +#include "options.h" +#include "vidmode.h" +#include "help.h" +#include "stubs.h" + +#define randomize() srand((unsigned)time((time_t*)NULL)) +#ifdef PROJECT_ROOT +#define DefaultXFree86Dir PROJECT_ROOT +#else +#define DefaultXFree86Dir "/usr" +#endif + +#define IS_KBDDRIV(S) ((strcasecmp((S),"kbd") == 0)) + +/* + * Prototypes + */ +void DrawCables(void); +static void DrawCable(Display*, Window, int, int, int, int); +static void ComputerEventHandler(Widget, XtPointer, XEvent*, Boolean*); +void SelectDeviceAction(Widget, XEvent*, String*, Cardinal*); +void MoveDeviceAction(Widget, XEvent*, String*, Cardinal*); +void UnselectDeviceAction(Widget, XEvent*, String*, Cardinal*); +void RenameLayoutAction(Widget, XEvent*, String*, Cardinal*); +void DevicePopupMenu(Widget, XEvent*, String*, Cardinal*); +void DevicePopdownMenu(Widget, XEvent*, String*, Cardinal*); +void AddDeviceCallback(Widget, XtPointer, XtPointer); +void QuitCallback(Widget, XtPointer, XtPointer); +void SmeConfigureDeviceCallback(Widget, XtPointer, XtPointer); +void ConfigureDeviceCallback(Widget, XtPointer, XtPointer); +void EnableDeviceCallback(Widget, XtPointer, XtPointer); +void DisableDeviceCallback(Widget, XtPointer, XtPointer); +void RemoveDeviceCallback(Widget, XtPointer, XtPointer); +void InitializeDevices(void); +void SetConfigModeCallback(Widget, XtPointer, XtPointer); +void SelectLayoutCallback(Widget, XtPointer, XtPointer); +void DefaultLayoutCallback(Widget, XtPointer, XtPointer); +void RemoveLayoutCallback(Widget, XtPointer, XtPointer); +void OptionsCallback(Widget, XtPointer, XtPointer); +xf86cfgDevice *AddDevice(int, XtPointer, int, int); +static Bool AskConfig(void); +void WriteConfigAction(Widget, XEvent*, String*, Cardinal*); +static void ScreenSetup(Bool); +void QuitAction(Widget, XEvent*, String*, Cardinal*); +void PopdownErrorCallback(Widget, XtPointer, XtPointer); +static void ErrorCancelAction(Widget, XEvent*, String*, Cardinal*); +static void QuitCancelAction(Widget, XEvent*, String*, Cardinal*); +static void HelpCallback(Widget, XtPointer, XtPointer); +void UpdateMenuDeviceList(int); + +extern void AccessXConfigureStart(void); +extern void AccessXConfigureEnd(void); +extern void CloseAccessXAction(Widget, XEvent*, String*, Cardinal*); + +#ifdef HAS_NCURSES +extern void TextMode(void); +#endif + +static void Usage(void); + +/* + * Initialization + */ +Widget toplevel, work, config, layout, layoutsme, layoutp, topMenu; +XtAppContext appcon; + +Pixmap menuPixmap; + +char *XF86Config_path = NULL; +char *XF86Module_path = NULL; +char *XFree86_path = NULL; +char *XF86Font_path = NULL; +char *XF86RGB_path = NULL; +char *XkbConfig_path = NULL; +char *XFree86Dir; +static char XF86Config_path_static[1024]; +static char XkbConfig_path_static[1024]; +Bool xf86config_set = False; + +int textmode = False; +#ifdef USE_MODULES +int nomodules = False; +#endif +int noverify = False; + +xf86cfgComputer computer; +xf86cfgDevice cpu_device; +Cursor no_cursor; +static Widget device, layoutm, popup, commands; +static int xpos, ypos; +int sxpos, sypos; +static char no_cursor_data[] = { 0,0,0,0, 0,0,0,0 }; +static GC cablegc, cablegcshadow; +Atom wm_delete_window; +static Bool config_set = False; +static Widget mouseSme, mouseMenu, keyboardSme, keyboardMenu, + cardSme, cardMenu, monitorSme, monitorMenu; + +int config_mode = CONFIG_LAYOUT; + +static XtActionsRec actions[] = { + {"filter-card", CardFilterAction}, + {"select-device", SelectDeviceAction}, + {"move-device", MoveDeviceAction}, + {"unselect-device", UnselectDeviceAction}, + {"device-popup", DevicePopupMenu}, + {"device-popdown", DevicePopdownMenu}, + {"rename-layout", RenameLayoutAction}, + {"write-config", WriteConfigAction}, + {"quit", QuitAction}, + {"vidmode-restore", VidmodeRestoreAction}, + {"config-cancel", ConfigCancelAction}, + {"options-cancel", OptionsCancelAction}, + {"error-cancel", ErrorCancelAction}, + {"quit-cancel", QuitCancelAction}, + {"addmode-cancel", CancelAddModeAction}, + {"accessx-close", CloseAccessXAction}, + {"testmode-cancel", CancelTestModeAction}, + {"help-close", HelpCancelAction}, + {"expert-close", ExpertCloseAction}, +#ifdef USE_MODULES + {"module-options-close", ModuleOptionsCancelAction}, +#endif +}; + +static char *device_names[] = { +/* MOUSE */ + "mouse", +/* KEYBOARD */ + "keyboard", +/* CARD */ + "card", +/* MONITOR */ + "monitor", +/* SCREEN */ + "screen", +}; + +static XtResource appResources[] = { +#if 0 + {"config", __XCONFIGFILE__, XtRString, sizeof(char*), + 0, XtRString, "/etc/X11/"__XCONFIGFILE__}, +#endif + {"menuBitmap", "MenuBitmap", XtRString, sizeof(char*), + 0, XtRString, "menu10"}, +}; + +static void +Usage(void) +{ + fprintf(stderr, +"Usage:\n" +" xorgcfg [-option ...]\n" +"\n" +"Options:\n" +" -config <"__XCONFIGFILE__"> Alternate configuration file.\n" +" -modulepath <module-path> "__XSERVERNAME__" modules location.\n" +" -serverpath <server-path> X server to start (if $DISPLAY is not defined).\n" +" -fontpath <font-path> Font path for fonts.\n" +#ifdef HAS_NCURSES +" -textmode Use this option for the text only interface.\n" +#endif +#ifdef USE_MODULES +" -nomodules Use this option if xorgcfg is slow to start.\n" +" -verbose <number> Verbosity used in the loader (default 1).\n" +#endif +" -verify Verify modules/options integrity.\n" +); + + exit(1); +} + +/* + * Implementation + */ +int +main(int argc, char *argv[]) +{ + Widget pane, hpane, expert, popup, mouse, keyboard, card, monitor; + Widget bottom, sme, smemodeline, help, quit, layopt; + XColor color, tmp; + Pixmap pixmap; + XGCValues values; + XF86ConfLayoutPtr lay; + int i, startedx; + char *menuPixmapPath = NULL; + XrmValue from, to; + + if ((XFree86Dir = getenv("XWINHOME")) == NULL) + XFree86Dir = DefaultXFree86Dir; + + chdir(XFree86Dir); + +#ifdef USE_MODULES + xf86Verbose = 1; +#endif + noverify = True; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-config") == 0 || + strcmp(argv[i], "-xorgconfig") == 0 || + strcmp(argv[i], "-xf86config") == 0) { + if (i + 1 < argc) { + XF86Config_path = argv[++i]; + config_set = True; + } + } else if (strcmp(argv[i], "-modulepath") == 0) { + if (i + 1 < argc) + XF86Module_path = argv[++i]; + } else if (strcmp(argv[i], "-serverpath") == 0) { + if (i + 1 < argc) + XFree86_path = argv[++i]; + } else if (strcmp(argv[i], "-fontpath") == 0) { + if (i + 1 < argc) + XF86Font_path = argv[++i]; + } +#ifdef HAS_NCURSES + else if (strcmp(argv[i], "-textmode") == 0) + textmode = True; +#endif +#ifdef USE_MODULES + else if (strcmp(argv[i], "-nomodules") == 0) + nomodules = True; + else if (strcmp(argv[i], "-verbose") == 0) { + if (i + 1 < argc) + xf86Verbose = atoi(argv[++i]); + } +#endif + else if (strcmp(argv[i], "-verify") == 0) + noverify = False; + else + Usage(); + } + +#ifdef HAS_NCURSES + if (textmode) { + TextMode(); + exit(0); + } +#endif + + startedx = startx(); + if (XF86Config_path == NULL) + XF86Config_path = XtNewString(__XCONFIGFILE__); + if (XkbConfig_path == NULL) { + XmuSnprintf(XkbConfig_path_static, sizeof(XkbConfig_path_static), + "%s/%s%s", XFree86Dir, XkbConfigDir, XkbConfigFile); + XkbConfig_path = XkbConfig_path_static; + } + toplevel = XtAppInitialize(&appcon, "XOrgCfg", + NULL, 0, + &argc, argv, + NULL, NULL, 0); + if (DPY == NULL) + DPY = XtDisplay(toplevel); + + XtGetApplicationResources(toplevel, (XtPointer)&menuPixmapPath, + appResources, XtNumber(appResources), NULL, 0); + if (menuPixmapPath && strlen(menuPixmapPath)) { + from.size = strlen(menuPixmapPath); + from.addr = menuPixmapPath; + to.size = sizeof(Pixmap); + to.addr = (XtPointer)&(menuPixmap); + XtConvertAndStore(toplevel, XtRString, &from, XtRBitmap, &to); + } + + XtAppAddActions(appcon, actions, XtNumber(actions)); + + XawSimpleMenuAddGlobalActions(appcon); + XtRegisterGrabAction(DevicePopupMenu, True, + ButtonPressMask | ButtonReleaseMask, + GrabModeAsync, GrabModeAsync); + + pane = XtCreateManagedWidget("pane", panedWidgetClass, + toplevel, NULL, 0); + hpane = XtVaCreateManagedWidget("hpane", panedWidgetClass, pane, + XtNorientation, XtorientHorizontal, NULL); + topMenu = XtCreateManagedWidget("topM", menuButtonWidgetClass, + hpane, NULL, 0); + expert = XtCreateManagedWidget("expert", commandWidgetClass, hpane, NULL, 0); + XtAddCallback(expert, XtNcallback, ExpertCallback, NULL); + popup = XtCreatePopupShell("menu", simpleMenuWidgetClass, + topMenu, NULL, 0); + sme = XtCreateManagedWidget("layout", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(sme, XtNcallback, SetConfigModeCallback, + (XtPointer)CONFIG_LAYOUT); + sme = XtCreateManagedWidget("screen", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(sme, XtNcallback, SetConfigModeCallback, + (XtPointer)CONFIG_SCREEN); + smemodeline = XtCreateManagedWidget("modeline", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(smemodeline, XtNcallback, SetConfigModeCallback, + (XtPointer)CONFIG_MODELINE); + sme = XtCreateManagedWidget("accessx", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(sme, XtNcallback, SetConfigModeCallback, + (XtPointer)CONFIG_ACCESSX); + + commands = XtCreateManagedWidget("commands", formWidgetClass, + pane, NULL, 0); + + mouse = XtVaCreateManagedWidget("mouse", menuButtonWidgetClass, + commands, XtNmenuName, "mouseP", NULL); + popup = XtCreatePopupShell("mouseP", simpleMenuWidgetClass, + mouse, NULL, 0); + sme = XtCreateManagedWidget("new", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)MOUSE); + mouseSme = XtCreateManagedWidget("configure", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(mouseSme, XtNcallback, SmeConfigureDeviceCallback, + (XtPointer)MOUSE); + + keyboard = XtVaCreateManagedWidget("keyboard", menuButtonWidgetClass, + commands, XtNmenuName, "keyboardP", NULL); + popup = XtCreatePopupShell("keyboardP", simpleMenuWidgetClass, + keyboard, NULL, 0); + sme = XtCreateManagedWidget("new", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)KEYBOARD); + keyboardSme = XtCreateManagedWidget("configure", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(keyboardSme, XtNcallback, SmeConfigureDeviceCallback, + (XtPointer)KEYBOARD); + + card = XtVaCreateManagedWidget("card", menuButtonWidgetClass, + commands, XtNmenuName, "cardP", NULL); + popup = XtCreatePopupShell("cardP", simpleMenuWidgetClass, + card, NULL, 0); + sme = XtCreateManagedWidget("new", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)CARD); + cardSme = XtCreateManagedWidget("configure", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(cardSme, XtNcallback, SmeConfigureDeviceCallback, + (XtPointer)CARD); + + monitor = XtVaCreateManagedWidget("monitor", menuButtonWidgetClass, + commands, XtNmenuName, "monitorP", NULL); + popup = XtCreatePopupShell("monitorP", simpleMenuWidgetClass, + monitor, NULL, 0); + sme = XtCreateManagedWidget("new", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(sme, XtNcallback, AddDeviceCallback, (XtPointer)MONITOR); + monitorSme = XtCreateManagedWidget("configure", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(monitorSme, XtNcallback, SmeConfigureDeviceCallback, + (XtPointer)MONITOR); + + work = XtCreateManagedWidget("work", compositeWidgetClass, + pane, NULL, 0); + + bottom = XtCreateManagedWidget("bottom", formWidgetClass, + pane, NULL, 0); + layoutm = XtCreateManagedWidget("select", menuButtonWidgetClass, + bottom, NULL, 0); + layout = XtVaCreateManagedWidget("layout", asciiTextWidgetClass, + bottom, + XtNeditType, XawtextEdit, + NULL); + layoutp = XtCreatePopupShell("menu", simpleMenuWidgetClass, + bottom, NULL, 0); + sme = XtCreateManagedWidget("new", smeBSBObjectClass, layoutp, + NULL, 0); + XtAddCallback(sme, XtNcallback, SelectLayoutCallback, NULL); + help = XtCreateManagedWidget("help", commandWidgetClass, + bottom, NULL, 0); + XtAddCallback(help, XtNcallback, HelpCallback, NULL); + quit = XtCreateManagedWidget("quit", commandWidgetClass, + bottom, NULL, 0); + XtAddCallback(quit, XtNcallback, QuitCallback, NULL); + + XtRealizeWidget(toplevel); + XtRealizeWidget(topMenu); + + pixmap = XCreateBitmapFromData(XtDisplay(toplevel), XtWindow(toplevel), + no_cursor_data, 8, 8); + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "black", + &color, &tmp); + no_cursor = XCreatePixmapCursor(XtDisplay(toplevel), pixmap, pixmap, + &color, &color, 0, 0); + + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray55", + &color, &tmp); + values.line_width = 3; + values.foreground = color.pixel; + cablegcshadow = XCreateGC(XtDisplay(toplevel), XtWindow(toplevel), + GCForeground | GCLineWidth, &values); + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray85", + &color, &tmp); + values.line_width = 1; + values.foreground = color.pixel; + cablegc = XCreateGC(XtDisplay(toplevel), XtWindow(toplevel), + GCForeground | GCLineWidth, &values); + + computer.cpu = XtCreateManagedWidget("cpu", simpleWidgetClass, + work, NULL, 0); + cpu_device.widget = computer.cpu; + cpu_device.type = SERVER; + + XtAddEventHandler(work, ExposureMask, False, + ComputerEventHandler, (XtPointer)NULL); + + wm_delete_window = XInternAtom(DPY, "WM_DELETE_WINDOW", False); + XSetWMProtocols(DPY, XtWindow(toplevel), &wm_delete_window, 1); + + StartConfig(); + InitializeDevices(); + UpdateMenuDeviceList(MOUSE); + UpdateMenuDeviceList(KEYBOARD); + UpdateMenuDeviceList(CARD); + UpdateMenuDeviceList(MONITOR); + XtSetSensitive(smemodeline, VideoModeInitialize()); + + lay = XF86Config->conf_layout_lst; + while (lay != NULL) { + sme = XtVaCreateManagedWidget("sme", smeBSBObjectClass, + layoutp, + XtNlabel, lay->lay_identifier, + XtNmenuName, lay->lay_identifier, + XtNleftBitmap, menuPixmap, + NULL); + XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay); + if (layoutsme == NULL) + layoutsme = sme; + layopt = XtCreatePopupShell(lay->lay_identifier, simpleMenuWidgetClass, + layoutp, NULL, 0); + sme = XtCreateManagedWidget("default", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL); + sme = XtCreateManagedWidget("remove", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL); + XtRealizeWidget(layopt); + + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + SelectLayoutCallback(layoutsme, + XF86Config->conf_layout_lst, NULL); + + startaccessx(); + if (startedx) { + switch (fork()) { + case 0: { + char path[PATH_MAX]; + + XmuSnprintf(path, sizeof(path), "%s/bin/twm", XFree86Dir); + execl(path, "twm", (void *)NULL); + exit(-127); + } break; + case -1: + fprintf(stderr, "Cannot fork.\n"); + exit(1); + break; + default: + break; + } + } + +#ifdef USE_MODULES + if (!nomodules) + LoaderInitializeOptions(); +#endif + + /* ReadCardsDatabase() must be called after LoaderInitializeOptions() */ + ReadCardsDatabase(); + + if (!config_set && startedx) { + XtFree(XF86Config_path); +#ifndef XF86CONFIG +# define XF86CONFIG __XCONFIGFILE__ +#endif +#ifdef XF86CONFIGDIR + XF86Config_path = XtNewString(XF86CONFIGDIR "/" XF86CONFIG); +#else + XF86Config_path = XtNewString("/etc/X11/" XF86CONFIG); +#endif + } + XtAppMainLoop(appcon); + if (startedx) + endx(); + + return (0); +} + +static Widget shell_cf; +static int write_cf, asking_cf; +static int cf_state = 0; +#define CF_XF86Config 1 +#define CF_XKBConfig 2 +#define CF_First CF_XF86Config +#define CF_Last CF_XKBConfig + +/*ARGSUSED*/ +static void +WriteConfig(Widget w, XtPointer user_data, XtPointer call_data) +{ + asking_cf = 0; + XtPopdown(shell_cf); + write_cf = (long)user_data; +} + +/*ARGSUSED*/ +void +QuitCancelAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + WriteConfig(w, (XtPointer)-1, NULL); +} + +/*ARGSUSED*/ +void +WriteConfigAction(Widget w, XEvent *event, + String *params, Cardinal *num_params) +{ + WriteConfig(w, (XtPointer)True, NULL); +} + +static Bool +AskConfig(void) +{ + static Widget dialog; + + if (shell_cf == NULL) { + Arg args[1]; + char *l, *label; + int len; + + shell_cf = XtCreatePopupShell("quit", transientShellWidgetClass, + toplevel, NULL, 0); + dialog = XtVaCreateManagedWidget("ask", dialogWidgetClass, shell_cf, + XtNvalue, XF86Config_path, NULL); + XawDialogAddButton(dialog, "yes", WriteConfig, (XtPointer)1); + XawDialogAddButton(dialog, "no", WriteConfig, (XtPointer)0); + XawDialogAddButton(dialog, "cancel", WriteConfig, (XtPointer)-1); + XtRealizeWidget(shell_cf); + XSetWMProtocols(DPY, XtWindow(shell_cf), &wm_delete_window, 1); + XtSetArg(args[0], XtNlabel, &l); + XtGetValues(dialog, args, 1); + label = XtMalloc(len = (strlen(l) + strlen(XF86CONFIG) + 2)); + XmuSnprintf(label, len, "%s\n", XF86CONFIG); + strcat(label, l); + XtSetArg(args[0], XtNlabel, label); + XtSetValues(dialog, args, 1); + XtFree(label); + } + else { + Arg args[2]; + Cardinal num_args = 0; + char *l, *label = NULL, *str = ""; + + XtSetArg(args[0], XtNlabel, &l); + XtGetValues(dialog, args, 1); + switch (cf_state) { + case CF_XF86Config: + str = XF86CONFIG; + XtSetArg(args[num_args], XtNvalue, XF86Config_path); + ++num_args; + break; + case CF_XKBConfig: + str = "XKB"; + XtSetArg(args[num_args], XtNvalue, XkbConfig_path); + ++num_args; + break; + } + l = strchr(l, '\n'); + if (l != NULL) { + label = XtMalloc(strlen(str) + strlen(l) + 1); + strcpy(label, str); + strcat(label, l); + XtSetArg(args[num_args], XtNlabel, label); + ++num_args; + } + XtSetValues(dialog, args, num_args); + if (l != NULL) + XtFree(label); + } + + asking_cf = 1; + + XtPopup(shell_cf, XtGrabExclusive); + while (asking_cf) + XtAppProcessEvent(XtWidgetToApplicationContext(shell_cf), XtIMAll); + + if (write_cf > 0) { + switch (cf_state) { + case CF_XF86Config: + XF86Config_path = XawDialogGetValueString(dialog); + XmuSnprintf(XF86Config_path_static, + sizeof(XF86Config_path_static), + "%s", XF86Config_path); + XF86Config_path = XF86Config_path_static; + break; + case CF_XKBConfig: + XkbConfig_path = XawDialogGetValueString(dialog); + XmuSnprintf(XkbConfig_path_static, + sizeof(XkbConfig_path_static), + "%s", XkbConfig_path); + XkbConfig_path = XkbConfig_path_static; + break; + } + } + + return (write_cf); +} + +/*ARGSUSED*/ +void +PopdownErrorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XtPopdown((Widget)user_data); +} + +/*ARGSUSED*/ +void +ErrorCancelAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + XtPopdown((Widget)w); +} + +/*ARGSUSED*/ +void +QuitAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + QuitCallback(w, NULL, NULL); +} + +/*ARGSUSED*/ +void +QuitCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + for (cf_state = CF_First; cf_state <= CF_Last; cf_state++) { + if (cf_state == CF_XKBConfig && xkb_info == NULL) + continue; + + switch (AskConfig()) { + case 0: + break; + case 1: + if ((cf_state == CF_XF86Config && + !xf86writeConfigFile(XF86Config_path, XF86Config)) || + (cf_state == CF_XKBConfig && + !WriteXKBConfiguration(XkbConfig_path, + &xkb_info->config))) { + static Widget shell; + + if (shell == NULL) { + Widget dialog; + + shell = XtCreatePopupShell("error", + transientShellWidgetClass, + toplevel, NULL, 0); + dialog = XtVaCreateManagedWidget("notice", + dialogWidgetClass, + shell, XtNvalue, NULL, + NULL); + XawDialogAddButton(dialog, "ok", PopdownErrorCallback, + (XtPointer)shell); + XtRealizeWidget(shell); + XSetWMProtocols(DPY, XtWindow(shell), + &wm_delete_window, 1); + } + XtPopup(shell, XtGrabExclusive); + return; + } + break; + default: + return; + } + } + + endx(); + exit(0); +} + +void +InitializeDevices(void) +{ + xf86cfgDevice *device; + int mouse_x, mouse_y, keyboard_x, keyboard_y, + card_x, card_y, monitor_x, monitor_y, len; + XF86ConfInputPtr input = XF86Config->conf_input_lst; + XF86ConfDevicePtr card = XF86Config->conf_device_lst; + XF86ConfMonitorPtr monitor = XF86Config->conf_monitor_lst; + XF86OptionPtr flags = NULL; + char buffer[4096], *tip; + Arg args[1]; + + if (XF86Config->conf_flags != NULL) + flags = XF86Config->conf_flags->flg_option_lst; + + len = 0; + while (flags && len < sizeof(buffer) - 1) { + len += XmuSnprintf(buffer + len, sizeof(buffer) - len, + "Option \"%s\"", + flags->opt_name); + if (flags->opt_val != NULL) + len += XmuSnprintf(buffer + len, sizeof(buffer) - len, + " \"%s\"\n", + flags->opt_val); + else + len += XmuSnprintf(buffer + len, sizeof(buffer) - len, + "%s", "\n"); + flags = (XF86OptionPtr)(flags->list.next); + } + + if (len) { + tip = XtNewString(buffer); + XtSetArg(args[0], XtNtip, tip); + XtSetValues(computer.cpu, args, 1); + } + +#define DEFAULT_MOUSE_WIDTH 30 +#define DEFAULT_MOUSE_HEIGHT 40 +#define DEFAULT_KEYBOARD_WIDTH 48 +#define DEFAULT_KEYBOARD_HEIGHT 36 + mouse_x = work->core.width - (work->core.width >> 2); + mouse_y = work->core.height - DEFAULT_MOUSE_HEIGHT; + keyboard_x = 6; + keyboard_y = work->core.height - DEFAULT_KEYBOARD_HEIGHT; + + while (input != NULL) { + if (input->inp_driver) { + if (strcasecmp(input->inp_driver, "mouse") == 0) { + device = AddDevice(MOUSE, (XtPointer)input, mouse_x, mouse_y); + SetTip(device); + if ((mouse_x += DEFAULT_MOUSE_WIDTH) > work->core.width) { + if ((mouse_y -= DEFAULT_MOUSE_HEIGHT) < (work->core.height >> 1)) + mouse_y = work->core.height >> 1; + mouse_x = work->core.width - (work->core.width >> 2); + } + } + else if (IS_KBDDRIV(input->inp_driver)) { + device = AddDevice(KEYBOARD, (XtPointer)input, keyboard_x, keyboard_y); + SetTip(device); + if ((keyboard_x += DEFAULT_KEYBOARD_WIDTH) > + work->core.width - (work->core.width >> 2)) { + if ((keyboard_y -= DEFAULT_KEYBOARD_HEIGHT) < (work->core.height >> 1)) + keyboard_y = work->core.height >> 1; + keyboard_x = 6; + } + } + } + input = (XF86ConfInputPtr)(input->list.next); + } + +#define DEFAULT_CARD_WIDTH 45 +#define DEFAULT_CARD_HEIGHT 46 + card_x = 6; + card_y = (work->core.height >> 1) - 20 - DEFAULT_CARD_HEIGHT; + while (card != NULL) { + device = AddDevice(CARD, (XtPointer)card, card_x, card_y); + SetTip(device); + if ((card_x += DEFAULT_CARD_WIDTH) > work->core.width) { + if ((card_y -= DEFAULT_CARD_HEIGHT) < (work->core.height >> 2)) + card_y = work->core.height >> 2; + card_x = 6; + } + card = (XF86ConfDevicePtr)(card->list.next); + } + +#define DEFAULT_MONITOR_WIDTH 48 +#define DEFAULT_MONITOR_HEIGHT 48 + monitor_x = 6; + monitor_y = 6; + while (monitor != NULL) { + XF86ConfScreenPtr screen = XF86Config->conf_screen_lst; + + device = AddDevice(MONITOR, (XtPointer)monitor, monitor_x, monitor_y); + SetTip(device); + if ((monitor_x += DEFAULT_MONITOR_WIDTH) > work->core.width) { + if ((monitor_y += DEFAULT_MONITOR_HEIGHT) > + (work->core.height >> 2) - DEFAULT_MONITOR_HEIGHT) + monitor_y = (work->core.height >> 2) - DEFAULT_MONITOR_HEIGHT; + monitor_x = 6; + } + + while (screen != NULL) { + if (screen->scrn_monitor == monitor) { + card = XF86Config->conf_device_lst; + while (card != NULL) { + if (screen->scrn_device == card) { + xf86cfgScreen *scr = (xf86cfgScreen*) + XtCalloc(1, sizeof(xf86cfgScreen)); + int i; + + for (i = 0; i < computer.num_devices; i++) + if ((XF86ConfDevicePtr)(computer.devices[i]->config) + == card) + break; + scr->screen = screen; + scr->card = computer.devices[i]; + scr->monitor = device; + scr->refcount = 0; + ++scr->card->refcount; + ++scr->monitor->refcount; + computer.screens = (xf86cfgScreen**) + XtRealloc((XtPointer)computer.screens, + sizeof(xf86cfgScreen*) * + (computer.num_screens + 1)); + CreateScreenWidget(scr); + scr->type = SCREEN; + computer.screens[computer.num_screens++] = scr; + SetTip((xf86cfgDevice*)scr); + break; + } + card = (XF86ConfDevicePtr)(card->list.next); + } + device->state = USED; + } + screen = (XF86ConfScreenPtr)(screen->list.next); + } + + monitor = (XF86ConfMonitorPtr)(monitor->list.next); + } +} + +xf86cfgDevice * +AddDevice(int type, XtPointer config, int x, int y) +{ + switch (type) { + case MOUSE: + case KEYBOARD: + case CARD: + case MONITOR: + computer.devices = (xf86cfgDevice**) + XtRealloc((XtPointer)computer.devices, + sizeof(xf86cfgDevice*) * (computer.num_devices + 1)); + computer.devices[computer.num_devices] = (xf86cfgDevice*) + XtCalloc(1, sizeof(xf86cfgDevice)); + computer.devices[computer.num_devices]->config = config; + computer.devices[computer.num_devices]->widget = + XtVaCreateManagedWidget(device_names[type], simpleWidgetClass, + work, + XtNx, x, + XtNy, y, + XtNtip, NULL, + NULL); + computer.devices[computer.num_devices]->type = type; + computer.devices[computer.num_devices]->state = UNUSED; + computer.devices[computer.num_devices]->refcount = 0; + ++computer.num_devices; + break; + default: + fprintf(stderr, "Bad argument to AddDevice.\n"); + exit(1); + return (NULL); + } + + UpdateMenuDeviceList(type); + + return (computer.devices[computer.num_devices - 1]); +} + +/*ARGSUSED*/ +static void +HelpCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + char *topic = NULL; + + switch (config_mode) { + case CONFIG_LAYOUT: + topic = HELP_DEVICES; + break; + case CONFIG_SCREEN: + topic = HELP_SCREEN; + break; + case CONFIG_MODELINE: + topic = HELP_MODELINE; + break; + case CONFIG_ACCESSX: + topic = HELP_ACCESSX; + break; + } + Help(topic); +} + +void +SelectLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i, j; + XF86ConfLayoutPtr lay = (XF86ConfLayoutPtr)user_data; + XF86ConfInputrefPtr input; + XF86ConfAdjacencyPtr adj; + Widget sme, layopt; + Arg args[1]; + char *str; + + /* XXX Needs to check computer.layout, + * because this function should also create + * a new layout... + */ + if (lay == computer.layout && computer.layout) + return; + + if (computer.layout != NULL) { + for (i = 0; i < computer.num_layouts; i++) { + if (computer.layouts[i]->layout == computer.layout) + break; + } + if (i < computer.num_layouts) { + XtFree((XtPointer)computer.layouts[i]->screen); + XtFree((XtPointer)computer.layouts[i]->position); + } + else { + computer.layouts = (xf86cfgLayout**) + XtRealloc((XtPointer)computer.layouts, sizeof(xf86cfgLayout*) * + (computer.num_layouts + 1)); + ++computer.num_layouts; + } + computer.layouts[i] = (xf86cfgLayout*)XtCalloc(1, sizeof(xf86cfgLayout)); + computer.layouts[i]->layout = computer.layout; + computer.layouts[i]->num_layouts = computer.num_screens; + computer.layouts[i]->screen = (xf86cfgScreen**) + XtMalloc(sizeof(xf86cfgScreen*) * computer.num_screens); + computer.layouts[i]->position = (XPoint*) + XtMalloc(sizeof(XPoint) * computer.num_screens); + for (j = 0; j < computer.num_screens; j++) { + computer.layouts[i]->screen[j] = computer.screens[j]; + computer.layouts[i]->position[j].x = computer.screens[j]->widget->core.x; + computer.layouts[i]->position[j].y = computer.screens[j]->widget->core.y; + } + } + + if (lay != NULL) { + for (i = 0; i < computer.num_layouts; i++) + if (computer.layouts[i]->layout == lay) { + for (j = 0; j < computer.layouts[i]->num_layouts; j++) { + int k; + + for (k = 0; k < computer.num_screens; k++) + if (computer.screens[k] == computer.layouts[i]->screen[j]) { + XtMoveWidget(computer.screens[k]->widget, + computer.layouts[i]->position[j].x, + computer.layouts[i]->position[j].y); + } + } + break; + } + + layoutsme = w; + XtSetArg(args[0], XtNlabel, &str); + XtGetValues(w, args, 1); + XtSetArg(args[0], XtNstring, str); + XtSetValues(layout, args, 1); + } + + computer.layout = lay; + + for (i = 0; i < computer.num_devices; i++) + computer.devices[i]->state = UNUSED; + for (i = 0; i < computer.num_screens; i++) + computer.screens[i]->state = UNUSED; + + if (lay == NULL) { + char name[64]; + XF86ConfLayoutPtr l; + int num_layouts = 0; + + l = XF86Config->conf_layout_lst; + while (l != NULL) { + if (l->lay_adjacency_lst == NULL && + l->lay_inactive_lst == NULL && + l->lay_input_lst == NULL && + l->lay_option_lst == NULL && + l->lay_comment == NULL) { + for (i = 0; + i < ((CompositeWidget)layout)->composite.num_children; i++) + if (strcmp(XtName(((CompositeWidget)layout)->composite. + children[i]), l->lay_identifier) == 0) { + layoutsme = ((CompositeWidget)layout)->composite.children[i]; + } + computer.layout = l; + XtSetArg(args[0], XtNstring, l->lay_identifier); + XtSetValues(layout, args, 1); + if (config_mode == CONFIG_LAYOUT) + DrawCables(); + if (config_mode == CONFIG_SCREEN) + ScreenSetup(True); + return; + } + ++num_layouts; + l = (XF86ConfLayoutPtr)(l->list.next); + } + do { + XmuSnprintf(name, sizeof(name), "Layout%d", num_layouts); + ++num_layouts; + } while (xf86findLayout(name, + XF86Config->conf_layout_lst) != NULL); + l = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec)); + + l->lay_identifier = XtNewString(name); + XF86Config->conf_layout_lst = + xf86addLayout(XF86Config->conf_layout_lst, l); + layoutsme = XtVaCreateManagedWidget("sme", smeBSBObjectClass, + layoutp, + XtNlabel, name, + XtNmenuName, l->lay_identifier, + XtNleftBitmap, menuPixmap, + NULL); + XtAddCallback(layoutsme, XtNcallback, + SelectLayoutCallback, (XtPointer)l); + + layopt = XtCreatePopupShell(l->lay_identifier, simpleMenuWidgetClass, + layoutp, NULL, 0); + sme = XtCreateManagedWidget("default", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL); + sme = XtCreateManagedWidget("remove", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL); + XtRealizeWidget(layopt); + + computer.layout = l; + XtSetArg(args[0], XtNstring, name); + XtSetValues(layout, args, 1); + if (config_mode == CONFIG_LAYOUT) + DrawCables(); + if (config_mode == CONFIG_SCREEN) + ScreenSetup(True); + return; + } + + input = lay->lay_input_lst; + adj = lay->lay_adjacency_lst; + + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->config != NULL && + (computer.devices[i]->type == MOUSE || + computer.devices[i]->type == KEYBOARD)) { + while (input != NULL) { + if (strcmp(input->iref_inputdev_str, ((XF86ConfInputPtr) + (computer.devices[i]->config))->inp_identifier) == 0) { + computer.devices[i]->state = USED; + break; + } + input = (XF86ConfInputrefPtr)(input->list.next); + } + input = lay->lay_input_lst; + } + + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->type == CARD) { + while (adj != NULL) { + XF86ConfScreenPtr screen = adj->adj_screen; + + if (computer.devices[i]->config != NULL && + strcmp(screen->scrn_device_str, ((XF86ConfDevicePtr) + (computer.devices[i]->config))->dev_identifier) == 0) { + int j; + + for (j = 0; j < computer.num_screens; j++) + if (computer.screens[j]->card == computer.devices[i]) + break; + computer.screens[j]->card->state = USED; + if (computer.screens[j]->monitor != NULL) + computer.screens[j]->monitor->state = USED; + computer.screens[j]->state = USED; + } + + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + adj = lay->lay_adjacency_lst; + } + + if (config_mode == CONFIG_LAYOUT) + DrawCables(); + else if (config_mode == CONFIG_SCREEN) + ScreenSetup(True); +} + +/*ARGSUSED*/ +void +DefaultLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Widget layopt, sme; + int i; + char *str; + XF86ConfLayoutPtr prev, tmp, lay; + + str = w && XtParent(w) ? XtName(XtParent(w)) : NULL; + if (str == NULL) + return; + + prev = XF86Config->conf_layout_lst; + lay = xf86findLayout(str, prev); + if (prev == lay) + return; + + tmp = prev; + while (tmp != NULL) { + if (tmp == lay) + break; + prev = tmp; + tmp = (XF86ConfLayoutPtr)(tmp->list.next); + } + + for (i = 1; i < ((CompositeWidget)layoutp)->composite.num_children; i++) + XtDestroyWidget(((CompositeWidget)layoutp)->composite.children[i]); + for (i = 0; i < layoutp->core.num_popups; i++) + XtDestroyWidget(layoutp->core.popup_list[i]); + + prev->list.next = lay->list.next; + lay->list.next = XF86Config->conf_layout_lst; + XF86Config->conf_layout_lst = lay; + + layoutsme = NULL; + lay = XF86Config->conf_layout_lst; + while (lay != NULL) { + sme = XtVaCreateManagedWidget("sme", smeBSBObjectClass, + layoutp, + XtNlabel, lay->lay_identifier, + XtNmenuName, lay->lay_identifier, + XtNleftBitmap, menuPixmap, + NULL); + XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay); + if (layoutsme == NULL) + layoutsme = sme; + layopt = XtCreatePopupShell(lay->lay_identifier, simpleMenuWidgetClass, + layoutp, NULL, 0); + sme = XtCreateManagedWidget("default", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL); + sme = XtCreateManagedWidget("remove", smeBSBObjectClass, + layopt, NULL, 0); + XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL); + XtRealizeWidget(layopt); + + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + SelectLayoutCallback(layoutsme, + XF86Config->conf_layout_lst, NULL); +} + +/*ARGSUSED*/ +void +RemoveLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XF86ConfLayoutPtr prev, tmp, lay, rem; + Widget sme = NULL; + int i; + char *str; + Arg args[1]; + + str = w && XtParent(w) ? XtName(XtParent(w)) : NULL; + if (str == NULL) + return; + + prev = XF86Config->conf_layout_lst; + lay = xf86findLayout(str, prev); + tmp = prev; + while (tmp != NULL) { + if (tmp == lay) + break; + prev = tmp; + tmp = (XF86ConfLayoutPtr)(tmp->list.next); + } + + rem = lay; + if (tmp != NULL) + lay = (XF86ConfLayoutPtr)(tmp->list.next); + if (lay == NULL && prev != tmp) + lay = prev; + + if (lay != NULL) { + int i; + + for (i = 0; i < ((CompositeWidget)layoutp)->composite.num_children; + i++) { + XtSetArg(args[0], XtNlabel, &str); + XtGetValues(((CompositeWidget)layoutp)->composite.children[i], + args, 1); + if (strcmp(lay->lay_identifier, str) == 0) { + layoutsme = ((CompositeWidget)layoutp)->composite.children[i]; + break; + } + } + SelectLayoutCallback(layoutsme, lay, NULL); + } + else { + computer.layout = NULL; + XtSetArg(args[0], XtNstring, ""); + XtSetValues(layout, args, 1); + + for (i = 0; i < computer.num_devices; i++) + computer.devices[i]->state = UNUSED; + DrawCables(); + } + + for (i = 0; i < ((CompositeWidget)layoutp)->composite.num_children; i++) { + XtSetArg(args[0], XtNlabel, &str); + XtGetValues(((CompositeWidget)layoutp)->composite.children[i], args, 1); + if (strcmp(rem->lay_identifier, str) == 0) { + sme = ((CompositeWidget)layoutp)->composite.children[i]; + break; + } + } + + xf86removeLayout(XF86Config, rem); + if (sme) + XtDestroyWidget(sme); +} + +void +SetTip(xf86cfgDevice *device) +{ + XF86OptionPtr option = NULL; + char *tip, buffer[4096]; + Arg args[1]; + int len = 0; + + XtSetArg(args[0], XtNtip, &tip); + XtGetValues(device->widget, args, 1); + + switch (device->type) { + case MOUSE: { + XF86ConfInputPtr mouse = (XF86ConfInputPtr)device->config; + + if (mouse == NULL) + return; + len = XmuSnprintf(buffer, sizeof(buffer), + "Identifier \"%s\"\n" + "Driver \"mouse\"\n", + mouse->inp_identifier); + option = mouse->inp_option_lst; + } break; + case KEYBOARD: { + XF86ConfInputPtr keyboard = (XF86ConfInputPtr)device->config; + + if (keyboard == NULL) + return; + len = XmuSnprintf(buffer, sizeof(buffer), + "Identifier \"%s\"\n" + "Driver \"keyboard\"\n", + keyboard->inp_identifier); + option = keyboard->inp_option_lst; + } break; + case CARD: { + XF86ConfDevicePtr card = (XF86ConfDevicePtr)device->config; + + if (card == NULL) + return; + len = XmuSnprintf(buffer, sizeof(buffer), + "Identifier \"%s\"\n" + "Driver \"%s\"\n", + card->dev_identifier, + card->dev_driver); + option = card->dev_option_lst; + } break; + case MONITOR: { + XF86ConfMonitorPtr monitor = (XF86ConfMonitorPtr)device->config; + + if (monitor == NULL) + return; + if (monitor->mon_vendor != NULL) + len = XmuSnprintf(buffer, sizeof(buffer), + "Identifier \"%s\"\n" + "Vendor \"%s\"\n", + monitor->mon_identifier, + monitor->mon_vendor); + else + len = XmuSnprintf(buffer, sizeof(buffer), + "Identifier \"%s\"\n", + monitor->mon_identifier); + option = monitor->mon_option_lst; + } break; + case SCREEN: { + XF86ConfScreenPtr screen = (XF86ConfScreenPtr)device->config; + + if (screen == NULL) + return; + len = XmuSnprintf(buffer, sizeof(buffer), + "Identifier \"%s\"\n", + screen->scrn_identifier); + if (screen->scrn_device_str != NULL) + len += XmuSnprintf(buffer + len, sizeof(buffer), + "Device \"%s\"\n", + screen->scrn_device_str); + if (screen->scrn_monitor_str != NULL) + len += XmuSnprintf(buffer + len, sizeof(buffer), + "Monitor \"%s\"\n", + screen->scrn_monitor_str); + option = screen->scrn_option_lst; + } break; + case SERVER: { + len = XmuSnprintf(buffer, sizeof(buffer), + "%s\n", "Server Flags"); + option = XF86Config->conf_flags->flg_option_lst; + } break; + } + + while (option && len < sizeof(buffer) - 1) { + len += XmuSnprintf(buffer + len, sizeof(buffer) - len, + "Option \"%s\"", + option->opt_name); + if (option->opt_val != NULL) + len += XmuSnprintf(buffer + len, sizeof(buffer) - len, + " \"%s\"\n", + option->opt_val); + else + len += XmuSnprintf(buffer + len, sizeof(buffer) - len, + "%s", "\n"); + option = (XF86OptionPtr)(option->list.next); + } + + tip = buffer; + XtSetArg(args[0], XtNtip, tip); + XtSetValues(device->widget, args, 1); +} + +/*ARGSUSED*/ +void +AddDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + AddDevice((long)user_data, NULL, 6, 6); +} + +void +SmeConfigureDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i; + + switch ((long)user_data) { + case MOUSE: + case KEYBOARD: + case CARD: + case MONITOR: + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->type == (long)user_data) { + config = computer.devices[i]->widget; + ConfigureDeviceCallback(w, NULL, NULL); + } + break; + + /* hack for newly added devices */ + case -(MOUSE + 100): + case -(KEYBOARD + 100): + case -(CARD + 100): + case -(MONITOR + 100): + for (i = 0; i < computer.num_devices; i++) + if (-(computer.devices[i]->type + 100) == (long)user_data && + computer.devices[i]->config == NULL) { + config = computer.devices[i]->widget; + ConfigureDeviceCallback(w, NULL, NULL); + } + break; + + default: + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->config == user_data) { + config = computer.devices[i]->widget; + ConfigureDeviceCallback(w, NULL, NULL); + } + break; + } +} + +void +ConfigureDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i, j; + + if (config_mode == CONFIG_LAYOUT) { + for (i = 0; i < computer.num_devices; i++) { + if (computer.devices[i]->widget == config) { + switch (computer.devices[i]->type) { + case MOUSE: { + XF86ConfInputPtr mouse = + MouseConfig(computer.devices[i]->config); + + if (mouse != NULL && computer.devices[i]->config == NULL) { + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, + mouse); + computer.devices[i]->config = (XtPointer)mouse; + } + SetTip(computer.devices[i]); + } break; + case KEYBOARD: { + XF86ConfInputPtr keyboard = + KeyboardConfig(computer.devices[i]->config); + + if (keyboard != NULL && computer.devices[i]->config == NULL) { + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, + keyboard); + computer.devices[i]->config = (XtPointer)keyboard; + } + SetTip(computer.devices[i]); + } break; + case CARD: { + XF86ConfDevicePtr card = + CardConfig(computer.devices[i]->config); + + if (card != NULL && computer.devices[i]->config == NULL) { + XF86Config->conf_device_lst = + xf86addDevice(XF86Config->conf_device_lst, + card); + computer.devices[i]->config = (XtPointer)card; + } + SetTip(computer.devices[i]); + for (j = 0; j < computer.num_screens; j++) + if (computer.screens[j]->card->widget == config) + SetTip((xf86cfgDevice*)computer.screens[j]); + } break; + case MONITOR: { + XF86ConfMonitorPtr monitor = + MonitorConfig(computer.devices[i]->config); + + if (monitor != NULL && computer.devices[i]->config == NULL) { + XF86Config->conf_monitor_lst = + xf86addMonitor(XF86Config->conf_monitor_lst, + monitor); + computer.devices[i]->config = (XtPointer)monitor; + } + SetTip(computer.devices[i]); + for (j = 0; j < computer.num_screens; j++) + if (computer.screens[j]->monitor->widget == config) + SetTip((xf86cfgDevice*)computer.screens[j]); + } break; + } + /* Need to update because it may have been renamed */ + UpdateMenuDeviceList(computer.devices[i]->type); + break; + } + } + } + else if (config_mode == CONFIG_SCREEN) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->widget == config) { + if (ScreenConfig(computer.screens[i]->screen) != NULL) + SetTip((xf86cfgDevice*)computer.screens[i]); + } + } +} + +void +OptionsCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i; + XF86OptionPtr *options = NULL; +#ifdef USE_MODULES + xf86cfgModuleOptions *drv_opts = NULL; +#endif + + if (config_mode == CONFIG_SCREEN) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->widget == config) { + options = &(computer.screens[i]->screen->scrn_option_lst); + break; + } + } + else { + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->widget == config) + break; + + if (i >= computer.num_devices) { + if (XF86Config->conf_flags == NULL) + XF86Config->conf_flags = (XF86ConfFlagsPtr) + XtCalloc(1, sizeof(XF86ConfFlagsRec)); + options = &(XF86Config->conf_flags->flg_option_lst); + } + else { + switch (computer.devices[i]->type) { + case MOUSE: + case KEYBOARD: + options = (XF86OptionPtr*)&(((XF86ConfInputPtr) + (computer.devices[i]->config))->inp_option_lst); +#ifdef USE_MODULES + if (!nomodules) { + char *drv = ((XF86ConfInputPtr) + (computer.devices[i]->config))->inp_driver; + + if (drv) { + drv_opts = module_options; + while (drv_opts) { + if (drv_opts->type == InputModule && + strcmp(drv_opts->name, drv) == 0) + break; + drv_opts = drv_opts->next; + } + } + } +#endif + + break; + case CARD: + options = (XF86OptionPtr*)&(((XF86ConfDevicePtr) + (computer.devices[i]->config))->dev_option_lst); +#ifdef USE_MODULES + if (!nomodules) { + char *drv = ((XF86ConfDevicePtr) + (computer.devices[i]->config))->dev_driver; + + if (drv) { + drv_opts = module_options; + while (drv_opts) { + if (drv_opts->type == VideoModule && + strcmp(drv_opts->name, drv) == 0) + break; + drv_opts = drv_opts->next; + } + } + } +#endif + break; + case MONITOR: + options = (XF86OptionPtr*)&(((XF86ConfMonitorPtr) + (computer.devices[i]->config))->mon_option_lst); + break; + } + } + } + +#ifdef USE_MODULES + OptionsPopup(options, drv_opts ? drv_opts->name : NULL, + drv_opts ? drv_opts->option : NULL); +#else + OptionsPopup(options); +#endif + if (config_mode == CONFIG_SCREEN) { + XF86OptionPtr option, options; + int rotate = 0; + + options = computer.screens[i]->screen->scrn_option_lst; + if ((option = xf86findOption(options, "Rotate")) != NULL) { + if (option->opt_val != NULL) + rotate = strcasecmp(option->opt_val, "CW") == 0 ? 1 : + strcasecmp(option->opt_val, "CCW") == 0 ? -1 : 0; + XtFree(option->opt_val); + option->opt_val = XtNewString(rotate > 0 ? "CW" : "CCW"); + computer.screens[i]->rotate = rotate; + } + else + computer.screens[i]->rotate = 0; + UpdateScreenUI(); + AdjustScreenUI(); + SetTip((xf86cfgDevice*)computer.screens[i]); + } + else { + if (i >= computer.num_devices) + SetTip(&cpu_device); + else + SetTip(computer.devices[i]); + } +} + +void +EnableDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i; + + if (config_mode == CONFIG_SCREEN) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->widget == config) { + computer.screens[i]->state = USED; + computer.screens[i]->card->state = USED; + ScreenSetup(False); + return; + } + } + + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->widget == config) { + if (computer.devices[i]->state == USED) + return; + computer.devices[i]->state = USED; + DrawCables(); + break; + } + if (i >= computer.num_devices || computer.layout == NULL) + return; + switch (computer.devices[i]->type) { + case MOUSE: + case KEYBOARD: { + int nmouses = 0, nkeyboards = 0; + XF86ConfInputPtr input = (XF86ConfInputPtr) + (computer.devices[i]->config); + XF86ConfInputrefPtr nex, iref = computer.layout->lay_input_lst; + XF86OptionPtr option; + + nex = iref; + while (nex != NULL) { + if (strcasecmp(nex->iref_inputdev->inp_driver, "mouse") == 0) + ++nmouses; + else if (IS_KBDDRIV(nex->iref_inputdev->inp_driver)) + ++nkeyboards; + iref = nex; + nex = (XF86ConfInputrefPtr)(nex->list.next); + } + nex = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec)); + nex->list.next = NULL; + nex->iref_inputdev = input; + nex->iref_inputdev_str = XtNewString(input->inp_identifier); + if (nmouses == 0 && computer.devices[i]->type == MOUSE) + option = xf86newOption(XtNewString("CorePointer"), NULL); + else if (nkeyboards == 0 && computer.devices[i]->type == KEYBOARD) + option = xf86newOption(XtNewString("CoreKeyboard"), NULL); + else + option = xf86newOption(XtNewString("SendCoreEvents"), NULL); + nex->iref_option_lst = option; + computer.layout->lay_input_lst = + xf86addInputref(computer.layout->lay_input_lst, nex); + } break; + case CARD: + for (i = 0; i < computer.num_screens; i++) { + if (computer.screens[i]->card->widget == config && + computer.screens[i]->state != USED) { + XF86ConfAdjacencyPtr adj; + + adj = (XF86ConfAdjacencyPtr) + XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = computer.screens[i]->screen; + adj->adj_screen_str = XtNewString(computer.screens[i]-> + screen->scrn_identifier); + computer.layout->lay_adjacency_lst = (XF86ConfAdjacencyPtr) + xf86addListItem((GenericListPtr)computer.layout-> + lay_adjacency_lst, (GenericListPtr)adj); + computer.screens[i]->state = USED; + } + } + break; + case MONITOR: + break; + } +} + +void +DisableDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i; + + if (config_mode == CONFIG_SCREEN) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->widget == config) { + computer.screens[i]->state = UNUSED; + computer.screens[i]->card->state = UNUSED; + ScreenSetup(False); + return; + } + } + + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->widget == config) { + if (computer.devices[i]->state == UNUSED) + return; + computer.devices[i]->state = UNUSED; + DrawCables(); + break; + } + if (i >= computer.num_devices || computer.layout == NULL) + return; + switch (computer.devices[i]->type) { + case MOUSE: + case KEYBOARD: + xf86removeInputRef(computer.layout, + (XF86ConfInputPtr)(computer.devices[i]->config)); + break; + case CARD: { + XF86ConfAdjacencyPtr adj; + int j; + + if (computer.layout == NULL) + break; + for (j = 0; j < computer.num_screens; j++) + if (computer.screens[j]->card->widget == config) { + adj = computer.layout->lay_adjacency_lst; + while (adj != NULL) { + if (adj->adj_screen == computer.screens[j]->screen) { + xf86removeAdjacency(computer.layout, adj); + break; + } + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + computer.screens[j]->state = UNUSED; + break; + } + } break; + case MONITOR: + break; + } +} + +/* ARGSUSED */ +void +RemoveDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i, j; + + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->widget == config) { + RemoveScreen(computer.screens[i]->monitor, + computer.screens[i]->card); + ScreenSetup(False); + return; + } + + for (i = 0; i < computer.num_devices; i++) { + if (computer.devices[i]->widget == config) { + switch (computer.devices[i]->type) { + case MOUSE: + case KEYBOARD: + xf86removeInput(XF86Config, + (XF86ConfInputPtr)(computer.devices[i]->config)); + break; + case CARD: + case MONITOR: + break; + } + + if (computer.devices[i]->type == CARD) { + for (j = 0; j < computer.num_screens; j++) + if (computer.screens[j]->card == computer.devices[i]) { + RemoveScreen(computer.screens[j]->monitor, + computer.devices[i]); + --j; + } + if (computer.devices[i]->refcount <= 0) + xf86removeDevice(XF86Config, + (XF86ConfDevicePtr)(computer.devices[i]->config)); + } + else if (computer.devices[i]->type == MONITOR) { + for (j = 0; j < computer.num_screens; j++) + if (computer.screens[j]->monitor == computer.devices[i]) { + RemoveScreen(computer.devices[i], + computer.screens[j]->card); + --j; + } + if (computer.devices[i]->refcount <= 0) + xf86removeMonitor(XF86Config, + (XF86ConfMonitorPtr)(computer.devices[i]->config)); + } + + if (computer.devices[i]->refcount <= 0) { + int type = computer.devices[i]->type; + + XtDestroyWidget(computer.devices[i]->widget); + XtFree((XtPointer)computer.devices[i]); + if (--computer.num_devices > i) + memmove(&computer.devices[i], &computer.devices[i + 1], + (computer.num_devices - i) * sizeof(xf86cfgDevice*)); + + DrawCables(); + UpdateMenuDeviceList(type); + } + + break; + } + } +} + +void +UpdateMenuDeviceList(int type) +{ + Widget sme = NULL, menu = NULL; + int i, count; + static char *mouseM = "mouseM", *keyboardM = "keyboardM", + *cardM = "cardM", *monitorM = "monitorM"; + + for (i = count = 0; i < computer.num_devices; i++) + if (computer.devices[i]->type == type) + ++count; + + switch (type) { + case MOUSE: + sme = mouseSme; + menu = mouseMenu; + break; + case KEYBOARD: + sme = keyboardSme; + menu = keyboardMenu; + break; + case CARD: + sme = cardSme; + menu = cardMenu; + break; + case MONITOR: + sme = monitorSme; + menu = monitorMenu; + break; + } + + if (menu) + for (i = ((CompositeWidget)menu)->composite.num_children - 1; i >= 0; i--) + XtDestroyWidget(((CompositeWidget)menu)->composite.children[i]); + + if (count < 2) { + XtVaSetValues(sme, XtNmenuName, NULL, XtNleftBitmap, None, NULL); + return; + } + + switch (type) { + case MOUSE: + if (mouseMenu == NULL) + menu = mouseMenu = + XtCreatePopupShell(mouseM, simpleMenuWidgetClass, + XtParent(mouseSme), NULL, 0); + XtVaSetValues(mouseSme, XtNmenuName, mouseM, + XtNleftBitmap, menuPixmap, NULL); + break; + case KEYBOARD: + if (keyboardMenu == NULL) + menu = keyboardMenu = + XtCreatePopupShell(keyboardM, simpleMenuWidgetClass, + XtParent(keyboardSme), NULL, 0); + XtVaSetValues(keyboardSme, XtNmenuName, keyboardM, + XtNleftBitmap, menuPixmap, NULL); + break; + case CARD: + if (cardMenu == NULL) + menu = cardMenu = + XtCreatePopupShell(cardM, simpleMenuWidgetClass, + XtParent(cardSme), NULL, 0); + XtVaSetValues(cardSme, XtNmenuName, cardM, + XtNleftBitmap, menuPixmap, NULL); + break; + case MONITOR: + if (monitorMenu == NULL) + menu = monitorMenu = + XtCreatePopupShell(monitorM, simpleMenuWidgetClass, + XtParent(monitorSme), NULL, 0); + XtVaSetValues(monitorSme, XtNmenuName, monitorM, + XtNleftBitmap, menuPixmap, NULL); + break; + } + + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->type == type) { + char *label = NULL; + + if (computer.devices[i]->config) { + switch (type) { + case MOUSE: + case KEYBOARD: + label = ((XF86ConfInputPtr)computer.devices[i]->config) + ->inp_identifier; + break; + case CARD: + label = ((XF86ConfDevicePtr)computer.devices[i]->config) + ->dev_identifier; + break; + case MONITOR: + label = ((XF86ConfMonitorPtr)computer.devices[i]->config) + ->mon_identifier; + break; + } + } + else { + switch (type) { + case MOUSE: + label = "newMouse"; + break; + case KEYBOARD: + label = "newKeyboard"; + break; + case CARD: + label = "newCard"; + break; + case MONITOR: + label = "newMonitor"; + break; + } + } + + sme = XtCreateManagedWidget(label, smeBSBObjectClass, menu, NULL, 0); + XtAddCallback(sme, XtNcallback, SmeConfigureDeviceCallback, + computer.devices[i]->config ? + computer.devices[i]->config : + (XtPointer) (-((long)type + 100))); + } +} + +/*ARGSUSED*/ +void +SelectDeviceAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + device = w; + xpos = event->xbutton.x_root; + ypos = event->xbutton.y_root; + XDefineCursor(XtDisplay(device), XtWindow(device), no_cursor); + + if (config_mode == CONFIG_SCREEN) { + sxpos = device->core.x; + sypos = device->core.y; + } +} + +/*ARGSUSED*/ +void +MoveDeviceAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + int dx, dy, x, y, oldx, oldy; + + if (device == NULL || device != w) + return; + + dx = event->xbutton.x_root - xpos; + dy = event->xbutton.y_root - ypos; + + oldx = device->core.x; + oldy = device->core.y; + x = device->core.x + dx; + y = device->core.y + dy; + + if (x < 0) + x = 0; + else if (x + device->core.width > XtParent(device)->core.width) + x = XtParent(device)->core.width - device->core.width; + if (y < 0) + y = 0; + else if (y + device->core.height > XtParent(device)->core.height) + y = XtParent(device)->core.height - device->core.height; + + dx = x - oldx; + dy = y - oldy; + + XRaiseWindow(XtDisplay(device), XtWindow(device)); + XtMoveWidget(device, x, y); + + xpos += dx; + ypos += dy; +} + +/*ARGSUSED*/ +void +UnselectDeviceAction(Widget w, XEvent *ev, String *params, Cardinal *num_params) +{ + if (device != NULL) { + XUndefineCursor(XtDisplay(device), XtWindow(device)); + + if (config_mode == CONFIG_SCREEN) + ScreenSetup(False); + device = NULL; + } +} + +/*ARGSUSED*/ +void +DevicePopupMenu(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + static Widget configure, options, enable, disable, remove; + static int first = 1; + int i; + xf86cfgDevice *dev; + + if (first) { + first = 0; + + popup = XtCreatePopupShell("popup", simpleMenuWidgetClass, + toplevel, NULL, 0); + configure = XtCreateManagedWidget("configure", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(configure, XtNcallback, ConfigureDeviceCallback, NULL); + options = XtCreateManagedWidget("options", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(options, XtNcallback, OptionsCallback, NULL); + XtCreateManagedWidget("line", smeLineObjectClass, + popup, NULL, 0); + enable = XtCreateManagedWidget("enable", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(enable, XtNcallback, EnableDeviceCallback, NULL); + disable = XtCreateManagedWidget("disable", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(disable, XtNcallback, DisableDeviceCallback, NULL); + XtCreateManagedWidget("line", smeLineObjectClass, + popup, NULL, 0); + remove = XtCreateManagedWidget("remove", smeBSBObjectClass, + popup, NULL, 0); + XtAddCallback(remove, XtNcallback, RemoveDeviceCallback, NULL); + + XtRealizeWidget(popup); + } + + dev = NULL; + if (config_mode == CONFIG_LAYOUT) { + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->widget == w) { + dev = computer.devices[i]; + break; + } + if (i >= computer.num_devices && strcmp(XtName(w), "cpu")) + return; + if (dev == NULL) + dev = &cpu_device; + } + else if (config_mode == CONFIG_SCREEN) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->widget == w) { + dev = (xf86cfgDevice*)computer.screens[i]; + break; + } + } + if (dev == NULL) + return; + + config = w; + + if (dev->type != SERVER) { + XtSetSensitive(configure, True); + XtSetSensitive(remove, True); + XtSetSensitive(options, dev->config != NULL); + if (computer.layout == NULL || dev->config == NULL || + dev->type == MONITOR) { + XtSetSensitive(enable, False); + XtSetSensitive(disable, False); + } + else if (dev->state == USED) { + XtSetSensitive(enable, False); + XtSetSensitive(disable, True); + } + else { + XtSetSensitive(enable, True); + XtSetSensitive(disable, False); + } + } + else { + XtSetSensitive(configure, False); + XtSetSensitive(options, True); + XtSetSensitive(enable, False); + XtSetSensitive(disable, False); + XtSetSensitive(remove, False); + } + + XtMoveWidget(popup, event->xbutton.x_root, event->xbutton.y_root); + XtPopup(popup, XtGrabNone); +} + +/*ARGSUSED*/ +void +DevicePopdownMenu(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + if (popup && XtIsRealized(popup)) + XtPopdown(popup); +} + +void RenameLayoutAction(Widget w, XEvent *event, + String *params, Cardinal *num_params) +{ + XF86ConfLayoutPtr lay = XF86Config->conf_layout_lst; + Arg args[1]; + char *name; + + XtSetArg(args[0], XtNstring, &name); + XtGetValues(layout, args, 1); + + if (computer.layout == NULL || (computer.layout && + strcasecmp(name, computer.layout->lay_identifier)) == 0) + return; + + if (name == NULL && *name == '\0') { + /* tell user about error */ + return; + } + + while (lay) { + if (strcasecmp(name, lay->lay_identifier) == 0) + /* tell user about error */ + return; + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + XtSetArg(args[0], XtNlabel, name); + XtSetValues(layoutsme, args, 1); + xf86renameLayout(XF86Config, computer.layout, name); +} + +/*ARGSUSED*/ +static void +ComputerEventHandler(Widget w, XtPointer closure, + XEvent *event, Boolean *continue_to_dispatch) +{ + if (event->xexpose.count > 1) + return; + + if (config_mode == CONFIG_LAYOUT) + DrawCables(); +} + +void +DrawCables(void) +{ + Display *display; + Window window; + int ox, oy, i; + xf86cfgScreen **scr = computer.screens; + + if (config_mode != CONFIG_LAYOUT) + return; + + ox = computer.cpu->core.x + (computer.cpu->core.width >> 1); + oy = computer.cpu->core.y + (computer.cpu->core.height >> 1); + + display = XtDisplay(work); + window = XtWindow(work); + XClearWindow(display, window); + + for (i = 0; i < computer.num_devices; i++) { + if (computer.devices[i]->state == USED && + computer.devices[i]->type != MONITOR) + DrawCable(display, window, ox, oy, + computer.devices[i]->widget->core.x + + (computer.devices[i]->widget->core.width>>1), + computer.devices[i]->widget->core.y + + (computer.devices[i]->widget->core.height>>1)); + + } + for (i = 0; i < computer.num_screens; i++) { + if (scr[i]->monitor != NULL) + DrawCable(display, window, + scr[i]->card->widget->core.x + + (scr[i]->card->widget->core.width>>1), + scr[i]->card->widget->core.y + + (scr[i]->card->widget->core.height>>1), + scr[i]->monitor->widget->core.x + + (scr[i]->monitor->widget->core.width>>1), + scr[i]->monitor->widget->core.y + + (scr[i]->monitor->widget->core.height>>1)); + } +} + +static void +DrawCable(Display *display, Window window, int o_x, int o_y, int d_x, int d_y) +{ + XDrawLine(display, window, cablegcshadow, o_x, o_y, d_x, d_y); + XDrawLine(display, window, cablegc, o_x, o_y, d_x, d_y); +} + +/*ARGSUSED*/ +void +SetConfigModeCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i, mode = (long)user_data; + Arg args[3]; + char *ptr; + static Dimension height; + + if (mode == config_mode) + return; + XtSetArg(args[0], XtNlabel, &ptr); + XtGetValues(w, args, 1); + XtSetArg(args[0], XtNlabel, ptr); + XtSetValues(topMenu, args, 1); + + if (config_mode == CONFIG_LAYOUT) { + XtSetArg(args[0], XtNheight, &height); + XtGetValues(commands, args, 1); + for (i = 0; i < computer.num_devices; i++) + XtUnmapWidget(computer.devices[i]->widget); + XtUnmapWidget(commands); + XtUnmapWidget(computer.cpu); + XtSetSensitive(commands, False); + XtSetArg(args[0], XtNheight, 1); + XtSetArg(args[1], XtNmin, 1); + XtSetArg(args[2], XtNmax, 1); + XtSetValues(commands, args, 3); + } + else if (config_mode == CONFIG_SCREEN) { + for (i = 0; i < computer.num_screens; i++) + XtUnmapWidget(computer.screens[i]->widget); + } + else if (config_mode == CONFIG_MODELINE) { + VideoModeConfigureEnd(); + XtSetSensitive(layout, True); + XtSetSensitive(layoutm, True); + } + else if (config_mode == CONFIG_ACCESSX) { + AccessXConfigureEnd(); + XtSetSensitive(layout, True); + XtSetSensitive(layoutm, True); + } + + config_mode = mode; + XClearWindow(XtDisplay(work), XtWindow(work)); + if (mode == CONFIG_LAYOUT) { + for (i = 0; i < computer.num_devices; i++) + XtMapWidget(computer.devices[i]->widget); + XtSetArg(args[0], XtNheight, height); + XtSetArg(args[1], XtNmin, height); + XtSetArg(args[2], XtNmax, height); + XtSetValues(commands, args, 3); + XtMapWidget(commands); + XtMapWidget(computer.cpu); + XtSetSensitive(commands, True); + DrawCables(); + } + else if (mode == CONFIG_SCREEN) { + for (i = 0; i < computer.num_screens; i++) + XtMapWidget(computer.screens[i]->widget); + ScreenSetup(True); + } + else if (mode == CONFIG_MODELINE) { + VideoModeConfigureStart(); + XtSetSensitive(layout, False); + XtSetSensitive(layoutm, False); + } + else if (mode == CONFIG_ACCESSX) { + AccessXConfigureStart(); + XtSetSensitive(layout, False); + XtSetSensitive(layoutm, False); + } +} + +static void +ScreenSetup(Bool check) +{ + if (check) { + int i; + + for (i = 0; i < computer.num_layouts; i++) + if (computer.layouts[i]->layout == computer.layout) + break; + + /* Just to put the screens in the correct positions */ + if (i >= computer.num_layouts) + AdjustScreenUI(); + } + + UpdateScreenUI(); + AdjustScreenUI(); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.c b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.c new file mode 100644 index 000000000..545a67067 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.c @@ -0,0 +1,1378 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "xf86config.h" +#include "keyboard-cfg.h" +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/SimpleMenu.h> +#include <X11/Xaw/SmeBSB.h> + +#define IS_KBDDRIV(X) ((strcasecmp((X),"kbd") == 0)) + +/* + * Types + */ +typedef struct { + char *rules; + XkbRF_RulesPtr list; + XF86XkbDescInfo model; + XF86XkbDescInfo layout; + XF86XkbDescInfo variant; + XF86XkbDescInfo option; +} XF86XkbRulesDescInfo; + +/* + * Prototypes + */ +static void KeyboardRulesCallback(Widget, XtPointer, XtPointer); +static void KeyboardModelCallback(Widget, XtPointer, XtPointer); +static void KeyboardLayoutCallback(Widget, XtPointer, XtPointer); +static void KeyboardVariantCallback(Widget, XtPointer, XtPointer); +static void KeyboardOptionsCallback(Widget, XtPointer, XtPointer); +static void KeyboardApplyCallback(Widget, XtPointer, XtPointer); +static Bool KeyboardConfigCheck(void); +static void XkbUIEventHandler(Widget, XtPointer, XEvent*, Boolean*); +static XF86XkbRulesDescInfo *GetXkbRulesDesc(char*); +static void UpdateRulesPopups(void); + +/* + * Initialization + */ +static XF86XkbRulesDescInfo **xkb_desc, *xkb_rules; +static int num_xkb_desc; +static char *XkbRulesDir = "share/X11/xkb/rules/"; +#ifdef XFREE98_XKB +static char *XkbRulesFile = "xfree98"; +#else +static char *XkbRulesFile = __XKBDEFRULES__; +#endif +static XF86ConfInputPtr current_input; + +static char *rules, *model, *layout, *variant, *options; +static Widget kbd, rulesb, modelb, layoutb, variantb, optionsb, + modelp, layoutp, variantp, optionsp; +static XkbInfo **xkb_infos; +static int num_xkb_infos; +XkbInfo *xkb_info; + +static Widget apply; + +/* + * Implementation + */ +/*ARGSUSED*/ +XtPointer +KeyboardConfig(XtPointer config) +{ + XF86ConfInputPtr keyboard = (XF86ConfInputPtr)config; + XF86OptionPtr option; + Arg args[1]; + static char *XkbRules = "XkbRules", *XkbModel = "XkbModel", + *XkbLayout = "XkbLayout", *XkbVariant = "XkbVariant", + *XkbOptions = "XkbOptions"; + XF86XkbRulesDescInfo *info; + char *omodel, *olayout, *ovariant, *ooptions; + + InitializeKeyboard(); + rules = xkb_rules->rules; + if (xkb_info->config.rules_file == NULL) + xkb_info->config.rules_file = rules; + + if (options) + XtFree(options); + options = NULL; + + if (xkb_info->conf == NULL) + xkb_info->conf = keyboard; + + if (xkb_info->conf != keyboard) { + int i; + + for (i = 0; i < num_xkb_infos; i++) + if (xkb_infos[i]->conf == keyboard) { + xkb_info = xkb_infos[i]; + break; + } + + if (i >= num_xkb_infos) { + int timeout = 10; + + xkb_info = (XkbInfo*)XtCalloc(1, sizeof(XkbInfo)); + xkb_info->conf = keyboard; + xkb_infos = (XkbInfo**) + XtRealloc((XtPointer)xkb_infos, sizeof(XkbInfo*) * + (num_xkb_infos + 1)); + xkb_infos[num_xkb_infos++] = xkb_info; + + xkb_info->conf = keyboard; + bzero((char*)&(xkb_info->defs), sizeof(XkbRF_VarDefsRec)); + while (timeout > 0) { + xkb_info->xkb = + XkbGetKeyboard(XtDisplay(configp), + XkbGBN_AllComponentsMask, XkbUseCoreKbd); + if (xkb_info->xkb == NULL) { + timeout -= 1; + sleep(1); + } + else + break; + } + if (timeout <= 0) { + fprintf(stderr, "Couldn't get keyboard\n"); + } + if (xkb_info->xkb && xkb_info->xkb->names && xkb_info->xkb->geom && + xkb_info->xkb->names->geometry == 0) + xkb_info->xkb->names->geometry = xkb_info->xkb->geom->name; + } + + /* check for removed devices */ + for (i = 0; i < num_xkb_infos; i++) { + XF86ConfInputPtr key = XF86Config->conf_input_lst; + + while (key != NULL) { + if (IS_KBDDRIV(key->inp_driver) && xkb_infos[i]->conf == key) + break; + key = (XF86ConfInputPtr)(key->list.next); + } + if (xkb_infos[i]->conf != NULL && key == NULL) { + XkbFreeKeyboard(xkb_infos[i]->xkb, 0, False); + XtFree((XtPointer)xkb_infos[i]); + if (--num_xkb_infos > i) + memmove(&xkb_infos[i], &xkb_infos[i + 1], + (num_xkb_infos - i) * sizeof(XkbInfo*)); + } + } + } + + current_input = keyboard; + + if (keyboard != NULL) { + if ((option = xf86findOption(keyboard->inp_option_lst, XkbRules)) != NULL) { + if (strcmp(rules, option->opt_val)) { + XF86XkbRulesDescInfo *info = GetXkbRulesDesc(option->opt_val); + + if (info) { + rules = info->rules; + UpdateRulesPopups(); + } + } + } + if ((option = xf86findOption(keyboard->inp_option_lst, XkbModel)) != NULL) + xkb_info->defs.model = model = option->opt_val; + else + xkb_info->defs.model = model = xkb_rules->model.name[0]; + if ((option = xf86findOption(keyboard->inp_option_lst, XkbLayout)) != NULL) + xkb_info->defs.layout = layout = option->opt_val; + else + xkb_info->defs.layout = layout = xkb_rules->layout.name[0]; + if ((option = xf86findOption(keyboard->inp_option_lst, XkbVariant)) != NULL) + xkb_info->defs.variant = variant = option->opt_val; + else + xkb_info->defs.variant = variant = NULL; + + if ((option = xf86findOption(keyboard->inp_option_lst, XkbOptions)) != NULL) + xkb_info->defs.options = options = XtNewString(option->opt_val); + else + xkb_info->defs.options = options = NULL; + + XtSetArg(args[0], XtNstring, keyboard->inp_identifier); + XtSetValues(ident_widget, args, 1); + + (void)UpdateKeyboard(False); + } + else { + XF86ConfInputPtr input = XF86Config->conf_input_lst; + char keyboard_name[48]; + int nkeyboards = 0; + + while (input != NULL) { + if (IS_KBDDRIV(input->inp_driver)) + ++nkeyboards; + input = (XF86ConfInputPtr)(input->list.next); + } + do { + XmuSnprintf(keyboard_name, sizeof(keyboard_name), + "Keyboard%d", nkeyboards); + ++nkeyboards; + } while (xf86findInput(keyboard_name, + XF86Config->conf_input_lst)); + + model = xkb_rules->model.name[0]; + layout = xkb_rules->layout.name[0]; + variant = ""; + options = XtNewString(""); + XtSetArg(args[0], XtNstring, keyboard_name); + XtSetValues(ident_widget, args, 1); + } + + info = xkb_rules; + omodel = model; + olayout = layout; + ovariant = variant; + ooptions = options ? XtNewString(options) : NULL; + + xf86info.cur_list = KEYBOARD; + XtSetSensitive(back, xf86info.lists[KEYBOARD].cur_function > 0); + XtSetSensitive(next, xf86info.lists[KEYBOARD].cur_function < + xf86info.lists[KEYBOARD].num_functions - 1); + (xf86info.lists[KEYBOARD].functions[xf86info.lists[KEYBOARD].cur_function]) + (&xf86info); + + if (ConfigLoop(KeyboardConfigCheck) == True) { + if (keyboard == NULL) { + keyboard = XtNew(XF86ConfInputRec); + keyboard->list.next = NULL; + keyboard->inp_identifier = XtNewString(ident_string); + keyboard->inp_driver = XtNewString("kbd"); + keyboard->inp_option_lst = xf86newOption(XtNewString(XkbRules), + XtNewString(rules)); + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbModel), XtNewString(model)); + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbLayout), XtNewString(layout)); + if (variant && *variant) + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbVariant), XtNewString(variant)); + if (options && *options) { + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbOptions), options); + options = NULL; + } + keyboard->inp_comment = NULL; + } + else { + int i; + char *str; + + XtSetArg(args[0], XtNlabel, &str); + XtGetValues(modelb, args, 1); + for (i = 0; i < xkb_rules->model.nelem; i++) + if (strcmp(xkb_rules->model.desc[i], str) == 0) { + model = xkb_rules->model.name[i]; + break; + } + + XtSetArg(args[0], XtNlabel, &str); + XtGetValues(layoutb, args, 1); + for (i = 0; i < xkb_rules->layout.nelem; i++) + if (strcmp(xkb_rules->layout.desc[i], str) == 0) { + layout = xkb_rules->layout.name[i]; + break; + } + + if ((option = xf86findOption(keyboard->inp_option_lst, XkbRules)) + != NULL) { + XtFree(option->opt_val); + option->opt_val = XtNewString(rules); + XtFree(option->opt_comment); + option->opt_comment = NULL; + } + else + keyboard->inp_option_lst = + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbRules), XtNewString(rules)); + + if ((option = xf86findOption(keyboard->inp_option_lst, XkbModel)) + != NULL) { + XtFree(option->opt_val); + option->opt_val = XtNewString(model); + XtFree(option->opt_comment); + option->opt_comment = NULL; + } + else + keyboard->inp_option_lst = + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbModel), XtNewString(model)); + XtFree(xkb_info->config.model); + xkb_info->config.model = XtNewString(model); + + if ((option = xf86findOption(keyboard->inp_option_lst, XkbLayout)) + != NULL) { + XtFree(option->opt_val); + option->opt_val = XtNewString(layout); + } + else + keyboard->inp_option_lst = + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbLayout), XtNewString(layout)); + XtFree(xkb_info->config.layout); + xkb_info->config.layout = XtNewString(layout); + + if ((option = xf86findOption(keyboard->inp_option_lst, XkbVariant)) + != NULL) { + if (variant && *variant) { + XtFree(option->opt_val); + option->opt_val = XtNewString(variant); + } + else + xf86removeOption(&keyboard->inp_option_lst, XkbVariant); + } + else if (variant && *variant) + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbVariant), XtNewString(variant)); + XtFree(xkb_info->config.variant); + xkb_info->config.variant = variant && *variant ? + XtNewString(variant) : NULL; + + XtFree(xkb_info->config.options); + xkb_info->config.options = options && *options ? + XtNewString(options) : NULL; + if ((option = xf86findOption(keyboard->inp_option_lst, XkbOptions)) + != NULL) { + if (options && *options) { + XtFree(option->opt_val); + option->opt_val = options; + options = NULL; + } + else + xf86removeOption(&keyboard->inp_option_lst, XkbOptions); + } + else if (options && *options) { + xf86addNewOption(keyboard->inp_option_lst, + XtNewString(XkbOptions), options); + options = NULL; + } + } + if (strcasecmp(keyboard->inp_identifier, ident_string)) + xf86renameInput(XF86Config, keyboard, ident_string); + + xkb_info->conf = keyboard; + xkb_info->config.rules_file = rules; + + return ((XtPointer)keyboard); + } + + xkb_rules = info; + rules = info->rules; + model = omodel; + layout = olayout; + variant = ovariant; + XtFree(options); + options = ooptions; + + return (NULL); +} + +static Bool +KeyboardConfigCheck(void) +{ + XF86ConfInputPtr keyboard = XF86Config->conf_input_lst; + + while (keyboard != NULL) { + if (keyboard != current_input && + strcasecmp(ident_string, keyboard->inp_identifier) == 0) + return (False); + keyboard = (XF86ConfInputPtr)(keyboard->list.next); + } + + return (True); +} + +/*ARGSUSED*/ +static void +XkbUIEventHandler(Widget w, XtPointer closure, + XEvent *event, Boolean *continue_to_dispatch) +{ + XkbUI_ViewOptsRec opts; + XkbUI_ViewPtr view; + int width, height, bd; + + if (event->xexpose.count > 1) + return; + + bzero((char *)&opts, sizeof(opts)); + bd = 1; + opts.present = XkbUI_SizeMask | XkbUI_ColormapMask | + XkbUI_MarginMask | XkbUI_OffsetMask; + opts.margin_width = opts.margin_height = 0; + opts.viewport.x = opts.viewport.y = bd; + width = opts.viewport.width = w->core.width - 2 * bd; + height = opts.viewport.height = w->core.height - 2 * bd; + opts.cmap = w->core.colormap; + + if ((view = XkbUI_Init(XtDisplay(w), XtWindow(w), width, height, + xkb_info->xkb, &opts)) != NULL) { + XkbUI_DrawRegion(view, NULL); + free(view); + } +} + +void +InitializeKeyboard(void) +{ + int major, minor, op, event, error; + static int first = 1; + int timeout = 5; + XF86ConfInputPtr keyboard = XF86Config->conf_input_lst; + XF86OptionPtr option; + char name[PATH_MAX]; + FILE *file; + + if (!first) + return; + first = 0; + + major = XkbMajorVersion; + minor = XkbMinorVersion; + if (XkbQueryExtension(DPY, &op, &event, &error, &major, &minor) == 0) { + fprintf(stderr, "Unable to initialize XKEYBOARD extension"); + exit(1); + } + + xkb_info = (XkbInfo *)XtCalloc(1, sizeof(XkbInfo)); + xkb_info->conf = NULL; + xkb_infos = (XkbInfo**)XtCalloc(1, sizeof(XkbInfo*)); + num_xkb_infos = 1; + xkb_infos[0] = xkb_info; + bzero((char*)&(xkb_info->defs), sizeof(XkbRF_VarDefsRec)); + + while (timeout > 0) { + xkb_info->xkb = + XkbGetKeyboard(DPY, XkbGBN_AllComponentsMask, XkbUseCoreKbd); + if (xkb_info->xkb == NULL) { + timeout -= 1; + sleep(1); + } + else + break; + } + if (timeout <= 0) { + fprintf(stderr, "Couldn't get keyboard\n"); + } + if (xkb_info->xkb && xkb_info->xkb->names && xkb_info->xkb->geom && + xkb_info->xkb->names->geometry == 0) + xkb_info->xkb->names->geometry = xkb_info->xkb->geom->name; + + /* Load configuration */ + XmuSnprintf(name, sizeof(name), "%s%s", XkbConfigDir, XkbConfigFile); + file = fopen(name, "r"); + if (file != NULL) { + if (XkbCFParse(file, XkbCFDflts, xkb_info->xkb, &xkb_info->config) == 0) { + fprintf(stderr, "Error parsing config file: "); + XkbCFReportError(stderr, name, xkb_info->config.error, + xkb_info->config.line); + } + fclose(file); + } + + xkb_rules = GetXkbRulesDesc(xkb_info->config.rules_file != NULL ? + xkb_info->config.rules_file : XkbRulesFile); + if (xkb_rules == NULL) + /* error message was printed */ + exit(1); + + /* XXX Assumes the first keyboard is the core keyboard */ + while (keyboard != NULL) { + if (IS_KBDDRIV(keyboard->inp_driver)) + break; + keyboard = (XF86ConfInputPtr)(keyboard->list.next); + } + if (keyboard == NULL) + return; + + if (xkb_info->config.rules_file != NULL) + rules = xkb_info->config.rules_file; + else if ((option = xf86findOption(keyboard->inp_option_lst, "XkbRules")) + != NULL) + rules = option->opt_val; + else + rules = XkbRulesFile; + + if (strcmp(rules, xkb_rules->rules)) { + xkb_rules = GetXkbRulesDesc(rules); + if (xkb_rules == NULL) + /* error message was printed */ + exit(1); + } + { + FILE *fp; + char filename[1024]; + + XmuSnprintf(filename, sizeof(filename), "%s%s", + XkbRulesDir, xkb_rules->rules); + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open rules file\n"); + exit(1); + } + + if (!XkbRF_LoadRules(fp, xkb_rules->list)) { + fclose(fp); + fprintf(stderr, "Can't load rules\n"); + exit(1); + } + fclose(fp); + } + + if (xkb_info->config.rules_file == NULL) + xkb_info->config.rules_file = xkb_rules->rules; + + if (xkb_info->config.model != NULL) + xkb_info->defs.model = xkb_info->config.model; + else if ((option = xf86findOption(keyboard->inp_option_lst, "XkbModel")) + != NULL) + xkb_info->defs.model = option->opt_val; + else + xkb_info->defs.model = xkb_rules->model.name[0]; + + if (xkb_info->config.layout != NULL) + xkb_info->defs.layout = xkb_info->config.layout; + else if ((option = xf86findOption(keyboard->inp_option_lst, "XkbLayout")) + != NULL) + xkb_info->defs.layout = option->opt_val; + else + xkb_info->defs.layout = xkb_rules->layout.name[0]; + + if (xkb_info->config.variant != NULL) + xkb_info->defs.variant = xkb_info->config.variant; + else if ((option = xf86findOption(keyboard->inp_option_lst, "XkbVariant")) + != NULL) + xkb_info->defs.variant = option->opt_val; + else + xkb_info->defs.variant = NULL; + + if (xkb_info->config.options != NULL) + xkb_info->defs.options = xkb_info->config.options; + else if ((option = xf86findOption(keyboard->inp_option_lst, "XkbOptions")) + != NULL) + xkb_info->defs.options = option->opt_val; + else + xkb_info->defs.options = NULL; + + if (xkb_info->xkb == NULL) { + /* Try again */ + XkbComponentNamesRec comps; + + bzero((char*)&comps, sizeof(XkbComponentNamesRec)); + XkbRF_GetComponents(xkb_rules->list, &(xkb_info->defs), &comps); + + xkb_info->xkb = XkbGetKeyboardByName(DPY, XkbUseCoreKbd, &comps, + XkbGBN_AllComponentsMask, 0, 0); + } +} + +static XF86XkbRulesDescInfo * +GetXkbRulesDesc(char *rules) +{ + int i; + XkbRF_RulesPtr list; + char filename[1024]; + XF86XkbRulesDescInfo *info; + + if (rules == NULL) + return (NULL); + + for (i = 0; i < num_xkb_desc; i++) + if (strcmp(rules, xkb_desc[i]->rules) == 0) + return (xkb_desc[i]); + + XmuSnprintf(filename, sizeof(filename), "%s%s", XkbRulesDir, rules); + if ((list = XkbRF_Create(0, 0)) == NULL || + !XkbRF_LoadDescriptionsByName(filename, NULL, list)) { + fprintf(stderr, "Can't create rules structure\n"); + return (NULL); + } + + info = (XF86XkbRulesDescInfo*)XtCalloc(1, sizeof(XF86XkbRulesDescInfo)); + xkb_desc = (XF86XkbRulesDescInfo**) + XtRealloc((XtPointer)xkb_desc, + sizeof(XF86XkbRulesDescInfo*) * (num_xkb_desc + 1)); + xkb_desc[num_xkb_desc++] = info; + info->rules = XtNewString(rules); + for (i = 0; i < list->models.num_desc; i++) { + if (i % 16 == 0) { + info->model.name = (char**)XtRealloc((XtPointer)info->model.name, + (i + 16) * sizeof(char*)); + info->model.desc = (char**)XtRealloc((XtPointer)info->model.desc, + (i + 16) * sizeof(char*)); + } + info->model.name[i] = XtNewString(list->models.desc[i].name); + info->model.desc[i] = XtNewString(list->models.desc[i].desc); + } + info->model.nelem = i; + + for (i = 0; i < list->layouts.num_desc; i++) { + if (i % 16 == 0) { + info->layout.name = (char**)XtRealloc((XtPointer)info->layout.name, + (i + 16) * sizeof(char*)); + info->layout.desc = (char**)XtRealloc((XtPointer)info->layout.desc, + (i + 16) * sizeof(char*)); + } + info->layout.name[i] = XtNewString(list->layouts.desc[i].name); + info->layout.desc[i] = XtNewString(list->layouts.desc[i].desc); + } + info->layout.nelem = i; + + for (i = 0; i < list->variants.num_desc; i++) { + if (i % 16 == 0) { + info->variant.name = (char**)XtRealloc((XtPointer)info->variant.name, + (i + 16) * sizeof(char*)); + info->variant.desc = (char**)XtRealloc((XtPointer)info->variant.desc, + (i + 16) * sizeof(char*)); + } + info->variant.name[i] = XtNewString(list->variants.desc[i].name); + info->variant.desc[i] = XtNewString(list->variants.desc[i].desc); + } + info->variant.nelem = i; + + for (i = 0; i < list->options.num_desc; i++) { + if (i % 16 == 0) { + info->option.name = (char**)XtRealloc((XtPointer)info->option.name, + (i + 16) * sizeof(char*)); + info->option.desc = (char**)XtRealloc((XtPointer)info->option.desc, + (i + 16) * sizeof(char*)); + } + info->option.name[i] = XtNewString(list->options.desc[i].name); + info->option.desc[i] = XtNewString(list->options.desc[i].desc); + } + info->option.nelem = i; + info->list = list; + + return (info); +} + +static xf86ConfigSymTabRec ax_controls[] = +{ + {XkbRepeatKeysMask, "RepeatKeys"}, + {XkbSlowKeysMask, "SlowKeys"}, + {XkbBounceKeysMask, "BounceKeys"}, + {XkbStickyKeysMask, "StickyKeys"}, + {XkbMouseKeysMask, "MouseKeys"}, + {XkbMouseKeysAccelMask, "MouseKeysAccel"}, + {XkbAccessXKeysMask, "AccessxKeys"}, + {XkbAccessXTimeoutMask, "AccessxTimeout"}, + {XkbAccessXFeedbackMask, "AccessxFeedback"}, + {XkbAudibleBellMask, "AudibleBell"}, + {XkbOverlay1Mask, "Overlay1"}, + {XkbOverlay2Mask, "Overlay2"}, + {XkbIgnoreGroupLockMask, "IgnoreGroupLock"}, + {-1, ""}, +}; + +static xf86ConfigSymTabRec ax_feedback[] = +{ + {XkbAX_SKPressFBMask, "SlowKeysPress"}, + {XkbAX_SKAcceptFBMask, "SlowKeysAccept"}, + {XkbAX_FeatureFBMask, "Feature"}, + {XkbAX_SlowWarnFBMask, "SlowWarn"}, + {XkbAX_IndicatorFBMask, "Indicator"}, + {XkbAX_StickyKeysFBMask, "StickyKeys"}, + {XkbAX_TwoKeysMask, "TwoKeys"}, + {XkbAX_LatchToLockMask, "LatchToLock"}, + {XkbAX_SKReleaseFBMask, "SlowKeysRelease"}, + {XkbAX_SKRejectFBMask, "SlowkeysReject"}, + {XkbAX_BKRejectFBMask, "BounceKeysReject"}, + {XkbAX_DumbBellFBMask, "DumbBell"}, + {-1, ""}, +}; + +Bool +WriteXKBConfiguration(char *filename, XkbConfigRtrnPtr conf) +{ + FILE *fp; + int i, count; + + if (filename == NULL || conf == NULL || + (fp = fopen(filename, "w")) == NULL) + return (False); + + if (conf->rules_file != NULL) + fprintf(fp, "Rules = \"%s\"\n", + conf->rules_file); + if (conf->model != NULL) + fprintf(fp, "Model = \"%s\"\n", + conf->model); + if (conf->layout != NULL) + fprintf(fp, "Layout = \"%s\"\n", + conf->layout); + if (conf->variant != NULL) + fprintf(fp, "Variant = \"%s\"\n", + conf->variant); + if (conf->options != NULL) + fprintf(fp, "Options = \"%s\"\n", + conf->options); + if (conf->keymap != NULL) + fprintf(fp, "Keymap = %s\n", + conf->keymap); + if (conf->keycodes != NULL) + fprintf(fp, "Keycodes = %s\n", + conf->keycodes); + if (conf->geometry != NULL) + fprintf(fp, "Geometry = %s\n", + conf->geometry); + if (conf->phys_symbols != NULL) + fprintf(fp, "RealSymbols = %s\n", + conf->phys_symbols); + if (conf->symbols != NULL) + fprintf(fp, "Symbols = %s\n", + conf->symbols); + if (conf->types != NULL) + fprintf(fp, "Types = %s\n", + conf->types); + if (conf->compat != NULL) + fprintf(fp, "Compat = %s\n", + conf->compat); + + if (conf->click_volume > 0) + fprintf(fp, "ClickVolume = %d\n", + conf->click_volume); + if (conf->bell_volume > 0) + fprintf(fp, "BellVolume = %d\n", + conf->bell_volume); + if (conf->bell_pitch > 0) + fprintf(fp, "BellPitch = %d\n", + conf->bell_pitch); + if (conf->bell_duration > 0) + fprintf(fp, "BellDuration = %d\n", + conf->bell_duration); + + if (conf->repeat_delay > 0) + fprintf(fp, "RepeatDelay = %d\n", + conf->repeat_delay); + if (conf->repeat_interval > 0) + fprintf(fp, "RepeatInterval = %d\n", + conf->repeat_interval); + + if (conf->slow_keys_delay > 0) + fprintf(fp, "SlowKeysDelay = %d\n", + conf->slow_keys_delay); + + if (conf->debounce_delay > 0) + fprintf(fp, "DebounceDelay = %d\n", + conf->debounce_delay); + + if (conf->mk_delay > 0) + fprintf(fp, "MouseKeysDelay = %d\n", + conf->mk_delay); + if (conf->mk_interval > 0) + fprintf(fp, "MouseKeysInterval = %d\n", + conf->mk_interval); + if (conf->mk_time_to_max > 0) + fprintf(fp, "MouseKeysTimeToMax = %d\n", + conf->mk_time_to_max); + if (conf->mk_max_speed > 0) + fprintf(fp, "MouseKeysMaxSpeed = %d\n", + conf->mk_max_speed); + fprintf(fp, "MouseKeysCurve = %d\n", conf->mk_curve); + + if (conf->ax_timeout) + fprintf(fp, "AccessXTimeout = %d\n", + conf->ax_timeout); + if (conf->initial_ctrls != 0) { + fprintf(fp, "Controls %c= ", + conf->replace_initial_ctrls ? ' ' : '+'); + for (i = count = 0; *ax_controls[i].name; i++) + if ((conf->initial_ctrls & ax_controls[i].token) + == ax_controls[i].token) + fprintf(fp, "%s%s", count++ ? " + " : "", + ax_controls[i].name); + fprintf(fp, "\n"); + } + if (conf->axt_ctrls_on != 0) { + fprintf(fp, "AcessXTimeoutCtrlsOn %c= ", + conf->replace_axt_ctrls_on ? ' ' : '+'); + for (i = count = 0; *ax_controls[i].name; i++) + if ((conf->axt_ctrls_on & ax_controls[i].token) + == ax_controls[i].token) + fprintf(fp, "%s%s", count++ ? " + " : "", + ax_controls[i].name); + fprintf(fp, "\n"); + } + if (conf->axt_ctrls_off != 0) { + fprintf(fp, "AcessXTimeoutCtrlsOff %c= ", + conf->replace_axt_ctrls_off ? ' ' : '-'); + for (i = count = 0; *ax_controls[i].name; i++) + if ((conf->axt_ctrls_off & ax_controls[i].token) + == ax_controls[i].token) + fprintf(fp, "%s%s", count++ ? " + " : "", + ax_controls[i].name); + fprintf(fp, "\n"); + } + + if (conf->initial_opts != 0) { + fprintf(fp, "Feedback %c= ", + conf->replace_initial_opts ? ' ' : '+'); + for (i = count = 0; *ax_feedback[i].name; i++) + if ((conf->initial_opts & ax_feedback[i].token) + == ax_feedback[i].token) + fprintf(fp, "%s%s", count++ ? " + " : "", + ax_feedback[i].name); + fprintf(fp, "\n"); + } + if (conf->axt_opts_on != 0) { + fprintf(fp, "AcessXTimeoutFeedbackOn %c= ", + conf->replace_axt_opts_on ? ' ' : '+'); + for (i = count = 0; *ax_controls[i].name; i++) + if ((conf->axt_opts_on & ax_feedback[i].token) + == ax_feedback[i].token) + fprintf(fp, "%s%s", count++ ? " + " : "", + ax_feedback[i].name); + fprintf(fp, "\n"); + } + if (conf->axt_opts_off != 0) { + fprintf(fp, "AcessXTimeoutFeedbackOff%c= ", + conf->replace_axt_opts_off ? ' ' : '-'); + for (i = count = 0; *ax_feedback[i].name; i++) + if ((conf->axt_opts_off & ax_feedback[i].token) + == ax_feedback[i].token) + fprintf(fp, "%s%s", count++ ? " + " : "", + ax_feedback[i].name); + fprintf(fp, "\n"); + } + + fclose(fp); + + return (True); +} + +Bool +UpdateKeyboard(Bool load) +{ + XkbComponentNamesRec comps; + XkbDescPtr xkb; + + bzero((char*)&comps, sizeof(XkbComponentNamesRec)); + XkbRF_GetComponents(xkb_rules->list, &(xkb_info->defs), &comps); + + xkb = XkbGetKeyboardByName(DPY, XkbUseCoreKbd, &comps, + XkbGBN_AllComponentsMask, 0, load); + + if (xkb == NULL || xkb->geom == NULL) { + fprintf(stderr, "Couldn't get keyboard\n"); + return (False); + } + if (xkb_info->xkb && xkb_info->xkb->names && xkb_info->xkb->geom && + xkb_info->xkb->names->geometry == 0) + xkb_info->xkb->names->geometry = xkb_info->xkb->geom->name; + + XkbFreeKeyboard(xkb_info->xkb, 0, False); + + xkb_info->xkb = xkb; + + XtFree(comps.keymap); + XtFree(comps.keycodes); + XtFree(comps.compat); + XtFree(comps.types); + XtFree(comps.symbols); + XtFree(comps.geometry); + + if (kbd != NULL) + XClearArea(XtDisplay(configp), XtWindow(kbd), 0, 0, 0, 0, True); + + return (True); +} + +static void +KeyboardRulesCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i; + FILE *fp; + Arg args[1]; + char filename[1024], *omodel, *olayout, *ovariant, *ooptions, + *dmodel, *dlayout, *dvariant; + XF86XkbRulesDescInfo *oxkb_rules, *info = GetXkbRulesDesc(XtName(w)); + + if (strcmp(XtName(w), rules) == 0 || info == NULL) + /* a error message was printed */ + return; + + XmuSnprintf(filename, sizeof(filename), "%s%s", + XkbRulesDir, info->rules); + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open rules file\n"); + return; + } + + if (!XkbRF_LoadRules(fp, info->list)) { + fclose(fp); + fprintf(stderr, "Can't load rules\n"); + return; + } + fclose(fp); + + oxkb_rules = xkb_rules; + omodel = xkb_info->defs.model; + olayout = xkb_info->defs.layout; + ovariant = xkb_info->defs.variant; + ooptions = xkb_info->defs.options; + + if (omodel) { + for (i = 0; i < info->model.nelem; i++) { + if (strcmp(omodel, info->model.name[i]) == 0) + break; + } + } + else + i = 0; + model = xkb_info->defs.model = info->model.name + [i < info->model.nelem ? i : 0]; + dmodel = info->model.desc[i < info->model.nelem ? i : 0]; + + if (olayout) { + for (i = 0; i < info->layout.nelem; i++) { + if (strcmp(olayout, info->layout.name[i]) == 0) + break; + } + } + else + i = 0; + layout = xkb_info->defs.layout = info->layout.name + [i < info->layout.nelem ? i : 0]; + dlayout = info->layout.desc[i < info->layout.nelem ? i : 0]; + + if (ovariant) { + for (i = 0; i < info->variant.nelem; i++) { + if (strcmp(ovariant, info->variant.name[i]) == 0) + break; + } + } + else + i = info->variant.nelem; + variant = xkb_info->defs.variant = i < info->variant.nelem ? + info->variant.name[i] : NULL; + dvariant = i < info->variant.nelem ? + info->variant.desc[i] : NULL; + + if (ooptions) { + char *ptr, *tmp = XtNewString(options); + + for (ptr = strtok(tmp, ","); ptr != NULL; ptr = strtok(NULL, ",")) { + if (strchr(ptr, ':') == NULL) + continue; + + for (i = 0; i < xkb_rules->option.nelem; i++) + if (strcmp(xkb_rules->option.name[i], ptr) == 0) + break; + + if (i == xkb_rules->option.nelem) { + XtFree(options); + options = NULL; + /* no option with the same name */ + break; + } + } + XtFree(tmp); + } + else { + XtFree(options); + options = NULL; + } + + oxkb_rules = xkb_rules; + xkb_rules = info; + rules = info->rules; + + if (!UpdateKeyboard(False)) { + model = xkb_info->defs.model = omodel; + layout = xkb_info->defs.layout = olayout; + variant = xkb_info->defs.variant = ovariant; + options = XtNewString(xkb_info->defs.options = ooptions); + xkb_rules = oxkb_rules; + rules = xkb_rules->rules; + + XmuSnprintf(filename, sizeof(filename), "%s%s", + XkbRulesDir, rules); + if ((fp = fopen(filename, "r")) == NULL) { + fprintf(stderr, "Can't open rules file\n"); + return; + } + + if (!XkbRF_LoadRules(fp, xkb_rules->list)) { + fprintf(stderr, "Can't load rules\n"); + } + fclose(fp); + + return; + } + + UpdateRulesPopups(); + + XtSetArg(args[0], XtNlabel, rules); + XtSetValues(rulesb, args, 1); + + XtSetArg(args[0], XtNlabel, dmodel); + XtSetValues(modelb, args, 1); + + XtSetArg(args[0], XtNlabel, dlayout); + XtSetValues(layoutb, args, 1); + + XtSetArg(args[0], XtNlabel, dvariant ? dvariant : ""); + XtSetValues(variantb, args, 1); + + XtSetArg(args[0], XtNlabel, options ? options : ""); + XtSetValues(variantb, args, 1); +} + +static void +KeyboardModelCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + int i; + char *oldval = xkb_info->defs.model; + + for (i = 0; i < xkb_rules->model.nelem; i++) + if (strcmp(XtName(w), xkb_rules->model.name[i]) == 0) + break; + model = xkb_info->defs.model = xkb_rules->model.name[i]; + if (!UpdateKeyboard(False)) + model = xkb_info->defs.model = oldval; + else { + XtSetArg(args[0], XtNlabel, xkb_rules->model.desc[i]); + XtSetValues(modelb, args, 1); + } +} + +static void +KeyboardLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + int i; + char *oldval = xkb_info->defs.layout; + + for (i = 0; i < xkb_rules->layout.nelem; i++) + if (strcmp(XtName(w), xkb_rules->layout.name[i]) == 0) + break; + layout = xkb_info->defs.layout = xkb_rules->layout.name[i]; + if (!UpdateKeyboard(False)) + layout = xkb_info->defs.layout = oldval; + else { + XtSetArg(args[0], XtNlabel, xkb_rules->layout.desc[i]); + XtSetValues(layoutb, args, 1); + } +} + +static void +KeyboardVariantCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + int i; + char *label, *oldval = xkb_info->defs.variant; + + for (i = 0; i < xkb_rules->variant.nelem; i++) + if (strcmp(XtName(w), xkb_rules->variant.name[i]) == 0) + break; + variant = i < xkb_rules->variant.nelem ? xkb_rules->variant.name[i] : ""; + xkb_info->defs.variant = variant && *variant ? variant : NULL; + + if (!UpdateKeyboard(False)) + xkb_info->defs.variant = variant = oldval; + else { + label = i < xkb_rules->variant.nelem ? xkb_rules->variant.desc[i] : ""; + XtSetArg(args[0], XtNlabel, label); + XtSetValues(variantb, args, 1); + } +} + +static void +KeyboardOptionsCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + int i; + + for (i = 0; i < xkb_rules->option.nelem; i++) + if (strcmp(XtName(w), xkb_rules->option.name[i]) == 0) + break; + + if (i < xkb_rules->option.nelem) { + char *delim, *ptr, str[256]; + + /* remove old string, don't check if the same */ + if ((delim = strchr(XtName(w), ':')) != NULL) { + if (delim - XtName(w) >= sizeof(str) - 2) + return; + strncpy(str, XtName(w), delim - XtName(w) + 1); + str[delim - XtName(w) + 1] = '\0'; + } + else + XmuSnprintf(str, sizeof(str), "%s:", XtName(w)); + if (options && (delim = strstr(options, str)) != NULL) { + if ((ptr = strchr(delim, ',')) != NULL) { + *delim = *ptr = '\0'; + XmuSnprintf(str, sizeof(str), "%s%s", options, ptr + 1); + XtFree(options); + options = XtNewString(str); + } + else { + if (delim > options) + delim[-1] = '\0'; + else + delim[0] = '\0'; + } + } + + /* update string, if required */ + if ((delim = strchr(XtName(w), ':')) != NULL) { + if (options && *options) + XmuSnprintf(str, sizeof(str), "%s,%s", options, XtName(w)); + else + XmuSnprintf(str, sizeof(str), "%s", XtName(w)); + XtFree(options); + options = XtNewString(str); + } + } + else { + XtFree(options); + options = XtNewString(""); + } + + if (options == NULL) + options = XtNewString(""); + + xkb_info->defs.options = options; + if (!UpdateKeyboard(False)) { + *options = '\0'; + xkb_info->defs.options = NULL; + } + XtSetArg(args[0], XtNlabel, options); + XtSetValues(optionsb, args, 1); + XtSetArg(args[0], XtNtip, options); + XtSetValues(optionsb, args, 1); +} + +/*ARGSUSED*/ +static void +KeyboardApplyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + (void)UpdateKeyboard(True); +} + +static void +UpdateRulesPopups(void) +{ + int i; + char *optname; + Widget sme, optpopup = NULL, optparent; + + /* MODEL */ + if (modelp) + XtDestroyWidget(modelp); + modelp = XtCreatePopupShell("modelP", simpleMenuWidgetClass, + modelb, NULL, 0); + for (i = 0; i < xkb_rules->model.nelem; i++) { + sme = XtVaCreateManagedWidget(xkb_rules->model.name[i], smeBSBObjectClass, + modelp, + XtNlabel, xkb_rules->model.desc[i], + NULL); + XtAddCallback(sme, XtNcallback, KeyboardModelCallback, NULL); + } + + /* LAYOUT */ + if (layoutp) + XtDestroyWidget(layoutp); + layoutp = XtCreatePopupShell("layoutP", simpleMenuWidgetClass, + layoutb, NULL, 0); + for (i = 0; i < xkb_rules->layout.nelem; i++) { + sme = XtVaCreateManagedWidget(xkb_rules->layout.name[i], smeBSBObjectClass, + layoutp, + XtNlabel, xkb_rules->layout.desc[i], + NULL); + XtAddCallback(sme, XtNcallback, KeyboardLayoutCallback, NULL); + } + + /* VARIANT */ + if (variantp) + XtDestroyWidget(variantp); + variantp = XtCreatePopupShell("variantP", simpleMenuWidgetClass, + variantb, NULL, 0); + sme = XtVaCreateManagedWidget("None", smeBSBObjectClass, + variantp, + XtNlabel, "None", + NULL); + XtAddCallback(sme, XtNcallback, KeyboardVariantCallback, NULL); + for (i = 0; i < xkb_rules->variant.nelem; i++) { + sme = XtVaCreateManagedWidget(xkb_rules->variant.name[i], smeBSBObjectClass, + variantp, + XtNlabel, xkb_rules->variant.desc[i], + NULL); + XtAddCallback(sme, XtNcallback, KeyboardVariantCallback, NULL); + } + + /* OPTIONS */ + if (optionsp) + XtDestroyWidget(optionsp); + optionsp = XtCreatePopupShell("optionsP", simpleMenuWidgetClass, + optionsb, NULL, 0); + sme = XtVaCreateManagedWidget("None", smeBSBObjectClass, + optionsp, + XtNlabel, "None", + NULL); + XtAddCallback(sme, XtNcallback, KeyboardOptionsCallback, NULL); + optparent = optionsp; + optname = NULL; + for (i = 0; i < xkb_rules->option.nelem; i++) { + if (!strchr(xkb_rules->option.name[i], ':')) { + optpopup = + XtCreatePopupShell(optname = xkb_rules->option.desc[i], + simpleMenuWidgetClass, + optparent = optionsp, NULL, 0); + sme = XtVaCreateManagedWidget(xkb_rules->option.name[i], + smeBSBObjectClass, + optpopup, + XtNlabel, "None", + NULL); + XtAddCallback(sme, XtNcallback, KeyboardOptionsCallback, NULL); + } + else { + optparent = optpopup; + optname = NULL; + } + sme = XtVaCreateManagedWidget(xkb_rules->option.name[i], smeBSBObjectClass, + optparent, + XtNlabel, xkb_rules->option.desc[i], + XtNmenuName, optname, + XtNleftBitmap, optname ? menuPixmap : None, + NULL); + if (optparent != optionsp) + XtAddCallback(sme, XtNcallback, KeyboardOptionsCallback, NULL); + } +} + +void +KeyboardModelAndLayout(XF86SetupInfo *info) +{ + static int first = 1; + static Widget kbdml; + Arg args[1]; + int i; + + if (first) { + Widget popup, sme; + + first = 0; + + kbdml = XtCreateWidget("keyboardML", formWidgetClass, + configp, NULL, 0); + + /* RULES */ + XtCreateManagedWidget("labelR", labelWidgetClass, kbdml, NULL, 0); + rulesb = XtVaCreateManagedWidget("rules", menuButtonWidgetClass, kbdml, + XtNmenuName, "rulesP", + NULL); + popup = XtCreatePopupShell("rulesP", simpleMenuWidgetClass, + rulesb, NULL, 0); + { + struct dirent *ent; + DIR *dir; + + if ((dir = opendir(XkbRulesDir)) != NULL) { + (void)readdir(dir); + (void)readdir(dir); + while ((ent = readdir(dir)) != NULL) { + if (strchr(ent->d_name, '.')) + continue; + + sme = XtVaCreateManagedWidget(ent->d_name, smeBSBObjectClass, + popup, + XtNlabel, ent->d_name, + NULL); + XtAddCallback(sme, XtNcallback, KeyboardRulesCallback, NULL); + } + closedir(dir); + } + } + + /* MODEL */ + XtCreateManagedWidget("labelM", labelWidgetClass, kbdml, NULL, 0); + modelb = XtVaCreateManagedWidget("model", menuButtonWidgetClass, kbdml, + XtNmenuName, "modelP", + NULL); + + /* LAYOUT */ + XtCreateManagedWidget("labelL", labelWidgetClass, kbdml, NULL, 0); + layoutb = XtVaCreateManagedWidget("layout", menuButtonWidgetClass, kbdml, + XtNmenuName, "layoutP", + XtNlabel, xkb_rules->layout.desc[0], + NULL); + + /* VARIANT */ + XtCreateManagedWidget("labelV", labelWidgetClass, kbdml, NULL, 0); + variantb = XtVaCreateManagedWidget("variant", menuButtonWidgetClass, kbdml, + XtNmenuName, "variantP", + XtNlabel, "", + NULL); + + /* OPTIONS */ + XtCreateManagedWidget("labelO", labelWidgetClass, kbdml, NULL, 0); + optionsb = XtVaCreateManagedWidget("options", menuButtonWidgetClass, kbdml, + XtNmenuName, "optionsP", + XtNlabel, "", + NULL); + + UpdateRulesPopups(); + + kbd = XtCreateManagedWidget("keyboard", coreWidgetClass, + kbdml, NULL, 0); + + apply = XtCreateManagedWidget("apply", commandWidgetClass, + kbdml, NULL, 0); + XtAddCallback(apply, XtNcallback, KeyboardApplyCallback, NULL); + + XtRealizeWidget(kbdml); + + XtAddEventHandler(kbd, ExposureMask, False, XkbUIEventHandler, NULL); + /* Force the first update */ + XClearArea(XtDisplay(kbd), XtWindow(kbd), 0, 0, 0, 0, True); + } + + XtSetArg(args[0], XtNlabel, xkb_rules->rules); + XtSetValues(rulesb, args, 1); + + for (i = 0; i < xkb_rules->model.nelem; i++) + if (strcmp(model, xkb_rules->model.name[i]) == 0) { + XtSetArg(args[0], XtNlabel, xkb_rules->model.desc[i]); + XtSetValues(modelb, args, 1); + break; + } + + for (i = 0; i < xkb_rules->layout.nelem; i++) + if (strcmp(layout, xkb_rules->layout.name[i]) == 0) { + XtSetArg(args[0], XtNlabel, xkb_rules->layout.desc[i]); + XtSetValues(layoutb, args, 1); + break; + } + + if (variant) + for (i = 0; i < xkb_rules->variant.nelem; i++) + if (strcmp(variant, xkb_rules->variant.name[i]) == 0) { + XtSetArg(args[0], XtNlabel, xkb_rules->variant.desc[i]); + XtSetValues(variantb, args, 1); + break; + } + + if (options) { + XtSetArg(args[0], XtNlabel, options); + XtSetValues(optionsb, args, 1); + } + + XtChangeManagedSet(¤t, 1, NULL, NULL, &kbdml, 1); + current = kbdml; +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.h b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.h new file mode 100644 index 000000000..512a19d7a --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard-cfg.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#include <X11/extensions/XKBconfig.h> + +#ifndef _xf86cfg_keyboard_h +#define _xf86cfg_keyboard_h + +/* + * All file names are from XProjectRoot or XWINHOME environment variable. + */ +#define XkbConfigDir "share/X11/xkb/" +#define XkbConfigFile "X0-config.keyboard" + +/* + * Types + */ +typedef struct { + char **name; + char **desc; + int nelem; +} XF86XkbDescInfo; + +typedef struct { + XF86ConfInputPtr conf; + XkbDescPtr xkb; + XkbRF_VarDefsRec defs; + XkbConfigRtrnRec config; +} XkbInfo; + +/* + * Prototypes + */ +XtPointer KeyboardConfig(XtPointer); +void KeyboardModelAndLayout(XF86SetupInfo*); +void InitializeKeyboard(void); +Bool UpdateKeyboard(Bool); +Bool WriteXKBConfiguration(char*, XkbConfigRtrnPtr); + +/* + * Initialization + */ +extern XkbInfo *xkb_info; + +#endif /* _xf86cfg_keyboard_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xbm new file mode 100644 index 000000000..0346a8ccd --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xbm @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +#define keyboard_width 50 +#define keyboard_height 44 +static unsigned char keyboard_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xe0, 0xff, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x78, 0x9e, + 0xe7, 0x3d, 0xef, 0x79, 0x00, 0x18, 0x9a, 0xa6, 0x35, 0xad, 0x61, 0x00, + 0x18, 0x9e, 0xe7, 0x3d, 0xef, 0x61, 0x00, 0x18, 0x9e, 0xe7, 0x3d, 0xef, + 0x61, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x60, 0x00, 0x98, 0xf7, 0xde, 0x7b, 0xef, 0x67, 0x00, 0x98, + 0xd6, 0x5a, 0x6b, 0x2d, 0x66, 0x00, 0x98, 0xf7, 0xde, 0x7b, 0xef, 0x66, + 0x00, 0x98, 0xf7, 0xde, 0x7b, 0xef, 0x66, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x80, 0x66, 0x00, 0x98, 0xdf, 0x7b, 0xef, 0xbd, 0x66, 0x00, 0x98, 0x58, + 0x6b, 0xad, 0xb5, 0x66, 0x00, 0x98, 0xdf, 0x7b, 0xef, 0xbd, 0x67, 0x00, + 0x98, 0xdf, 0x7b, 0xef, 0xbd, 0x67, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x98, 0xf7, 0xde, 0x7b, 0xef, 0x67, 0x00, 0x98, 0xd6, 0x5a, + 0x6b, 0x2d, 0x66, 0x00, 0x98, 0xf7, 0xde, 0x7b, 0xef, 0x67, 0x00, 0x98, + 0xf7, 0xde, 0x7b, 0xef, 0x67, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x60, + 0x00, 0x98, 0xf7, 0xfd, 0xf7, 0xbd, 0x67, 0x00, 0x98, 0x96, 0x05, 0x96, + 0xb5, 0x66, 0x00, 0x98, 0xf7, 0xfd, 0xf7, 0xbd, 0x67, 0x00, 0x98, 0xf7, + 0xfd, 0xf7, 0xbd, 0x67, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, + 0x3f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xpm b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xpm new file mode 100644 index 000000000..200ba7f42 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/keyboard.xpm @@ -0,0 +1,66 @@ +/* XPM */ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +static char * card_xpm[] = { +"60 28 5 1", +" c none", +". c #AEBAAEBAAEBA", +"X c #CF3CCF3CCF3C", +"o c #8E388A288E38", +"O c #69A671C669A6", +" ........................ ", +" .............................XXXXXXXXXXXXXXXXXXXXXXXX..... ", +".XXXXXXXXXXXXXXXXXXXXXXXXXXXXX........................XXXXoO", +".X........................................................oO", +".X........................................................oO", +".X.Xo..Xo.Xo.Xo..Xo.Xo.Xo.Xo.Xo.Xo..Xo.Xo.Xo..ooooooooooo.oO", +".X.oo..oo.oo.oo..oo.oo.oo.oo.oo.oo..oo.oo.oo..XXXXXXXXXXX.oO", +".X........................................................oO", +".X........................................................oO", +".X.Xo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.o..Xo.Xo.Xo..Xo.Xo.Xo.Xo.oO", +".X.oo.oo.oo.oo.oo.oo.oo.oo.oo.oo.o..oo.oo.oo..oo.oo.oo.oo.oO", +".X........................................................oO", +".X.XXo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.oXo..Xo.Xo.Xo..Xo.Xo.Xo.Xo.oO", +".X.ooo.oo.oo.oo.oo.oo.oo.oo.oo..Xo..oo.oo.oo..oo.oo.oo.Xo.oO", +".X..............................Xo.....................Xo.oO", +".X.Xo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.XXXo..Xo.Xo.Xo..Xo.Xo.Xo.Xo.oO", +".X.oo.oo.oo.oo.oo.oo.oo.oo.oo.oooo..oo.oo.oo..oo.oo.oo.oo.oO", +".X........................................................oO", +".X.XXo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.Xo.XXo.....Xo.....Xo.Xo.Xo.Xo.oO", +".X.ooo.oo.oo.oo.oo.oo.oo.oo.oo.ooo.....oo.....oo.oo.oo.Xo.oO", +".X.....................................................Xo.oO", +".X.Xo.Xo.Xo.XXXXXXXXXXXXo.Xo.Xo.Xo..Xo.Xo.Xo..XXXXo.Xo.Xo.oO", +".X.oo.oo.oo.ooooooooooooo.oo.oo.oo..oo.oo.oo..ooooo.oo.oo.oO", +".X........................................................oO", +".X........................................................oO", +".Xooooo.......................oooooooooooooooooooooooooooooO", +" XOOOOOoooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOO ", +" OOOOOOOOOOOOOOOOOOOOOOO "}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/left.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/left.xbm new file mode 100644 index 000000000..bfb8f3ba8 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/left.xbm @@ -0,0 +1,8 @@ +#define left_width 19 +#define left_height 19 +static unsigned char left_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x07, 0x00, 0x80, 0x07, 0x00, 0xc0, 0x07, 0x00, 0xe0, 0xff, 0x01, + 0xf0, 0xff, 0x01, 0xf8, 0xff, 0x01, 0xf0, 0xff, 0x01, 0xe0, 0xff, 0x01, + 0xc0, 0x07, 0x00, 0x80, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/loader.c b/xorg-server/hw/xfree86/utils/xorgcfg/loader.c new file mode 100644 index 000000000..8a9ad1aef --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/loader.c @@ -0,0 +1,405 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#include "cards.h" +#include "options.h" +#include "loader.h" +#include "stubs.h" +#include <X11/Xresource.h> +#include <X11/Xos.h> + +#ifdef USE_MODULES +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#if defined(X_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE X_POSIX_C_SOURCE +#include <setjmp.h> +#undef _POSIX_C_SOURCE +#else +#include <setjmp.h> +#endif +#include <signal.h> +#include <ctype.h> + +#include <stdarg.h> + +#ifndef OPTIONSPATH +#define OPTIONSPATH "/usr/lib/X11" +#endif + +#ifndef SIGNALRETURNSINT +void sig_handler(int); +#else +int sig_handler(int); +#endif /* SIGNALRETURNSINT */ + +static Bool EnumDatabase(XrmDatabase*, XrmBindingList, XrmQuarkList, + XrmRepresentation*, XrmValue*, XPointer); + +static sigjmp_buf jmp; +int signal_caught; +int error_level; +char *loaderPath, **loaderList, **ploaderList; +extern XrmDatabase options_xrm; +extern int noverify; +extern ModuleType module_type; +static OptionInfoPtr option; + +extern FontModule *font_module; +extern int numFontModules; + +char **checkerLegend; +int *checkerErrors; + +#ifndef SIGNALRETURNSINT +void +#else +int +#endif +sig_handler(int sig) +{ + char *str; + + switch (sig) { + case SIGTRAP: + str = "TRAP"; + break; + case SIGBUS: + str = "BUS"; + break; + case SIGSEGV: + str = "SEGV"; + break; + case SIGILL: + str = "ILL"; + break; + case SIGFPE: + str = "FPE"; + break; + default: + str = "???"; + break; + } + + if (signal_caught == 1) { + ErrorF(" ERROR I am dead.\n"); + exit(1); + } + else if (signal_caught == 2) + abort(); + ++signal_caught; + ErrorF(" ERROR SIG%s caught!\n", str); + if (!noverify) + error_level += 50; + siglongjmp(jmp, 1); + /*NOTREACHED*/ +} + +void +CheckMsg(int code, char *fmt, ...) +{ + va_list ap; + + ++checkerErrors[code]; + ErrorF("%3d ", code); + + va_start(ap, fmt); + VErrorF(fmt, ap); + va_end(ap); +} + +static Bool +EnumDatabase(XrmDatabase *db, XrmBindingList bindings, XrmQuarkList quarks, + XrmRepresentation *type, XrmValue *value, XPointer closure) +{ + char *res = XrmQuarkToString(quarks[1]); + + if (res) { + option = module_options->option; + while (option->name) { + if (strcasecmp(option->name, res) == 0) + return (False); + ++option; + } + CheckMsg(CHECKER_OPTION_UNUSED, + "WARNING %s.%s is not used\n", + XrmQuarkToString(quarks[0]), res); + ++error_level; + } + + return (False); +} + +Bool +LoaderInitializeOptions(void) +{ + static int first = 1; + static char *modules = "lib/modules"; + volatile Bool options_ok = False; + char *ptr, query[256]; + char *ptr2, query2[256]; + char *type; + XrmValue value; + XrmQuark names[2]; + XrmQuark classes[2]; + volatile int i; + static ModuleType module_types[] = { + GenericModule, FontRendererModule, InputModule, VideoModule, NullModule + }; + + /* The offset in this vector must match loader.h:enum ModuleType values */ + static char *module_strs[] = { + "Null Module", "Video Module", "Input Module", "Generic Module", "Font Module" + }; + + if (first) { + checkerLegend = (char**) + XtCalloc(1, sizeof(char*) * (CHECKER_LAST_MESSAGE + 1)); + checkerErrors = (int*) + XtCalloc(1, sizeof(int) * (CHECKER_LAST_MESSAGE + 1)); + xf86cfgLoaderInit(); + first = 0; + + checkerLegend[CHECKER_OPTIONS_FILE_MISSING] = + "The Options file, normally " OPTIONSPATH "/Options was not found.\n"; + checkerLegend[CHECKER_OPTION_DESCRIPTION_MISSING] = + "No description for the module option. The description should be in\n" + "in the Options file, and using the sintax:\n" + "Module.Option: any text describing the option"; + checkerLegend[CHECKER_LOAD_FAILED] = + "Failed to load the module. Usually the loader will print a complete\n" + "description for the reason the module was not loaded. Use the -verbose\n" + "command line option if it is not printing any messages."; + checkerLegend[CHECKER_RECOGNIZED_AS] = + "This message means the module code did not follow what was expected\n" + "by the checker. For video drivers, it did not call xf86AddDriver,\n" + "a input module did not call xf86AddInputDriver and a font renderer\n" + "module did not call LoadFont. This message can also be printed if\n" + "the module is in the incorrect directory."; + checkerLegend[CHECKER_NO_OPTIONS_AVAILABLE] = + "The driver does not have an AvailableOptions function, or that\n" + "function is returning NULL. If the driver is returning NULL, and\n" + "really does not need any options from "__XCONFIGFILE__", than the message\n" + "can be ignored."; + checkerLegend[CHECKER_NO_VENDOR_CHIPSET] = + "The checker could not fetch the PCI chipset/vendor information from\n" + "the module. The checker currently wraps xf86PrintChipsets and\n" + "xf86MatchPciInstances to read the information from the module."; + checkerLegend[CHECKER_CANNOT_VERIFY_CHIPSET] = + "The vendor id was not found, so it is not possible to search the list\n" + "of chipsets."; + checkerLegend[CHECKER_OPTION_UNUSED] = + "The option description is defined in the Options file, but the option\n" + "was name not retrieved when calling the module AvailableOptions."; + checkerLegend[CHECKER_NOMATCH_CHIPSET_STRINGS] = + "The string specified in the module does not match the one in\n" + "common/xf86PciInfo.h"; + checkerLegend[CHECKER_CHIPSET_NOT_LISTED] = + "This means that common/xf86PciInfo.h does not have an entry for the\n" + "given vendor and id."; + checkerLegend[CHECKER_CHIPSET_NOT_SUPPORTED] = + "The chipset is listed in common/xf86PciInfo.h, but the driver does\n" + "not support it, or does not list it in the chipsets fetched by the checker."; + checkerLegend[CHECKER_CHIPSET_NO_VENDOR] = + "The vendor id specified to xf86MatchPciInstances is not defined in\n" + "common/xf86PciInfo.h"; + checkerLegend[CHECKER_NO_CHIPSETS] = + "No chipsets were passed to xf86MatchPciIntances."; + checkerLegend[CHECKER_FILE_MODULE_NAME_MISMATCH] = + "The module name string does not match the the modname field of the\n" + "XF86ModuleVersionInfo structure. This generally is not an error, but\n" + "to may be a good idea to use the same string to avoid confusion."; + } + + if (XF86Module_path == NULL) { + XF86Module_path = malloc(strlen(XFree86Dir) + strlen(modules) + 2); + sprintf(XF86Module_path, "%s/%s", XFree86Dir, modules); + } + + if (loaderPath == NULL || strcmp(XF86Module_path, loaderPath)) + loaderPath = strdup(XF86Module_path); + else + /* nothing new */ + return (True); + + if (!noverify) { + options_ok = InitializeOptionsDatabase(); + InitializePciInfo(); + } + + for (i = 0; module_types[i] != NullModule; i++) { + xf86cfgLoaderInitList(module_types[i]); + if (!noverify) + ErrorF("================= Checking modules of type \"%s\" =================\n", + module_strs[module_types[i]]); + + if (loaderList) { + for (ploaderList = loaderList; *ploaderList; ploaderList++) { + signal_caught = 0; + signal(SIGTRAP, sig_handler); + signal(SIGBUS, sig_handler); + signal(SIGSEGV, sig_handler); + signal(SIGILL, sig_handler); + signal(SIGFPE, sig_handler); + if (sigsetjmp(jmp, 1) == 0) { + if (!noverify) { + int ok, nfont_modules; + + nfont_modules = numFontModules; + error_level = 0; + ErrorF("CHECK MODULE %s\n", *ploaderList); + if ((ok = xf86cfgCheckModule()) == 0) { + CheckMsg(CHECKER_LOAD_FAILED, + "ERROR Failed to load module.\n"); + error_level += 50; + } + else if (module_type != module_types[i]) { + CheckMsg(CHECKER_RECOGNIZED_AS, + "WARNING %s recognized as a \"%s\"\n", *ploaderList, + module_strs[module_type]); + ++error_level; + } + if (ok) { + if (options_ok) { + if ((module_options == NULL || module_options->option == NULL) && + module_type != GenericModule) { + CheckMsg(CHECKER_NO_OPTIONS_AVAILABLE, + "WARNING Not a generic module, but no options available.\n"); + ++error_level; + } + else if (module_options && strcmp(module_options->name, *ploaderList) == 0) { + ErrorF(" CHECK OPTIONS\n"); + option = module_options->option; + + while (option->name) { + XmuSnprintf(query, sizeof(query), "%s.%s", *ploaderList, option->name); + for (ptr = query, ptr2 = query2; *ptr; ptr++) { + if (*ptr != '_' && *ptr != ' ' && *ptr != '\t') + *ptr2 = tolower(*ptr); + } + *ptr2 = '\0'; + /* all resources are in lowercase */ + if (!XrmGetResource(options_xrm, query2, "Module.Option", &type, &value) || + value.addr == NULL) { + CheckMsg(CHECKER_OPTION_DESCRIPTION_MISSING, + "WARNING no description for %s\n", query); + ++error_level; + } + ++option; + } + + /* now do a linear search for Options file entries that are not + * in the driver. + */ + names[0] = XrmPermStringToQuark(module_options->name); + classes[0] = XrmPermStringToQuark("Option"); + names[1] = classes[1] = NULLQUARK; + (void)XrmEnumerateDatabase(options_xrm, (XrmNameList)&names, (XrmClassList)&classes, + XrmEnumOneLevel, EnumDatabase, NULL); + } + } + else { + CheckMsg(CHECKER_OPTIONS_FILE_MISSING, + "ERROR Options file missing.\n"); + error_level += 10; + } + + if (module_type == VideoModule && + (module_options == NULL || module_options->vendor < 0 || + module_options->chipsets == NULL)) { + CheckMsg(CHECKER_NO_VENDOR_CHIPSET, + "WARNING No vendor/chipset information available.\n"); + ++error_level; + } + else if (module_type == VideoModule) { + if (module_options == NULL) { + /* No description for this, if this happen, + * something really strange happened. */ + ErrorF(" ERROR No module_options!?!\n"); + error_level += 50; + } + else { + ErrorF(" CHECK CHIPSETS\n"); + CheckChipsets(module_options, &error_level); + } + } + + /* font modules check */ + if (module_type == FontRendererModule) { + if (strcmp(*ploaderList, font_module->name)) { + /* not an error */ + ErrorF(" NOTICE FontModule->name specification mismatch: \"%s\" \"%s\"\n", + *ploaderList, font_module->name); + } + if (nfont_modules + 1 != numFontModules) { + /* not an error */ + ErrorF(" NOTICE font module \"%s\" loaded more than one font renderer.\n", + *ploaderList); + } + } + else if (nfont_modules != numFontModules) { + ErrorF(" WARNING number of font modules changed from %d to %d.\n", + nfont_modules, numFontModules); + ++error_level; + } + } + ErrorF(" SUMMARY error_level set to %d.\n\n", error_level); + } + else + (void)xf86cfgCheckModule(); + } + signal(SIGTRAP, SIG_DFL); + signal(SIGBUS, SIG_DFL); + signal(SIGSEGV, SIG_DFL); + signal(SIGILL, SIG_DFL); + signal(SIGFPE, SIG_DFL); + } + xf86cfgLoaderFreeList(); + } + else + ErrorF(" ERROR Failed to initialize module list.\n"); + } + + if (!noverify) { + ErrorF("===================================== LEGEND ===============================\n"); + ErrorF("NOTICE lines are just informative.\n"); + ErrorF("WARNING lines add 1 to error_level.\n"); + ErrorF("ERROR lines add 2 or more (based on the severity of the error) to error_level.\n\n"); + for (i = 0; i <= CHECKER_LAST_MESSAGE; i++) + if (checkerErrors[i]) { + ErrorF("%3d\n%s\n\n", i, checkerLegend[i]); + } + } + + return (True); +} +#endif diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/loader.h b/xorg-server/hw/xfree86/utils/xorgcfg/loader.h new file mode 100644 index 000000000..16c527327 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/loader.h @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#ifdef USE_MODULES +#ifndef LOADER_PRIVATE +#include "config.h" +#include "stubs.h" + +#else + +#define IN_LOADER + +#include "xf86.h" +#include "xf86str.h" +#include "xf86Opt.h" +#include "xf86Module.h" + +#ifndef XINPUT +#define XINPUT +#endif +#include "xf86Xinput.h" + +#include <X11/fonts/fontmod.h> +#include "loaderProcs.h" + +#include <sym.h> + +void LoaderDefaultFunc(void); +#endif + +#ifndef _xf86cfg_loader_h +#define _xf86cfg_loader_h + +void xf86cfgLoaderInit(void); +void xf86cfgLoaderInitList(int); +void xf86cfgLoaderFreeList(void); +int xf86cfgCheckModule(void); + +#ifndef LOADER_PRIVATE +/* common/xf86Opt.h */ +typedef struct { + double freq; + int units; +} OptFrequency; + +typedef union { + unsigned long num; + char * str; + double realnum; + Bool xbool; + OptFrequency freq; +} ValueUnion; + +typedef enum { + OPTV_NONE = 0, + OPTV_INTEGER, + OPTV_STRING, /* a non-empty string */ + OPTV_ANYSTR, /* Any string, including an empty one */ + OPTV_REAL, + OPTV_BOOLEAN, + OPTV_FREQ +} OptionValueType; + +typedef enum { + OPTUNITS_HZ = 1, + OPTUNITS_KHZ, + OPTUNITS_MHZ +} OptFreqUnits; + +typedef struct { + int token; + const char* name; + OptionValueType type; + ValueUnion value; + Bool found; +} OptionInfoRec, *OptionInfoPtr; + +/* fontmod.h */ +typedef void (*InitFont)(void); + +typedef struct { + InitFont initFunc; + char * name; + void *module; +} FontModule; + +extern FontModule *FontModuleList; + +typedef struct { + int token; /* id of the token */ + const char * name; /* token name */ +} SymTabRec, *SymTabPtr; +#endif /* !LOADER_PRIVATE */ + +typedef enum { + NullModule = 0, + VideoModule, + InputModule, + GenericModule, + FontRendererModule +} ModuleType; + +typedef struct _xf86cfgModuleOptions { + char *name; + ModuleType type; + OptionInfoPtr option; + int vendor; + SymTabPtr chipsets; + struct _xf86cfgModuleOptions *next; +} xf86cfgModuleOptions; + +extern xf86cfgModuleOptions *module_options; + +/* When adding a new code to the LEGEND, also update checkerLegend + * in loader.c + */ +extern char **checkerLegend; +extern int *checkerErrors; +#define CHECKER_OPTIONS_FILE_MISSING 1 +#define CHECKER_OPTION_DESCRIPTION_MISSING 2 +#define CHECKER_LOAD_FAILED 3 +#define CHECKER_RECOGNIZED_AS 4 +#define CHECKER_NO_OPTIONS_AVAILABLE 5 +#define CHECKER_NO_VENDOR_CHIPSET 6 +#define CHECKER_CANNOT_VERIFY_CHIPSET 7 +#define CHECKER_OPTION_UNUSED 8 +#define CHECKER_NOMATCH_CHIPSET_STRINGS 9 +#define CHECKER_CHIPSET_NOT_LISTED 10 +#define CHECKER_CHIPSET_NOT_SUPPORTED 11 +#define CHECKER_CHIPSET_NO_VENDOR 12 +#define CHECKER_NO_CHIPSETS 13 +#define CHECKER_FILE_MODULE_NAME_MISMATCH 14 + +#define CHECKER_LAST_MESSAGE 14 + +extern void CheckMsg(int, char*, ...); + +#ifndef LOADER_PRIVATE +int LoaderInitializeOptions(void); +#endif +#endif /* USE_MODULES */ + +#endif /* _xf86cfg_loader_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/loadmod.c b/xorg-server/hw/xfree86/utils/xorgcfg/loadmod.c new file mode 100644 index 000000000..629dfe118 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/loadmod.c @@ -0,0 +1,663 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#ifdef USE_MODULES +#include <setjmp.h> + +#ifndef HAS_GLIBC_SIGSETJMP +#if defined(setjmp) && defined(__GNU_LIBRARY__) && \ + (!defined(__GLIBC__) || (__GLIBC__ < 2) || \ + ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 3))) +#define HAS_GLIBC_SIGSETJMP 1 +#endif +#endif + +#define LOADER_PRIVATE +#include "loader.h" + +#define True 1 +#define False 0 +#define XtPointer char* +#define XtMalloc malloc +#define XtCalloc calloc +#define XtRealloc realloc +#define XtFree free +#define XtNew(t) malloc(sizeof(t)) +#define XtNewString(s) ((s) ? strdup(s) : NULL) + +#define pointer void* + +/* XXX beware (or fix it) libc functions called here are the xf86 ones */ + +static void AddModuleOptions(char*, const OptionInfoRec*); +#if 0 +void xf86AddDriver(DriverPtr, void*, int); +Bool xf86ServerIsOnlyDetecting(void); +void xf86AddInputDriver(InputDriverPtr, pointer, int); +void xf86AddModuleInfo(ModuleInfoPtr, void*); +Bool xf86LoaderCheckSymbol(const char*); +void xf86LoaderRefSymLists(const char **, ...); +void xf86LoaderReqSymLists(const char **, ...); +void xf86Msg(int, const char*, ...); +void xf86MsgVerb(int, int, const char*, ...); +void xf86PrintChipsets(const char*, const char*, SymTabPtr); +void xf86ErrorFVerb(int verb, const char *format, ...); +int xf86MatchDevice(const char*, GDevPtr**); +int xf86MatchPciInstances(const char*, int, SymTabPtr, PciChipsets*, GDevPtr*, int, DriverPtr,int**); +int xf86MatchIsaInstances(const char*, SymTabPtr, pointer*, DriverPtr, pointer, GDevPtr*, int, int**); +void *xf86LoadDrvSubModule(DriverPtr drv, const char*); +void xf86DrvMsg(int, int, const char*, ...); +Bool xf86IsPrimaryPci(pcVideoPtr*); +Bool xf86CheckPciSlot( const struct pci_device * ); +#endif + +extern char *loaderPath, **loaderList, **ploaderList; +xf86cfgModuleOptions *module_options; +FontModule *font_module; +int numFontModules; + +extern int noverify, error_level; + +int xf86ShowUnresolved = 1; + +LOOKUP miLookupTab[] = {{0,0}}; +LOOKUP dixLookupTab[] = {{0,0}}; +LOOKUP fontLookupTab[] = {{0,0}}; +LOOKUP extLookupTab[] = {{0,0}}; +LOOKUP xfree86LookupTab[] = { + /* Loader functions */ + SYMFUNC(LoaderDefaultFunc) + SYMFUNC(LoadSubModule) + SYMFUNC(DuplicateModule) + SYMFUNC(LoaderErrorMsg) + SYMFUNC(LoaderCheckUnresolved) + SYMFUNC(LoadExtension) + SYMFUNC(LoadFont) + SYMFUNC(LoaderReqSymbols) + SYMFUNC(LoaderReqSymLists) + SYMFUNC(LoaderRefSymbols) + SYMFUNC(LoaderRefSymLists) + SYMFUNC(UnloadSubModule) + SYMFUNC(LoaderSymbol) + SYMFUNC(LoaderListDirs) + SYMFUNC(LoaderFreeDirList) + SYMFUNC(LoaderGetOS) + + /* + * these here are our own interfaces to libc functions + */ + SYMFUNC(xf86abort) + SYMFUNC(xf86abs) + SYMFUNC(xf86acos) + SYMFUNC(xf86asin) + SYMFUNC(xf86atan) + SYMFUNC(xf86atan2) + SYMFUNC(xf86atof) + SYMFUNC(xf86atoi) + SYMFUNC(xf86atol) + SYMFUNC(xf86bsearch) + SYMFUNC(xf86ceil) + SYMFUNC(xf86calloc) + SYMFUNC(xf86clearerr) + SYMFUNC(xf86close) + SYMFUNC(xf86cos) + SYMFUNC(xf86exit) + SYMFUNC(xf86exp) + SYMFUNC(xf86fabs) + SYMFUNC(xf86fclose) + SYMFUNC(xf86feof) + SYMFUNC(xf86ferror) + SYMFUNC(xf86fflush) + SYMFUNC(xf86fgetc) + SYMFUNC(xf86fgetpos) + SYMFUNC(xf86fgets) + SYMFUNC(xf86finite) + SYMFUNC(xf86floor) + SYMFUNC(xf86fmod) + SYMFUNC(xf86fopen) + SYMFUNC(xf86fprintf) + SYMFUNC(xf86fputc) + SYMFUNC(xf86fputs) + SYMFUNC(xf86fread) + SYMFUNC(xf86free) + SYMFUNC(xf86freopen) + SYMFUNC(xf86frexp) + SYMFUNC(xf86fscanf) + SYMFUNC(xf86fseek) + SYMFUNC(xf86fsetpos) + SYMFUNC(xf86ftell) + SYMFUNC(xf86fwrite) + SYMFUNC(xf86getc) + SYMFUNC(xf86getenv) + SYMFUNC(xf86getpagesize) + SYMFUNC(xf86hypot) + SYMFUNC(xf86ioctl) + SYMFUNC(xf86isalnum) + SYMFUNC(xf86isalpha) + SYMFUNC(xf86iscntrl) + SYMFUNC(xf86isdigit) + SYMFUNC(xf86isgraph) + SYMFUNC(xf86islower) + SYMFUNC(xf86isprint) + SYMFUNC(xf86ispunct) + SYMFUNC(xf86isspace) + SYMFUNC(xf86isupper) + SYMFUNC(xf86isxdigit) + SYMFUNC(xf86labs) + SYMFUNC(xf86ldexp) + SYMFUNC(xf86log) + SYMFUNC(xf86log10) + SYMFUNC(xf86lseek) + SYMFUNC(xf86malloc) + SYMFUNC(xf86memchr) + SYMFUNC(xf86memcmp) + SYMFUNC(xf86memcpy) +#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || \ + defined(__sparc__) || defined(__sparc) || defined(__ia64__) || \ + defined (__amd64__) || defined(__x86_64__) + /* + * Some PPC, SPARC, and IA64 compilers generate calls to memcpy to handle + * structure copies. This causes a problem both here and in shared + * libraries as there is no way to map the name of the call to the + * correct function. + */ + SYMFUNC(memcpy) + /* + * Some PPC, SPARC, and IA64 compilers generate calls to memset to handle + * aggregate initializations. + */ + SYMFUNC(memset) +#endif + SYMFUNC(xf86memmove) + SYMFUNC(xf86memset) + SYMFUNC(xf86mmap) + SYMFUNC(xf86modf) + SYMFUNC(xf86munmap) + SYMFUNC(xf86open) + SYMFUNC(xf86perror) + SYMFUNC(xf86pow) + SYMFUNC(xf86printf) + SYMFUNC(xf86qsort) + SYMFUNC(xf86read) + SYMFUNC(xf86realloc) + SYMFUNC(xf86remove) + SYMFUNC(xf86rename) + SYMFUNC(xf86rewind) + SYMFUNC(xf86setbuf) + SYMFUNC(xf86setvbuf) + SYMFUNC(xf86sin) + SYMFUNC(xf86snprintf) + SYMFUNC(xf86sprintf) + SYMFUNC(xf86sqrt) + SYMFUNC(xf86sscanf) + SYMFUNC(xf86strcat) + SYMFUNC(xf86strcmp) + SYMFUNC(xf86strcasecmp) + SYMFUNC(xf86strcpy) + SYMFUNC(xf86strcspn) + SYMFUNC(xf86strerror) + SYMFUNC(xf86strlen) + SYMFUNC(xf86strncmp) + SYMFUNC(xf86strncasecmp) + SYMFUNC(xf86strncpy) + SYMFUNC(xf86strpbrk) + SYMFUNC(xf86strchr) + SYMFUNC(xf86strrchr) + SYMFUNC(xf86strspn) + SYMFUNC(xf86strstr) + SYMFUNC(xf86strtod) + SYMFUNC(xf86strtok) + SYMFUNC(xf86strtol) + SYMFUNC(xf86strtoul) + SYMFUNC(xf86tan) + SYMFUNC(xf86tmpfile) + SYMFUNC(xf86tolower) + SYMFUNC(xf86toupper) + SYMFUNC(xf86ungetc) + SYMFUNC(xf86vfprintf) + SYMFUNC(xf86vsnprintf) + SYMFUNC(xf86vsprintf) + SYMFUNC(xf86write) + +/* non-ANSI C functions */ + SYMFUNC(xf86opendir) + SYMFUNC(xf86closedir) + SYMFUNC(xf86readdir) + SYMFUNC(xf86rewinddir) + SYMFUNC(xf86ffs) + SYMFUNC(xf86strdup) + SYMFUNC(xf86bzero) + SYMFUNC(xf86usleep) + SYMFUNC(xf86execl) + + SYMFUNC(xf86getsecs) + SYMFUNC(xf86fpossize) /* for returning sizeof(fpos_t) */ + + SYMFUNC(xf86stat) + SYMFUNC(xf86fstat) + SYMFUNC(xf86access) + SYMFUNC(xf86geteuid) + SYMFUNC(xf86getegid) + SYMFUNC(xf86getpid) + SYMFUNC(xf86mknod) + SYMFUNC(xf86chmod) + SYMFUNC(xf86chown) + SYMFUNC(xf86sleep) + SYMFUNC(xf86mkdir) + SYMFUNC(xf86shmget) + SYMFUNC(xf86shmat) + SYMFUNC(xf86shmdt) + SYMFUNC(xf86shmctl) +#ifdef HAS_GLIBC_SIGSETJMP + SYMFUNC(xf86setjmp) + SYMFUNC(xf86setjmp0) +#if defined(__GLIBC__) && (__GLIBC__ >= 2) + SYMFUNCALIAS("xf86setjmp1",__sigsetjmp) +#else + SYMFUNC(xf86setjmp1) +#endif +#else + SYMFUNCALIAS("xf86setjmp",setjmp) + SYMFUNCALIAS("xf86setjmp0",setjmp) + SYMFUNC(xf86setjmp1) +#endif + SYMFUNCALIAS("xf86longjmp",longjmp) + SYMFUNC(xf86getjmptype) + SYMFUNC(xf86setjmp1_arg2) + SYMFUNC(xf86setjmperror) + + SYMFUNC(xf86AddDriver) + SYMFUNC(xf86ServerIsOnlyDetecting) + SYMFUNC(xf86AddInputDriver) + SYMFUNC(xf86AddModuleInfo) + SYMFUNC(xf86LoaderCheckSymbol) + + SYMFUNC(xf86LoaderRefSymLists) + SYMFUNC(xf86LoaderReqSymLists) + SYMFUNC(xf86Msg) + SYMFUNC(xf86MsgVerb) + SYMFUNC(ErrorF) + SYMFUNC(xf86PrintChipsets) + SYMFUNC(xf86ErrorFVerb) + SYMFUNC(xf86MatchDevice) + SYMFUNC(xf86MatchPciInstances) + SYMFUNC(xf86MatchIsaInstances) + SYMFUNC(Xfree) + SYMFUNC(xf86LoadDrvSubModule) + SYMFUNC(xf86DrvMsg) + SYMFUNC(xf86IsPrimaryPci) + SYMFUNC(xf86CheckPciSlot) + SYMFUNC(XNFalloc) + SYMFUNC(XNFrealloc) + SYMFUNC(XNFcalloc) + {0,0} +}; + +static DriverPtr driver; +static ModuleInfoPtr info; +static SymTabPtr chips; +static int vendor; +ModuleType module_type = GenericModule; + +static void +AddModuleOptions(char *name, const OptionInfoRec *option) +{ + xf86cfgModuleOptions *ptr; + const OptionInfoRec *tmp; + SymTabPtr ctmp; + int count; + + /* XXX If the module is already in the list, then it means that + * it is now being properly loaded by xf86cfg and the "fake" entry + * added in xf86cfgLoaderInitList() isn't required anymore. + * Currently: + * ati and vmware are known to fail. */ + for (ptr = module_options; ptr; ptr = ptr->next) + if (strcmp(name, ptr->name) == 0) { + fprintf(stderr, "Module %s already in list!\n", name); + return; + } + + ptr = XtNew(xf86cfgModuleOptions); + ptr->name = XtNewString(name); + ptr->type = module_type; + if (option) { + for (count = 0, tmp = option; tmp->name != NULL; tmp++, count++) + ; + ++count; + ptr->option = XtCalloc(1, count * sizeof(OptionInfoRec)); + for (count = 0, tmp = option; tmp->name != NULL; count++, tmp++) { + memcpy(&ptr->option[count], tmp, sizeof(OptionInfoRec)); + ptr->option[count].name = XtNewString(tmp->name); + if (tmp->type == OPTV_STRING || tmp->type == OPTV_ANYSTR) + ptr->option[count].value.str = XtNewString(tmp->value.str); + } + } + else + ptr->option = NULL; + if (vendor != -1 && chips) { + ptr->vendor = vendor; + for (count = 0, ctmp = chips; ctmp->name; ctmp++, count++) + ; + ++count; + ptr->chipsets = XtCalloc(1, count * sizeof(SymTabRec)); + for (count = 0, ctmp = chips; ctmp->name != NULL; count++, ctmp++) { + memcpy(&ptr->chipsets[count], ctmp, sizeof(SymTabRec)); + ptr->chipsets[count].name = XtNewString(ctmp->name); + } + } + else + ptr->chipsets = NULL; + + ptr->next = module_options; + module_options = ptr; +} + +extern void xf86WrapperInit(void); + +void +xf86cfgLoaderInit(void) +{ + LoaderInit(); + xf86WrapperInit(); +} + +void +xf86cfgLoaderInitList(int type) +{ + static const char *generic[] = { + ".", + NULL + }; + static const char *video[] = { + "drivers", + NULL + }; + static const char *input[] = { + "input", + NULL + }; + static const char *font[] = { + "fonts", + NULL + }; + const char **subdirs; + + switch (type) { + case GenericModule: + subdirs = generic; + break; + case VideoModule: + subdirs = video; + break; + case InputModule: + subdirs = input; + break; + case FontRendererModule: + subdirs = font; + break; + default: + fprintf(stderr, "Invalid value passed to xf86cfgLoaderInitList.\n"); + subdirs = generic; + break; + } + LoaderSetPath(loaderPath); + loaderList = LoaderListDirs(subdirs, NULL); + + /* XXX Xf86cfg isn't able to provide enough wrapper functions + * to these drivers. Maybe the drivers could also be changed + * to work better when being loaded "just for testing" */ + if (type == VideoModule) { + module_type = VideoModule; + AddModuleOptions("vmware", NULL); + AddModuleOptions("ati", NULL); + module_type = NullModule; + } +} + +void +xf86cfgLoaderFreeList(void) +{ + LoaderFreeDirList(loaderList); +} + +int +xf86cfgCheckModule(void) +{ + int errmaj, errmin; + ModuleDescPtr module; + int nfonts; + FontModule *fonts, *pfont_module; + + driver = NULL; + chips = NULL; + info = NULL; + pfont_module = NULL; + vendor = -1; + module_type = GenericModule; + + if ((module = LoadModule(*ploaderList, NULL, NULL, NULL, NULL, + NULL, &errmaj, &errmin)) == NULL) { + LoaderErrorMsg(NULL, *ploaderList, errmaj, errmin); + return (0); + } + else if (driver && driver->AvailableOptions) { + /* at least fbdev does not call xf86MatchPciInstances in Probe */ + if (driver->Identify) + (*driver->Identify)(-1); + if (driver->Probe) + (*driver->Probe)(driver, PROBE_DETECT); + AddModuleOptions(*ploaderList, (*driver->AvailableOptions)(-1, -1)); + } + else if (info && info->AvailableOptions) + AddModuleOptions(*ploaderList, (*info->AvailableOptions)(NULL)); + + if (!noverify) { + XF86ModuleData *initdata = NULL; + char *p; + + p = XtMalloc(strlen(*ploaderList) + strlen("ModuleData") + 1); + strcpy(p, *ploaderList); + strcat(p, "ModuleData"); + initdata = LoaderSymbol(p); + if (initdata) { + XF86ModuleVersionInfo *vers; + + vers = initdata->vers; + if (vers && strcmp(*ploaderList, vers->modname)) { + /* This was a problem at some time for some video drivers */ + CheckMsg(CHECKER_FILE_MODULE_NAME_MISMATCH, + "WARNING file/module name mismatch: \"%s\" \"%s\"\n", + *ploaderList, vers->modname); + ++error_level; + } + } + XtFree(p); + } + + nfonts = numFontModules; + numFontModules = 0; + fonts = FontModuleList; + if (fonts) { + Bool dup = FALSE; + while (fonts->name) { + if (strcasecmp(fonts->name, *ploaderList) == 0) { + pfont_module = fonts; + /* HACK: + * fonts->names points into modules. + * Duplicate string of all remaining names to survive + * unloading. Since new fonts are appended to list + * this will only happen once per renderer. + */ + dup = TRUE; + } + if (dup) + fonts->name = strdup(fonts->name); + ++numFontModules; + ++fonts; + } + } + if (pfont_module) + module_type = FontRendererModule; + else if (nfonts + 1 <= numFontModules) { + /* loader.c will flag a warning if -noverify is not set */ + pfont_module = &FontModuleList[nfonts]; + module_type = FontRendererModule; + } + + if (font_module) { + XtFree((XtPointer)font_module->name); + XtFree((XtPointer)font_module); + font_module = NULL; + } + if (pfont_module) { + font_module = XtNew(FontModule); + memcpy(font_module, pfont_module, sizeof(FontModule)); + font_module->name = XtNewString(pfont_module->name); + } + + UnloadModule(module); + + return (1); +} + +_X_EXPORT void +xf86AddDriver(DriverPtr drv, void *module, int flags) +{ + driver = drv; + if (driver) + driver->module = module; + module_type = VideoModule; +} + +_X_EXPORT Bool +xf86ServerIsOnlyDetecting(void) +{ + return (True); +} + +_X_EXPORT void +xf86AddInputDriver(InputDriverPtr inp, void *module, int flags) +{ + module_type = InputModule; +} + +_X_EXPORT void +xf86AddModuleInfo(ModuleInfoPtr inf, void *module) +{ + info = inf; +} + +_X_EXPORT Bool +xf86LoaderCheckSymbol(const char *symbol) +{ + return LoaderSymbol(symbol) != NULL; +} + +_X_EXPORT void +xf86LoaderRefSymLists(const char **list0, ...) +{ +} + +_X_EXPORT void +xf86LoaderReqSymLists(const char **list0, ...) +{ +} + +#if 0 +void xf86Msg(int type, const char *format, ...) +{ +} +#endif + +/*ARGSUSED*/ +_X_EXPORT void +xf86PrintChipsets(const char *name, const char *msg, SymTabPtr chipsets) +{ + vendor = 0; + chips = chipsets; +} + +_X_EXPORT int +xf86MatchDevice(const char *name, GDevPtr **gdev) +{ + *gdev = NULL; + + return (1); +} + +_X_EXPORT int +xf86MatchPciInstances(const char *name, int VendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities) +{ + vendor = VendorID; + if (chips == NULL) + chips = chipsets; + *foundEntities = NULL; + + return (0); +} + +_X_EXPORT int +xf86MatchIsaInstances(const char *name, SymTabPtr chipsets, IsaChipsets *ISAchipsets, DriverPtr drvp, + FindIsaDevProc FindIsaDevice, GDevPtr *devList, int numDevs, int **foundEntities) +{ + *foundEntities = NULL; + + return (0); +} + +/*ARGSUSED*/ +_X_EXPORT void * +xf86LoadDrvSubModule(DriverPtr drv, const char *name) +{ + pointer ret; + int errmaj = 0, errmin = 0; + + ret = LoadSubModule(drv->module, name, NULL, NULL, NULL, NULL, + &errmaj, &errmin); + if (!ret) + LoaderErrorMsg(NULL, name, errmaj, errmin); + return (ret); +} + +_X_EXPORT Bool +xf86IsPrimaryPci(pciVideoPtr pPci) +{ + return (True); +} + +_X_EXPORT Bool +xf86CheckPciSlot( const struct pci_device * d ) +{ + (void) d; + return (False); +} +#endif diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.c b/xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.c new file mode 100644 index 000000000..a443c54c2 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.c @@ -0,0 +1,456 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "xf86config.h" +#include "monitor-cfg.h" +#include "screen.h" +#include <X11/extensions/xf86vmode.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Simple.h> + +#include <ctype.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/List.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/Viewport.h> +#include <X11/Xaw/SimpleMenu.h> +#include <X11/Xaw/SmeBSB.h> + +/* + * Prototypes + */ +static Bool MonitorConfigCheck(void); +static void MonitorHsyncCallback(Widget, XtPointer, XtPointer); +static void MonitorVsyncCallback(Widget, XtPointer, XtPointer); +static void MonitorSelectCardCallback(Widget, XtPointer, XtPointer); + +extern void DrawCables(void); + +/* + * Initialization + */ +static char *hmodes[] = { + "Standard VGA, 640x480 @ 60 Hz", + "Super VGA, 800x600 @ 56 Hz", + "1024x768 @ 87 Hz int. (no 800x600)", + "1024x768 @ 87 Hz int., 800x600 @ 56 Hz", + "800x600 @ 60 Hz, 640x480 @ 72 Hz", + "1024x768 @ 60 Hz, 800x600 @ 72 Hz", + "High Frequency SVGA, 1024x768 @ 70 Hz", + "Monitor that can do 1280x1024 @ 60 Hz", + "Monitor that can do 1280x1024 @ 74 Hz", + "Monitor that can do 1280x1024 @ 76 Hz", + "Monitor that can do 1280x1024 @ 85 Hz", + "Monitor that can do 1600x1200 @ 85 Hz", + "Monitor that can do 1920x1440 @ 85 Hz", + "Monitor that can do 2048x1536 @ 85 Hz" +}; + +static char *hmodes_trans[] = { + "31.5", + "31.5 - 35.1", + "31.5, 35.5", + "31.5, 35.15, 35.5", + "31.5 - 37.9", + "31.5 - 48.5", + "31.5 - 57.0", + "31.5 - 64.3", + "31.5 - 79.0", + "31.5 - 82.0", + "31.5 - 92.0", + "31.5 - 108.0", + "31.5 - 128.5", + "31.5 - 137.0" +}; + +static char *vmodes [] = { "50 - 70", "50 - 90", "50 - 100", "40 - 150", }; + +extern Widget config; +static Widget hsync, vsync, hlist, vlist, cmenu; + +static parser_range mon_hsync[CONF_MAX_HSYNC]; +static parser_range mon_vrefresh[CONF_MAX_VREFRESH]; +static int mon_n_hsync, mon_n_vrefresh; +static XF86ConfDevicePtr oldcard, card; +static XF86ConfMonitorPtr current_monitor; + +/* + * Implementation + */ +XtPointer +MonitorConfig(XtPointer conf) +{ + XF86ConfMonitorPtr monitor = (XF86ConfMonitorPtr)conf; + char monitor_name[48]; + Arg args[1]; + + current_monitor = monitor; + + xf86info.cur_list = MONITOR; + XtSetSensitive(back, xf86info.lists[MONITOR].cur_function > 0); + XtSetSensitive(next, xf86info.lists[MONITOR].cur_function < + xf86info.lists[MONITOR].num_functions - 1); + (xf86info.lists[MONITOR].functions[xf86info.lists[MONITOR].cur_function]) + (&xf86info); + + XawListUnhighlight(hlist); + XawListUnhighlight(vlist); + + if (monitor != NULL) { + XF86ConfScreenPtr screen = XF86Config->conf_screen_lst; + char str[PARSER_RANGE_SIZE]; + + XtSetArg(args[0], XtNstring, monitor->mon_identifier); + XtSetValues(ident_widget, args, 1); + + while (screen != NULL) { + if (screen->scrn_monitor == monitor) + break; + + screen = (XF86ConfScreenPtr)(screen->list.next); + } + if (screen != NULL) { + oldcard = card = screen->scrn_device; + XtSetArg(args[0], XtNlabel, card->dev_identifier); + } + else { + oldcard = card = NULL; + XtSetArg(args[0], XtNlabel, ""); + } + XtSetValues(cmenu, args, 1); + + mon_n_hsync = monitor->mon_n_hsync; + memcpy(mon_hsync, monitor->mon_hsync, + sizeof(parser_range) * mon_n_hsync); + *str = '\0'; + parser_range_to_string(str, mon_hsync, mon_n_hsync); + XtSetArg(args[0], XtNstring, str); + XtSetValues(hsync, args, 1); + + mon_n_vrefresh = monitor->mon_n_vrefresh; + memcpy(mon_vrefresh, monitor->mon_vrefresh, + sizeof(parser_range) * mon_n_vrefresh); + *str = '\0'; + parser_range_to_string(str, mon_vrefresh, mon_n_vrefresh); + XtSetArg(args[0], XtNstring, str); + XtSetValues(vsync, args, 1); + } + else { + XF86ConfMonitorPtr monitor = XF86Config->conf_monitor_lst; + int nmonitors = 0; + + oldcard = card = NULL; + while (monitor != NULL) { + ++nmonitors; + monitor = (XF86ConfMonitorPtr)(monitor->list.next); + } + do { + XmuSnprintf(monitor_name, sizeof(monitor_name), + "Monitor%d", nmonitors); + ++nmonitors; + } while (xf86findMonitor(monitor_name, + XF86Config->conf_monitor_lst)); + + XtSetArg(args[0], XtNstring, monitor_name); + XtSetValues(ident_widget, args, 1); + + XtSetArg(args[0], XtNstring, ""); + XtSetValues(hsync, args, 1); + XtSetValues(vsync, args, 1); + + XtSetArg(args[0], XtNlabel, ""); + XtSetValues(cmenu, args, 1); + } + + if (ConfigLoop(MonitorConfigCheck) == True) { + if (monitor == NULL) { + monitor = (XF86ConfMonitorPtr) + XtCalloc(1, sizeof(XF86ConfMonitorRec)); + monitor->mon_identifier = XtNewString(ident_string); + } + + memcpy(monitor->mon_hsync, mon_hsync, sizeof(parser_range) * + (monitor->mon_n_hsync = mon_n_hsync)); + memcpy(monitor->mon_vrefresh, mon_vrefresh, sizeof(parser_range) * + (monitor->mon_n_vrefresh = mon_n_vrefresh)); + + if (strcasecmp(monitor->mon_identifier, ident_string)) + xf86renameMonitor(XF86Config, monitor, ident_string); + + if (oldcard != card) { + int i; + + for (i = 0; i < computer.num_devices; i++) + if (computer.devices[i]->widget == config) + break; + if (computer.devices[i]->config == NULL) + XF86Config->conf_monitor_lst = + xf86addMonitor(XF86Config->conf_monitor_lst, + monitor); + computer.devices[i]->config = (XtPointer)monitor; + ChangeScreen(monitor, monitor, card, oldcard); + DrawCables(); + } + + return (monitor); + } + + return (NULL); +} + +static Bool +MonitorConfigCheck(void) +{ + char *str; + Arg args[1]; + XF86ConfMonitorPtr monitor = XF86Config->conf_monitor_lst; + + if (ident_string == NULL || strlen(ident_string) == 0) + return (False); + + bzero(mon_hsync, sizeof(parser_range) * CONF_MAX_HSYNC); + bzero(mon_vrefresh, sizeof(parser_range) * CONF_MAX_VREFRESH); + + XtSetArg(args[0], XtNstring, &str); + XtGetValues(hsync, args, 1); + if ((mon_n_hsync = string_to_parser_range(str, mon_hsync, + CONF_MAX_HSYNC)) <= 0) + return (False); + + XtSetArg(args[0], XtNstring, &str); + XtGetValues(vsync, args, 1); + if ((mon_n_vrefresh = string_to_parser_range(str, mon_vrefresh, + CONF_MAX_VREFRESH)) <= 0) + return (False); + + while (monitor != NULL) { + if (monitor != current_monitor && + strcasecmp(ident_string, monitor->mon_identifier) == 0) + return (False); + monitor = (XF86ConfMonitorPtr)(monitor->list.next); + } + + return (True); +} + +int +string_to_parser_range(char *str, parser_range *range, int nrange) +{ + double val; + int i = 0; + + if (str == NULL || *str == '\0' || range == NULL || nrange == 0) + return (0); + + while (*str) { + while (*str && isspace(*str)) + ++str; + if (!isdigit(*str)) { + ++str; + continue; + } + val = strtod(str, &str); + while (*str && isspace(*str)) + ++str; + if (*str == ',' || *str == '\0') { + if (*str) + ++str; + range[i].lo = range[i].hi = val; + if (++i >= nrange || *str == '\0') + break; + continue; + } + else if (*str != '-') + return (0); + ++str; + range[i].lo = val; + while (*str && isspace(*str)) + ++str; + if ((range[i].hi = strtod(str, &str)) < range[i].lo) + return (0); + if (++i >= nrange) + break; + } + + return (i); +} + +int +parser_range_to_string(char *str, parser_range *range, int nrange) +{ + int i, len; + + if (str == NULL || range == NULL || nrange <= 0) + return (0); + + for (i = len = 0; i < nrange; i++) { + if (i > 0) + len += XmuSnprintf(str + len, PARSER_RANGE_SIZE - len, "%s", + ", "); + if (range[i].lo == range[i].hi) + len += XmuSnprintf(str + len, PARSER_RANGE_SIZE - len, "%g", + range[i].lo); + else if (range[i].lo < range[i].hi) + len += XmuSnprintf(str + len, PARSER_RANGE_SIZE - len, "%g - %g", + range[i].lo, range[i].hi); + else + return (0); + } + + return (i); +} + +/*ARGSUSED*/ +static void +MonitorHsyncCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + Arg args[1]; + + XtSetArg(args[0], XtNstring, hmodes_trans[info->list_index]); + XtSetValues(hsync, args, 1); +} + +/*ARGSUSED*/ +static void +MonitorVsyncCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + Arg args[1]; + + XtSetArg(args[0], XtNstring, info->string); + XtSetValues(vsync, args, 1); +} + +/*ARGSUSED*/ +static void +MonitorSelectCardCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + + card = (XF86ConfDevicePtr)user_data; + XtSetArg(args[0], XtNlabel, card != NULL ? card->dev_identifier : ""); + XtSetValues(cmenu, args, 1); +} + +void +MonitorLayout(XF86SetupInfo *info) +{ + static int first = 1, men; + static Widget layout, menu; + XF86ConfDevicePtr device = XF86Config->conf_device_lst; + Widget sme; + Arg args[1]; + char *menuname; + + if (first) { + Widget viewport; + + first = 0; + + layout = XtCreateWidget("monitorl", formWidgetClass, + configp, NULL, 0); + XtCreateManagedWidget("hlabel", labelWidgetClass, layout, NULL, 0); + hsync = XtVaCreateManagedWidget("hsync", asciiTextWidgetClass, layout, + XtNeditType, XawtextEdit, + NULL); + viewport = XtCreateManagedWidget("hviewport", viewportWidgetClass, + layout, NULL, 0); + hlist = XtVaCreateManagedWidget("hlist", listWidgetClass, viewport, + XtNlist, hmodes, + XtNnumberStrings, sizeof(hmodes) / + sizeof(hmodes[0]), NULL); + XtAddCallback(hlist, XtNcallback, MonitorHsyncCallback, NULL); + + XtCreateManagedWidget("vlabel", labelWidgetClass, layout, NULL, 0); + vsync = XtVaCreateManagedWidget("vsync", asciiTextWidgetClass, layout, + XtNeditType, XawtextEdit, + NULL); + viewport = XtCreateManagedWidget("vviewport", viewportWidgetClass, + layout, NULL, 0); + vlist = XtVaCreateManagedWidget("vlist", listWidgetClass, viewport, + XtNlist, vmodes, + XtNnumberStrings, sizeof(vmodes) / + sizeof(vmodes[0]), NULL); + XtAddCallback(vlist, XtNcallback, MonitorVsyncCallback, NULL); + + XtCreateManagedWidget("clabel", labelWidgetClass, layout, NULL, 0); + cmenu = XtCreateManagedWidget("cmenu", menuButtonWidgetClass, + layout, NULL, 0); + + XtRealizeWidget(layout); + } + + if (menu != NULL) + XtDestroyWidget(menu); + + /* + * swaps names because XtDestroyWidget will only really destroy it + * when the code returns to XtAppMainLoop + */ + menuname = men & 1 ? "mena" : "menb"; + menu = XtCreatePopupShell(menuname, simpleMenuWidgetClass, + cmenu, NULL, 0); + XtSetArg(args[0], XtNmenuName, menuname); + XtSetValues(cmenu, args, 1); + ++men; + sme = XtVaCreateManagedWidget("none", smeBSBObjectClass, menu, + NULL); + XtAddCallback(sme, XtNcallback, MonitorSelectCardCallback, NULL); + + while (device != NULL) { + XF86ConfScreenPtr screen = XF86Config->conf_screen_lst; + Widget sme; + Bool sensitive = True; + + while (screen != NULL) { + if (screen->scrn_device == device) { + sensitive = screen->scrn_monitor == NULL || + screen->scrn_monitor == current_monitor; + break; + } + screen = (XF86ConfScreenPtr)(screen->list.next); + } + sme = XtCreateManagedWidget(device->dev_identifier, + smeBSBObjectClass, menu, + NULL, 0); + if (sensitive) + XtAddCallback(sme, XtNcallback, MonitorSelectCardCallback, device); + XtSetSensitive(sme, sensitive); + + device = (XF86ConfDevicePtr)(device->list.next); + } + + XtRealizeWidget(menu); + + XtChangeManagedSet(¤t, 1, NULL, NULL, &layout, 1); + current = layout; +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.h b/xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.h new file mode 100644 index 000000000..48fc804bf --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/monitor-cfg.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" + +#ifndef _xf86cfg_monitor_h +#define _xf86cfg_monitor_h + +/* + * Prototypes + */ +XtPointer MonitorConfig(XtPointer); +void MonitorLayout(XF86SetupInfo*); +void MonitorVidtune(XF86SetupInfo*); +int string_to_parser_range(char*, parser_range*, int); +#define PARSER_RANGE_SIZE 256 +/* string must have at least 256 bytes */ +int parser_range_to_string(char*, parser_range*, int); + +#endif /* _xf86cfg_monitor_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/monitor.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/monitor.xbm new file mode 100644 index 000000000..a2d4c6863 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/monitor.xbm @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +#define monitor_width 50 +#define monitor_height 44 +static unsigned char monitor_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x03, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xe0, 0x01, 0x00, + 0x00, 0x00, 0x1e, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x70, + 0xfc, 0xff, 0xff, 0xff, 0x38, 0x00, 0x30, 0xfe, 0xff, 0xff, 0xff, 0x31, + 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, + 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, + 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, + 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, + 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, + 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, + 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, + 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, + 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, + 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x30, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x30, 0xfe, 0xff, + 0xff, 0xff, 0x31, 0x00, 0x70, 0xfc, 0xff, 0xff, 0xff, 0x38, 0x00, 0x60, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x1e, + 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0xc0, 0x0f, + 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x30, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, + 0xf8, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x3f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/monitor.xpm b/xorg-server/hw/xfree86/utils/xorgcfg/monitor.xpm new file mode 100644 index 000000000..e647e3cc1 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/monitor.xpm @@ -0,0 +1,79 @@ +/* XPM */ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +static char * monitor_xpm[] = { +"47 40 6 1", +" c none", +"Z c #DF7DE38DDF7D", +". c #BEFBBEFBBEFB", +"X c #9E799A699E79", +"o c #30C230C230C2", +"O c #96589E799658", +"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ..", +"Z..............................................", +"Z.............................................X", +"Z.............................................X", +"Z...XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.....X", +"Z...Xooooooooooooooooooooooooooooooooooooo....X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z...XoooooooooooooooooooooooooooooooooooooZ...X", +"Z....oooooooooooooooooooooooooooooooooooooZ...X", +"Z.....ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...X", +"Z.............................................X", +"Z.............................................X", +"..............................................X", +"..XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", +" OOOOOOOOOOOOOOOOOOOOOOOOOo ", +" XXXXXXXXXXXXXXXXXXXXXXXXXX ", +" OOOOOOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo. ", +" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" ooooooooooooooooooooooooooooooooooooooo "}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.c b/xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.c new file mode 100644 index 000000000..24aec6ae4 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.c @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "xf86config.h" +#include "mouse-cfg.h" +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/List.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Toggle.h> +#include <X11/Xaw/Viewport.h> +#include <X11/extensions/xf86misc.h> + +/* + * Prototypes + */ +static void MouseDeviceCallback(Widget, XtPointer, XtPointer); +static void MouseProtocolCallback(Widget, XtPointer, XtPointer); +static void MouseEmulateCallback(Widget, XtPointer, XtPointer); +static void MouseApplyCallback(Widget, XtPointer, XtPointer); +static Bool MouseConfigCheck(void); + +/* + * Initialization + */ +static struct MouseProtocol { + char *name; + int type; +} protocols[] = { +#ifdef __SCO__ + {"OsMouse", MTYPE_AUTOMOUSE}, +#endif +#ifdef WSCONS_SUPPORT + {"wsmouse", MTYPE_AUTOMOUSE}, +#endif + {"Auto", MTYPE_AUTOMOUSE}, + {"SysMouse", MTYPE_SYSMOUSE}, + {"MouseSystems", MTYPE_MOUSESYS}, + {"BusMouse", MTYPE_BUSMOUSE}, + {"PS/2", MTYPE_PS_2}, + {"Microsoft", MTYPE_MICROSOFT}, +#ifndef __FreeBSD__ + {"ImPS/2", MTYPE_IMPS2}, + {"ExplorerPS/2", MTYPE_EXPPS2}, + {"GlidePointPS/2", MTYPE_GLIDEPOINTPS2}, + {"MouseManPlusPS/2", MTYPE_MMANPLUSPS2}, + {"NetMousePS/2", MTYPE_NETPS2}, + {"NetScrollPS/2", MTYPE_NETSCROLLPS2}, + {"ThinkingMousePS/2", MTYPE_THINKINGPS2}, +#endif + {"AceCad", MTYPE_ACECAD}, + {"GlidePoint", MTYPE_GLIDEPOINT}, + {"IntelliMouse", MTYPE_IMSERIAL}, + {"Logitech", MTYPE_LOGITECH}, + {"MMHitTab", MTYPE_MMHIT}, + {"MMSeries", MTYPE_MMSERIES}, + {"MouseMan", MTYPE_LOGIMAN}, + {"ThinkingMouse", MTYPE_THINKING}, +}; + +static Widget text; +static char *device, *protocol; +static Bool emulate; +static XF86ConfInputPtr current_input; + +/* + * Implementation + */ +/*ARGSUSED*/ +XtPointer +MouseConfig(XtPointer config) +{ + XF86ConfInputPtr mouse = (XF86ConfInputPtr)config; + XF86OptionPtr option; + char mouse_name[32]; + Arg args[1]; + + static char *Device = "Device", *Protocol = "Protocol", + *Emulate3Buttons = "Emulate3Buttons", + *Emulate3Timeout = "Emulate3Timeout"; + + current_input = mouse; + + if (mouse != NULL) { + emulate = xf86findOption(mouse->inp_option_lst, + Emulate3Buttons) != NULL; + if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) + device = option->opt_val; + else + device = NULL; + if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) + protocol = option->opt_val; + else + protocol = NULL; + + XtSetArg(args[0], XtNstring, mouse->inp_identifier); + XtSetValues(ident_widget, args, 1); + } + else { + XF86ConfInputPtr input = XF86Config->conf_input_lst; + int nmouses = 0; + + while (input != NULL) { + if (strcasecmp(input->inp_driver, "mouse") == 0) + ++nmouses; + input = (XF86ConfInputPtr)(input->list.next); + } + do { + XmuSnprintf(mouse_name, sizeof(mouse_name), "Mouse%d", nmouses); + ++nmouses; + } while (xf86findInput(mouse_name, + XF86Config->conf_input_lst)); + + XtSetArg(args[0], XtNstring, mouse_name); + XtSetValues(ident_widget, args, 1); + + emulate = True; + device = NULL; + protocol = NULL; + } + + xf86info.cur_list = MOUSE; + XtSetSensitive(back, xf86info.lists[MOUSE].cur_function > 0); + XtSetSensitive(next, xf86info.lists[MOUSE].cur_function < + xf86info.lists[MOUSE].num_functions - 1); + (xf86info.lists[MOUSE].functions[xf86info.lists[MOUSE].cur_function]) + (&xf86info); + + if (ConfigLoop(MouseConfigCheck) == True) { + XtSetArg(args[0], XtNstring, &device); + XtGetValues(text, args, 1); + if (mouse == NULL) { + mouse = XtNew(XF86ConfInputRec); + mouse->list.next = NULL; + mouse->inp_identifier = XtNewString(ident_string); + mouse->inp_driver = XtNewString("mouse"); + mouse->inp_option_lst = xf86newOption(XtNewString(Device), + XtNewString(device)); + xf86addNewOption(mouse->inp_option_lst, + XtNewString(Protocol), XtNewString(protocol)); + if (emulate) { + xf86addNewOption(mouse->inp_option_lst, + XtNewString(Emulate3Buttons), NULL); + xf86addNewOption(mouse->inp_option_lst, + XtNewString(Emulate3Timeout), + XtNewString("50")); + } + mouse->inp_comment = NULL; + } + else { + if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) { + XtFree(option->opt_val); + option->opt_val = XtNewString(device); + XtFree(option->opt_comment); + } + else { + if (mouse->inp_option_lst == NULL) + mouse->inp_option_lst = xf86newOption(XtNewString(Device), + XtNewString(device)); + else + xf86addNewOption(mouse->inp_option_lst, + XtNewString(Device), XtNewString(device)); + } + + if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) { + XtFree(option->opt_val); + option->opt_val = XtNewString(protocol); + XtFree(option->opt_comment); + } + else + xf86addNewOption(mouse->inp_option_lst, + XtNewString(Protocol), XtNewString(protocol)); + + if (emulate == False) { + xf86removeOption(&(mouse->inp_option_lst), Emulate3Buttons); + xf86removeOption(&(mouse->inp_option_lst), Emulate3Timeout); + } + else if (emulate) { + xf86addNewOption(mouse->inp_option_lst, + XtNewString(Emulate3Buttons), NULL); + xf86addNewOption(mouse->inp_option_lst, + XtNewString(Emulate3Timeout), XtNewString("50")); + } + } + if (strcasecmp(mouse->inp_identifier, ident_string)) + xf86renameInput(XF86Config, mouse, ident_string); + + return ((XtPointer)mouse); + } + + return (NULL); +} + +static Bool +MouseConfigCheck(void) +{ + Arg args[1]; + XF86ConfInputPtr mouse = XF86Config->conf_input_lst; + + XtSetArg(args[0], XtNstring, &device); + XtGetValues(text, args, 1); + + if (ident_string == NULL || strlen(ident_string) == 0 || + device == NULL || strlen(device) == 0 || protocol == NULL) + return (False); + while (mouse != NULL) { + if (mouse != current_input && + strcasecmp(ident_string, mouse->inp_identifier) == 0) + return (False); + mouse = (XF86ConfInputPtr)(mouse->list.next); + } + + return (True); +} + +static void +MouseDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + Arg args[1]; + + XtSetArg(args[0], XtNstring, info->string); + XtSetValues((Widget)user_data, args, 1); + XawTextSetInsertionPoint((Widget)user_data, strlen(info->string)); +} + +static void +MouseProtocolCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + + protocol = info->string; +} + +static void +MouseEmulateCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + emulate = (Bool)(long)call_data; +} + +static void +MouseApplyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + int i; + XF86MiscMouseSettings mouse; + + XF86MiscGetMouseSettings(XtDisplay(w), &mouse); + XtFree(mouse.device); + + if (mouse.baudrate == 0 || mouse.baudrate < 0 || mouse.baudrate > 9600 || + mouse.baudrate % 1200) + mouse.baudrate = 1200; + + mouse.type = MTYPE_AUTOMOUSE; + for (i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) + if (strcmp(protocols[i].name, protocol) == 0) { + mouse.type = protocols[i].type; + break; + } + + mouse.emulate3buttons = emulate; + mouse.flags |= MF_REOPEN; + + mouse.device = device; + + XFlush(XtDisplay(w)); + XF86MiscSetMouseSettings(XtDisplay(w), &mouse); +} + +void +MouseDeviceAndProtocol(XF86SetupInfo *info) +{ + static int first = 1, ndevices; + static Widget mouse_dp, listD, listP, emul3, apply; + static char **devices; + static char *dirs[] = { + "/dev", +#ifdef __linux__ + "/dev/input" +#endif + }; + static char *patterns[] = { +#ifdef WSCONS_SUPPORT + "wsmouse", +#endif + "cuaa", + "mice", + "mouse", + "ps", + "sysmouse", + "ttyS", + }; + Arg args[2]; + int i; + + if (first) { + Widget viewport; + struct dirent *ent; + DIR *dir; + char **list; + int count; + + first = 0; + + mouse_dp = XtCreateWidget("mouseDP", formWidgetClass, + configp, NULL, 0); + + /* DEVICE */ + for (count = 0; count < sizeof(dirs) / sizeof(dirs[0]); count++) { + if ((dir = opendir(dirs[count])) != NULL) { + int i, len, xlen = strlen(dirs[count]) + 2; + + (void)readdir(dir); + (void)readdir(dir); + while ((ent = readdir(dir)) != NULL) { + for (i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) { + len = strlen(patterns[i]); + + if (strncmp(patterns[i], ent->d_name, len) == 0) { + len = strlen(ent->d_name) + xlen; + + devices = (char**)XtRealloc((XtPointer)devices, + sizeof(char*) * ++ndevices); + devices[ndevices - 1] = XtMalloc(len); + XmuSnprintf(devices[ndevices - 1], len, "%s/%s", + dirs[count], ent->d_name); + } + } + } + closedir(dir); + } + } + + (void) XtCreateManagedWidget("labelD", labelWidgetClass, + mouse_dp, NULL, 0); + text = XtVaCreateManagedWidget("device", asciiTextWidgetClass, + mouse_dp, + XtNeditType, XawtextEdit, + NULL); + viewport = XtCreateManagedWidget("viewportD", viewportWidgetClass, + mouse_dp, NULL, 0); + + listD = XtVaCreateManagedWidget("listD", listWidgetClass, + viewport, + XtNlist, devices, + XtNnumberStrings, ndevices, + NULL); + XtAddCallback(listD, XtNcallback, MouseDeviceCallback, (XtPointer)text); + + /* PROTOCOL */ + (void) XtCreateManagedWidget("labelP", labelWidgetClass, + mouse_dp, NULL, 0); + viewport = XtCreateManagedWidget("viewportP", viewportWidgetClass, + mouse_dp, NULL, 0); + + list = (char**)XtMalloc(sizeof(char*) * + sizeof(protocols)/sizeof(protocols[0])); + for (count = 0; count < sizeof(protocols)/sizeof(protocols[0]); count++) + list[count] = XtNewString(protocols[count].name); + listP = XtVaCreateManagedWidget("listP", listWidgetClass, + viewport, + XtNlist, list, + XtNnumberStrings, count, + NULL); + XtAddCallback(listP, XtNcallback, MouseProtocolCallback, NULL); + + emul3 = XtVaCreateManagedWidget("emulate3", toggleWidgetClass, + mouse_dp, XtNstate, True, NULL); + XtAddCallback(emul3, XtNcallback, MouseEmulateCallback, NULL); + apply = XtCreateManagedWidget("apply", commandWidgetClass, + mouse_dp, NULL, 0); + XtAddCallback(apply, XtNcallback, MouseApplyCallback, NULL); + + XtRealizeWidget(mouse_dp); + } + + if (device != NULL) { + for (i = 0; i < ndevices; i++) + if (strcmp(device, devices[i]) == 0) { + XtSetArg(args[0], XtNstring, device); + XtSetValues(text, args, 1); + XawListHighlight(listD, i); + break; + } + + if (i >= ndevices) { + devices = (char**)XtRealloc((XtPointer)devices, + sizeof(char*) * ++ndevices); + devices[ndevices - 1] = XtNewString(device); + XawListHighlight(listD, ndevices - 1); + XtSetArg(args[0], XtNlist, devices); + XtSetArg(args[1], XtNnumberStrings, ndevices); + XtSetValues(listD, args, 2); + } + device = devices[i]; + } + else { + XtSetArg(args[0], XtNstring, ""); + XtSetValues(text, args, 1); + XawListUnhighlight(listD); + } + + if (protocol != NULL) { + for (i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) + if (strcasecmp(protocol, protocols[i].name) == 0) { + protocol = protocols[i].name; + XawListHighlight(listP, i); + break; + } + } + else { + /* "Auto" is the default */ + protocol = protocols[0].name; + XawListHighlight(listP, 0); + } + + XtSetArg(args[0], XtNstate, emulate); + XtSetValues(emul3, args, 1); + + XtChangeManagedSet(¤t, 1, NULL, NULL, &mouse_dp, 1); + current = mouse_dp; +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.h b/xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.h new file mode 100644 index 000000000..90e5980e6 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/mouse-cfg.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + */ + +#include "config.h" + +#ifndef _xf86cfg_mouse_h +#define _xf86cfg_mouse_h + +/* + * Prototypes + */ +XtPointer MouseConfig(XtPointer); +void MouseDeviceAndProtocol(XF86SetupInfo*); + +#endif /* _xf86cfg_mouse_h */ + diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/mouse.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/mouse.xbm new file mode 100644 index 000000000..dce92d24a --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/mouse.xbm @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +#define mouse_width 50 +#define mouse_height 44 +static unsigned char mouse_bits[] = { + 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xcf, 0x03, 0x00, + 0x00, 0x00, 0xc0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xe0, 0x79, 0x78, + 0x1e, 0x00, 0x00, 0x00, 0x60, 0x38, 0x70, 0x18, 0x00, 0x00, 0x00, 0x70, + 0x30, 0x30, 0x38, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, + 0x00, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, + 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x30, 0x30, + 0x30, 0x30, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, + 0xf0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x3f, 0x00, + 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, + 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, + 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, + 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, + 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, + 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x38, + 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xe0, 0x01, + 0x00, 0x1e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/mouse.xpm b/xorg-server/hw/xfree86/utils/xorgcfg/mouse.xpm new file mode 100644 index 000000000..ea157c266 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/mouse.xpm @@ -0,0 +1,76 @@ +/* XPM */ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86$ + */ +static char * mouse_xpm[] = { +"26 35 8 1", +" c none", +". c #E79DE79DE79D", +"X c #CF3CCF3CCF3C", +"o c #BEFBBAEABEFB", +"O c #8E3896588E38", +"+ c #AEBAAAAAAEBA", +"@ c #9E79AAAA9E79", +"# c #A699A289A699", +" .....XXXX. ", +" X..o.XXXXXXXo... ", +" X..XXo.XXXXXXXo.XX.X ", +" X.XXXXo.XXXXXXXo.XXX.X ", +" .XXXXXo.XXXXXXXo.XXXXoo ", +" X.XXXXXo.XXXoXXXo.XXXXoXo", +"oX.XXXXXo.XXXXXXXo.XXXXXoo", +"oX.XoXoXo.XXoXoXXo.XXXXXoO", +"oX.XXXXXo.XXXXXXXo.XXoXX+O", +"oX.XXXoXo.XXoXoXXo.XXXXX+O", +"oX.XXXXXo.XXXXXXXo.XX...+O", +"ooooo...o........oooo@@@OO", +"oX.XX#@@@@@@@@@@@@@@@XXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXXX+O", +"oX.XXXXXXXXXXXXXXXXXXXX+oO", +" #X.XXXXXXXXXXXXXXXXXXooO ", +" #X.XXXXXXXXXXXXXXXXXXooO ", +" #X.XXXXXXXXXXXXXXXXXX+oO ", +" #X.XXXXXXXXXXXXXXXXXX+oO ", +" #.XXXXXXXXXXXXXXXXX++O ", +" #X..XXXXXXXXXXXXXXX+oO ", +" #X.XXXXXXXXXXXXXX+oO ", +" #.XXXXXXXXXXXXXX+O ", +" #X..XXXXXXXXXo++oO ", +" #XX..XXXXXoo+ooO ", +" ##XXooooo+ooOO ", +" ooooooooOO ", +" oOOOOO "}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/narrower.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/narrower.xbm new file mode 100644 index 000000000..0649ef8b4 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/narrower.xbm @@ -0,0 +1,8 @@ +#define narrower_width 19 +#define narrower_height 19 +static unsigned char narrower_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x80, 0x00, 0x18, 0xc0, 0x00, + 0x38, 0xe0, 0x00, 0x78, 0xf0, 0x00, 0xf8, 0xf8, 0x00, 0xff, 0xfd, 0x07, + 0xff, 0xff, 0x07, 0xff, 0xff, 0x07, 0xff, 0xff, 0x07, 0xff, 0xfd, 0x07, + 0xf8, 0xf8, 0x00, 0x78, 0xf0, 0x00, 0x38, 0xe0, 0x00, 0x18, 0xc0, 0x00, + 0x08, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/options.c b/xorg-server/hw/xfree86/utils/xorgcfg/options.c new file mode 100644 index 000000000..d229bb17f --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/options.c @@ -0,0 +1,787 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "options.h" +#include "xf86config.h" +#include <X11/Xresource.h> +#include <X11/Shell.h> +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/List.h> +#include <X11/Xaw/Command.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/Paned.h> +#include <X11/Xaw/SimpleMenP.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/Viewport.h> +#include <ctype.h> + +/* + * Prototypes + */ +static void PopdownCallback(Widget, XtPointer, XtPointer); +static void SelectOptionCallback(Widget, XtPointer, XtPointer); +static void AddOption(Widget, XtPointer, XtPointer); +static void RemoveOption(Widget, XtPointer, XtPointer); +static void UpdateOption(Widget, XtPointer, XtPointer); +static void UpdateOptionList(void); +#ifdef USE_MODULES +static void AddDriverOption(Widget, XtPointer, XtPointer); +static void SelectModuleCallback(Widget, XtPointer, XtPointer); +static void SelectModuleOptionCallback(Widget, XtPointer, XtPointer); +static void ModuleOptionsPopdown(Widget, XtPointer, XtPointer); +#endif +static Bool EnumDatabase(XrmDatabase*, XrmBindingList, XrmQuarkList, + XrmRepresentation*, XrmValue*, XPointer); + +/* + * Initialization + */ +Widget optionsShell; +static XF86OptionPtr *options; +static Widget add, remov, update, list, name, value; +static char *option_str; +static int option_index, popped = False; +static char *Options = "lib/X11/Options"; +XrmDatabase options_xrm; +struct { + char *string; + int offset; +} rebuild_xrm; +#ifdef USE_MODULES +static Widget modList, optList, desc, modOptionsShell, labelType; +static char *module_sel; +static char *types[] = { + "none", "integer", "(non null) string", "string", "real", + "boolean", "frequency", +}; +#endif + +/* + * Implementation + */ +#ifdef USE_MODULES +static int +qcmp_str(_Xconst void *a, _Xconst void *b) +{ + return (strcmp(*(char**)a, *(char**)b)); +} + +void +ModuleOptionsPopup(Widget w, XtPointer user_data, XtPointer call_data) +{ + xf86cfgModuleOptions *info = module_options; + + if (modOptionsShell == NULL) { + char **ops; + int nops; + Widget pane, form, viewport, bottom, popdown; + + modOptionsShell = XtCreatePopupShell("moduleOptions", + transientShellWidgetClass, + optionsShell, NULL, 0); + + pane = XtCreateManagedWidget("pane", panedWidgetClass, + modOptionsShell, NULL, 0); + + form = XtCreateManagedWidget("descriptions", formWidgetClass, + pane, NULL, 0); + labelType = XtCreateManagedWidget("labelType", labelWidgetClass, + form, NULL, 0); + XtCreateManagedWidget("module", labelWidgetClass, form, NULL, 0); + viewport = XtCreateManagedWidget("viewM", viewportWidgetClass, + form, NULL, 0); + ops = NULL; + nops = 0; + while (info) { + ++nops; + ops = (char**)XtRealloc((XtPointer)ops, sizeof(char*) * nops); + ops[nops - 1] = XtNewString(info->name); + info = info->next; + } + if (nops == 0) { + ops = (char**)XtMalloc(sizeof(char*)); + ops[0] = XtNewString(""); + nops = 1; + } + else + qsort(ops, nops, sizeof(char*), qcmp_str); + modList = XtVaCreateManagedWidget("modL", listWidgetClass, + viewport, XtNlist, ops, + XtNnumberStrings, nops, + NULL); + XtAddCallback(modList, XtNcallback, SelectModuleCallback, NULL); + XtCreateManagedWidget("option", labelWidgetClass, form, NULL, 0); + viewport = XtCreateManagedWidget("viewO", viewportWidgetClass, + form, NULL, 0); + ops = (char**)XtMalloc(sizeof(char*)); + ops[0] = XtNewString(""); + optList = XtVaCreateManagedWidget("optL", listWidgetClass, + viewport, XtNlist, ops, + XtNnumberStrings, 1, NULL); + XtAddCallback(optList, XtNcallback, SelectModuleOptionCallback, NULL); + desc = XtVaCreateManagedWidget("desc", asciiTextWidgetClass, + form, XtNeditType, XawtextRead, + NULL); + + bottom = XtCreateManagedWidget("bottom", formWidgetClass, + pane, NULL, 0); + popdown = XtVaCreateManagedWidget("popdown", commandWidgetClass, + bottom, NULL); + XtAddCallback(popdown, XtNcallback, ModuleOptionsPopdown, NULL); + XtRealizeWidget(modOptionsShell); + XSetWMProtocols(DPY, XtWindow(modOptionsShell), &wm_delete_window, 1); + + info = module_options; + } + + if (module_sel && *module_sel) { + XawListReturnStruct list; /* hack to call ballbacks */ + char **strs; + int nstrs, idx = 0; + + XtVaGetValues(modList, XtNlist, &strs, XtNnumberStrings, &nstrs, NULL); + for (idx = nstrs - 1; idx > 0; idx--) + if (strcmp(module_sel, strs[idx]) == 0) + break; + while (info) { + if (strcmp(module_sel, info->name) == 0) + break; + info = info->next; + } + if (info) { + list.string = info->name; + list.list_index = idx; + XawListHighlight(modList, idx); + SelectModuleCallback(modList, NULL, (XtPointer)&list); + } + if (option_str && *option_str) { + OptionInfoPtr opts = info->option; + + idx = 0; + while (opts && opts->name) { + if (strcmp(opts->name, option_str) == 0) + break; + ++idx; + ++opts; + } + + if (opts && opts->name) { + list.string = (char *)opts->name; + list.list_index = idx; + XawListHighlight(optList, idx); + SelectModuleOptionCallback(optList, NULL, (XtPointer)&list); + } + } + } + XtPopup(modOptionsShell, XtGrabNone); +} + +/*ARGSUSED*/ +static void +ModuleOptionsPopdown(Widget w, XtPointer user_data, XtPointer call_data) +{ + XtPopdown(modOptionsShell); +} + +/*ARGSUSED*/ +void +ModuleOptionsCancelAction(Widget w, XEvent *event, + String *params, Cardinal *num_params) +{ + ModuleOptionsPopdown(w, NULL, NULL); +} +#endif + +void +CreateOptionsShell(void) +{ + optionsShell = XtCreatePopupShell("options", transientShellWidgetClass, + toplevel, NULL, 0); +} + +#ifdef USE_MODULES +void +OptionsPopup(XF86OptionPtr *opts, char *driver, OptionInfoPtr drv_opts) +#else +void +OptionsPopup(XF86OptionPtr *opts) +#endif +{ + static int first = 1; +#ifdef USE_MODULES + static Widget button, menu; + static char label[256], menuName[16]; + Widget sme; + char buf[256]; + int i = 0; + Arg args[1]; + static int menuN; +#endif + + option_str = NULL; + options = opts; + if (first) { + Widget pane, form, viewport, bottom, popdown; + + first = 0; + + if (optionsShell == NULL) + CreateOptionsShell(); + pane = XtCreateManagedWidget("pane", panedWidgetClass, + optionsShell, NULL, 0); + + form = XtCreateManagedWidget("commands", formWidgetClass, + pane, NULL, 0); + add = XtCreateManagedWidget("add", commandWidgetClass, + form, NULL, 0); + XtAddCallback(add, XtNcallback, AddOption, NULL); + remov = XtCreateManagedWidget("remove", commandWidgetClass, + form, NULL, 0); + XtAddCallback(remov, XtNcallback, RemoveOption, NULL); + update = XtCreateManagedWidget("update", commandWidgetClass, + form, NULL, 0); + XtAddCallback(update, XtNcallback, UpdateOption, NULL); +#ifdef USE_MODULES + if (!nomodules) { + Widget command; + + command = XtCreateManagedWidget("help", commandWidgetClass, + form, NULL, 0); + XtAddCallback(command, XtNcallback, ModuleOptionsPopup, NULL); + } +#endif + form = XtCreateManagedWidget("form", formWidgetClass, + pane, NULL, 0); + XtVaCreateManagedWidget("label1", labelWidgetClass, form, + XtNlabel, " Option \"", + NULL); + name = XtVaCreateManagedWidget("name", asciiTextWidgetClass, form, + XtNeditType, XawtextEdit, + NULL); + XtVaCreateManagedWidget("label2", labelWidgetClass, + form, + XtNlabel, "\" \"", + NULL); + value = XtVaCreateManagedWidget("value", asciiTextWidgetClass, form, + XtNeditType, XawtextEdit, + NULL); + XtVaCreateManagedWidget("label3", labelWidgetClass, form, + XtNlabel, "\" ", + NULL); + viewport = XtCreateManagedWidget("viewport", viewportWidgetClass, + form, NULL, 0); + list = XtCreateManagedWidget("list", listWidgetClass, + viewport, NULL, 0); + XtAddCallback(list, XtNcallback, SelectOptionCallback, NULL); + bottom = XtCreateManagedWidget("bottom", formWidgetClass, + pane, NULL, 0); +#ifdef USE_MODULES + if (!nomodules) + button = XtCreateManagedWidget("driverOpts", menuButtonWidgetClass, + bottom, NULL, 0); +#endif + popdown = XtVaCreateManagedWidget("popdown", commandWidgetClass, + bottom, NULL); +#ifdef USE_MODULES + if (!nomodules) + XtVaSetValues(popdown, XtNfromHoriz, button, NULL); +#endif + + XtAddCallback(popdown, XtNcallback, PopdownCallback, NULL); + XtRealizeWidget(optionsShell); + XSetWMProtocols(DPY, XtWindow(optionsShell), &wm_delete_window, 1); + +#ifdef USE_MODULES + if (!nomodules) { + char *str; + + XtSetArg(args[0], XtNlabel, &str); + XtGetValues(button, args, 1); + XmuSnprintf(label, sizeof(label), "%s", str); + } +#endif + } + +#ifdef USE_MODULES + if (!nomodules) { + if (menu) + XtDestroyWidget(menu); + XmuSnprintf(menuName, sizeof(menuName), "optionM%d", menuN); + menuN = !menuN; + menu = XtCreatePopupShell(menuName, simpleMenuWidgetClass, button, + NULL, 0); + XtVaSetValues(button, XtNmenuName, menuName, NULL); + if (drv_opts) { + int len, longest = 0; + char fmt[32]; + + for (i = 0; drv_opts[i].name != NULL; i++) { + len = strlen(drv_opts[i].name); + if (len > longest) + longest = len; + } + XmuSnprintf(fmt, sizeof(fmt), "%c-%ds %%s", '%', longest); + for (; drv_opts->name != NULL; drv_opts++) { + char *type; + + if (drv_opts->type >= OPTV_NONE && drv_opts->type <= OPTV_FREQ) + type = types[drv_opts->type]; + else + type = "UNKNOWN"; + + XmuSnprintf(buf, sizeof(buf), fmt, drv_opts->name, type); + sme = XtVaCreateManagedWidget(drv_opts->name, smeBSBObjectClass, + menu, XtNlabel, buf, NULL); + XtAddCallback(sme, XtNcallback, AddDriverOption, (XtPointer)drv_opts); + } + } + if (i) { + xf86cfgModuleOptions *mod = module_options; + + while (mod) { + if (strcmp(mod->name, driver) == 0) { + /* don't assign to driver, as it may be a temp string */ + module_sel = mod->name; + break; + } + mod = mod->next; + } + XmuSnprintf(buf, sizeof(buf), "%s%s", label, driver); + XtSetArg(args[0], XtNlabel, buf); + XtSetValues(button, args, 1); + XtMapWidget(button); + } + else + XtUnmapWidget(button); + } +#endif + + UpdateOptionList(); + popped = True; + XtPopup(optionsShell, XtGrabExclusive); + + while (popped) + XtAppProcessEvent(XtWidgetToApplicationContext(optionsShell), XtIMAll); +} + +static void +UpdateOptionList(void) +{ + Arg args[2]; + char **ops, **oldops; + int nops, oldnops; + XF86OptionPtr opt; + + ops = NULL; + nops = 0; + XawListUnhighlight(list); + XtSetArg(args[0], XtNlist, &oldops); + XtSetArg(args[1], XtNnumberStrings, &oldnops); + XtGetValues(list, args, 2); + opt = *options; + while (opt != NULL) { + if (nops % 16 == 0) + ops = (char**)XtRealloc((XtPointer)ops, (nops + 16) * + sizeof(char*)); + ops[nops++] = XtNewString(opt->opt_name); + opt = (XF86OptionPtr)(opt->list.next); + } + if (nops == 0) { + ops = (char**)XtMalloc(sizeof(char*)); + ops[0] = XtNewString(""); + nops = 1; + } + XtSetArg(args[0], XtNlist, ops); + XtSetArg(args[1], XtNnumberStrings, nops); + XtSetValues(list, args, 2); + if (oldnops > 0 && + (oldnops != 1 || XtName(list) != oldops[0])) { + while (--oldnops >= 0) + XtFree(oldops[oldnops]); + XtFree((XtPointer)oldops); + } + + XtSetArg(args[0], XtNstring, ""); + XtSetValues(name, args, 1); + XtSetValues(value, args, 1); + + /* force relayout */ + XtUnmanageChild(list); + XtManageChild(list); + + XtSetSensitive(remov, False); + XtSetSensitive(update, False); +} + +/*ARGSUSED*/ +static void +PopdownCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XtPopdown(optionsShell); + popped = False; +} + +/*ARGSUSED*/ +void +OptionsCancelAction(Widget w, XEvent *event, + String *params, Cardinal *num_params) +{ + PopdownCallback(w, NULL, NULL); +} + +/*ARGSUSED*/ +static void +SelectOptionCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + XF86OptionPtr option; + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + + option_str = info->string; + option_index = info->list_index; + if ((option = xf86findOption(*options, info->string)) != NULL) { + XtSetArg(args[0], XtNstring, option->opt_name); + XtSetValues(name, args, 1); + XtSetArg(args[0], XtNstring, + option->opt_val != NULL ? option->opt_val : ""); + XtSetValues(value, args, 1); + } + XtSetSensitive(remov, True); + XtSetSensitive(update, True); +} + +/*ARGSUSED*/ +static void +AddOption(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + char *nam, *val; + + XtSetArg(args[0], XtNstring, &nam); + XtGetValues(name, args, 1); + XtSetArg(args[0], XtNstring, &val); + XtGetValues(value, args, 1); + if (xf86findOption(*options, nam) != NULL || strlen(nam) == 0) + /* XXX xf86addNewOption will trash the option linked list if + * the options being added already exists. + */ + return; + *options = xf86addNewOption(*options, XtNewString(nam), + val && strlen(val) ? XtNewString(val) : NULL); + UpdateOptionList(); +} + +#ifdef USE_MODULES +/*ARGSUSED*/ +static void +AddDriverOption(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + OptionInfoPtr opt = (OptionInfoPtr)user_data; + XF86OptionPtr option; + + option_str = (char *)opt->name; + XtSetArg(args[0], XtNstring, opt->name); + XtSetValues(name, args, 1); + if ((option = xf86findOption(*options, opt->name)) == NULL) + XtSetArg(args[0], XtNstring, ""); + else + XtSetArg(args[0], XtNstring, option->opt_val); + XtSetValues(value, args, 1); +} + +/*ARGSUSED*/ +static void +SelectModuleCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + xf86cfgModuleOptions *mod = module_options; + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + + while (mod) { + if (strcmp(mod->name, info->string) == 0) + break; + mod = mod->next; + } + + if (mod) { + Arg args[2]; + char **list = NULL, **old; + OptionInfoPtr opts = mod->option; + int num = 0, oldnum; + + module_sel = mod->name; + XtSetArg(args[0], XtNlist, &old); + XtSetArg(args[1], XtNnumberStrings, &oldnum); + XtGetValues(optList, args, 2); + while (opts && opts->name) { + ++num; + list = (char**)XtRealloc((XtPointer)list, sizeof(char*) * num); + list[num - 1] = XtNewString(opts->name); + ++opts; + } + if (num == 0) { + list = (char**)XtMalloc(sizeof(char*)); + list[0] = XtNewString(""); + num = 1; + } + XtSetArg(args[0], XtNlist, list); + XtSetArg(args[1], XtNnumberStrings, num); + XtSetValues(optList, args, 2); + while (--oldnum >= 0) + XtFree(old[oldnum]); + XtFree((XtPointer)old); + + XtVaSetValues(desc, XtNstring, "", NULL); + XawListUnhighlight(optList); + + /* force relayout */ + XtUnmanageChild(optList); + XtManageChild(optList); + } +} + +static void +SelectModuleOptionCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + xf86cfgModuleOptions *mod = module_options; + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + char *description = NULL, *type = "undefined"; + char label[256]; + + if (module_sel && info->string) + description = GetOptionDescription(module_sel, info->string); + if (description == NULL) + description = "** NO DESCRIPTION AVAILABLE **"; + + XtVaSetValues(desc, XtNstring, description, NULL); + + while (mod) { + if (strcmp(module_sel, mod->name) == 0) + break; + mod = mod->next; + } + if (mod) { + OptionInfoPtr opts = mod->option; + + while (opts && opts->name) { + if (strcasecmp(opts->name, info->string) == 0) + break; + ++opts; + } + if (opts && opts->name && opts->type >= OPTV_NONE && + opts->type <= OPTV_FREQ) + type = types[opts->type]; + } + + XmuSnprintf(label, sizeof(label), "%s.%s (%s)", module_sel, info->string, + type); + XtVaSetValues(labelType, XtNlabel, label, NULL); +} +#endif + +/*ARGSUSED*/ +static void +RemoveOption(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + char *str; + + XtSetArg(args[0], XtNstring, &str); + XtGetValues(name, args, 1); + xf86removeOption(options, str); + UpdateOptionList(); +} + +/*ARGSUSED*/ +static void +UpdateOption(Widget w, XtPointer user_data, XtPointer call_data) +{ +/* xf86removeOption(options, option_str); + AddOption(w, user_data, call_data); + UpdateOptionList();*/ + + Arg args[1]; + char *nam, *val; + XF86OptionPtr option; + + XtSetArg(args[0], XtNstring, &nam); + XtGetValues(name, args, 1); + XtSetArg(args[0], XtNstring, &val); + XtGetValues(value, args, 1); + if ((option = xf86findOption(*options, option_str)) == NULL) + return; + XtFree(option->opt_name); + option->opt_name = option_str = XtNewString(nam); + XtFree(option->opt_val); + if (val && strlen(val)) + option->opt_val = XtNewString(val); + else + option->opt_val = NULL; + + UpdateOptionList(); + XawListHighlight(list, option_index); + XtSetArg(args[0], XtNstring, option->opt_name); + XtSetValues(name, args, 1); + XtSetArg(args[0], XtNstring, option->opt_val); + XtSetValues(value, args, 1); + + XtSetSensitive(remov, True); + XtSetSensitive(update, True); +} + +/*ARGUSED*/ +static Bool +EnumDatabase(XrmDatabase *db, XrmBindingList bindings, XrmQuarkList quarks, + XrmRepresentation *type, XrmValue *value, XPointer closure) +{ + char *module = XrmQuarkToString(quarks[0]), + *option = XrmQuarkToString(quarks[1]); + + /* handle *.Option: value */ + if (module && option == NULL) { + option = module; + module = "*"; + } + + /* + * NOTE: If the Options file is changed to support any other format than + * + * Module.Option: description text + * + * this code will also need to be updated. + */ + + if (module) { + XrmValue xrm; + char *type, *value, query[256]; + + XmuSnprintf(query, sizeof(query), "%s.%s", module, option); + if (XrmGetResource(options_xrm, query, "Module.Option", &type, &xrm)) + value = (char*)xrm.addr; + else + value = NULL; + + if (value) { + char *norm; + unsigned char *ptr; + int position; + int length = strlen(module) + strlen(option) + strlen(value) + 4; + + rebuild_xrm.string = XtRealloc(rebuild_xrm.string, + rebuild_xrm.offset + length); + position = rebuild_xrm.offset + + sprintf(rebuild_xrm.string + rebuild_xrm.offset, "%s.%s:", + module, option); + + /* removes underlines and spaces */ + norm = strchr(rebuild_xrm.string + rebuild_xrm.offset, '.') + 1; + for (; *norm; norm++) { + if (*norm == '_' || *norm == ' ' || *norm == '\t') { + memmove(norm, norm + 1, strlen(norm) + 1); + --position; + --length; + } + } + + for (ptr = (unsigned char*)rebuild_xrm.string + rebuild_xrm.offset; + *ptr; ptr++) + *ptr = tolower(*ptr); + sprintf(rebuild_xrm.string + position, "%s\n", value); + rebuild_xrm.offset += length - 1; + } + } + + return (False); +} + +Bool +InitializeOptionsDatabase(void) +{ + static int first = 1; + static Bool result = True; + + if (first) { + XrmQuark names[2]; + XrmQuark classes[2]; + + first = 0; + XrmInitialize(); + if ((options_xrm = XrmGetFileDatabase(Options)) == (XrmDatabase)0) { + fprintf(stderr, "Cannot open '%s' database.\n", Options); + return (False); + } + + /* rebuild database, using only lowercase characters */ + names[0] = classes[0] = names[1] = classes[1] = NULLQUARK; + (void)XrmEnumerateDatabase(options_xrm, (XrmNameList)&names, + (XrmClassList)&classes, XrmEnumAllLevels, + EnumDatabase, NULL); + + /* free previous database, as it is not guaranteed to be + * "case insensitive" */ + XrmDestroyDatabase(options_xrm); + + /* create case insensitive database by making everything lowercase */ + if (rebuild_xrm.string == NULL || + (options_xrm = XrmGetStringDatabase(rebuild_xrm.string)) == + (XrmDatabase)0) { + fprintf(stderr, "Cannot rebuild '%s' database.\n", Options); + XtFree(rebuild_xrm.string); + return (False); + } + XtFree(rebuild_xrm.string); + } + + return (result); +} + +char * +GetOptionDescription(char *module, char *option) +{ + char *type; + XrmValue value; + char query[256]; + unsigned char *ptr; + + InitializeOptionsDatabase(); + + XmuSnprintf(query, sizeof(query), "%s.%s", module, option); + ptr = (unsigned char*)strchr(query, '.') + 1; + for (; *ptr; ptr++) { + if (*ptr == '_' || *ptr == ' ' || *ptr == '\t') + memmove(ptr, ptr + 1, strlen((char*)ptr) + 1); + } + for (ptr = (unsigned char*)query; *ptr; ptr++) + *ptr = tolower(*ptr); + if (XrmGetResource(options_xrm, query, "Module.Option", &type, &value)) + return ((char*)value.addr); + + return (NULL); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/options.h b/xorg-server/hw/xfree86/utils/xorgcfg/options.h new file mode 100644 index 000000000..2d08ca448 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/options.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#ifdef USE_MODULES +#include "loader.h" +#endif + +/* + * Prototypes + */ +#ifdef USE_MODULES +void OptionsPopup(XF86OptionPtr*, char*, OptionInfoPtr); +void ModuleOptionsPopup(Widget, XtPointer, XtPointer); +#else +void OptionsPopup(XF86OptionPtr*); +#endif +void OptionsCancelAction(Widget, XEvent*, String*, Cardinal*); +void ModuleOptionsCancelAction(Widget, XEvent*, String*, Cardinal*); +char *GetOptionDescription(char *module, char *option); +Bool InitializeOptionsDatabase(void); + +void CreateOptionsShell(void); diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/right.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/right.xbm new file mode 100644 index 000000000..a2f2ce2d1 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/right.xbm @@ -0,0 +1,8 @@ +#define right_width 19 +#define right_height 19 +static unsigned char right_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x0e, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x3e, 0x00, 0xf8, 0x7f, 0x00, + 0xf8, 0xff, 0x00, 0xf8, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xf8, 0x7f, 0x00, + 0x00, 0x3e, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.c b/xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.c new file mode 100644 index 000000000..4c67d725a --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.c @@ -0,0 +1,555 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "xf86config.h" +#include "screen-cfg.h" +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/List.h> +#include <X11/Xaw/Toggle.h> +#include <X11/Xaw/Viewport.h> +#ifdef USE_MODULES +#include "loader.h" +#endif + +#define CW 1 +#define CCW -1 + +/* + * Prototypes + */ +static void DepthCallback(Widget, XtPointer, XtPointer); +static void SelectIndexCallback(Widget, XtPointer, XtPointer); +static void UnselectIndexCallback(Widget, XtPointer, XtPointer); +static void SelectCallback(Widget, XtPointer, XtPointer); +static void UnselectCallback(Widget, XtPointer, XtPointer); +static void MoveCallback(Widget, XtPointer, XtPointer); +static void RotateCallback(Widget, XtPointer, XtPointer); + +/* + * Initialization + */ +static char *standard_modes[] = { + "640x400", + "640x480", + "800x600", + "1024x768", + "1280x960", + "1280x1024", + "320x200", + "320x240", + "400x300", + "1152x864", + "1600x1200", + "1800x1400", + "512x384", + "1400x1050", + "2048x1536", + "1920x1440", +}; + +static char **modes; +static int nmodes; +static int default_depth, sel_index, unsel_index; +static Widget listL, listR; +static char **defmodes; +static int ndefmodes; +static XF86ConfScreenPtr screen; +static int rotate; + +/* + * Implementation + */ +XtPointer +ScreenConfig(XtPointer conf) +{ + XF86ConfDisplayPtr disp; + Arg args[2]; + int i, oldrotate; + + screen = (XF86ConfScreenPtr)conf; + if (screen == NULL) + return (NULL); + + XtSetArg(args[0], XtNstring, screen->scrn_identifier); + XtSetValues(ident_widget, args, 1); + if ((default_depth = screen->scrn_defaultdepth) <= 0) + default_depth = 8; + sel_index = unsel_index = -1; + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == screen) { + SetScreenRotate(computer.screens[i]); + rotate = computer.screens[i]->rotate; + } + oldrotate = rotate; + + ndefmodes = 0; + disp = screen->scrn_display_lst; + while (disp != NULL) { + if (disp->disp_depth == default_depth) { + XF86ModePtr mod = disp->disp_mode_lst; + + while (mod != NULL) { + if (ndefmodes % 16 == 0) + defmodes = (char**) + XtRealloc((XtPointer)defmodes, + (ndefmodes + 16) * sizeof(char*)); + defmodes[ndefmodes++] = XtNewString(mod->mode_name); + mod = (XF86ModePtr)(mod->list.next); + } + break; + } + disp = (XF86ConfDisplayPtr)(disp->list.next); + } + if (ndefmodes == 0) { + defmodes = (char**)XtMalloc(sizeof(char*)); + defmodes[0] = XtNewString("640x480"); + ndefmodes = 1; + } + + if (listL != NULL) { + XawListUnhighlight(listL); + XawListUnhighlight(listR); + } + + xf86info.cur_list = SCREEN; + XtSetSensitive(back, xf86info.lists[SCREEN].cur_function > 0); + XtSetSensitive(next, xf86info.lists[SCREEN].cur_function < + xf86info.lists[SCREEN].num_functions - 1); + (xf86info.lists[SCREEN].functions[xf86info.lists[SCREEN].cur_function]) + (&xf86info); + + if (ConfigLoop(NULL) == True) { + XF86ModePtr prev = NULL, mod; + + /* user may have changed the default depth, read variables again */ + disp = screen->scrn_display_lst; + while (disp != NULL) { + if (disp->disp_depth == default_depth) + break; + disp = (XF86ConfDisplayPtr)(disp->list.next); + } + + if (disp == NULL) { + disp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec)); + screen->scrn_display_lst = (XF86ConfDisplayPtr) + xf86addListItem((GenericListPtr)(screen->scrn_display_lst), + (GenericListPtr)(disp)); + disp->disp_depth = default_depth; + } + + if (strcasecmp(screen->scrn_identifier, ident_string)) + xf86renameScreen(XF86Config, screen, ident_string); + + screen->scrn_defaultdepth = default_depth; + + XtSetArg(args[0], XtNlist, NULL); + XtSetArg(args[1], XtNnumberStrings, 0); + XtSetValues(listL, args, 2); + + XtSetArg(args[0], XtNlist, NULL); + XtSetArg(args[1], XtNnumberStrings, 0); + XtSetValues(listR, args, 2); + + mod = disp->disp_mode_lst; + /* free all modes */ + while (mod != NULL) { + prev = mod; + mod = (XF86ModePtr)(mod->list.next); + XtFree(prev->mode_name); + XtFree((XtPointer)prev); + } + /* readd modes */ + for (i = 0; i < ndefmodes; i++) { + mod = XtNew(XF86ModeRec); + mod->mode_name = XtNewString(defmodes[i]); + XtFree(defmodes[i]); + if (i == 0) + disp->disp_mode_lst = mod; + else + prev->list.next = mod; + prev = mod; + } + if (i == 0) + disp->disp_mode_lst = NULL; + else + mod->list.next = NULL; + + XtFree((XtPointer)defmodes); + defmodes = NULL; + ndefmodes = 0; + + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == screen) + computer.screens[i]->rotate = rotate; + + if (oldrotate != rotate) { + static char *Rotate = "Rotate"; + + if (screen->scrn_option_lst != NULL) + xf86removeOption(&screen->scrn_option_lst, Rotate); + if (rotate) + screen->scrn_option_lst = + xf86addNewOption(screen->scrn_option_lst, + XtNewString(Rotate), + XtNewString(rotate > 0 ? "CW" : "CCW")); + UpdateScreenUI(); + AdjustScreenUI(); + } + + return ((XtPointer)screen); + } + + XtSetArg(args[0], XtNlist, NULL); + XtSetArg(args[1], XtNnumberStrings, 0); + XtSetValues(listL, args, 2); + + XtSetArg(args[0], XtNlist, NULL); + XtSetArg(args[1], XtNnumberStrings, 0); + XtSetValues(listR, args, 2); + + for (i = 0; i < ndefmodes; i++) + XtFree(defmodes[i]); + XtFree((XtPointer)defmodes); + defmodes = NULL; + ndefmodes = 0; + + return (NULL); +} + +/*ARGSUSED*/ +static void +DepthCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + if (call_data != NULL) + default_depth = (long)user_data; +} + +/*ARGSUSED*/ +static void +SelectIndexCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + + sel_index = info->list_index; +} + +/*ARGSUSED*/ +static void +UnselectIndexCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawListReturnStruct *info = (XawListReturnStruct *)call_data; + + unsel_index = info->list_index; +} + +/*ARGSUSED*/ +static void +SelectCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[2]; + + if (sel_index < 0 || sel_index >= nmodes) + return; + + if (ndefmodes == 1 && *defmodes[0] == '\0') { + /* make sure tmp and defentries are not the same pointer */ + char **tmp = defmodes; + + XtFree(defmodes[0]); + defmodes = (char**)XtMalloc(sizeof(char*)); + --ndefmodes; + XtFree((char*)tmp); + } + else + defmodes = (char**)XtRealloc((XtPointer)defmodes, + sizeof(char*) * (ndefmodes + 1)); + defmodes[ndefmodes++] = XtNewString(modes[sel_index]); + + XtSetArg(args[0], XtNlist, defmodes); + XtSetArg(args[1], XtNnumberStrings, ndefmodes); + XtSetValues(listR, args, 2); + + XawListUnhighlight(listR); + if (ndefmodes > 1 || (ndefmodes == 1 && *defmodes[0] != '\0')) { + if (unsel_index >= ndefmodes) + unsel_index = ndefmodes - 1; + XawListHighlight(listR, unsel_index = ndefmodes - 1); + } + else + unsel_index = -1; + + /* force realyout */ + XtUnmanageChild(listR); + XtManageChild(listR); +} + +/*ARGSUSED*/ +static void +UnselectCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[2]; + char **modes; + Cardinal num_modes; + + if (unsel_index < 0 || unsel_index >= ndefmodes) + return; + + XawListUnhighlight(listL); + XtSetArg(args[0], XtNlist, &modes); + XtSetArg(args[1], XtNnumberStrings, &num_modes); + XtGetValues(listL, args, 2); + if (modes) { + for (sel_index = 0; sel_index < num_modes; sel_index++) + if (strcmp(defmodes[unsel_index], modes[sel_index]) == 0) + break; + if (sel_index < num_modes) + XawListHighlight(listL, sel_index); + else + sel_index = -1; + } + + XtFree(defmodes[unsel_index]); + if (--ndefmodes > unsel_index) + memmove(&defmodes[unsel_index], &defmodes[unsel_index + 1], + (ndefmodes - unsel_index) * sizeof(char*)); + if (ndefmodes == 0) { + char **tmp = defmodes; + + defmodes = (char**)XtMalloc(sizeof(char*)); + defmodes[0] = XtNewString(""); + ndefmodes = 1; + XtFree((char*)tmp); + } + + XtSetArg(args[0], XtNlist, defmodes); + XtSetArg(args[1], XtNnumberStrings, ndefmodes); + XtSetValues(listR, args, 2); + + XawListUnhighlight(listR); + if (ndefmodes > 1 || (ndefmodes == 1 && *defmodes[0] != '\0')) { + if (unsel_index >= ndefmodes) + unsel_index = ndefmodes - 1; + XawListHighlight(listR, unsel_index); + } + else + unsel_index = -1; +} + +/*ARGSUSED*/ +static void +MoveCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + char *tmp; + Bool down = (long)user_data; + + if (unsel_index < 0 || unsel_index >= ndefmodes) + return; + + if ((down && unsel_index + 1 >= ndefmodes) || + (!down && unsel_index - 1 < 0)) + return; + + tmp = defmodes[unsel_index]; + if (down) { + defmodes[unsel_index] = defmodes[unsel_index + 1]; + unsel_index++; + } else { + defmodes[unsel_index] = defmodes[unsel_index - 1]; + unsel_index--; + } + defmodes[unsel_index] = tmp; + + XawListUnhighlight(listR); + XawListHighlight(listR, unsel_index); +} + +/*ARGSUSED*/ +void +RotateCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + if (call_data != NULL) + rotate = (long)user_data; + else + rotate = 0; +} + +void +ScreenDialog(XF86SetupInfo *info) +{ + static Widget dialog, d1, d4, d8, d16, d24, labelRotate, cw, ccw; + Arg args[2]; + XF86ConfMonitorPtr mon = screen->scrn_monitor; + XF86ConfModeLinePtr mline = mon != NULL ? mon->mon_modeline_lst : NULL; + int i; +#ifdef USE_MODULES + xf86cfgModuleOptions *drv_opts = module_options; + Bool foundRotate = False; +#endif + + while (nmodes > 0) + XtFree(modes[--nmodes]); + XtFree((XtPointer)modes); + modes = NULL; + while (mline) { + if (nmodes % 16 == 0) + modes = (char**)XtRealloc((XtPointer)modes, + sizeof(char*) * (nmodes + 16)); + modes[nmodes++] = XtNewString(mline->ml_identifier); + mline = (XF86ConfModeLinePtr)(mline->list.next); + } + for (i = 0; i < sizeof(standard_modes) / sizeof(standard_modes[0]); i++) { + if (nmodes % 16 == 0) + modes = (char**)XtRealloc((XtPointer)modes, + sizeof(char*) * (nmodes + 16)); + modes[nmodes++] = XtNewString(standard_modes[i]); + } + + if (dialog == NULL) { + Widget command, viewport; + + dialog = XtCreateWidget("screenD", formWidgetClass, + configp, NULL, 0); + XtCreateManagedWidget("depthL", labelWidgetClass, + dialog, NULL, 0); + d1 = XtCreateManagedWidget("1", toggleWidgetClass, dialog, NULL, 0); + XtAddCallback(d1, XtNcallback, DepthCallback, (XtPointer)1); + d4 = XtVaCreateManagedWidget("4", toggleWidgetClass, dialog, + XtNradioGroup, d1, NULL); + XtAddCallback(d4, XtNcallback, DepthCallback, (XtPointer)4); + d8 = XtVaCreateManagedWidget("8", toggleWidgetClass, dialog, + XtNradioGroup, d4, NULL); + XtAddCallback(d8, XtNcallback, DepthCallback, (XtPointer)8); + d16 = XtVaCreateManagedWidget("16", toggleWidgetClass, dialog, + XtNradioGroup, d8, NULL); + XtAddCallback(d16, XtNcallback, DepthCallback, (XtPointer)16); + d24 = XtVaCreateManagedWidget("24", toggleWidgetClass, dialog, + XtNradioGroup, d16, NULL); + XtAddCallback(d24, XtNcallback, DepthCallback, (XtPointer)24); + + XtCreateManagedWidget("modeL", labelWidgetClass, dialog, NULL, 0); + viewport = XtCreateManagedWidget("viewL", viewportWidgetClass, dialog, + NULL, 0); + listL = XtCreateManagedWidget("listLeft", listWidgetClass, viewport, + NULL, 0); + XtAddCallback(listL, XtNcallback, SelectIndexCallback, NULL); + command = XtCreateManagedWidget("select", commandWidgetClass, + dialog, NULL, 0); + XtAddCallback(command, XtNcallback, SelectCallback, NULL); + command = XtCreateManagedWidget("unselect", commandWidgetClass, + dialog, NULL, 0); + XtAddCallback(command, XtNcallback, UnselectCallback, NULL); + command = XtCreateManagedWidget("up", commandWidgetClass, + dialog, NULL, 0); + XtAddCallback(command, XtNcallback, MoveCallback, (XtPointer)False); + command = XtCreateManagedWidget("down", commandWidgetClass, + dialog, NULL, 0); + XtAddCallback(command, XtNcallback, MoveCallback, (XtPointer)True); + viewport = XtCreateManagedWidget("viewR", viewportWidgetClass, dialog, + NULL, 0); + listR = XtCreateManagedWidget("listRight", listWidgetClass, viewport, + NULL, 0); + XtAddCallback(listR, XtNcallback, UnselectIndexCallback, NULL); + + labelRotate = XtCreateManagedWidget("rotate", labelWidgetClass, + dialog, NULL, 0); + cw = XtCreateManagedWidget("CW", toggleWidgetClass, dialog, NULL, 0); + XtAddCallback(cw, XtNcallback, RotateCallback, (XtPointer)CW); + ccw = XtVaCreateManagedWidget("CCW", toggleWidgetClass, dialog, + XtNradioGroup, cw, NULL); + XtAddCallback(ccw, XtNcallback, RotateCallback, (XtPointer)CCW); + + XtRealizeWidget(dialog); + } + +#ifdef USE_MODULES + if (!nomodules) { + while (drv_opts) { + if (drv_opts->type == VideoModule && + strcmp(drv_opts->name, screen->scrn_device->dev_driver) == 0) { + OptionInfoPtr opts = drv_opts->option; + + while (opts->name) { + if (xf86nameCompare(opts->name, "Rotate") == 0) { + foundRotate = True; + break; + } + opts++; + } + break; + } + drv_opts = drv_opts->next; + } + + if (!foundRotate) { + XtUnmapWidget(labelRotate); + XtUnmapWidget(cw); + XtUnmapWidget(ccw); + } + else { + XtMapWidget(labelRotate); + XtMapWidget(cw); + XtMapWidget(ccw); + } + } +#else + (void)labelRotate; +#endif + if (rotate == CW) { + XtVaSetValues(cw, XtNstate, True, NULL); + XtVaSetValues(ccw, XtNstate, False, NULL); + } + else if (rotate == CCW) { + XtVaSetValues(cw, XtNstate, False, NULL); + XtVaSetValues(ccw, XtNstate, True, NULL); + } + else { + XtVaSetValues(cw, XtNstate, False, NULL); + XtVaSetValues(ccw, XtNstate, False, NULL); + } + + XtSetArg(args[0], XtNlist, modes); + XtSetArg(args[1], XtNnumberStrings, nmodes); + XtSetValues(listL, args, 2); + + XtSetArg(args[0], XtNlist, defmodes); + XtSetArg(args[1], XtNnumberStrings, ndefmodes); + XtSetValues(listR, args, 2); + + XtSetArg(args[0], XtNstate, True); + XtSetValues(default_depth == 1 ? d1 : + default_depth == 4 ? d4 : + default_depth == 16 ? d16 : + default_depth == 24 ? d24 : d8, args, 1); + + XtChangeManagedSet(¤t, 1, NULL, NULL, &dialog, 1); + current = dialog; +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.h b/xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.h new file mode 100644 index 000000000..07e9bc3ee --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/screen-cfg.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#include "screen.h" + +#ifndef _xf86cfg_screencfg_h +#define _xf86cfg_screencfg_h + +/* + * Prototypes + */ +XtPointer ScreenConfig(XtPointer); +void ScreenDialog(XF86SetupInfo*); + +#endif /* _xf86cfg_screencfg_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/screen.c b/xorg-server/hw/xfree86/utils/xorgcfg/screen.c new file mode 100644 index 000000000..6b411de15 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/screen.c @@ -0,0 +1,983 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include <X11/IntrinsicP.h> +#include <X11/extensions/shape.h> +#include <X11/Xaw/Simple.h> +#include "screen.h" + +#define CW 1 +#define CCW -1 + +/* + * Prototypes + */ +void ReshapeScreenWidget(xf86cfgScreen*); +static int qcmp_screen(_Xconst void*, _Xconst void*); + +/* + * Initialization + */ +extern Widget work; + +static int rows, columns; /* number of rows/columns of monitors */ + +static int mon_width, mon_height; +static int *mon_widths, *mon_heights; + +/* + * Implementation + */ +void +SetScreenRotate(xf86cfgScreen *screen) +{ + static char *Rotate = "Rotate", *_CW = "CW", *_CCW = "CCW"; + int rotate = 0; + XF86OptionPtr option, options; + + /* This is the only place where xf86cfg is intrusive, and deletes options + * added by the user directly in the config file. The "Rotate" option + * will be kept in the screen section. + */ + if (screen->monitor != NULL) { + options = ((XF86ConfMonitorPtr)(screen->monitor->config))->mon_option_lst; + if ((option = xf86findOption(options, Rotate)) != NULL) { + if (option->opt_val != NULL) + rotate = strcasecmp(option->opt_val, _CW) == 0 ? CW : + strcasecmp(option->opt_val, _CCW) == 0 ? CCW : 0; + xf86removeOption(&((XF86ConfMonitorPtr)(screen->monitor->config)) + ->mon_option_lst, Rotate); + } + } + if (screen->card != NULL) { + options = ((XF86ConfDevicePtr)(screen->card->config))->dev_option_lst; + if ((option = xf86findOption(options, Rotate)) != NULL) { + if (option->opt_val != NULL) + rotate += strcasecmp(option->opt_val, _CW) == 0 ? CW : + strcasecmp(option->opt_val, _CCW) == 0 ? CCW : 0; + xf86removeOption(&((XF86ConfDevicePtr)(screen->card->config)) + ->dev_option_lst, Rotate); + } + } + + options = screen->screen->scrn_option_lst; + if ((option = xf86findOption(options, Rotate)) != NULL) { + if (option->opt_val != NULL) + rotate += strcasecmp(option->opt_val, _CW) == 0 ? CW : + strcasecmp(option->opt_val, _CCW) == 0 ? CCW : 0; + xf86removeOption(&screen->screen->scrn_option_lst, Rotate); + } + + rotate = rotate > 0 ? CW : rotate < 0 ? CCW : 0; + if (rotate) + screen->screen->scrn_option_lst = + xf86addNewOption(screen->screen->scrn_option_lst, + XtNewString(Rotate), + XtNewString(rotate > 0 ? _CW : _CCW)); + screen->rotate = rotate; +} + +void +CreateScreenWidget(xf86cfgScreen *screen) +{ + Widget w = XtCreateWidget("screen", simpleWidgetClass, + XtParent(computer.cpu), NULL, 0); + + SetScreenRotate(screen); + XtRealizeWidget(w); + screen->widget = w; + screen->column = screen->row = -1; + + ReshapeScreenWidget(screen); +} + +void +ReshapeScreenWidget(xf86cfgScreen *screen) +{ + Pixmap pixmap; + XGCValues values; + GC gc; + int x = 0, y = 0, width = screen->rect.width, height = screen->rect.height; + Widget w = screen->widget; + + if (screen->state == USED && screen->row >= 0) { + if (screen->column == 0) + x = w->core.width - width; + else if (screen->column == columns - 1) + x = w->core.width - mon_widths[screen->column]; + else + x = (w->core.width - mon_widths[screen->column]) + + ((mon_widths[screen->column] - width) >> 1); + + if (screen->row == 0) + y = w->core.height - height; + else if (screen->row == rows - 1) + y = w->core.height - mon_heights[screen->row]; + else + y = (w->core.height - mon_heights[screen->row]) + + ((mon_heights[screen->row] - height) >> 1); + } + else if (screen->rect.width == 0) { + width = w->core.width; + height = w->core.height; + } + + screen->rect.x = x; + screen->rect.y = y; + screen->rect.width = width; + screen->rect.height = height; + pixmap = XCreatePixmap(XtDisplay(w), XtWindow(w), + w->core.width, w->core.height, 1); + values.foreground = 0; + values.background = 1; + gc = XCreateGC(XtDisplay(w), pixmap, GCForeground | GCBackground, &values); + XFillRectangle(XtDisplay(w), pixmap, gc, 0, 0, w->core.width, w->core.height); + XSetForeground(XtDisplay(w), gc, 1); + + DrawScreenMask(XtDisplay(w), pixmap, gc, x, y, x + width, y + height, + screen->rotate); + XShapeCombineMask(XtDisplay(w), XtWindow(w), ShapeBounding, + 0, 0, pixmap, ShapeSet); + + /* Do not call XtSetValues, to avoid all extra code for caching pixmaps */ + XFreePixmap(XtDisplay(w), pixmap); + if (XtIsRealized(w)) { + pixmap = XCreatePixmap(XtDisplay(w), XtWindow(w), + w->core.width, w->core.height, + DefaultDepthOfScreen(XtScreen(w))); + DrawScreen(XtDisplay(w), pixmap, x, y, x + width, y + height, + screen->state == USED ? True : False, screen->rotate); + XSetWindowBackgroundPixmap(XtDisplay(w), XtWindow(w), pixmap); + XClearWindow(XtDisplay(w), XtWindow(w)); + XFreePixmap(XtDisplay(w), pixmap); + } + XFreeGC(XtDisplay(w), gc); +} + +void +AddScreen(xf86cfgDevice *mon, xf86cfgDevice *dev) +{ + int nscreens = 0; + char screen_name[48]; + XF86ConfScreenPtr screen = XF86Config->conf_screen_lst; + XF86ConfAdjacencyPtr adj; + + while (screen != NULL) { + ++nscreens; + screen = (XF86ConfScreenPtr)(screen->list.next); + } + do { + XmuSnprintf(screen_name, sizeof(screen_name), "Screen%d", + nscreens); + ++nscreens; + } while (xf86findScreen(screen_name, + XF86Config->conf_screen_lst) != NULL); + + screen = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec)); + screen->scrn_identifier = XtNewString(screen_name); + screen->scrn_device_str = XtNewString(((XF86ConfDevicePtr)(dev->config))->dev_identifier); + screen->scrn_device = (XF86ConfDevicePtr)(dev->config); + screen->scrn_monitor_str = XtNewString(((XF86ConfMonitorPtr)(mon->config))->mon_identifier); + screen->scrn_monitor = (XF86ConfMonitorPtr)(mon->config); + XF86Config->conf_screen_lst = + xf86addScreen(XF86Config->conf_screen_lst, screen); + + adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = screen; + adj->adj_screen_str = XtNewString(screen_name); + if (computer.layout == NULL) + computer.layout = XF86Config->conf_layout_lst = (XF86ConfLayoutPtr) + XtCalloc(1, sizeof(XF86ConfLayoutRec)); + computer.layout->lay_adjacency_lst = (XF86ConfAdjacencyPtr) + xf86addListItem((GenericListPtr)computer.layout->lay_adjacency_lst, + (GenericListPtr)adj); + + computer.screens = (xf86cfgScreen**) + XtRealloc((XtPointer)computer.screens, sizeof(xf86cfgScreen*) * + (computer.num_screens + 1)); + computer.screens[computer.num_screens] = + (xf86cfgScreen*)XtCalloc(1, sizeof(xf86cfgScreen)); + computer.screens[computer.num_screens]->screen = screen; + computer.screens[computer.num_screens]->card = dev; + computer.screens[computer.num_screens]->monitor = mon; + + ++dev->refcount; + ++mon->refcount; + + CreateScreenWidget(computer.screens[computer.num_screens]); + computer.screens[computer.num_screens]->type = SCREEN; + SetTip((xf86cfgDevice*)computer.screens[computer.num_screens]); + + ++computer.num_screens; +} + +void +RemoveScreen(xf86cfgDevice *mon, xf86cfgDevice *dev) +{ + XF86ConfScreenPtr screen = XF86Config->conf_screen_lst; + int i; + + mon->state = dev->state = UNUSED; + while (screen != NULL) { + if ((XtPointer)screen->scrn_monitor == mon->config && + (XtPointer)screen->scrn_device == dev->config) + break; + + screen = (XF86ConfScreenPtr)(screen->list.next); + } + --mon->refcount; + --dev->refcount; + + for (i = 0; i < computer.num_screens; i++) { + if (computer.screens[i]->screen == screen) { + XtDestroyWidget(computer.screens[i]->widget); + if (i < --computer.num_screens) + memmove(&computer.screens[i], &computer.screens[i + 1], + (computer.num_screens - i) * sizeof(xf86cfgScreen*)); + break; + } + } + + xf86removeScreen(XF86Config, screen); +} + +void +ChangeScreen(XF86ConfMonitorPtr mon, XF86ConfMonitorPtr oldmon, + XF86ConfDevicePtr dev, XF86ConfDevicePtr olddev) +{ + int ioldm, im, ioldc, ic; + + if (mon == oldmon && dev == olddev) + return; + + if (mon != NULL) { + for (im = 0; im < computer.num_devices; im++) + if (computer.devices[im]->config == (XtPointer)mon) + break; + } + else + im = -1; + if (oldmon != NULL) { + for (ioldm = 0; ioldm < computer.num_devices; ioldm++) + if (computer.devices[ioldm]->config == (XtPointer)oldmon) + break; + } + else + ioldm = -1; + + if (dev != NULL) { + for (ic = 0; ic < computer.num_devices; ic++) + if (computer.devices[ic]->config == (XtPointer)dev) + break; + } + else + ic = -1; + if (olddev != NULL) { + for (ioldc = 0; ioldc < computer.num_devices; ioldc++) + if (computer.devices[ioldc]->config == (XtPointer)olddev) + break; + } + else + ioldc = -1; + + if (ioldm >= 0 && ioldc >= 0) { + RemoveScreen(computer.devices[ioldm], computer.devices[ioldc]); + computer.devices[ioldm]->state = UNUSED; +/* computer.devices[ioldc]->state = UNUSED;*/ + } + + if (im >= 0 && ic >= 0) { + AddScreen(computer.devices[im], computer.devices[ic]); + computer.devices[im]->state = USED; +/* computer.devices[ic]->state = USED;*/ + } +} + +/* + ++------------------------------------------------+ +| | +| +------------------------------------------+ | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| +------------------------------------------+ | +| | ++------------------------------------------------+ + | | + +-------+ +-------+ + | | + +----------------------------------------+ + + */ +static double oxs = 0.0, oys = 0.0, oxe = 100.0, oye = 70.0; +static double ixs = 7.0, iys = 7.0, ixe = 93.0, iye = 63.0; +static double lin[] = { 25.0, 70.0, 25.0, 75.0, 5.0, 75.0, 5.0, 80.0, + 95.0, 80.0, 95.0, 75.0, 75.0, 75.0, 75.0, 70.0 }; + +void +DrawScreen(Display *dpy, Drawable win, int xs, int ys, int xe, int ye, + Bool active, int rotate) +{ + double xfact, yfact; + XPoint points[(sizeof(lin) / sizeof(lin[0])) >> 1]; + int i; + static GC gray0, gray1, gray2, black, red; + + if (black == NULL) { + XColor color, exact; + XGCValues values; + + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray95", + &color, &exact); + values.foreground = color.pixel; + gray0 = XCreateGC(XtDisplay(toplevel), win, GCForeground, &values); + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray75", + &color, &exact); + values.foreground = color.pixel; + gray1 = XCreateGC(XtDisplay(toplevel), win, GCForeground, &values); + + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray60", + &color, &exact); + values.foreground = color.pixel; + gray2 = XCreateGC(XtDisplay(toplevel), win, GCForeground, &values); + + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "gray20", + &color, &exact); + values.foreground = color.pixel; + black = XCreateGC(XtDisplay(toplevel), win, GCForeground, &values); + + XAllocNamedColor(XtDisplay(toplevel), toplevel->core.colormap, "red", + &color, &exact); + values.foreground = color.pixel; + values.line_width = 4; + values.cap_style = CapButt; + red = XCreateGC(XtDisplay(toplevel), win, + GCForeground | GCLineWidth | GCCapStyle, &values); + } + + if (rotate) { + xfact = (xe - xs) / 80.0; + yfact = (ye - ys) / 100.0; + if (rotate == CW) { + /* outer rectangle */ + XFillRectangle(dpy, win, gray1, + oxs * xfact + xs + .5, + oys * yfact + ys + .5, + (oye - oys) * xfact + .5, + (oxe - oxs) * yfact + .5); + XDrawLine(dpy, win, gray2, + xs, ye - 1, + 70 * xfact + xs - 1 + .5, ye - 1); + XDrawLine(dpy, win, gray2, + 70 * xfact + xs - 1 + .5, ye - 1, + 70 * xfact + xs - 1 + .5, ys); + /* inner rectangle */ + XFillRectangle(dpy, win, black, + ixs * xfact + xs + .5, + iys * yfact + ys + .5, + (iye - iys) * xfact + .5, + (ixe - ixs) * yfact + .5); + for (i = 0; i < sizeof(points) / sizeof(points[0]); i++) { + points[i].x = lin[(i<<1) + 1] * xfact + xs + .5; + points[i].y = lin[(i<<1)] * yfact + ys + .5; + } + XFillPolygon(dpy, win, gray2, points, i, Convex, CoordModeOrigin); + XDrawLine(dpy, win, gray0, + (oxe - 10) * xfact + xs + .5, oys * yfact + ys + .5, + xs, oys * yfact + ys + .5); + XDrawLine(dpy, win, gray0, + xs, ys, + xs, xe); + XDrawLine(dpy, win, black, + lin[7] * xfact + xs - 1 + .5, lin[6] * yfact + ys + .5, + lin[9] * xfact + xs - 1 + .5, lin[8] * yfact + ys - 1 + .5); + XDrawLine(dpy, win, black, + lin[9] * xfact + xs - 1 + .5, lin[8] * yfact + ys - 1 + .5, + lin[11] * xfact + xs + .5, lin[10] * yfact + ys - 1 + .5); + XDrawLine(dpy, win, black, + lin[13] * xfact + xs + .5, lin[12] * yfact + ys - 1 + .5, + lin[15] * xfact + xs + .5, lin[14] * yfact + ys - 1 + .5); + + if (!active) { + XDrawLine(dpy, win, red, + iys * xfact, ixs * yfact, iye * xfact, ixe * yfact); + XDrawLine(dpy, win, red, + iye * xfact, ixs * yfact, iys * xfact, ixe * yfact); + } + } + else if (rotate == CCW) { + /* outer rectangle */ + XFillRectangle(dpy, win, gray1, + 10 * xfact + xs + .5, + oys * yfact + ys + .5, + (oye - oys) * xfact + .5, + (oxe - oxs) * yfact + .5); + + XDrawLine(dpy, win, gray2, + 10 * xfact + xs + .5, ye - 1, + oxe * xfact + xs - 1 + .5, ye - 1); + XDrawLine(dpy, win, gray2, + xe - 1, ye - 1, + xe - 1, ys); + /* inner rectangle */ + XFillRectangle(dpy, win, black, + (ixs + 10) * xfact + xs + .5, + iys * yfact + ys + .5, + (iye - iys) * xfact + .5, + (ixe - ixs) * yfact + .5); + for (i = 0; i < sizeof(points) / sizeof(points[0]); i++) { + points[i].x = (-lin[(i<<1) + 1] + 80.0) * xfact + xs + .5; + points[i].y = lin[(i<<1)] * yfact + ys + .5; + } + XFillPolygon(dpy, win, gray2, points, i, Convex, CoordModeOrigin); + XDrawLine(dpy, win, gray0, + oxe * xfact + xs + .5, oys * yfact + ys + .5, + (oxs - 10) * xfact + xs + .5, oys * yfact + ys + .5); + XDrawLine(dpy, win, gray0, + (oxs + 10) * xfact + xs + .5, ys, + (oxs + 10) * xfact + xs + .5, xe); + + XDrawLine(dpy, win, black, + xs, lin[8] * yfact - 1 + ys + .5, + 4 * xfact + xs + .5, lin[8] * yfact - 1 + ys + .5); + XDrawLine(dpy, win, black, + 4 * xfact + xs, lin[8] * yfact - 1 + ys + .5, + 4 * xfact + xs, lin[3] * yfact - 1 + ys + .5); + XDrawLine(dpy, win, black, + 4 * xfact + xs + .5, lin[3] * yfact - 1 + ys + .5, + 10 * xfact + xs + .5 - 1, lin[3] * yfact - 1 + ys + .5); + XDrawLine(dpy, win, black, + 4 * xfact + xs, lin[0] * yfact - 1 + ys + .5, + 4 * xfact + xs, lin[4] * yfact - 1 + ys + .5); + + if (!active) { + XDrawLine(dpy, win, red, + (iys + 10) * xfact, ixs * yfact, + (iye + 10) * xfact, ixe * yfact); + XDrawLine(dpy, win, red, + (iye + 10) * xfact, ixs * yfact, + (iys + 10) * xfact, ixe * yfact); + } + } + } + else { + xfact = (xe - xs) / 100.0; + yfact = (ye - ys) / 80.0; + + /* outer rectangle */ + XFillRectangle(dpy, win, gray1, + oxs * xfact + xs + .5, + oys * yfact + ys + .5, + (oxe - oxs) * xfact + .5, + (oye - oys) * yfact + .5); + + XDrawLine(dpy, win, gray2, + oxs * xfact + xs + .5, oye * yfact + ys - 1 + .5, + oxe * xfact + xs - 1 + .5, oye * yfact + ys - 1 + .5); + XDrawLine(dpy, win, gray2, + oxe * xfact + xs - 1 + .5, oys * yfact + ys + .5, + oxe * xfact + xs - 1 + .5, oye * yfact + ys - 1 + .5); + + /* inner rectangle */ + XFillRectangle(dpy, win, black, + ixs * xfact + xs + .5, + iys * yfact + ys + .5, + (ixe - ixs) * xfact + .5, + (iye - iys) * yfact + .5); + + for (i = 0; i < sizeof(points) / sizeof(points[0]); i++) { + points[i].x = lin[i<<1] * xfact + xs + .5; + points[i].y = lin[(i<<1) + 1] * yfact + ys + .5; + } + + XFillPolygon(dpy, win, gray2, points, i, Convex, CoordModeOrigin); + + XDrawLine(dpy, win, black, + lin[6] * xfact + xs + .5, lin[7] * yfact + ys - 1 + .5, + lin[8] * xfact + xs - 1 + .5, lin[9] * yfact + ys - 1 + .5); + XDrawLine(dpy, win, black, + lin[8] * xfact + xs - 1 + .5, lin[9] * yfact + ys - 1 + .5, + lin[10] * xfact + xs - 1 + .5, lin[11] * yfact + ys + .5); + XDrawLine(dpy, win, black, + lin[12] * xfact + xs - 1 + .5, lin[13] * yfact + ys + .5, + lin[14] * xfact + xs - 1 + .5, lin[15] * yfact + ys + .5); + + XDrawLine(dpy, win, gray0, + oxe * xfact + xs + .5, oys * yfact + ys + .5, + oxs * xfact + xs + .5, oys * yfact + ys + .5); + XDrawLine(dpy, win, gray0, + oxs * xfact + xs + .5, oys * yfact + ys + .5, + oxs * xfact + xs + .5, lin[1] * yfact + ys + .5); + + if (!active) { + XDrawLine(dpy, win, red, + ixs * xfact, iys * yfact, ixe * xfact, iye * yfact); + XDrawLine(dpy, win, red, + ixe * xfact, iys * yfact, ixs * xfact, iye * yfact); + } + } +} + +void +DrawScreenMask(Display *dpy, Drawable win, GC gc, int xs, int ys, int xe, int ye, + int rotate) +{ + double xfact, yfact; + XPoint points[(sizeof(lin) / sizeof(lin[0])) >> 1]; + int i = 0, x = 0, y = 0, width, height; + + if (rotate) { + xfact = (xe - xs) / 80.0; + yfact = (ye - ys) / 100.0; + width = (oye - oys) * xfact + .5; + height = (oxe - oxs) * yfact + .5; + if (rotate == CW) { + x = oxs * xfact + xs + .5; + y = oys * yfact + ys + .5; + for (i = 0; i < sizeof(points) / sizeof(points[0]); i++) { + points[i].x = lin[(i<<1) + 1] * xfact + xs + .5; + points[i].y = lin[(i<<1)] * yfact + ys + .5; + } + } + else if (rotate == CCW) { + x = 10 * xfact + xs + .5; + y = oys * yfact + ys + .5; + for (i = 0; i < sizeof(points) / sizeof(points[0]); i++) { + points[i].x = (-lin[(i<<1) + 1] + 80.0) * xfact + xs + .5; + points[i].y = lin[(i<<1)] * yfact + ys + .5; + } + } + } + else { + xfact = (xe - xs) / 100.0; + yfact = (ye - ys) / 80.0; + x = oxs * xfact + xs + .5; + y = oys * yfact + ys + .5; + width = (oxe - oxs) * xfact + .5; + height = (oye - oys) * yfact + .5; + for (i = 0; i < sizeof(points) / sizeof(points[0]); i++) { + points[i].x = lin[(i<<1)] * xfact + xs + .5; + points[i].y = lin[(i<<1) + 1] * yfact + ys + .5; + } + } + + /* rectangle */ + XFillRectangle(dpy, win, gc, x, y, width, height); + + + XFillPolygon(dpy, win, gc, points, i, Convex, CoordModeOrigin); +} + +void +AdjustScreenUI(void) +{ + XF86ConfLayoutPtr lay = computer.layout; + XF86ConfAdjacencyPtr adj; + int i, dx, dy, x, y, w, h, base = -1; + double xf, yf; + + if (lay == NULL) + return; + + adj = lay->lay_adjacency_lst; + +#define USED1 -USED + + XtFree((XtPointer)mon_widths); + XtFree((XtPointer)mon_heights); + mon_widths = (int*)XtCalloc(1, sizeof(int) * columns); + mon_heights = (int*)XtCalloc(1, sizeof(int) * rows); + + mon_width = mon_height = 0; + for (i = 0; i < computer.num_screens; i++) { + if (base == -1 && computer.screens[i]->state == USED) + base = i; + if (computer.screens[i]->screen->scrn_monitor->mon_width > mon_width) + mon_width = computer.screens[i]->screen->scrn_monitor->mon_width; + if (computer.screens[i]->screen->scrn_monitor->mon_height > mon_height) + mon_height = computer.screens[i]->screen->scrn_monitor->mon_height; + } + if (base < 0) { + for (i = 0; i < computer.num_screens; i++) + ReshapeScreenWidget(computer.screens[i]); + return; + } + + if (mon_width == 0) { + mon_width = 10; + mon_height = 8; + } + + XtUnmapWidget(work); + + while (adj) { + xf86cfgScreen *scr = NULL, + *topscr = NULL, *botscr = NULL, *lefscr = NULL, *rigscr = NULL; + + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == adj->adj_screen) + break; + if (i < computer.num_screens) + scr = computer.screens[i]; + + if (adj->adj_top != NULL) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == adj->adj_top) + break; + if (i < computer.num_screens) + topscr = computer.screens[i]; + } + + if (adj->adj_bottom != NULL) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == adj->adj_bottom) + break; + if (i < computer.num_screens) + botscr = computer.screens[i]; + } + + if (adj->adj_left != NULL) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == adj->adj_left) + break; + if (i < computer.num_screens) + lefscr = computer.screens[i]; + } + + if (adj->adj_right != NULL) { + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == adj->adj_right) + break; + if (i < computer.num_screens) + rigscr = computer.screens[i]; + } + + if (lefscr == NULL && rigscr == NULL && topscr == NULL && lefscr == NULL) { + XF86ConfScreenPtr s; + + if (adj->adj_where >= CONF_ADJ_RIGHTOF && adj->adj_where <= CONF_ADJ_BELOW) { + s = xf86findScreen(adj->adj_refscreen, XF86Config->conf_screen_lst); + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == s) + break; + if (i < computer.num_screens) { + switch (adj->adj_where) { + case CONF_ADJ_RIGHTOF: + lefscr = computer.screens[i]; + break; + case CONF_ADJ_LEFTOF: + rigscr = computer.screens[i]; + break; + case CONF_ADJ_ABOVE: + botscr = computer.screens[i]; + break; + case CONF_ADJ_BELOW: + topscr = computer.screens[i]; + break; + } + } + } + } + + XtMoveWidget(scr->widget, 0, 0); + scr->state = USED1; + if (lefscr != NULL) { + if (lefscr->state == USED1) + XtMoveWidget(scr->widget, + lefscr->widget->core.x + lefscr->widget->core.width, + lefscr->widget->core.y); + else + XtMoveWidget(lefscr->widget, + -(int)(lefscr->widget->core.width), + scr->widget->core.y); + } + + if (rigscr != NULL) { + if (rigscr->state == USED1) { + dx = rigscr->widget->core.x - scr->widget->core.width - scr->widget->core.x; + dy = rigscr->widget->core.y - scr->widget->core.y; + + XtMoveWidget(scr->widget, scr->widget->core.x + dx, + scr->widget->core.y + dy); + if (lefscr != NULL && lefscr->state != USED1) + XtMoveWidget(lefscr->widget, lefscr->widget->core.x + dx, + lefscr->widget->core.y + dy); + } + else + XtMoveWidget(rigscr->widget, scr->widget->core.width, + scr->widget->core.y); + } + + if (topscr != NULL) { + if (topscr->state == USED1) { + dx = topscr->widget->core.x - scr->widget->core.x; + dy = topscr->widget->core.y + topscr->widget->core.height - + scr->widget->core.y; + + XtMoveWidget(scr->widget, scr->widget->core.x + dx, + scr->widget->core.y + dy); + if (lefscr != NULL && lefscr->state != USED1) + XtMoveWidget(lefscr->widget, lefscr->widget->core.x + dx, + lefscr->widget->core.y + dy); + if (rigscr != NULL && rigscr->state != USED1) + XtMoveWidget(rigscr->widget, rigscr->widget->core.x + dx, + rigscr->widget->core.y + dy); + } + else + XtMoveWidget(topscr->widget, scr->widget->core.x, + scr->widget->core.y - topscr->widget->core.height); + } + + if (botscr != NULL) { + if (botscr->state == USED1) { + dx = botscr->widget->core.x - scr->widget->core.x; + dy = botscr->widget->core.y - scr->widget->core.height - scr->widget->core.y; + + XtMoveWidget(scr->widget, scr->widget->core.x + dx, + scr->widget->core.y + dy); + if (lefscr != NULL && lefscr->state != USED1) + XtMoveWidget(lefscr->widget, lefscr->widget->core.x + dx, + lefscr->widget->core.y + dy); + if (rigscr != NULL && rigscr->state != USED1) + XtMoveWidget(rigscr->widget, rigscr->widget->core.x + dx, + rigscr->widget->core.y + dy); + if (botscr != NULL && botscr->state != USED1) + XtMoveWidget(botscr->widget, botscr->widget->core.x + dx, + botscr->widget->core.y + dy); + } + else + XtMoveWidget(botscr->widget, scr->widget->core.x, + scr->widget->core.y + scr->widget->core.height); + } + + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->state == USED1) + computer.screens[i]->state = USED; + else + XLowerWindow(XtDisplay(computer.screens[i]->widget), + XtWindow(computer.screens[i]->widget)); + + w = work->core.width / (columns + 1) - 5; + h = work->core.height / (rows + 1) - 5; + + if (w > h) + w = h; + else + h = w; + + dx = (work->core.width - (columns * w)) >> 1; + dy = (work->core.height - (rows * h)) >> 1; + + xf = (double)w / (double)computer.screens[0]->widget->core.width; + yf = (double)h / (double)computer.screens[0]->widget->core.height; + + for (i = 0; i < computer.num_screens; i++) { + Widget z = computer.screens[i]->widget; + + if (computer.screens[i]->state == USED) + XtConfigureWidget(z, z->core.x * xf + dx, + z->core.y * yf + dy, w, h, 0); + else + XtConfigureWidget(z, z->core.x, z->core.y, w, h, 0); + } + + if (computer.screens[base]->row >= 0) { + double xf, yf; + int width, height; + + for (i = 0; i < computer.num_screens; i++) { + width = computer.screens[i]->screen->scrn_monitor->mon_width; + height = computer.screens[i]->screen->scrn_monitor->mon_height; + if (width <= 0) { + width = mon_width; + height = mon_height; + } + + if (computer.screens[i]->rotate) { + xf = (double)width / (double)mon_width * 8. / 10.; + yf = (double)height / (double)mon_height; + } + else { + xf = (double)width / (double)mon_width; + yf = (double)height / (double)mon_height * 8. / 10.; + } + width = computer.screens[i]->widget->core.width * xf; + height = computer.screens[i]->widget->core.height * yf; + if (computer.screens[i]->state == USED) { + if (mon_widths[computer.screens[i]->column] < width) + mon_widths[computer.screens[i]->column] = width; + if (mon_heights[computer.screens[i]->row] < height) + mon_heights[computer.screens[i]->row] = height; + } + + /* do it here to avoid recalculation */ + computer.screens[i]->rect.width = width; + computer.screens[i]->rect.height = height; + } + } + + for (i = 0; i < computer.num_screens; i++) + ReshapeScreenWidget(computer.screens[i]); + + /* do a new pass, to avoid gaps if the monitors have different + * sizes. + */ + if (computer.screens[base]->row >= 0) { + x = computer.screens[base]->widget->core.x; + y = computer.screens[base]->widget->core.y; + + /* screens representations are already ordered */ + for (i = base; i < computer.num_screens; i++) { + if (computer.screens[i]->state == UNUSED) + continue; + if (computer.screens[i]->column != 0) + x += mon_widths[computer.screens[i]->column]; + else { + x = computer.screens[base]->widget->core.x; + if (i != base) + y += mon_heights[computer.screens[i]->row]; + } + XtMoveWidget(computer.screens[i]->widget, x, y); + } + } + XtMapWidget(work); +} + +static int +qcmp_screen(_Xconst void *a, _Xconst void *b) +{ + xf86cfgScreen *s1, *s2; + + s1 = *(xf86cfgScreen**)a; + s2 = *(xf86cfgScreen**)b; + + if (s1->widget->core.x > s2->widget->core.x) { + if (s2->widget->core.y >= + s1->widget->core.y + (s1->widget->core.height >> 1)) + return (-1); + return (1); + } + else { + if (s1->widget->core.y >= + s2->widget->core.y + (s2->widget->core.height >> 1)) + return (1); + return (-1); + } + /*NOTREACHED*/ +} + +void +UpdateScreenUI(void) +{ + XF86ConfLayoutPtr lay = computer.layout; + XF86ConfAdjacencyPtr adj, prev, left, base; + int i, p, cols, scrno; + + if (lay == NULL) + return; + + rows = columns = cols = 1; + + qsort(computer.screens, computer.num_screens, sizeof(xf86cfgScreen*), + qcmp_screen); + + adj = prev = left = base = NULL; + for (i = p = scrno = 0; i < computer.num_screens; i++) { + XF86ConfScreenPtr scr = computer.screens[i]->screen; + + if (computer.screens[i]->state == UNUSED) + continue; + + adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_scrnum = scrno++; + adj->adj_screen = scr; + adj->adj_screen_str = XtNewString(scr->scrn_identifier); + if (base == NULL) { + base = left = adj; + computer.screens[i]->row = computer.screens[i]->column = 0; + } + else { + int dy = computer.screens[i]->widget->core.y - + computer.screens[p]->widget->core.y; + + prev->list.next = adj; + if (dy > (computer.screens[i]->widget->core.height >> 1)) { + adj->adj_where = CONF_ADJ_BELOW; + adj->adj_refscreen = XtNewString(left->adj_screen_str); + left = adj; + computer.screens[i]->row = rows; + computer.screens[i]->column = 0; + cols = 1; + ++rows; + } + else { + computer.screens[i]->row = rows - 1; + computer.screens[i]->column = cols; + adj->adj_where = CONF_ADJ_RIGHTOF; + if (++cols > columns) + columns = cols; + adj->adj_refscreen = XtNewString(prev->adj_screen_str); + } + } + prev = adj; + p = i; + } + + adj = lay->lay_adjacency_lst; + + while (adj != NULL) { + prev = adj; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + XtFree(prev->adj_screen_str); + XtFree(prev->adj_right_str); + XtFree(prev->adj_left_str); + XtFree(prev->adj_top_str); + XtFree(prev->adj_bottom_str); + XtFree(prev->adj_refscreen); + XtFree((char*)prev); + } + + lay->lay_adjacency_lst = base; +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/screen.h b/xorg-server/hw/xfree86/utils/xorgcfg/screen.h new file mode 100644 index 000000000..293820db4 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/screen.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "xf86config.h" +#include "config.h" + +#ifndef _xf86cfg_screen_h +#define _xf86cfg_screen_h + +/* + * Prototypes + */ +void AddScreen(xf86cfgDevice*, xf86cfgDevice*); +void RemoveScreen(xf86cfgDevice*, xf86cfgDevice*); + +void DrawScreen(Display*, Drawable, int, int, int, int, Bool, int); +void DrawScreenMask(Display*, Drawable, GC, int, int, int, int, int); +void CreateScreenWidget(xf86cfgScreen*); +void SetScreenRotate(xf86cfgScreen*); + +void AdjustScreenUI(void); +void UpdateScreenUI(void); + +#endif /* _xf86cfg_screen_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/shorter.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/shorter.xbm new file mode 100644 index 000000000..878f219d4 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/shorter.xbm @@ -0,0 +1,8 @@ +#define shorter_width 19 +#define shorter_height 19 +static unsigned char shorter_bits[] = { + 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0xfc, 0xff, 0x01, + 0xf8, 0xff, 0x00, 0xf0, 0x7f, 0x00, 0xe0, 0x3f, 0x00, 0xc0, 0x1f, 0x00, + 0x80, 0x0f, 0x00, 0x00, 0x07, 0x00, 0x80, 0x0f, 0x00, 0xc0, 0x1f, 0x00, + 0xe0, 0x3f, 0x00, 0xf0, 0x7f, 0x00, 0xf8, 0xff, 0x00, 0xfc, 0xff, 0x01, + 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/startx.c b/xorg-server/hw/xfree86/utils/xorgcfg/startx.c new file mode 100644 index 000000000..507afbf15 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/startx.c @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> + +/* + * Initialization + */ +static int xpid; +Display *DPY; + +/* + * Implementation + */ +Bool +startx(void) +{ + int timeout = 8; + + if (getenv("DISPLAY") != NULL) + /* already running Xserver */ + return (False); + + if (XF86Config_path == NULL) { + char *home, filename[PATH_MAX]; + char commandline[PATH_MAX * 4]; + int c_pos; + int len; + /* + * The name of the 4.0 binary is XFree86. X might also + * be the name of the 3.3 binary. Therefore don't change + * name to 'X'. + */ + if (XFree86_path) + c_pos = XmuSnprintf(commandline, sizeof(commandline), + "%s/"__XSERVERNAME__" :8 -configure ",XFree86_path); + else + c_pos = XmuSnprintf(commandline, sizeof(commandline), + "%s/bin/"__XSERVERNAME__" :8 -configure ", XFree86Dir); + if (XF86Module_path && ((len = sizeof(commandline) - c_pos) > 0)) + c_pos += XmuSnprintf(commandline + c_pos,len, + " -modulepath %s",XF86Module_path); + if (XF86Font_path && ((len = sizeof(commandline) - c_pos) > 0)) + c_pos += XmuSnprintf(commandline + c_pos,len, + " -fontpath %s",XF86Font_path); + + if (system(commandline) != 0) { + fprintf(stderr, "Failed to run \"X -configure\".\n"); + exit(1); + } + + if ((home = getenv("HOME")) == NULL) + home = "/"; + +#ifndef QNX4 + XmuSnprintf(filename, sizeof(filename), "%s/"__XCONFIGFILE__".new", home); +#else + XmuSnprintf(filename, sizeof(filename), "//%d%s/"__XCONFIGFILE__".new", + getnid(), home); +#endif + + /* this memory is never released, even if the value of XF86Config_path is + * changed. + */ + XF86Config_path = XtNewString(filename); + } + + putenv("DISPLAY=:8"); + + switch (xpid = fork()) { + case 0: { + char path[PATH_MAX]; + /* Don't change to X! see above */ + if (XFree86_path) + XmuSnprintf(path, sizeof(path), "%s/"__XSERVERNAME__, XFree86_path); + else + XmuSnprintf(path, sizeof(path), "%s/bin/"__XSERVERNAME__, XFree86Dir); + execl(path, "X", ":8", /*"+xinerama",*/ "+accessx","-allowMouseOpenFail", + "-xf86config", XF86Config_path, (void *)NULL); + exit(-127); + } break; + case -1: + fprintf(stderr, "Cannot fork.\n"); + exit(1); + break; + default: + break; + } + + while (timeout > 0) { + int status; + + sleep(timeout -= 2); + if (waitpid(xpid, &status, WNOHANG | WUNTRACED) == xpid) + break; + else { + DPY = XOpenDisplay(NULL); + if (DPY != NULL) + break; + } + } + + if (DPY == NULL) { + fprintf(stderr, "Cannot connect to X server.\n"); + exit(1); + } + + return (True); +} + +void +endx(void) +{ + if (xpid != 0) + kill(xpid, SIGTERM); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/stubs.c b/xorg-server/hw/xfree86/utils/xorgcfg/stubs.c new file mode 100644 index 000000000..fdc840a7e --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/stubs.c @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include <stdio.h> +#include <string.h> +#include "stubs.h" + +/* + * Implementation + */ + +#if !defined(USE_MODULES) +/* these are defined in libdummy.a */ +int +ErrorF(const char *fmt, ...) +{ + int retval; + va_list ap; + + va_start(ap, fmt); + retval = vfprintf(stderr, fmt, ap); + + va_end(ap); + + return (retval); +} + +int +VErrorF(const char *fmt, va_list ap) +{ + int retval; + + retval = vfprintf(stderr, fmt, ap); + + return (retval); +} + +#endif /* !defined(USE_MODULES) */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/stubs.h b/xorg-server/hw/xfree86/utils/xorgcfg/stubs.h new file mode 100644 index 000000000..c2f9f76b0 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/stubs.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#ifndef _xf86cfg_stubs_h +#define _xf86cfg_stubs_h + +#include <stdarg.h> + +int ErrorF(const char*, ...); +int VErrorF(const char*, va_list); +#if defined(USE_MODULES) +extern int xf86Verbose; +#endif + +#endif /* _xf86cfg_stubs_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/taller.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/taller.xbm new file mode 100644 index 000000000..c779300ea --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/taller.xbm @@ -0,0 +1,8 @@ +#define taller_width 19 +#define taller_height 19 +static unsigned char taller_bits[] = { + 0x00, 0x02, 0x00, 0x00, 0x07, 0x00, 0x80, 0x0f, 0x00, 0xc0, 0x1f, 0x00, + 0xe0, 0x3f, 0x00, 0xf0, 0x7f, 0x00, 0xf8, 0xff, 0x00, 0xfc, 0xff, 0x01, + 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0xfc, 0xff, 0x01, + 0xf8, 0xff, 0x00, 0xf0, 0x7f, 0x00, 0xe0, 0x3f, 0x00, 0xc0, 0x1f, 0x00, + 0x80, 0x0f, 0x00, 0x00, 0x07, 0x00, 0x00, 0x02, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/text-mode.c b/xorg-server/hw/xfree86/utils/xorgcfg/text-mode.c new file mode 100644 index 000000000..0b6e65482 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/text-mode.c @@ -0,0 +1,3379 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#if defined(__SCO__) || defined(__UNIXWARE__) || \ + (defined(sun) && defined(__SVR4)) || defined(__NetBSD__) +#include <curses.h> +#else +#include <ncurses.h> +#endif +#include <ctype.h> +#include <X11/Xlib.h> +#include <X11/extensions/XKBstr.h> +#include <X11/extensions/XKBrules.h> +#include "cards.h" +#include "config.h" +#include "xf86config.h" +#include "loader.h" + +#define IS_KBDDRIV(X) ((strcmp((X),"kbd") == 0)) + +#ifndef PROJECT_ROOT +#define PROJECT_ROOT "/usr" +#endif + +#ifndef XKB_RULES_DIR +#define XKB_RULES_DIR PROJECT_ROOT "/share/X11/xkb/rules" +#endif + +#define CONTROL_A 1 +#define CONTROL_D 4 +#define CONTROL_E 5 +#define CONTROL_K 11 +#define TAB 9 +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +void TextMode(void); + +static void ClearScreen(void); +static void PaintWindow(WINDOW*, char*, int, int, int, int); +static void PaintBox(WINDOW*, int, int, int, int); +static void PaintButton(WINDOW*, char*, int, int, int); +static void PrintWrap(WINDOW*, char*, int, int, int); +static int Dialog(char*, char*, int, int, char*, char*, int); +static void PaintItem(WINDOW*, char*, int, int); +static int DialogMenu(char*, char*, int, int, int, int, char**, char*, char*, int); +static void PaintCheckItem(WINDOW*, char*, int, int, int); +static int DialogCheckBox(char*, char*, int, int, int, int, char**, char*, char*, char*); +static char *DialogInput(char*, char*, int, int, char*, char*, char*, int); +static void PaintScroller(WINDOW*, int, int, int); + +static int MouseConfig(void); +static int KeyboardConfig(void); +static int MonitorConfig(void); +static int CardConfig(void); +static int ScreenConfig(void); +static int LayoutConfig(void); +static int WriteXF86Config(void); + +static XF86ConfLayoutPtr CopyLayout(XF86ConfLayoutPtr); +static XF86ConfAdjacencyPtr CopyAdjacency(XF86ConfAdjacencyPtr); +static XF86ConfInputrefPtr CopyInputref(XF86ConfInputrefPtr); +static XF86ConfInactivePtr CopyInactive(XF86ConfInactivePtr); +static void FreeLayout(XF86ConfLayoutPtr); + +extern int string_to_parser_range(char*, parser_range*, int); +#define PARSER_RANGE_SIZE 256 +/* string must have at least 256 bytes */ +extern int parser_range_to_string(char*, parser_range*, int); + +static Bool newconfig; + +static chtype screen_attr = A_NORMAL; +static chtype dialog_attr = A_REVERSE; +static chtype highlight_border_attr = A_REVERSE; +static chtype shadow_border_attr = A_REVERSE; +static chtype title_attr = A_NORMAL; +static chtype button_active_attr = A_NORMAL; +static chtype button_inactive_attr = A_NORMAL; +static int menu_width, item_x; +static char Edit[] = "Edit "; + +static char *main_menu[] = { +#define CONF_MOUSE 0 + "Configure mouse", +#define CONF_KEYBOARD 1 + "Configure keyboard", +#define CONF_MONITOR 2 + "Configure monitor", +#define CONF_CARD 3 + "Configure card", +#define CONF_SCREEN 4 + "Configure screen", +#define CONF_LAYOUT 5 + "Configure layout", +#define CONF_FINISH 6 + "Write "__XCONFIGFILE__" and quit", +#define CONF_QUIT 7 + "Quit", +}; + +void +TextMode(void) +{ + static int first = 1; + int i, choice = CONF_MOUSE; + +#ifdef USE_MODULES + if (!nomodules) + LoaderInitializeOptions(); +#endif + initscr(); + noecho(); + nonl(); + keypad(stdscr, TRUE); + + if (first) { + const char *filename; + + first = 0; + + if (has_colors()) { + start_color(); + init_pair(1, COLOR_BLACK, COLOR_BLACK); + screen_attr = A_BOLD | COLOR_PAIR(1); + + init_pair(2, COLOR_BLACK, COLOR_WHITE); + dialog_attr = COLOR_PAIR(2); + + init_pair(3, COLOR_BLACK, COLOR_WHITE); + shadow_border_attr = A_BOLD | COLOR_PAIR(3); + + init_pair(4, COLOR_WHITE, COLOR_WHITE); + highlight_border_attr = A_BOLD | COLOR_PAIR(4); + + init_pair(5, COLOR_WHITE, COLOR_BLUE); + title_attr = A_BOLD | COLOR_PAIR(5); + button_active_attr = title_attr; + + init_pair(6, COLOR_WHITE, COLOR_BLACK); + button_inactive_attr = A_BOLD | COLOR_PAIR(6); + } + + if ((filename = xf86openConfigFile(getuid() == 0 ? + CONFPATH : USER_CONFPATH, + XF86Config_path, NULL)) != NULL) { + XF86Config_path = (char *)filename; + if ((XF86Config = xf86readConfigFile()) == NULL) { + ClearScreen(); + refresh(); + Dialog("Configuration error", + "Error parsing configuration file.", + 7, 50, " Ok ", NULL, 0); + } + } + if (XF86Config == NULL) { + XF86Config = (XF86ConfigPtr)XtCalloc(1, sizeof(XF86ConfigRec)); + newconfig = True; + } + else + newconfig = False; + } + + ClearScreen(); + refresh(); + + /*CONSTCOND*/ + while (1) { + int cancel = FALSE; + + ClearScreen(); + refresh(); + if (Dialog( __XSERVERNAME__" Configuration", + "This program will create the "__XCONFIGFILE__" file, based on " + "menu selections you make.\n" + "\n" +#if defined(__SCO__) || defined(__UNIXWARE__) + "The "__XCONFIGFILE__" file usually resides in /etc. A " + "sample "__XCONFIGFILE__" file is supplied with " +#else + "The "__XCONFIGFILE__" file usually resides in " PROJECT_ROOT "/etc/X11 " + "or /etc/X11. A sample "__XCONFIGFILE__" file is supplied with " +#endif + __XSERVERNAME__"; it is configured for a standard VGA card and " + "monitor with 640x480 resolution. This program will ask for " + "a pathname when it is ready to write the file.\n" + "\n" + "You can either take the sample "__XCONFIGFILE__" as a base and " + "edit it for your configuration, or let this program " + "produce a base "__XCONFIGFILE__" file for your configuration and " + "fine-tune it.", + 20, 60, " Ok ", " Cancel ", 0) != 0) + break; + + while (!cancel) { + ClearScreen(); + refresh(); + switch (DialogMenu("Main menu", + "Choose one of the options:", + 17, 60, 8, sizeof(main_menu) / + sizeof(main_menu[0]), main_menu, + " Ok ", " Cancel ", choice)) { + case CONF_MOUSE: + i = MouseConfig(); + if (i > 0 && choice == CONF_MOUSE) + choice = CONF_KEYBOARD; + else if (i == 0) + choice = CONF_MOUSE; + break; + case CONF_KEYBOARD: + i = KeyboardConfig(); + if (i > 0 && choice <= CONF_KEYBOARD) + choice = CONF_MONITOR; + else if (i == 0) + choice = CONF_KEYBOARD; + break; + case CONF_MONITOR: + i = MonitorConfig(); + if (i > 0 && choice <= CONF_MONITOR) + choice = CONF_CARD; + else if (i == 0) + choice = CONF_MONITOR; + break; + case CONF_CARD: + i = CardConfig(); + if (i > 0 && choice <= CONF_CARD) + choice = CONF_SCREEN; + else if (i == 0) + choice = CONF_CARD; + break; + case CONF_SCREEN: + i = ScreenConfig(); + if (i > 0 && choice <= CONF_SCREEN) + choice = CONF_LAYOUT; + else if (i == 0) + choice = CONF_SCREEN; + break; + case CONF_LAYOUT: + i = LayoutConfig(); + if (i > 0 && choice <= CONF_LAYOUT) + choice = CONF_FINISH; + else if (i == 0) + choice = CONF_LAYOUT; + break; + case CONF_FINISH: + if (WriteXF86Config() < 0) + break; + /*FALLTROUGH*/ + case CONF_QUIT: + endwin(); + exit(0); + default: + cancel = TRUE; + break; + } + } + } + + endwin(); +} + +static int +WriteXF86Config(void) +{ + char *xf86config; + + ClearScreen(); + refresh(); + xf86config = DialogInput("Write "__XCONFIGFILE__, "Write configuration to file:", + 10, 60, XF86Config_path ? XF86Config_path : + "/etc/X11/"__XCONFIGFILE__, " Ok ", " Cancel ", 0); + + if (xf86config == NULL) + return (-1); + + if (newconfig) { + if (XF86Config->conf_modules == NULL) { + static char *modules[] = {"extmod", "glx", "dri", "dbe", + "record", "xtrap", "type1"}; + XF86LoadPtr load; + int i; + + XF86Config->conf_modules = (XF86ConfModulePtr) + XtCalloc(1, sizeof(XF86ConfModuleRec)); + + XF86Config->conf_modules->mod_comment = + XtNewString("\tLoad \"freetype\"\n" + "\t# Load \"xtt\"\n"); + + for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) { + load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec)); + load->load_name = XtNewString(modules[i]); + XF86Config->conf_modules->mod_load_lst = + xf86addModule(XF86Config->conf_modules->mod_load_lst, load); + } + } + } + + if (!xf86writeConfigFile(xf86config, XF86Config)) { + char msg[1024]; + + XmuSnprintf(msg, sizeof(msg), "Failed to write configuration file %s.", + xf86config); + ClearScreen(); + refresh(); + (void)Dialog("Write failed!", msg, 8, 60, " Ok ", NULL, 0); + XtFree(xf86config); + return (-1); + } + XtFree(xf86config); + + return (1); +} + +static char *protocols[] = { +#ifdef __SCO__ + "OsMouse", +#endif +#ifdef WSCONS_SUPPORT + "wsmouse", +#endif + "Auto", + "SysMouse", + "MouseSystems", + "BusMouse", + "PS/2", + "Microsoft", +#ifndef __FreeBSD__ + "ImPS/2", + "ExplorerPS/2", + "GlidePointPS/2", + "MouseManPlusPS/2", + "NetMousePS/2", + "NetScrollPS/2", + "ThinkingMousePS/2", +#endif + "AceCad", + "GlidePoint", + "IntelliMouse", + "Logitech", + "MMHitTab", + "MMSeries", + "MouseMan", + "ThinkingMouse", +}; + +static int +MouseConfig(void) +{ + int i, nlist, def, proto, emul; + char **list = NULL, *device, *str; + XF86ConfInputPtr *inputs = NULL; + XF86ConfInputPtr input = XF86Config->conf_input_lst; + XF86OptionPtr option; + + nlist = 0; + while (input) { + if (strcmp(input->inp_driver, "mouse") == 0) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(input->inp_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, input->inp_identifier); + inputs = (XF86ConfInputPtr*)XtRealloc((XtPointer)inputs, (nlist + 1) * + sizeof(XF86ConfInputPtr)); + inputs[nlist] = input; + ++nlist; + } + input = (XF86ConfInputPtr)(input->list.next); + } + + input = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new mouse"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(inputs[0]->inp_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", inputs[0]->inp_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove mouse"); + ClearScreen(); + refresh(); + i = DialogMenu("Mouse configuration", + "You can edit or remove a previously configured mouse, " + "or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove mouse", + "Select which mouse to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + input = inputs[i]; + } + else + input = inputs[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + xf86removeInput(XF86Config, input); + return (0); + } + if (i < nlist - 2) + input = inputs[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + + if (input == NULL) { + char label[32]; + + input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec)); + XmuSnprintf(label, sizeof(label), "Mouse%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + input->inp_identifier = + DialogInput("Mouse identifier", + "Enter an identifier for your mouse definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (input->inp_identifier == NULL) { + XtFree((XtPointer)input); + return (-1); + } + } + + def = 0; + option = xf86findOption(input->inp_option_lst, "Protocol"); + if (option) + for (i = 0; i < sizeof(protocols)/sizeof(protocols[0]); i++) + if (strcasecmp(option->opt_val, protocols[i]) == 0) { + def = i; + break; + } + + ClearScreen(); + refresh(); + i = DialogMenu("Select mouse protocol", + "If you have a serial mouse, it probably will work with " + "the \"Auto\" protocol. But, if it is an old serial " + "mouse probably it is not PNP; in that case, most serial " + "mouses understand the \"Microsoft\" protocol.", + 19, 60, 7, sizeof(protocols) / + sizeof(protocols[0]), protocols, " Next >>", " Cancel ", def); + if (i < 0) { + if (input->inp_driver == NULL) { + XtFree(input->inp_driver); + XtFree((XtPointer)input); + } + return (i); + } + proto = i; + + def = 0; + if (input->inp_driver) { + option = xf86findOption(input->inp_option_lst, "Emulate3Buttons"); + def = option ? 0 : 1; + } + ClearScreen(); + refresh(); + i = Dialog("Mouse 3 buttons emulation", + "If your mouse has only two buttons, it is recommended that " + "you enable Emulate3Buttons.\n" + "\n" + "Do you want to enable Emulate3Buttons?", + 10, 60, " Yes ", " No ", def); + if (i < 0) + return (i); + emul = !i; + + str = NULL; + option = xf86findOption(input->inp_option_lst, "Device"); + if (option) + str = option->opt_val; + if (str == NULL) +#ifdef WSCONS_SUPPORT + str = "/dev/wsmouse"; +#elif defined(__FreeBSD__) || defined(__DragonFly__) + str = "/dev/sysmouse"; +#elif defined(__linux__) + str = "/dev/input/mice"; +#else + str = "/dev/mouse"; +#endif + + ClearScreen(); + refresh(); + device = DialogInput("Select mouse device", + "Enter mouse device:", 10, 40, str, + " Finish ", " Cancel ", 0); + if (device == NULL) { + if (input->inp_driver == NULL) { + XtFree(input->inp_driver); + XtFree((XtPointer)input); + } + return (-1); + } + + /* Finish mouse configuration */ + option = xf86findOption(input->inp_option_lst, "Protocol"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = XtNewString(protocols[proto]); + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("Protocol"), XtNewString(protocols[proto])); + + option = xf86findOption(input->inp_option_lst, "Emulate3Buttons"); + if (option && !emul) { + xf86removeOption(&input->inp_option_lst, "Emulate3Buttons"); + } + else if (option == NULL && emul) + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("Emulate3Buttons"), NULL); + + option = xf86findOption(input->inp_option_lst, "Device"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = device; + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("Device"), device); + + if (input->inp_driver == NULL) { + input->inp_driver = XtNewString("mouse"); + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, input); + } + + return (1); +} + +static int +KeyboardConfig(void) +{ + int i; + char *rulesfile; + static int first = 1; + static XkbRF_RulesPtr rules; + static char **models, **layouts; + XF86ConfInputPtr *inputs = NULL, input = XF86Config->conf_input_lst; + char **list = NULL, *model, *layout; + int nlist, def; + XF86OptionPtr option; + + nlist = 0; + while (input) { + if (IS_KBDDRIV(input->inp_driver)) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(input->inp_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, input->inp_identifier); + inputs = (XF86ConfInputPtr*)XtRealloc((XtPointer)inputs, (nlist + 1) * + sizeof(XF86ConfInputPtr)); + inputs[nlist] = input; + ++nlist; + } + input = (XF86ConfInputPtr)(input->list.next); + } + + input = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new keyboard"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(inputs[0]->inp_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", inputs[0]->inp_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove keyboard"); + ClearScreen(); + refresh(); + i = DialogMenu("Keyboard configuration", + "You can edit or remove a previously configured " + "keyboard, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove keyboard", + "Select which keyboard to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + input = inputs[i]; + } + else + input = inputs[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + xf86removeInput(XF86Config, input); + return (0); + } + if (i < nlist - 2) + input = inputs[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + + if (input == NULL) { + char label[32]; + + input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec)); + XmuSnprintf(label, sizeof(label), "Keyboard%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + input->inp_identifier = + DialogInput("Keyboard identifier", + "Enter an identifier for your keyboard definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (input->inp_identifier == NULL) { + XtFree((XtPointer)input); + return (-1); + } + } + + if (first) { + first = 0; +#ifdef XFREE98_XKB + rulesfile = XKB_RULES_DIR "/xfree98"; +#else + rulesfile = XKB_RULES_DIR "/"__XKBDEFRULES__; +#endif + rules = XkbRF_Load(rulesfile, "", True, False); + if (rules == NULL) { + ClearScreen(); + refresh(); + Dialog("Configuration error", + "XKB rules file not found.\n" + "\n" + "Keyboard XKB options will be set to default values.", + 10, 50, " Ok ", NULL, 0); + if (input->inp_driver == NULL) { + input->inp_option_lst = + xf86addNewOption(input->inp_option_lst, + XtNewString("XkbModel"), XtNewString("pc101")); + input->inp_option_lst = + xf86addNewOption(input->inp_option_lst, + XtNewString("XkbLayout"), XtNewString("us")); + input->inp_driver = XtNewString("kbd"); + XF86Config->conf_input_lst = + xf86addInput(XF86Config, input); + } + return (0); + } + models = (char**)XtMalloc(sizeof(char*) * rules->models.num_desc); + for (i = 0; i < rules->models.num_desc; i++) + models[i] = XtNewString(rules->models.desc[i].desc); + layouts = (char**)XtMalloc(sizeof(char*) * rules->layouts.num_desc); + for (i = 0; i < rules->layouts.num_desc; i++) + layouts[i] = XtNewString(rules->layouts.desc[i].desc); + } + else if (rules == NULL) + return (-1); + + def = 0; + option = xf86findOption(input->inp_option_lst, "XkbModel"); + if (option) { + for (i = 0; i < rules->models.num_desc; i++) + if (strcasecmp(option->opt_val, rules->models.desc[i].name) == 0) { + def = i; + break; + } + } + ClearScreen(); + refresh(); + i = DialogMenu("Keyboard model", + "Please select one of the following keyboard types that is " + "the better description of your keyboard. If nothing really " + "matches, choose \"Generic 101-key PC\".\n", + 20, 60, 9, rules->models.num_desc, + models, " Next >>", " Cancel ", def); + if (i < 0) + return (i); + model = rules->models.desc[i].name; + + def = 0; + option = xf86findOption(input->inp_option_lst, "XkbLayout"); + if (option) { + for (i = 0; i < rules->layouts.num_desc; i++) + if (strcasecmp(option->opt_val, rules->layouts.desc[i].name) == 0) { + def = i; + break; + } + } + ClearScreen(); + refresh(); + i = DialogMenu("Keyboard layout", + "Select keyboard layout:", + 20, 60, 11, rules->layouts.num_desc, + layouts, " Finish ", " Cancel ", def); + if (i < 0) + return (i); + layout = rules->layouts.desc[i].name; + + /* Finish keyboard configuration */ + option = xf86findOption(input->inp_option_lst, "XkbModel"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = XtNewString(model); + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("XkbModel"), XtNewString(model)); + + option = xf86findOption(input->inp_option_lst, "XkbLayout"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = XtNewString(layout); + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("XkbLayout"), XtNewString(layout)); + + if (input->inp_driver == NULL) { + input->inp_driver = XtNewString("kbd"); + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, input); + } + + return (1); +} + +static char *hsync[] = { +#define CONF_MONITOR_HSYNC 0 + "Enter your own horizontal sync range", + "31.5; Standard VGA, 640x480 @ 60 Hz", + "31.5 - 35.1; Super VGA, 800x600 @ 56 Hz", + "31.5, 35.5; 8514 Compatible, 1024x768 @ 87 Hz interlaced (no 800x600)", + "31.5, 35.15, 35.5; Super VGA, 1024x768 @ 87 Hz int., 800x600 @ 56 Hz", + "31.5 - 37.9; Extended Super VGA, 800x600 @ 60 Hz, 640x480 @ 72 Hz", + "31.5 - 48.5; Non-Interlaced SVGA, 1024x768 @ 60 Hz, 800x600 @ 72 Hz", + "31.5 - 57.0; High Frequency SVGA, 1024x768 @ 70 Hz", + "31.5 - 64.3; Monitor that can do 1280x1024 @ 60 Hz", + "31.5 - 79.0; Monitor that can do 1280x1024 @ 74 Hz", + "31.5 - 82.0; Monitor that can do 1280x1024 @ 76 Hz", + "31.5 - 92.0; Monitor that can do 1280x1024 @ 85 Hz", + "31.5 - 108.0; Monitor that can do 1600x1200 @ 85 Hz", + "31.5 - 128.5; Monitor that can do 1920x1440 @ 85 Hz", + "31.5 - 137.0; Monitor that can do 2048x1536 @ 85 Hz" +}; + +static char *vrefresh[] = { +#define CONF_MONITOR_VREFRESH 0 + "Enter your own vertical sync range", + "50 - 70", + "50 - 90", + "50 - 100", + "40 - 150", +}; + +static int +MonitorConfig(void) +{ + int i; + XF86ConfMonitorPtr *monitors = NULL, monitor = XF86Config->conf_monitor_lst; + char **list = NULL, *identifier = NULL, *tmp; + int nlist, def; + char hsync_str[256], vrefresh_str[256]; + + hsync_str[0] = vrefresh_str[0] = '\0'; + nlist = 0; + while (monitor) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(monitor->mon_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, monitor->mon_identifier); + monitors = (XF86ConfMonitorPtr*)XtRealloc((XtPointer)monitors, (nlist + 1) * + sizeof(XF86ConfMonitorPtr)); + monitors[nlist] = monitor; + ++nlist; + monitor = (XF86ConfMonitorPtr)(monitor->list.next); + } + + monitor = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new monitor"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(monitors[0]->mon_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", monitors[0]->mon_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove monitor"); + ClearScreen(); + refresh(); + i = DialogMenu("Monitor configuration", + "You can edit or remove a previously configured " + "monitor, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove monitor", + "Select which monitor to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + return (-1); + } + monitor = monitors[i]; + } + else + monitor = monitors[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + xf86removeMonitor(XF86Config, monitor); + return (0); + } + if (i < nlist - 2) + monitor = monitors[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + + if (monitor == NULL) { + char label[32]; + + monitor = (XF86ConfMonitorPtr)XtCalloc(1, sizeof(XF86ConfMonitorRec)); + XmuSnprintf(label, sizeof(label), "Monitor%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Monitor identifier", + "Enter an identifier for your monitor definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) { + XtFree((XtPointer)monitor); + return (-1); + } + } + + if (monitor->mon_identifier == NULL) { + ClearScreen(); + refresh(); + i = Dialog("Monitor configuration", + "Now we want to set the specifications of the monitor. The " + "two critical parameters are the vertical refresh rate, which " + "is the rate at which the whole screen is refreshed, and most " + "importantly the horizontal sync rate, which is the rate at " + "which scanlines are displayed.\n" + "\n" + "The valid range for horizontal sync and vertical sync should " + "be documented in the manual of your monitor.", + 15, 60, " Next >>", " Cancel ", 0); + if (i != 0) { + XtFree(identifier); + XtFree((XtPointer)monitor); + return (-1); + } + } + + def = 0; + if (monitor->mon_identifier) { + int len; + + parser_range_to_string(hsync_str, &(monitor->mon_hsync[0]), + monitor->mon_n_hsync); + len = strlen(hsync_str); + for (i = 1; i < sizeof(hsync) / sizeof(hsync[0]); i++) { + tmp = strchr(hsync[i], ';'); + if (strncmp(hsync_str, hsync[i], len) == 0) { + def = i; + break; + } + } + } + if (hsync_str[0] == '\0') + strcpy(hsync_str, "31.5"); + + ClearScreen(); + refresh(); + i = DialogMenu("Monitor HorizSync", + "You must indicate the horizontal sync range of your " + "monitor. You can either select one of the predefined " + "ranges below that correspond to industry-standard monitor " + "types, or give a specific range.", + 22, 78, 11, sizeof(hsync) / + sizeof(hsync[0]), hsync, " Next >>", " Cancel ", def); + if (i < 0) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (-1); + } + if (i == CONF_MONITOR_HSYNC) { + ClearScreen(); + refresh(); + tmp = DialogInput("Monitor HorizSync", + "Please enter the horizontal sync range of your " + "monitor, in the format used in the table of monitor " + "types above. You can either specify one or more " + "continuous ranges (e.g. 15-25, 30-50), or one or more " + "fixed sync frequencies.\n" + "\n" + "Horizontal sync range:", 16, 62, hsync_str, + " Ok ", " Cancel ", def); + if (tmp == NULL) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (-1); + } + XmuSnprintf(hsync_str, sizeof(hsync_str), "%s", tmp); + XtFree(tmp); + } + else { + tmp = strchr(hsync[i], ';'); + strncpy(hsync_str, hsync[i], tmp - hsync[i]); + hsync_str[tmp - hsync[i]] = '\0'; + } + + def = 0; + if (monitor->mon_identifier) { + parser_range_to_string(vrefresh_str, &(monitor->mon_vrefresh[0]), + monitor->mon_n_vrefresh); + for (i = 1; i < sizeof(vrefresh) / sizeof(vrefresh[0]); i++) { + if (strcmp(vrefresh_str, vrefresh[i]) == 0) { + def = i; + break; + } + } + } + if (vrefresh_str[0] == '\0') + strcpy(vrefresh_str, "50 - 70"); + ClearScreen(); + refresh(); + i = DialogMenu("Monitor VertRefresh", + "You must indicate the vertical sync range of your monitor. " + "You can either select one of the predefined ranges below " + "that correspond to industry-standard monitor types, or " + "give a specific range. For interlaced modes, the number " + "that counts is the high one (e.g. 87 Hz rather than 43 Hz).", + 19, 60, 5, sizeof(vrefresh) / + sizeof(vrefresh[0]), vrefresh, " Finish ", " Cancel ", def); + if (i < 0) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (i); + } + if (i == CONF_MONITOR_VREFRESH) { + ClearScreen(); + refresh(); + tmp = DialogInput("Monitor VertRefresh", + "Vertical sync range:", 10, 50, vrefresh_str, + " Done ", " Cancel ", 0); + if (tmp == NULL) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (-1); + } + XmuSnprintf(vrefresh_str, sizeof(vrefresh_str), "%s", tmp); + XtFree(tmp); + } + else + strcpy(vrefresh_str, vrefresh[i]); + + /* Finish monitor configuration */ + monitor->mon_n_hsync = string_to_parser_range(hsync_str, + &(monitor->mon_hsync[0]), CONF_MAX_HSYNC); + monitor->mon_n_vrefresh = string_to_parser_range(vrefresh_str, + &(monitor->mon_vrefresh[0]), CONF_MAX_VREFRESH); + if (monitor->mon_identifier == NULL) { + monitor->mon_identifier = identifier; + XF86Config->conf_monitor_lst = + xf86addMonitor(XF86Config->conf_monitor_lst, monitor); + } + + return (1); +} + +static int +CardConfig(void) +{ + int i; + XF86ConfDevicePtr *devices = NULL, device = XF86Config->conf_device_lst; + char **list = NULL, *identifier = NULL, *driver, *busid, *tmp; + int nlist, def; + CardsEntry *entry = NULL; + static char **drivers; + static int ndrivers; + static char *xdrivers[] = { + "apm", + "ark", + "ast", + "ati", + "r128", + "radeon", + "chips", + "cirrus", + "cyrix", + "fbdev", + "glint", + "i128", + "i740", + "i810", + "imstt", + "mga", + "neomagic", + "nv", + "rendition", + "s3", + "s3virge", + "savage", + "siliconmotion", + "sis", + "tdfx", + "tga", + "trident", + "tseng", + "vmware", + "vga", + "vesa", + }; + +#ifdef USE_MODULES + if (!nomodules) { + xf86cfgModuleOptions *opts = module_options; + + drivers = NULL; + ndrivers = 0; + while (opts) { + if (opts->type == VideoModule) { + ++ndrivers; + drivers = (char**)XtRealloc((XtPointer)drivers, + ndrivers * sizeof(char*)); + /* XXX no private copy */ + drivers[ndrivers - 1] = opts->name; + } + opts = opts->next; + } + } + else +#endif + { + ndrivers = sizeof(xdrivers) / sizeof(xdrivers[0]); + drivers = xdrivers; + } + + nlist = 0; + while (device) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(device->dev_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, device->dev_identifier); + devices = (XF86ConfDevicePtr*)XtRealloc((XtPointer)devices, (nlist + 1) * + sizeof(XF86ConfDevicePtr)); + devices[nlist] = device; + ++nlist; + device = (XF86ConfDevicePtr)(device->list.next); + } + + device = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new card"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(devices[0]->dev_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", devices[0]->dev_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove device"); + ClearScreen(); + refresh(); + i = DialogMenu("Card configuration", + "You can edit or remove a previously configured " + "card, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove card", + "Select which card to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + return (-1); + } + device = devices[i]; + } + else + device = devices[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + xf86removeDevice(XF86Config, device); + return (0); + } + if (i < nlist - 2) + device = devices[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + + if (device == NULL) { + char label[32]; + + device = (XF86ConfDevicePtr)XtCalloc(1, sizeof(XF86ConfDeviceRec)); + device->dev_chipid = device->dev_chiprev = device->dev_irq = -1; + XmuSnprintf(label, sizeof(label), "Card%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Card identifier", + "Enter an identifier for your card definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) { + XtFree((XtPointer)device); + return (-1); + } + } + + ClearScreen(); + refresh(); + if (Dialog("Card configuration", + "Now we must configure video card specific settings. At this " + "point you can choose to make a selection out of a database of " + "video card definitions.\n" + "\n" + "The database entries include information about the chipset, " + "what driver to run, the Ramdac and ClockChip, and comments " + "that will be included in the Device section. However, a lot " + "of definitions only hint about what driver to run (based on " + "the chipset the card uses) and are untested.\n" + "\n" + "Do you want to look at the card database?", + 18, 60, " Yes ", " No ", device->dev_identifier != NULL) == 0) { + static char **cards; + static int ncards; + + if (cards == NULL) { + ReadCardsDatabase(); + cards = GetCardNames(&ncards); + cards = (char**)XtRealloc((XtPointer)cards, + (ncards + 1) * sizeof(char*)); + for (i = ncards; i > 0; i--) + cards[i] = cards[i - 1]; + cards[0] = "** Unlisted card **"; + ++ncards; + } + if (device->dev_card) + entry = LookupCard(device->dev_card); + def = 0; + if (entry) { + for (i = 0; i < NumCardsEntry; i++) + if (strcasecmp(CardsDB[i]->name, entry->name) == 0) { + def = i + 1; + break; + } + /* make sure entry is set to null again */ + entry = NULL; + } + + i = DialogMenu("Card database", + "Select name that better matches your card:", + 20, 70, 11, ncards, cards, "Next >>", " Cancel ", def); + if (i > 0) + entry = LookupCard(cards[i]); + } + + def = 0; + tmp = device->dev_driver ? device->dev_driver : entry && entry->driver ? + entry->driver : "vga"; + for (i = 0; i < ndrivers; i++) + if (strcmp(drivers[i], tmp) == 0) { + def = i; + break; + } + + ClearScreen(); + refresh(); + i = DialogMenu("Card driver", + "You can select the driver for your card here, or just press " + "Enter to use the default/current:", 20, 50, 9, + ndrivers, drivers, " Ok ", " Cancel ", def); + if (i < 0) { + if (device->dev_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)device); + } + return (-1); + } + driver = ndrivers ? drivers[i] : "vga"; + + ClearScreen(); + refresh(); + tmp = device->dev_busid ? device->dev_busid : ""; + busid = DialogInput("Card BusID", + "You normally does not need to fill this field " + "if you have only one video card:", 11, 50, tmp, + " Finish ", " Cancel ", 0); + + /* Finish card configuration */ + if (entry) { + XtFree(device->dev_card); + device->dev_card = XtNewString(entry->name); + if (entry->chipset) { + XtFree(device->dev_chipset); + device->dev_chipset = XtNewString(entry->chipset); + } + if (entry->ramdac) { + XtFree(device->dev_ramdac); + device->dev_ramdac = XtNewString(entry->ramdac); + } + if (entry->clockchip) { + XtFree(entry->clockchip); + device->dev_clockchip = XtNewString(entry->clockchip); + } + } + if (busid) { + XtFree(device->dev_busid); + if (*busid) + device->dev_busid = busid; + else { + device->dev_busid = NULL; + XtFree(busid); + } + } + XtFree(device->dev_driver); + device->dev_driver = XtNewString(driver); + if (device->dev_identifier == NULL) { + device->dev_identifier = identifier; + XF86Config->conf_device_lst = + xf86addDevice(XF86Config->conf_device_lst, device); + } + + return (1); +} + +static char *depths[] = { + "1 bit, monochrome", + "4 bit, 16 colors", + "8 bit, 256 colors", + "15 bits, 32Kb colors", + "16 bits, 65Kb colors", + "24 bits, 16Mb colors", +}; + +static char *modes[] = { + "2048x1536", + "1920x1440", + "1800x1400", + "1600x1200", + "1400x1050", + "1280x1024", + "1280x960", + "1152x864", + "1024x768", + "800x600", + "640x480", + "640x400", + "512x384", + "400x300", + "320x240", + "320x200", +}; + +static int +ScreenConfig(void) +{ + int i, disp_allocated; + XF86ConfScreenPtr *screens = NULL, screen = XF86Config->conf_screen_lst; + char **list = NULL, *identifier = NULL; + int nlist, def; + XF86ConfDevicePtr device = NULL; + XF86ConfMonitorPtr monitor = NULL; + XF86ConfDisplayPtr display; + XF86ModePtr mode, ptr = NULL; + char *checks; + + nlist = 0; + while (screen) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(screen->scrn_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, screen->scrn_identifier); + screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens, (nlist + 1) * + sizeof(XF86ConfScreenPtr)); + screens[nlist] = screen; + ++nlist; + screen = (XF86ConfScreenPtr)(screen->list.next); + } + + screen = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new screen"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(screens[0]->scrn_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", screens[0]->scrn_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove screen"); + ClearScreen(); + refresh(); + i = DialogMenu("Screen configuration", + "You can edit or remove a previously configured " + "screen, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove screen", + "Select which screen to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + return (-1); + } + screen = screens[i]; + } + else + screen = screens[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + xf86removeScreen(XF86Config, screen); + return (0); + } + if (i < nlist - 2) + screen = screens[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + + if (screen == NULL) { + char label[256]; + XF86ConfDevicePtr *devices = NULL; + XF86ConfMonitorPtr *monitors = NULL; + + device = XF86Config->conf_device_lst; + monitor = XF86Config->conf_monitor_lst; + + if (device == NULL || monitor == NULL) { + ClearScreen(); + refresh(); + Dialog("Configuration error", + "You need to configure (at least) one card and one " + "monitor before creating a screen definition.", + 9, 50, " Ok ", NULL, 0); + + return (-1); + } + + XmuSnprintf(label, sizeof(label), "Screen%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Screen identifier", + "Enter an identifier for your screen definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) + return (-1); + + nlist = 0; + list = NULL; + while (device) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtNewString(device->dev_identifier); + devices = (XF86ConfDevicePtr*)XtRealloc((XtPointer)devices, (nlist + 1) * + sizeof(XF86ConfDevicePtr)); + devices[nlist] = device; + ++nlist; + device = (XF86ConfDevicePtr)(device->list.next); + } + ClearScreen(); + refresh(); + i = DialogMenu("Screen card", "Please select a video card:", + 13, 60, 4, nlist, list, " Next >>", " Cancel ", 0); + for (def = 0; def < nlist; def++) + XtFree(list[def]); + XtFree((XtPointer)list); + if (i < 0) { + XtFree(identifier); + XtFree((XtPointer)devices); + return (-1); + } + device = devices[i]; + XtFree((XtPointer)devices); + + nlist = 0; + list = NULL; + while (monitor) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtNewString(monitor->mon_identifier); + monitors = (XF86ConfMonitorPtr*)XtRealloc((XtPointer)monitors, (nlist + 1) * + sizeof(XF86ConfMonitorPtr)); + monitors[nlist] = monitor; + ++nlist; + monitor = (XF86ConfMonitorPtr)(monitor->list.next); + } + XmuSnprintf(label, sizeof(label), + "Select the monitor connected to \"%s\":", + device->dev_identifier); + ClearScreen(); + refresh(); + i = DialogMenu("Screen monitor", label, + 13, 60, 4, nlist, list, " Next >>", " Cancel ", 0); + for (def = 0; def < nlist; def++) + XtFree(list[def]); + XtFree((XtPointer)list); + if (i < 0) { + XtFree(identifier); + XtFree((XtPointer)monitors); + return (-1); + } + monitor = monitors[i]; + XtFree((XtPointer)monitors); + + screen = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec)); + screen->scrn_device = device; + screen->scrn_monitor = monitor; + } + + if (screen->scrn_defaultdepth == 1) + def = 0; + else if (screen->scrn_defaultdepth == 4) + def = 1; + else if (screen->scrn_defaultdepth == 8) + def = 2; + else if (screen->scrn_defaultdepth == 15) + def = 3; + else if (screen->scrn_defaultdepth == 16) + def = 4; + else if (screen->scrn_defaultdepth == 24) + def = 5; + else { + if (screen->scrn_device && screen->scrn_device->dev_driver && + strcmp(screen->scrn_device->dev_driver, "vga") == 0) + def = 1; /* 4bpp */ + else + def = 2; /* 8bpp */ + } + ClearScreen(); + refresh(); + i = DialogMenu("Screen depth", + "Please specify which color depth you want to use by default:", + 15, 60, 6, sizeof(depths) / sizeof(depths[0]), depths, + " Next >>", " Cancel ", def); + if (i < 0) { + if (screen->scrn_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)screen); + } + return (-1); + } + else + /* XXX depths must begin with the depth number */ + screen->scrn_defaultdepth = atoi(depths[i]); + + def = 0; /* use def to count how many modes are selected*/ + nlist = 0; + list = NULL; + checks = XtMalloc(sizeof(modes) / sizeof(modes[0])); + /* XXX list fields in the code below are not allocated */ + disp_allocated = 0; + display = screen->scrn_display_lst; + while (display && display->disp_depth != screen->scrn_defaultdepth) + display = (XF86ConfDisplayPtr)(display->list.next); + if (display == NULL) { + display = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec)); + display->disp_white.red = display->disp_black.red = -1; + display->disp_depth = screen->scrn_defaultdepth; + disp_allocated = 1; + } + else { + mode = display->disp_mode_lst; + while (mode) { + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + if (strcmp(modes[i], mode->mode_name) == 0) { + break; + } + + if (i == sizeof(modes) / sizeof(modes[0])) { + list = (char**)XtRealloc((XtPointer)list, + (nlist + 1) * sizeof(char*)); + list[nlist] = mode->mode_name; + checks = XtRealloc(checks, sizeof(modes) / sizeof(modes[0]) + + nlist + 1); + checks[nlist] = 1; + ++def; + nlist++; + break; + } + mode = (XF86ModePtr)(mode->list.next); + } + } + + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + checks[i + nlist] = 0; + + mode = display->disp_mode_lst; + while (mode) { + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + if (strcmp(modes[i], mode->mode_name) == 0) { + ++def; + checks[i + nlist] = 1; + break; + } + mode = (XF86ModePtr)(mode->list.next); + } + + if (nlist == 0 && def == 0) + checks[7] = 1; /* 640x480 */ + list = (char**)XtRealloc((XtPointer)list, (nlist + sizeof(modes) / + sizeof(modes[0])) * sizeof(char*)); + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + list[i + nlist] = modes[i]; + nlist += sizeof(modes) / sizeof(modes[0]); + + ClearScreen(); + refresh(); + i = DialogCheckBox("Screen modes", + "Select the video modes for this screen:", + 17, 60, 8, sizeof(modes) / sizeof(modes[0]), modes, + " Finish ", " Cancel ", checks); + if (i < 0) { + if (screen->scrn_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)screen); + XtFree((XtPointer)list); + if (disp_allocated) + XtFree((XtPointer)display); + } + return (-1); + } + + mode = display->disp_mode_lst; + while (mode) { + ptr = (XF86ModePtr)(mode->list.next); + XtFree(mode->mode_name); + XtFree((XtPointer)mode); + mode = ptr; + } + display->disp_mode_lst = NULL; + + for (i = 0; i < nlist; i++) { + if (checks[i]) { + mode = (XF86ModePtr)XtCalloc(1, sizeof(XF86ModeRec)); + mode->mode_name = XtNewString(list[i]); + if (display->disp_mode_lst == NULL) + display->disp_mode_lst = ptr = mode; + else { + ptr->list.next = mode; + ptr = mode; + } + } + } + XtFree((XtPointer)list); + + if (disp_allocated) { + display->list.next = NULL; + if (screen->scrn_display_lst == NULL) + screen->scrn_display_lst = display; + else + screen->scrn_display_lst->list.next = display; + } + + if (screen->scrn_identifier == NULL) { + screen->scrn_identifier = identifier; + screen->scrn_monitor_str = XtNewString(monitor->mon_identifier); + screen->scrn_device_str = XtNewString(device->dev_identifier); + XF86Config->conf_screen_lst = + xf86addScreen(XF86Config->conf_screen_lst, screen); + } + + return (1); +} + +static XF86ConfAdjacencyPtr +CopyAdjacency(XF86ConfAdjacencyPtr ptr) +{ + XF86ConfAdjacencyPtr adj = (XF86ConfAdjacencyPtr) + XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + + adj->adj_scrnum = ptr->adj_scrnum; + adj->adj_screen = ptr->adj_screen; + adj->adj_screen_str = XtNewString(ptr->adj_screen_str); + adj->adj_top = ptr->adj_top; + if (ptr->adj_top_str) + adj->adj_top_str = XtNewString(ptr->adj_top_str); + adj->adj_bottom = ptr->adj_bottom; + if (ptr->adj_bottom_str) + adj->adj_bottom_str = XtNewString(ptr->adj_bottom_str); + adj->adj_left = ptr->adj_left; + if (ptr->adj_left_str) + adj->adj_left_str = XtNewString(ptr->adj_left_str); + adj->adj_right = ptr->adj_right; + if (ptr->adj_right_str) + adj->adj_right_str = XtNewString(ptr->adj_right_str); + adj->adj_where = ptr->adj_where; + adj->adj_x = ptr->adj_x; + adj->adj_y = ptr->adj_y; + if (ptr->adj_refscreen) + adj->adj_refscreen = XtNewString(ptr->adj_refscreen); + + return (adj); +} + +static XF86ConfInactivePtr +CopyInactive(XF86ConfInactivePtr ptr) +{ + XF86ConfInactivePtr inac = (XF86ConfInactivePtr) + XtCalloc(1, sizeof(XF86ConfInactiveRec)); + + inac->inactive_device = ptr->inactive_device; + if (ptr->inactive_device_str) + inac->inactive_device_str = XtNewString(ptr->inactive_device_str); + + return (inac); +} + +static XF86ConfInputrefPtr +CopyInputref(XF86ConfInputrefPtr ptr) +{ + XF86ConfInputrefPtr iref = (XF86ConfInputrefPtr) + XtCalloc(1, sizeof(XF86ConfInputrefRec)); + XF86OptionPtr opt = ptr->iref_option_lst; + + iref->iref_inputdev = ptr->iref_inputdev; + if (ptr->iref_inputdev_str) + iref->iref_inputdev_str = XtNewString(ptr->iref_inputdev_str); + while (opt) { + iref->iref_option_lst = xf86addNewOption(iref->iref_option_lst, + XtNewString(opt->opt_name), + opt->opt_val ? XtNewString(opt->opt_val) : NULL); + opt = (XF86OptionPtr)(opt->list.next); + } + + return (iref); +} + +static XF86ConfLayoutPtr +CopyLayout(XF86ConfLayoutPtr ptr) +{ + XF86ConfLayoutPtr lay = (XF86ConfLayoutPtr) + XtCalloc(1, sizeof(XF86ConfLayoutRec)); + XF86ConfAdjacencyPtr adj = ptr->lay_adjacency_lst, padj; + XF86ConfInactivePtr inac = ptr->lay_inactive_lst, pinac; + XF86ConfInputrefPtr iref = ptr->lay_input_lst, piref; + XF86OptionPtr opt = ptr->lay_option_lst; + + if (ptr->lay_identifier) + lay->lay_identifier = XtNewString(ptr->lay_identifier); + if (adj) { + padj = lay->lay_adjacency_lst = CopyAdjacency(adj); + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + while (adj) { + padj->list.next = CopyAdjacency(adj); + padj = (XF86ConfAdjacencyPtr)(padj->list.next); + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + } + if (inac) { + pinac = lay->lay_inactive_lst = CopyInactive(inac); + inac = (XF86ConfInactivePtr)(inac->list.next); + while (inac) { + pinac->list.next = CopyInactive(inac); + pinac = (XF86ConfInactivePtr)(pinac->list.next); + inac = (XF86ConfInactivePtr)(inac->list.next); + } + } + if (iref) { + piref = lay->lay_input_lst = CopyInputref(iref); + iref = (XF86ConfInputrefPtr)(iref->list.next); + while (iref) { + piref->list.next = CopyInputref(iref); + piref = (XF86ConfInputrefPtr)(piref->list.next); + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + } + + while (opt) { + lay->lay_option_lst = xf86addNewOption(lay->lay_option_lst, + XtNewString(opt->opt_name), + opt->opt_val ? XtNewString(opt->opt_val) : NULL); + opt = (XF86OptionPtr)(opt->list.next); + } + + return (lay); +} + +static void +FreeLayout(XF86ConfLayoutPtr lay) +{ + static XF86ConfigRec xf86config; + + xf86config.conf_layout_lst = lay; + xf86removeLayout(&xf86config, lay); +} + +static int +LayoutConfig(void) +{ + int i; + XF86ConfLayoutPtr *layouts = NULL, rlayout = NULL, + layout = XF86Config->conf_layout_lst; + XF86ConfInputPtr input = XF86Config->conf_input_lst; + char **list = NULL, *identifier = NULL; + XF86ConfInputPtr *mouses = NULL, *keyboards = NULL, mouse, keyboard; + XF86ConfInputrefPtr iref, piref, mref, kref; + XF86ConfAdjacencyPtr adj, padj; + int nmouses, nkeyboards; + int nlist; + XF86OptionPtr option; + XF86ConfScreenPtr screen, *screens; + + nmouses = nkeyboards = 0; + while (input) { + if (strcmp(input->inp_driver, "mouse") == 0) { + mouses = (XF86ConfInputPtr*)XtRealloc((XtPointer)mouses, + (nmouses + 1) * sizeof(XF86ConfInputPtr)); + mouses[nmouses] = input; + ++nmouses; + } + else if (IS_KBDDRIV(input->inp_driver)) { + keyboards = (XF86ConfInputPtr*)XtRealloc((XtPointer)keyboards, + (nkeyboards + 1) * sizeof(XF86ConfInputPtr)); + keyboards[nkeyboards] = input; + ++nkeyboards; + } + input = (XF86ConfInputPtr)(input->list.next); + } + if (XF86Config->conf_screen_lst == NULL || + nmouses == 0 || nkeyboards == 0) { + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + ClearScreen(); + refresh(); + Dialog("Configuration error", + "You need to configure (at least) one screen, mouse " + "and keyboard before creating a layout definition.", + 9, 50, " Ok ", NULL, 0); + return (-1); + } + + nlist = 0; + while (layout) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(layout->lay_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, layout->lay_identifier); + layouts = (XF86ConfLayoutPtr*)XtRealloc((XtPointer)layouts, (nlist + 1) * + sizeof(XF86ConfLayoutPtr)); + layouts[nlist] = layout; + ++nlist; + layout = (XF86ConfLayoutPtr)(layout->list.next); + } + + layout = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new layout"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(layouts[0]->lay_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", layouts[0]->lay_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove layout"); + ClearScreen(); + refresh(); + i = DialogMenu("Layout configuration", + "You can edit or remove a previously configured " + "layout, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove layout", + "Select which layout to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + return (-1); + } + layout = layouts[i]; + } + else + layout = layouts[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + xf86removeLayout(XF86Config, layout); + return (0); + } + if (i < nlist - 2) + layout = layouts[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + + if (layout == NULL) { + char label[32]; + + layout = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec)); + XmuSnprintf(label, sizeof(label), "Layout%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Layout identifier", + "Enter an identifier for your layout definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) { + XtFree((XtPointer)layout); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + return (-1); + } + } + else { + /* So that we can safely change it */ + rlayout = layout; + layout = CopyLayout(rlayout); + } + + + mouse = keyboard = NULL; + + /* Mouse */ + piref = NULL; + iref = layout->lay_input_lst; + while (iref) { + if (strcmp(iref->iref_inputdev->inp_driver, "mouse") == 0) { + if (mouse == NULL) + piref = iref; + if (xf86findOption(iref->iref_option_lst, "CorePointer")) { + mouse = iref->iref_inputdev; + piref = iref; + break; + } + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + if (mouse == NULL) { + if (piref) { + mref = piref; + mouse = piref->iref_inputdev; + piref->iref_option_lst = + xf86addNewOption(piref->iref_option_lst, + XtNewString("CorePointer"), NULL); + } + else { + mouse = mouses[0]; + mref = iref = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec)); + iref->iref_inputdev_str = XtNewString(mouse->inp_identifier); + iref->iref_inputdev = mouse; + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + XtNewString("CorePointer"), NULL); + iref->list.next = layout->lay_input_lst; + if (layout->lay_input_lst == NULL) + layout->lay_input_lst = iref; + else { + iref->list.next = layout->lay_input_lst; + layout->lay_input_lst = iref; + } + } + } + else + mref = piref; + + /* XXX list fields are not allocated */ + if (nmouses > 1) { + nlist = 0; + list = (char**)XtMalloc(sizeof(char*)); + list[nlist++] = mouse->inp_identifier; + input = XF86Config->conf_input_lst; + while (input) { + if (input != mouse && strcmp(input->inp_driver, "mouse") == 0) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist++] = input->inp_identifier; + } + input = (XF86ConfInputPtr)(input->list.next); + } + ClearScreen(); + refresh(); + i = DialogMenu("Select Core Pointer", + "Select the mouse connected to you computer", + 12, 60, 4, nlist, list, " Ok ", " Cancel ", 0); + if (i < 0) { + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + XtFree((XtPointer)list); + if (layout->lay_identifier == NULL) + XtFree(identifier); + FreeLayout(layout); + return (-1); + } + if (i > 0) { + /* Did not select the default one */ + iref = layout->lay_input_lst; + while (iref) { + if (strcasecmp(iref->iref_inputdev_str, list[i]) == 0) { + if ((option = xf86findOption(iref->iref_option_lst, + "SendCoreEvents")) != NULL) { + XtFree(option->opt_name); + option->opt_name = XtNewString("CorePointer"); + } + else + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + XtNewString("CorePointer"), NULL); + option = xf86findOption(mref->iref_option_lst, + "CorePointer"); + XtFree(option->opt_name); + option->opt_name = XtNewString("SendCoreEvents"); + break; + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + } + + /* XXX Write code to add/remove more mouses here */ + } + + + /* Keyboard */ + piref = NULL; + iref = layout->lay_input_lst; + while (iref) { + if (IS_KBDDRIV(iref->iref_inputdev->inp_driver)) { + if (keyboard == NULL) + piref = iref; + if (xf86findOption(iref->iref_option_lst, "CoreKeyboard")) { + keyboard = iref->iref_inputdev; + piref = iref; + break; + } + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + if (keyboard == NULL) { + if (piref) { + kref = piref; + keyboard = piref->iref_inputdev; + piref->iref_option_lst = + xf86addNewOption(piref->iref_option_lst, + XtNewString("CoreKeyboard"), NULL); + } + else { + keyboard = keyboards[0]; + kref = iref = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec)); + iref->iref_inputdev_str = XtNewString(keyboard->inp_identifier); + iref->iref_inputdev = keyboard; + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + XtNewString("CoreKeyboard"), NULL); + iref->list.next = layout->lay_input_lst; + if (layout->lay_input_lst == NULL) + layout->lay_input_lst = iref; + else { + iref->list.next = layout->lay_input_lst; + layout->lay_input_lst = iref; + } + } + } + else + kref = piref; + + /* XXX list fields are not allocated */ + if (nkeyboards > 1) { + nlist = 0; + list = (char**)XtMalloc(sizeof(char*)); + list[nlist++] = keyboard->inp_identifier; + input = XF86Config->conf_input_lst; + while (input) { + if (input != keyboard && IS_KBDDRIV(input->inp_driver)) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist++] = input->inp_identifier; + } + input = (XF86ConfInputPtr)(input->list.next); + } + ClearScreen(); + refresh(); + i = DialogMenu("Select Core Keyboard", + "Select the keyboard connected to you computer", + 12, 60, 4, nlist, list, " Ok ", " Cancel ", 0); + if (i < 0) { + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + XtFree((XtPointer)list); + if (layout->lay_identifier == NULL) + XtFree(identifier); + FreeLayout(layout); + return (-1); + } + if (i > 0) { + /* Did not select the default one */ + iref = layout->lay_input_lst; + while (iref) { + if (strcasecmp(iref->iref_inputdev_str, list[i]) == 0) { + if ((option = xf86findOption(iref->iref_option_lst, + "SendCoreEvents")) != NULL) { + XtFree(option->opt_name); + option->opt_name = XtNewString("CoreKeyboard"); + } + else + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + XtNewString("CoreKeyboard"), NULL); + option = xf86findOption(kref->iref_option_lst, + "CoreKeyboard"); + XtFree(option->opt_name); + option->opt_name = XtNewString("SendCoreEvents"); + break; + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + } + + /* XXX Write code to add/remove more keyboards here */ + } + + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + + /* Just one screen */ + if (XF86Config->conf_screen_lst->list.next == NULL) { + ClearScreen(); + refresh(); + Dialog("Layout configuration", + (nmouses > 1 || nkeyboards > 1) ? + "As you have only one screen configured, I can now finish " + "creating this Layout configuration." + : + "As you have only one screen, mouse and keyboard configured, " + "I can now finish creating this Layout configuration.", + 12, 60, " Finish ", NULL, 0); + + goto LayoutFinish; + } + + + /* The code below just adds a screen to the right of the last + * one, or allows removing a screen. + * Needs some review, and adding more options. + */ + + /*CONSTCOND*/ + while (1) { + static char *screen_opts[] = { + "Add a new screen to layout", + "Remove screen from layout", + "Finish layout configuration", + }; + + ClearScreen(); + refresh(); + i = DialogMenu("Layout configuration", "Please choose one option:", + 12, 60, 3, sizeof(screen_opts) / sizeof(screen_opts[0]), + screen_opts, " Done ", " Cancel all changes ", 2); + + /* cancel */ + if (i < 0) { + XtFree(identifier); + FreeLayout(layout); + return (-1); + } + + /* add new screen */ + else if (i == 0) { + nlist = 0; + list = NULL; + screens = NULL; + screen = XF86Config->conf_screen_lst; + while (screen) { + adj = layout->lay_adjacency_lst; + while (adj) { + if (adj->adj_screen == screen) + break; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + if (adj == NULL) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens, + (nlist + 1) * sizeof(XF86ConfScreenPtr)); + /* NOT duplicated */ + list[nlist] = screen->scrn_identifier; + screens[nlist] = screen; + ++nlist; + } + screen = (XF86ConfScreenPtr)(screen->list.next); + } + + if (nlist == 0) + continue; + + ClearScreen(); + refresh(); + i = DialogMenu("Layout add screen", "Choose screen to add:", + 12, 60, 3, nlist, list, + " Add ", " Cancel ", 0); + if (i >= 0) { + padj = layout->lay_adjacency_lst; + adj = (XF86ConfAdjacencyPtr) + XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = screens[i]; + if (padj == NULL) { + adj->adj_where = CONF_ADJ_ABSOLUTE; + layout->lay_adjacency_lst = adj; + } + else { + while (padj->list.next) + padj = (XF86ConfAdjacencyPtr)(padj->list.next); + padj->list.next = adj; + adj->adj_where = CONF_ADJ_RIGHTOF; + adj->adj_refscreen = + XtNewString(padj->adj_screen->scrn_identifier); + } + } + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + } + + /* remove a screen */ + else if (i == 1) { + nlist = 0; + list = NULL; + screens = NULL; + adj = layout->lay_adjacency_lst; + + while (adj) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens, + (nlist + 1) * sizeof(XF86ConfScreenPtr)); + list[nlist] = adj->adj_screen->scrn_identifier; + screens[nlist] = adj->adj_screen; + ++nlist; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + + if (nlist == 0) + continue; + + ClearScreen(); + refresh(); + i = DialogMenu("Layout remove screen", "Choose screen to remove:", + 12, 60, 3, nlist, list, + " Remove ", " Cancel ", 0); + + adj = padj = layout->lay_adjacency_lst; + while (adj) { + if (adj->adj_screen == screens[i]) { + padj = (XF86ConfAdjacencyPtr)(padj->list.next); + if (padj && adj->adj_where == CONF_ADJ_RIGHTOF && + padj->adj_where == CONF_ADJ_RIGHTOF) { + XtFree(padj->adj_refscreen); + padj->adj_refscreen = XtNewString(adj->adj_refscreen); + } + xf86removeAdjacency(layout, adj); + break; + } + padj = adj; + adj = (XF86ConfAdjacencyPtr)(padj->list.next); + } + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + } + + /* finish screen configuration */ + else + break; + } + +LayoutFinish: + if (layout->lay_adjacency_lst == NULL) { + adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = XF86Config->conf_screen_lst; + adj->adj_screen_str = XtNewString(XF86Config->conf_screen_lst->scrn_identifier); + adj->adj_where = CONF_ADJ_ABSOLUTE; + layout->lay_adjacency_lst = adj; + } + if (rlayout) { + /* just edited this layout */ + if (nmouses > 1 || nkeyboards > 1) { + XF86ConfAdjacencyPtr tadj = rlayout->lay_adjacency_lst; + XF86ConfInactivePtr tinac = rlayout->lay_inactive_lst; + XF86ConfInputrefPtr tinp = rlayout->lay_input_lst; + + rlayout->lay_adjacency_lst = layout->lay_adjacency_lst; + rlayout->lay_inactive_lst = layout->lay_inactive_lst; + rlayout->lay_input_lst = layout->lay_input_lst; + + layout->lay_adjacency_lst = tadj; + layout->lay_inactive_lst = tinac; + layout->lay_input_lst = tinp; + FreeLayout(layout); + } + return (0); + } + else { + layout->lay_identifier = identifier; + XF86Config->conf_layout_lst = + xf86addLayout(XF86Config->conf_layout_lst, layout); + } + + return (1); +} + +static void +ClearScreen(void) +{ + int i, j; + + wattrset(stdscr, screen_attr); + for (i = 0; i < LINES; i++) { + wmove(stdscr, i, 0); + for (j = 0; j < COLS; j++) + waddch(stdscr, ACS_PLUS); + } + touchwin(stdscr); +} + +static int +Dialog(char *title, char * prompt, int height, int width, + char *label1, char *label2, int button) +{ + int x, x1, x2, y, key, l1len, l2len; + WINDOW *dialog; + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + if (label2) + l2len = strlen(label2); + else { + l2len = button = 0; + } + + x1 = (width - (l1len + l2len)) / (label2 ? 3 : 2); + x2 = x1 + x1 + l1len; + y = height - 3; + if (!button) { + if (label2) + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + else { + PaintButton(dialog, label1, y, x1, FALSE); + if (label2) + PaintButton(dialog, label2, y, x2, TRUE); + } + wrefresh(dialog); + + /*CONSTCOND*/ + while (1) { + key = wgetch(dialog); + switch (key) { + case KEY_LEFT: + case KEY_RIGHT: + if (!button) { + if (label2) { + button = 1; + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + } + + } + else { + if (label2) { + button = 0; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + } + wrefresh(dialog); + break; + case ' ': + case '\r': + case '\n': + delwin(dialog); + return button; + } + } + /*NOTREACHED*/ +} + +static void +PaintWindow(WINDOW *win, char *title_str, int y, int x, int height, int width) +{ + int i, j; + + if (title_str != NULL) { + j = (width - strlen(title_str)) / 2 - 1; + + wattrset(win, title_attr); + wmove(win, x, y); + for (i = 0; i < j; i++) + waddch(win, ' '); + waddstr(win, title_str); + for (; i < width; i++) + waddch(win, ' '); + } + + wattrset(win, 0); + + for (i = 1; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (i == height - 1 && !j) + waddch(win, highlight_border_attr | ACS_LLCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, shadow_border_attr | ACS_LRCORNER); + else if (i == height - 1) + waddch(win, shadow_border_attr | ACS_HLINE); + else if (!j) + waddch(win, highlight_border_attr | ACS_VLINE); + else if (j == width - 1) + waddch(win, shadow_border_attr | ACS_VLINE); + else + waddch(win, dialog_attr | ' '); + } + +} + +static void +PaintBox(WINDOW *win, int y, int x, int height, int width) +{ + int i, j; + + wattrset(win, 0); + + for (i = 0; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch(win, shadow_border_attr | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch(win, shadow_border_attr | ACS_LLCORNER); + else if (!i && j == width-1) + waddch(win, highlight_border_attr | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, highlight_border_attr | ACS_LRCORNER); + else if (!i) + waddch(win, shadow_border_attr | ACS_HLINE); + else if (i == height - 1) + waddch(win, highlight_border_attr | ACS_HLINE); + else if (!j) + waddch(win, shadow_border_attr | ACS_VLINE); + else if (j == width - 1) + waddch(win, highlight_border_attr | ACS_VLINE); + else + waddch(win, dialog_attr | ' '); + } + +} + +static void +PaintButton(WINDOW *win, char *label, int y, int x, int selected) +{ + int i, temp; + + wmove(win, y, x); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, selected ? "[" : " "); + temp = strspn(label, " "); + label += temp; + wattrset(win, selected ? button_active_attr : button_inactive_attr); + for (i = 0; i < temp; i++) + waddch(win, ' '); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddch(win, label[0]); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, label + 1); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, selected ? "]" : " "); + wmove(win, y, x + temp + 1); +} + +static void +PrintWrap(WINDOW *win, char *prompt, int width, int y, int x) +{ + int cur_x, cur_y, len, yinc; + char *word, *tempstr = XtMalloc(strlen(prompt) + 1); + + cur_x = x; + cur_y = y; + + while (*prompt == '\n') { + ++cur_y; + ++prompt; + } + + strcpy(tempstr, prompt); + + for (word = strtok(tempstr, " \n"); word != NULL; word = strtok(NULL, " \n")) { + yinc = 0; + len = strlen(word); + while (prompt[word - tempstr + len + yinc] == '\n') + ++yinc; + if (cur_x + strlen(word) > width) { + cur_y++; + cur_x = x; + } + wmove(win, cur_y, cur_x); + waddstr(win, word); + getyx(win, cur_y, cur_x); + if (yinc) { + cur_y += yinc; + cur_x = x; + } + else + cur_x++; + } + + free(tempstr); +} + +static int +DialogMenu(char *title, char *prompt, int height, int width, int menu_height, + int item_no, char **items, char *label1, char *label2, int choice) +{ + int i, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, + scrlx = 0, max_choice, nscroll, max_scroll, x1, x2, l1len, l2len; + WINDOW *dialog, *menu; + + max_choice = MIN(menu_height, item_no); + max_scroll = MAX(0, item_no - max_choice); + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + l2len = strlen(label2); + + x1 = (width - (l1len + l2len)) / 3; + x2 = x1 + x1 + l1len; + + menu_width = width - 6; + getyx(dialog, cur_y, cur_x); + box_y = cur_y + 1; + box_x = (width - menu_width) / 2 - 1; + + menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + PaintBox(dialog, box_y, box_x, menu_height + 2, menu_width + 2); + + item_x = 3; + + if (choice > menu_height) { + scrlx = MIN(max_scroll, choice); + choice -= scrlx; + } + + for (i = 0; i < max_choice; i++) + PaintItem(menu, items[i + scrlx], i, i == choice); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + + x = width / 2 - 11; + y = height - 3; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + + /*CONSTCOND*/ + while (1) { + i = choice; + key = wgetch(dialog); + + if (menu_height > 1 && key == KEY_PPAGE) { + if (!choice) { + if (scrlx) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + + nscroll = max_choice > scrlx ? -scrlx : -max_choice; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + PaintItem(menu, items[i = scrlx + nscroll], 0, TRUE); + for (++i; i <= scrlx; i++) + PaintItem(menu, items[i], i - (scrlx + nscroll), FALSE); + scrlx += nscroll; + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = 0; + } + else if (menu_height > 1 && key == KEY_NPAGE) { + if (choice == max_choice - 1) { + if (scrlx < max_scroll) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + + nscroll = (scrlx + max_choice > max_scroll ? + max_scroll : scrlx + max_choice) - scrlx; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + scrlx += nscroll; + for (i = 0; i < max_choice - 1; i++) + PaintItem(menu, items[i + scrlx], i, FALSE); + PaintItem(menu, items[i + scrlx], max_choice - 1, TRUE); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = max_choice - 1; + } + else if (key == KEY_UP) { + if (!choice) { + if (scrlx) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintItem(menu, items[scrlx], 0, FALSE); + scrollok(menu, TRUE); + wscrl(menu, - 1); + scrollok(menu, FALSE); + } + scrlx--; + PaintItem(menu, items[scrlx], 0, TRUE); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = choice - 1; + } + else if (key == KEY_DOWN) { + if (choice == max_choice - 1) { + if (scrlx + choice < item_no - 1) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintItem(menu, items[scrlx + max_choice - 1], max_choice - 1, FALSE); + scrollok(menu, TRUE); + scroll(menu); + scrollok(menu, FALSE); + } + scrlx++; + PaintItem(menu, items[scrlx + max_choice - 1], max_choice - 1, TRUE); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = MIN(choice + 1, item_no - 1); + } + + if (i != choice) { + getyx(dialog, cur_y, cur_x); + PaintItem(menu, items[scrlx + choice], choice, FALSE); + + choice = i; + PaintItem(menu, items[scrlx + choice], choice, TRUE); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + continue; + } + + switch (key) { + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + if (!button) { + button = 1; + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + } + else { + button = 0; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + wrefresh(dialog); + break; + case ' ': + case '\r': + case '\n': + delwin(dialog); + return (!button ? scrlx + choice : -1); + default: + for (i = scrlx + choice + 1; i < item_no; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + if (i == item_no) { + for (i = 0; i < scrlx + choice; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + } + getyx(dialog, cur_y, cur_x); + if (i < item_no && i != scrlx + choice) { + if (i >= scrlx && i < scrlx + max_choice) { + /* it is already visible */ + PaintItem(menu, items[scrlx + choice], choice, FALSE); + choice = i - scrlx; + } + else { + scrlx = MIN(i, max_scroll); + choice = i - scrlx; + for (i = 0; i < max_choice; i++) + if (i != choice) + PaintItem(menu, items[scrlx + i], i, FALSE); + } + PaintItem(menu, items[scrlx + choice], choice, TRUE); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + } + break; + } + } + /*NOTREACHED*/ +} + +static void +PaintItem(WINDOW *win, char *item, int choice, int selected) +{ + int i; + + wattrset(win, selected ? title_attr : dialog_attr); + wmove(win, choice, 1); + for (i = 1; i < menu_width; i++) + waddch(win, ' '); + wmove(win, choice, item_x); + wattrset(win, selected ? title_attr : dialog_attr); + waddstr(win, item); +} + +static void +PaintScroller(WINDOW *win, int offset, int lenght, int visible) +{ + int i, pos; + + if (lenght > visible) + pos = (visible / (double)lenght) * offset; + else + pos = offset; + wattrset(win, shadow_border_attr); + for (i = 0; i < visible; i++) { + wmove(win, i, 0); + waddch(win, i == pos ? ACS_BLOCK : ACS_VLINE); + } +} + +static int +DialogCheckBox(char *title, char *prompt, int height, int width, int menu_height, + int item_no, char **items, char *label1, char *label2, char *checks) +{ + int i, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, + scrlx = 0, max_choice, nscroll, max_scroll, x1, x2, l1len, l2len; + WINDOW *dialog, *menu; + + max_choice = MIN(menu_height, item_no); + max_scroll = MAX(0, item_no - max_choice); + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + l2len = strlen(label2); + + x1 = (width - (l1len + l2len)) / 3; + x2 = x1 + x1 + l1len; + + menu_width = width - 6; + getyx(dialog, cur_y, cur_x); + box_y = cur_y + 1; + box_x = (width - menu_width) / 2 - 1; + + menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + PaintBox(dialog, box_y, box_x, menu_height + 2, menu_width + 2); + + item_x = 3; + + for (i = 0; i < max_choice; i++) + PaintCheckItem(menu, items[i + scrlx], i, i == 0, checks[i + scrlx]); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + + x = width / 2 - 11; + y = height - 3; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + + /*CONSTCOND*/ + while (1) { + i = choice; + key = wgetch(dialog); + + if (menu_height > 1 && key == KEY_PPAGE) { + if (!choice) { + if (scrlx) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + + nscroll = max_choice > scrlx ? -scrlx : -max_choice; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + i = scrlx + nscroll; + PaintCheckItem(menu, items[i], 0, TRUE, checks[i]); + for (++i; i <= scrlx; i++) + PaintCheckItem(menu, items[i], i - (scrlx + nscroll), FALSE, checks[i]); + scrlx += nscroll; + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = 0; + } + else if (menu_height > 1 && key == KEY_NPAGE) { + if (choice == max_choice - 1) { + if (scrlx < max_scroll) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + + nscroll = (scrlx + max_choice > max_scroll ? + max_scroll : scrlx + max_choice) - scrlx; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + scrlx += nscroll; + for (i = 0; i < max_choice - 1; i++) + PaintCheckItem(menu, items[i + scrlx], i, FALSE, checks[i + scrlx]); + PaintCheckItem(menu, items[i + scrlx], max_choice - 1, TRUE, checks[i + scrlx]); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = max_choice - 1; + } + else if (key == KEY_UP) { + if (!choice) { + if (scrlx) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintCheckItem(menu, items[scrlx], 0, FALSE, checks[scrlx]); + scrollok(menu, TRUE); + wscrl(menu, - 1); + scrollok(menu, FALSE); + } + scrlx--; + PaintCheckItem(menu, items[scrlx], 0, TRUE, checks[scrlx]); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = choice - 1; + } + else if (key == KEY_DOWN) { + if (choice == max_choice - 1) { + if (scrlx + choice < item_no - 1) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintCheckItem(menu, items[scrlx + max_choice - 1], max_choice - 1, FALSE, checks[scrlx + max_choice - 1]); + scrollok(menu, TRUE); + scroll(menu); + scrollok(menu, FALSE); + } + scrlx++; + PaintCheckItem(menu, items[scrlx + max_choice - 1], max_choice - 1, TRUE, checks[scrlx + max_choice - 1]); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = MIN(choice + 1, item_no - 1); + } + + if (i != choice) { + getyx(dialog, cur_y, cur_x); + PaintCheckItem(menu, items[scrlx + choice], choice, FALSE, checks[scrlx + choice]); + + choice = i; + PaintCheckItem(menu, items[scrlx + choice], choice, TRUE, checks[scrlx + choice]); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + continue; + } + + switch (key) { + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + if (!button) { + button = 1; + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + } + else { + button = 0; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + wrefresh(dialog); + break; + case ' ': + getyx(dialog, cur_y, cur_x); + checks[scrlx + choice] = !checks[scrlx + choice]; + PaintCheckItem(menu, items[scrlx + choice], choice, TRUE, checks[scrlx + choice]); + wmove(dialog, cur_y, cur_x); + wnoutrefresh(menu); + wrefresh(dialog); + break; + case '\r': + case '\n': + delwin(dialog); + return (!button ? 0 : -1); + default: + for (i = scrlx + choice + 1; i < item_no; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + if (i == item_no) { + for (i = 0; i < scrlx + choice; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + } + getyx(dialog, cur_y, cur_x); + if (i < item_no && i != scrlx + choice) { + if (i >= scrlx && i < scrlx + max_choice) { + /* it is already visible */ + PaintCheckItem(menu, items[scrlx + choice], choice, FALSE, checks[scrlx + choice]); + choice = i - scrlx; + } + else { + scrlx = MIN(i, max_scroll); + choice = i - scrlx; + for (i = 0; i < max_choice; i++) + if (i != choice) + PaintCheckItem(menu, items[scrlx + i], i, FALSE, checks[scrlx + i]); + } + PaintCheckItem(menu, items[scrlx + choice], choice, TRUE, checks[scrlx + choice]); + PaintScroller(menu, scrlx + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + } + break; + } + } + /*NOTREACHED*/ +} + +static void +PaintCheckItem(WINDOW *win, char *item, int choice, int selected, int checked) +{ + int i; + + wattrset(win, selected ? title_attr : dialog_attr); + wmove(win, choice, 1); + for (i = 1; i < menu_width; i++) + waddch(win, ' '); + wmove(win, choice, item_x); + wattrset(win, selected ? title_attr : dialog_attr); + wprintw(win, "[%c] ", checked ? 'X' : ' '); + waddstr(win, item); +} + +static char * +DialogInput(char *title, char *prompt, int height, int width, char *init, + char *label1, char *label2, int def_button) +{ + int i, x, y, box_y, box_x, box_width, len, + input_x = 0, scrlx = 0, key = 0, button = -1, x1, x2, l1len, l2len; + char instr[1024 + 1]; + WINDOW *dialog; + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + l2len = strlen(label2); + + x1 = (width - (l1len + l2len)) / 3; + x2 = x1 + x1 + l1len; + + box_width = width - 6; + getyx(dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + PaintBox(dialog, y + 1, box_x - 1, 3, box_width + 2); + + x = width / 2 - 11; + y = height - 3; + PaintButton(dialog, label2, y, x2, def_button == 1); + PaintButton(dialog, label1, y, x1, def_button == 0); + + memset(instr, '\0', sizeof(instr)); + wmove(dialog, box_y, box_x); + wattrset(dialog, dialog_attr); + if (init) + strncpy(instr, init, sizeof(instr) - 2); + + input_x = len = strlen(instr); + if (input_x >= box_width) { + scrlx = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scrlx + i]); + } + else + waddstr(dialog, instr); + + wmove(dialog, box_y, box_x + input_x); + + wrefresh(dialog); + + while (1) { + key = wgetch(dialog); + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + if (scrlx && !input_x) { + --scrlx; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, instr[scrlx + input_x + i] ? instr[scrlx + input_x + i] : ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + else if (input_x) { + wmove(dialog, box_y, --input_x + box_x); + wrefresh(dialog); + } + continue; + case KEY_RIGHT: + if (input_x + scrlx < len) { + if (input_x == box_width - 1) { + ++scrlx; + wmove(dialog, box_y, box_x); + for (i = scrlx; i < scrlx + box_width; i++) + waddch(dialog, instr[i] ? instr[i] : ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + else { + wmove(dialog, box_y, ++input_x + box_x); + wrefresh(dialog); + } + } + continue; + case KEY_BACKSPACE: + case 0177: +#if defined(__SCO__) || defined(__UNIXWARE__) + case '\b': +#endif + if (input_x || scrlx) { + wattrset(dialog, dialog_attr); + + if (scrlx + input_x < len) + memmove(instr + scrlx + input_x - 1, + instr + scrlx + input_x, + len - (scrlx + input_x)); + instr[--len] = '\0'; + + if (!input_x) { + scrlx = scrlx < box_width - 1 ? 0 : scrlx - (box_width - 1); + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, instr[scrlx + input_x + i] ? instr[scrlx + input_x + i] : ' '); + input_x = len - scrlx; + } + else { + wmove(dialog, box_y, --input_x + box_x); + for (i = scrlx + input_x; i < len && + i < scrlx + box_width; i++) + waddch(dialog, instr[i]); + if (i < scrlx + box_width) + waddch(dialog, ' '); + } + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + continue; + case KEY_HOME: + case CONTROL_A: + wmove(dialog, box_y, box_x); + if (scrlx != 0) { + scrlx = 0; + for (i = 0; i < box_width; i++) + waddch(dialog, instr[i] ? instr[i] : ' '); + } + input_x = 0; + wmove(dialog, box_y, box_x); + wrefresh(dialog); + break; + case CONTROL_D: + if (input_x + scrlx < len) { + memmove(instr + scrlx + input_x, + instr + scrlx + input_x + 1, + len - (scrlx + input_x)); + instr[--len] = '\0'; + for (i = scrlx + input_x; i < len && + i < scrlx + box_width; i++) + waddch(dialog, instr[i]); + if (i < scrlx + box_width) + waddch(dialog, ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + break; + case CONTROL_E: + case KEY_END: + if (box_width + scrlx < len) { + input_x = box_width - 1; + scrlx = len - box_width + 1; + wmove(dialog, box_y, box_x); + for (i = scrlx; i < scrlx + box_width; i++) + waddch(dialog, instr[i] ? instr[i] : ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + else { + input_x = len - scrlx; + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + break; + case CONTROL_K: + if (len) { + for (i = input_x; i < box_width; i++) + waddch(dialog, ' '); + for (i = scrlx + input_x; i < len; i++) + instr[i] = '\0'; + len = scrlx + input_x; + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + } + break; + default: + if (key < 0x100 && isprint(key)) { + if (scrlx + input_x < sizeof(instr) - 1) { + wattrset(dialog, dialog_attr); + if (scrlx + input_x < len) { + memmove(instr + scrlx + input_x + 1, + instr + scrlx + input_x, + len - (scrlx + input_x)); + } + instr[scrlx + input_x] = key; + instr[++len] = '\0'; + if (input_x == box_width - 1) { + scrlx++; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scrlx + i]); + } + else { + wmove(dialog, box_y, input_x++ + box_x); + for (i = scrlx + input_x - 1; i < len && + i < scrlx + box_width; i++) + waddch(dialog, instr[i]); + wmove(dialog, box_y, input_x + box_x); + } + wrefresh(dialog); + } + else + flash(); /* Alarm user about overflow */ + continue; + } + } + } + + switch (key) { + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Cancel" button is selected */ + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + wrefresh(dialog); + break; + case 0: + button = -1; /* Indicates input box is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + break; + case 0: + button = 1; /* Indicates "Cancel" button is selected */ + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + wrefresh(dialog); + break; + case 1: + button = -1; /* Indicates input box is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + } + break; + case ' ': + case '\r': + case '\n': + delwin(dialog); + return (button != 1 ? XtNewString(instr) : NULL); + } + } +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/up.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/up.xbm new file mode 100644 index 000000000..64f8f9ec4 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/up.xbm @@ -0,0 +1,8 @@ +#define up_width 19 +#define up_height 19 +static unsigned char up_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x07, 0x00, 0x80, 0x0f, 0x00, 0xc0, 0x1f, 0x00, 0xe0, 0x3f, 0x00, + 0xf0, 0x7f, 0x00, 0xf8, 0xff, 0x00, 0xfc, 0xff, 0x01, 0x80, 0x0f, 0x00, + 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x0f, 0x00, + 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/vidmode.c b/xorg-server/hw/xfree86/utils/xorgcfg/vidmode.c new file mode 100644 index 000000000..2d613b6df --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/vidmode.c @@ -0,0 +1,1346 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +/* + * Most of the code here is based on the xvidtune code. + */ + +#include "vidmode.h" +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/Repeater.h> +#include <X11/Shell.h> +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Dialog.h> +#include <X11/Xaw/SimpleMenP.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/Toggle.h> +#include "xf86config.h" + +#define V_FLAG_MASK 0x1FF +#define V_PHSYNC 0x001 +#define V_NHSYNC 0x002 +#define V_PVSYNC 0x004 +#define V_NVSYNC 0x008 +#define V_INTERLACE 0x010 +#define V_DBLSCAN 0x020 +#define V_CSYNC 0x040 +#define V_PCSYNC 0x080 +#define V_NCSYNC 0x100 + +#define LEFT 0 +#define RIGHT 1 +#define UP 2 +#define DOWN 3 +#define WIDER 4 +#define TALLER 5 +#define NARROWER 6 +#define SHORTER 7 + +#define HDISPLAY 0 +#define VDISPLAY 1 +#define HSYNCSTART 2 +#define HSYNCEND 3 +#define HTOTAL 4 +#define VSYNCSTART 5 +#define VSYNCEND 6 +#define VTOTAL 7 +#define FLAGS 8 +#define CLOCK 9 +#define HSYNC 10 +#define VSYNC 11 + +#define MINMAJOR 2 +#define MINMINOR 0 + +/* + * Types + */ +typedef struct { + char *ident; + XF86VidModeModeInfo info; +} xf86cfgVesaModeInfo; + +/* + * Prototypes + */ +static Bool GetModeLine(Bool); +static void StartAdjustMonitorCallback(Widget, XtPointer, XtPointer); +static void AdjustMonitorCallback(Widget, XtPointer, XtPointer); +static void EndAdjustMonitorCallback(Widget, XtPointer, XtPointer); +static void SetLabel(int, int); +static void UpdateSyncRates(Bool); +static int VidmodeError(Display*, XErrorEvent*); +static void CleanUp(Display*); +static void ApplyCallback(Widget, XtPointer, XtPointer); +static void AutoCallback(Widget, XtPointer, XtPointer); +static void RestoreCallback(Widget, XtPointer, XtPointer); +static void SelectCallback(Widget, XtPointer, XtPointer); +static void SelectMonitorCallback(Widget, XtPointer, XtPointer); +static void SwitchCallback(Widget, XtPointer, XtPointer); +static void SetLabels(void); +static void UpdateCallback(Widget, XtPointer, XtPointer); +static void ChangeScreenCallback(Widget, XtPointer, XtPointer); +static void SetLabelAndModeline(void); +static void AddVesaModeCallback(Widget, XtPointer, XtPointer); +static void GetModes(void); +static void AddModeCallback(Widget, XtPointer, XtPointer); +static void TestCallback(Widget, XtPointer, XtPointer); +static void TestTimeout(XtPointer, XtIntervalId*); +static void StopTestCallback(Widget, XtPointer, XtPointer); +static int ForceAddMode(void); +static int AddMode(void); +/* + * Initialization + */ +extern Widget work; +Widget vtune; +static Widget apply, automatic, restore, mode, menu, screenb, screenp; +static Bool autoflag; +static xf86cfgVidmode *vidtune; +static XF86VidModeModeLine modeline, orig_modeline; +static int dot_clock, hsync_rate, vsync_rate, hitError; +static int screenno; +static int (*XtErrorFunc)(Display*, XErrorEvent*); +static Widget values[VSYNC + 1], repeater, monitor, + monitorb, add, text, vesap, forceshell, testshell, addshell; +static int MajorVersion, MinorVersion, EventBase, ErrorBase; +static XtIntervalId timeout; + +/* The information bellow is extracted from + * xc/programs/Xserver/hw/xfree86/etc/vesamodes + * If that file is changed, please update the table bellow also. Or even + * better, write a script to generate the table. + */ +static xf86cfgVesaModeInfo vesamodes[] = { + { + "640x350 @ 85Hz (VESA) hsync: 37.9kHz", + { + 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, + V_PHSYNC | V_NVSYNC + } + }, + { + "640x400 @ 85Hz (VESA) hsync: 37.9kHz", + { + 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, + V_NHSYNC | V_PVSYNC + } + }, + { + "720x400 @ 85Hz (VESA) hsync: 37.9kHz", + { + 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, + V_NHSYNC | V_PVSYNC + } + }, + { + "640x480 @ 60Hz (Industry standard) hsync: 31.5kHz", + { + 25200, 640, 656, 752, 800, 0, 480, 490, 492, 525, + V_NHSYNC | V_NVSYNC + } + }, + { + "640x480 @ 72Hz (VESA) hsync: 37.9kHz", + { + 31500, 640, 664, 704, 832, 0, 480, 489, 491, 520, + V_NHSYNC | V_NVSYNC + } + }, + { + "640x480 @ 75Hz (VESA) hsync: 37.5kHz", + { + 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, + V_NHSYNC | V_NVSYNC + } + }, + { + "640x480 @ 85Hz (VESA) hsync: 43.3kHz", + { + 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, + V_NHSYNC | V_NVSYNC + } + }, + { + "800x600 @ 56Hz (VESA) hsync: 35.2kHz", + { + 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, + V_PHSYNC | V_PVSYNC + } + }, + { + "800x600 @ 60Hz (VESA) hsync: 37.9kHz", + { + 400000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, + V_PHSYNC | V_PVSYNC + } + }, + { + "800x600 @ 72Hz (VESA) hsync: 48.1kHz", + { + 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, + V_PHSYNC | V_PVSYNC + } + }, + { + "800x600 @ 75Hz (VESA) hsync: 46.9kHz", + { + 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, + V_PHSYNC | V_PVSYNC + } + }, + { + "800x600 @ 85Hz (VESA) hsync: 53.7kHz", + { + 563000, 800, 832, 896, 1048, 0, 600, 601, 604, 631, + V_PHSYNC | V_PVSYNC + } + }, + { + "1024x768i @ 43Hz (industry standard) hsync: 35.5kHz", + { + 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 776, 817, + V_PHSYNC | V_PVSYNC | V_INTERLACE + } + }, + { + "1024x768 @ 60Hz (VESA) hsync: 48.4kHz", + { + 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, + V_NHSYNC | V_NVSYNC + } + }, + { + "1024x768 @ 70Hz (VESA) hsync: 56.5kHz", + { + 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, + V_NHSYNC | V_NVSYNC + } + }, + { + "1024x768 @ 75Hz (VESA) hsync: 60.0kHz", + { + 78800, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, + V_PHSYNC | V_PVSYNC + } + }, + { + "1024x768 @ 85Hz (VESA) hsync: 68.7kHz", + { + 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, + V_PHSYNC | V_PVSYNC + } + }, + { + "1152x864 @ 75Hz (VESA) hsync: 67.5kHz", + { + 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, + V_PHSYNC | V_PVSYNC + } + }, + { + "1280x960 @ 60Hz (VESA) hsync: 60.0kHz", + { + 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, + V_PHSYNC | V_PVSYNC + } + }, + { + "1280x960 @ 85Hz (VESA) hsync: 85.9kHz", + { + 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, + V_PHSYNC | V_PVSYNC + } + }, + { + "1280x1024 @ 60Hz (VESA) hsync: 64.0kHz", + { + 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, + V_PHSYNC | V_PVSYNC + } + }, + { + "1280x1024 @ 75Hz (VESA) hsync: 80.0kHz", + { + 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, + V_PHSYNC | V_PVSYNC + } + }, + { + "1280x1024 @ 85Hz (VESA) hsync: 91.1kHz", + { + 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, + V_PHSYNC | V_PVSYNC + } + }, + { + "1600x1200 @ 60Hz (VESA) hsync: 75.0kHz", + { + 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, + V_PHSYNC | V_PVSYNC + } + }, + { + "1600x1200 @ 65Hz (VESA) hsync: 81.3kHz", + { + 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, + V_PHSYNC | V_PVSYNC + } + }, + { + "1600x1200 @ 70Hz (VESA) hsync: 87.5kHz", + { + 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, + V_PHSYNC | V_PVSYNC + } + }, + { + "1600x1200 @ 75Hz (VESA) hsync: 93.8kHz", + { + 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, + V_PHSYNC | V_PVSYNC + } + }, + { + "1600x1200 @ 85Hz (VESA) hsync: 106.3kHz", + { + 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, + V_PHSYNC | V_PVSYNC + } + }, + { + "1792x1344 @ 60Hz (VESA) hsync: 83.6kHz", + { + 204800, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, + V_NHSYNC | V_PVSYNC + } + }, + { + "1792x1344 @ 75Hz (VESA) hsync: 106.3kHz", + { + 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, + V_NHSYNC | V_PVSYNC + } + }, + { + "1856x1392 @ 60Hz (VESA) hsync: 86.3kHz", + { + 218300, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, + V_NHSYNC | V_PVSYNC + } + }, + { + "1856x1392 @ 75Hz (VESA) hsync: 112.5kHz", + { + 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, + V_NHSYNC | V_PVSYNC + } + }, + { + "1920x1440 @ 60Hz (VESA) hsync: 90.0kHz", + { + 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, + V_NHSYNC | V_PVSYNC + } + }, + { + "1920x1440 @ 75Hz (VESA) hsync: 112.5kHz", + { + 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, + V_NHSYNC | V_PVSYNC + } + }, +}; + +/* + * Implementation + */ +Bool +VideoModeInitialize(void) +{ + Widget form; + char dispstr[128], *ptr, *tmp; + + static char *names[] = { + NULL, + NULL, + "hsyncstart", + "hsyncend", + "htotal", + "vsyncstart", + "vsyncend", + "vtotal", + "flags", + "clock", + "hsync", + "vsync", + }; + static char *vnames[] = { + NULL, + NULL, + "v-hsyncstart", + "v-hsyncend", + "v-htotal", + "v-vsyncstart", + "v-vsyncend", + "v-vtotal", + "v-flags", + "v-clock", + "v-hsync", + "v-vsync", + }; + Widget rep; + int i; + + if (!XF86VidModeQueryVersion(XtDisplay(toplevel), + &MajorVersion, &MinorVersion)) { + fprintf(stderr, "Unable to query video extension version\n"); + return (False); + } + else if (!XF86VidModeQueryExtension(XtDisplay(toplevel), + &EventBase, &ErrorBase)) { + fprintf(stderr, "Unable to query video extension information\n"); + return (False); + } + else if (MajorVersion < MINMAJOR || + (MajorVersion == MINMAJOR && MinorVersion < MINMINOR)) { + fprintf(stderr, + "Xserver is running an old XFree86-VidModeExtension version" + " (%d.%d)\n", MajorVersion, MinorVersion); + fprintf(stderr, "Minimum required version is %d.%d\n", + MINMAJOR, MINMINOR); + return (False); + } + else + InitializeVidmodes(); + + vtune = XtCreateWidget("vidtune", formWidgetClass, + work, NULL, 0); + + (void) XtVaCreateManagedWidget("vesaB", menuButtonWidgetClass, vtune, + XtNmenuName, "vesaP", NULL); + vesap = XtCreatePopupShell("vesaP", simpleMenuWidgetClass, vtune, NULL, 0); + for (i = 0; i < sizeof(vesamodes) / sizeof(vesamodes[0]); i++) { + rep = XtCreateManagedWidget(vesamodes[i].ident, smeBSBObjectClass, + vesap, NULL, 0); + XtAddCallback(rep, XtNcallback, AddVesaModeCallback, + (XtPointer)&vesamodes[i]); + } + + rep = XtCreateManagedWidget("prev", commandWidgetClass, vtune, NULL, 0); + XtAddCallback(rep, XtNcallback, SwitchCallback, (XtPointer)-1); + mode = XtCreateManagedWidget("mode", menuButtonWidgetClass, vtune, NULL, 0); + rep = XtCreateManagedWidget("next", commandWidgetClass, vtune, NULL, 0); + XtAddCallback(rep, XtNcallback, SwitchCallback, (XtPointer)1); + + screenp = XtCreatePopupShell("screenP", simpleMenuWidgetClass, vtune, + NULL, 0); + + XmuSnprintf(dispstr, sizeof(dispstr), "%s", + DisplayString(XtDisplay(toplevel))); + ptr = strrchr(dispstr, '.'); + tmp = strrchr(dispstr, ':'); + if (tmp != NULL && ptr != NULL && ptr > tmp) + *ptr = '\0'; + + for (i = 0; i < ScreenCount(XtDisplay(toplevel)); i++) { + char name[128]; + + XmuSnprintf(name, sizeof(name), "%s.%d", dispstr, i); + rep = XtCreateManagedWidget(name, smeBSBObjectClass, screenp, + NULL, 0); + XtAddCallback(rep, XtNcallback, ChangeScreenCallback, + (XtPointer)(long)i); + if (i == 0) { + screenb = XtVaCreateManagedWidget("screenB", menuButtonWidgetClass, + vtune, + XtNmenuName, "screenP", + XtNlabel, name, + NULL); + } + } + XtRealizeWidget(screenp); + + rep = XtCreateManagedWidget("up", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)UP); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + rep = XtCreateManagedWidget("left", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)LEFT); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + XtCreateManagedWidget("monitor", simpleWidgetClass, vtune, NULL, 0); + rep = XtCreateManagedWidget("right", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)RIGHT); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + rep = XtCreateManagedWidget("down", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)DOWN); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + rep = XtCreateManagedWidget("wider", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)WIDER); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + rep = XtCreateManagedWidget("narrower", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)NARROWER); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + rep = XtCreateManagedWidget("shorter", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)SHORTER); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + rep = XtCreateManagedWidget("taller", repeaterWidgetClass, + vtune, NULL, 0); + XtAddCallback(rep, XtNstartCallback, StartAdjustMonitorCallback, NULL); + XtAddCallback(rep, XtNcallback, + AdjustMonitorCallback, (XtPointer)TALLER); + XtAddCallback(rep, XtNstopCallback, EndAdjustMonitorCallback, NULL); + + automatic = XtCreateManagedWidget("auto", toggleWidgetClass, vtune, NULL, 0); + XtAddCallback(automatic, XtNcallback, AutoCallback, NULL); + apply = XtCreateManagedWidget("apply", commandWidgetClass, vtune, NULL, 0); + XtAddCallback(apply, XtNcallback, ApplyCallback, NULL); + restore = XtCreateManagedWidget("restore", commandWidgetClass, vtune, NULL, 0); + XtAddCallback(restore, XtNcallback, RestoreCallback, NULL); + rep = XtCreateManagedWidget("update", commandWidgetClass, vtune, NULL, 0); + XtAddCallback(rep, XtNcallback, UpdateCallback, NULL); + rep = XtCreateManagedWidget("test", commandWidgetClass, vtune, NULL, 0); + XtAddCallback(rep, XtNcallback, TestCallback, NULL); + + form = XtCreateManagedWidget("form", formWidgetClass, vtune, NULL, 0); + for (i = 2; i < VSYNC + 1; i++) { + (void) XtCreateManagedWidget(names[i], labelWidgetClass, + form, NULL, 0); + values[i] = XtCreateManagedWidget(vnames[i], labelWidgetClass, + form, NULL, 0); + } + + add = XtCreateManagedWidget("add", commandWidgetClass, vtune, NULL, 0); + XtAddCallback(add, XtNcallback, AddModeCallback, NULL); + XtCreateManagedWidget("addto", labelWidgetClass, vtune, NULL, 0); + monitorb = XtCreateManagedWidget("ident", menuButtonWidgetClass, vtune, + NULL, 0); + XtCreateManagedWidget("as", labelWidgetClass, vtune, NULL, 0); + text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, vtune, + XtNeditType, XawtextEdit, NULL); + + XtRealizeWidget(vtune); + + return (True); +} + +void +InitializeVidmodes(void) +{ + int i; + Display *display = XtDisplay(toplevel); + + computer.num_vidmodes = ScreenCount(display); + computer.vidmodes = (xf86cfgVidmode**) + XtMalloc(sizeof(xf86cfgVidmode*) * computer.num_vidmodes); + for (i = 0; i < computer.num_vidmodes; i++) { + + computer.vidmodes[i] = (xf86cfgVidmode*) + XtCalloc(1, sizeof(xf86cfgVidmode)); + computer.vidmodes[i]->screen = i; + } +} + +void +VideoModeConfigureStart(void) +{ + vidtune = computer.vidmodes[screenno]; + + XtSetSensitive(vtune, vidtune != NULL); + if (!XtIsManaged(vtune)) + XtManageChild(vtune); + else + XtMapWidget(vtune); + if (vidtune != NULL) { + Arg args[1]; + Boolean state; + XF86ConfMonitorPtr mon; + static char menuName[16]; + static int menuN; + + XtErrorFunc = XSetErrorHandler(VidmodeError); + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, True); + GetModeLine(True); + GetModes(); + + SetLabels(); + XtSetArg(args[0], XtNstate, &state); + XtGetValues(automatic, args, 1); + XtSetSensitive(apply, !state); + autoflag = state; + + if (monitor) + XtDestroyWidget(monitor); + XmuSnprintf(menuName, sizeof(menuName), "menuP%d", menuN); + menuN = !menuN; + monitor = XtCreatePopupShell(menuName, simpleMenuWidgetClass, + vtune, NULL, 0); + XtVaSetValues(monitorb, XtNmenuName, menuName, NULL); + + mon = XF86Config->conf_monitor_lst; + while (mon != NULL) { + Widget sme = XtCreateManagedWidget(mon->mon_identifier, + smeBSBObjectClass, + monitor, NULL, 0); + XtAddCallback(sme, XtNcallback, + SelectMonitorCallback, (XtPointer)mon); + + /* guess the monitor at a given screen and/or + * updates configuration if a monitor was removed from the + * configuration. + */ + if (XF86Config->conf_layout_lst) { + XF86ConfAdjacencyPtr adj = XF86Config->conf_layout_lst-> + lay_adjacency_lst; + + while (adj != NULL) { + if (adj->adj_screen != NULL) { + if (adj->adj_screen->scrn_monitor == mon && + adj->adj_scrnum >= 0 && + adj->adj_scrnum < ScreenCount(XtDisplay(toplevel))) { + if (computer.vidmodes[adj->adj_scrnum]->monitor == + NULL || computer.vidmodes[adj->adj_scrnum]-> + monitor == adj->adj_screen->scrn_monitor) { + computer.vidmodes[adj->adj_scrnum]->monitor = + adj->adj_screen->scrn_monitor; + break; + } + else + computer.vidmodes[adj->adj_scrnum]->monitor = + NULL; + } + } + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + } + mon = (XF86ConfMonitorPtr)(mon->list.next); + } + SetLabelAndModeline(); + } +} + +void +VideoModeConfigureEnd(void) +{ + XtUnmapWidget(vtune); + if (vidtune != NULL) { + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, False); + XSetErrorHandler(XtErrorFunc); + } + vidtune = NULL; +} + +static void +SetLabelAndModeline(void) +{ + if (vidtune->monitor != NULL) { + char string[32]; + + XtVaSetValues(monitorb, XtNlabel, + vidtune->monitor->mon_identifier, NULL); + XtSetSensitive(add, True); + + if (modeline.htotal && modeline.vtotal) + XmuSnprintf(string, sizeof(string), "%dx%d@%d", + modeline.hdisplay, modeline.vdisplay, + (int)((double)dot_clock / (double)modeline.htotal * 1000.0 / + (double)modeline.vtotal)); + else + XmuSnprintf(string, sizeof(string), "%dx%d", + modeline.hdisplay, modeline.vdisplay); + XtVaSetValues(text, XtNstring, string, NULL); + } + else { + XtVaSetValues(monitorb, XtNlabel, "", NULL); + XtSetSensitive(add, False); + XtVaSetValues(text, XtNstring, "", NULL); + } +} + +/*ARGSUSED*/ +void +VidmodeRestoreAction(Widget w, XEvent *event, + String *params, Cardinal *num_params) +{ + if (vidtune != NULL) { + if (timeout != 0) + StopTestCallback(w, NULL, NULL); + else + RestoreCallback(w, NULL, NULL); + } +} + +static void +UpdateSyncRates(Bool update) +{ + if (modeline.htotal && modeline.vtotal) { + hsync_rate = (dot_clock * 1000) / modeline.htotal; + vsync_rate = (hsync_rate * 1000) / modeline.vtotal; + if (modeline.flags & V_INTERLACE) + vsync_rate *= 2; + else if (modeline.flags & V_DBLSCAN) + vsync_rate /= 2; + if (update) { + SetLabel(HSYNC, hsync_rate); + SetLabel(VSYNC, vsync_rate); + } + } +} + +static void +SetLabel(int ident, int value) +{ + Arg args[1]; + char label[256]; + + if (ident == FLAGS) { + int len = 0; + + *label = '\0'; + if (value & V_PHSYNC) + len += XmuSnprintf(label, sizeof(label), "%s", "+hsync"); + if (modeline.flags & V_NHSYNC) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "-hsync"); + if (value & V_PVSYNC) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "+vsync"); + if (value & V_NVSYNC) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "-vsync"); + if (value & V_INTERLACE) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "interlace"); + if (value & V_CSYNC) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "composite"); + if (value & V_PCSYNC) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "+csync"); + if (value & V_NCSYNC) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "-csync"); + if (value & V_DBLSCAN) + len += XmuSnprintf(label + len, sizeof(label), "%s%s", + len ? " " : "", "doublescan"); + + } + else if (ident == CLOCK || ident == HSYNC || ident == VSYNC) + XmuSnprintf(label, sizeof(label), "%6.2f", (float)value / 1000.0); + else + XmuSnprintf(label, sizeof(label), "%d", value); + + XtSetArg(args[0], XtNlabel, label); + XtSetValues(values[ident], args, 1); +} + +/*ARGSUSED*/ +static void +StartAdjustMonitorCallback(Widget w, XtPointer client_data, XtPointer call_data) +{ + repeater = w; +} + +static void +AdjustMonitorCallback(Widget w, XtPointer client_data, XtPointer call_data) +{ + if (repeater != w) + return; + switch ((long)client_data) { + case LEFT: + if (modeline.hsyncend + 4 < modeline.htotal) { + modeline.hsyncstart += 4; + modeline.hsyncend += 4; + SetLabel(HSYNCSTART, modeline.hsyncstart); + SetLabel(HSYNCEND, modeline.hsyncend); + } + else + XBell(XtDisplay(w), 80); + break; + case RIGHT: + if (modeline.hsyncstart - 4 > modeline.hdisplay) { + modeline.hsyncstart -= 4; + modeline.hsyncend -= 4; + SetLabel(HSYNCSTART, modeline.hsyncstart); + SetLabel(HSYNCEND, modeline.hsyncend); + } + else + XBell(XtDisplay(w), 80); + break; + case NARROWER: + modeline.htotal += 4; + SetLabel(HTOTAL, modeline.htotal); + UpdateSyncRates(True); + break; + case WIDER: + if (modeline.htotal - 4 > modeline.hsyncend) { + modeline.htotal -= 4; + SetLabel(HTOTAL, modeline.htotal); + UpdateSyncRates(True); + } + else + XBell(XtDisplay(w), 80); + break; + case UP: + if (modeline.vsyncend + 4 < modeline.vtotal) { + modeline.vsyncstart += 4; + modeline.vsyncend += 4; + SetLabel(VSYNCSTART, modeline.vsyncstart); + SetLabel(VSYNCEND, modeline.vsyncend); + } + else + XBell(XtDisplay(w), 80); + break; + case DOWN: + if (modeline.vsyncstart - 4 > modeline.vdisplay) { + modeline.vsyncstart -= 4; + modeline.vsyncend -= 4; + SetLabel(VSYNCSTART, modeline.vsyncstart); + SetLabel(VSYNCEND, modeline.vsyncend); + } + else + XBell(XtDisplay(w), 80); + break; + case SHORTER: + modeline.vtotal += 4; + SetLabel(VTOTAL, modeline.vtotal); + UpdateSyncRates(True); + break; + case TALLER: + if (modeline.vtotal - 4 > modeline.vsyncend) { + modeline.vtotal -= 4; + SetLabel(VTOTAL, modeline.vtotal); + UpdateSyncRates(True); + } + else + XBell(XtDisplay(w), 80); + break; + } + + if (autoflag) + ApplyCallback(w, call_data, client_data); +} + +/*ARGSUSED*/ +static void +EndAdjustMonitorCallback(Widget w, XtPointer client_data, XtPointer call_data) +{ + repeater = NULL; +} + +static Bool +GetModeLine(Bool save) +{ + if (XF86VidModeGetModeLine(XtDisplay(toplevel), vidtune->screen, + &dot_clock, &modeline)) { + if (save) + memcpy(&orig_modeline, &modeline, sizeof(XF86VidModeModeLine)); + UpdateSyncRates(False); + return (True); + } + + return (False); +} + +static void +CleanUp(Display *display) +{ + /* Make sure mode switching is not locked out at exit */ + XF86VidModeLockModeSwitch(display, vidtune->screen, False); + XFlush(display); +} + +static int +VidmodeError(Display *display, XErrorEvent *error) +{ + if ((error->error_code >= ErrorBase && + error->error_code < ErrorBase + XF86VidModeNumberErrors) || + error->error_code == BadValue) { + hitError = 1; + } + else { + CleanUp(display); + if (XtErrorFunc) + (*XtErrorFunc)(display, error); + } + return (0); +} + +/*ARGSUSED*/ +static void +ApplyCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + hitError = 0; + XF86VidModeModModeLine(XtDisplay(w), vidtune->screen, &modeline); + XSync(XtDisplay(w), False); + if (hitError) { + if (repeater != NULL) { + XtCallActionProc(repeater, "unset", NULL, NULL, 0); + XtCallActionProc(repeater, "stop", NULL, NULL, 0); + repeater = NULL; + } + XBell(XtDisplay(w), 80); + if (timeout) + StopTestCallback(w, NULL, NULL); + GetModeLine(False); + SetLabels(); + } +} + +/*ARGSUSED*/ +static void +AutoCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + autoflag = (Bool)(long)client_data; + XtSetSensitive(apply, !autoflag); +} + +static void +RestoreCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + memcpy(&modeline, &orig_modeline, sizeof(XF86VidModeModeLine)); + if (autoflag) + ApplyCallback(w, call_data, client_data); + SetLabels(); +} + +static void +SelectCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + XF86VidModeModeInfo *info = (XF86VidModeModeInfo*)call_data; + Arg args[1]; + Bool result; + + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, False); + result = XF86VidModeSwitchToMode(XtDisplay(toplevel), vidtune->screen, info); + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, True); + if (!result) + return; + + XtSetArg(args[0], XtNlabel, XtName(w)); + XtSetValues(mode, args, 1); + UpdateCallback(w, call_data, client_data); +} + +static void +SwitchCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + int direction = (long)call_data; + Arg args[1]; + Bool result; + char label[32]; + + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, False); + result = XF86VidModeSwitchMode(XtDisplay(toplevel), vidtune->screen, + direction); + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, True); + if (!result) + return; + + UpdateCallback(w, call_data, client_data); + + if (modeline.htotal && modeline.vtotal) + XmuSnprintf(label, sizeof(label), "%dx%d @ %d Hz", + modeline.hdisplay, modeline.vdisplay, + (int)((double)dot_clock / (double)modeline.htotal * 1000.0 / + (double)modeline.vtotal)); + else + XmuSnprintf(label, sizeof(label), "%dx%d", + modeline.hdisplay, modeline.vdisplay); + XtSetArg(args[0], XtNlabel, label); + XtSetValues(mode, args, 1); +} + +/*ARGSUSED*/ +static void +UpdateCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + GetModeLine(True); + SetLabels(); + SetLabelAndModeline(); +} + +static void +SetLabels(void) +{ + SetLabel(HSYNCSTART, modeline.hsyncstart); + SetLabel(VSYNCSTART, modeline.vsyncstart); + SetLabel(HSYNCEND, modeline.hsyncend); + SetLabel(VSYNCEND, modeline.vsyncend); + SetLabel(HTOTAL, modeline.htotal); + SetLabel(VTOTAL, modeline.vtotal); + SetLabel(FLAGS, modeline.flags); + SetLabel(CLOCK, dot_clock); + UpdateSyncRates(True); +} + +/*ARGSUSED*/ +static void +ChangeScreenCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + Arg args[1]; + + screenno = (long)call_data; + if (screenno > computer.num_vidmodes || screenno < 0 || + vidtune == computer.vidmodes[screenno]) + return; + + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, False); + vidtune = computer.vidmodes[screenno]; + XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, True); + UpdateCallback(w, call_data, client_data); + GetModes(); + + XtSetArg(args[0], XtNlabel, XtName(w)); + XtSetValues(screenb, args, 1); + + SetLabelAndModeline(); +} + +/*ARGSUSED*/ +static void +SelectMonitorCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + vidtune->monitor = (XF86ConfMonitorPtr)(call_data); + SetLabelAndModeline(); +} + +/*ARGSUSED*/ +static void +AddVesaModeCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + xf86cfgVesaModeInfo *vesa = (xf86cfgVesaModeInfo*)call_data; + XF86VidModeModeInfo mode; + int num_infos = vidtune->num_infos; + + memcpy(&mode, &vesa->info, sizeof(XF86VidModeModeInfo)); + if (XF86VidModeAddModeLine(XtDisplay(toplevel), vidtune->screen, + &vesa->info, &mode)) { + XSync(XtDisplay(toplevel), False); + GetModes(); + } + else { + XBell(XtDisplayOfObject(w), 80); + return; + } + + if (vidtune && num_infos == vidtune->num_infos) { + /* XF86VidModeAddModeLine returned True, but no modeline was added */ + XBell(XtDisplayOfObject(w), 80); + if (vidtune->monitor && AddMode()) { + XF86ConfModeLinePtr mode; + char label[256], *ptr, *str; + + XmuSnprintf(label, sizeof(label), "%s", vesa->ident); + + /* format mode name to not have spaces */ + ptr = strchr(label, ')'); + if (ptr) + *++ptr = '\0'; + ptr = str = label; + while (*ptr) { + if (*ptr != ' ') + *str++ = *ptr; + ++ptr; + } + *str = '\0'; + + if (xf86findModeLine(label, vidtune->monitor->mon_modeline_lst) + != NULL && !ForceAddMode()) + return; + + mode = (XF86ConfModeLinePtr)XtCalloc(1, sizeof(XF86ConfModeLineRec)); + mode->ml_identifier = XtNewString(label); + mode->ml_clock = vesa->info.dotclock; + mode->ml_hdisplay = vesa->info.hdisplay; + mode->ml_hsyncstart = vesa->info.hsyncstart; + mode->ml_hsyncend = vesa->info.hsyncend; + mode->ml_htotal = vesa->info.htotal; + mode->ml_vdisplay = vesa->info.vdisplay; + mode->ml_vsyncstart = vesa->info.vsyncstart; + mode->ml_vsyncend = vesa->info.vsyncend; + mode->ml_vtotal = vesa->info.vtotal; +/* mode->ml_vscan = ???;*/ + mode->ml_flags = vesa->info.flags; + mode->ml_hskew = vesa->info.hskew; + vidtune->monitor->mon_modeline_lst = + xf86addModeLine(vidtune->monitor->mon_modeline_lst, mode); + } + } +} + +static void +GetModes(void) +{ + int i; + char label[32]; + Arg args[1]; + static char menuName[16]; + static int menuN; + + XFree(vidtune->infos); + XF86VidModeGetAllModeLines(XtDisplay(toplevel), vidtune->screen, + &vidtune->num_infos, &vidtune->infos); + + XmuSnprintf(menuName, sizeof(menuName), "menu%d", menuN); + menuN = !menuN; + if (menu) + XtDestroyWidget(menu); + menu = XtCreatePopupShell(menuName, simpleMenuWidgetClass, vtune, NULL, 0); + XtVaSetValues(mode, XtNmenuName, menuName, NULL); + for (i = 0; i < vidtune->num_infos; i++) { + Widget sme; + + if ((double)vidtune->infos[i]->htotal && + (double)vidtune->infos[i]->vtotal) + XmuSnprintf(label, sizeof(label), "%dx%d @ %d Hz", + vidtune->infos[i]->hdisplay, + vidtune->infos[i]->vdisplay, + (int)((double)vidtune->infos[i]->dotclock / + (double)vidtune->infos[i]->htotal * 1000.0 / + (double)vidtune->infos[i]->vtotal)); + else + XmuSnprintf(label, sizeof(label), "%dx%d", + vidtune->infos[i]->hdisplay, + vidtune->infos[i]->vdisplay); + sme = XtCreateManagedWidget(label, smeBSBObjectClass, menu, NULL, 0); + XtAddCallback(sme, XtNcallback, SelectCallback, + (XtPointer)vidtune->infos[i]); + } + + if (modeline.htotal && modeline.vtotal) + XmuSnprintf(label, sizeof(label), "%dx%d @ %d Hz", + modeline.hdisplay, modeline.vdisplay, + (int)((double)dot_clock / (double)modeline.htotal * 1000.0 / + (double)modeline.vtotal)); + else + XmuSnprintf(label, sizeof(label), "%dx%d", + modeline.hdisplay, modeline.vdisplay); + XtSetArg(args[0], XtNlabel, label); + XtSetValues(mode, args, 1); +} + +static int do_force, asking_force; + +static void +PopdownForce(Widget w, XtPointer user_data, XtPointer call_data) +{ + asking_force = 0; + XtPopdown(forceshell); + do_force = (long)user_data; +} + +static int +ForceAddMode(void) +{ + if (forceshell == NULL) { + Widget dialog; + + forceshell = XtCreatePopupShell("force", transientShellWidgetClass, + toplevel, NULL, 0); + dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass, + forceshell, XtNvalue, NULL, NULL); + XawDialogAddButton(dialog, "yes", PopdownForce, (XtPointer)True); + XawDialogAddButton(dialog, "no", PopdownForce, (XtPointer)False); + XtRealizeWidget(forceshell); + XSetWMProtocols(DPY, XtWindow(forceshell), &wm_delete_window, 1); + } + + asking_force = 1; + + XtPopup(forceshell, XtGrabExclusive); + while (asking_force) + XtAppProcessEvent(XtWidgetToApplicationContext(forceshell), XtIMAll); + + return (do_force); +} + +static int do_add, asking_add; + +static void +PopdownAdd(Widget w, XtPointer user_data, XtPointer call_data) +{ + asking_add = 0; + XtPopdown(addshell); + do_add = (long)user_data; +} + +void +CancelAddModeAction(Widget w, XEvent *event, + String *params, Cardinal *num_params) +{ + if (asking_force) + PopdownForce(w, (XtPointer)False, NULL); + else if (asking_add) + PopdownAdd(w, (XtPointer)False, NULL); +} + +static int +AddMode(void) +{ + if (addshell == NULL) { + Widget dialog; + + addshell = XtCreatePopupShell("addMode", transientShellWidgetClass, + toplevel, NULL, 0); + dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass, + addshell, XtNvalue, NULL, NULL); + XawDialogAddButton(dialog, "yes", PopdownAdd, (XtPointer)True); + XawDialogAddButton(dialog, "no", PopdownAdd, (XtPointer)False); + XtRealizeWidget(addshell); + XSetWMProtocols(DPY, XtWindow(addshell), &wm_delete_window, 1); + } + + asking_add = 1; + + XtPopup(addshell, XtGrabExclusive); + while (asking_add) + XtAppProcessEvent(XtWidgetToApplicationContext(addshell), XtIMAll); + + return (do_add); +} + +/*ARGSUSED*/ +static void +AddModeCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + if (vidtune && vidtune->monitor) { + char *label; + Arg args[1]; + XF86ConfModeLinePtr mode; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(text, args, 1); + if (*label == '\0') { + XBell(XtDisplay(w), 80); + return; + } + if (xf86findModeLine(label, vidtune->monitor->mon_modeline_lst) + != NULL && !ForceAddMode()) + return; + + mode = (XF86ConfModeLinePtr)XtCalloc(1, sizeof(XF86ConfModeLineRec)); + mode->ml_identifier = XtNewString(label); + mode->ml_clock = dot_clock; + mode->ml_hdisplay = modeline.hdisplay; + mode->ml_hsyncstart = modeline.hsyncstart; + mode->ml_hsyncend = modeline.hsyncend; + mode->ml_htotal = modeline.htotal; + mode->ml_vdisplay = modeline.vdisplay; + mode->ml_vsyncstart = modeline.vsyncstart; + mode->ml_vsyncend = modeline.vsyncend; + mode->ml_vtotal = modeline.vtotal; +/* mode->ml_vscan = ???;*/ + mode->ml_flags = modeline.flags; + mode->ml_hskew = modeline.hskew; + vidtune->monitor->mon_modeline_lst = + xf86addModeLine(vidtune->monitor->mon_modeline_lst, mode); + } + else + XBell(XtDisplay(w), 80); +} + +/*ARGSUSED*/ +static void +StopTestCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + XtRemoveTimeOut(timeout); + TestTimeout((XtPointer)w, NULL); +} + +/*ARGSUSED*/ +void +CancelTestModeAction(Widget w, XEvent *event, + String *params, Cardinal *num_params) +{ + StopTestCallback(w, NULL, NULL); +} + +static void +TestTimeout(XtPointer client_data, XtIntervalId* id) +{ + XF86VidModeModeLine mode; + + XtPopdown(testshell); + timeout = 0; + memcpy(&mode, &modeline, sizeof(XF86VidModeModeLine)); + memcpy(&modeline, &orig_modeline, sizeof(XF86VidModeModeLine)); + ApplyCallback((Widget)client_data, NULL, NULL); +/* if (hitError == 0)*/ + memcpy(&modeline, &mode, sizeof(XF86VidModeModeLine)); + SetLabels(); +} + +static void +TestCallback(Widget w, XtPointer call_data, XtPointer client_data) +{ + if (testshell == NULL) { + Widget dialog; + + testshell = XtCreatePopupShell("test", transientShellWidgetClass, + toplevel, NULL, 0); + dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass, + testshell, XtNvalue, NULL, NULL); + XawDialogAddButton(dialog, "stop", StopTestCallback, NULL); + XtRealizeWidget(testshell); + XSetWMProtocols(DPY, XtWindow(testshell), &wm_delete_window, 1); + } + + XtPopup(testshell, XtGrabExclusive); + + XSync(XtDisplay(toplevel), False); + timeout = XtAppAddTimeOut(XtWidgetToApplicationContext(w), + /* the timeout probably shoud be converted to a resource */ + 4000, TestTimeout, (XtPointer)w); + ApplyCallback(w, call_data, client_data); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/vidmode.h b/xorg-server/hw/xfree86/utils/xorgcfg/vidmode.h new file mode 100644 index 000000000..d0c71d5c6 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/vidmode.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#ifndef _xf86cfg_vidmode_h +#define _xf86cfg_vidmode_h + +#include "xf86config.h" +#include <X11/extensions/xf86vmode.h> + +/* + * Types + */ +struct _xf86cfgVidMode { + XF86ConfMonitorPtr monitor; + int screen; + int num_infos; + XF86VidModeModeInfo **infos; +}; + +/* + * Prototypes + */ +Bool VideoModeInitialize(void); +void VideoModeConfigureStart(void); +void VideoModeConfigureEnd(void); +void VidmodeRestoreAction(Widget, XEvent*, String*, Cardinal*); +void CancelAddModeAction(Widget, XEvent*, String*, Cardinal*); +void CancelTestModeAction(Widget, XEvent*, String*, Cardinal*); +void InitializeVidmodes(void); + +/* + * Initialization + */ +extern Widget vtune; + +#endif /* _xf86cfg_vidmode_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/wider.xbm b/xorg-server/hw/xfree86/utils/xorgcfg/wider.xbm new file mode 100644 index 000000000..5cf87f25a --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/wider.xbm @@ -0,0 +1,8 @@ +#define wider_width 19 +#define wider_height 19 +static unsigned char wider_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08, 0x00, 0xc0, 0x18, 0x00, + 0xe0, 0x38, 0x00, 0xf0, 0x78, 0x00, 0xf8, 0xf8, 0x00, 0xfc, 0xff, 0x01, + 0xfe, 0xff, 0x03, 0xff, 0xff, 0x07, 0xfe, 0xff, 0x03, 0xfc, 0xff, 0x01, + 0xf8, 0xf8, 0x00, 0xf0, 0x78, 0x00, 0xe0, 0x38, 0x00, 0xc0, 0x18, 0x00, + 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/xf86config.c b/xorg-server/hw/xfree86/utils/xorgcfg/xf86config.c new file mode 100644 index 000000000..2c667dcde --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/xf86config.c @@ -0,0 +1,982 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "xf86config.h" + +/* + * Implementation + */ +int +xf86removeOption(XF86OptionPtr *options, char *name) +{ + XF86OptionPtr opt = *options, prev = opt; + + while (opt) { + if (strcasecmp(opt->opt_name, name) == 0) { + XtFree(opt->opt_name); + XtFree(opt->opt_val); + XtFree(opt->opt_comment); + if (opt == prev) + *options = (XF86OptionPtr)(opt->list.next); + else + prev->list.next = opt->list.next; + XtFree((XtPointer)opt); + + return (True); + } + + prev = opt; + opt = (XF86OptionPtr)(opt->list.next); + } + + return (False); +} + +int +xf86removeInput(XF86ConfigPtr config, XF86ConfInputPtr input) +{ + XF86ConfInputPtr prev, inp = config->conf_input_lst; + XF86ConfLayoutPtr lay = config->conf_layout_lst; + + /* remove from main structure */ + prev = inp; + while (inp != NULL) { + if (inp == input) { + if (inp == prev) + config->conf_input_lst = (XF86ConfInputPtr)(inp->list.next); + else + prev->list.next = inp->list.next; + break; + } + prev = inp; + inp = (XF86ConfInputPtr)(inp->list.next); + } + + if (inp == NULL) + return (False); + + /* remove references */ + while (lay != NULL) { + xf86removeInputRef(lay, inp); + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + XtFree(inp->inp_identifier); + XtFree(inp->inp_driver); + XtFree(inp->inp_comment); + xf86optionListFree(inp->inp_option_lst); + XtFree((XtPointer)inp); + + return (True); +} + +int +xf86removeInputRef(XF86ConfLayoutPtr layout, XF86ConfInputPtr input) +{ + XF86ConfInputrefPtr prev, iref = layout->lay_input_lst; + + prev = iref; + while (iref != NULL) { + if (iref->iref_inputdev == input) { + XtFree(iref->iref_inputdev_str); + xf86optionListFree(iref->iref_option_lst); + if (prev == iref) + layout->lay_input_lst = + (XF86ConfInputrefPtr)(iref->list.next); + else + prev->list.next = iref->list.next; + XtFree((XtPointer)iref); + + return (True); + } + prev = iref; + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + + return (False); +} + +int +xf86removeDevice(XF86ConfigPtr config, XF86ConfDevicePtr device) +{ + XF86ConfDevicePtr prev, dev = config->conf_device_lst; + XF86ConfScreenPtr psc, scr = config->conf_screen_lst; + + /* remove from main structure */ + prev = dev; + while (dev != NULL) { + if (dev == device) { + if (dev == prev) + config->conf_device_lst = (XF86ConfDevicePtr)(dev->list.next); + else + prev->list.next = dev->list.next; + break; + } + prev = dev; + dev = (XF86ConfDevicePtr)(dev->list.next); + } + + if (dev == NULL) + return (False); + + /* remove references */ + psc = scr; + while (scr != NULL) { + if (scr->scrn_device == device) { + xf86removeScreen(config, scr); + if (scr == psc) + scr = psc = config->conf_screen_lst; + else + scr = psc; + continue; + } + psc = scr; + scr = (XF86ConfScreenPtr)(scr->list.next); + } + + XtFree(dev->dev_identifier); + XtFree(dev->dev_vendor); + XtFree(dev->dev_board); + XtFree(dev->dev_chipset); + XtFree(dev->dev_busid); + XtFree(dev->dev_card); + XtFree(dev->dev_driver); + XtFree(dev->dev_ramdac); + XtFree(dev->dev_clockchip); + XtFree(dev->dev_comment); + xf86optionListFree(dev->dev_option_lst); + XtFree((XtPointer)dev); + + return (True); +} + +int +xf86removeMonitor(XF86ConfigPtr config, XF86ConfMonitorPtr monitor) +{ + XF86ConfMonitorPtr prev, mon = config->conf_monitor_lst; + XF86ConfScreenPtr psc, scr = config->conf_screen_lst; + + /* remove from main structure */ + prev = mon; + while (mon != NULL) { + if (mon == monitor) { + if (mon == prev) + config->conf_monitor_lst = (XF86ConfMonitorPtr)(mon->list.next); + else + prev->list.next = mon->list.next; + break; + } + prev = mon; + mon = (XF86ConfMonitorPtr)(mon->list.next); + } + + if (mon == NULL) + return (False); + + /* remove references */ + psc = scr; + while (scr != NULL) { + if (scr->scrn_monitor == monitor) { + xf86removeScreen(config, scr); + if (scr == psc) + scr = psc = config->conf_screen_lst; + else + scr = psc; + continue; + } + psc = scr; + scr = (XF86ConfScreenPtr)(scr->list.next); + } + + XtFree(mon->mon_identifier); + XtFree(mon->mon_vendor); + XtFree(mon->mon_modelname); + XtFree(mon->mon_comment); + xf86optionListFree(mon->mon_option_lst); + XtFree((XtPointer)mon); + + return (True); +} + +int +xf86removeScreen(XF86ConfigPtr config, XF86ConfScreenPtr screen) +{ + XF86ConfScreenPtr prev, scrn; + XF86ConfLayoutPtr lay; + + if (config == NULL || screen == NULL) + return (False); + + lay = config->conf_layout_lst; + prev = scrn = config->conf_screen_lst; + + while (scrn != NULL) { + if (scrn == screen) { + if (scrn == prev) + config->conf_screen_lst = (XF86ConfScreenPtr)(scrn->list.next); + else + prev->list.next = scrn->list.next; + break; + } + prev = scrn; + scrn = (XF86ConfScreenPtr)(scrn->list.next); + } + + if (scrn == NULL) + return (False); + + while (lay != NULL) { + XF86ConfAdjacencyPtr pad, ad = NULL, adj = lay->lay_adjacency_lst; + + pad = adj; + while (adj) { + if (adj->adj_screen == screen) + ad = adj; + else { + if (adj->adj_top != NULL && adj->adj_top == screen) { + XtFree(adj->adj_top_str); + adj->adj_top_str = NULL; + adj->adj_top = NULL; + } + else if (adj->adj_bottom != NULL && adj->adj_bottom == screen) { + XtFree(adj->adj_bottom_str); + adj->adj_bottom_str = NULL; + adj->adj_bottom = NULL; + } + else if (adj->adj_left != NULL && adj->adj_left == screen) { + XtFree(adj->adj_left_str); + adj->adj_left_str = NULL; + adj->adj_left = NULL; + } + else if (adj->adj_right != NULL && adj->adj_right == screen) { + XtFree(adj->adj_right_str); + adj->adj_right_str = NULL; + adj->adj_right = NULL; + } + else if (adj->adj_refscreen != NULL && + strcasecmp(scrn->scrn_identifier, + adj->adj_refscreen) == 0) { + XtFree(adj->adj_refscreen); + adj->adj_refscreen = NULL; + adj->adj_where = CONF_ADJ_ABSOLUTE; + adj->adj_x = adj->adj_y = 0; + } + } + if (ad == NULL) + pad = adj; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + + if (ad != NULL) { + if (ad == lay->lay_adjacency_lst) + lay->lay_adjacency_lst = (XF86ConfAdjacencyPtr)(ad->list.next); + else + pad->list.next = (XF86ConfAdjacencyPtr)(ad->list.next); + XtFree(ad->adj_screen_str); + XtFree(ad->adj_top_str); + XtFree(ad->adj_bottom_str); + XtFree(ad->adj_left_str); + XtFree(ad->adj_right_str); + XtFree(ad->adj_refscreen); + XtFree((XtPointer)ad); + } + + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + xf86freeAdaptorLinkList(screen->scrn_adaptor_lst); + xf86freeDisplayList(screen->scrn_display_lst); + + XtFree(screen->scrn_identifier); + XtFree(screen->scrn_monitor_str); + XtFree(screen->scrn_device_str); + xf86optionListFree(screen->scrn_option_lst); + XtFree((XtPointer)screen); + + return (True); +} + +int +xf86removeAdjacency(XF86ConfLayoutPtr layout, XF86ConfAdjacencyPtr adjacency) +{ + XF86ConfAdjacencyPtr prev, adj = layout->lay_adjacency_lst; + + if (layout == NULL || adjacency == NULL) + return (False); + + prev = adj; + while (adj != NULL) { + if (adj == adjacency) + break; + prev = adj; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + if (adj == NULL) + return (False); + + XtFree(adj->adj_screen_str); + XtFree(adj->adj_top_str); + XtFree(adj->adj_bottom_str); + XtFree(adj->adj_left_str); + XtFree(adj->adj_right_str); + XtFree(adj->adj_refscreen); + if (prev == adj) + layout->lay_adjacency_lst = (XF86ConfAdjacencyPtr)(adj->list.next); + else + prev->list.next = adj->list.next; + XtFree((XtPointer)adj); + + return (True); +} + +int +xf86removeInactive(XF86ConfLayoutPtr layout, XF86ConfInactivePtr inactive) +{ + XF86ConfInactivePtr prev, inac = layout->lay_inactive_lst; + + if (layout == NULL || inactive == NULL) + return (False); + + prev = inac; + while (inac != NULL) { + if (inac == inactive) + break; + prev = inac; + inac = (XF86ConfInactivePtr)(inac->list.next); + } + if (inac == NULL) + return (False); + + XtFree(inac->inactive_device_str); + if (prev == inac) + layout->lay_inactive_lst = (XF86ConfInactivePtr)(inac->list.next); + else + prev->list.next = inac->list.next; + XtFree((XtPointer)inac); + + return (True); +} + +int +xf86removeLayout(XF86ConfigPtr config, XF86ConfLayoutPtr layout) +{ + XF86ConfLayoutPtr prev, lay = config->conf_layout_lst; + XF86ConfAdjacencyPtr adj, nadj; + XF86ConfInactivePtr inac, ninac; + XF86ConfInputrefPtr iref, niref; + + if (config == NULL || layout == NULL) + return (False); + + prev = lay; + while (lay != NULL) { + if (lay == layout) + break; + prev = lay; + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + if (lay == NULL) + return (False); + + adj = lay->lay_adjacency_lst; + while (adj != NULL) { + nadj = (XF86ConfAdjacencyPtr)(adj->list.next); + xf86removeAdjacency(lay, adj); + adj = nadj; + } + + inac = lay->lay_inactive_lst; + while (inac != NULL) { + ninac = (XF86ConfInactivePtr)(inac->list.next); + xf86removeInactive(lay, inac); + inac = ninac; + } + + iref = lay->lay_input_lst; + while (iref != NULL) { + niref = (XF86ConfInputrefPtr)(iref->list.next); + xf86removeInputRef(lay, iref->iref_inputdev); + iref = niref; + } + + xf86optionListFree(lay->lay_option_lst); + + if (prev == lay) + config->conf_layout_lst = (XF86ConfLayoutPtr)(lay->list.next); + else + prev->list.next = lay->list.next; + XtFree(lay->lay_identifier); + XtFree((XtPointer)lay); + + return (True); +} + +int +xf86removeModule(XF86ConfigPtr config, XF86LoadPtr load) +{ + XF86LoadPtr prev, mod; + + if (config == NULL || config->conf_modules == NULL || + config->conf_modules->mod_load_lst == NULL) + return (False); + + for (mod = prev = config->conf_modules->mod_load_lst; + mod != NULL; prev = mod, mod = (XF86LoadPtr)(mod->list.next)) + if (load == mod) { + if (mod == prev) + config->conf_modules->mod_load_lst = + (XF86LoadPtr)(mod->list.next); + else + prev->list.next = mod->list.next; + XtFree(mod->load_name); + xf86optionListFree(mod->load_opt); + + return (True); + } + + return (False); +} + +int +xf86removeModes(XF86ConfigPtr config, XF86ConfModesPtr modes) +{ + XF86ConfModesPtr mod; + XF86ConfModeLinePtr ml, next; + XF86ConfMonitorPtr mon; + + if (config == NULL || modes == NULL) + return (False); + + /* check if modes is in config */ + if ((mod = config->conf_modes_lst) == modes) + config->conf_modes_lst = (XF86ConfModesPtr)(mod->list.next); + else + for (; mod != NULL; mod = (XF86ConfModesPtr)(mod->list.next)) + if ((XF86ConfModesPtr)(mod->list.next) == modes) { + mod->list.next = modes->list.next; + break; + } + + if (mod == NULL) + return (False); + + /* remove references in monitor sections */ + mon = config->conf_monitor_lst; + while (mon) { + XF86ConfModesLinkPtr m, p; + + m = p = mon->mon_modes_sect_lst; + while (m) { + if (m->ml_modes == modes) { + XtFree(m->ml_modes_str); + if (m == mon->mon_modes_sect_lst) + p = mon->mon_modes_sect_lst = + (XF86ConfModesLinkPtr)(m->list.next); + else { + p->list.next = m->list.next; + p = p->list.next; + } + XtFree((XtPointer)m); + m = p; + continue; + } + p = m; + m = (XF86ConfModesLinkPtr)(m->list.next); + } + mon = (XF86ConfMonitorPtr)(mon->list.next); + } + + /* free modelines */ + ml = modes->mon_modeline_lst; + while (ml) { + next = (XF86ConfModeLinePtr)(ml->list.next); + XtFree(ml->ml_identifier); + XtFree((XtPointer)ml); + ml = next; + } + + /* free mode */ + XtFree(modes->modes_identifier); + XtFree((XtPointer)modes); + + return (True); +} + +int +xf86removeModesModeLine(XF86ConfModesPtr modes, XF86ConfModeLinePtr modeline) +{ + XF86ConfModeLinePtr ml, prev; + + if (modes == NULL || modeline == NULL || modes->mon_modeline_lst == NULL) + return (False); + + for (ml = prev = modes->mon_modeline_lst; ml; + prev = ml, ml = (XF86ConfModeLinePtr)(ml->list.next)) + if (ml == modeline) { + if (prev == ml) + modes->mon_modeline_lst = (XF86ConfModeLinePtr)(ml->list.next); + else + prev->list.next = ml->list.next; + XtFree(modeline->ml_identifier); + XtFree((XtPointer)modeline); + return (True); + } + + return (False); +} + +int +xf86removeMonitorModeLine(XF86ConfMonitorPtr monitor, XF86ConfModeLinePtr modeline) +{ + XF86ConfModeLinePtr ml, prev; + + if (monitor == NULL || modeline == NULL || monitor->mon_modeline_lst == NULL) + return (False); + + for (ml = prev = monitor->mon_modeline_lst; ml; + prev = ml, ml = (XF86ConfModeLinePtr)(ml->list.next)) + if (ml == modeline) { + if (prev == ml) + monitor->mon_modeline_lst = (XF86ConfModeLinePtr)(ml->list.next); + else + prev->list.next = ml->list.next; + XtFree(modeline->ml_identifier); + XtFree((XtPointer)modeline); + return (True); + } + + return (False); +} + +int +xf86removeMonitorModesLink(XF86ConfMonitorPtr monitor, XF86ConfModesLinkPtr link) +{ + XF86ConfModesLinkPtr lnk, prev; + + if (monitor == NULL || link == NULL || monitor->mon_modes_sect_lst == NULL) + return (False); + + for (lnk = prev = monitor->mon_modes_sect_lst; lnk != NULL; + prev = lnk, lnk = (XF86ConfModesLinkPtr)(lnk->list.next)) + if (lnk == link) { + if (prev == lnk) + monitor->mon_modes_sect_lst = (XF86ConfModesLinkPtr)(lnk->list.next); + else + prev->list.next = lnk->list.next; + XtFree(link->ml_modes_str); + XtFree((XtPointer)link); + + return (True); + } + + return (False); +} + +int +xf86removeScreenAdaptorLink(XF86ConfScreenPtr scrn, XF86ConfAdaptorLinkPtr link) +{ + XF86ConfAdaptorLinkPtr lnk, prev; + + if (scrn == NULL || link == NULL || scrn->scrn_adaptor_lst == NULL) + return (False); + + for (lnk = prev = scrn->scrn_adaptor_lst; lnk != NULL; + prev = lnk, lnk = (XF86ConfAdaptorLinkPtr)(lnk->list.next)) + if (lnk == link) { + if (prev == lnk) + scrn->scrn_adaptor_lst = + (XF86ConfAdaptorLinkPtr)(lnk->list.next); + else + prev->list.next = lnk->list.next; + XtFree(link->al_adaptor_str); + XtFree((XtPointer)link); + + return (True); + } + + return (False); +} + +int +xf86removeScreenDisplay(XF86ConfScreenPtr scrn, XF86ConfDisplayPtr display) +{ + XF86ConfDisplayPtr dsp, prev; + + if (scrn == NULL || display == NULL || scrn->scrn_display_lst == NULL) + return (False); + + for (dsp = prev = scrn->scrn_display_lst; dsp != NULL; + prev = dsp, dsp = (XF86ConfDisplayPtr)(dsp->list.next)) + if (dsp == display) { + if (prev == dsp) + scrn->scrn_display_lst = + (XF86ConfDisplayPtr)(dsp->list.next); + else + prev->list.next = dsp->list.next; + xf86optionListFree(display->disp_option_lst); + XtFree((XtPointer)display->disp_visual); + xf86freeModeList(display->disp_mode_lst); + XtFree((XtPointer)display); + + return (True); + } + + return (False); +} + +int +xf86removeVideoAdaptor(XF86ConfigPtr config, XF86ConfVideoAdaptorPtr video) +{ + XF86ConfVideoAdaptorPtr vid; + XF86ConfScreenPtr scrn; + XF86ConfVideoPortPtr vp, next; + + if (config == NULL || video == NULL) + return (False); + + /* check if video is in config and update videoadaptor list */ + if ((vid = config->conf_videoadaptor_lst) == video) + config->conf_videoadaptor_lst = (XF86ConfVideoAdaptorPtr)(vid->list.next); + else + for (; vid != NULL; vid = (XF86ConfVideoAdaptorPtr)(vid->list.next)) + if ((XF86ConfVideoAdaptorPtr)(vid->list.next) == video) { + vid->list.next = video->list.next; + break; + } + + if (vid == NULL) + return (False); + + /* remove references in screen sections */ + scrn = config->conf_screen_lst; + while (scrn) { + XF86ConfAdaptorLinkPtr v, p; + + v = p = scrn->scrn_adaptor_lst; + while (v) { + if (v->al_adaptor == video) { + XtFree(v->al_adaptor_str); + if (v == scrn->scrn_adaptor_lst) + p = scrn->scrn_adaptor_lst = + (XF86ConfAdaptorLinkPtr)(v->list.next); + else { + p->list.next = v->list.next; + p = p->list.next; + } + XtFree((XtPointer)v); + v = p; + continue; + } + p = v; + v = (XF86ConfAdaptorLinkPtr)(v->list.next); + } + scrn = (XF86ConfScreenPtr)(scrn->list.next); + } + + /* free videoports */ + vp = video->va_port_lst; + while (vp) { + next = (XF86ConfVideoPortPtr)(vp->list.next); + XtFree(vp->vp_identifier); + xf86optionListFree(vp->vp_option_lst); + XtFree((XtPointer)vp); + vp = next; + } + + /* free videoadaptor */ + XtFree(video->va_identifier); + XtFree(video->va_vendor); + XtFree(video->va_board); + XtFree(video->va_busid); + XtFree(video->va_driver); + XtFree(video->va_fwdref); + xf86optionListFree(video->va_option_lst); + XtFree((XtPointer)video); + + return (True); +} + +int +xf86removeVideoPort(XF86ConfVideoAdaptorPtr va, XF86ConfVideoPortPtr vp) +{ + XF86ConfVideoPortPtr prev; + + if (va == NULL || vp == NULL) + return (False); + + if ((prev = va->va_port_lst) == vp) + va->va_port_lst = (XF86ConfVideoPortPtr)(va->va_port_lst->list.next); + else { + while (prev && (XF86ConfVideoPortPtr)(prev->list.next) != vp) + prev = (XF86ConfVideoPortPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = vp->list.next; + } + + xf86optionListFree(vp->vp_option_lst); + XtFree((XtPointer)vp); + + return (True); +} + +int +xf86removeDisplayMode(XF86ConfDisplayPtr display, XF86ModePtr mode) +{ + XF86ModePtr prev; + + if (display == NULL || mode == NULL) + return (False); + + if ((prev = display->disp_mode_lst) == mode) + display->disp_mode_lst = (XF86ModePtr)(display->disp_mode_lst->list.next); + else { + while (prev && (XF86ModePtr)(prev->list.next) != mode) + prev = (XF86ModePtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = mode->list.next; + } + + XtFree((XtPointer)mode); + + return (True); +} + +int +xf86removeVendor(XF86ConfigPtr config, XF86ConfVendorPtr vendor) +{ + XF86ConfVendorPtr prev; + + if (config == NULL || vendor == NULL) + return (False); + + if ((prev = config->conf_vendor_lst) == vendor) + config->conf_vendor_lst = (XF86ConfVendorPtr)(config->conf_vendor_lst->list.next); + else { + while (prev && (XF86ConfVendorPtr)(prev->list.next) != vendor) + prev = (XF86ConfVendorPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = vendor->list.next; + } + + xf86optionListFree(vendor->vnd_option_lst); + xf86freeVendorSubList(vendor->vnd_sub_lst); + XtFree(vendor->vnd_identifier); + XtFree((XtPointer)vendor); + + return (True); +} + +int +xf86removeVendorSub(XF86ConfVendorPtr vendor, XF86ConfVendSubPtr sub) +{ + XF86ConfVendSubPtr prev; + + if (vendor == NULL || sub == NULL) + return (False); + + if ((prev = vendor->vnd_sub_lst) == sub) + vendor->vnd_sub_lst = (XF86ConfVendSubPtr)(vendor->vnd_sub_lst->list.next); + else { + while (prev && (XF86ConfVendSubPtr)(prev->list.next) != sub) + prev = (XF86ConfVendSubPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = sub->list.next; + } + + xf86optionListFree(sub->vs_option_lst); + XtFree(sub->vs_name); + XtFree(sub->vs_identifier); + XtFree((XtPointer)sub); + + return (True); +} + +int +xf86removeBuffers(XF86ConfDRIPtr dri, XF86ConfBuffersPtr buf) +{ + XF86ConfBuffersPtr prev; + + if (dri == NULL || buf == NULL) + return (False); + + if ((prev = dri->dri_buffers_lst) == buf) + dri->dri_buffers_lst = (XF86ConfBuffersPtr)(dri->dri_buffers_lst->list.next); + else { + while (prev && (XF86ConfBuffersPtr)(prev->list.next) != buf) + prev = (XF86ConfBuffersPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = buf->list.next; + } + + XtFree(buf->buf_flags); + XtFree((XtPointer)buf); + + return (True); +} + +int +xf86renameInput(XF86ConfigPtr config, XF86ConfInputPtr input, char *name) +{ + XF86ConfLayoutPtr lay = config->conf_layout_lst; + + if (config == NULL || input == NULL || name == NULL || *name == '\0') + return (False); + + while (lay != NULL) { + XF86ConfInputrefPtr iref = lay->lay_input_lst; + + while (iref != NULL) { + if (strcasecmp(input->inp_identifier, iref->iref_inputdev_str) == 0) { + XtFree(iref->iref_inputdev_str); + iref->iref_inputdev_str = XtNewString(name); + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + XtFree(input->inp_identifier); + input->inp_identifier = XtNewString(name); + + return (True); +} + +int +xf86renameDevice(XF86ConfigPtr config, XF86ConfDevicePtr dev, char *name) +{ + XF86ConfScreenPtr scr = config->conf_screen_lst; + + if (config == NULL || dev == NULL || name == NULL || *name == '\0') + return (False); + + while (scr != NULL) { + if (scr->scrn_device == dev) { + XtFree(scr->scrn_device_str); + scr->scrn_device_str = XtNewString(name); + } + + scr = (XF86ConfScreenPtr)(scr->list.next); + } + + XtFree(dev->dev_identifier); + dev->dev_identifier = XtNewString(name); + + return (True); +} + +int +xf86renameMonitor(XF86ConfigPtr config, XF86ConfMonitorPtr mon, char *name) +{ + XF86ConfScreenPtr scr = config->conf_screen_lst; + + if (config == NULL || mon == NULL || name == NULL || *name == '\0') + return (False); + + while (scr != NULL) { + if (scr->scrn_monitor == mon) { + XtFree(scr->scrn_monitor_str); + scr->scrn_monitor_str = XtNewString(name); + } + + scr = (XF86ConfScreenPtr)(scr->list.next); + } + + XtFree(mon->mon_identifier); + mon->mon_identifier = XtNewString(name); + + return (True); +} + +int +xf86renameLayout(XF86ConfigPtr config, XF86ConfLayoutPtr layout, char *name) +{ + if (config == NULL || layout == NULL || name == NULL || *name == '\0') + return (False); + + XtFree(layout->lay_identifier); + layout->lay_identifier = XtNewString(name); + + return (True); +} + +int +xf86renameScreen(XF86ConfigPtr config, XF86ConfScreenPtr scrn, char *name) +{ + XF86ConfLayoutPtr lay = config->conf_layout_lst; + + if (config == NULL || scrn == NULL || name == NULL || *name == '\0') + return (False); + + while (lay != NULL) { + XF86ConfAdjacencyPtr adj = lay->lay_adjacency_lst; + + while (adj != NULL) { + if (adj->adj_screen == scrn) { + XtFree(adj->adj_screen_str); + adj->adj_screen_str = XtNewString(name); + } + else if (adj->adj_top == scrn) { + XtFree(adj->adj_top_str); + adj->adj_top_str = XtNewString(name); + } + else if (adj->adj_bottom == scrn) { + XtFree(adj->adj_bottom_str); + adj->adj_bottom_str = XtNewString(name); + } + else if (adj->adj_left == scrn) { + XtFree(adj->adj_left_str); + adj->adj_left_str = XtNewString(name); + } + else if (adj->adj_right == scrn) { + XtFree(adj->adj_right_str); + adj->adj_right_str = XtNewString(name); + } + else if (adj->adj_refscreen != NULL && + strcasecmp(adj->adj_refscreen, name) == 0) { + XtFree(adj->adj_refscreen); + adj->adj_refscreen = XtNewString(name); + } + + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + XtFree(scrn->scrn_identifier); + scrn->scrn_identifier = XtNewString(name); + + return (True); +} diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/xf86config.h b/xorg-server/hw/xfree86/utils/xorgcfg/xf86config.h new file mode 100644 index 000000000..9387d782f --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/xf86config.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * 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 + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + */ + +#include "config.h" + +#ifndef _xf86cfg_xf86config_h +#define _xf86cfg_xf86config_h + +#define xf86addInput(head, ptr) \ + (XF86ConfInputPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addInputref(head, ptr) \ + (XF86ConfInputrefPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addDevice(head, ptr) \ + (XF86ConfDevicePtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addDisplayMode(head, ptr) \ + (XF86ModePtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addMonitor(head, ptr) \ + (XF86ConfMonitorPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addScreen(head, ptr) \ + (XF86ConfScreenPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addLayout(head, ptr) \ + (XF86ConfLayoutPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModeLine(head, ptr) \ + (XF86ConfModeLinePtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModes(head, ptr) \ + (XF86ConfModesPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModesLink(head, ptr) \ + (XF86ConfModesLinkPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModule(head, ptr) \ + (XF86LoadPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addScreenAdaptor(head, ptr) \ + (XF86ConfAdaptorLinkPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addScreenDisplay(head, ptr) \ + (XF86ConfDisplayPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVideoAdaptor(head, ptr) \ + (XF86ConfVideoAdaptorPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVideoPort(head, ptr) \ + (XF86ConfVideoPortPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addAdjacency(head, ptr) \ + (XF86ConfAdjacencyPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVendor(head, ptr) \ + (XF86ConfVendorPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVendorSub(head, ptr) \ + (XF86ConfVendSubPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addBuffers(head, ptr) \ + (XF86ConfBuffersPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) + + +int xf86removeOption(XF86OptionPtr*, char*); +int xf86removeInput(XF86ConfigPtr, XF86ConfInputPtr); +int xf86removeInputRef(XF86ConfLayoutPtr, XF86ConfInputPtr); +int xf86removeDevice(XF86ConfigPtr, XF86ConfDevicePtr); +int xf86removeDisplayMode(XF86ConfDisplayPtr, XF86ModePtr); +int xf86removeMonitor(XF86ConfigPtr, XF86ConfMonitorPtr); +int xf86removeScreen(XF86ConfigPtr, XF86ConfScreenPtr); +int xf86removeAdjacency(XF86ConfLayoutPtr, XF86ConfAdjacencyPtr); +int xf86removeInactive(XF86ConfLayoutPtr, XF86ConfInactivePtr); +int xf86removeLayout(XF86ConfigPtr, XF86ConfLayoutPtr); +int xf86removeModule(XF86ConfigPtr, XF86LoadPtr); +int xf86removeModes(XF86ConfigPtr, XF86ConfModesPtr); +int xf86removeModesModeLine(XF86ConfModesPtr, XF86ConfModeLinePtr); +int xf86removeMonitorModeLine(XF86ConfMonitorPtr, XF86ConfModeLinePtr); +int xf86removeMonitorModesLink(XF86ConfMonitorPtr, XF86ConfModesLinkPtr); +int xf86removeScreenAdaptorLink(XF86ConfScreenPtr, XF86ConfAdaptorLinkPtr); +int xf86removeScreenDisplay(XF86ConfScreenPtr, XF86ConfDisplayPtr); +int xf86removeVideoAdaptor(XF86ConfigPtr, XF86ConfVideoAdaptorPtr); +int xf86removeVideoPort(XF86ConfVideoAdaptorPtr, XF86ConfVideoPortPtr); +int xf86removeVendor(XF86ConfigPtr, XF86ConfVendorPtr); +int xf86removeVendorSub(XF86ConfVendorPtr, XF86ConfVendSubPtr); +int xf86removeBuffers(XF86ConfDRIPtr, XF86ConfBuffersPtr); + +int xf86renameInput(XF86ConfigPtr, XF86ConfInputPtr, char*); +int xf86renameDevice(XF86ConfigPtr, XF86ConfDevicePtr, char*); +int xf86renameMonitor(XF86ConfigPtr, XF86ConfMonitorPtr, char*); +int xf86renameLayout(XF86ConfigPtr, XF86ConfLayoutPtr, char*); +int xf86renameScreen(XF86ConfigPtr, XF86ConfScreenPtr, char*); + +extern void xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr); +extern void xf86freeDisplayList(XF86ConfDisplayPtr); +extern void xf86freeModeList(XF86ModePtr); +extern void xf86freeVendorSubList(XF86ConfVendSubPtr); + +#endif /* _xf86cfg_xf86config_h */ diff --git a/xorg-server/hw/xfree86/utils/xorgcfg/xorgcfg.man.pre b/xorg-server/hw/xfree86/utils/xorgcfg/xorgcfg.man.pre new file mode 100644 index 000000000..71e75e2d8 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgcfg/xorgcfg.man.pre @@ -0,0 +1,148 @@ +.\" +.\" $XdotOrg: $ +.\" Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) +.\" +.\" 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 +.\" CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +.\" SOFTWARE. +.\" +.\" Except as contained in this notice, the name of Conectiva Linux shall +.\" not be used in advertising or otherwise to promote the sale, use or other +.\" dealings in this Software without prior written authorization from +.\" Conectiva Linux. +.\" +.\" Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> +.\" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man,v 1.9 2002/12/30 14:34:02 herrb Exp $ +.\" +.TH xorgcfg __appmansuffix__ __vendorversion__ +.SH NAME +xorgcfg - Graphical configuration tool for __xservername__ +.SH SYNOPSIS +.B xorgcfg +[-config \fIconfigfile\fP] [-modulepath \fImoduledir\fP] +[-fontpath \fIfontsdir\fP] [-toolkitoption ...] +.SH DESCRIPTION +.I Xorgcfg +is a tool to configure\fI __xservername__\fP, and can be used to either write the +initial configuration file or make customizations to the current configuration. +.PP +When the \fBDISPLAY\fP environment variable is not set, xorgcfg will run +the command\fI __xservername__ -configure\fP to allow the xserver to detect the +hardware in the computer, and write an initial\fI __xconfigfile__\fP file +in the user's home directory. Then, it will start +__xservername__ and allow customizations. +.PP +If the \fBDISPLAY\fP environment variable is set, xorgcfg will read the +default\fI __xconfigfile__\fP, which may or may not be the one being used by +the current server, and allow customizations. +.PP +To use an alternative location for modules or fonts the respective search +paths may be specified. +.PP +Unless there is an \fBApply\fP button in the current xorgcfg dialog, the +changes made will take place the next time\fI __xservername__\fP is started. +.PP +Xorgcfg allows addition and configuration of new devices, such as video cards, +monitors, keyboards and mouses. +.PP +Screen layout configuration for xinerama or traditional multi-head is also +available. +.PP +Modelines can be configured or optimized. +.PP +AccessX basic configurations can be made in the xorgcfg's accessx section. + +.SH OPTIONS +.TP 8 +.I -config +Specifies an alternate __xconfigfile__ file for configuration. +.TP 8 +.I -modulepath +Specifies where xorgcfg, and the server it may start, should look for +__xservername__ modules. +.TP 8 +.I -serverpath +Specifies the complete path, not including the binary name, of the +__xservername__ binary. +.TP 8 +.I -fontpath +Specifies the path to the fonts that should be used by the server started +by xorgcfg. +.TP 8 +.I -textmode +If xorgcfg was compiled with support for ncurses, this option makes xorgcfg +enter a text mode interface. +.TP 8 +.I -nomodules +When built with support for loading modules, this options changes xorgcfg +behaviour, so that it will not load any modules, and thus start quicker. + +.SH ENVIRONMENT +.TP 8 +.I DISPLAY +Default host and display number. +.TP 8 +.I XWINHOME +Directory where __xservername__ was installed, defaults to __projectroot__. +.TP 8 +.I XENVIRONMENT +Name of a resource file that overrides the global resources +stored in the RESOURCE_MANAGER property. + +.SH FILES +.TP 8 +.I /etc/__xconfigfile__ +Server configuration file +.TP 8 +.I /etc/X11/__xconfigfile__ +Server configuration file +.TP 8 +.I __projectroot__/etc/__xconfigfile__ +Server configuration file +.TP 8 +.IR __projectroot__/lib/X11/__xconfigfile__. hostname +Server configuration file +.TP 8 +.I __projectroot__/lib/X11/__xconfigfile__ +Server configuration file +.TP 8 +.I __projectroot__/lib/X11/app-default/XOrgCfg +Specifies xorgcfg resources +.TP 8 +.I __projectroot__/lib/X11/xkb/X0-config.keyboard +Keyboard specific configuration + +.SH "SEE ALSO" +.IR __xservername__ (__appmansuffix__), +.IR __xconfigfile__ (__filemansuffix__) + +.SH COPYRIGHT +.TP 8 +Copyright 2000, Conectiva Linux S.A. +\fIhttp://www.conectiva.com\fP +.TP 8 +Copyright 2000, The XFree86 Project +\fIhttp://www.XFree86.org\fP + +.SH AUTHORS +.TP 8 +Paulo C\'esar Pereira de Andrade \fI<pcpa@conectiva.com.br>\fP +originally for The XFree86 Project. + +.SH BUGS +Probably. diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/Cards b/xorg-server/hw/xfree86/utils/xorgconfig/Cards new file mode 100644 index 000000000..b95928c37 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/Cards @@ -0,0 +1,3135 @@ +# $XConsortium: Cards /main/27 1996/10/28 05:43:53 kaleb $ +# This is the database of card definitions used by xf86config. +# Each definition should have a NAME entry, CHIPSET (descriptive) and +# SERVER (one of Mono, VGA16, SVGA, S3, 8514, Mach8, Mach32, Mach64, AGX, +# P9000, W32, I128). +# A reference to another definition is made with SEE (already defined +# entries are not overridden). +# Optional entries are RAMDAC (identifier), CLOCKCHIP (identifier), +# DACSPEED, NOCLOCKPROBE (advises never to probe clocks), UNSUPPORTED +# (indicates card that is not yet properly supported by a dedicated +# server). A LINE entry adds a line of text to be included in the +# Device section (can include options or comments). +# There's no CLOCKS option (although a Clocks line can be included +# with LINE), as it is very undesirable to have a Clocks line that +# is incorrect. The idea is that the Clocks are probed for to be +# sure (a commented suggested Clocks line can be included). +# +# The majority of entries are just a binding of a model name to a +# chipset/server and untested. +# +# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.79 2002/10/16 01:31:05 dawes Exp $ + +# VGA + +NAME * Generic VGA compatible +SERVER VGA16 +DRIVER vga + +NAME * Generic VESA compatible +SERVER VGA16 +DRIVER vesa + +NAME * Unsupported VGA compatible +SERVER VGA16 +DRIVER vga +UNSUPPORTED + + +# # +# generic # +# # + +NAME ** Alliance Pro Motion (generic) [apm] +#CHIPSET apm +SERVER SVGA +DRIVER apm +LINE #Option "no_accel" + +NAME ** Ark Logic (generic) [ark] +#CHIPSET ark +SERVER SVGA +DRIVER ark + +NAME ** ASPEED Technology (generic) [ast] +#CHIPSET ast +SERVER SVGA +DRIVER ast + +NAME ** ATI (generic) [ati] +#CHIPSET ati +SERVER SVGA +DRIVER ati + +NAME ** ATI Rage 128 based (generic) [r128] +#CHIPSET r128 +SERVER SVGA +DRIVER r128 + +NAME ** ATI Radeon (generic) [radeon] +#CHIPSET radeon +SERVER SVGA +DRIVER radeon + +NAME ** Chips and Technologies (generic) [chips] +#CHIPSET chips +SERVER SVGA +DRIVER chips +LINE # Option "suspend_hack" +LINE # Option "STN" +LINE # Option "no_stretch" +LINE # Option "no_center" +LINE # Option "use_modeline" +LINE # Option "fix_panel_size" +LINE # videoram 512 +LINE # Option "noaccel" +LINE # Option "no_bitblt" +LINE # Option "xaa_no_color_exp" +LINE # Option "xaa_benchmark" +LINE # Option "hw_cursor" +LINE # Option "nolinear" +LINE # MemBase 0x03b00000 +LINE # Option "hw_clocks" +LINE # Textclockfreq 25.175 + +NAME ** Cirrus Logic (generic) [cirrus] +#CHIPSET cirrus +SERVER SVGA +DRIVER cirrus +LINE # MemBase 0x00e00000 # ISA card that maps to 14Mb +LINE # MemBase 0x04000000 # VLB card that maps to 64Mb +LINE # MemBase 0x80000000 # VLB card that maps to 2048Mb +LINE # MemBase 0x02000000 # VLB card that maps to 32Mb +LINE # Option "linear" +LINE # Option "fifo_conservative" + +NAME ** Cyrix MediaGX (generic) [cyrix] +#CHIPSET cyrix +SERVER SVGA +DRIVER cyrix + +NAME ** Linux framebuffer (generic) [fbdev] +#CHIPSET fbdev +SERVER SVGA +DRIVER fbdev + +NAME ** 3DLabs, TI (generic) [glint] +#CHIPSET glint +SERVER SVGA +DRIVER glint +LINE #Option "no_accel" + +NAME ** Number Nine I128 (generic) [i128] +#CHIPSET i128 +SERVER SVGA +DRIVER i128 + +NAME ** Intel i740 (generic) [i740] +#CHIPSET i740 +SERVER SVGA +DRIVER i740 + +NAME ** Intel i810 (generic) [i810] +#CHIPSET i810 +SERVER SVGA +DRIVER i810 + +NAME ** Matrox Graphics (generic) [mga] +#CHIPSET mga +SERVER SVGA +DRIVER mga +LINE # Option "mga_sdram" + +NAME ** NeoMagic (generic) [neomagic] +#CHIPSET neomagic +SERVER SVGA +DRIVER neomagic +LINE # Chipset "NM2160" +LINE # IOBase 0xfea00000 +LINE # MemBase 0xfd000000 +LINE # VideoRam 2048 +LINE # DacSpeed 90 +LINE # Option "linear" +LINE # Option "nolinear" +LINE # Option "sw_cursor" +LINE # Option "hw_cursor" +LINE # Option "no_accel" +LINE # Option "intern_disp" +LINE # Option "extern_disp" +LINE # Option "mmio" +LINE # Option "no_mmio" +LINE # Option "lcd_center" +LINE # Option "no_stretch" + +NAME ** NVIDIA (generic) [nv] +#CHIPSET nv +SERVER SVGA +DRIVER nv + +NAME ** Rendition (generic) [rendition] +#CHIPSET rendition +SERVER SVGA +DRIVER rendition +LINE # Option "sw_cursor" + +NAME ** S3 (not ViRGE or Savage) (generic) [s3] +#CHIPSET s3 +SERVER SVGA +DRIVER s3 + +NAME ** S3 ViRGE (generic) [s3virge] +#CHIPSET s3virge +SERVER SVGA +DRIVER s3virge +LINE # Option "xaa_benchmark" +LINE # Option "fifo_moderate" +LINE # Option "pci_burst_on" +LINE # Option "pci_retry" +LINE # Option "lcd_center" +LINE # Set_LCDClk <pixel_clock_for_LCD> + +NAME ** S3 Savage (generic) [savage] +#CHIPSET savage +SERVER SVGA +DRIVER savage + +NAME ** Silicon Motion (generic) [siliconmotion] +#CHIPSET siliconmotion +SERVER SVGA +DRIVER siliconmotion + +NAME ** SiS (generic) [sis] +#CHIPSET sis +SERVER SVGA +DRIVER sis +LINE # Option "no_accel" +LINE # Option "fifo_moderate" +LINE # Option "fifo_conserv" +LINE # Option "fifo_aggressive" +LINE # Option "no_BitBlt" +LINE # Option "fast_vram" +LINE # Option "pci_burst_on" +LINE # Option "xaa_benchmark" +LINE # Option "ext_eng_queue" + +NAME ** 3Dfx (generic) [tdfx] +#CHIPSET tdfx +SERVER SVGA +DRIVER tdfx + +NAME ** DEC TGA (generic) [tga] +#CHIPSET tga +SERVER SVGA +DRIVER tga + +NAME ** Trident (generic) [trident] +#CHIPSET trident +SERVER SVGA +DRIVER trident + +NAME ** Tseng Labs (generic) [tseng] +#CHIPSET tseng +SERVER SVGA +DRIVER tseng +LINE # Option "linear" +LINE # Option "noaccel" +LINE # Option "power_saver" +LINE # Option "fast_dram" +LINE # Option "pci_retry" +LINE # Option "hibit_high" +LINE # Option "hibit_low" +LINE # MemBase 0x3C00000 + +NAME ** VMWare guest OS (generic) [vmware] +#CHIPSET vmware +SERVER SVGA +DRIVER vmware + + +#Chips & Technologies + +#untested +NAME Chips & Technologies CT65520 +CHIPSET ct65520 +SERVER SVGA +DRIVER chips +LINE # Device section for C&T cards. +LINE # Option "suspend_hack" +LINE # Option "STN" +LINE # Option "no_stretch" +LINE # Option "no_center" +LINE # Option "use_modeline" +LINE # Option "fix_panel_size" +LINE # videoram 512 + +NAME Chips & Technologies CT65525 +CHIPSET ct65525 +LINE # Option "nolinear" +LINE # MemBase 0x03b00000 +SEE Chips & Technologies CT65520 + +NAME Chips & Technologies CT65530 +CHIPSET ct65530 +SEE Chips & Technologies CT65525 + +NAME Chips & Technologies CT65535 +CHIPSET ct65535 +NOCLOCKPROBE +LINE # Option "hw_clocks" +LINE # Textclockfreq 25.175 +SEE Chips & Technologies CT65530 + +NAME Chips & Technologies CT65540 +CHIPSET ct65540 +NOCLOCKPROBE +LINE # Option "use_18bit_bus" +SEE Chips & Technologies CT65535 + +NAME Chips & Technologies CT65545 +CHIPSET ct65545 +NOCLOCKPROBE +LINE # Option "noaccel" +LINE # Option "no_bitblt" +LINE # Option "xaa_no_color_exp" +LINE # Option "xaa_benchmark" +LINE # Option "hw_cursor" +LINE # Option "mmio" +SEE Chips & Technologies CT65540 + +NAME Chips & Technologies CT65546 +CHIPSET ct65546 +SEE Chips & Technologies CT65545 + +NAME Chips & Technologies CT65548 +CHIPSET ct65548 +SEE Chips & Technologies CT65545 + +NAME Chips & Technologies CT65550 +CHIPSET ct65550 +NOCLOCKPROBE +LINE # Option "noaccel" +LINE # Option "no_bitblt" +LINE # Option "xaa_no_color_exp" +LINE # Option "xaa_benchmark" +LINE # Option "hw_cursor" +LINE # Option "sync_on_green" +LINE # Option "fast_dram" +LINE # Option "use_vclk1" +LINE # Textclockfreq 25.175 +SEE Chips & Technologies CT65530 + +NAME Chips & Technologies CT65554 +CHIPSET ct65554 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT65555 +CHIPSET ct65555 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT68554 +CHIPSET ct68554 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT69000 +CHIPSET ct69000 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT69030 +CHIPSET ct69030 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT64200 +CHIPSET ct64200 +SERVER SVGA +DRIVER chips +LINE # Device section for C&T cards. +LINE # videoram 1024 + +NAME Chips & Technologies CT64300 +CHIPSET ct64300 +SERVER SVGA +DRIVER chips +LINE # Option "noaccel" +LINE # Option "no_bitblt" +LINE # Option "xaa_no_color_exp" +LINE # Option "xaa_benchmark" +LINE # Option "hw_cursor" +LINE # Option "nolinear" +LINE # MemBase 0x03b00000 +LINE # Option "hw_clocks" +LINE # Textclockfreq 25.175 +SEE Chips & Technologies CT64200 + +# Cirrus Logic + +#tested +NAME Cirrus Logic GD542x +SERVER SVGA +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE +LINE # Device section for Cirrus Logic GD5420/2/4/6/8/9-based cards. +LINE #MemBase 0x00e00000 +LINE #MemBase 0x04e00000 +LINE #Option "linear" + +#tested +NAME Cirrus Logic GD543x +CHIPSET CL-GD5430/5434/5436 +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE +LINE # Device section for Cirrus Logic GD5430/34-based cards. +LINE #MemBase 0x00e00000 # ISA card that maps to 14Mb +LINE #MemBase 0x04000000 # VLB card that maps to 64Mb +LINE #MemBase 0x80000000 # VLB card that maps to 2048Mb +LINE #MemBase 0x02000000 # VLB card that maps to 32Mb +LINE #Option "linear" + +NAME Cirrus Logic GD544x +CHIPSET CL-GD544x +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE + +NAME Creative Labs Graphics Blaster MA201 +SEE Cirrus Logic GD544x + +NAME Creative Labs Graphics Blaster MA202 +SEE Cirrus Logic GD544x + +#tested +NAME Cirrus Logic GD5462 +CHIPSET CL-GD5462 +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE +LINE #Option "fifo_conservative" + +#tested +NAME Cirrus Logic GD5464 +CHIPSET CL-GD5464 +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE +LINE #Option "fifo_conservative" + +#tested +NAME Cirrus Logic GD5465 +CHIPSET CL-GD5465 +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE +LINE #Option "fifo_conservative" + +NAME Creative Labs Graphics Blaster MA302 +CHIPSET CL-GD5462 +SEE Cirrus Logic GD5462 + +NAME Creative Labs Graphics Blaster MA334 +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME Creative Labs Graphics Blaster 3D +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +#tested +NAME Cirrus Logic GD5480 +CHIPSET CL-GD5480 +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE + +#tested +NAME Diamond SpeedStar 64 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Diamond SpeedStar64 Graphics 2000/2200 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Diamond SpeedStar Pro SE (CL-GD5430/5434) +SEE Cirrus Logic GD543x + +NAME Diamond SpeedStar Pro 1100 +SEE Cirrus Logic GD542x + +NAME Orchid Kelvin 64 VLB Rev A +CHIPSET CL-GD5434 +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE +LINE # Device section for Orchid Kelvin 64 VLB Rev A +LINE # Linear framebuffer maps at 2048Mb. Some motherboards make linear addressing +LINE # impossible. Some cards map at 32Mb. +LINE #MemBase 0x02000000 # VLB card that maps to 32Mb +LINE #MemBase 0x04000000 # VLB card that maps to 64Mb +LINE MemBase 0x80000000 # VLB card that maps to 2048Mb +LINE #Option "linear" + +NAME Orchid Kelvin 64 VLB Rev B +CHIPSET CL-GD5434 +SERVER SVGA +DRIVER cirrus +NOCLOCKPROBE +LINE # Device section for Orchid Kelvin 64 VLB Rev B +LINE # Linear framebuffer maps at 32Mb. Some motherboards make linear addressing +LINE # impossible. Some cards map at 2048Mb. +LINE MemBase 0x02000000 # VLB card that maps to 32Mb +LINE #MemBase 0x04000000 # VLB card that maps to 64Mb +LINE #MemBase 0x80000000 # VLB card that maps to 2048Mb +LINE #Option "linear" + +NAME Orchid Kelvin 64 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Intel 5430 +CHIPSET CL-GD5430 +SEE Cirrus Logic GD543x + +NAME STB Nitro (64) +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME STB Nitro 64 Video +CHIPSET CL-GD5446 +SEE Cirrus Logic GD544x + +NAME STB Horizon +CHIPSET CL-GD5426/28 +SEE Cirrus Logic GD542x + +NAME STB Horizon Video +CHIPSET CL-GD5440 +SEE Cirrus Logic GD544x + +NAME Genoa 8500VL(-28) +CHIPSET CL-GD5426/28 +SEE Cirrus Logic GD542x + +NAME Diamond SpeedStar Pro (not SE) +CHIPSET CL-GD5426/28 +SEE Cirrus Logic GD542x + +NAME ALG-5434(E) +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Actix ProStar +CHIPSET CL-GD5426/5428 +SEE Cirrus Logic GD542x + +NAME Actix ProStar 64 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +#tested +NAME Acumos AVGA3 +SEE Cirrus Logic GD542x + +NAME DFI-WG1000 +SEE Cirrus Logic GD542x + +NAME Spider VLB Plus +CHIPSET CL-GD5428 +SEE Cirrus Logic GD542x + +NAME VI720 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Cirrus Logic GD62xx (laptop) +CHIPSET CL-GD6205/15/25/35 +SERVER SVGA +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME Cirrus Logic GD64xx (laptop) +CHIPSET CL-GD6420/6440 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Cirrus Logic GD754x (laptop) +CHIPSET CL-GD7541/42/43/48 +SERVER SVGA +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME Techworks Ultimate 3D +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME VideoLogic GrafixStar 550 +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME Jaton Video-70P +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME PixelView Combo TV Pro (Prolink) +CHIPSET CL-GD5480, 4MB +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE # COMMENT on card TV Tuner +NOCLOCKPROBE + +NAME PixelView Combo TV 3D AGP (Prolink) +CHIPSET CL-GD5465, 4MB +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE # COMMENT on card TV+FM Tuner +NOCLOCKPROBE + +NAME Creative Labs Graphics Blaster Eclipse (OEM Model CT6510) +SEE Cirrus Logic GD5465 + +NAME VideoLogic GrafixStar 560 (PCI/AGP) +SEE Cirrus Logic GD5465 + +NAME Cirrus Logic GD5446 (noname card) +CHIPSET CL-GD5446, 1MB (upgradable to 2MB). +SERVER SVGA +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME Octek VL-VGA-26 +CHIPSET CL-GD5426 +SEE Cirrus Logic GD542x + +NAME Octek VL-VGA-28 +CHIPSET CL-GD5428 +SEE Cirrus Logic GD542x + +NAME Octek Combo-26 +CHIPSET CL-GD5426 +SEE Cirrus Logic GD542x + +NAME Octek Combo-28 +CHIPSET CL-GD5428 +SEE Cirrus Logic GD542x + +NAME Octek AVGA-20 +SEE Cirrus Logic GD542x + +# S3 801/805 + +NAME S3 801/805 (generic) +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED + +NAME S3 86C801 (generic) +SEE S3 801/805 (generic) + +NAME S3 86C805 (generic) +SEE S3 801/805 (generic) + +#tested +NAME S3 801/805 with ATT20c490 RAMDAC +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c490 +LINE #Option "dac_8_bit" # Not supported by some 20c490 clones + +NAME S3 801/805 with SC1148{2,3,4} RAMDAC +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC sc11482 + +NAME S3 801/805 with SC1148{5,7,9} RAMDAC +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC sc11485 + +NAME S3 801/805 with S3 GenDAC +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC s3gendac +CLOCKCHIP s3gendac + +NAME S3 801/805 with ATT20c490 RAMDAC and ICD2061A +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c490 +CLOCKCHIP icd2061a +LINE #Option "dac_8_bit" # Not supported by some 20c490 clones + +NAME S3 801/805 with Chrontel 8391 +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c490 +CLOCKCHIP ch8391 +LINE Option "dac_8_bit" + +#tested +NAME Actix GE32+ 2MB +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c490 +LINE #Option "dac_8_bit" + +NAME Actix GE32i +CHIPSET S3 805i +SERVER S3 +DRIVER vga +UNSUPPORTED + +NAME Orchid Fahrenheit VA +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c490 + +NAME Orchid Fahrenheit 1280 +CHIPSET S3 801 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Probable clocks: +LINE #Clocks 25.20 28.32 32.50 0.00 40.00 44.90 50.40 65.00 +LINE #Clocks 78.00 56.70 63.10 75.10 80.00 89.90 100.90 31.50 + +NAME Orchid Fahrenheit-1280+ +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20C490 +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE #Option "nolinear" # VLB card may require this +LINE #Probable clocks: +LINE #Clocks 25.20 28.32 40.0 0.0 50.10 77.0 36.10 45.0 +LINE #Clocks 130.0 120.20 80.0 31.50 110.30 65.0 75.0 94.60 + +NAME Diamond Stealth 24 +CHIPSET S3 801/805 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a +LINE #Option "nolinear" +LINE #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp + +NAME Miro Crystal 8S +SEE S3 801/805 (generic) + +NAME Miro Crystal 10SD with GenDAC +SEE S3 801/805 with S3 GenDAC + +NAME Dell S3 805 +SEE S3 801/805 (generic) + +NAME STB Powergraph X-24 +SEE S3 801/805 with ATT20c490 RAMDAC and ICD2061A + +NAME JAX 8241 +SEE S3 801/805 with Chrontel 8391 + +NAME VL-41 +SEE S3 801/805 with Chrontel 8391 + +NAME SPEA Mirage +SEE S3 801/805 with Chrontel 8391 + +# S3 864/Trio64/Trio32/868 + +NAME S3 864 (generic) +SERVER S3 +DRIVER vga +UNSUPPORTED + +NAME S3 86C864 (generic) +SEE S3 864 (generic) + +NAME S3 Vision864 (generic) +SEE S3 864 (generic) + +NAME S3 864 with SDAC (86C716) +CHIPSET S3 864 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC s3_sdac +CLOCKCHIP s3_sdac +NOCLOCKPROBE + +NAME S3 864 with ATT 20C498 or 21C498 +CHIPSET S3 864 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c498 + +NAME S3 864 with STG1703 +CHIPSET S3 864 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC stg1703 +NOCLOCKPROBE + +NAME S3 868 (generic) +CHIPSET S3 868 +SERVER S3 +DRIVER vga +UNSUPPORTED + +NAME S3 86C868 (generic) +SEE S3 868 (generic) + +NAME S3 Vision868 (generic) +SEE S3 868 (generic) + +NAME S3 868 with SDAC (86C716) +CHIPSET S3 868 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME S3 868 with ATT 20C498 or 21C498 +CHIPSET S3 868 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c498 + +NAME S3 868 with ATT 20C409 +CHIPSET S3 868 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c409 +NOCLOCKPROBE + +NAME Number Nine FX Motion 531 +CLOCKCHIP icd2061a +SEE S3 868 with ATT 20C498 or 21C498 + +NAME S3 Trio64 (generic) +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME S3 86C764 (generic) +SEE S3 Trio64 (generic) + +NAME S3 Trio64V+ (generic) +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME S3 86C765 (generic) +SEE S3 Trio64V+ (generic) + +NAME S3 Trio32 (generic) +CHIPSET S3 Trio32 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME Genoa Phantom 64i with S3 SDAC +DACSPEED 135 +SEE S3 864 with SDAC (86C716) + +NAME Number Nine GXE64 +CHIPSET S3 864 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a +LINE Option "number_nine" + +NAME Number Nine GXE64 with S3 Trio64 +SEE S3 Trio64 (generic) + +NAME Diamond Stealth 64 DRAM with S3 SDAC +DACSPEED 135 +SEE S3 864 with SDAC (86C716) + +NAME Diamond Stealth64 Graphics 2xx0 series (864 + SDAC) +DACSPEED 135 +SEE S3 864 with SDAC (86C716) + +NAME Diamond Stealth 64 DRAM with S3 Trio64 +SEE S3 Trio64 (generic) + +NAME Diamond Stealth64 Graphics 2xx0 series (Trio64) +SEE S3 Trio64 (generic) + +NAME Diamond Stealth 64 DRAM SE +SEE S3 Trio32 (generic) + +NAME Diamond Stealth64 Video 2001 series (2121/2201) +SEE S3 Trio64V+ (generic) + +NAME Actix GE64 +CLOCKCHIP icd2061a +SEE S3 864 (generic) + +NAME ELSA Winner 1000PRO with S3 SDAC +SEE S3 864 with SDAC (86C716) + +NAME ELSA Winner 1000PRO with STG1700 or AT&T RAMDAC +CHIPSET S3 864 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a + +NAME ELSA Winner 1000PRO/X +SEE S3 868 with SDAC (86C716) + +NAME ELSA Winner 1000ISA +CHIPSET S3 805i +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a +LINE Option "dac_8_bit" +LINE # the following settings should be detected and set automatically by XF86_S3 +LINE # if the serial number of the ELSA card is printed correctly: +LINE #ClockChip "icd2061a" + +NAME Cardex Trio64 +SEE S3 Trio64 (generic) + +NAME Cardex Trio64Pro +SEE S3 Trio64 (generic) + +NAME Miro Crystal 12SD +SEE S3 Trio32 (generic) + +NAME Miro Crystal 22SD +SEE S3 Trio64 (generic) + +NAME Miro Crystal 20SD with ICS2494 (BIOS 1.xx) +SEE S3 864 with ATT 20C498 or 21C498 + +NAME Miro Crystal 20SD with ICD2061A (BIOS 2.xx) +CLOCKCHIP icd2061a +SEE S3 864 with ATT 20C498 or 21C498 + +NAME Miro Crystal 20SD VLB with S3 SDAC (BIOS 3.xx) +SEE S3 864 with SDAC (86C716) + +NAME Miro Crystal 20SD PCI with S3 SDAC +SEE S3 868 with SDAC (86C716) + +NAME ELSA Winner 1000AVI (SDAC version) +SEE S3 868 with SDAC (86C716) + +NAME ELSA Winner 1000AVI (AT&T 20C409 version) +SEE S3 868 with ATT 20C409 + +NAME Diamond Stealth Video DRAM +SEE S3 868 with SDAC (86C716) + +NAME Diamond Stealth64 Video 2120/2200 +SEE S3 868 with SDAC (86C716) + +NAME SPEA/V7 Mirage P64 +CLOCKCHIP ics2595 +SEE S3 864 (generic) + +NAME SPEA/V7 Mirage P64 with S3 Trio64 +SEE S3 Trio64 (generic) + +NAME Number Nine FX Vision 330 +SEE S3 Trio64 (generic) + +NAME Number Nine FX Motion 331 +SEE S3 Trio64V+ (generic) + +NAME ASUS Video Magic PCI V864 +SEE S3 864 (generic) + +NAME ASUS Video Magic PCI VT64 +SEE S3 Trio64 (generic) + +NAME VidTech FastMax P20 +SEE S3 864 (generic) + +NAME VideoLogic GrafixStar 500 +SEE S3 868 with SDAC (86C716) + +NAME VideoLogic GrafixStar 400 +SEE S3 Trio64V+ (generic) + +NAME VideoLogic GrafixStar 300 +SEE S3 Trio64 (generic) + +NAME 2 the Max MAXColor S3 Trio64V+ +SEE S3 Trio64V+ (generic) + +NAME DataExpert DSV3365 +SEE S3 Trio64V+ (generic) + +NAME ExpertColor DSV3365 +SEE S3 Trio64V+ (generic) + +NAME DSV3326 +SEE S3 Trio64V+ (generic) + +# S3 Trio64V2 + +NAME S3 Trio64V2 (generic) +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME S3 Trio64V2/DX (generic) +SEE S3 Trio64V2 (generic) + +NAME S3 Trio64V2/GX (generic) +SEE S3 Trio64V2 (generic) + +NAME S3 86C775 (generic) +SEE S3 Trio64V2/DX (generic) + +NAME S3 86C785 (generic) +SEE S3 Trio64V2/GX (generic) + +NAME ELSA WINNER 1000/T2D +SEE S3 Trio64V2/DX (generic) + + +# S3 Aurora64V+ + +NAME S3 Aurora64V+ (generic) +CHIPSET S3 Aurora64V+ +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE +LINE # Option "lcd_center" +LINE # Set_LCDClk <pixel_clock_for_LCD> + +NAME S3 86CM65 +SEE S3 Aurora64V+ (generic) + +NAME SHARP 9080 +SEE S3 Aurora64V+ (generic) + +NAME SHARP 9090 +SEE S3 Aurora64V+ (generic) + +NAME COMPAQ Armada 7730MT +SEE S3 Aurora64V+ (generic) + +NAME COMPAQ Armada 7380DMT +SEE S3 Aurora64V+ (generic) + + +# S3 964/968 + +NAME S3 964 (generic) +CHIPSET S3 964 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME S3 86C964 (generic) +SEE S3 964 (generic) + +NAME S3 Vision964 (generic) +SEE S3 964 (generic) + +NAME S3 968 (generic) +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME S3 86C968 (generic) +SEE S3 968 (generic) + +NAME S3 Vision968 (generic) +SEE S3 968 (generic) + +NAME Number Nine GXE64 Pro +CHIPSET S3 964 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC ti3025 +LINE Option "number_nine" + +NAME Diamond Stealth 64 VRAM +CLOCKCHIP icd2061a +LINE #Option "slow_vram" +SEE S3 964 (generic) + +NAME Diamond Stealth64 Video 3200 +CHIPSET S3 968 +LINE #Option "slow_vram" +SEE S3 968 (generic) + +NAME Diamond Stealth 64 Video VRAM (TI RAMDAC) +CHIPSET S3 968 +LINE #Option "slow_vram" +LINE #DacSpeed 220 +SEE S3 968 (generic) + +NAME Diamond Stealth64 Video 3240/3400 (TI RAMDAC) +CHIPSET S3 968 +LINE #Option "slow_vram" +LINE #DacSpeed 220 +SEE S3 968 (generic) + +NAME Diamond Stealth64 Video 3240/3400 (IBM RAMDAC) +CHIPSET S3 968 +LINE #Option "slow_vram" +RAMDAC ibm_rgb526 +LINE DacSpeed 220 +SEE S3 968 (generic) + +NAME Genoa VideoBlitz III AV +CHIPSET S3 968 +LINE #s3RefClk 50 +LINE #DACspeed 170 +SEE S3 968 (generic) + +NAME STB Velocity 64 Video +CHIPSET S3 968 +LINE #s3RefClk 24 +LINE #DACspeed 220 +SEE S3 968 (generic) + +NAME STB Powergraph 64 Video +SEE S3 Trio64V+ (generic) + +NAME STB Powergraph 64 +SEE S3 Trio64 (generic) + +NAME ELSA Winner 1000TRIO +SEE S3 Trio64 (generic) + +NAME ELSA Winner 1000TRIO/V +SEE S3 Trio64V+ (generic) + +NAME Hercules Graphite Terminator 64 +LINE Option "slow_vram" +LINE #s3RefClk 50 +LINE #DACspeed 170 +SEE S3 964 (generic) + +NAME Hercules Terminator 64/Video +SEE S3 Trio64V+ (generic) + +NAME Hercules Graphite Terminator 64/DRAM +SEE S3 Trio64 (generic) + +NAME Hercules Graphite Terminator Pro 64 +LINE #s3RefClk 16 +LINE #DACspeed 220 +SEE S3 968 (generic) + +NAME Number Nine FX Motion 771 +LINE #s3RefClk 16 +SEE S3 968 (generic) + +NAME Spider Tarantula 64 +SEE S3 964 (generic) + +NAME Miro Crystal 20SV +CHIPSET S3 964 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a + +NAME Miro Crystal 40SV +CHIPSET S3 964 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP ti3025 + +NAME Miro Crystal 80SV +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME Miro Video 20SV +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c505 +LINE #DacSpeed 150 +CLOCKCHIP ics9161a + +NAME SPEA Mercury 64 +CHIPSET S3 964 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP ics9161a +LINE #Option "spea_mercury" + +NAME ELSA Winner 2000PRO-2 +CHIPSET S3 964 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "ELSA_w2000pro" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO-4 +CHIPSET S3 964 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "ELSA_w2000pro" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO/X-2 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO/X-4 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO/X-8 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Winner 2000AVI +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Gloria-4 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Gloria-8 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME VideoLogic GrafixStar 700 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME LeadTek WinFast S430 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME WinFast S430 +SEE LeadTek WinFast S430 + +NAME LeadTek WinFast S510 +CHIPSET S3 968 +SERVER S3 +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME WinFast S510 +SEE LeadTek WinFast S510 + +# S3 928 + +NAME S3 928 (generic) +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED + +NAME S3 86C928 (generic) +SEE S3 928 (generic) + +NAME Actix Ultra +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC att20c490 +LINE #Option "dac_8_bit" + +NAME Diamond Stealth Pro +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a +LINE #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp +LINE #Option "no_linear" # Some VLB machines may require this + +NAME ELSA Winner 1000VL +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE # the following settings should be detected and set automatically by XF86_S3 +LINE # if the serial number of the ELSA card is printed correctly: +LINE #ClockChip "icd2061a" +LINE #Membase 0xf8000000 + +NAME ELSA Winner 1000TwinBus +SEE ELSA Winner 1000VL + +NAME ELSA Winner 2000 +SEE S3 928 (generic) + +NAME Miro Crystal 16S +SEE S3 928 (generic) + +NAME SPEA/V7 Mercury +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP sc11412 +LINE Option "spea_mercury" + +NAME STB Pegasus +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +RAMDAC bt485 +CLOCKCHIP icd2061a +LINE Option "stb_pegasus" +LINE #Option "sync_on_green" + +NAME Number Nine GXE Level 14/16 +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +DACSPEED 200 +CLOCKCHIP icd2061a +LINE Option "number_nine" +LINE #Option "nolinear" +LINE #Option "nomemaccess" + +NAME Number Nine GXE Level 10/11/12 +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a +LINE Option "number_nine" + +NAME 928Movie +CHIPSET S3 928 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2595 +RAMDAC bt485 +LINE # pixel multiplexing not supported + +# S3 911/924 + +NAME S3 911/924 (generic) +CHIPSET S3 911/924 +SERVER S3 +DRIVER vga +UNSUPPORTED + +NAME S3 86C911 (generic) +SEE S3 911/924 (generic) + +NAME S3 86C924 (generic) +SEE S3 911/924 (generic) + +NAME Diamond Stealth VRAM +CHIPSET S3 911/924 +SERVER S3 +DRIVER vga +UNSUPPORTED +CLOCKCHIP icd2061a + +#NAME Orchid Fahrenheit 1280 +#SEE S3 911/924 (generic) + +NAME S3 924 with SC1148 DAC +CHIPSET S3 924 +SERVER S3 +DRIVER vga +UNSUPPORTED +LINE #Probable clocks: +LINE #Clocks 25.2 28.3 39.7 1.7 49.9 76.7 35.7 44 +LINE #Clocks 130.2 119.5 79.4 31.2 110.0 65.2 74.9 71.3 + +# S3 ViRGE,/DX,/GX and ViRGE/VX + +NAME S3 ViRGE (old S3V server) +CHIPSET S3 ViRGE +SERVER S3V +DRIVER s3virge +NOCLOCKPROBE + +NAME S3 ViRGE (generic) +CHIPSET S3 ViRGE +SERVER SVGA +DRIVER s3virge +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + +NAME S3 ViRGE/DX (generic) +CHIPSET S3 ViRGE/DX +SERVER SVGA +DRIVER s3virge +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + +NAME S3 ViRGE/GX (generic) +CHIPSET S3 ViRGE/GX +SERVER SVGA +DRIVER s3virge +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + + +NAME S3 ViRGE/GX2 (generic) +CHIPSET S3 ViRGE/GX2 +SERVER SVGA +DRIVER s3virge +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + +NAME S3 ViRGE/MX (generic) +CHIPSET S3 ViRGE/MX +SERVER SVGA +DRIVER s3virge +NOCLOCKPROBE +LINE #Option "lcd_center" +LINE #Set_LCDClk <pixel_clock_for_LCD> +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + +NAME S3 ViRGE/MX+ (generic) +SEE S3 ViRGE/MX (generic) + + + + +NAME S3 86C325 (generic) +SEE S3 ViRGE (generic) + +NAME S3 86C375 (generic) +SEE S3 ViRGE/DX (generic) + +NAME S3 86C385 (generic) +SEE S3 ViRGE/GX (generic) + +NAME S3 86C357 (generic) +SEE S3 ViRGE/GX2 (generic) + +NAME S3 86C260 (generic) +SEE S3 ViRGE/MX (generic) + +NAME S3 86C280 (generic) +SEE S3 ViRGE/MX+ (generic) + + +NAME ELSA Victory 3D +SEE S3 ViRGE (generic) + +NAME ELSA Victory 3DX +SEE S3 ViRGE/DX (generic) + +NAME ELSA Winner 3000-S +SEE S3 ViRGE (generic) + +NAME Number Nine Visual 9FX Reality 332 +SEE S3 ViRGE (generic) + +NAME Number Nine FX Motion 332 +SEE S3 ViRGE (generic) + +NAME Diamond Stealth 3D 2000 +SEE S3 ViRGE (generic) + +NAME Diamond Stealth 3D 2000 PRO +SEE S3 ViRGE/DX (generic) + +NAME Diamond Multimedia Stealth 3D 2000 +SEE S3 ViRGE (generic) + +NAME Diamond Multimedia Stealth 3D 2000 PRO +SEE S3 ViRGE/DX (generic) + +NAME Canopus Co. Power Window 3DV +SEE S3 ViRGE (generic) + +NAME DataExpert DSV3325 +SEE S3 ViRGE (generic) + +NAME ExpertColor DSV3325 +SEE S3 ViRGE (generic) + +NAME DSV3325 +SEE S3 ViRGE (generic) + +NAME Hercules Terminator 64/3D +SEE S3 ViRGE (generic) + +NAME Hercules Terminator 3D/DX +SEE S3 ViRGE/DX (generic) + +NAME LeadTek WinFast 3D S600 +SEE S3 ViRGE (generic) + +NAME WinFast 3D S600 +SEE LeadTek WinFast 3D S600 + +NAME LeadTek WinFast 3D S680 +SEE S3 ViRGE/GX2 (generic) + +NAME Miro MiroMedia 3D +SEE S3 ViRGE (generic) + +NAME Orchid Technology Fahrenheit Video 3D +SEE S3 ViRGE (generic) + +NAME STB Systems Powergraph 3D +SEE S3 ViRGE (generic) + +NAME STB Nitro 3D +CHIPSET S3 ViRGE/GX +SEE S3 ViRGE/GX (generic) + +NAME MELCO WGP-VG4S +LINE #DACSpeed 191 162 111 83 +LINE #SetMClck 75 +SEE S3 ViRGE (generic) + + + +NAME S3 ViRGE/VX (generic) +CHIPSET S3 ViRGE/VX +SERVER SVGA +DRIVER s3virge +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + + +NAME S3 86C988 (generic) +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 3000 +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 3000-M-22 +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 3000-L-42 +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 2000AVI/3D +SEE S3 ViRGE/VX (generic) + +NAME Diamond Stealth 3D 3000 +SEE S3 ViRGE/VX (generic) + +NAME STB Systems Velocity 3D +SEE S3 ViRGE/VX (generic) + +NAME MELCO WGP-VX8 +SEE S3 ViRGE/VX (generic) + +NAME Diamond Stealth 3D 4000 +SEE S3 ViRGE/GX2 (generic) + +NAME Toshiba Tecra 750CDT +SEE S3 ViRGE/MX (generic) + +NAME Toshiba Tecra 750DVD +SEE S3 ViRGE/MX (generic) + +NAME Toshiba Tecra 540CDT +SEE S3 ViRGE/MX (generic) + +NAME Toshiba Tecra 550CDT +SEE S3 ViRGE/MX (generic) + +# currently unsupported S3 + +NAME S3 86C365 (Trio3D) +SEE * Unsupported VGA compatible + +NAME S3 86C391 (Savage3D) +SEE * Unsupported VGA compatible + +NAME S3 Trio3D +SEE * Unsupported VGA compatible + +NAME S3 Savage3D +SEE * Unsupported VGA compatible + +NAME S3 Savage4 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +# ET4000/ET6000 + +NAME ET3000 (generic) +CHIPSET ET3000 +SERVER SVGA +DRIVER tseng + +NAME Genoa 5400 +SEE ET3000 (generic) + +NAME ET4000 (generic) +CHIPSET ET4000 +SERVER SVGA +DRIVER tseng + +NAME ET4000/W32 (generic) +CHIPSET ET4000/W32 +SERVER W32 +DRIVER tseng + +NAME ET4000 W32i, W32p (generic) +CHIPSET ET4000/W32(i/p) +SERVER SVGA +DRIVER tseng +LINE #Option "linear" # for linear mode at 8bpp +LINE #Option "noaccel" # when problems with accelerator +LINE #Option "power_saver" # enable VESA DPMS +LINE #Option "fast_dram" +LINE #Option "pci_retry" # faster, but problematic for ISA DMA +LINE #Option "hibit_high" # see README.tseng -- most cards need this +LINE #Option "hibit_low" # see README.tseng -- mostly for older ET4000 cards +LINE #MemBase 0x3C00000 # when automatic MemBase detection doesn't work +LINE # -- see README.tseng for more (important) information on MemBase + +NAME ET6000 (generic) +CHIPSET ET6000 +SERVER SVGA +DRIVER tseng +NOCLOCKPROBE +LINE #videoram 2304 # 2.25 MB, when memory probe is incorrect +LINE #Option "linear" # for linear mode at 8bpp +LINE #Option "noaccel" # when problems with accelerator +LINE #Option "power_saver" # enable VESA DPMS +LINE #Option "pci_retry" # faster, but problematic for ISA DMA +LINE #Option "hw_cursor" # Use hardware cursor (see docs for limitations) +LINE #Option "xaa_no_color_exp" # When text (or bitmap) is not rendered correctly + +NAME ET6100 (generic) +CHIPSET ET6100 +SEE ET6000 (generic) + +NAME Diamond Stealth 32 +CLOCKCHIP icd2061a +NOCLOCKPROBE +SEE ET4000 W32i, W32p (generic) + +NAME Cardex Cobra +SEE ET4000 W32i, W32p (generic) + +NAME Cardex Challenger (Pro) +SEE ET4000 W32i, W32p (generic) + +NAME Colorgraphic Dual Lightning +SEE ET4000 W32i, W32p (generic) + +NAME Dell onboard ET4000 +SEE ET4000 (generic) + +NAME DFI-WG5000 +SEE ET4000 W32i, W32p (generic) + +NAME Diamond SpeedStar (Plus) +SEE ET4000 (generic) + +NAME Diamond SpeedStar 24 +SEE ET4000 (generic) + +NAME Diamond SpeedStar HiColor +SEE ET4000 (generic) + +NAME Genoa 8900 Phantom 32i +SEE ET4000 W32i, W32p (generic) + +NAME Hercules Dynamite +SEE ET4000/W32 (generic) + +NAME Hercules Dynamite Power +SEE ET4000 W32i, W32p (generic) + +NAME Hercules Dynamite Pro +SEE ET4000 W32i, W32p (generic) + +NAME Integral FlashPoint +SEE ET4000 W32i, W32p (generic) + +NAME LeadTek WinFast S200 +SEE ET4000 W32i, W32p (generic) + +NAME Matrox Comet +SEE ET4000 W32i, W32p (generic) + +NAME Matrox Marvel II +SEE ET4000 W32i, W32p (generic) + +NAME Miro MiroVideo 20TD +SEE ET4000 W32i, W32p (generic) + +NAME WinFast S200 +SEE LeadTek WinFast S200 + +NAME Sigma Concorde +SEE ET4000/W32 (generic) + +NAME Sigma Legend +SEE ET4000 (generic) + +NAME SPEA/V7 ShowTime Plus +SEE ET4000 W32i, W32p (generic) + +NAME STB LightSpeed +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-2 +SEE ET4000 (generic) + +NAME STB MVP-2 PCI +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-2X +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-4 PCI +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-4X +SEE ET4000 W32i, W32p (generic) + +NAME TechWorks Thunderbolt +SEE ET4000/W32 (generic) + +NAME ViewTop PCI +SEE ET4000 W32i, W32p (generic) + +NAME SNI PC5H W32 +CLOCKCHIP stg1703 +NOCLOCKPROBE +SEE ET4000 W32i, W32p (generic) + +NAME SNI Scenic W32 +CLOCKCHIP stg1703 +NOCLOCKPROBE +SEE ET4000 W32i, W32p (generic) + +NAME Hercules Dynamite 128/Video +SEE ET6000 (generic) + +NAME STB LightSpeed 128 +SEE ET6000 (generic) + +NAME VideoLogic GrafixStar 600 +SEE ET6000 (generic) + +NAME Jazz Multimedia G-Force 128 +SEE ET6000 (generic) + +NAME Mirage Z-128 +SEE ET6000 (generic) + +NAME California Graphics SunTracer 6000 +SEE ET6000 (generic) + +NAME Binar Graphics AnyView +SEE ET6000 (generic) + +NAME MediaVision Proaxcel 128 +SEE ET6000 (generic) + +NAME ATrend ATC-2165A +SEE ET6000 (generic) + +NAME Interay PMC Viper +SEE ET6000 (generic) + +NAME 2-the-Max MAXColor 6000 +SEE ET6000 (generic) + +NAME Gainward Challenger EV +SEE ET6000 (generic) + +NAME MachSpeed VGA ET6000 +SEE ET6000 (generic) + +NAME KouTech KeyVision 128 EV +SEE ET6000 (generic) + +NAME Jaton Video-58P +SEE ET6000 (generic) + +# ATI + +NAME ATI Rage 128 +CHIPSET ati +SERVER SVGA +DRIVER ati + +NAME ATI 8514 Ultra (no VGA) +CHIPSET ati +SERVER Mach8 +DRIVER vga +UNSUPPORTED + +NAME ATI Graphics Ultra +CHIPSET ati +SERVER Mach8 +DRIVER ati + +NAME ATI Graphics Ultra Pro +CHIPSET ati +SERVER Mach32 +DRIVER ati + +NAME ATI Wonder SVGA +CHIPSET ati +SERVER SVGA +DRIVER ati + +NAME ATI Ultra Plus +CHIPSET ati +SERVER Mach32 +DRIVER ati + +NAME ATI Mach32 +CHIPSET ati +SERVER Mach32 +DRIVER ati + +NAME ATI Mach64 +CHIPSET ati +SERVER Mach64 +DRIVER ati +NOCLOCKPROBE + +NAME ATI Mach64 CT (264CT) +SEE ATI Mach64 + +NAME ATI Mach64 VT (264VT) +SEE ATI Mach64 + +NAME ATI Mach64 GT (264GT), aka 3D RAGE +SEE ATI Mach64 + +NAME ATI Mach64 3D RAGE II +SEE ATI Mach64 + +NAME ATI Mach64 3D RAGE II+DVD +SEE ATI Mach64 + +NAME ATI Mach64 3D Rage IIC +SEE ATI Mach64 + +NAME ATI Mach64 3D Rage Pro +SEE ATI Mach64 + +NAME ATI 3D Pro Turbo +SEE ATI Mach64 + +NAME ATI 3D Pro Turbo PC2TV +SEE ATI Mach64 + +NAME ATI 3D Xpression +SEE ATI Mach64 + +NAME ATI 3D Xpression+ +SEE ATI Mach64 + +NAME ATI 3D Xpression+ PC2TV +SEE ATI Mach64 + +NAME ATI All-in-Wonder +SEE ATI Mach64 + +NAME ATI All-in-Wonder Pro +SEE ATI Mach64 + +NAME ATI Graphics Pro Turbo +SEE ATI Mach64 + +NAME ATI Graphics Pro Turbo 1600 +SEE ATI Mach64 + +NAME ATI Graphics Xpression +SEE ATI Mach64 + +NAME ATI Video Boost +SEE ATI Mach64 + +NAME ATI Video Charger +SEE ATI Mach64 + +NAME ATI Video Xpression +SEE ATI Mach64 + +NAME ATI Video Xpression+ +SEE ATI Mach64 + +NAME ATI WinBoost +SEE ATI Mach64 + +NAME ATI WinCharger +SEE ATI Mach64 + +NAME ATI WinTurbo +SEE ATI Mach64 + +NAME ATI Xpert 98 +SEE ATI Mach64 + +NAME ATI Xpert XL +SEE ATI Mach64 + +NAME ATI Xpert@Play +SEE ATI Mach64 + +NAME ATI Xpert@Play 98 +SEE ATI Mach64 + +NAME ATI Xpert@Work +SEE ATI Mach64 + +NAME ATI integrated on Intel Maui MU440EX motherboard +SEE ATI Mach64 + +NAME ASUS PCI-V264CT +SEE ATI Mach64 + +NAME ASUS PCI-AV264CT +SEE ATI Mach64 + +# AGX + +NAME AGX (generic) +CHIPSET AGX-014/15/16 +SERVER AGX +DRIVER vga +UNSUPPORTED + +NAME Boca Vortex (Sierra RAMDAC) +CHIPSET AGX-015 +SERVER AGX +DRIVER vga +UNSUPPORTED +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + +NAME EIZO (VRAM) +SEE AGX (generic) + +NAME Orchid Celsius (AT&T RAMDAC) +CHIPSET AGX-015 +SERVER AGX +DRIVER vga +UNSUPPORTED +RAMDAC att20c490 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + +NAME Orchid Celsius (Sierra RAMDAC) +CHIPSET AGX-015 +SERVER AGX +DRIVER vga +UNSUPPORTED +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + + +NAME Spider Black Widow +CHIPSET AGX-015 +SERVER AGX +DRIVER vga +UNSUPPORTED +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + + +NAME Spider Black Widow Plus +CHIPSET AGX-016 +SERVER AGX +DRIVER vga +UNSUPPORTED +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels +LINE #Option "fifo_aggressive" # 3x bus bw - may result in random pixels +LINE #Probable clocks: +LINE #Clocks 25.2 28.3 39.9 72.2 50.0 76.9 36.1 44.8 +LINE #Clocks 89.0 119.8 79.9 31.5 110.0 64.9 74.9 94.9 + +NAME Hercules Graphite HG210 +CHIPSET AGX-014 +SERVER AGX +DRIVER vga +UNSUPPORTED +RAMDAC bt482 +DACSPEED 85 +LINE Chipset "AGX-014" +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Probable clocks: +LINE #Clocks 25.0 28.0 32.0 36.0 40.0 45.0 50.0 65.0 +LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0 + +NAME Hercules Graphite Pro +CHIPSET AGX-015 +SERVER AGX +DRIVER vga +UNSUPPORTED +# Card specific DAC, doesn't appear in ramdac menu +LINE Ramdac "herc_dual_dac" +LINE Chipset "AGX-015" +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels +LINE #Probable clocks: +LINE #Clocks 25.0 28.0 32.0 36.0 40.0 45.0 50.0 65.0 +LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0 + +NAME Hercules Graphite Power +CHIPSET AGX-016 +SERVER AGX +DRIVER vga +UNSUPPORTED +# Card specific DAC, doesn't appear in ramdac menu +# The glue logic state machine for RAMDAC switching doesn't work as +# documented, for now we're stuck with the small RAMDAC +LINE Ramdac "herc_small_dac" +LINE Chipset "AGX-016" +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels +LINE #Option "fifo_aggressive" # 3x bus bw - may result in random pixels +LINE #Probable clocks: +LINE #Clocks 25.0 28.0 32.0 36.0 40.0 45.0 50.0 65.0 +LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0 + +NAME XGA-2 (ISA bus) +CHIPSET XGA-2 +SERVER AGX +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE +LINE #Instance 7 # XGA instance 0-7 +LINE #COPbase 0xC8F00 # XGA memory-mapped register address +LINE #POSbase 0 # Disable probing if above are specified + +NAME XGA-1 (ISA bus) +CHIPSET XGA-1 +SERVER AGX +DRIVER vga +UNSUPPORTED +LINE #Instance 7 # XGA instance 0-7 +LINE #COPbase 0xC8F00 # XGA memory-mapped register address +LINE #POSbase 0 # Disable probing if above are specified + +# WD + +NAME Paradise/WD 90CXX +CHIPSET WD90CXX +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME DFI-WG6000 +CHIPSET WD90C33 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Diamond SpeedStar 24X (not fully supported) +CHIPSET WD90C31 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME WD 90C24 (laptop) +CHIPSET WD90C24 +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE #Chipset "wd90c24" +LINE #Option "noaccel" # Use this if acceleration is causing problems +LINE #Clocks 25.175 28.322 65 36 # These are not programmable +LINE #Clocks 29.979 77.408 62.195 59.957 # These are programmable +LINE #Clocks 31.5 35.501 75.166 50.114 # These are not programmable +LINE #Clocks 39.822 72.038 44.744 80.092 # These are programmable +LINE #Clocks 44.297 # Must match Mclk + + +NAME WD 90C24A or 90C24A2 (laptop) +CHIPSET WD90C24A +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE #Chipset "wd90c24" +LINE #Clocks 25.175 28.322 65 36 # These are not programmable +LINE #Clocks 29.979 77.408 62.195 59.957 # These are programmable +LINE #Clocks 31.5 35.501 75.166 50.114 # These are not programmable +LINE #Clocks 39.822 72.038 44.744 80.092 # These are programmable +LINE #Clocks 44.297 # Must match Mclk + +# Avance Logic + +NAME Avance Logic 2101 +CHIPSET Avance Logic +LINE #chipset "al2101" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Avance Logic 2228 +CHIPSET Avance Logic +LINE #chipset "ali2228" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Avance Logic 2301 +CHIPSET Avance Logic +LINE #chipset "ali2301" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Avance Logic 2302 +CHIPSET Avance Logic +LINE #chipset "ali2302" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Avance Logic 2308 +CHIPSET Avance Logic +LINE #chipset "ali2308" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Avance Logic 2401 +CHIPSET Avance Logic +LINE #chipset "ali2401" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Hercules Stingray +CHIPSET ALG-2228/2301/2302 +LINE #chipset "ali2228" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME SPEA/V7 Mirage VEGA Plus +CHIPSET ALG-2228 +LINE #chipset "ali2228" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +# ARK Logic + +NAME Ark Logic ARK1000PV (generic) +CHIPSET ARK1000PV +SERVER SVGA +DRIVER vga +UNSUPPORTED + +# For now, treat the VL as a PV. This may be changed later +NAME Ark Logic ARK1000VL (generic) +CHIPSET ARK1000VL +LINE Chipset "ark1000pv" +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Ark Logic ARK2000PV (generic) +CHIPSET ARK1000PV +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Ark Logic ARK2000MT (generic) +CHIPSET ARK1000MT +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Hercules Stingray Pro +SEE Ark Logic ARK1000PV (generic) + +NAME Hercules Stingray Pro/V +SEE Ark Logic ARK1000PV (generic) + +NAME Ocean (octek) VL-VGA-1000 +RAMDAC att20c490 +SEE Ark Logic ARK1000VL (generic) + +NAME Hercules Stingray 64/V with ZoomDAC +SEE Ark Logic ARK2000PV (generic) + +NAME Hercules Stingray 64/V with ICS5342 +CHIPSET ARK2000MT +RAMDAC ics5342 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Diamond Stealth64 Graphics 2001 series +CHIPSET ARK2000PV +RAMDAC ics5342 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +# Oak + +NAME Oak ISA Card (generic) +CHIPSET Oak OTI-067/77 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Oak 87 VLB (generic) +CHIPSET Oak OTI-087 +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE Option "fifo_aggressive" # Comment this if you experience streaks. +LINE Option "no_wait" # Comment this if you find problems. +LINE #Option "enable_bitblt" # You may enable this and see if it works (see README.Oak file) + +NAME Oak 87 ISA (generic) +CHIPSET Oak OTI-087 +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE Option "noaccel" # ISA cards seem to have Color Expansion support broken +LINE #Option "enable_bitblt" # This should work on ISA, but lets not make it default just in case. + +NAME Paradise Accelerator Value +SEE Oak 87 ISA (generic) + +# P9000 + +NAME Diamond Viper VLB 2Mb +CHIPSET Weitek 9000 +SERVER P9000 +DRIVER vga +UNSUPPORTED +LINE #Clocks must match the mode clocks (XFree86 3.1 P9000 server) +LINE #Versions later than 3.1 do not require a clocks line +LINE Chipset "vipervlb" # Required for some cards which autodetect as PCI +LINE Videoram 2048 # Required +LINE Membase 0x80000000 # Optional (0x80000000 is default) +NOCLOCKPROBE + +NAME Diamond Viper PCI 2Mb +CHIPSET Weitek 9000 +SERVER P9000 +DRIVER vga +UNSUPPORTED +LINE #Clocks must match the mode clocks (XFree86 3.1 P9000 server) +LINE #Versions later than 3.1 do not require a clocks line +LINE Videoram 2048 # Required +LINE #Membase 0x80000000 # Use scanpci to get the correct Membase +NOCLOCKPROBE + +NAME Orchid P9000 VLB +CHIPSET Weitek 9000 +SERVER P9000 +DRIVER vga +UNSUPPORTED +LINE Chipset "orchid_p9000" +LINE Membase 0xE0000000 +NOCLOCKPROBE + +# P9100 + +NAME Weitek P9100 (generic) +CHIPSET Weitek P9100 +SERVER SVGA +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME Diamond Viper Pro Video +SEE Weitek P9100 (generic) + +# Trident + +NAME Trident 8900/9000 (generic) +CHIPSET TVGA8900/9000 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Trident 8900D (generic) +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Trident TVGA9200CXr (generic) +CHIPSET TVGA9200CXr +SERVER SVGA +DRIVER vga +UNSUPPORTED + +NAME Trident TGUI9400CXi (generic) +CHIPSET TGUI9400CXi +SERVER SVGA +DRIVER trident + +NAME Trident TGUI9420DGi (generic) +CHIPSET TGUI9420DGi +SERVER SVGA +DRIVER trident + +NAME Trident TGUI9430DGi (generic) +CHIPSET TGUI9430DGi +SERVER SVGA +DRIVER trident + +NAME Trident TGUI9420 (generic) +CHIPSET TGUI9420 +DRIVER trident +NOCLOCKPROBE + +NAME Trident TGUI9440 (generic) +CHIPSET TGUI9440 +DRIVER trident +NOCLOCKPROBE + +NAME Trident TGUI9660 (generic) +CHIPSET TGUI9660 +DRIVER trident +NOCLOCKPROBE + +NAME Trident TGUI9680 (generic) +CHIPSET TGUI9680 +DRIVER trident +NOCLOCKPROBE + +NAME Trident TGUI9682 (generic) +CHIPSET TGUI9682 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident TGUI9685 (generic) +CHIPSET TGUI9685 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Cyber 9320 (generic) +CHIPSET Cyber9320 +DRIVER trident +NOCLOCKPROBE + +NAME Trident Cyber 9382 (generic) +CHIPSET Cyber9382 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Cyber 9385 (generic) +CHIPSET Cyber9385 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Cyber 9388 (generic) +CHIPSET Cyber9388 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Cyber 939a (generic) +CHIPSET Cyber939a +DRIVER trident +NOCLOCKPROBE + +NAME Trident Cyber 9397 (generic) +CHIPSET Cyber9397 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Cyber 9520 (generic) +CHIPSET Cyber9520 +DRIVER trident +NOCLOCKPROBE + +NAME Trident 3DImage975 (generic) +CHIPSET 3dimage975 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident 3DImage975 AGP (generic) +CHIPSET 3dimage975 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident 3DImage985 (generic) +CHIPSET 3dimage985 +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Providia 9682 (generic) +CHIPSET Providia9682 +DRIVER trident +NOCLOCKPROBE + +NAME Trident Providia 9685 (generic) +CHIPSET Providia9685 +DRIVER trident +NOCLOCKPROBE + +NAME Trident TVGA 8800BR +SEE * Generic VGA compatible + +NAME Trident TVGA 8800CS +SEE * Generic VGA compatible + +NAME Trident CyberBlade (generic) +CHIPSET CyberBlade +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Blade3D (generic) +CHIPSET Blade3D +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +# SiS + +NAME SiS 530 +CHIPSET SIS530 +SERVER SVGA +DRIVER sis + +NAME SiS 620 +CHIPSET SIS620 +SERVER SVGA +DRIVER sis + +NAME SiS SG86C201 +CHIPSET SIS86C201 +SERVER SVGA +DRIVER sis + +NAME SiS SG86C205 +CHIPSET SIS86C205 +SERVER SVGA +DRIVER sis +LINE # Option "no_accel" # Use this if acceleration is causing problems +LINE # Option "fifo_moderate" +LINE # Option "fifo_conserv" +LINE # Option "fifo_aggressive" +NOCLOCKPROBE + +NAME SiS SG86C215 +CHIPSET SIS86C215 +SERVER SVGA +DRIVER sis +LINE # This is a cheap version of 86c205. I am not sure if acceleration works +LINE # Option "no_accel" # Use this if acceleration is causing problems +LINE # Option "no_BitBlt" # Use this if acceleration is causing problems +LINE # Option "fifo_moderate" +LINE # Option "fifo_conserv" +LINE # Option "fifo_aggressive" +NOCLOCKPROBE + +NAME SiS SG86C225 +CHIPSET SIS86C225 +SERVER SVGA +DRIVER sis +LINE # Option "no_accel" # Use this if acceleration is causing problems +LINE # Option "fifo_moderate" +LINE # Option "fifo_conserv" +LINE # Option "fifo_aggressive" +NOCLOCKPROBE + +NAME SiS 5597 +CHIPSET SiS5597 +SERVER SVGA +DRIVER sis +LINE # Option "no_accel" # Use this if acceleration is causing problems +LINE # Option "fifo_moderate" +LINE # Option "fifo_conserv" +LINE # Option "fifo_aggressive" +LINE # Option "fast_vram" +LINE # Option "pci_burst_on" +LINE # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!! +LINE # Option "ext_eng_queue" # Turbo-queue. This can cause drawing +LINE # errors, but gives some accel +NOCLOCKPROBE + +NAME SiS 5598 +CHIPSET SIS5598 +SERVER SVGA +DRIVER sis +LINE # Option "no_accel" # Use this if acceleration is causing problems +LINE # Option "fifo_moderate" +LINE # Option "fifo_conserv" +LINE # Option "fifo_aggressive" +LINE # Option "fast_vram" +LINE # Option "pci_burst_on" +LINE # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!! +LINE # Option "ext_eng_queue" # Turbo-queue. This can cause drawing +LINE # errors, but gives some accel +NOCLOCKPROBE + +NAME SiS 6326 +CHIPSET SiS6326 +SERVER SVGA +DRIVER sis +LINE # Option "no_accel" # Use this if acceleration is causing problems +LINE # Option "fifo_moderate" +LINE # Option "fifo_conserv" +LINE # Option "fifo_aggressive" +LINE # Option "fast_vram" +LINE # Option "pci_burst_on" +LINE # Option "xaa_benchmark" # DON'T use with "ext_eng_queue" !!! +LINE # Option "ext_eng_queue" # Turbo-queue. This can cause drawing +LINE # errors, but gives some accel +NOCLOCKPROBE + +NAME MSI MS-4417 +SEE SiS 6326 + +NAME SiS 3D PRO AGP +SEE SiS 6326 + +NAME Miro Crystal DVD +SEE SiS 6326 + +NAME PC-Chips M567 Mainboard +SEE SiS 5597 + +NAME Diamond SpeedStar A50 +SEE SiS 6326 + +# Cyrix + +NAME MediaGX +CHIPSET mediagx +SERVER SVGA +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +# Alliance ProMotion + +NAME Alliance ProMotion 6422 +CHIPSET AP6422 +SERVER SVGA +DRIVER vga +UNSUPPORTED + +# Number 9 I128 + +NAME Number Nine Imagine I-128 +CHIPSET I128 +SERVER I128 +DRIVER i128 +NOCLOCKPROBE + +NAME Number Nine Imagine I-128 Series 2 +CHIPSET I128 +SERVER I128 +DRIVER i128 +NOCLOCKPROBE + +NAME Number Nine Revolution 3D (T2R) +CHIPSET I128 +SERVER I128 +DRIVER i128 +NOCLOCKPROBE + +NAME Number Nine Imagine-128 Revolution IV (T2R4) +CHIPSET I128 +SERVER I128 +DRIVER i128 +NOCLOCKPROBE + +# Matrox + +NAME Matrox Millennium 2MB +CHIPSET mga2064w +SERVER SVGA +DRIVER mga +LINE VideoRam 2048 +NOCLOCKPROBE + +NAME Matrox Millennium 4MB +CHIPSET mga2064w +SERVER SVGA +DRIVER mga +LINE VideoRam 4096 +NOCLOCKPROBE + +NAME Matrox Millennium 8MB +CHIPSET mga2064w +SERVER SVGA +DRIVER mga +LINE VideoRam 8192 +NOCLOCKPROBE + +NAME Matrox Millennium II 4MB +CHIPSET mga2164w +SERVER SVGA +DRIVER mga +LINE VideoRam 4096 +NOCLOCKPROBE + +NAME Matrox Millennium II 8MB +CHIPSET mga2164w +SERVER SVGA +DRIVER mga +LINE VideoRam 8192 +NOCLOCKPROBE + +NAME Matrox Millennium II 16MB +CHIPSET mga2164w +SERVER SVGA +DRIVER mga +LINE VideoRam 16384 +NOCLOCKPROBE + +NAME Matrox Millennium G200 4MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 4096 +NOCLOCKPROBE + +NAME Matrox Millennium G200 8MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 8192 +NOCLOCKPROBE + +NAME Matrox Millennium G200 16MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 16384 +NOCLOCKPROBE + +NAME Matrox Millennium G200 SD 4MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 4096 +LINE # Option "mga_sdram" +NOCLOCKPROBE + +NAME Matrox Millennium G200 SD 8MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 8192 +LINE # Option "mga_sdram" +NOCLOCKPROBE + +NAME Matrox Millennium G200 SD 16MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 16384 +LINE # Option "mga_sdram" +NOCLOCKPROBE + +NAME Matrox Mystique +CHIPSET mga1064sg +SERVER SVGA +DRIVER mga +NOCLOCKPROBE + +NAME Matrox Mystique G200 4MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 4096 +NOCLOCKPROBE + +NAME Matrox Mystique G200 8MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 8192 +NOCLOCKPROBE + +NAME Matrox Millennium G400 +CHIPSET mgag400 +SERVER SVGA +DRIVER mga +NOCLOCKPROBE + +NAME Matrox Mystique G200 16MB +CHIPSET mgag200 +SERVER SVGA +DRIVER mga +LINE VideoRam 16384 +NOCLOCKPROBE + +NAME Matrox Productiva G100 4MB +CHIPSET mgag100 +SERVER SVGA +DRIVER mga +LINE VideoRam 4096 +NOCLOCKPROBE + +NAME Matrox Productiva G100 8MB +CHIPSET mgag100 +SERVER SVGA +DRIVER mga +LINE VideoRam 8192 +NOCLOCKPROBE + +# NVIDIA + +NAME Diamond Edge 3D +CHIPSET nv1 +SERVER SVGA +DRIVER vga +UNSUPPORTED +NOCLOCKPROBE + +NAME RIVA128 +CHIPSET RIVA128 +SERVER SVGA +DRIVER nv +NOCLOCKPROBE + +NAME RIVA TNT +CHIPSET RIVATNT +SERVER SVGA +DRIVER nv +NOCLOCKPROBE + +NAME RIVA TNT2 +CHIPSET RIVATNT2 +SERVER SVGA +DRIVER nv +NOCLOCKPROBE + +NAME NVIDIA GeForce +CHIPSET GeForce +SERVER SVGA +DRIVER nv +NOCLOCKPROBE + +NAME ELSA VICTORY ERAZOR +SEE RIVA128 + +NAME ELSA Winner 1000 R3D +SEE RIVA128 + +NAME ELSA ERAZOR II +SEE RIVA TNT + +NAME Diamond Viper 330 +SEE RIVA128 + +NAME Diamond Viper 550 +SEE RIVA TNT + +NAME Diamond Viper 770 +SEE RIVA TNT2 + +NAME STB Velocity 128 +SEE RIVA128 + +NAME STB nvidia 128 +SEE RIVA128 + +NAME STB Velocity 4400 +SEE RIVA TNT + +NAME ASUS 3Dexplorer +SEE RIVA128 + +NAME Guillemot Maxi Gamer Xentor +SEE RIVA TNT2 + +NAME Guillemot Maxi Gamer Xentor 32 +SEE RIVA TNT2 + +NAME Creative Graphics Blaster TNT +SEE RIVA TNT + +NAME Creative Graphics Blaster TNT2 +SEE RIVA TNT2 + +# 3Dfx +NAME Voodoo Banshee (generic) +SERVER SVGA +CHIPSET 3dfx Banshee +DRIVER tdfx + +NAME Voodoo3 (generic) +SERVER SVGA +CHIPSET 3dfx Voodoo3 +DRIVER tdfx + +NAME Elsa Victory II +SEE Voodoo Banshee (generic) + +NAME Diamond Monster Fusion +SEE Voodoo Banshee (generic) + +NAME AOpen PA2010 +SEE Voodoo Banshee (generic) + +NAME Chaintech Desperado 3F10 +SEE Voodoo Banshee (generic) + +# 3DLabs + +NAME ELSA GLoria-L/MX +CHIPSET GLINT MX +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +NOCLOCKPROBE + +NAME ELSA GLoria-L +CHIPSET GLINT 500TX +SERVER 3DLabs +DRIVER glint +NOCLOCKPROBE + +NAME ELSA GLoria-XL +CHIPSET GLINT MX +SERVER 3DLabs +DRIVER glint +NOCLOCKPROBE + +NAME Diamond Fire GL 3000 +CHIPSET GLINT 500TX +SERVER 3DLabs +DRIVER glint +LINE Option "firegl_3000" +NOCLOCKPROBE + +NAME ELSA GLoria-S +CHIPSET PERMEDIA +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +LINE #VideoRam 8192 +NOCLOCKPROBE + +NAME Diamond Fire GL 1000 +CHIPSET PERMEDIA +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +LINE #VideoRam 8192 +NOCLOCKPROBE + +NAME ELSA GLoria Synergy +CHIPSET PERMEDIA 2 +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +NOCLOCKPROBE + +NAME ELSA Winner 2000/Office +CHIPSET PERMEDIA 2 +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +NOCLOCKPROBE + +NAME Diamond Fire GL 1000 PRO +CHIPSET PERMEDIA 2 +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +NOCLOCKPROBE + +NAME Creative Blaster Exxtreme +CHIPSET PERMEDIA 2 +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +NOCLOCKPROBE + +NAME AccelStar Permedia II AGP +CHIPSET PERMEDIA 2 +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +NOCLOCKPROBE + +NAME Leadtek WinFast 2300 +CHIPSET PERMEDIA 2 +SERVER 3DLabs +DRIVER glint +NOCLOCKPROBE + +NAME 3DLabs Oxygen GMX +CHIPSET PERMEDIA 2 +SERVER 3DLabs +DRIVER glint +LINE #Option "no_accel" +NOCLOCKPROBE + +NAME Appian Jeronimo 2000 +CHIPSET PERMEDIA 3 +SERVER 3DLabs +DRIVER glint +NOCLOCKPROBE + +# Alliance Semiconductor + +NAME Diamond Stealth Video 2500 +CHIPSET Alliance AT24 +SERVER SVGA +DRIVER apm +NOCLOCKPROBE + +NAME AT3D +CHIPSET Alliance AT3D +SERVER SVGA +DRIVER apm +NOCLOCKPROBE +LINE #Option "no_accel" + +NAME AT25 +SEE AT3D + +NAME Hercules Stingray 128 3D +SEE AT3D + +# NeoMagic + +NAME NeoMagic (laptop/notebook) +CHIPSET MagicGraph 128 series +SERVER SVGA +DRIVER neomagic +LINE # Chipset "NM2160" +LINE # IOBase 0xfea00000 +LINE # MemBase 0xfd000000 +LINE # VideoRam 2048 +LINE # DacSpeed 90 +LINE # Option "linear" +LINE # Option "nolinear" +LINE # Option "sw_cursor" +LINE # Option "hw_cursor" +LINE # Option "no_accel" +LINE # Option "intern_disp" +LINE # Option "extern_disp" +LINE # Option "mmio" +LINE # Option "no_mmio" +LINE # Option "lcd_center" +LINE # Option "no_stretch" + +# Epson SPC8110 + +NAME EPSON SPC8110 (CardPC) +CHIPSET SPC8110 +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE # Chipset "spc8110" +LINE # MemBase 0x03e00000 +LINE # VideoRam 1024 +LINE # Option "nolinear" +LINE # Option "sw_cursor" +LINE # Option "noaccel" +LINE # Option "fifo_moderate" +LINE # Option "fifo_conservative" + +# Silicon Motion, Inc. + +NAME Silicon Motion Lynx family +CHIPSET Lynx +SERVER SVGA +DRIVER siliconmotion +NOCLOCKPROBE + +# Rendition + +NAME Rendition Verite 1000 +CHIPSET Verite 1000 +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE # Option "sw_cursor" + +NAME Rendition Verite 2x00 +CHIPSET Verite 2x00 +SERVER SVGA +DRIVER vga +UNSUPPORTED +LINE # Option "sw_cursor" + +NAME Creative Labs 3D Blaster PCI (Verite 1000) +SEE Rendition Verite 1000 + +NAME Canopus Total-3D +SEE Rendition Verite 1000 + +NAME Sierra Screaming 3D +SEE Rendition Verite 1000 + +NAME Miro CRYSTAL VRX +SEE Rendition Verite 1000 + +NAME Diamond Stealth II S220 +CHIPSET Verite 2100 +SEE Rendition Verite 2x00 + +NAME Hercules Thriller3D +CHIPSET Verite 2200 +SEE Rendition Verite 2x00 + +# Digital + +NAME Digital 8-plane TGA (UDB/Multia) +CHIPSET TGA +SERVER TGA +DRIVER tga +RAMDAC Bt485 + +NAME Digital 8-plane TGA (ZLXp-E1) +CHIPSET TGA +SERVER TGA +DRIVER tga +RAMDAC Bt485 + +NAME Digital 24-plane TGA (ZLXp-E2) +CHIPSET TGA +SERVER TGA +DRIVER tga +RAMDAC Bt463 + +NAME Digital 24-plane+3D TGA (ZLXp-E3) +CHIPSET TGA +SERVER TGA +DRIVER tga +RAMDAC Bt463 + +# i810 + +NAME Intel 810 +SERVER SVGA +DRIVER i810 + +# i740 + +NAME Intel 740 (generic) +SERVER SVGA +DRIVER i740 + +# Misc + +END diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/Cards98 b/xorg-server/hw/xfree86/utils/xorgconfig/Cards98 new file mode 100644 index 000000000..ef14a0345 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/Cards98 @@ -0,0 +1,647 @@ +# $XFree86: xc/programs/Xserver/hw/xfree98/xf86config/Cards98,v 1.7 1998/06/04 16:43:45 hohndel Exp $ +# +# +# +# $XConsortium: Cards /main/27 1996/10/28 05:43:53 kaleb $ +# This is the database of card definitions used by xf86config. +# Each definition should have a NAME entry, CHIPSET (descriptive) and +# SERVER (one of EGC, GANBWAP, PEGC, NKVNEC, WABS, WABEP, WSNA, TGUI, +# MGA, SVGA, NECS3, PWSKB, PWLB, GA968). +# A reference to another definition is made with SEE (already defined +# entries are not overridden). +# Optional entries are RAMDAC (identifier), CLOCKCHIP (identifier), +# DACSPEED, NOCLOCKPROBE (advises never to probe clocks), UNSUPPORTED +# (indicates card that is not yet properly supported by a dedicated +# server). A LINE entry adds a line of text to be included in the +# Device section (can include options or comments). +# There's no CLOCKS option (although a Clocks line can be included +# with LINE), as it is very undesirable to have a Clocks line that +# is incorrect. The idea is that the Clocks are probed for to be +# sure (a commented suggested Clocks line can be included). +# +# The majority of entries are just a binding of a model name to a +# chipset/server and untested. +# + +# EGC + +NAME EGC16 +CHIPSET EGC +SERVER EGC +LINE Chipset "vga" + +# PEGC + +NAME PEGC +CHIPSET PEGC +SERVER PEGC +LINE VideoRam 512 +LINE Clocks 31.5 +LINE # Virtual resolution for 640x400 +LINE # Clocks 28.322 + +# GANBWAP + +NAME GA-98NBI +CHIPSET CL-GD5434 +SERVER GANBWAP +LINE ClockChip "cirrus" +LINE Option "ga98nb1" +LINE Option "no_mmio" +LINE # Option "sw_cursor" + +NAME GA-98NBII +CHIPSET CL-GD5434 +SERVER GANBWAP +LINE ClockChip "cirrus" +LINE Option "ga98nb2" +LINE Option "no_mmio" +LINE # Option "sw_cursor" + +NAME GA-98NBIV +CHIPSET CL-GD5434 +SERVER GANBWAP +LINE ClockChip "cirrus" +LINE Option "ga98nb4" +LINE Option "no_mmio" +LINE # Option "sw_cursor" + +NAME WAP-2000/4000 +CHIPSET CL-GD5434 +SERVER GANBWAP +LINE Option "wap" +LINE Option "no_mmio" +LINE # Option "epsonmemwin" + +# NKVNEC + +NAME PCNKV/PCNKV2/NEC_CIRRUS +CHIPSET CL-GD5428/5429/5430 +SERVER NKVNEC +LINE # Option "fast_dram" +LINE VideoRam 1024 + +NAME PC9821Bf/U8W +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Bp/U8W/U7W +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Bs/U7W +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Be/U7W +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821BA3/U2/W +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821BX3/U2/W +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821BX4/U2 +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Cb +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Ce +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Cf +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Ce2 +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Cs +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Cs2 +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Cx +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Cx2 +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Es +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Nd +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Ne2 +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Nf +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Np +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Ns +LINE Option "nec_cirrus" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821V7/C +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821V10/C,S +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821V12/S +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821V13/S +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821V16/S +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821V16/S5V,P +LINE Chipset "clgd5446" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821V20/S7 +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Xb10 +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Xc13/S5 +LINE Chipset "clgd5446" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Xc16/M,S +LINE Chipset "clgd5446" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Xc200/M,S +LINE Chipset "clgd5446" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Xa7e +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Xe +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC9821Xe10 +LINE Chipset "clgd5430" +LINE Option "nec_cirrus" +LINE Option "no_mmio" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC486MR +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC486MS +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC486MU +LINE Chipset "clgd5429" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC486MV +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC586MV +SEE PCNKV/PCNKV2/NEC_CIRRUS + +NAME PC586RV +LINE Chipset "clgd5429" +SEE PCNKV/PCNKV2/NEC_CIRRUS + +# WABS + +NAME WAB-S +CHIPSET CL-GD5426/5428 +SERVER WABS +LINE VideoRam 1024 +LINE # VideoRam 2048 + +NAME WAB-1000/2000 +CHIPSET CL-GD5428 +SERVER WABS +LINE VideoRam 1024 +LINE # VideoRam 2048 + +NAME WSR-E/G +SEE WAB-1000/2000 + +# WABEP + +NAME WAB-EP +CHIPSET CL-GD5428 +SERVER WABEP +LINE Option "med_dram" + +# WSNA + +NAME WSN-A2F +CHIPSET CL-GD5434 +SERVER WSNA +LINE Option "no_mmio" +LINE Option "med_dram" + +# TGUI + +NAME NEC Trident +CHIPSET TGUI9680/9682 +SERVER TGUI +LINE Option "xaa_no_color_exp" +LINE # Option "noaccel" +LINE # Option "Linear" +LINE # Option "med_dram" +LINE # Option "hw_cursor" + +NAME PC9821Ra20/N +SEE NEC Trident + +NAME PC9821RaII23/N,W +SEE NEC Trident + +NAME PC9821Ra266/N,W +SEE NEC Trident + +NAME PC9821Rs20/B20 +SEE NEC Trident + +NAME PC9821RsII26/B40 +SEE NEC Trident + +NAME PC9821V13/M7 +SEE NEC Trident + +NAME PC9821V16/M7 +SEE NEC Trident + +NAME PC9821V20/M7 +SEE NEC Trident + +NAME PC9821Xa7/C,K +SEE NEC Trident + +NAME PC9821Xa9/C,K +SEE NEC Trident + +NAME PC9821Xa10/C,K +SEE NEC Trident + +NAME PC9821Xa12/C,K +SEE NEC Trident + +NAME PC9821Xa13/C,K,W +SEE NEC Trident + +NAME PC9821Xa16/R,W +SEE NEC Trident + +NAME PC9821Xa20/W +SEE NEC Trident + +NAME PC9821Xc13/M,S +SEE NEC Trident + +NAME PC9821Xv13/R +SEE NEC Trident + +NAME GA-DRV/98 +CHIPSET TGUI9680 +SERVER TGUI +LINE Option "noaccel" +LINE # Option "med_dram" +LINE # Option "hw_cursor" + +# MGA + +NAME MGA Millennium +CHIPSET MGA2064W +SERVER MGA + +NAME PC9821Xt13 +SEE MGA Millennium + +NAME PC9821Xt16 +SEE MGA Millennium + +NAME PC9821Xv13/W +SEE MGA Millennium + +NAME PC9821Xv20/W +SEE MGA Millennium + +NAME PC9821St15 +SEE MGA Millennium + +NAME PC9821St20 +SEE MGA Millennium + +NAME PC9821RvII26/N20 +SEE MGA Millennium + +NAME NEC FC-WAB-X2 +SEE MGA Millennium + +NAME MGA Mystique +CHIPSET MGA1064SG +SERVER MGA + +NAME PC9821V166/S +LINE VideoRam 2048 +SEE MGA Mystique + +NAME PC9821V200/S +LINE VideoRam 2048 +SEE MGA Mystique + +NAME PC9821V200/M +LINE VideoRam 4096 +SEE MGA Mystique + +NAME PC9821V233/M7 +LINE VideoRam 2048 +SEE MGA Mystique + +NAME PC9821V233/M7V +LINE VideoRam 4096 +SEE MGA Mystique + +# SVGA + +NAME NEC Cirrus 755x +CHIPSET CL-GD7555 +LINE Chipset "clgd7555" +LINE # VideoRam 2048 +LINE # Option "no_bitblt" +LINE # Option "fast_dram" +LINE Option "linear" +LINE Option "noaccel" +SERVER SVGA + +NAME PC9821Nr12 +SEE NEC Cirrus 755x + +NAME PC9821Nr13 +SEE NEC Cirrus 755x + +NAME PC9821La13 +SEE NEC Cirrus 755x + +NAME PC9821Ls12 +SEE NEC Cirrus 755x + +NAME PC9821Ls13 +SEE NEC Cirrus 755x + +NAME PC9821Ls150 +SEE NEC Cirrus 755x + +# NECS3 + +NAME NEC WAB-A/B +CHIPSET S3 928 +SERVER NECS3 +LINE Chipset "s3_generic" +LINE Dacspeed 110 +LINE Ramdac "sc15025" +LINE Option "dac_8_bit" +LINE # Option "necwab" +LINE # Option "nomemaccess" +LINE Clocks 25.0 28.0 40.0 0.0 50.0 77.0 36.0 45.0 +LINE Clocks 130.0 120.0 80.0 31.0 110.0 65.0 75.0 94.0 + +NAME NEC FC-WAB-A/B +CHIPSET S3 928 +SERVER NECS3 +LINE Chipset "s3_generic" +LINE Dacspeed 110 +LINE Ramdac "bt485" +LINE Option "necwab" +LINE Option "nomemaccess" +LINE Option "noinit" +LINE Option "nolinear" +LINE Clocks 25.0 28.0 40.0 0.0 50.0 77.0 36.0 45.0 +LINE Clocks 130.0 120.0 80.0 31.0 110.0 65.0 75.0 94.0 + +NAME PC9821Af/U9W E09? +SEE NEC WAB-A/B + +NAME PC9821An/U8W +SEE NEC WAB-A/B + +NAME PC9821Ap2/U8W/C9W +SEE NEC WAB-A/B + +NAME PC9821As2/U7W/U8W +SEE NEC WAB-A/B + +NAME NEC 864 +CHIPSET S3 864 +SERVER NECS3 +LINE Chipset "s3_generic" +LINE Option "necwab" +LINE Ramdac "s3_sdac" +LINE ClockChip "s3_sdac" + +NAME PC9821Ap3 +SEE NEC 864 + +NAME PC9821As3 +SEE NEC 864 + +NAME PC9821Xp +SEE NEC 864 + +NAME PC9821Xs +SEE NEC 864 + +# PWSKB + +NAME PowerWindow 928/801 +CHIPSET S3 928 +SERVER PWSKB +LINE Chipset "s3_generic" +LINE # Chipset "mmio_928" +LINE Ramdac "sc15025" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE # Option "epsonmemwin" +LINE # Option "nomemaccess" +LINE ClockChip "icd2061a" + +NAME PowerWindow 928II +CHIPSET S3 928 +SERVER PWSKB +LINE Chipset "s3_generic" +LINE # Chipset "mmio_928" +LINE Ramdac "att20c505" +LINE # Ramdac "bt485" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE # Option "pw_mux" +LINE Option "bt485_curs" +LINE # Option "epsonmemwin" +LINE # Option "nomemaccess" +LINE ClockChip "icd2061a" + +NAME PowerWindow 805i +CHIPSET S3 805 +SERVER PWSKB +LINE Chipset "s3_generic" +LINE Ramdac "s3gendac" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE # Option "pw805i" +LINE # Option "epsonmemwin" +LINE # Option "nomemaccess" +LINE ClockChip "s3_sdac" + +NAME PowerWindow 928G +CHIPSET S3 928 +SERVER PWSKB +LINE Chipset "s3_generic" +LINE # Chipset "mmio_928" +LINE Ramdac "sc15025" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE # Option "nomemaccess" +LINE # Option "nolinear" +LINE ClockChip "icd2061a" + +NAME PCSKB/PCSKB2 +CHIPSET S3 911/924 +SERVER PWSKB +LINE Chipset "s3_generic" +LINE Ramdac "sc15025" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE # Option "nomemaccess" +LINE Option "pcskb" +LINE Clocks 25.0 28.0 40.0 0.0 50.0 77.0 36.0 45.0 +LINE Clocks 130.0 120.0 80.0 31.0 110.0 65.0 75.0 94.0 + +NAME PCSKB3/PCSKB4/PCPKB4 +CHIPSET S3 928 +SERVER PWSKB +LINE Chipset "s3_generic" +LINE Ramdac "sc15025" +LINE # Ramdac "att20c498" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE Option "nomemaccess" +LINE Option "pcskb4" +LINE Clocks 25.0 28.0 40.0 0.0 50.0 77.0 36.0 45.0 +LINE Clocks 130.0 120.0 80.0 31.0 110.0 65.0 75.0 94.0 + +# PWLB + +NAME PowerWindow 928GLB +CHIPSET S3 928 +SERVER PWLB +LINE Chipset "s3_generic" +LINE # Chipset "mmio_928" +LINE Ramdac "sc15025" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE # Option "pw_localbus" +LINE # Option "nomemaccess" +LINE # Option "nolinear" +LINE ClockChip "icd2061a" + +NAME PowerWindow 928IILB +CHIPSET S3 928 +SERVER PWLB +LINE Chipset "s3_generic" +LINE # Chipset "mmio_928" +LINE Ramdac "att20c505" +LINE # Ramdac "bt485" +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE Option "bt485_curs" +LINE Option "pw_localbus" +LINE # Option "pw_mux" +LINE # Option "nomemaccess" +LINE # Option "nolinear" +LINE ClockChip "icd2061a" + +NAME PowerWindow 964LB +CHIPSET S3 964 +SERVER PWLB +LINE Chipset "s3_generic" +LINE Option "pw_localbus" +LINE Option "number_nine" +LINE Ramdac "ti3025" +LINE ClockChip "ti3025" +LINE VideoRam 4096 + +# GA968 + +NAME GA-968V4/PCI +CHIPSET S3 968 +SERVER GA968 +LINE Chipset "s3_generic" +LINE # Chipset "mmio_928" +LINE VideoRam 4096 diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/Makefile.am b/xorg-server/hw/xfree86/utils/xorgconfig/Makefile.am new file mode 100644 index 000000000..dabfc3214 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/Makefile.am @@ -0,0 +1,70 @@ +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +bin_PROGRAMS = xorgconfig + +X11dir = $(libdir)/X11 +dist_X11_DATA = Cards + +xorgconfig_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ \ + -DCARD_DATABASE_FILE='"$(X11dir)/Cards"' \ + -DPROJECTROOT='"$(PROJECTROOT)"' \ + -DFILEMANSUFFIX='"$(FILE_MAN_SUFFIX)"' \ + -DXVERSIONSTRING='"$(PACKAGE_STRING)"' + +xorgconfig_LDADD = @XORGCONFIG_DEP_LIBS@ + +xorgconfig_SOURCES = \ + cards.c \ + cards.h \ + xorgconfig.c + +# Man page +include $(top_srcdir)/cpprules.in + +appmandir = $(APP_MAN_DIR) + +appman_PRE = xorgconfig.man +appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) + +EXTRAMANDEFS = \ + -D__XCONFIGFILE__=$(__XCONFIGFILE__) \ + -D__XSERVERNAME__=$(XSERVERNAME) + +BUILT_SOURCES = $(appman_PRE) +CLEANFILES = $(appman_PRE) $(appman_DATA) + +SUFFIXES += .$(APP_MAN_SUFFIX) .man + +.man.$(APP_MAN_SUFFIX): + -rm -f $@ + $(LN_S) $< $@ + +EXTRA_DIST = \ + Cards98 \ + xorgconfig.man.pre diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/Makefile.in b/xorg-server/hw/xfree86/utils/xorgconfig/Makefile.in new file mode 100644 index 000000000..4e54d04a1 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/Makefile.in @@ -0,0 +1,857 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, 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. +# + +# -*- Makefile -*- +# Rules for generating files using the C pre-processor +# (Replaces CppFileTarget from Imake) + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = xorgconfig$(EXEEXT) +DIST_COMMON = $(dist_X11_DATA) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/cpprules.in +subdir = hw/xfree86/utils/xorgconfig +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appmandir)" \ + "$(DESTDIR)$(X11dir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_xorgconfig_OBJECTS = xorgconfig-cards.$(OBJEXT) \ + xorgconfig-xorgconfig.$(OBJEXT) +xorgconfig_OBJECTS = $(am_xorgconfig_OBJECTS) +xorgconfig_DEPENDENCIES = +xorgconfig_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(xorgconfig_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(xorgconfig_SOURCES) +DIST_SOURCES = $(xorgconfig_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +appmanDATA_INSTALL = $(INSTALL_DATA) +dist_X11DATA_INSTALL = $(INSTALL_DATA) +DATA = $(appman_DATA) $(dist_X11_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = sed +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +X11dir = $(libdir)/X11 +dist_X11_DATA = Cards +xorgconfig_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ \ + -DCARD_DATABASE_FILE='"$(X11dir)/Cards"' \ + -DPROJECTROOT='"$(PROJECTROOT)"' \ + -DFILEMANSUFFIX='"$(FILE_MAN_SUFFIX)"' \ + -DXVERSIONSTRING='"$(PACKAGE_STRING)"' + +xorgconfig_LDADD = @XORGCONFIG_DEP_LIBS@ +xorgconfig_SOURCES = \ + cards.c \ + cards.h \ + xorgconfig.c + +SUFFIXES = .pre .man .man.pre .$(APP_MAN_SUFFIX) .man + +# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM +# to cpp, because that trick does not work on all ANSI C preprocessors. +# Delete line numbers from the cpp output (-P is not portable, I guess). +# Allow XCOMM to be preceded by whitespace and provide a means of generating +# output lines with trailing backslashes. +# Allow XHASH to always be substituted, even in cases where XCOMM isn't. +CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ + -e '/^\#line *[0-9][0-9]* *.*$$/d' \ + -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ + -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ + -e '/^[ ]*XHASH/s/XHASH/\#/' \ + -e '/\@\@$$/s/\@\@$$/\\/' + + +# Strings to replace in man pages +XORGRELSTRING = @PACKAGE_STRING@ +XORGMANNAME = X Version 11 +XSERVERNAME = Xorg +MANDEFS = \ + -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \ + -D__appmansuffix__=$(APP_MAN_SUFFIX) \ + -D__filemansuffix__=$(FILE_MAN_SUFFIX) \ + -D__libmansuffix__=$(LIB_MAN_SUFFIX) \ + -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \ + -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \ + -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \ + -D__mandir__=$(mandir) \ + -D__projectroot__=$(prefix) \ + -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \ + -D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME) + + +# Man page +appmandir = $(APP_MAN_DIR) +appman_PRE = xorgconfig.man +appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) +EXTRAMANDEFS = \ + -D__XCONFIGFILE__=$(__XCONFIGFILE__) \ + -D__XSERVERNAME__=$(XSERVERNAME) + +BUILT_SOURCES = $(appman_PRE) +CLEANFILES = $(appman_PRE) $(appman_DATA) +EXTRA_DIST = \ + Cards98 \ + xorgconfig.man.pre + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .pre .man .man.pre .$(APP_MAN_SUFFIX) .man .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/cpprules.in $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/utils/xorgconfig/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/utils/xorgconfig/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +xorgconfig$(EXEEXT): $(xorgconfig_OBJECTS) $(xorgconfig_DEPENDENCIES) + @rm -f xorgconfig$(EXEEXT) + $(xorgconfig_LINK) $(xorgconfig_OBJECTS) $(xorgconfig_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgconfig-cards.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorgconfig-xorgconfig.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +xorgconfig-cards.o: cards.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -MT xorgconfig-cards.o -MD -MP -MF $(DEPDIR)/xorgconfig-cards.Tpo -c -o xorgconfig-cards.o `test -f 'cards.c' || echo '$(srcdir)/'`cards.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgconfig-cards.Tpo $(DEPDIR)/xorgconfig-cards.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cards.c' object='xorgconfig-cards.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -c -o xorgconfig-cards.o `test -f 'cards.c' || echo '$(srcdir)/'`cards.c + +xorgconfig-cards.obj: cards.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -MT xorgconfig-cards.obj -MD -MP -MF $(DEPDIR)/xorgconfig-cards.Tpo -c -o xorgconfig-cards.obj `if test -f 'cards.c'; then $(CYGPATH_W) 'cards.c'; else $(CYGPATH_W) '$(srcdir)/cards.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgconfig-cards.Tpo $(DEPDIR)/xorgconfig-cards.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cards.c' object='xorgconfig-cards.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -c -o xorgconfig-cards.obj `if test -f 'cards.c'; then $(CYGPATH_W) 'cards.c'; else $(CYGPATH_W) '$(srcdir)/cards.c'; fi` + +xorgconfig-xorgconfig.o: xorgconfig.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -MT xorgconfig-xorgconfig.o -MD -MP -MF $(DEPDIR)/xorgconfig-xorgconfig.Tpo -c -o xorgconfig-xorgconfig.o `test -f 'xorgconfig.c' || echo '$(srcdir)/'`xorgconfig.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgconfig-xorgconfig.Tpo $(DEPDIR)/xorgconfig-xorgconfig.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xorgconfig.c' object='xorgconfig-xorgconfig.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -c -o xorgconfig-xorgconfig.o `test -f 'xorgconfig.c' || echo '$(srcdir)/'`xorgconfig.c + +xorgconfig-xorgconfig.obj: xorgconfig.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -MT xorgconfig-xorgconfig.obj -MD -MP -MF $(DEPDIR)/xorgconfig-xorgconfig.Tpo -c -o xorgconfig-xorgconfig.obj `if test -f 'xorgconfig.c'; then $(CYGPATH_W) 'xorgconfig.c'; else $(CYGPATH_W) '$(srcdir)/xorgconfig.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xorgconfig-xorgconfig.Tpo $(DEPDIR)/xorgconfig-xorgconfig.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xorgconfig.c' object='xorgconfig-xorgconfig.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xorgconfig_CFLAGS) $(CFLAGS) -c -o xorgconfig-xorgconfig.obj `if test -f 'xorgconfig.c'; then $(CYGPATH_W) 'xorgconfig.c'; else $(CYGPATH_W) '$(srcdir)/xorgconfig.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-appmanDATA: $(appman_DATA) + @$(NORMAL_INSTALL) + test -z "$(appmandir)" || $(MKDIR_P) "$(DESTDIR)$(appmandir)" + @list='$(appman_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(appmanDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appmandir)/$$f'"; \ + $(appmanDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appmandir)/$$f"; \ + done + +uninstall-appmanDATA: + @$(NORMAL_UNINSTALL) + @list='$(appman_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(appmandir)/$$f'"; \ + rm -f "$(DESTDIR)$(appmandir)/$$f"; \ + done +install-dist_X11DATA: $(dist_X11_DATA) + @$(NORMAL_INSTALL) + test -z "$(X11dir)" || $(MKDIR_P) "$(DESTDIR)$(X11dir)" + @list='$(dist_X11_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(dist_X11DATA_INSTALL) '$$d$$p' '$(DESTDIR)$(X11dir)/$$f'"; \ + $(dist_X11DATA_INSTALL) "$$d$$p" "$(DESTDIR)$(X11dir)/$$f"; \ + done + +uninstall-dist_X11DATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_X11_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(X11dir)/$$f'"; \ + rm -f "$(DESTDIR)$(X11dir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appmandir)" "$(DESTDIR)$(X11dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-appmanDATA install-dist_X11DATA + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-appmanDATA uninstall-binPROGRAMS \ + uninstall-dist_X11DATA + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-appmanDATA install-binPROGRAMS install-data \ + install-data-am install-dist_X11DATA install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-appmanDATA uninstall-binPROGRAMS \ + uninstall-dist_X11DATA + + +.pre: + $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.pre.man: + $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@ + +.man.$(APP_MAN_SUFFIX): + -rm -f $@ + $(LN_S) $< $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/cards.c b/xorg-server/hw/xfree86/utils/xorgconfig/cards.c new file mode 100644 index 000000000..8116f0a03 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/cards.c @@ -0,0 +1,278 @@ +/* + * Functions to manipulate card database. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "cards.h" + +/* Some vars to make path names in texts more flexible. */ +#ifndef PROJECTROOT +# define PROJECTROOT "/usr" +#endif +#define TREEROOT PROJECTROOT +#define TREEROOTLX TREEROOT "/lib/X11" +#define TREEROOTCFG TREEROOT "/etc/X11" +#ifdef XDOCDIR +# define TREEROOTDOC XDOCDIR +#else +# define TREEROOTDOC TREEROOTLX "/doc" +#endif + +/* + * Database format: + * + * NAME <name of card> + * CHIPSET <chipset description> + * SERVER <server name> + * DRIVER <driver name> + * + * Optional keywords: + * RAMDAC <ramdac identifier> + * CLOCKCHIP <clockchip identifier> + * DACSPEED <dacspeed> + * NOCLOCKPROBE + * UNSUPPORTED + * + * SEE <name of card> refers to another card definition; parameters that + * are already defined are not overridden. + * + * <server name> is one of Mono, VGA16, SVGA, S3, Mach32, Mach8, 8514, + * P9000, AGX, W32. + * + * A useful additional keywords may be CLOCKS. + */ + + + +/* Database vars. */ + +int lastcard; + +Card card[MAX_CARDS]; + + +static int +getnextline(FILE *f, char *l) +{ + if (fgets(l, 128, f) == NULL) + return -1; + return 0; +} + +static void +appendstring(char **destp, char *src) +{ + char *newstr; + newstr = malloc(strlen(*destp) + strlen(src) + 1); + strcpy(newstr, *destp); + strcat(newstr, src); + if (strlen(*destp) > 0) + free(*destp); + *destp = newstr; +} + +int +lookupcard(char *name) { + int i; + for (i = 0; i <= lastcard; i++) + if (strcmp(name, card[i].name) == 0) + return i; + return -1; +} + +static char *s3_comment = +"# Use Option \"nolinear\" if the server doesn't start up correctly\n" +"# (this avoids the linear framebuffer probe). If that fails try\n" +"# option \"nomemaccess\".\n" +"#\n" +"# Refer to " TREEROOTDOC "/README.S3, and the XF86_S3 man page.\n"; + +static char *cirrus_comment = +"# Use Option \"no_bitblt\" if you have graphics problems. If that fails\n" +"# try Option \"noaccel\".\n" +"# Refer to " TREEROOTDOC "/README.cirrus.\n" +"# To allow linear addressing, uncomment the Option line and the\n" +"# address that the card maps the framebuffer to.\n"; + +int parse_database() { + FILE *f; + char buf[128]; + int i, lineno; + char filename[128]; + + strcpy(filename, CARD_DATABASE_FILE); + f = fopen(filename, "r"); + if (f == NULL) + return -1; + + lastcard = -1; + lineno = 0; + + for (;;) { + if (getnextline(f, buf)) + break; + lineno++; + if (buf[0] == '#') + /* Comment. */ + continue; + if (strncmp(buf, "END", 3) == 0) + /* End of database. */ + break; + if (strncmp(buf, "LINE", 4) == 0 && lastcard>=0) { + /* Line of Device comment. */ + /* Append to existing lines. */ + appendstring(&card[lastcard].lines, buf + 5); + continue; + } + /* + * The following keywords require the trailing newline + * to be deleted. + */ + i = strlen(buf); + buf[--i] = '\0'; + + /* remove trailing spaces or tabs */ + for(--i; i>=0 && (buf[i] == ' ' || buf[i] == '\011'); i--) ; + if (i>=0) + buf[i+1] = '\0'; + else + continue; /* skip empty lines */ + + if (strncmp(buf, "NAME", 4) == 0) { + /* New entry. */ + lastcard++; + card[lastcard].name = malloc(strlen(buf + 5) + 1); + strcpy(card[lastcard].name, buf + 5); + card[lastcard].chipset = NULL; + card[lastcard].server = NULL; + card[lastcard].driver = NULL; + card[lastcard].ramdac = NULL; + card[lastcard].clockchip = NULL; + card[lastcard].dacspeed = NULL; + card[lastcard].flags = 0; + card[lastcard].lines = ""; + continue; + } + if (lastcard < 0) /* no NAME line found yet */ + continue; + if (strncmp(buf, "SEE", 3) == 0) { + /* Reference to another entry. */ + int i; + i = lookupcard(buf + 4); + if (i == -1) { + printf("Error in database, invalid reference: %s.\n", + buf + 4); + free(card[lastcard].name); + lastcard--; + continue; + } + if (card[lastcard].chipset == NULL) + card[lastcard].chipset = card[i].chipset; + if (card[lastcard].server == NULL) + card[lastcard].server = card[i].server; + if (card[lastcard].driver == NULL) + card[lastcard].driver = card[i].driver; + if (card[lastcard].ramdac == NULL) + card[lastcard].ramdac = card[i].ramdac; + if (card[lastcard].clockchip == NULL) + card[lastcard].clockchip = card[i].clockchip; + if (card[lastcard].dacspeed == NULL) + card[lastcard].dacspeed = card[i].dacspeed; + card[lastcard].flags |= card[i].flags; + appendstring(&card[lastcard].lines, card[i].lines); + continue; + } + if (strncmp(buf, "CHIPSET", 7) == 0) { + /* Chipset description. */ + card[lastcard].chipset = malloc(strlen(buf + 8) + 1); + strcpy(card[lastcard].chipset, buf + 8); + continue; + } + if (strncmp(buf, "SERVER", 6) == 0) { + /* Server identifier. */ + card[lastcard].server = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].server, buf + 7); + continue; + } + if (strncmp(buf, "DRIVER", 6) == 0) { + /* Driver identifier. */ + card[lastcard].driver = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].driver, buf + 7); + continue; + } + if (strncmp(buf, "RAMDAC", 6) == 0) { + /* Ramdac indentifier. */ + card[lastcard].ramdac = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].ramdac, buf + 7); + continue; + } + if (strncmp(buf, "CLOCKCHIP", 9) == 0) { + /* Clockchip indentifier. */ + card[lastcard].clockchip = malloc(strlen(buf + 10) + 1); + strcpy(card[lastcard].clockchip, buf + 10); + card[lastcard].flags |= NOCLOCKPROBE; + continue; + } + if (strncmp(buf, "DACSPEED", 8) == 0) { + /* Clockchip indentifier. */ + card[lastcard].dacspeed = malloc(strlen(buf + 9) + 1); + strcpy(card[lastcard].dacspeed, buf + 9); + continue; + } + if (strncmp(buf, "NOCLOCKPROBE", 12) == 0) { + card[lastcard].flags |= NOCLOCKPROBE; + continue; + } + if (strncmp(buf, "UNSUPPORTED", 12) == 0) { + card[lastcard].flags |= UNSUPPORTED; + continue; + } + /* test for missing required fields */ + if (card[lastcard].driver == NULL) { + fprintf(stderr, "Warning DRIVER specification missing " + "in Card database entry %s (line %d).\n", + card[lastcard].name, lineno); + keypress(); + card[lastcard].driver = "unknown"; + } + if (card[lastcard].chipset == NULL) { + fprintf(stderr, "Warning CHIPSET specification missing " + "in Card database entry %s (line %d).\n", + card[lastcard].name, lineno); + keypress(); + card[lastcard].chipset = "unknown"; + } + } + + fclose(f); + + /* + * Add general comments. + */ + for (i = 0; i <= lastcard; i++) { + if (card[i].server && strcmp(card[i].server, "S3") == 0) + appendstring(&card[i].lines, s3_comment); + if (card[i].chipset && + strncmp(card[i].chipset, "CL-GD", 5) == 0) + appendstring(&card[i].lines, cirrus_comment); + } + + sort_database(); + + return 0; +} + +static int +compare_card(const void *e1, const void *e2) +{ + return strcmp(((Card *)e1)->name, ((Card *)e2)->name); +} + +void +sort_database() { + /* Each element is a bunch of words, but nothing too bad. */ + qsort(card, lastcard + 1, sizeof(Card), compare_card); +} diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/cards.h b/xorg-server/hw/xfree86/utils/xorgconfig/cards.h new file mode 100644 index 000000000..7e1438db8 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/cards.h @@ -0,0 +1,30 @@ +#ifndef CARD_DATABASE_FILE +#define CARD_DATABASE_FILE "Cards" +#endif + +#define MAX_CARDS 1000 + +typedef struct { + char *name; /* Name of the card. */ + char *chipset; /* Chipset (decriptive). */ + char *server; /* Server identifier. */ + char *driver; /* Driver identifier. */ + char *ramdac; /* Ramdac identifier. */ + char *clockchip; /* Clockchip identifier. */ + char *dacspeed; /* DAC speed rating. */ + int flags; + char *lines; /* Additional Device section lines. */ +} Card; + +/* Flags: */ +#define NOCLOCKPROBE 0x1 /* Never probe clocks of the card. */ +#define UNSUPPORTED 0x2 /* Card is not supported (only VGA). */ + +extern int lastcard; + +extern Card card[MAX_CARDS]; + +extern int lookupcard ( char *name ); +extern int parse_database ( void ); +extern void sort_database ( void ); +extern void keypress ( void ); diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.c b/xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.c new file mode 100644 index 000000000..30eb83182 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.c @@ -0,0 +1,2890 @@ +/* + * This is a configuration program that will create a base XF86Config + * file based on menu choices. Its main feature is that clueless users + * may be less inclined to select crazy sync rates way over monitor spec, + * by presenting a menu with standard monitor types. Also some people + * don't read docs unless an executable that they can run tells them to. + * + * It assumes a 24-line or bigger text console. + * + * Revision history: + * 25Sep94 Initial version. + * 27Sep94 Fix hsync range of monitor types to match with best possible mode. + * Remove 'const'. + * Tweak descriptions. + * 28Sep94 Fixes from J"org Wunsch: + * Don't use gets(). + * Add mouse device prompt. + * Fix lines overrun for 24-line console. + * Increase buffer size for probeonly output. + * 29Sep94 Fix bad bug with old XF86Config preserving during probeonly run. + * Add note about vertical refresh in interlaced modes. + * Name gets() replacement getstring(). + * Add warning about binary paths. + * Fixes from David Dawes: + * Don't use 'ln -sf'. + * Omit man path reference in comment. + * Generate only a generic 320x200 SVGA section for accel cards. + * Only allow writing to /usr/X11R6/lib/X11 if root, and use + * -xf86config for the -probeonly phase (root only). + * Fix bug that forces screen type to accel in some cases. + * 30Sep94 Continue after clocks probe fails. + * Note about programmable clocks. + * Rename to 'xf86config'. Not to be confused with XF86Config + * or the -xf86config option. + * 07Oct94 Correct hsync in standard mode timings comments, and include + * the proper +/-h/vsync flags. + * 11Oct94 Skip 'numclocks:' and 'pixel clocks:' lines when probing for + * clocks. + * 18Oct94 Add check for existence of /usr/X11R6. + * Add note about ctrl-alt-backspace. + * 06Nov94 Add comment above standard mode timings in XF86Config. + * 24Dec94 Add low-resolution modes using doublescan. + * 29Dec94 Add note in horizontal sync range selection. + * Ask about ClearDTR/RTS option for Mouse Systems mice. + * Ask about writing to /etc/XF86Config. + * Allow link to be set in /var/X11R6/bin. + * Note about X -probeonly crashing. + * Add keyboard Alt binding option for non-ASCII characters. + * Add card database selection. + * Write temporary XF86Config for clock probing in /tmp instead + * of /usr/X11R6/lib/X11. + * Add RAMDAC and Clockchip menu. + * 27Mar99 Modified for XFree86 4.0 config file format + * 06Sep02 Write comment block about 'DontVTSwitch'. + * + * Possible enhancements: + * - Add more standard mode timings (also applies to README.Config). Missing + * are 1024x768 @ 72 Hz, 1152x900 modes, and 1280x1024 @ ~70 Hz. + * I suspect there is a VESA standard for 1024x768 @ 72 Hz with 77 MHz dot + * clock, and 1024x768 @ 75 Hz with 78.7 MHz dot clock. New types of + * monitors probably work better with VESA 75 Hz timings. + * - Add option for creation of clear, minimal XF86Config. + * - The card database doesn't include most of the entries in previous + * databases. + * + * Send comments to H.Hanemaayer@inter.nl.net. + * + * Things to keep up-to-date: + * - Accelerated server names. + * - Ramdac and Clockchip settings. + * - The card database. + * + */ +/* Oct2000 + * New 'Configuration of XKB' section. + * Author: Ivan Pascal The XFree86 Project. + */ +/* + * Nov2002 + * Some enhancements: + * - Add new PS/2 mouse protocol. + * "IMPS/2","ExplorerPS/2","ThinkingMousePS/2","MouseManPlusPS/2", + * "GlidePointPS/2","NetMousePS/2" and "NetScrollPS/2". + * - Add mouse-speed setting for PS/2 mouse. + * - Fix seg.fault problem on Solaris. + * - Add modestring "1400x1050"(for ATI Mobile-Rage). + * - Add videomemory 8192, 16384, 32768, 65536, 131072 and 262144. + * - Ready to DRI. + * - Load xtt module instead of freetype module. + * - Add font path "/TrueType/" and "/freefont/". + * Chisato Yamauchi(cyamauch@phyas.aichi-edu.ac.jp) + */ + +#ifdef HAVE_CONFIG_H +# include "xorg-server.h" +# include "xkb-config.h" +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include <X11/Xlib.h> +#include <X11/extensions/XKBstr.h> +#include <X11/extensions/XKBrules.h> +#define MAX_XKBOPTIONS 5 + +#include "cards.h" + + +/* + * Define the following to 310 to remove references to XFree86 features that + * have been added since XFree86 3.1 (e.g. DoubleScan modes). + * or to 311 to remove certain new modelines + */ +#define XFREE86_VERSION 400 + +/* + * Define this to have /etc/X11/XF86Config prompted for as the default + * location to write the XF86Config file to. + */ +#define PREFER_XF86CONFIG_IN_ETC + +/* + * Define this to force the user to go through XKB configuration section. + * + */ +#define FORCE_XKB_DIALOG + +/* + * Configuration variables. + */ + +#define MAX_CLOCKS_LINES 16 + +#define DUMBCONFIG2 "dumbconfig.2" +#define DUMBCONFIG3 "dumbconfig.3" + +/* some more vars to make path names in texts more flexible. OS/2 users + * may be more irritated than Unix users + */ +#ifndef PROJECTROOT +#define PROJECTROOT "/usr" +#endif +#define TREEROOT PROJECTROOT +#define TREEROOTLX TREEROOT "/lib/X11" +#define TREEROOTCFG TREEROOT "/etc/X11" +#define TREEROOTSHARE TREEROOT "/share/X11" +#ifdef XDOCDIR +# define TREEROOTDOC XDOCDIR +#else +# define TREEROOTDOC TREEROOTLX "/doc" +#endif +#ifdef XFONTDIR +# define TREEROOTFONT XFONTDIR +#else +# define TREEROOTFONT TREEROOTLX "/fonts" +#endif +#define MODULEPATH TREEROOT "/lib/modules" + +#define XSERVERNAME_FOR_PROBE "X" + +#ifndef XCONFIGFILE +#define XCONFIGFILE "xorg.conf" +#endif +#define CONFIGNAME XCONFIGFILE + +/* + * This is the filename of the temporary XF86Config file that is written + * when the program is told to probe clocks (which can only happen for + * root). + */ +#define TEMPORARY_XF86CONFIG_DIR_PREFIX "/tmp/."XCONFIGFILE +#define TEMPORARY_XF86CONFIG_FILENAME XCONFIGFILE".tmp" + +#ifndef XF86_VERSION_MAJOR +#ifdef XVERSION +#if XVERSION > 40000000 +#define XF86_VERSION_MAJOR (XVERSION / 10000000) +#else +#define XF86_VERSION_MAJOR (XVERSION / 1000) +#endif +#else +#define XF86_VERSION_MAJOR 4 +#endif +#endif + + +int config_mousetype; /* Mouse. */ +int config_emulate3buttons; +int config_chordmiddle; +int config_cleardtrrts; +char *config_pointerdevice; +int config_altmeta; /* Keyboard. */ +int config_monitortype; /* Monitor. */ +char *config_hsyncrange; +char *config_vsyncrange; +char *config_monitoridentifier; +int config_videomemory; /* Video card. */ +int config_screentype; /* mono, vga16, svga, accel */ +char *config_deviceidentifier; +int config_numberofclockslines; +char *config_clocksline[MAX_CLOCKS_LINES]; +char *config_modesline8bpp; +char *config_modesline16bpp; +char *config_modesline24bpp; +int config_virtual; /* 1 (yes) or 0 (no) */ +int config_virtualx8bpp, config_virtualy8bpp; +int config_virtualx16bpp, config_virtualy16bpp; +int config_virtualx24bpp, config_virtualy24bpp; +char *config_ramdac; +char *config_dacspeed; +char *config_clockchip; +#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) +char *config_keyboard_dev = "/dev/wskbd0"; +#endif +int config_xkbdisable = 0; +char *config_xkbrules; +char *config_xkbmodel = "pc105"; +char *config_xkblayout = "us"; +char *config_xkbvariant = (char *) 0; +char *config_xkboptions = (char *) 0; +char *config_depth; + +char *temp_dir = ""; + +/* + * These are from the selected card definition. Parameters from the + * definition are offered during the questioning about the video card. + */ + +int card_selected; /* Card selected from database. */ + + +static int write_XF86Config(char *filename); + + +/* + * This is the initial intro text that appears when the program is started. + */ + +static char *intro_text = +"\n" +"This program will create a basic " CONFIGNAME " file, based on menu selections\n" +"you make. It will ask for a pathname when it is ready to write the file.\n" +"\n" +"The " CONFIGNAME " file usually resides in /etc/X11 or " TREEROOTCFG ". If\n" +"no " CONFIGNAME " file is present there, " __XSERVERNAME__" will probe the system to\n" +"autoconfigure itself. You can run " __XSERVERNAME__ " -configure to generate a " CONFIGNAME "\n" +"file based on the results of autoconfiguration, or let this program\n" +"produce a base " CONFIGNAME " file for your configuration, and fine-tune it.\n" +"A sample " CONFIGNAME " file is also supplied with "__XSERVERNAME__"; it is configured \n" +"for a standard VGA card and monitor with 640x480 resolution.\n" +"\n" +"There are also many chipset and card-specific options and settings available,\n" +"but this program does not know about these. On some configurations some of\n" +"these settings must be specified. Refer to the X driver man pages and the\n" +"chipset-specific READMEs in " TREEROOTDOC " for further details.\n" +#if 0 +" Refer to " TREEROOTDOC "/README.Config\n" +"for a detailed overview of the configuration process.\n" +"\n" +"(what should we change this section to?)\n" +"For accelerated servers (including accelerated drivers in the SVGA server),\n" +"there are many chipset and card-specific options and settings. This program\n" +"does not know about these. On some configurations some of these settings must\n" +"be specified. Refer to the server man pages and chipset-specific READMEs.\n" +#endif +"\n" +"Before continuing with this program, make sure you know what video card\n" +"you have, and preferably also the chipset it uses and the amount of video\n" +"memory on your video card, as well as the specifications of your monitor.\n" +"\n" +; + +static char *finalcomment_text = +"File has been written. Take a look at it before starting an X server. Note that\n" +"the " CONFIGNAME " file must be in one of the directories searched by the server\n" +"(e.g. /etc/X11) in order to be used. Within the server press\n" +"ctrl, alt and '+' simultaneously to cycle video resolutions. Pressing ctrl,\n" +"alt and backspace simultaneously immediately exits the server (use if\n" +"the monitor doesn't sync for a particular mode).\n" +"\n" +"For further configuration, refer to the " XCONFIGFILE "(" FILEMANSUFFIX ") manual page.\n" +"\n"; + +static void * +Malloc(int i) { + void *p; + + p = malloc(i); + if (p == NULL) { + printf("Fatal malloc error\n"); + exit(-1); + } + return p; +} + +static char * +Strdup(const char *s){ + char *d; + + d = Malloc(strlen(s) + 1); + strcpy(d, s); + return d; +} + +static void +createtmpdir(void) { + /* length of prefix + 20 (digits in 2**64) + 1 (slash) + 1 */ + temp_dir = Malloc(strlen(TEMPORARY_XF86CONFIG_DIR_PREFIX) + 22); + sprintf(temp_dir, "%s%ld", TEMPORARY_XF86CONFIG_DIR_PREFIX, + (long)getpid()); + if (mkdir(temp_dir, 0700) != 0) { + printf("Cannot create directory %s\n", temp_dir); + exit(-1); + } + /* append a slash */ + strcat(temp_dir, "/"); +} + + +void +keypress(void) { + printf("Press enter to continue, or ctrl-c to abort."); + getchar(); + printf("\n"); +} + +static void +emptylines(void) { + int i; + for (i = 0; i < 50; i++) + printf("\n"); +} + +static int +answerisyes(char *s) +{ + if (s[0] == '\'') /* For fools that type the ' literally. */ + return tolower(s[1]) == 'y'; + return tolower(s[0]) == 'y'; +} + +/* + * This is a replacement for gets(). Limit is 80 chars. + * The 386BSD descendants scream about using gets(), for good reason. + */ + +static void +getstring(char *s) +{ + char *cp; + if (fgets(s, 80, stdin) == NULL) + exit(1); + cp = strchr(s, '\n'); + if (cp) + *cp=0; +} + +/* + * Mouse configuration. + */ + +int M_OSMOUSE, M_WSMOUSE, M_AUTO, + M_SYSMOUSE, M_MOUSESYSTEMS, M_PS2, + M_MICROSOFT, M_BUSMOUSE, M_IMPS2, + M_EXPLORER_PS2, M_GLIDEPOINT_PS2, M_MOUSEMANPLUS_PS2, + M_NETMOUSE_PS2, M_NETSCROLL_PS2, M_THINKINGMOUSE_PS2, + M_ACECAD, M_GLIDEPOINT, M_INTELLIMOUSE, + M_LOGITECH, M_MMHITTAB, M_MMSERIES, + M_MOUSEMAN, M_THINKINGMOUSE, M_VUID; + +struct { + char *name; + int *ident; + char *desc; +} mouse_info[] = { +#if defined(QNX4) +#define DEF_PROTO_STRING "OSMOUSE" + {"OSMOUSE", &M_OSMOUSE, + "OSMOUSE" + }, +#endif +#ifdef WSCONS_SUPPORT +#define WS_MOUSE_STRING "wsmouse" +#define DEF_PROTO_STRING WS_MOUSE_STRING + {WS_MOUSE_STRING, &M_WSMOUSE, + "wsmouse protocol" + }, +#endif +#ifndef DEF_PROTO_STRING +#define DEF_PROTO_STRING "Auto" +#endif + {"Auto", &M_AUTO, + "Auto detect" + }, +#ifdef sun + {"VUID", &M_VUID, + "Solaris VUID protocol (SPARC, USB, or virtual mouse)" + }, +#endif + {"SysMouse", &M_SYSMOUSE, + "SysMouse" + }, +#define M_MOUSESYSTEMS_STRING "MouseSystems" + {M_MOUSESYSTEMS_STRING, &M_MOUSESYSTEMS, + "Mouse Systems (3-button protocol)" + }, + {"PS/2", &M_PS2, + "PS/2 Mouse" + }, +#define M_MICROSOFT_STRING "Microsoft" + {M_MICROSOFT_STRING, &M_MICROSOFT, + "Microsoft compatible (2-button protocol)" + }, + {"Busmouse", &M_BUSMOUSE, + "Bus Mouse" + }, +#ifndef __FreeBSD__ + {"IMPS/2", &M_IMPS2, + "IntelliMouse PS/2" + }, + {"ExplorerPS/2", &M_EXPLORER_PS2, + "Explorer PS/2" + }, + {"GlidePointPS/2", &M_GLIDEPOINT_PS2, + "GlidePoint PS/2" + }, + {"MouseManPlusPS/2", &M_MOUSEMANPLUS_PS2, + "MouseManPlus PS/2" + }, + {"NetMousePS/2", &M_NETMOUSE_PS2, + "NetMouse PS/2" + }, + {"NetScrollPS/2", &M_NETSCROLL_PS2, + "NetScroll PS/2" + }, + {"ThinkingMousePS/2", &M_THINKINGMOUSE_PS2, + "ThinkingMouse PS/2" + }, +#endif + {"AceCad", &M_ACECAD, + "AceCad" + }, + {"GlidePoint", &M_GLIDEPOINT, + "GlidePoint" + }, + {"IntelliMouse", &M_INTELLIMOUSE, + "Microsoft IntelliMouse" + }, + {"Logitech", &M_LOGITECH, + "Logitech Mouse (serial, old type, Logitech protocol)" + }, + {"MMHitTab", &M_MMHITTAB, + "MM HitTablet" + }, + {"MMSeries", &M_MMSERIES, + "MM Series" /* XXXX These descriptions should be improved. */ + }, + {"MouseMan", &M_MOUSEMAN, + "Logitech MouseMan (Microsoft compatible)" + }, + {"ThinkingMouse", &M_THINKINGMOUSE, + "ThinkingMouse" + }, +}; + +#ifdef WSCONS_SUPPORT +# define DEF_MOUSEDEV "/dev/wsmouse"; +#elif defined(__FreeBSD__) || defined(__DragonFly__) +# define DEF_MOUSEDEV "/dev/sysmouse"; +#elif defined(__linux__) +# define DEF_MOUSEDEV "/dev/input/mice"; +#else +# define DEF_MOUSEDEV "/dev/mouse"; +#endif + +static char *mouseintro_text = +"First specify a mouse protocol type. Choose one from the following list:\n" +"\n"; + +static char *mousedev_text = +"Now give the full device name that the mouse is connected to, for example\n" +"/dev/tty00. Just pressing enter will use the default, %s.\n" +"\n"; + +static char *mousecomment_text = +"The recommended protocol is " DEF_PROTO_STRING ". If you have a very old mouse\n" +"or don't want OS support or auto detection, and you have a two-button\n" +"or three-button serial mouse, it is most likely of type " M_MICROSOFT_STRING ".\n" +#ifdef WSCONS_SUPPORT +"\n" +"If your system uses the wscons console driver, with a PS/2 type mouse,\n" +"select " WS_MOUSE_STRING ".\n" +#endif +"\n"; + +static char *twobuttonmousecomment_text = +"You have selected a two-button mouse protocol. It is recommended that you\n" +"enable Emulate3Buttons.\n"; + +static char *threebuttonmousecomment_text = +"You have selected a three-button mouse protocol. It is recommended that you\n" +"do not enable Emulate3Buttons, unless the third button doesn't work.\n"; + +static char *unknownbuttonsmousecomment_text = +"If your mouse has only two buttons, it is recommended that you enable\n" +"Emulate3Buttons.\n"; + +static char *microsoftmousecomment_text = +"You have selected a Microsoft protocol mouse. If your mouse was made by\n" +"Logitech, you might want to enable ChordMiddle which could cause the\n" +"third button to work.\n"; + +static char *mousesystemscomment_text = +"You have selected a Mouse Systems protocol mouse. If your mouse is normally\n" +"in Microsoft-compatible mode, enabling the ClearDTR and ClearRTS options\n" +"may cause it to switch to Mouse Systems mode when the server starts.\n"; + +static char *logitechmousecomment_text = +"You have selected a Logitech protocol mouse. This is only valid for old\n" +"Logitech mice.\n"; + +static char *mousemancomment_text = +"You have selected a Logitech MouseMan type mouse. You might want to enable\n" +"ChordMiddle which could cause the third button to work.\n"; + +static void +mouse_configuration(void) { + +#if !defined(QNX4) + int i, j; + char s[80]; + char *def_mousedev = DEF_MOUSEDEV; + +#define MOUSETYPE_COUNT sizeof(mouse_info)/sizeof(mouse_info[0]) + for (i = 0; i < MOUSETYPE_COUNT; i++) + *(mouse_info[i].ident) = i; + + for (i=0;;) { + emptylines(); + printf("%s", mouseintro_text); + for (j = i; j < i + 14 && j < MOUSETYPE_COUNT; j++) + printf("%2d. %s [%s]\n", j + 1, + mouse_info[j].name, mouse_info[j].desc); + printf("\n"); + printf("%s", mousecomment_text); + printf("Enter a protocol number: "); + getstring(s); + if (strlen(s) == 0) { + i += 14; + if (i >= MOUSETYPE_COUNT) + i = 0; + continue; + } + config_mousetype = atoi(s) - 1; + if (config_mousetype >= 0 && config_mousetype < MOUSETYPE_COUNT) + break; + } + printf("\n"); + + if (config_mousetype == M_LOGITECH) { + /* Logitech. */ + printf("%s", logitechmousecomment_text); + printf("\n"); + printf("Please answer the following question with either 'y' or 'n'.\n"); + printf("Are you sure it's really not a Microsoft compatible one? "); + getstring(s); + if (!answerisyes(s)) + config_mousetype = M_MICROSOFT; + printf("\n"); + } + + config_chordmiddle = 0; + if (config_mousetype == M_MICROSOFT || config_mousetype == M_MOUSEMAN) { + /* Microsoft or MouseMan. */ + if (config_mousetype == M_MICROSOFT) + printf("%s", microsoftmousecomment_text); + else + printf("%s", mousemancomment_text); + printf("\n"); + printf("Please answer the following question with either 'y' or 'n'.\n"); + printf("Do you want to enable ChordMiddle? "); + getstring(s); + if (answerisyes(s)) + config_chordmiddle = 1; + printf("\n"); + } + + config_cleardtrrts = 0; + if (config_mousetype == M_MOUSESYSTEMS) { + /* Mouse Systems. */ + printf("%s", mousesystemscomment_text); + printf("\n"); + printf("Please answer the following question with either 'y' or 'n'.\n"); + printf("Do you want to enable ClearDTR and ClearRTS? "); + getstring(s); + if (answerisyes(s)) + config_cleardtrrts = 1; + printf("\n"); + } + + if (config_mousetype == M_MICROSOFT) { + if (config_chordmiddle) + printf("%s", threebuttonmousecomment_text); + else + printf("%s", twobuttonmousecomment_text); + } + else if (config_mousetype == M_MOUSESYSTEMS || + config_mousetype == M_INTELLIMOUSE) { + printf("%s", threebuttonmousecomment_text); + } + else { + printf("%s", unknownbuttonsmousecomment_text); + } + + printf("\n"); + + printf("Please answer the following question with either 'y' or 'n'.\n"); + printf("Do you want to enable Emulate3Buttons? "); + getstring(s); + if (answerisyes(s)) + config_emulate3buttons = 1; + else + config_emulate3buttons = 0; + printf("\n"); + +#if (defined(sun) && (defined(__i386) || defined(__x86))) + /* SPARC & USB mice (VUID or AUTO protocols) default to /dev/mouse, + but PS/2 mice default to /dev/kdmouse */ + if ((config_mousetype != M_AUTO) && (config_mousetype != M_VUID)) { + def_mousedev = "/dev/kdmouse"; + } +#endif + + printf(mousedev_text, def_mousedev); + printf("Mouse device: "); + getstring(s); + if (strlen(s) == 0) { + config_pointerdevice = def_mousedev; + } else { + config_pointerdevice = Malloc(strlen(s) + 1); + strcpy(config_pointerdevice, s); + } + printf("\n"); + +#else + /* set some reasonable defaults for OS/2 */ + config_mousetype = M_OSMOUSE; + config_chordmiddle = 0; + config_cleardtrrts = 0; + config_emulate3buttons = 0; + config_pointerdevice = "QNXMOUSE"; +#endif +} + + +/* + * Keyboard configuration. + */ + +/* + * Configuration of XKB + */ +static char *xkbmodeltext = +"Please select one of the following keyboard types that is the better\n" +"description of your keyboard. If nothing really matches,\n" +"choose \"Generic 104-key PC\"\n\n"; + +static char *xkblayouttext = +"Please select the layout corresponding to your keyboard\n"; + +static char *xkbvarianttext = +"Please enter a variant name for '%s' layout. Or just press enter\n" +"for default variant\n\n"; + +static char *xkboptionstext = +"Please answer the following question with either 'y' or 'n'.\n" +"Do you want to select additional XKB options (group switcher,\n" +"group indicator, etc.)? "; + +#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) +static char *kbdevtext = +"Please enter the device name for your keyboard or just press enter\n" +"for the default of wskbd0\n\n"; +#endif + +static void +keyboard_configuration(void) +{ + int i, j; + char s[80]; + char *rulesfile; + int number, options[MAX_XKBOPTIONS], num_options; + XkbRF_RulesPtr rules; + +#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) + printf(kbdevtext); + getstring(s); + if (strlen(s) != 0) { + config_keyboard_dev = Malloc(strlen(s) + 1); + strcpy(config_keyboard_dev, s); + } +#endif + +#ifndef XKB_RULES_DIR +# define XKB_RULES_DIR XKB_BASE_DIRECTORY "/rules" +#endif + +#ifdef XFREE98_XKB + config_xkbrules = "xfree98"; /* static */ + rulesfile = XKB_RULES_DIR "/xfree98"; +#else + config_xkbrules = __XKBDEFRULES__; /* static */ + rulesfile = XKB_RULES_DIR "/" __XKBDEFRULES__; +#endif + + rules = XkbRF_Load(rulesfile, "", True, False); + emptylines(); + + if (!rules) { + printf("XKB rules file '%s' not found\n", rulesfile); + printf("Keyboard XKB options will be set to default values.\n"); + keypress(); + return; + } + + number = -1; + for (i=0;;) { + emptylines(); + printf(xkbmodeltext); + for (j = i; j < i + 16 && j < rules->models.num_desc; j++) + printf("%3d %-50s\n", j+1, rules->models.desc[j].desc); + printf("\nEnter a number to choose the keyboard.\n\n"); + if (rules->models.num_desc >= 16) + printf("Press enter for the next page\n"); + getstring(s); + if (strlen(s) == 0) { + i += 16; + if (i > rules->models.num_desc) + i = 0; + continue; + } + number = atoi(s) - 1; + if (number >= 0 && number < rules->models.num_desc) + break; + } + + i = strlen(rules->models.desc[number].name) + 1; + config_xkbmodel = Malloc(i); + sprintf(config_xkbmodel,"%s", rules->models.desc[number].name); + + emptylines(); + printf(xkblayouttext); + + number = -1; + for (i=0;;) { + emptylines(); + for (j = i; j < i + 18 && j < rules->layouts.num_desc; j++) + printf("%3d %-50s\n", j+1, + rules->layouts.desc[j].desc); + printf("\n"); + printf("Enter a number to choose the country.\n"); + if (rules->layouts.num_desc >= 18) + printf("Press enter for the next page\n"); + printf("\n"); + getstring(s); + if (strlen(s) == 0) { + i += 18; + if (i > rules->layouts.num_desc) + i = 0; + continue; + } + number = atoi(s) - 1; + if (number >= 0 && number < rules->layouts.num_desc) + break; + } + config_xkblayout = Malloc(strlen(rules->layouts.desc[number].name)+1); + sprintf(config_xkblayout,"%s", rules->layouts.desc[number].name); + + emptylines(); + printf(xkbvarianttext, config_xkblayout); + getstring(s); + if (strlen(s) != 0) { + config_xkbvariant = Malloc(strlen(s) + 1); + strcpy(config_xkbvariant, s); + } + + emptylines(); + printf(xkboptionstext); + getstring(s); + if (!answerisyes(s)) + return; + + num_options = 0; + for (j=0,i=0;;) { + if (!strchr(rules->options.desc[i].name, ':')) { + emptylines(); + printf(" %s\n\n", rules->options.desc[i].desc); + j = i; + } else { + printf("%3d %-50s\n", i - j, rules->options.desc[i].desc); + } + i++; + if ( i == rules->options.num_desc || + !strchr(rules->options.desc[i].name, ':')) { + printf("\nPlease select the option or just press enter if none\n"); + getstring(s); + if (strlen(s) != 0) { + number = atoi(s); + if (number && (num_options < MAX_XKBOPTIONS)) { + options[num_options++] = number + j; + } + } + } + if (i == rules->options.num_desc) + break; + } + + if (!num_options) + return; + + for (j=0,i=0; i<num_options; i++) { + j += strlen(rules->options.desc[options[i]].name); + } + config_xkboptions = Malloc(j + num_options); + for (j=0,i=0; i<num_options; i++) { + j += sprintf(config_xkboptions+j,"%s%s", + i == 0 ? "": "," ,rules->options.desc[options[i]].name); + } + return; +} + + + +/* + * Monitor configuration. + */ + +static char *monitorintro_text = +"Now we want to set the specifications of the monitor. The two critical\n" +"parameters are the vertical refresh rate, which is the rate at which the\n" +"the whole screen is refreshed, and most importantly the horizontal sync rate,\n" +"which is the rate at which scanlines are displayed.\n" +"\n" +"The valid range for horizontal sync and vertical sync should be documented\n" +"in the manual of your monitor.\n" +"\n"; + +static char *hsyncintro_text = +"You must indicate the horizontal sync range of your monitor. You can either\n" +"select one of the predefined ranges below that correspond to industry-\n" +"standard monitor types, or give a specific range.\n" +"\n" +"It is VERY IMPORTANT that you do not specify a monitor type with a horizontal\n" +"sync range that is beyond the capabilities of your monitor. If in doubt,\n" +"choose a conservative setting.\n" +"\n"; + +static char *customhsync_text = +"Please enter the horizontal sync range of your monitor, in the format used\n" +"in the table of monitor types above. You can either specify one or more\n" +"continuous ranges (e.g. 15-25, 30-50), or one or more fixed sync frequencies.\n" +"\n"; + +static char *vsyncintro_text = +"You must indicate the vertical sync range of your monitor. You can either\n" +"select one of the predefined ranges below that correspond to industry-\n" +"standard monitor types, or give a specific range. For interlaced modes,\n" +"the number that counts is the high one (e.g. 87 Hz rather than 43 Hz).\n" +"\n" +" 1 50-70\n" +" 2 50-90\n" +" 3 50-100\n" +" 4 40-150\n" +" 5 Enter your own vertical sync range\n"; + +static char *monitordescintro_text = +"You must now enter a few identification/description strings, namely an\n" +"identifier, a vendor name, and a model name. Just pressing enter will fill\n" +"in default names.\n" +"\n"; + +#define NU_MONITORTYPES 10 + +static char *monitortype_range[NU_MONITORTYPES] = { + "31.5", + "31.5 - 35.1", + "31.5, 35.5", + "31.5, 35.15, 35.5", + "31.5 - 37.9", + "31.5 - 48.5", + "31.5 - 57.0", + "31.5 - 64.3", + "31.5 - 79.0", + "31.5 - 82.0" +}; + +static char *monitortype_name[NU_MONITORTYPES] = { + "Standard VGA, 640x480 @ 60 Hz", + "Super VGA, 800x600 @ 56 Hz", + "8514 Compatible, 1024x768 @ 87 Hz interlaced (no 800x600)", + "Super VGA, 1024x768 @ 87 Hz interlaced, 800x600 @ 56 Hz", + "Extended Super VGA, 800x600 @ 60 Hz, 640x480 @ 72 Hz", + "Non-Interlaced SVGA, 1024x768 @ 60 Hz, 800x600 @ 72 Hz", + "High Frequency SVGA, 1024x768 @ 70 Hz", + "Monitor that can do 1280x1024 @ 60 Hz", + "Monitor that can do 1280x1024 @ 74 Hz", + "Monitor that can do 1280x1024 @ 76 Hz" +}; + +static void +monitor_configuration(void) { + int i; + char s[80]; + printf("%s", monitorintro_text); + + keypress(); + emptylines(); + + printf("%s", hsyncintro_text); + + printf(" hsync in kHz; monitor type with characteristic modes\n"); + for (i = 0; i < NU_MONITORTYPES; i++) + printf("%2d %s; %s\n", i + 1, monitortype_range[i], + monitortype_name[i]); + + printf("%2d Enter your own horizontal sync range\n", + NU_MONITORTYPES + 1); + printf("\n"); + + printf("Enter your choice (1-%d): ", NU_MONITORTYPES + 1); + getstring(s); + config_monitortype = atoi(s) - 1; + if (config_monitortype < 0) + config_monitortype = 0; + + printf("\n"); + + if (config_monitortype < NU_MONITORTYPES) + config_hsyncrange = monitortype_range[config_monitortype]; + else { + /* Custom hsync range option selected. */ + printf("%s", customhsync_text); + printf("Horizontal sync range: "); + getstring(s); + config_hsyncrange = Malloc(strlen(s) + 1); + strcpy(config_hsyncrange, s); + printf("\n"); + } + + printf("%s", vsyncintro_text); + printf("\n"); + + printf("Enter your choice: "); + getstring(s); + printf("\n"); + switch (atoi(s)) { + case 0 : + case 1 : + config_vsyncrange = "50-70"; + break; + case 2 : + config_vsyncrange = "50-90"; + break; + case 3 : + config_vsyncrange = "50-100"; + break; + case 4 : + config_vsyncrange = "40-150"; + break; + case 5 : + /* Custom vsync range option selected. */ + printf("Vertical sync range: "); + getstring(s); + config_vsyncrange = Malloc(strlen(s) + 1); + strcpy(config_vsyncrange, s); + printf("\n"); + break; + } + printf("%s", monitordescintro_text); + printf("The strings are free-form, spaces are allowed.\n"); + printf("Enter an identifier for your monitor definition: "); + getstring(s); + if (strlen(s) == 0) + config_monitoridentifier = "My Monitor"; + else { + config_monitoridentifier = Malloc(strlen(s) + 1); + strcpy(config_monitoridentifier, s); + } +} + + +/* + * Card database. + */ + +static char *cardintro_text = +"Now we must configure video card specific settings. At this point you can\n" +"choose to make a selection out of a database of video card definitions.\n" +"Because there can be variation in Ramdacs and clock generators even\n" +"between cards of the same model, it is not sensible to blindly copy\n" +"the settings (e.g. a Device section). For this reason, after you make a\n" +"selection, you will still be asked about the components of the card, with\n" +"the settings from the chosen database entry presented as a strong hint.\n" +"\n" +"The database entries include information about the chipset, what driver to\n" +"run, the Ramdac and ClockChip, and comments that will be included in the\n" +"Device section. However, a lot of definitions only hint about what driver\n" +"to run (based on the chipset the card uses) and are untested.\n" +"\n" +"If you can't find your card in the database, there's nothing to worry about.\n" +"You should only choose a database entry that is exactly the same model as\n" +"your card; choosing one that looks similar is just a bad idea (e.g. a\n" +"GemStone Snail 64 may be as different from a GemStone Snail 64+ in terms of\n" +"hardware as can be).\n" +"\n"; + +static char *cardunsupported_text = +"This card is basically UNSUPPORTED. It may only work as a generic\n" +"VGA-compatible card. If you have an "__XSERVERNAME__" version more recent than what\n" +"this card definition was based on, there's a chance that it is now\n" +"supported.\n"; + +static void +carddb_configuration(void) { + int i; + char s[80]; + card_selected = -1; + printf("%s", cardintro_text); + printf("Do you want to look at the card database? "); + getstring(s); + printf("\n"); + if (!answerisyes(s)) + return; + + /* + * Choose a database entry. + */ + if (parse_database()) { + printf("Couldn't read card database file %s.\n", + CARD_DATABASE_FILE); + keypress(); + return; + } + + i = 0; + for (;;) { + int j; + emptylines(); + for (j = i; j < i + 18 && j <= lastcard; j++) { + char *name = card[j].name, + *chipset = card[j].chipset; + + printf("%3d %-50s%s\n", j, + name ? name : "-", + chipset ? chipset : "-"); + } + printf("\n"); + printf("Enter a number to choose the corresponding card definition.\n"); + printf("Press enter for the next page, q to continue configuration.\n"); + printf("\n"); + getstring(s); + if (s[0] == 'q') + break; + if (strlen(s) == 0) { + i += 18; + if (i > lastcard) + i = 0; + continue; + } + card_selected = atoi(s); + if (card_selected >= 0 && card_selected <= lastcard) + break; + } + + /* + * Look at the selected card. + */ + if (card_selected != -1) { + char *name = card[card_selected].name, + *chipset = card[card_selected].chipset; + + printf("\nYour selected card definition:\n\n"); + printf("Identifier: %s\n", name ? name : "-"); + printf("Chipset: %s\n", chipset ? chipset : "-"); + if (!card[card_selected].driver) + card[card_selected].driver = "unknown"; + printf("Driver: %s\n", card[card_selected].driver); + + if (card[card_selected].ramdac != NULL) + printf("Ramdac: %s\n", card[card_selected].ramdac); + if (card[card_selected].dacspeed != NULL) + printf("DacSpeed: %s\n", card[card_selected].dacspeed); + if (card[card_selected].clockchip != NULL) + printf("Clockchip: %s\n", card[card_selected].clockchip); + if (card[card_selected].flags & NOCLOCKPROBE) + printf("Do NOT probe clocks or use any Clocks line.\n"); + if (card[card_selected].flags & UNSUPPORTED) + printf("%s", cardunsupported_text); +#if 0 /* Might be confusing. */ + if (strlen(card[card_selected].lines) > 0) + printf("Device section text:\n%s", + card[card_selected].lines); +#endif + printf("\n"); + keypress(); + } +} + + +/* + * Screen/video card configuration. + */ + +static char *deviceintro_text = +"Now you must give information about your video card. This will be used for\n" +"the \"Device\" section of your video card in " CONFIGNAME ".\n" +"\n"; + +static char *videomemoryintro_text = +"It is probably a good idea to use the same approximate amount as that detected\n" +"by the server you intend to use. If you encounter problems that are due to the\n" +"used server not supporting the amount memory you have, specify the maximum\n" +"amount supported by the server.\n" +"\n" +"How much video memory do you have on your video card:\n" +"\n"; + +static char *carddescintro_text = +"You must now enter a few identification/description strings, namely an\n" +"identifier, a vendor name, and a model name. Just pressing enter will fill\n" +"in default names (possibly from a card definition).\n" +"\n"; + +#if 0 +static char *devicesettingscomment_text = +"Especially for accelerated drivers, Ramdac, Dacspeed and ClockChip settings\n" +"or special options may be required in the Device section.\n" +"\n"; + +static char *ramdaccomment_text = +"The RAMDAC setting only applies to some drivers. Some RAMDAC's are\n" +"auto-detected by the server. The detection of a RAMDAC is forced by using a\n" +"Ramdac \"identifier\" line in the Device section. The identifiers are shown\n" +"at the right of the following table of RAMDAC types:\n" +"\n"; + +#define NU_RAMDACS 24 + +static char *ramdac_name[NU_RAMDACS] = { + "AT&T 20C490 (S3 and AGX servers, ARK driver)", + "AT&T 20C498/21C498/22C498 (S3, autodetected)", + "AT&T 20C409/20C499 (S3, autodetected)", + "AT&T 20C505 (S3)", + "BrookTree BT481 (AGX)", + "BrookTree BT482 (AGX)", + "BrookTree BT485/9485 (S3)", + "Sierra SC15025 (S3, AGX)", +#if XFREE86_VERSION >= 311 + "S3 GenDAC (86C708) (autodetected)", + "S3 SDAC (86C716) (autodetected)", +#else + "S3 GenDAC (86C708)", + "S3 SDAC (86C716)", +#endif + "STG-1700 (S3, autodetected)", + "STG-1703 (S3, autodetected)", + "TI 3020 (S3, autodetected)", + "TI 3025 (S3, autodetected)", + "TI 3026 (S3, autodetected)", + "IBM RGB 514 (S3, autodetected)", + "IBM RGB 524 (S3, autodetected)", + "IBM RGB 525 (S3, autodetected)", + "IBM RGB 526 (S3)", + "IBM RGB 528 (S3, autodetected)", + "ICS5342 (S3, ARK)", + "ICS5341 (W32)", + "IC Works w30C516 ZoomDac (ARK)", + "Normal DAC" +}; + +static char *ramdac_id[NU_RAMDACS] = { + "att20c490", "att20c498", "att20c409", "att20c505", "bt481", "bt482", + "bt485", "sc15025", "s3gendac", "s3_sdac", "stg1700","stg1703", + "ti3020", "ti3025", "ti3026", "ibm_rgb514", "ibm_rgb524", + "ibm_rgb525", "ibm_rgb526", "ibm_rgb528", "ics5342", "ics5341", + "zoomdac", "normal" +}; + +static char *clockchipcomment_text = +"A Clockchip line in the Device section forces the detection of a\n" +"programmable clock device. With a clockchip enabled, any required\n" +"clock can be programmed without requiring probing of clocks or a\n" +"Clocks line. Most cards don't have a programmable clock chip.\n" +"Choose from the following list:\n" +"\n"; + +#define NU_CLOCKCHIPS 12 + +static char *clockchip_name[] = { + "Chrontel 8391", + "ICD2061A and compatibles (ICS9161A, DCS2824)", + "ICS2595", + "ICS5342 (similar to SDAC, but not completely compatible)", + "ICS5341", + "S3 GenDAC (86C708) and ICS5300 (autodetected)", + "S3 SDAC (86C716)", + "STG 1703 (autodetected)", + "Sierra SC11412", + "TI 3025 (autodetected)", + "TI 3026 (autodetected)", + "IBM RGB 51x/52x (autodetected)", +}; + +static char *clockchip_id[] = { + "ch8391", "icd2061a", "ics2595", "ics5342", "ics5341", + "s3gendac", "s3_sdac", + "stg1703", "sc11412", "ti3025", "ti3026", "ibm_rgb5xx", +}; + +static char *deviceclockscomment_text = +"For most modern configurations, a Clocks line is neither required or\n" +"desirable. However for some older hardware it can be useful since it\n" +"prevents the slow and nasty sounding clock probing at server start-up.\n" +"Probed clocks are displayed at server startup, along with other server\n" +"and hardware configuration info. You can save this information in a file\n" +"by running 'X -probeonly 2>output_file'. Be warned that clock probing is\n" +"inherently imprecise; some clocks may be slightly too high (varies per run).\n" +"\n"; + +static char *deviceclocksquestion_text = +"At this point I can run X -probeonly, and try to extract the clock information\n" +"from the output. It is recommended that you do this yourself and if a set of\n" +"clocks is shown then you add a clocks line (note that the list of clocks may\n" +"be split over multiple Clocks lines) to your Device section afterwards. Be\n" +"aware that a clocks line is not appropriate for most modern hardware that\n" +"has programmable clocks.\n" +"\n" +"You must be root to be able to run X -probeonly now.\n" +"\n"; + +static char *probeonlywarning_text = +"It is possible that the hardware detection routines in the server will somehow\n" +"cause the system to crash and the screen to remain blank. If this is the\n" +"case, do not choose this option the next time. The server may need a\n" +"Ramdac, ClockChip or special option (e.g. \"nolinear\" for S3) to probe\n" +"and start-up correctly.\n" +"\n"; +#endif + +static char *modesorderintro_text = +"For each depth, a list of modes (resolutions) is defined. The default\n" +"resolution that the server will start-up with will be the first listed\n" +"mode that can be supported by the monitor and card.\n" +"Currently it is set to:\n" +"\n"; + +static char *modesorder_text2 = +"Modes that cannot be supported due to monitor or clock constraints will\n" +"be automatically skipped by the server.\n" +"\n" +" 1 Change the modes for 8-bit (256 colors)\n" +" 2 Change the modes for 16-bit (32K/64K colors)\n" +" 3 Change the modes for 24-bit (24-bit color)\n" +" 4 The modes are OK, continue.\n" +"\n"; + +static char *modeslist_text = +"Please type the digits corresponding to the modes that you want to select.\n" +"For example, 432 selects \"1024x768\" \"800x600\" \"640x480\", with a\n" +"default mode of 1024x768.\n" +"\n"; + +static char *virtual_text = +"You can have a virtual screen (desktop), which is screen area that is larger\n" +"than the physical screen and which is panned by moving the mouse to the edge\n" +"of the screen. If you don't want virtual desktop at a certain resolution,\n" +"you cannot have modes listed that are larger. Each color depth can have a\n" +"differently-sized virtual screen\n" +"\n"; + +static int videomemory[] = { + 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144 +}; + +/* Is this required? */ +#if XFREE86_VERSION >= 400 +#define NU_MODESTRINGS 13 +#else +#if XFREE86_VERSION >= 330 +#define NU_MODESTRINGS 12 +#else +#if XFREE86_VERSION >= 311 +#define NU_MODESTRINGS 8 +#else +#define NU_MODESTRINGS 5 +#endif +#endif +#endif + +static char *modestring[NU_MODESTRINGS] = { + "\"640x400\"", + "\"640x480\"", + "\"800x600\"", + "\"1024x768\"", + "\"1280x1024\"", +#if XFREE86_VERSION >= 311 + "\"320x200\"", + "\"320x240\"", + "\"400x300\"" +#endif +#if XFREE86_VERSION >= 330 + ,"\"1152x864\"", + "\"1600x1200\"", + "\"1800x1400\"", + "\"512x384\"" +#endif +#if XFREE86_VERSION >= 400 + ,"\"1400x1050\"" +#endif +}; + +static int exists_dir(char *name) { + struct stat sbuf; + + /* is it there ? */ + if (stat(name,&sbuf) == -1) + return 0; + + /* is there, but is it a dir? */ + return S_ISDIR(sbuf.st_mode) ? 1 : 0; +} + +static int +screen_configuration(void) { + int i, c/*, np*/; + char s[80]; + + /* + * Configure the "Device" section for the video card. + */ + + printf("%s", deviceintro_text); + + printf("%s", videomemoryintro_text); + + for (i = 0; i < sizeof(videomemory) / sizeof(videomemory[0]); i++) + printf("%2d %dK\n", i + 1, videomemory[i]); + printf("%2d Other\n\n", i + 1); + + printf("Enter your choice: "); + getstring(s); + printf("\n"); + + c = atoi(s) - 1; + if (c >= 0 && c < sizeof(videomemory) / sizeof(videomemory[0])) + config_videomemory = videomemory[c]; + else { + printf("Amount of video memory in Kbytes: "); + getstring(s); + config_videomemory = atoi(s); + printf("\n"); + } + + printf("%s", carddescintro_text); + if (card_selected != -1) + printf("Your card definition is %s.\n\n", + card[card_selected].name); + printf("The strings are free-form, spaces are allowed.\n"); + printf("Enter an identifier for your video card definition: "); + getstring(s); + if (strlen(s) == 0) + if (card_selected != -1) + config_deviceidentifier = card[card_selected].name; + else + config_deviceidentifier = "My Video Card"; + else { + config_deviceidentifier = Malloc(strlen(s) + 1); + strcpy(config_deviceidentifier, s); + } + printf("\n"); + + emptylines(); + + /* + * Initialize screen mode variables for svga and accel + * to default values. + * XXXX Doesn't leave room for off-screen caching in 16/32bpp modes + * for the accelerated servers in some situations. + */ + config_modesline8bpp = + config_modesline16bpp = + config_modesline24bpp = "\"640x480\""; + config_virtualx8bpp = config_virtualx16bpp = config_virtualx24bpp = + config_virtualy8bpp = config_virtualy16bpp = config_virtualy24bpp = 0; + if (config_videomemory >= 4096) { + config_virtualx8bpp = 1600; + config_virtualy8bpp = 1280; + if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) { + /* + * Allow room for font/pixmap cache for accel + * servers. + */ + config_virtualx16bpp = 1280; + config_virtualy16bpp = 1024; + } + else { + config_virtualx16bpp = 1600; + config_virtualy16bpp = 1280; + } + if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) { + config_virtualx24bpp = 1152; + config_virtualy24bpp = 900; + } + else { + config_virtualx24bpp = 1280; + config_virtualy24bpp = 1024; + } + /* Add 1600x1280 */ + config_modesline8bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\""; + config_modesline16bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\""; + config_modesline24bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\""; + + } + else + if (config_videomemory >= 2048) { + if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) { + /* + * Allow room for font/pixmap cache for accel + * servers. + * Also the mach32 is has a limited width. + */ + config_virtualx8bpp = 1280; + config_virtualy8bpp = 1024; + } + else { + config_virtualx8bpp = 1600; + config_virtualy8bpp = 1200; + } + if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) { + config_virtualx16bpp = 1024; + config_virtualy16bpp = 768; + } + else { + config_virtualx16bpp = 1152; + config_virtualy16bpp = 900; + } + config_virtualx24bpp = 800; + config_virtualy24bpp = 600; + if (config_videomemory >= 2048 + 256) { + config_virtualx24bpp = 1024; + config_virtualy24bpp = 768; + } + config_modesline8bpp = "\"1280x1024\" \"1024x768\" \"800x600\" \"640x480\""; + config_modesline16bpp = "\"1024x768\" \"800x600\" \"640x480\""; + if (config_videomemory >= 2048 + 256) + config_modesline24bpp = "\"1024x768\" \"800x600\" \"640x480\""; + else + config_modesline24bpp = "\"800x600\" \"640x480\""; + } + else + if (config_videomemory >= 1024) { + if (card_selected != -1 && !(card[card_selected].flags & UNSUPPORTED)) { + /* + * Allow room for font/pixmap cache for accel + * servers. + */ + config_virtualx8bpp = 1024; + config_virtualy8bpp = 768; + } + else { + config_virtualx8bpp = 1152; + config_virtualy8bpp = 900; + } + config_virtualx16bpp = 800; /* Forget about cache space; */ + config_virtualy16bpp = 600; /* it's small enough as it is. */ + config_virtualx24bpp = 640; + config_virtualy24bpp = 480; + config_modesline8bpp = "\"1024x768\" \"800x600\" \"640x480\""; + config_modesline16bpp = "\"800x600\" \"640x480\""; + config_modesline24bpp = "\"640x480\""; + } + else + if (config_videomemory >= 512) { + config_virtualx8bpp = 800; + config_virtualy8bpp = 600; + config_modesline8bpp = "\"800x600\" \"640x480\""; + config_modesline16bpp = "\"640x400\""; + } + else + if (config_videomemory >= 256) { + config_modesline8bpp = "\"640x400\""; + config_virtualx8bpp = 640; + config_virtualy8bpp = 400; + } + else { + printf("Invalid amount of video memory. Please try again\n"); + return(1); + } + +#if 0 + /* + * Handle the Ramdac/Clockchip setting. + */ + + printf("%s", devicesettingscomment_text); + + if (card_selected == -1 || (card[card_selected].flags & UNSUPPORTED)) + goto skipramdacselection; + + printf("%s", ramdaccomment_text); + + /* meanwhile there are so many RAMDACs that they do no longer fit on + * on page + */ + for (np=12, i=0 ;;) { + int j; + for (j = i; j < i + np && j < NU_RAMDACS; j++) + printf("%3d %-60s%s\n", j+1, + ramdac_name[j], + ramdac_id[j]); + + printf("\n"); + if (card_selected != -1) + if (card[card_selected].ramdac != NULL) + printf("The card definition has Ramdac \"%s\".\n\n", + card[card_selected].ramdac); + printf("\n"); + printf("Enter a number to choose the corresponding RAMDAC.\n"); + printf("Press enter for the next page, q to quit without selection of a RAMDAC.\n"); + printf("\n"); + getstring(s); + + config_ramdac = NULL; + if (s[0] == 'q') + break; + + if (strlen(s) > 0) { + c = atoi(s)-1; + if (c >= 0 && c < NU_RAMDACS) { + config_ramdac = ramdac_id[atoi(s)-1]; + break; + } + } + + i += np; + if (np==12) np = 18; /* account intro lines only displayed 1st time */ + if (i >= NU_RAMDACS) + i = 0; + emptylines(); + } + +skipramdacselection: + emptylines(); + printf("%s", clockchipcomment_text); + + for (i = 0; i < NU_CLOCKCHIPS; i++) + printf("%2d %-60s%s\n", + i + 1, clockchip_name[i], clockchip_id[i]); + + printf("\n"); + + if (card_selected != -1) + if (card[card_selected].clockchip != NULL) + printf("The card definition has Clockchip \"%s\"\n\n", + card[card_selected].clockchip); + + printf("Just press enter if you don't want a Clockchip setting.\n"); + printf("What Clockchip setting do you want (1-%d)? ", NU_CLOCKCHIPS); + + getstring(s); + config_clockchip = NULL; + if (strlen(s) > 0) + config_clockchip = clockchip_id[atoi(s) - 1]; + + emptylines(); + + /* + * Optionally run X -probeonly to figure out the clocks. + */ + + config_numberofclockslines = 0; + + printf("%s", deviceclockscomment_text); + + printf("%s", deviceclocksquestion_text); +#endif + +#if 0 + /* + * XXX Change this to check for a CLOCKPROBE flag rather than an + * NOCLOCKPROBE. + */ + if (card_selected != -1) + if (card[card_selected].flags & NOCLOCKPROBE) + printf("The card definition says to NOT probe clocks.\n"); + + if (config_clockchip != NULL) { + printf("Because you have enabled a Clockchip line, there's no need for clock\n" + "probing.\n"); + keypress(); + goto skipclockprobing; + } + + printf("Do you want me to run 'X -probeonly' now? "); + getstring(s); + printf("\n"); + if (answerisyes(s)) { + /* + * Write temporary XF86Config and run X -probeonly. + * Only allow when root. + */ + FILE *f; + char *buf; + char syscmdline[2*256+100]; /* enough */ + char *fname = NULL; + char *d2name = NULL; + char *d3name = NULL; + + if (getuid() != 0) { + printf("Sorry, you must be root to do this.\n\n"); + goto endofprobeonly; + } + printf("%s", probeonlywarning_text); + keypress(); + fname = Malloc(strlen(temp_dir) + + strlen(TEMPORARY_XF86CONFIG_FILENAME) + 1); + sprintf(fname, "%s%s", temp_dir, + TEMPORARY_XF86CONFIG_FILENAME); + d2name = Malloc(strlen(temp_dir) + strlen(DUMBCONFIG2) + 1); + sprintf(d2name, "%s%s", temp_dir, DUMBCONFIG2); + d3name = Malloc(strlen(temp_dir) + strlen(DUMBCONFIG3) + 1); + sprintf(d3name, "%s%s", temp_dir, DUMBCONFIG3); + printf("Running X -probeonly -pn -xf86config %s.\n", fname); + write_XF86Config(fname); + sync(); + /* compose a line with the real path */ + sprintf(syscmdline, "X -probeonly -pn -xf86config %s 2> %s", + fname, d2name); + + if (system(syscmdline)) { + printf("X -probeonly call failed.\n"); + printf("No Clocks line inserted.\n"); + goto clocksprobefailed; + } + /* Look for 'clocks:' (case sensitive). */ + sprintf(syscmdline, "grep clocks\\: %s > %s", d2name, d3name); + if (system(syscmdline)) { + printf("grep failed.\n"); + printf("Cannot find clocks in server output.\n"); + goto clocksprobefailed; + } + f = fopen(d3name, "r"); + buf = Malloc(8192); + /* Parse lines. */ + while (fgets(buf, 8192, f) != NULL) { + char *clks; + clks = strstr(buf, "clocks: ") + 8; + if (clks >= buf + 3 && strcmp(clks - 11, "num") == 0) + /* Reject lines with 'numclocks:'. */ + continue; + if (clks >= buf + 8 && strcpy(clks - 14, "pixel ") == 0) + /* Reject lines with 'pixel clocks:'. */ + continue; + clks[strlen(clks) - 1] = '\0'; /* Remove '\n'. */ + config_clocksline[config_numberofclockslines] = + Malloc(strlen(clks) + 1); + strcpy(config_clocksline[config_numberofclockslines], + clks); + printf("Clocks %s\n", clks); + config_numberofclockslines++; + } + fclose(f); +clocksprobefailed: + unlink(d3name); + unlink(d2name); + unlink(fname); + printf("\n"); + +endofprobeonly: + keypress(); + } +skipclockprobing: +#endif + + /* + * For vga driver, no further configuration is required. + */ + if (card_selected == -1 || (card[card_selected].flags & UNSUPPORTED)) + return (0); + + /* + * Configure the modes order. + */ + config_virtual = 0; + for (;;) { + char modes[128]; + + emptylines(); + + printf("%s", modesorderintro_text); + printf("%s for 8-bit\n", config_modesline8bpp); + printf("%s for 16-bit\n", config_modesline16bpp); + printf("%s for 24-bit\n", config_modesline24bpp); + printf("\n"); + printf("%s", modesorder_text2); + + printf("Enter your choice: "); + getstring(s); + printf("\n"); + + c = atoi(s) - 1; + if (c < 0 || c >= 3) + break; + + printf("Select modes from the following list:\n\n"); + + for (i = 0; i < NU_MODESTRINGS; i++) + printf(" %c %s\n", i < 9 ? '1' + i : + 'a' + i - 9, + modestring[i]); + printf("\n"); + + printf("%s", modeslist_text); + + printf("Which modes? "); + getstring(s); + printf("\n"); + + modes[0] = '\0'; + for (i = 0; i < strlen(s); i++) { + if ( NU_MODESTRINGS > 9 ) { + if ((s[i] < '1' || s[i] > '9') && + (s[i] < 'a' || s[i] > 'a' + NU_MODESTRINGS - 10)) { + printf("Invalid mode skipped.\n"); + continue; + } + } + else { + if (s[i] < '1' || s[i] > '0' + NU_MODESTRINGS) { + printf("Invalid mode skipped.\n"); + continue; + } + } + if (i > 0) + strcat(modes, " "); + strcat(modes, modestring[s[i] <= '9' ? s[i] - '1' : + s[i] - 'a' + 9]); + } + switch (c) { + case 0 : + config_modesline8bpp = Malloc(strlen(modes) + 1); + strcpy(config_modesline8bpp, modes); + break; + case 1 : + config_modesline16bpp = Malloc(strlen(modes) + 1); + strcpy(config_modesline16bpp, modes); + break; + case 2 : + config_modesline24bpp = Malloc(strlen(modes) + 1); + strcpy(config_modesline24bpp, modes); + break; + } + + printf("%s", virtual_text); + + printf("Please answer the following question with either 'y' or 'n'.\n"); + printf("Do you want a virtual screen that is larger than the physical screen?"); + getstring(s); + if (answerisyes(s)) + config_virtual = 1; + } + return(0); +} + +static char *defaultdepthtext = +"Please specify which color depth you want to use by default:\n" +"\n"; + +static struct depth_str { + char *name; + char *desc; +} depth_list[] = { + { "1", "1 bit (monochrome)" }, + { "4", "4 bits (16 colors)" }, + { "8", "8 bits (256 colors)" }, + { "16", "16 bits (65536 colors)" }, + { "24", "24 bits (16 million colors)" } +}; + +static int ndepths = sizeof(depth_list)/sizeof(struct depth_str); + +static void +depth_configuration(void) +{ + int i; + char s[80]; + int depth; + + printf(defaultdepthtext); + for (i=0; i<ndepths; i++) { + printf("%3d %-50s\n",i+1,depth_list[i].desc); + } + + printf("\nEnter a number to choose the default depth.\n\n"); + getstring(s); + if (strlen(s) == 0) + depth = 0; + else { + i = atoi(s)-1; + depth = (i < 0 || i > ndepths) ? 0 : i; + } + config_depth = depth_list[depth].name; +} + +/* + * Create the XF86Config file. + */ + +static char *XF86Config_firstchunk_text = +"# File generated by xorgconfig.\n" +"\n" +"#\n" +"# Copyright 2004 "XVENDORNAME"\n" +"#\n" +"# Permission is hereby granted, free of charge, to any person obtaining a\n" +"# copy of this software and associated documentation files (the \"Software\"),\n" +"# to deal in the Software without restriction, including without limitation\n" +"# the rights to use, copy, modify, merge, publish, distribute, sublicense,\n" +"# and/or sell copies of the Software, and to permit persons to whom the\n" +"# Software is furnished to do so, subject to the following conditions:\n" +"# \n" +"# The above copyright notice and this permission notice shall be included in\n" +"# all copies or substantial portions of the Software.\n" +"# \n" +"# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" +"# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" +"# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n" +"# "XVENDORNAME" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n" +"# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF\n" +"# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n" +"# SOFTWARE.\n" +"# \n" +"# Except as contained in this notice, the name of "XVENDORNAME" shall\n" +"# not be used in advertising or otherwise to promote the sale, use or other\n" +"# dealings in this Software without prior written authorization from\n" +"# "XVENDORNAME".\n" +"#\n" +"\n" +"# **********************************************************************\n" +"# Refer to the " CONFIGNAME "(" FILEMANSUFFIX ") man page for details about the format of \n" +"# this file.\n" +"# **********************************************************************\n" +"\n" +"# **********************************************************************\n" +"# Module section -- this section is used to specify\n" +"# which dynamically loadable modules to load.\n" +"# **********************************************************************\n" +"#\n" +"Section \"Module\"\n" +"\n" +"# This loads the DBE extension module.\n" +"\n" +" Load \"dbe\" # Double buffer extension\n" +"\n" +"# This loads the miscellaneous extensions module, and disables\n" +"# initialisation of the XFree86-DGA extension within that module.\n" +" SubSection \"extmod\"\n" +" Option \"omit xfree86-dga\" # don't initialise the DGA extension\n" +" EndSubSection\n" +"\n" +"# This loads the font modules\n" +#ifdef HAS_TYPE1 +" Load \"type1\"\n" +#else +"# Load \"type1\"\n" +#endif +" Load \"freetype\"\n" +"# Load \"xtt\"\n" +"\n" +"# This loads the GLX module\n" +"# Load \"glx\"\n" +"# This loads the DRI module\n" +"# Load \"dri\"\n" +"\n" +"EndSection\n" +"\n" +"# **********************************************************************\n" +"# Files section. This allows default font and rgb paths to be set\n" +"# **********************************************************************\n" +"\n" +"Section \"Files\"\n" +"\n" +"# Multiple FontPath entries are allowed (which are concatenated together),\n" +"# as well as specifying multiple comma-separated entries in one FontPath\n" +"# command (or a combination of both methods)\n" +"# \n" +"\n"; + +static char *XF86Config_fontpaths[] = +{ +/* " FontPath \"" TREEROOTFONT "/75dpi/\"\n"*/ + "/local/", + "/misc/", + "/75dpi/:unscaled", + "/100dpi/:unscaled", + "/Type1/", + "/TrueType/", + "/freefont/", + "/75dpi/", + "/100dpi/", + 0 /* end of fontpaths */ +}; + +static char *XF86Config_fontpathchunk_text = + +"\n" +"# The module search path. The default path is shown here.\n" +"\n" +"# ModulePath \"" MODULEPATH "\"\n" +"\n" +"EndSection\n" +"\n" +"# **********************************************************************\n" +"# Server flags section.\n" +"# **********************************************************************\n" +"\n" +"Section \"ServerFlags\"\n" +"\n" +"# Uncomment this to cause a core dump at the spot where a signal is \n" +"# received. This may leave the console in an unusable state, but may\n" +"# provide a better stack trace in the core dump to aid in debugging\n" +"\n" +"# Option \"NoTrapSignals\"\n" +"\n" +"# Uncomment this to disable the <Ctrl><Alt><Fn> VT switch sequence\n" +"# (where n is 1 through 12). This allows clients to receive these key\n" +"# events.\n" +"\n" +"# Option \"DontVTSwitch\"\n" +"\n" +"# Uncomment this to disable the <Ctrl><Alt><BS> server abort sequence\n" +"# This allows clients to receive this key event.\n" +"\n" +"# Option \"DontZap\"\n" +"\n" +"# Uncomment this to disable the <Ctrl><Alt><KP_+>/<KP_-> mode switching\n" +"# sequences. This allows clients to receive these key events.\n" +"\n" +"# Option \"Dont Zoom\"\n" +"\n" +"# Uncomment this to disable tuning with the xvidtune client. With\n" +"# it the client can still run and fetch card and monitor attributes,\n" +"# but it will not be allowed to change them. If it tries it will\n" +"# receive a protocol error.\n" +"\n" +"# Option \"DisableVidModeExtension\"\n" +"\n" +"# Uncomment this to enable the use of a non-local xvidtune client. \n" +"\n" +"# Option \"AllowNonLocalXvidtune\"\n" +"\n" +"# Uncomment this to disable dynamically modifying the input device\n" +"# (mouse and keyboard) settings. \n" +"\n" +"# Option \"DisableModInDev\"\n" +"\n" +"# Uncomment this to enable the use of a non-local client to\n" +"# change the keyboard or mouse settings (currently only xset).\n" +"\n" +"# Option \"AllowNonLocalModInDev\"\n" +"\n" +"EndSection\n" +"\n" +"# **********************************************************************\n" +"# Input devices\n" +"# **********************************************************************\n" +"\n" +"# **********************************************************************\n" +"# Core keyboard's InputDevice section\n" +"# **********************************************************************\n" +"\n" +"Section \"InputDevice\"\n" +"\n" +" Identifier \"Keyboard1\"\n" +" Driver \"kbd\"\n" +"\n" +" Option \"AutoRepeat\" \"500 30\"\n" +"\n" +"# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))\n" +"# Option \"Xleds\" \"1 2 3\"\n" +"\n"; + +static char *keyboardchunk2_text = +"\n"; + +static char *keyboardchunk3_text = +"# To customise the XKB settings to suit your keyboard, modify the\n" +"# lines below (which are the defaults). For example, for a non-U.S.\n" +"# keyboard, you will probably want to use:\n" +"# Option \"XkbModel\" \"pc105\"\n" +"# If you have a US Microsoft Natural keyboard, you can use:\n" +"# Option \"XkbModel\" \"microsoft\"\n" +"#\n" +"# Then to change the language, change the Layout setting.\n" +"# For example, a german layout can be obtained with:\n" +"# Option \"XkbLayout\" \"de\"\n" +"# or:\n" +"# Option \"XkbLayout\" \"de\"\n" +"# Option \"XkbVariant\" \"nodeadkeys\"\n" +"#\n" +"# If you'd like to switch the positions of your capslock and\n" +"# control keys, use:\n" +"# Option \"XkbOptions\" \"ctrl:swapcaps\"\n" +"\n" +"# These are the default XKB settings for "__XSERVERNAME__"\n" +"# Option \"XkbRules\" \""__XKBDEFRULES__"\"\n" +"# Option \"XkbModel\" \"pc105\"\n" +"# Option \"XkbLayout\" \"us\"\n" +"# Option \"XkbVariant\" \"\"\n" +"# Option \"XkbOptions\" \"\"\n" +"\n"; + +static char *keyboardlastchunk_text = +"\n" +"EndSection\n" +"\n" +"\n"; + +static char *pointersection_text1 = +"# **********************************************************************\n" +"# Core Pointer's InputDevice section\n" +"# **********************************************************************\n" +"\n" +"Section \"InputDevice\"\n" +"\n" +"# Identifier and driver\n" +"\n" +#if defined(__UNIXWARE__) +"# Identifier \"Mouse1\"\n" +"# Driver \"mouse\"\n" +#else +" Identifier \"Mouse1\"\n" +" Driver \"mouse\"\n" +#endif +; + +static char *pointersection_text2 = +"\n" +"# Mouse-speed setting for PS/2 mouse.\n" +"\n" +"# Option \"Resolution\" \"256\"\n" +"\n" +"# Baudrate and SampleRate are only for some Logitech mice. In\n" +"# almost every case these lines should be omitted.\n" +"\n" +"# Option \"BaudRate\" \"9600\"\n" +"# Option \"SampleRate\" \"150\"\n" +"\n" +"# Mouse wheel mapping. Default is to map vertical wheel to buttons 4 & 5,\n" +"# horizontal wheel to buttons 6 & 7. Change if your mouse has more than\n" +"# 3 buttons and you need to map the wheel to different button ids to avoid\n" +"# conflicts.\n" +"\n" +" Option \"ZAxisMapping\" \"4 5 6 7\"\n" +"\n" +"# Emulate3Buttons is an option for 2-button mice\n" +"# Emulate3Timeout is the timeout in milliseconds (default is 50ms)\n" +"\n"; + + +static char *xinputsection_text = +"# **********************************************************************\n" +"# Other input device sections \n" +"# this is optional and is required only if you\n" +"# are using extended input devices. This is for example only. Refer\n" +"# to the " CONFIGNAME " man page for a description of the options.\n" +"# **********************************************************************\n" +"#\n" +"# Section \"InputDevice\" \n" +"# Identifier \"Mouse2\"\n" +"# Driver \"mouse\"\n" +"# Option \"Protocol\" \"MouseMan\"\n" +"# Option \"Device\" \"/dev/mouse2\"\n" +"# EndSection\n" +"#\n" +"# Section \"InputDevice\"\n" +"# Identifier \"spaceball\"\n" +"# Driver \"magellan\"\n" +"# Option \"Device\" \"/dev/cua0\"\n" +"# EndSection\n" +"#\n" +"# Section \"InputDevice\"\n" +"# Identifier \"spaceball2\"\n" +"# Driver \"spaceorb\"\n" +"# Option \"Device\" \"/dev/cua0\"\n" +"# EndSection\n" +"#\n" +"# Section \"InputDevice\"\n" +"# Identifier \"touchscreen0\"\n" +"# Driver \"microtouch\"\n" +"# Option \"Device\" \"/dev/ttyS0\"\n" +"# Option \"MinX\" \"1412\"\n" +"# Option \"MaxX\" \"15184\"\n" +"# Option \"MinY\" \"15372\"\n" +"# Option \"MaxY\" \"1230\"\n" +"# Option \"ScreenNumber\" \"0\"\n" +"# Option \"ReportingMode\" \"Scaled\"\n" +"# Option \"ButtonNumber\" \"1\"\n" +"# Option \"SendCoreEvents\"\n" +"# EndSection\n" +"#\n" +"# Section \"InputDevice\"\n" +"# Identifier \"touchscreen1\"\n" +"# Driver \"elo2300\"\n" +"# Option \"Device\" \"/dev/ttyS0\"\n" +"# Option \"MinX\" \"231\"\n" +"# Option \"MaxX\" \"3868\"\n" +"# Option \"MinY\" \"3858\"\n" +"# Option \"MaxY\" \"272\"\n" +"# Option \"ScreenNumber\" \"0\"\n" +"# Option \"ReportingMode\" \"Scaled\"\n" +"# Option \"ButtonThreshold\" \"17\"\n" +"# Option \"ButtonNumber\" \"1\"\n" +"# Option \"SendCoreEvents\"\n" +"# EndSection\n" +"\n"; + +static char *monitorsection_text1 = +"# **********************************************************************\n" +"# Monitor section\n" +"# **********************************************************************\n" +"\n" +"# Any number of monitor sections may be present\n" +"\n" +"Section \"Monitor\"\n" +"\n"; + +static char *monitorsection_text2 = +"# HorizSync is in kHz unless units are specified.\n" +"# HorizSync may be a comma separated list of discrete values, or a\n" +"# comma separated list of ranges of values.\n" +"# NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR\'S\n" +"# USER MANUAL FOR THE CORRECT NUMBERS.\n" +"\n"; + +static char *monitorsection_text3 = +"# HorizSync 30-64 # multisync\n" +"# HorizSync 31.5, 35.2 # multiple fixed sync frequencies\n" +"# HorizSync 15-25, 30-50 # multiple ranges of sync frequencies\n" +"\n" +"# VertRefresh is in Hz unless units are specified.\n" +"# VertRefresh may be a comma separated list of discrete values, or a\n" +"# comma separated list of ranges of values.\n" +"# NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR\'S\n" +"# USER MANUAL FOR THE CORRECT NUMBERS.\n" +"\n"; + +#if 0 +static char *monitorsection_text4 = +"# Modes can be specified in two formats. A compact one-line format, or\n" +"# a multi-line format.\n" +"\n" +"# These two are equivalent\n" +"\n" +"# ModeLine \"1024x768i\" 45 1024 1048 1208 1264 768 776 784 817 Interlace\n" +"\n" +"# Mode \"1024x768i\"\n" +"# DotClock 45\n" +"# HTimings 1024 1048 1208 1264\n" +"# VTimings 768 776 784 817\n" +"# Flags \"Interlace\"\n" +"# EndMode\n" +"\n"; + +static char *modelines_text = +"# This is a set of standard mode timings. Modes that are out of monitor spec\n" +"# are automatically deleted by the server (provided the HorizSync and\n" +"# VertRefresh lines are correct), so there's no immediate need to\n" +"# delete mode timings (unless particular mode timings don't work on your\n" +"# monitor). With these modes, the best standard mode that your monitor\n" +"# and video card can support for a given resolution is automatically\n" +"# used.\n" +"\n" +"# 640x400 @ 70 Hz, 31.5 kHz hsync\n" +"Modeline \"640x400\" 25.175 640 664 760 800 400 409 411 450\n" +"# 640x480 @ 60 Hz, 31.5 kHz hsync\n" +"Modeline \"640x480\" 25.175 640 664 760 800 480 491 493 525\n" +"# 800x600 @ 56 Hz, 35.15 kHz hsync\n" +"ModeLine \"800x600\" 36 800 824 896 1024 600 601 603 625\n" +"# 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync\n" +"Modeline \"1024x768\" 44.9 1024 1048 1208 1264 768 776 784 817 Interlace\n" +"\n" +"# 640x400 @ 85 Hz, 37.86 kHz hsync\n" +"Modeline \"640x400\" 31.5 640 672 736 832 400 401 404 445 -HSync +VSync\n" +"# 640x480 @ 72 Hz, 36.5 kHz hsync\n" +"Modeline \"640x480\" 31.5 640 680 720 864 480 488 491 521\n" +"# 640x480 @ 75 Hz, 37.50 kHz hsync\n" +"ModeLine \"640x480\" 31.5 640 656 720 840 480 481 484 500 -HSync -VSync\n" +"# 800x600 @ 60 Hz, 37.8 kHz hsync\n" +"Modeline \"800x600\" 40 800 840 968 1056 600 601 605 628 +hsync +vsync\n" +"\n" +"# 640x480 @ 85 Hz, 43.27 kHz hsync\n" +"Modeline \"640x480\" 36 640 696 752 832 480 481 484 509 -HSync -VSync\n" +"# 1152x864 @ 89 Hz interlaced, 44 kHz hsync\n" +"ModeLine \"1152x864\" 65 1152 1168 1384 1480 864 865 875 985 Interlace\n" +"\n" +"# 800x600 @ 72 Hz, 48.0 kHz hsync\n" +"Modeline \"800x600\" 50 800 856 976 1040 600 637 643 666 +hsync +vsync\n" +"# 1024x768 @ 60 Hz, 48.4 kHz hsync\n" +"Modeline \"1024x768\" 65 1024 1032 1176 1344 768 771 777 806 -hsync -vsync\n" +"\n" +"# 640x480 @ 100 Hz, 53.01 kHz hsync\n" +"Modeline \"640x480\" 45.8 640 672 768 864 480 488 494 530 -HSync -VSync\n" +"# 1152x864 @ 60 Hz, 53.5 kHz hsync\n" +"Modeline \"1152x864\" 89.9 1152 1216 1472 1680 864 868 876 892 -HSync -VSync\n" +"# 800x600 @ 85 Hz, 55.84 kHz hsync\n" +"Modeline \"800x600\" 60.75 800 864 928 1088 600 616 621 657 -HSync -VSync\n" +"\n" +"# 1024x768 @ 70 Hz, 56.5 kHz hsync\n" +"Modeline \"1024x768\" 75 1024 1048 1184 1328 768 771 777 806 -hsync -vsync\n" +"# 1280x1024 @ 87 Hz interlaced, 51 kHz hsync\n" +"Modeline \"1280x1024\" 80 1280 1296 1512 1568 1024 1025 1037 1165 Interlace\n" +"\n" +"# 800x600 @ 100 Hz, 64.02 kHz hsync\n" +"Modeline \"800x600\" 69.65 800 864 928 1088 600 604 610 640 -HSync -VSync\n" +"# 1024x768 @ 76 Hz, 62.5 kHz hsync\n" +"Modeline \"1024x768\" 85 1024 1032 1152 1360 768 784 787 823\n" +"# 1152x864 @ 70 Hz, 62.4 kHz hsync\n" +"Modeline \"1152x864\" 92 1152 1208 1368 1474 864 865 875 895\n" +"# 1280x1024 @ 61 Hz, 64.2 kHz hsync\n" +"Modeline \"1280x1024\" 110 1280 1328 1512 1712 1024 1025 1028 1054\n" +"\n" +"# 1024x768 @ 85 Hz, 70.24 kHz hsync\n" +"Modeline \"1024x768\" 98.9 1024 1056 1216 1408 768 782 788 822 -HSync -VSync\n" +"# 1152x864 @ 78 Hz, 70.8 kHz hsync\n" +"Modeline \"1152x864\" 110 1152 1240 1324 1552 864 864 876 908\n" +"\n" +"# 1280x1024 @ 70 Hz, 74.59 kHz hsync\n" +"Modeline \"1280x1024\" 126.5 1280 1312 1472 1696 1024 1032 1040 1068 -HSync -VSync\n" +"# 1600x1200 @ 60Hz, 75.00 kHz hsync\n" +"Modeline \"1600x1200\" 162 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync\n" +"# 1152x864 @ 84 Hz, 76.0 kHz hsync\n" +"Modeline \"1152x864\" 135 1152 1464 1592 1776 864 864 876 908\n" +"\n" +"# 1280x1024 @ 74 Hz, 78.85 kHz hsync\n" +"Modeline \"1280x1024\" 135 1280 1312 1456 1712 1024 1027 1030 1064\n" +"\n" +"# 1024x768 @ 100Hz, 80.21 kHz hsync\n" +"Modeline \"1024x768\" 115.5 1024 1056 1248 1440 768 771 781 802 -HSync -VSync\n" +"# 1280x1024 @ 76 Hz, 81.13 kHz hsync\n" +"Modeline \"1280x1024\" 135 1280 1312 1416 1664 1024 1027 1030 1064\n" +"\n" +"# 1600x1200 @ 70 Hz, 87.50 kHz hsync\n" +"Modeline \"1600x1200\" 189 1600 1664 1856 2160 1200 1201 1204 1250 -HSync -VSync\n" +"# 1152x864 @ 100 Hz, 89.62 kHz hsync\n" +"Modeline \"1152x864\" 137.65 1152 1184 1312 1536 864 866 885 902 -HSync -VSync\n" +"# 1280x1024 @ 85 Hz, 91.15 kHz hsync\n" +"Modeline \"1280x1024\" 157.5 1280 1344 1504 1728 1024 1025 1028 1072 +HSync +VSync\n" +"# 1600x1200 @ 75 Hz, 93.75 kHz hsync\n" +"Modeline \"1600x1200\" 202.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync\n" +"# 1600x1200 @ 85 Hz, 105.77 kHz hsync\n" +"Modeline \"1600x1200\" 220 1600 1616 1808 2080 1200 1204 1207 1244 +HSync +VSync\n" +"# 1280x1024 @ 100 Hz, 107.16 kHz hsync\n" +"Modeline \"1280x1024\" 181.75 1280 1312 1440 1696 1024 1031 1046 1072 -HSync -VSync\n" +"\n" +"# 1800x1440 @ 64Hz, 96.15 kHz hsync \n" +"ModeLine \"1800X1440\" 230 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync\n" +"# 1800x1440 @ 70Hz, 104.52 kHz hsync \n" +"ModeLine \"1800X1440\" 250 1800 1896 2088 2392 1440 1441 1444 1490 +HSync +VSync\n" +"\n" +"# 512x384 @ 78 Hz, 31.50 kHz hsync\n" +"Modeline \"512x384\" 20.160 512 528 592 640 384 385 388 404 -HSync -VSync\n" +"# 512x384 @ 85 Hz, 34.38 kHz hsync\n" +"Modeline \"512x384\" 22 512 528 592 640 384 385 388 404 -HSync -VSync\n" +"\n" +#if XFREE86_VERSION >= 311 +"# Low-res Doublescan modes\n" +"# If your chipset does not support doublescan, you get a 'squashed'\n" +"# resolution like 320x400.\n" +"\n" +"# 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio\n" +"Modeline \"320x200\" 12.588 320 336 384 400 200 204 205 225 Doublescan\n" +"# 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio\n" +"Modeline \"320x240\" 12.588 320 336 384 400 240 245 246 262 Doublescan\n" +"# 320x240 @ 72 Hz, 36.5 kHz hsync\n" +"Modeline \"320x240\" 15.750 320 336 384 400 240 244 246 262 Doublescan\n" +"# 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio\n" +"ModeLine \"400x300\" 18 400 416 448 512 300 301 302 312 Doublescan\n" +"# 400x300 @ 60 Hz, 37.8 kHz hsync\n" +"Modeline \"400x300\" 20 400 416 480 528 300 301 303 314 Doublescan\n" +"# 400x300 @ 72 Hz, 48.0 kHz hsync\n" +"Modeline \"400x300\" 25 400 424 488 520 300 319 322 333 Doublescan\n" +"# 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio\n" +"ModeLine \"480x300\" 21.656 480 496 536 616 300 301 302 312 Doublescan\n" +"# 480x300 @ 60 Hz, 37.8 kHz hsync\n" +"Modeline \"480x300\" 23.890 480 496 576 632 300 301 303 314 Doublescan\n" +"# 480x300 @ 63 Hz, 39.6 kHz hsync\n" +"Modeline \"480x300\" 25 480 496 576 632 300 301 303 314 Doublescan\n" +"# 480x300 @ 72 Hz, 48.0 kHz hsync\n" +"Modeline \"480x300\" 29.952 480 504 584 624 300 319 322 333 Doublescan\n" +"\n" +#endif +; +#endif + +static char *devicesection_text = +"# **********************************************************************\n" +"# Graphics device section\n" +"# **********************************************************************\n" +"\n" +"# Any number of graphics device sections may be present\n" +"\n" +"# Standard VGA Device:\n" +"\n" +"Section \"Device\"\n" +" Identifier \"Standard VGA\"\n" +" VendorName \"Unknown\"\n" +" BoardName \"Unknown\"\n" +"\n" +"# The chipset line is optional in most cases. It can be used to override\n" +"# the driver's chipset detection, and should not normally be specified.\n" +"\n" +"# Chipset \"generic\"\n" +"\n" +"# The Driver line must be present. When using run-time loadable driver\n" +"# modules, this line instructs the server to load the specified driver\n" +"# module. Even when not using loadable driver modules, this line\n" +"# indicates which driver should interpret the information in this section.\n" +"\n" +" Driver \"vga\"\n" +"# The BusID line is used to specify which of possibly multiple devices\n" +"# this section is intended for. When this line isn't present, a device\n" +"# section can only match up with the primary video device. For PCI\n" +"# devices a line like the following could be used. This line should not\n" +"# normally be included unless there is more than one video device\n" +"# intalled.\n" +"\n" +"# BusID \"PCI:0:10:0\"\n" +"\n" +"# VideoRam 256\n" +"\n" +"# Clocks 25.2 28.3\n" +"\n" +"EndSection\n" +"\n" +"# Device configured by xorgconfig:\n" +"\n"; + +static char *screensection_text1 = +"# **********************************************************************\n" +"# Screen sections\n" +"# **********************************************************************\n" +"\n" +"# Any number of screen sections may be present. Each describes\n" +"# the configuration of a single screen. A single specific screen section\n" +"# may be specified from the X server command line with the \"-screen\"\n" +"# option.\n"; + +static char *serverlayout_section_text1 = +"# **********************************************************************\n" +"# ServerLayout sections.\n" +"# **********************************************************************\n" +"\n" +"# Any number of ServerLayout sections may be present. Each describes\n" +"# the way multiple screens are organised. A specific ServerLayout\n" +"# section may be specified from the X server command line with the\n" +"# \"-layout\" option. In the absence of this, the first section is used.\n" +"# When now ServerLayout section is present, the first Screen section\n" +"# is used alone.\n" +"\n" +"Section \"ServerLayout\"\n" +"\n" +"# The Identifier line must be present\n" +" Identifier \"Simple Layout\"\n" +"\n" +"# Each Screen line specifies a Screen section name, and optionally\n" +"# the relative position of other screens. The four names after\n" +"# primary screen name are the screens to the top, bottom, left and right\n" +"# of the primary screen. In this example, screen 2 is located to the\n" +"# right of screen 1.\n" +"\n"; + +static char *serverlayout_section_text2 = +"\n" +"# Each InputDevice line specifies an InputDevice section name and\n" +"# optionally some options to specify the way the device is to be\n" +"# used. Those options include \"CorePointer\", \"CoreKeyboard\" and\n" +"# \"SendCoreEvents\".\n" +"\n" +" InputDevice \"Mouse1\" \"CorePointer\"\n" +" InputDevice \"Keyboard1\" \"CoreKeyboard\"\n" +"\n" +"EndSection\n" +"\n" +"# Section \"DRI\"\n" +"# Mode 0666\n" +"# EndSection\n" +"\n"; + +static void +write_fontpath_section(FILE *f) +{ + /* this will create the Fontpath lines, but only after checking, + * that the corresponding dir exists (was THE absolute problem + * users had with XFree86/OS2 3.1.2D !) + */ + int i; + char cur[256+20],*colon, *hash; + +#ifdef COMPILEDDEFAULTFONTPATH + static const char dfp[] = COMPILEDDEFAULTFONTPATH; + const char *thisdir; + const char *nextdir; + int len; + + for (thisdir = dfp; thisdir != NULL; thisdir = nextdir) { + nextdir = strchr(thisdir, ','); + if (nextdir == NULL) { + len = strlen(thisdir); + } else { + len = nextdir - thisdir; + nextdir++; + } + if (len >= sizeof(cur)) + continue; + strncpy(cur, thisdir, len); + cur[len] = '\0'; + colon = strchr(cur+2,':'); /* OS/2: C:/...:scaled */ + if (colon) *colon = 0; + hash = exists_dir(cur) ? "" : "#"; + if (colon) *colon = ':'; + fprintf(f,"%s FontPath \"%s\"\n", hash, cur); + } +#endif + + for (i=0; XF86Config_fontpaths[i]; i++) { + strcpy(cur,TREEROOTFONT); + strcat(cur,XF86Config_fontpaths[i]); + /* remove a ':' */ + colon = strchr(cur+2,':'); /* OS/2: C:/...:scaled */ + if (colon) *colon = 0; +#ifdef COMPILEDDEFAULTFONTPATH + /* skip if we already added it as part of the default font path */ + if (strstr(dfp, cur) != NULL) + continue; +#endif + hash = exists_dir(cur) ? "" : "#"; + fprintf(f,"%s FontPath \"%s%s\"\n", + hash, + TREEROOTFONT, + XF86Config_fontpaths[i]); + } +} + +static int +write_XF86Config(char *filename) +{ + FILE *f; + + /* + * Write the file. + */ + + f = fopen(filename, "w"); + if (f == NULL) { + printf("Failed to open filename for writing.\n"); + if (getuid() != 0) + printf("Maybe you need to be root to write to the specified directory?\n"); + return(1); + } + + fprintf(f, "%s", XF86Config_firstchunk_text); + write_fontpath_section(f); + fprintf(f, "%s", XF86Config_fontpathchunk_text); + + /* + * Write keyboard section. + */ + if (config_altmeta) { + fprintf(f, " Option \"LeftAlt\" \"Meta\"\n"); + fprintf(f, " Option \"RightAlt\" \"ModeShift\"\n"); + } + else { + fprintf(f, "# Option \"LeftAlt\" \"Meta\"\n"); + fprintf(f, "# Option \"RightAlt\" \"ModeShift\"\n"); + } +#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) + /* wscons keyoards need a protocol line */ + fprintf(f, " Option \"Protocol\" \"wskbd\"\n"); + fprintf(f, " Option \"Device\" \"%s\"\n", config_keyboard_dev); + fprintf(f, " Option \"XkbKeycodes\" \"wscons(ppc)\"\n"); +#endif + fprintf(f, "%s", keyboardchunk2_text); + + fprintf(f, "%s", keyboardchunk3_text); + if (config_xkbdisable) { + fprintf(f, " Option \"XkbDisable\"\n\n"); + } else { + fprintf(f, "# Option \"XkbDisable\"\n\n"); + } + fprintf(f, " Option \"XkbRules\" \"%s\"\n", + config_xkbrules); + fprintf(f, " Option \"XkbModel\" \"%s\"\n", + config_xkbmodel); + fprintf(f, " Option \"XkbLayout\" \"%s\"\n", + config_xkblayout); + if (config_xkbvariant) + fprintf(f, " Option \"XkbVariant\" \"%s\"\n", + config_xkbvariant); + if (config_xkboptions) + fprintf(f, " Option \"XkbOptions\" \"%s\"\n", + config_xkboptions); + + fprintf(f, "%s",keyboardlastchunk_text); + + /* + * Write pointer section. + */ + fprintf(f, "%s", pointersection_text1); + fprintf(f, " Option \"Protocol\" \"%s\"\t# %s\n", + mouse_info[config_mousetype].name, + mouse_info[config_mousetype].desc); +#if !defined(QNX4) + fprintf(f, " Option \"Device\" \"%s\"\n", config_pointerdevice); +#endif + fprintf(f, "%s", pointersection_text2); + if (!config_emulate3buttons) + fprintf(f, "#"); + fprintf(f, " Option \"Emulate3Buttons\"\n"); + fprintf(f, "# Option \"Emulate3Timeout\" \"50\"\n\n"); + fprintf(f, "# ChordMiddle is an option for some 3-button Logitech mice\n\n"); + if (!config_chordmiddle) + fprintf(f, "#"); + fprintf(f, " Option \"ChordMiddle\"\n\n"); + if (config_cleardtrrts) { + fprintf(f, " Option \"ClearDTR\"\n"); + fprintf(f, " Option \"ClearRTS\"\n\n"); + } + fprintf(f, "EndSection\n\n\n"); + + /* + * Write XInput sample section + */ + fprintf(f, "%s", xinputsection_text); + + /* + * Write monitor section. + */ + fprintf(f, "%s", monitorsection_text1); + fprintf(f, " Identifier \"%s\"\n", config_monitoridentifier); + fprintf(f, "\n"); + fprintf(f, "%s", monitorsection_text2); + fprintf(f, " HorizSync %s\n", config_hsyncrange); + fprintf(f, "\n"); + fprintf(f, "%s", monitorsection_text3); + fprintf(f, " VertRefresh %s\n", config_vsyncrange); + fprintf(f, "\n"); +#if 0 + fprintf(f, "%s", monitorsection_text4); + fprintf(f, "%s", modelines_text); +#endif + fprintf(f, "EndSection\n\n\n"); + + /* + * Write Device section. + */ + + fprintf(f, "%s", devicesection_text); + fprintf(f, "Section \"Device\"\n"); + fprintf(f, " Identifier \"%s\"\n", config_deviceidentifier); + if (card_selected != -1) { + fprintf(f, " Driver \"%s\"\n", card[card_selected].driver); + if (card[card_selected].flags & UNSUPPORTED) { + fprintf(f, " # unsupported card\n"); + } + } else { + fprintf(f, " Driver \"vga\"\n" + " # unsupported card\n"); + } + /* Rely on server to detect video memory. */ + fprintf(f, " #VideoRam %d\n", config_videomemory); + if (card_selected != -1) + /* Add comment lines from card definition. */ + fprintf(f, card[card_selected].lines); + if (config_ramdac != NULL) + fprintf(f, " Ramdac \"%s\"\n", config_ramdac); + if (card_selected != -1) + if (card[card_selected].dacspeed != NULL) + fprintf(f, " Dacspeed %s\n", + card[card_selected].dacspeed); + if (config_clockchip != NULL) + fprintf(f, " Clockchip \"%s\"\n", config_clockchip); + else + if (config_numberofclockslines == 0) + fprintf(f, " # Insert Clocks lines here if appropriate\n"); + else { + int i; + for (i = 0; i < config_numberofclockslines; i++) + fprintf(f, " Clocks %s\n", config_clocksline[i]); + } + fprintf(f, "EndSection\n\n\n"); + + /* + * Write Screen sections. + */ + + fprintf(f, "%s", screensection_text1); + + fprintf(f, + "Section \"Screen\"\n" + " Identifier \"Screen 1\"\n" + " Device \"%s\"\n" + " Monitor \"%s\"\n" + " DefaultDepth %s\n" + "\n" + " Subsection \"Display\"\n" + " Depth 8\n" + " Modes %s\n" + " ViewPort 0 0\n", + config_deviceidentifier, + config_monitoridentifier, + config_depth, + config_modesline8bpp); + if (config_virtual) + fprintf(f, " Virtual %d %d\n", + config_virtualx8bpp, config_virtualy8bpp); + fprintf(f, + " EndSubsection\n" + " Subsection \"Display\"\n" + " Depth 16\n" + " Modes %s\n" + " ViewPort 0 0\n", + config_modesline16bpp); + if (config_virtual) + fprintf(f, " Virtual %d %d\n", + config_virtualx16bpp, config_virtualy16bpp); + fprintf(f, + " EndSubsection\n" + " Subsection \"Display\"\n" + " Depth 24\n" + " Modes %s\n" + " ViewPort 0 0\n", + config_modesline24bpp); + if (config_virtual) + fprintf(f, " Virtual %d %d\n", + config_virtualx24bpp, config_virtualy24bpp); + fprintf(f, + " EndSubsection\n" + "EndSection\n" + "\n"); + + /* + * ServerLayout section + */ + + fprintf(f, serverlayout_section_text1); + /* replace with screen config */ + fprintf(f, " Screen \"Screen 1\"\n"); + + fprintf(f, serverlayout_section_text2); + + fclose(f); + return(0); +} + +static char * +append_version(char *name) +{ +#ifdef APPEND_VERSION_TO_CONFIG_NAME + char *ret = NULL; + + if (XF86_VERSION_MAJOR > 9 || XF86_VERSION_MAJOR < 0) + return name; + + ret = Malloc(strlen(name) + 2 + 1); + sprintf(ret, "%s-%d", name, XF86_VERSION_MAJOR); + free(name); + return ret; +#else + return name; +#endif +} + +/* + * Ask where to write XF86Config to. Returns filename. + */ + +static char * +ask_XF86Config_location(void) { + char s[80]; + char *filename = NULL; + + printf( +"I am going to write the " CONFIGNAME " file now. Make sure you don't accidently\n" +"overwrite a previously configured one.\n\n"); + + if (getuid() == 0) { +#ifdef PREFER_XF86CONFIG_IN_ETC + filename = Strdup("/etc/X11/" XCONFIGFILE); + filename = append_version(filename); + printf("Shall I write it to %s? ", filename); + getstring(s); + printf("\n"); + if (answerisyes(s)) + return filename; +#endif + + if (filename) + free(filename); + filename = Strdup(TREEROOTCFG "/" XCONFIGFILE); + filename = append_version(filename); + printf("Please answer the following question with either 'y' or 'n'.\n"); + printf("Shall I write it to the default location, %s? ", filename); + getstring(s); + printf("\n"); + if (answerisyes(s)) + return filename; + +#ifndef PREFER_XF86CONFIG_IN_ETC + if (filename) + free(filename); + filename = Strdup("/etc/X11/" XCONFIGFILE); + filename = append_version(filename); + printf("Shall I write it to %s? ", filename); + getstring(s); + printf("\n"); + if (answerisyes(s)) + return filename; +#endif + } + + if (filename) + free(filename); + filename = Strdup(XCONFIGFILE); + filename = append_version(filename); + printf("Do you want it written to the current directory as '%s'? ", filename); + getstring(s); + printf("\n"); + if (answerisyes(s)) { + return filename; + } + + printf("Please give a filename to write to: "); + getstring(s); + printf("\n"); + if (filename) + free(filename); + filename = Strdup(s); + return filename; +} + + +/* + * Check if an earlier version of XFree86 is installed; warn about proper + * search path order in that case. + */ + +static char *notinstalled_text = +"The directory " TREEROOT " does not exist. This probably means that you have\n" +"not yet installed the version of "__XSERVERNAME__" that this program was built\n" +"to configure. Please install "__XSERVERNAME__" "XVERSIONSTRING" before running this program,\n" +"following the instructions in the INSTALL or README that comes with the\n" +__XSERVERNAME__" distribution for your OS.\n" +"For a minimal installation it is sufficient to only install base binaries,\n" +"libraries, configuration files and a server that you want to use.\n" +"\n"; + +static char *oldxfree86_text = +"The directory '/usr/X386/bin' exists. You probably have a very old version of\n" +"XFree86 installed, but this program was built to configure "__XSERVERNAME__" "XVERSIONSTRING"\n" +"installed in '" TREEROOT "' instead of '/usr/X386'.\n" +"\n" +"It is important that the directory '" TREEROOT "' is present in your\n" +"search path, *before* any occurrence of '/usr/X386/bin'. If you have installed\n" +"X program binaries that are not in the base "__XSERVERNAME__" distribution in\n" +"'/usr/X386/bin', you can keep the directory in your path as long as it is\n" +"after '" TREEROOT "'.\n" +"\n"; + +static char *pathnote_text = +"Note that the X binary directory in your path may be a symbolic link.\n" +"In that case you could modify the symbolic link to point to the new binaries.\n" +"Example: 'rm -f /usr/bin/X11; ln -s /usr/X11R6/bin /usr/bin/X11', if the\n" +"link is '/usr/bin/X11'.\n" +"\n" +"Make sure the path is OK before continuing.\n"; + +static void +path_check(void) { + char s[80]; + int ok; + + ok = exists_dir(TREEROOT); + if (!ok) { + printf("%s", notinstalled_text); + printf("Do you want to continue? "); + getstring(s); + if (!answerisyes(s)) + exit(-1); + printf("\n"); + } + + ok = exists_dir("/usr/X386/bin"); + if (!ok) + return; + + printf("%s", oldxfree86_text); + printf("Your PATH is currently set as follows:\n%s\n\n", + getenv("PATH")); + printf("%s", pathnote_text); + keypress(); +} + + +static void +configdir_check(void) +{ + /* /etc/X11 may not exist on some systems */ + if (getuid() == 0) { + struct stat buf; + if (stat("/etc/X11", &buf) == -1 && errno == ENOENT) + mkdir("/etc/X11", 0777); + if (stat(TREEROOTCFG, &buf) == -1 && errno == ENOENT) + mkdir(TREEROOTCFG, 0777); + } +} + + +/* + * Program entry point. + */ + +int +main(int argc, char *argv[]) { + + createtmpdir(); + + emptylines(); + + printf("%s", intro_text); + + keypress(); + emptylines(); + + path_check(); + + emptylines(); + + configdir_check(); + + emptylines(); + + mouse_configuration(); + + emptylines(); + + keyboard_configuration(); + + emptylines(); + + monitor_configuration(); + + emptylines(); + + carddb_configuration(); + + emptylines(); + + while(screen_configuration()){}; + + emptylines(); + + depth_configuration(); + + emptylines(); + + while(write_XF86Config(ask_XF86Config_location())){}; + + printf("%s", finalcomment_text); + + exit(0); +} diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.man.pre b/xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.man.pre new file mode 100644 index 000000000..b3d656cfa --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/xorgconfig.man.pre @@ -0,0 +1,22 @@ +.\" $XdotOrg: $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xorgconfig.man,v 1.5 2001/11/01 23:35:34 dawes Exp $ +.TH xorgconfig 1 __vendorversion__ +.SH NAME +xorgconfig \- generate an __XCONFIGFILE__ file +.SH SYNOPSIS +.B xorgconfig +.SH DESCRIPTION +\fIxorgconfig\fP is an interactive program for generating an __XCONFIGFILE__ file +for use with __XSERVERNAME__ X servers. +.PP +Note that the default name used by \fIxorgconfig\fP for the __XCONFIGFILE__ file +is system-dependent. For instance, on OS/2, XConfig is used. +.SH FILES +.TP +.I __projectroot__/lib/X11/Cards +Video cards database +.SH "SEE ALSO" +__XSERVERNAME__(1), __XCONFIGFILE__(__filemansuffix__), xorgcfg(1), reconfig(1) +.SH AUTHOR +Harm Hanemaayer. +.\" $TOG: xf86conf.man /main/9 1997/07/19 10:53:08 kaleb $ diff --git a/xorg-server/hw/xfree86/vbe/Makefile.am b/xorg-server/hw/xfree86/vbe/Makefile.am new file mode 100644 index 000000000..85c6fd82a --- /dev/null +++ b/xorg-server/hw/xfree86/vbe/Makefile.am @@ -0,0 +1,10 @@ +module_LTLIBRARIES = libvbe.la +libvbe_la_LDFLAGS = -avoid-version +libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c + +sdk_HEADERS = vbe.h vbeModes.h + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../int10 diff --git a/xorg-server/hw/xfree86/vbe/Makefile.in b/xorg-server/hw/xfree86/vbe/Makefile.in new file mode 100644 index 000000000..111ce5a46 --- /dev/null +++ b/xorg-server/hw/xfree86/vbe/Makefile.in @@ -0,0 +1,704 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/vbe +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libvbe_la_LIBADD = +am_libvbe_la_OBJECTS = vbe.lo vbeModes.lo vbe_module.lo +libvbe_la_OBJECTS = $(am_libvbe_la_OBJECTS) +libvbe_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libvbe_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libvbe_la_SOURCES) +DIST_SOURCES = $(libvbe_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libvbe.la +libvbe_la_LDFLAGS = -avoid-version +libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c +sdk_HEADERS = vbe.h vbeModes.h +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../int10 + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/vbe/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/vbe/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libvbe.la: $(libvbe_la_OBJECTS) $(libvbe_la_DEPENDENCIES) + $(libvbe_la_LINK) -rpath $(moduledir) $(libvbe_la_OBJECTS) $(libvbe_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vbe.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vbeModes.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vbe_module.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c new file mode 100644 index 000000000..8af1727cc --- /dev/null +++ b/xorg-server/hw/xfree86/vbe/vbe.c @@ -0,0 +1,1146 @@ + +/* + * XFree86 vbe module + * Copyright 2000 Egbert Eich + * + * The mode query/save/set/restore functions from the vesa driver + * have been moved here. + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "xf86.h" +#include "vbe.h" +#include <X11/Xarch.h> +#define DPMS_SERVER +#include <X11/extensions/dpms.h> + +#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x) + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN +#define B_O16(x) (x) +#define B_O32(x) (x) +#else +#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8)) +#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \ + | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) +#endif +#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00) + +#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff)) +#define R16(v) ((v) & 0xffff) + +static unsigned char * vbeReadEDID(vbeInfoPtr pVbe); +static Bool vbeProbeDDC(vbeInfoPtr pVbe); + +static const char vbeVersionString[] = "VBE2"; + +vbeInfoPtr +VBEInit(xf86Int10InfoPtr pInt, int entityIndex) +{ + return VBEExtendedInit(pInt, entityIndex, 0); +} + +vbeInfoPtr +VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags) +{ + int RealOff; + pointer page = NULL; + ScrnInfoPtr pScrn = xf86FindScreenForEntity(entityIndex); + vbeControllerInfoPtr vbe = NULL; + Bool init_int10 = FALSE; + vbeInfoPtr vip = NULL; + int screen; + + if (!pScrn) return NULL; + screen = pScrn->scrnIndex; + + if (!pInt) { + if (!xf86LoadSubModule(pScrn, "int10")) + goto error; + + xf86DrvMsg(screen,X_INFO,"initializing int10\n"); + pInt = xf86ExtendedInitInt10(entityIndex,Flags); + if (!pInt) + goto error; + init_int10 = TRUE; + } + + page = xf86Int10AllocPages(pInt,1,&RealOff); + if (!page) goto error; + vbe = (vbeControllerInfoPtr) page; + memcpy(vbe->VbeSignature,vbeVersionString,4); + + pInt->ax = 0x4F00; + pInt->es = SEG_ADDR(RealOff); + pInt->di = SEG_OFF(RealOff); + pInt->num = 0x10; + + xf86ExecX86int10(pInt); + + if ((pInt->ax & 0xff) != 0x4f) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA BIOS not detected\n"); + goto error; + } + + switch (pInt->ax & 0xff00) { + case 0: + xf86DrvMsg(screen,X_INFO,"VESA BIOS detected\n"); + break; + case 0x100: + xf86DrvMsg(screen,X_INFO,"VESA BIOS function failed\n"); + goto error; + case 0x200: + xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported\n"); + goto error; + case 0x300: + xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported in current mode\n"); + goto error; + default: + xf86DrvMsg(screen,X_INFO,"Invalid\n"); + goto error; + } + + xf86DrvMsgVerb(screen, X_INFO, 4, + "VbeVersion is %d, OemStringPtr is 0x%08lx,\n" + "\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n" + "\tOemProductRevPtr is 0x%08lx\n", + vbe->VbeVersion, (unsigned long)vbe->OemStringPtr, + (unsigned long)vbe->OemVendorNamePtr, + (unsigned long)vbe->OemProductNamePtr, + (unsigned long)vbe->OemProductRevPtr); + + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Version %i.%i\n", + VERSION(vbe->VbeVersion)); + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Total Mem: %i kB\n", + vbe->TotalMem * 64); + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM: %s\n", + (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemStringPtr))); + + if (B_O16(vbe->VbeVersion) >= 0x200) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Software Rev: %i.%i\n", + VERSION(vbe->OemSoftwareRev)); + if (vbe->OemVendorNamePtr) + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Vendor: %s\n", + (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemVendorNamePtr))); + if (vbe->OemProductNamePtr) + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product: %s\n", + (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductNamePtr))); + if (vbe->OemProductRevPtr) + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product Rev: %s\n", + (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductRevPtr))); + } + vip = (vbeInfoPtr)xnfalloc(sizeof(vbeInfoRec)); + vip->version = B_O16(vbe->VbeVersion); + vip->pInt10 = pInt; + vip->ddc = DDC_UNCHECKED; + vip->memory = page; + vip->real_mode_base = RealOff; + vip->num_pages = 1; + vip->init_int10 = init_int10; + + return vip; + + error: + if (page) + xf86Int10FreePages(pInt, page, 1); + if (init_int10) + xf86FreeInt10(pInt); + return NULL; +} + +void +vbeFree(vbeInfoPtr pVbe) +{ + if (!pVbe) + return; + + xf86Int10FreePages(pVbe->pInt10,pVbe->memory,pVbe->num_pages); + /* If we have initalized int10 we ought to free it, too */ + if (pVbe->init_int10) + xf86FreeInt10(pVbe->pInt10); + xfree(pVbe); + return; +} + +static Bool +vbeProbeDDC(vbeInfoPtr pVbe) +{ + char *ddc_level; + int screen = pVbe->pInt10->scrnIndex; + + if (pVbe->ddc == DDC_NONE) + return FALSE; + if (pVbe->ddc != DDC_UNCHECKED) + return TRUE; + + pVbe->pInt10->ax = 0x4F15; + pVbe->pInt10->bx = 0; + pVbe->pInt10->cx = 0; + pVbe->pInt10->es = 0; + pVbe->pInt10->di = 0; + pVbe->pInt10->num = 0x10; + + xf86ExecX86int10(pVbe->pInt10); + + if ((pVbe->pInt10->ax & 0xff) != 0x4f) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC not supported\n"); + pVbe->ddc = DDC_NONE; + return FALSE; + } + + switch ((pVbe->pInt10->ax >> 8) & 0xff) { + case 0: + xf86DrvMsg(screen,X_INFO,"VESA VBE DDC supported\n"); + switch (pVbe->pInt10->bx & 0x3) { + case 0: + ddc_level = " none"; + pVbe->ddc = DDC_NONE; + break; + case 1: + ddc_level = " 1"; + pVbe->ddc = DDC_1; + break; + case 2: + ddc_level = " 2"; + pVbe->ddc = DDC_2; + break; + case 3: + ddc_level = " 1 + 2"; + pVbe->ddc = DDC_1_2; + break; + default: + ddc_level = ""; + pVbe->ddc = DDC_NONE; + break; + } + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Level%s\n",ddc_level); + if (pVbe->pInt10->bx & 0x4) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Screen blanked" + "for data transfer\n"); + pVbe->ddc_blank = TRUE; + } else + pVbe->ddc_blank = FALSE; + + xf86DrvMsgVerb(screen,X_INFO,3, + "VESA VBE DDC transfer in appr. %x sec.\n", + (pVbe->pInt10->bx >> 8) & 0xff); + } + + return TRUE; +} + +typedef enum { + VBEOPT_NOVBE, + VBEOPT_NODDC +} VBEOpts; + +static const OptionInfoRec VBEOptions[] = { + { VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE }, + { VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE }, +}; + +static unsigned char * +vbeReadEDID(vbeInfoPtr pVbe) +{ + int RealOff = pVbe->real_mode_base; + pointer page = pVbe->memory; + unsigned char *tmp = NULL; + Bool novbe = FALSE; + Bool noddc = FALSE; + int screen = pVbe->pInt10->scrnIndex; + OptionInfoPtr options; + + if (!page) return NULL; + + options = xnfalloc(sizeof(VBEOptions)); + (void)memcpy(options, VBEOptions, sizeof(VBEOptions)); + xf86ProcessOptions(screen, xf86Screens[screen]->options, options); + xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe); + xf86GetOptValBool(options, VBEOPT_NODDC, &noddc); + xfree(options); + if (novbe || noddc) return NULL; + + if (!vbeProbeDDC(pVbe)) goto error; + + memset(page,0,sizeof(vbeInfoPtr)); + strcpy(page,vbeVersionString); + + pVbe->pInt10->ax = 0x4F15; + pVbe->pInt10->bx = 0x01; + pVbe->pInt10->cx = 0; + pVbe->pInt10->dx = 0; + pVbe->pInt10->es = SEG_ADDR(RealOff); + pVbe->pInt10->di = SEG_OFF(RealOff); + pVbe->pInt10->num = 0x10; + + xf86ExecX86int10(pVbe->pInt10); + + if ((pVbe->pInt10->ax & 0xff) != 0x4f) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC invalid\n"); + goto error; + } + switch (pVbe->pInt10->ax & 0xff00) { + case 0x0: + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read successfully\n"); + tmp = (unsigned char *)xnfalloc(128); + memcpy(tmp,page,128); + break; + case 0x100: + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read failed\n"); + break; + default: + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC unkown failure %i\n", + pVbe->pInt10->ax & 0xff00); + break; + } + + error: + return tmp; +} + +xf86MonPtr +vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule) +{ + xf86MonPtr pMonitor; + pointer pModule; + unsigned char *DDC_data = NULL; + + if (!pVbe) return NULL; + if (pVbe->version < 0x200) + return NULL; + + if (!(pModule = pDDCModule)) { + pModule = + xf86LoadSubModule(xf86Screens[pVbe->pInt10->scrnIndex], "ddc"); + if (!pModule) + return NULL; + } + + DDC_data = vbeReadEDID(pVbe); + + if (!DDC_data) + return NULL; + + pMonitor = xf86InterpretEDID(pVbe->pInt10->scrnIndex, DDC_data); + + if (!pDDCModule) + xf86UnloadSubModule(pModule); + return pMonitor; +} + +#define GET_UNALIGNED2(x) \ + ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16) + +VbeInfoBlock * +VBEGetVBEInfo(vbeInfoPtr pVbe) +{ + VbeInfoBlock *block = NULL; + int i, pStr, pModes; + char *str; + CARD16 major, *modes; + + bzero(pVbe->memory, sizeof(VbeInfoBlock)); + + /* + Input: + AH := 4Fh Super VGA support + AL := 00h Return Super VGA information + ES:DI := Pointer to buffer + + Output: + AX := status + (All other registers are preserved) + */ + + ((char*)pVbe->memory)[0] = 'V'; + ((char*)pVbe->memory)[1] = 'B'; + ((char*)pVbe->memory)[2] = 'E'; + ((char*)pVbe->memory)[3] = '2'; + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f00; + pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); + pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (NULL); + + block = xcalloc(sizeof(VbeInfoBlock), 1); + block->VESASignature[0] = ((char*)pVbe->memory)[0]; + block->VESASignature[1] = ((char*)pVbe->memory)[1]; + block->VESASignature[2] = ((char*)pVbe->memory)[2]; + block->VESASignature[3] = ((char*)pVbe->memory)[3]; + + block->VESAVersion = *(CARD16*)(((char*)pVbe->memory) + 4); + major = (unsigned)block->VESAVersion >> 8; + + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 6)); + str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); + block->OEMStringPtr = strdup(str); + + block->Capabilities[0] = ((char*)pVbe->memory)[10]; + block->Capabilities[1] = ((char*)pVbe->memory)[11]; + block->Capabilities[2] = ((char*)pVbe->memory)[12]; + block->Capabilities[3] = ((char*)pVbe->memory)[13]; + + pModes = GET_UNALIGNED2((((char*)pVbe->memory) + 14)); + modes = xf86int10Addr(pVbe->pInt10, FARP(pModes)); + i = 0; + while (modes[i] != 0xffff) + i++; + block->VideoModePtr = xalloc(sizeof(CARD16) * i + 1); + memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i); + block->VideoModePtr[i] = 0xffff; + + block->TotalMemory = *(CARD16*)(((char*)pVbe->memory) + 18); + + if (major < 2) + memcpy(&block->OemSoftwareRev, ((char*)pVbe->memory) + 20, 236); + else { + block->OemSoftwareRev = *(CARD16*)(((char*)pVbe->memory) + 20); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 22)); + str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); + block->OemVendorNamePtr = strdup(str); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 26)); + str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); + block->OemProductNamePtr = strdup(str); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 30)); + str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); + block->OemProductRevPtr = strdup(str); + memcpy(&block->Reserved, ((char*)pVbe->memory) + 34, 222); + memcpy(&block->OemData, ((char*)pVbe->memory) + 256, 256); + } + + return (block); +} + +void +VBEFreeVBEInfo(VbeInfoBlock *block) +{ + xfree(block->OEMStringPtr); + xfree(block->VideoModePtr); + if (((unsigned)block->VESAVersion >> 8) >= 2) { + xfree(block->OemVendorNamePtr); + xfree(block->OemProductNamePtr); + xfree(block->OemProductRevPtr); + } + xfree(block); +} + +Bool +VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *block) +{ + /* + Input: + AH := 4Fh Super VGA support + AL := 02h Set Super VGA video mode + BX := Video mode + D0-D8 := Mode number + D9-D10 := Reserved (must be 0) + D11 := 0 Use current default refresh rate + := 1 Use user specified CRTC values for refresh rate + D12-13 Reserved for VBE/AF (must be 0) + D14 := 0 Use windowed frame buffer model + := 1 Use linear/flat frame buffer model + D15 := 0 Clear video memory + := 1 Don't clear video memory + ES:DI := Pointer to VbeCRTCInfoBlock structure + + Output: AX = Status + (All other registers are preserved) + */ + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f02; + pVbe->pInt10->bx = mode; + if (block) { + pVbe->pInt10->bx |= 1 << 11; + memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock)); + pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); + pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); + } else + pVbe->pInt10->bx &= ~(1 << 11); + + xf86ExecX86int10(pVbe->pInt10); + + return (R16(pVbe->pInt10->ax) == 0x4f); +} + +Bool +VBEGetVBEMode(vbeInfoPtr pVbe, int *mode) +{ + /* + Input: + AH := 4Fh Super VGA support + AL := 03h Return current video mode + + Output: + AX := Status + BX := Current video mode + (All other registers are preserved) + */ + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f03; + + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) == 0x4f) { + *mode = R16(pVbe->pInt10->bx); + + return (TRUE); + } + + return (FALSE); +} + +VbeModeInfoBlock * +VBEGetModeInfo(vbeInfoPtr pVbe, int mode) +{ + VbeModeInfoBlock *block = NULL; + + bzero(pVbe->memory, sizeof(VbeModeInfoBlock)); + + /* + Input: + AH := 4Fh Super VGA support + AL := 01h Return Super VGA mode information + CX := Super VGA video mode + (mode number must be one of those returned by Function 0) + ES:DI := Pointer to buffer + + Output: + AX := status + (All other registers are preserved) + */ + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f01; + pVbe->pInt10->cx = mode; + pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); + pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); + xf86ExecX86int10(pVbe->pInt10); + if (R16(pVbe->pInt10->ax) != 0x4f) + return (NULL); + + block = xcalloc(sizeof(VbeModeInfoBlock), 1); + + block->ModeAttributes = *(CARD16*)pVbe->memory; + block->WinAAttributes = ((char*)pVbe->memory)[2]; + block->WinBAttributes = ((char*)pVbe->memory)[3]; + block->WinGranularity = *(CARD16*)(((char*)pVbe->memory) + 4); + block->WinSize = *(CARD16*)(((char*)pVbe->memory) + 6); + block->WinASegment = *(CARD16*)(((char*)pVbe->memory) + 8); + block->WinBSegment = *(CARD16*)(((char*)pVbe->memory) + 10); + block->WinFuncPtr = *(CARD32*)(((char*)pVbe->memory) + 12); + block->BytesPerScanline = *(CARD16*)(((char*)pVbe->memory) + 16); + + /* mandatory information for VBE 1.2 and above */ + block->XResolution = *(CARD16*)(((char*)pVbe->memory) + 18); + block->YResolution = *(CARD16*)(((char*)pVbe->memory) + 20); + block->XCharSize = ((char*)pVbe->memory)[22]; + block->YCharSize = ((char*)pVbe->memory)[23]; + block->NumberOfPlanes = ((char*)pVbe->memory)[24]; + block->BitsPerPixel = ((char*)pVbe->memory)[25]; + block->NumberOfBanks = ((char*)pVbe->memory)[26]; + block->MemoryModel = ((char*)pVbe->memory)[27]; + block->BankSize = ((char*)pVbe->memory)[28]; + block->NumberOfImages = ((char*)pVbe->memory)[29]; + block->Reserved = ((char*)pVbe->memory)[30]; + + /* Direct color fields (required for direct/6 and YUV/7 memory models) */ + block->RedMaskSize = ((char*)pVbe->memory)[31]; + block->RedFieldPosition = ((char*)pVbe->memory)[32]; + block->GreenMaskSize = ((char*)pVbe->memory)[33]; + block->GreenFieldPosition = ((char*)pVbe->memory)[34]; + block->BlueMaskSize = ((char*)pVbe->memory)[35]; + block->BlueFieldPosition = ((char*)pVbe->memory)[36]; + block->RsvdMaskSize = ((char*)pVbe->memory)[37]; + block->RsvdFieldPosition = ((char*)pVbe->memory)[38]; + block->DirectColorModeInfo = ((char*)pVbe->memory)[39]; + + /* Mandatory information for VBE 2.0 and above */ + if (pVbe->version >= 0x200) { + block->PhysBasePtr = *(CARD32*)(((char*)pVbe->memory) + 40); + block->Reserved32 = *(CARD32*)(((char*)pVbe->memory) + 44); + block->Reserved16 = *(CARD16*)(((char*)pVbe->memory) + 48); + + /* Mandatory information for VBE 3.0 and above */ + if (pVbe->version >= 0x300) { + block->LinBytesPerScanLine = *(CARD16*)(((char*)pVbe->memory) + 50); + block->BnkNumberOfImagePages = ((char*)pVbe->memory)[52]; + block->LinNumberOfImagePages = ((char*)pVbe->memory)[53]; + block->LinRedMaskSize = ((char*)pVbe->memory)[54]; + block->LinRedFieldPosition = ((char*)pVbe->memory)[55]; + block->LinGreenMaskSize = ((char*)pVbe->memory)[56]; + block->LinGreenFieldPosition = ((char*)pVbe->memory)[57]; + block->LinBlueMaskSize = ((char*)pVbe->memory)[58]; + block->LinBlueFieldPosition = ((char*)pVbe->memory)[59]; + block->LinRsvdMaskSize = ((char*)pVbe->memory)[60]; + block->LinRsvdFieldPosition = ((char*)pVbe->memory)[61]; + block->MaxPixelClock = *(CARD32*)(((char*)pVbe->memory) + 62); + memcpy(&block->Reserved2, ((char*)pVbe->memory) + 66, 188); + } + else + memcpy(&block->LinBytesPerScanLine, ((char*)pVbe->memory) + 50, 206); + } + else + memcpy(&block->PhysBasePtr, ((char*)pVbe->memory) + 40, 216); + + return (block); +} + +void +VBEFreeModeInfo(VbeModeInfoBlock *block) +{ + xfree(block); +} + +Bool +VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function, + pointer *memory, int *size, int *real_mode_pages) +{ + /* + Input: + AH := 4Fh Super VGA support + AL := 04h Save/restore Super VGA video state + DL := 00h Return save/restore state buffer size + CX := Requested states + D0 = Save/restore video hardware state + D1 = Save/restore video BIOS data state + D2 = Save/restore video DAC state + D3 = Save/restore Super VGA state + + Output: + AX = Status + BX = Number of 64-byte blocks to hold the state buffer + (All other registers are preserved) + + + Input: + AH := 4Fh Super VGA support + AL := 04h Save/restore Super VGA video state + DL := 01h Save Super VGA video state + CX := Requested states (see above) + ES:BX := Pointer to buffer + + Output: + AX := Status + (All other registers are preserved) + + + Input: + AH := 4Fh Super VGA support + AL := 04h Save/restore Super VGA video state + DL := 02h Restore Super VGA video state + CX := Requested states (see above) + ES:BX := Pointer to buffer + + Output: + AX := Status + (All other registers are preserved) + */ + + if ((pVbe->version & 0xff00) > 0x100) { + int screen = pVbe->pInt10->scrnIndex; + if (function == MODE_QUERY || + (function == MODE_SAVE && !*memory)) { + /* Query amount of memory to save state */ + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f04; + pVbe->pInt10->dx = 0; + pVbe->pInt10->cx = 0x000f; + xf86ExecX86int10(pVbe->pInt10); + if (R16(pVbe->pInt10->ax) != 0x4f) + return (FALSE); + + if (function == MODE_SAVE) { + int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1; + if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages, + real_mode_pages)) == NULL) { + xf86DrvMsg(screen, X_ERROR, + "Cannot allocate memory to save SVGA state.\n"); + return (FALSE); + } + } + *size = pVbe->pInt10->bx * 64; + } + + /* Save/Restore Super VGA state */ + if (function != MODE_QUERY) { + + if (!*memory) return FALSE; + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f04; + switch (function) { + case MODE_SAVE: + pVbe->pInt10->dx = 1; + break; + case MODE_RESTORE: + pVbe->pInt10->dx = 2; + break; + case MODE_QUERY: + return FALSE; + } + pVbe->pInt10->cx = 0x000f; + + pVbe->pInt10->es = SEG_ADDR(*real_mode_pages); + pVbe->pInt10->bx = SEG_OFF(*real_mode_pages); + xf86ExecX86int10(pVbe->pInt10); + return (R16(pVbe->pInt10->ax) == 0x4f); + + } + } + return TRUE; +} + +Bool +VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window) +{ + /* + Input: + AH := 4Fh Super VGA support + AL := 05h + + Output: + */ + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f05; + pVbe->pInt10->bx = window; + pVbe->pInt10->dx = iBank; + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (FALSE); + + return (TRUE); +} + +Bool +VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command, + int width, int *pixels, int *bytes, int *max) +{ + if (command < SCANWID_SET || command > SCANWID_GET_MAX) + return (FALSE); + + /* + Input: + AX := 4F06h VBE Set/Get Logical Scan Line Length + BL := 00h Set Scan Line Length in Pixels + := 01h Get Scan Line Length + := 02h Set Scan Line Length in Bytes + := 03h Get Maximum Scan Line Length + CX := If BL=00h Desired Width in Pixels + If BL=02h Desired Width in Bytes + (Ignored for Get Functions) + + Output: + AX := VBE Return Status + BX := Bytes Per Scan Line + CX := Actual Pixels Per Scan Line + (truncated to nearest complete pixel) + DX := Maximum Number of Scan Lines + */ + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f06; + pVbe->pInt10->bx = command; + if (command == SCANWID_SET || command == SCANWID_SET_BYTES) + pVbe->pInt10->cx = width; + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (FALSE); + + if (command == SCANWID_GET || command == SCANWID_GET_MAX) { + if (pixels) + *pixels = R16(pVbe->pInt10->cx); + if (bytes) + *bytes = R16(pVbe->pInt10->bx); + if (max) + *max = R16(pVbe->pInt10->dx); + } + + return (TRUE); +} + +Bool +VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace) +{ + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f07; + pVbe->pInt10->bx = wait_retrace ? 0x80 : 0x00; + pVbe->pInt10->cx = x; + pVbe->pInt10->dx = y; + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (FALSE); + + return (TRUE); +} + +Bool +VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y) +{ + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f07; + pVbe->pInt10->bx = 0x01; + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (FALSE); + + *x = pVbe->pInt10->cx; + *y = pVbe->pInt10->dx; + + return (TRUE); +} + +int +VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits) +{ + /* + Input: + AX := 4F08h VBE Set/Get Palette Format + BL := 00h Set DAC Palette Format + := 01h Get DAC Palette Format + BH := Desired bits of color per primary + (Set DAC Palette Format only) + + Output: + AX := VBE Return Status + BH := Current number of bits of color per primary + */ + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f08; + if (!bits) + pVbe->pInt10->bx = 0x01; + else + pVbe->pInt10->bx = (bits & 0x00ff) << 8; + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (0); + + return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff); +} + +CARD32 * +VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num, + CARD32 *data, Bool secondary, Bool wait_retrace) +{ + /* + Input: + (16-bit) + AX := 4F09h VBE Load/Unload Palette Data + BL := 00h Set Palette Data + := 01h Get Palette Data + := 02h Set Secondary Palette Data + := 03h Get Secondary Palette Data + := 80h Set Palette Data during Vertical Retrace + CX := Number of palette registers to update (to a maximum of 256) + DX := First of the palette registers to update (start) + ES:DI := Table of palette values (see below for format) + + Output: + AX := VBE Return Status + + + Input: + (32-bit) + BL := 00h Set Palette Data + := 80h Set Palette Data during Vertical Retrace + CX := Number of palette registers to update (to a maximum of 256) + DX := First of the palette registers to update (start) + ES:EDI := Table of palette values (see below for format) + DS := Selector for memory mapped registers + */ + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f09; + if (!secondary) + pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1; + else + pVbe->pInt10->bx = set ? 2 : 3; + pVbe->pInt10->cx = num; + pVbe->pInt10->dx = first; + pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); + pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); + if (set) + memcpy(pVbe->memory, data, num * sizeof(CARD32)); + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (NULL); + + if (set) + return (data); + + data = xalloc(num * sizeof(CARD32)); + memcpy(data, pVbe->memory, num * sizeof(CARD32)); + + return (data); +} + +VBEpmi * +VBEGetVBEpmi(vbeInfoPtr pVbe) +{ + VBEpmi *pmi; + + /* + Input: + AH := 4Fh Super VGA support + AL := 0Ah Protected Mode Interface + BL := 00h Return Protected Mode Table + + Output: + AX := Status + ES := Real Mode Segment of Table + DI := Offset of Table + CX := Lenght of Table including protected mode code in bytes (for copying purposes) + (All other registers are preserved) + */ + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f0a; + pVbe->pInt10->bx = 0; + pVbe->pInt10->di = 0; + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (NULL); + + pmi = xalloc(sizeof(VBEpmi)); + pmi->seg_tbl = R16(pVbe->pInt10->es); + pmi->tbl_off = R16(pVbe->pInt10->di); + pmi->tbl_len = R16(pVbe->pInt10->cx); + + return (pmi); +} + +#if 0 +vbeModeInfoPtr +VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock *vbe) +{ + vbeModeInfoPtr ModeList = NULL; + + int i = 0; + while (vbe->VideoModePtr[i] != 0xffff) { + vbeModeInfoPtr m; + VbeModeInfoBlock *mode; + int id = vbe->VideoModePtr[i++]; + int bpp; + + if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) + continue; + + bpp = mode->BitsPerPixel; + + m = xnfcalloc(sizeof(vbeModeInfoRec),1); + m->width = mode->XResolution; + m->height = mode->YResolution; + m->bpp = bpp; + m->n = id; + m->next = ModeList; + + xf86DrvMsgVerb(pVbe->pInt10->scrnIndex, X_PROBED, 3, + "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n", + m->n, m->width, m->height, m->bpp); + + ModeList = m; + + VBEFreeModeInfo(mode); + } + return ModeList; +} + +unsigned short +VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp) +{ + while (m) { + if (bpp == m->bpp + && mode->HDisplay == m->width + && mode->VDisplay == m->height) + return m->n; + m = m->next; + } + return 0; +} +#endif + +void +VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr, + vbeSaveRestoreFunction function) +{ + Bool SaveSucc = FALSE; + + if (VBE_VERSION_MAJOR(pVbe->version) > 1 + && (function == MODE_SAVE || vbe_sr->pstate)) { + if (function == MODE_RESTORE) + memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize); + ErrorF("VBESaveRestore\n"); + if ((VBESaveRestore(pVbe,function, + (pointer)&vbe_sr->state, + &vbe_sr->stateSize,&vbe_sr->statePage))) { + if (function == MODE_SAVE) { + SaveSucc = TRUE; + vbe_sr->stateMode = -1; /* invalidate */ + /* don't rely on the memory not being touched */ + if (vbe_sr->pstate == NULL) + vbe_sr->pstate = xalloc(vbe_sr->stateSize); + memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize); + } + ErrorF("VBESaveRestore done with success\n"); + return; + } + ErrorF("VBESaveRestore done\n"); + } + + if (function == MODE_SAVE && !SaveSucc) + (void)VBEGetVBEMode(pVbe, &vbe_sr->stateMode); + + if (function == MODE_RESTORE && vbe_sr->stateMode != -1) + VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL); + +} + +int +VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock) +{ + /* + Input: + AX := 4F0Bh VBE Get Pixel Clock + BL := 00h Get Pixel Clock + ECX := pixel clock in units of Hz + DX := mode number + + Output: + AX := VBE Return Status + ECX := Closest pixel clock + */ + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f0b; + pVbe->pInt10->bx = 0x00; + pVbe->pInt10->cx = clock; + pVbe->pInt10->dx = mode; + xf86ExecX86int10(pVbe->pInt10); + + if (R16(pVbe->pInt10->ax) != 0x4f) + return (0); + + return (pVbe->pInt10->cx); +} + +Bool +VBEDPMSSet(vbeInfoPtr pVbe, int mode) +{ + /* + Input: + AX := 4F10h DPMS + BL := 01h Set Display Power State + BH := requested power state + + Output: + AX := VBE Return Status + */ + + pVbe->pInt10->num = 0x10; + pVbe->pInt10->ax = 0x4f10; + pVbe->pInt10->bx = 0x01; + switch (mode) { + case DPMSModeOn: + break; + case DPMSModeStandby: + pVbe->pInt10->bx |= 0x100; + break; + case DPMSModeSuspend: + pVbe->pInt10->bx |= 0x200; + break; + case DPMSModeOff: + pVbe->pInt10->bx |= 0x400; + break; + } + xf86ExecX86int10(pVbe->pInt10); + return (R16(pVbe->pInt10->ax) == 0x4f); +} + +void +VBEInterpretPanelID(int scrnIndex, struct vbePanelID *data) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + DisplayModePtr mode; + const float PANEL_HZ = 60.0; + + if (!data) + return; + + xf86DrvMsg(scrnIndex, X_INFO, "PanelID returned panel resolution %dx%d\n", + data->hsize, data->vsize); + + if (pScrn->monitor->nHsync || pScrn->monitor->nVrefresh) + return; + + mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0); + + pScrn->monitor->nHsync = 1; + pScrn->monitor->hsync[0].lo = 31.5; + pScrn->monitor->hsync[0].hi = (float)mode->Clock / (float)mode->HTotal; + pScrn->monitor->nVrefresh = 1; + pScrn->monitor->vrefresh[0].lo = 56.0; + pScrn->monitor->vrefresh[0].hi = + (float)mode->Clock*1000.0 / (float)mode->HTotal / (float)mode->VTotal; + + xfree(mode); +} + +struct vbePanelID * +VBEReadPanelID(vbeInfoPtr pVbe) +{ + int RealOff = pVbe->real_mode_base; + pointer page = pVbe->memory; + unsigned char *tmp = NULL; + int screen = pVbe->pInt10->scrnIndex; + + pVbe->pInt10->ax = 0x4F11; + pVbe->pInt10->bx = 0x01; + pVbe->pInt10->cx = 0; + pVbe->pInt10->dx = 0; + pVbe->pInt10->es = SEG_ADDR(RealOff); + pVbe->pInt10->di = SEG_OFF(RealOff); + pVbe->pInt10->num = 0x10; + + xf86ExecX86int10(pVbe->pInt10); + + if ((pVbe->pInt10->ax & 0xff) != 0x4f) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID invalid\n"); + goto error; + } + + switch (pVbe->pInt10->ax & 0xff00) { + case 0x0: + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read successfully\n"); + tmp = (unsigned char *)xnfalloc(32); + memcpy(tmp,page,32); + break; + case 0x100: + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read failed\n"); + break; + default: + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID unknown failure %i\n", + pVbe->pInt10->ax & 0xff00); + break; + } + +error: + return tmp; +} diff --git a/xorg-server/hw/xfree86/vbe/vbe.h b/xorg-server/hw/xfree86/vbe/vbe.h new file mode 100644 index 000000000..de9237c9d --- /dev/null +++ b/xorg-server/hw/xfree86/vbe/vbe.h @@ -0,0 +1,347 @@ + +/* + * XFree86 vbe module + * Copyright 2000 Egbert Eich + * + * The mode query/save/set/restore functions from the vesa driver + * have been moved here. + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + */ + +#ifndef _VBE_H +#define _VBE_H +#include "xf86int10.h" +#include "xf86DDC.h" + +typedef enum { + DDC_UNCHECKED, + DDC_NONE, + DDC_1, + DDC_2, + DDC_1_2 +} +ddc_lvl; + +typedef struct { + xf86Int10InfoPtr pInt10; + int version; + pointer memory; + int real_mode_base; + int num_pages; + Bool init_int10; + ddc_lvl ddc; + Bool ddc_blank; +} vbeInfoRec, *vbeInfoPtr; + +#define VBE_VERSION_MAJOR(x) *((CARD8*)(&x) + 1) +#define VBE_VERSION_MINOR(x) (CARD8)(x) + +vbeInfoPtr VBEInit(xf86Int10InfoPtr pInt, int entityIndex); +vbeInfoPtr VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags); +void vbeFree(vbeInfoPtr pVbe); +xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule); + +#pragma pack(1) + +typedef struct vbeControllerInfoBlock { + CARD8 VbeSignature[4]; + CARD16 VbeVersion; + CARD32 OemStringPtr; + CARD8 Capabilities[4]; + CARD32 VideoModePtr; + CARD16 TotalMem; + CARD16 OemSoftwareRev; + CARD32 OemVendorNamePtr; + CARD32 OemProductNamePtr; + CARD32 OemProductRevPtr; + CARD8 Scratch[222]; + CARD8 OemData[256]; +} vbeControllerInfoRec, *vbeControllerInfoPtr; + +#if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C) +#pragma pack() /* All GCC versions recognise this syntax */ +#else +#pragma pack(0) +#endif + +#ifndef __GNUC__ +#define __attribute__(a) +#endif + +typedef struct _VbeInfoBlock VbeInfoBlock; +typedef struct _VbeModeInfoBlock VbeModeInfoBlock; +typedef struct _VbeCRTCInfoBlock VbeCRTCInfoBlock; + +/* + * INT 0 + */ + +struct _VbeInfoBlock { + /* VESA 1.2 fields */ + CARD8 VESASignature[4]; /* VESA */ + CARD16 VESAVersion; /* Higher byte major, lower byte minor */ + /*CARD32*/char *OEMStringPtr; /* Pointer to OEM string */ + CARD8 Capabilities[4]; /* Capabilities of the video environment */ + + /*CARD32*/CARD16 *VideoModePtr; /* pointer to supported Super VGA modes */ + + CARD16 TotalMemory; /* Number of 64kb memory blocks on board */ + /* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */ + + /* VESA 2 fields */ + CARD16 OemSoftwareRev; /* VBE implementation Software revision */ + /*CARD32*/char *OemVendorNamePtr; /* Pointer to Vendor Name String */ + /*CARD32*/char *OemProductNamePtr; /* Pointer to Product Name String */ + /*CARD32*/char *OemProductRevPtr; /* Pointer to Product Revision String */ + CARD8 Reserved[222]; /* Reserved for VBE implementation */ + CARD8 OemData[256]; /* Data Area for OEM Strings */ +} __attribute__((packed)); + +/* Return Super VGA Information */ +VbeInfoBlock *VBEGetVBEInfo(vbeInfoPtr pVbe); +void VBEFreeVBEInfo(VbeInfoBlock *block); + +/* + * INT 1 + */ + +struct _VbeModeInfoBlock { + CARD16 ModeAttributes; /* mode attributes */ + CARD8 WinAAttributes; /* window A attributes */ + CARD8 WinBAttributes; /* window B attributes */ + CARD16 WinGranularity; /* window granularity */ + CARD16 WinSize; /* window size */ + CARD16 WinASegment; /* window A start segment */ + CARD16 WinBSegment; /* window B start segment */ + CARD32 WinFuncPtr; /* real mode pointer to window function */ + CARD16 BytesPerScanline; /* bytes per scanline */ + + /* Mandatory information for VBE 1.2 and above */ + CARD16 XResolution; /* horizontal resolution in pixels or characters */ + CARD16 YResolution; /* vertical resolution in pixels or characters */ + CARD8 XCharSize; /* character cell width in pixels */ + CARD8 YCharSize; /* character cell height in pixels */ + CARD8 NumberOfPlanes; /* number of memory planes */ + CARD8 BitsPerPixel; /* bits per pixel */ + CARD8 NumberOfBanks; /* number of banks */ + CARD8 MemoryModel; /* memory model type */ + CARD8 BankSize; /* bank size in KB */ + CARD8 NumberOfImages; /* number of images */ + CARD8 Reserved; /* 1 */ /* reserved for page function */ + + /* Direct color fields (required for direct/6 and YUV/7 memory models) */ + CARD8 RedMaskSize; /* size of direct color red mask in bits */ + CARD8 RedFieldPosition; /* bit position of lsb of red mask */ + CARD8 GreenMaskSize; /* size of direct color green mask in bits */ + CARD8 GreenFieldPosition; /* bit position of lsb of green mask */ + CARD8 BlueMaskSize; /* size of direct color blue mask in bits */ + CARD8 BlueFieldPosition; /* bit position of lsb of blue mask */ + CARD8 RsvdMaskSize; /* size of direct color reserved mask in bits */ + CARD8 RsvdFieldPosition; /* bit position of lsb of reserved mask */ + CARD8 DirectColorModeInfo; /* direct color mode attributes */ + + /* Mandatory information for VBE 2.0 and above */ + CARD32 PhysBasePtr; /* physical address for flat memory frame buffer */ + CARD32 Reserved32; /* 0 */ /* Reserved - always set to 0 */ + CARD16 Reserved16; /* 0 */ /* Reserved - always set to 0 */ + + /* Mandatory information for VBE 3.0 and above */ + CARD16 LinBytesPerScanLine; /* bytes per scan line for linear modes */ + CARD8 BnkNumberOfImagePages; /* number of images for banked modes */ + CARD8 LinNumberOfImagePages; /* number of images for linear modes */ + CARD8 LinRedMaskSize; /* size of direct color red mask (linear modes) */ + CARD8 LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */ + CARD8 LinGreenMaskSize; /* size of direct color green mask (linear modes) */ + CARD8 LinGreenFieldPosition; /* bit position of lsb of green mask (linear modes) */ + CARD8 LinBlueMaskSize; /* size of direct color blue mask (linear modes) */ + CARD8 LinBlueFieldPosition; /* bit position of lsb of blue mask (linear modes) */ + CARD8 LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */ + CARD8 LinRsvdFieldPosition; /* bit position of lsb of reserved mask (linear modes) */ + CARD32 MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */ + CARD8 Reserved2[189]; /* remainder of VbeModeInfoBlock */ +} __attribute__((packed)); + +/* Return VBE Mode Information */ +VbeModeInfoBlock *VBEGetModeInfo(vbeInfoPtr pVbe, int mode); +void VBEFreeModeInfo(VbeModeInfoBlock *block); + +/* + * INT2 + */ + +#define CRTC_DBLSCAN (1<<0) +#define CRTC_INTERLACE (1<<1) +#define CRTC_NHSYNC (1<<2) +#define CRTC_NVSYNC (1<<3) + +struct _VbeCRTCInfoBlock { + CARD16 HorizontalTotal; /* Horizontal total in pixels */ + CARD16 HorizontalSyncStart; /* Horizontal sync start in pixels */ + CARD16 HorizontalSyncEnd; /* Horizontal sync end in pixels */ + CARD16 VerticalTotal; /* Vertical total in lines */ + CARD16 VerticalSyncStart; /* Vertical sync start in lines */ + CARD16 VerticalSyncEnd; /* Vertical sync end in lines */ + CARD8 Flags; /* Flags (Interlaced, Double Scan etc) */ + CARD32 PixelClock; /* Pixel clock in units of Hz */ + CARD16 RefreshRate; /* Refresh rate in units of 0.01 Hz */ + CARD8 Reserved[40]; /* remainder of ModeInfoBlock */ +} __attribute__((packed)); +/* VbeCRTCInfoBlock is in the VESA 3.0 specs */ + +Bool VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *crtc); + +/* + * INT 3 + */ + +Bool VBEGetVBEMode(vbeInfoPtr pVbe, int *mode); + +/* + * INT 4 + */ + +/* Save/Restore Super VGA video state */ +/* function values are (values stored in VESAPtr): + * 0 := query & allocate amount of memory to save state + * 1 := save state + * 2 := restore state + * + * function 0 called automatically if function 1 called without + * a previous call to function 0. + */ + +typedef enum { + MODE_QUERY, + MODE_SAVE, + MODE_RESTORE +} vbeSaveRestoreFunction; + +Bool +VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction fuction, + pointer *memory, int *size, int *real_mode_pages); + +/* + * INT 5 + */ + +Bool +VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window); + +/* + * INT 6 + */ + +typedef enum { + SCANWID_SET, + SCANWID_GET, + SCANWID_SET_BYTES, + SCANWID_GET_MAX +} vbeScanwidthCommand; + +#define VBESetLogicalScanline(pVbe, width) \ + VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET, width, \ + NULL, NULL, NULL) +#define VBESetLogicalScanlineBytes(pVbe, width) \ + VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET_BYTES, width, \ + NULL, NULL, NULL) +#define VBEGetLogicalScanline(pVbe, pixels, bytes, max) \ + VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET, 0, \ + pixels, bytes, max) +#define VBEGetMaxLogicalScanline(pVbe, pixels, bytes, max) \ + VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET_MAX, 0, \ + pixels, bytes, max) +Bool VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, + vbeScanwidthCommand command, int width, + int *pixels, int *bytes, int *max); + +/* + * INT 7 + */ + +/* 16 bit code */ +Bool VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace); +Bool VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y); + +/* + * INT 8 + */ + +/* if bits is 0, then it is a GET */ +int VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits); + +/* + * INT 9 + */ + +/* + * If getting a palette, the data argument is not used. It will return + * the data. + * If setting a palette, it will return the pointer received on success, + * NULL on failure. + */ +CARD32 *VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num, + CARD32 *data, Bool secondary, Bool wait_retrace); +#define VBEFreePaletteData(data) xfree(data) + +/* + * INT A + */ + +typedef struct _VBEpmi { + int seg_tbl; + int tbl_off; + int tbl_len; +} VBEpmi; + +VBEpmi *VBEGetVBEpmi(vbeInfoPtr pVbe); +#define VESAFreeVBEpmi(pmi) xfree(pmi) + +/* high level helper functions */ + +typedef struct _vbeModeInfoRec { + int width; + int height; + int bpp; + int n; + struct _vbeModeInfoRec *next; +} vbeModeInfoRec, *vbeModeInfoPtr; + +vbeModeInfoPtr VBEBuildVbeModeList(vbeInfoPtr pVbe, + VbeInfoBlock *vbe); + +unsigned short VBECalcVbeModeIndex(vbeModeInfoPtr m, + DisplayModePtr mode, int bpp); + +typedef struct { + CARD8 *state; + CARD8 *pstate; + int statePage; + int stateSize; + int stateMode; +} vbeSaveRestoreRec, *vbeSaveRestorePtr; + +void +VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr, + vbeSaveRestoreFunction function); + +int VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int Clock); +Bool VBEDPMSSet(vbeInfoPtr pVbe, int mode); + +struct vbePanelID { + short hsize; + short vsize; + short fptype; + char redbpp; + char greenbpp; + char bluebpp; + char reservedbpp; + int reserved_offscreen_mem_size; + int reserved_offscreen_mem_pointer; + char reserved[14]; +}; + +void VBEInterpretPanelID(int scrnIndex, struct vbePanelID *data); +struct vbePanelID *VBEReadPanelID(vbeInfoPtr pVbe); + +#endif diff --git a/xorg-server/hw/xfree86/vbe/vbeModes.c b/xorg-server/hw/xfree86/vbe/vbeModes.c new file mode 100644 index 000000000..fb730a708 --- /dev/null +++ b/xorg-server/hw/xfree86/vbe/vbeModes.c @@ -0,0 +1,453 @@ +#define DEBUG_VERB 2 +/* + * Copyright © 2002 David Dawes + * + * 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 AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the author(s) shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * the author(s). + * + * Authors: David Dawes <dawes@xfree86.org> + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include <string.h> + +#include "xf86.h" +#include "vbe.h" +#include "vbeModes.h" + +static int +GetDepthFlag(vbeInfoPtr pVbe, int id) +{ + VbeModeInfoBlock *mode; + int bpp; + + if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) + return 0; + + if (VBE_MODE_USABLE(mode, 0)) { + int depth; + + if (VBE_MODE_COLOR(mode)) { + depth = mode->RedMaskSize + mode->GreenMaskSize + + mode->BlueMaskSize; + } else { + depth = 1; + } + bpp = mode->BitsPerPixel; + VBEFreeModeInfo(mode); + mode = NULL; + switch (depth) { + case 1: + return V_DEPTH_1; + case 4: + return V_DEPTH_4; + case 8: + return V_DEPTH_8; + case 15: + return V_DEPTH_15; + case 16: + return V_DEPTH_16; + case 24: + switch (bpp) { + case 24: + return V_DEPTH_24_24; + case 32: + return V_DEPTH_24_32; + } + } + } + if (mode) + VBEFreeModeInfo(mode); + return 0; +} + +/* + * Find supported mode depths. + */ +int +VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock *vbe, int *flags24, + int modeTypes) +{ + int i = 0; + int depths = 0; + + if (modeTypes & V_MODETYPE_VBE) { + while (vbe->VideoModePtr[i] != 0xffff) { + depths |= GetDepthFlag(pVbe, vbe->VideoModePtr[i++]); + } + } + + /* + * XXX This possibly only works with VBE 3.0 and later. + */ + if (modeTypes & V_MODETYPE_VGA) { + for (i = 0; i < 0x7F; i++) { + depths |= GetDepthFlag(pVbe, i); + } + } + + if (flags24) { + if (depths & V_DEPTH_24_24) + *flags24 |= Support24bppFb; + if (depths & V_DEPTH_24_32) + *flags24 |= Support32bppFb; + } + + return depths; +} + +static DisplayModePtr +CheckMode(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe, int id, + int flags) +{ + CARD16 major; + VbeModeInfoBlock *mode; + DisplayModePtr pMode; + VbeModeInfoData *data; + Bool modeOK = FALSE; + + major = (unsigned)(vbe->VESAVersion >> 8); + + if ((mode = VBEGetModeInfo(pVbe, id)) == NULL) + return NULL; + + /* Does the mode match the depth/bpp? */ + /* Some BIOS's set BitsPerPixel to 15 instead of 16 for 15/16 */ + if (VBE_MODE_USABLE(mode, flags) && + ((pScrn->bitsPerPixel == 1 && !VBE_MODE_COLOR(mode)) || + (mode->BitsPerPixel > 8 && + (mode->RedMaskSize + mode->GreenMaskSize + + mode->BlueMaskSize) == pScrn->depth && + mode->BitsPerPixel == pScrn->bitsPerPixel) || + (mode->BitsPerPixel == 15 && pScrn->depth == 15) || + (mode->BitsPerPixel <= 8 && + mode->BitsPerPixel == pScrn->bitsPerPixel))) { + modeOK = TRUE; + xf86ErrorFVerb(DEBUG_VERB, "*"); + } + + xf86ErrorFVerb(DEBUG_VERB, + "Mode: %x (%dx%d)\n", id, mode->XResolution, mode->YResolution); + xf86ErrorFVerb(DEBUG_VERB, + " ModeAttributes: 0x%x\n", mode->ModeAttributes); + xf86ErrorFVerb(DEBUG_VERB, + " WinAAttributes: 0x%x\n", mode->WinAAttributes); + xf86ErrorFVerb(DEBUG_VERB, + " WinBAttributes: 0x%x\n", mode->WinBAttributes); + xf86ErrorFVerb(DEBUG_VERB, + " WinGranularity: %d\n", mode->WinGranularity); + xf86ErrorFVerb(DEBUG_VERB, + " WinSize: %d\n", mode->WinSize); + xf86ErrorFVerb(DEBUG_VERB, + " WinASegment: 0x%x\n", mode->WinASegment); + xf86ErrorFVerb(DEBUG_VERB, + " WinBSegment: 0x%x\n", mode->WinBSegment); + xf86ErrorFVerb(DEBUG_VERB, + " WinFuncPtr: 0x%lx\n", (unsigned long)mode->WinFuncPtr); + xf86ErrorFVerb(DEBUG_VERB, + " BytesPerScanline: %d\n", mode->BytesPerScanline); + xf86ErrorFVerb(DEBUG_VERB, + " XResolution: %d\n", mode->XResolution); + xf86ErrorFVerb(DEBUG_VERB, + " YResolution: %d\n", mode->YResolution); + xf86ErrorFVerb(DEBUG_VERB, + " XCharSize: %d\n", mode->XCharSize); + xf86ErrorFVerb(DEBUG_VERB, + " YCharSize: %d\n", mode->YCharSize); + xf86ErrorFVerb(DEBUG_VERB, + " NumberOfPlanes: %d\n", mode->NumberOfPlanes); + xf86ErrorFVerb(DEBUG_VERB, + " BitsPerPixel: %d\n", mode->BitsPerPixel); + xf86ErrorFVerb(DEBUG_VERB, + " NumberOfBanks: %d\n", mode->NumberOfBanks); + xf86ErrorFVerb(DEBUG_VERB, + " MemoryModel: %d\n", mode->MemoryModel); + xf86ErrorFVerb(DEBUG_VERB, + " BankSize: %d\n", mode->BankSize); + xf86ErrorFVerb(DEBUG_VERB, + " NumberOfImages: %d\n", mode->NumberOfImages); + xf86ErrorFVerb(DEBUG_VERB, + " RedMaskSize: %d\n", mode->RedMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " RedFieldPosition: %d\n", mode->RedFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " GreenMaskSize: %d\n", mode->GreenMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " GreenFieldPosition: %d\n", mode->GreenFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " BlueMaskSize: %d\n", mode->BlueMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " BlueFieldPosition: %d\n", mode->BlueFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " RsvdMaskSize: %d\n", mode->RsvdMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " RsvdFieldPosition: %d\n", mode->RsvdFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " DirectColorModeInfo: %d\n", mode->DirectColorModeInfo); + if (major >= 2) { + xf86ErrorFVerb(DEBUG_VERB, + " PhysBasePtr: 0x%lx\n", + (unsigned long)mode->PhysBasePtr); + if (major >= 3) { + xf86ErrorFVerb(DEBUG_VERB, + " LinBytesPerScanLine: %d\n", mode->LinBytesPerScanLine); + xf86ErrorFVerb(DEBUG_VERB, + " BnkNumberOfImagePages: %d\n", mode->BnkNumberOfImagePages); + xf86ErrorFVerb(DEBUG_VERB, + " LinNumberOfImagePages: %d\n", mode->LinNumberOfImagePages); + xf86ErrorFVerb(DEBUG_VERB, + " LinRedMaskSize: %d\n", mode->LinRedMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " LinRedFieldPosition: %d\n", mode->LinRedFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " LinGreenMaskSize: %d\n", mode->LinGreenMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " LinGreenFieldPosition: %d\n", mode->LinGreenFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " LinBlueMaskSize: %d\n", mode->LinBlueMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " LinBlueFieldPosition: %d\n", mode->LinBlueFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " LinRsvdMaskSize: %d\n", mode->LinRsvdMaskSize); + xf86ErrorFVerb(DEBUG_VERB, + " LinRsvdFieldPosition: %d\n", mode->LinRsvdFieldPosition); + xf86ErrorFVerb(DEBUG_VERB, + " MaxPixelClock: %ld\n", (unsigned long)mode->MaxPixelClock); + } + } + + if (!modeOK) { + VBEFreeModeInfo(mode); + return NULL; + } + pMode = xnfcalloc(sizeof(DisplayModeRec), 1); + + pMode->status = MODE_OK; + pMode->type = M_T_BUILTIN; + + /* for adjust frame */ + pMode->HDisplay = mode->XResolution; + pMode->VDisplay = mode->YResolution; + + data = xnfcalloc(sizeof(VbeModeInfoData), 1); + data->mode = id; + data->data = mode; + pMode->PrivSize = sizeof(VbeModeInfoData); + pMode->Private = (INT32*)data; + pMode->next = NULL; + return pMode; +} + +/* + * Check the available BIOS modes, and extract those that match the + * requirements into the modePool. Note: modePool is a NULL-terminated + * list. + */ + +DisplayModePtr +VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, VbeInfoBlock *vbe, + int modeTypes) +{ + DisplayModePtr pMode, p = NULL, modePool = NULL; + int i = 0; + + if (modeTypes & V_MODETYPE_VBE) { + while (vbe->VideoModePtr[i] != 0xffff) { + int id = vbe->VideoModePtr[i++]; + + if ((pMode = CheckMode(pScrn, pVbe, vbe, id, modeTypes)) != NULL) { + ModeStatus status = MODE_OK; + + /* Check the mode against a specified virtual size (if any) */ + if (pScrn->display->virtualX > 0 && + pMode->HDisplay > pScrn->display->virtualX) { + status = MODE_VIRTUAL_X; + } + if (pScrn->display->virtualY > 0 && + pMode->VDisplay > pScrn->display->virtualY) { + status = MODE_VIRTUAL_Y; + } + if (status != MODE_OK) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Not using mode \"%dx%d\" (%s)\n", + pMode->HDisplay, pMode->VDisplay, + xf86ModeStatusToString(status)); + } else { + if (p == NULL) { + modePool = pMode; + } else { + p->next = pMode; + } + pMode->prev = NULL; + p = pMode; + } + } + } + } + if (modeTypes & V_MODETYPE_VGA) { + for (i = 0; i < 0x7F; i++) { + if ((pMode = CheckMode(pScrn, pVbe, vbe, i, modeTypes)) != NULL) { + ModeStatus status = MODE_OK; + + /* Check the mode against a specified virtual size (if any) */ + if (pScrn->display->virtualX > 0 && + pMode->HDisplay > pScrn->display->virtualX) { + status = MODE_VIRTUAL_X; + } + if (pScrn->display->virtualY > 0 && + pMode->VDisplay > pScrn->display->virtualY) { + status = MODE_VIRTUAL_Y; + } + if (status != MODE_OK) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Not using mode \"%dx%d\" (%s)\n", + pMode->HDisplay, pMode->VDisplay, + xf86ModeStatusToString(status)); + } else { + if (p == NULL) { + modePool = pMode; + } else { + p->next = pMode; + } + pMode->prev = NULL; + p = pMode; + } + } + } + } + return modePool; +} + +void +VBESetModeNames(DisplayModePtr pMode) +{ + if (!pMode) + return; + + do { + if (!pMode->name) { + /* Catch "bad" modes. */ + if (pMode->HDisplay > 10000 || pMode->HDisplay < 0 || + pMode->VDisplay > 10000 || pMode->VDisplay < 0) { + pMode->name = strdup("BADMODE"); + } else { + pMode->name = xnfalloc(4 + 1 + 4 + 1); + sprintf(pMode->name, "%dx%d", pMode->HDisplay, pMode->VDisplay); + } + } + pMode = pMode->next; + } while (pMode); +} + +/* + * Go through the monitor modes and selecting the best set of + * parameters for each BIOS mode. Note: This is only supported in + * VBE version 3.0 or later. + */ +void +VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe) +{ + DisplayModePtr pMode; + VbeModeInfoData *data; + + pMode = pScrn->modes; + do { + DisplayModePtr p, best = NULL; + ModeStatus status; + + for (p = pScrn->monitor->Modes; p != NULL; p = p->next) { + if ((p->HDisplay != pMode->HDisplay) || + (p->VDisplay != pMode->VDisplay) || + (p->Flags & (V_INTERLACE | V_DBLSCAN | V_CLKDIV2))) + continue; + /* XXX could support the various V_ flags */ + status = xf86CheckModeForMonitor(p, pScrn->monitor); + if (status != MODE_OK) + continue; + if (!best || (p->Clock > best->Clock)) + best = p; + } + + if (best) { + int clock; + + data = (VbeModeInfoData*)pMode->Private; + pMode->HSync = (float)best->Clock * 1000.0 / best->HTotal + 0.5; + pMode->VRefresh = pMode->HSync / best->VTotal + 0.5; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Attempting to use %dHz refresh for mode \"%s\" (%x)\n", + (int)pMode->VRefresh, pMode->name, data->mode); + data->block = xcalloc(sizeof(VbeCRTCInfoBlock), 1); + data->block->HorizontalTotal = best->HTotal; + data->block->HorizontalSyncStart = best->HSyncStart; + data->block->HorizontalSyncEnd = best->HSyncEnd; + data->block->VerticalTotal = best->VTotal; + data->block->VerticalSyncStart = best->VSyncStart; + data->block->VerticalSyncEnd = best->VSyncEnd; + data->block->Flags = ((best->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) | + ((best->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0); + data->block->PixelClock = best->Clock * 1000; + /* XXX May not have this. */ + clock = VBEGetPixelClock(pVbe, data->mode, data->block->PixelClock); +#ifdef DEBUG + ErrorF("Setting clock %.2fMHz, closest is %.2fMHz\n", + (double)data->block->PixelClock / 1000000.0, + (double)clock / 1000000.0); +#endif + if (clock) + data->block->PixelClock = clock; + data->mode |= (1 << 11); + data->block->RefreshRate = ((double)(data->block->PixelClock) / + (double)(best->HTotal * best->VTotal)) * 100; + } + pMode = pMode->next; + } while (pMode != pScrn->modes); +} + +/* + * These wrappers are to allow (temporary) funtionality divergences. + */ +int +VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, + char **modeNames, ClockRangePtr clockRanges, + int *linePitches, int minPitch, int maxPitch, int pitchInc, + int minHeight, int maxHeight, int virtualX, int virtualY, + int apertureSize, LookupModeFlags strategy) +{ + return xf86ValidateModes(scrp, availModes, modeNames, clockRanges, + linePitches, minPitch, maxPitch, pitchInc, + minHeight, maxHeight, virtualX, virtualY, + apertureSize, strategy); +} + +void +VBEPrintModes(ScrnInfoPtr scrp) +{ + xf86PrintModes(scrp); +} + diff --git a/xorg-server/hw/xfree86/vbe/vbeModes.h b/xorg-server/hw/xfree86/vbe/vbeModes.h new file mode 100644 index 000000000..c28cdaa37 --- /dev/null +++ b/xorg-server/hw/xfree86/vbe/vbeModes.h @@ -0,0 +1,90 @@ +/* + * Copyright © 2002 David Dawes + * + * 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 AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the author(s) shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * the author(s). + * + * Authors: David Dawes <dawes@xfree86.org> + * + */ + +#ifndef _VBE_MODES_H + +/* + * This is intended to be stored in the DisplayModeRec's private area. + * It includes all the information necessary to VBE information. + */ +typedef struct _VbeModeInfoData { + int mode; + VbeModeInfoBlock *data; + VbeCRTCInfoBlock *block; +} VbeModeInfoData; + +#define V_DEPTH_1 0x001 +#define V_DEPTH_4 0x002 +#define V_DEPTH_8 0x004 +#define V_DEPTH_15 0x008 +#define V_DEPTH_16 0x010 +#define V_DEPTH_24_24 0x020 +#define V_DEPTH_24_32 0x040 +#define V_DEPTH_24 (V_DEPTH_24_24 | V_DEPTH_24_32) +#define V_DEPTH_30 0x080 +#define V_DEPTH_32 0x100 + +#define VBE_MODE_SUPPORTED(m) (((m)->ModeAttributes & 0x01) != 0) +#define VBE_MODE_COLOR(m) (((m)->ModeAttributes & 0x08) != 0) +#define VBE_MODE_GRAPHICS(m) (((m)->ModeAttributes & 0x10) != 0) +#define VBE_MODE_VGA(m) (((m)->ModeAttributes & 0x40) == 0) +#define VBE_MODE_LINEAR(m) (((m)->ModeAttributes & 0x80) != 0 && \ + ((m)->PhysBasePtr != 0)) + +#define VBE_MODE_USABLE(m, f) (VBE_MODE_SUPPORTED(m) || \ + (f & V_MODETYPE_BAD)) && \ + VBE_MODE_GRAPHICS(m) && \ + (VBE_MODE_VGA(m) || VBE_MODE_LINEAR(m)) + +#define V_MODETYPE_VBE 0x01 +#define V_MODETYPE_VGA 0x02 +#define V_MODETYPE_BAD 0x04 + +extern int VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock *vbe, + int *flags24, int modeTypes); +extern DisplayModePtr VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe, + VbeInfoBlock *vbe, int modeTypes); +extern void VBESetModeNames(DisplayModePtr pMode); +extern void VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe); + + +/* + * Note: These are alternatives to the standard helpers. They should + * usually just wrap the standard helpers. + */ +extern int VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, + char **modeNames, ClockRangePtr clockRanges, + int *linePitches, int minPitch, int maxPitch, + int pitchInc, int minHeight, int maxHeight, + int virtualX, int virtualY, int apertureSize, + LookupModeFlags strategy); +extern void VBEPrintModes(ScrnInfoPtr scrp); + +#endif /* VBE_MODES_H */ diff --git a/xorg-server/hw/xfree86/vbe/vbe_module.c b/xorg-server/hw/xfree86/vbe/vbe_module.c new file mode 100644 index 000000000..cf37ef951 --- /dev/null +++ b/xorg-server/hw/xfree86/vbe/vbe_module.c @@ -0,0 +1,31 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86str.h" +#include "vbe.h" + +static MODULESETUPPROTO(vbeSetup); + +static XF86ModuleVersionInfo vbeVersRec = +{ + "vbe", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 1, 0, + ABI_CLASS_VIDEODRV, /* needs the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData vbeModuleData = { &vbeVersRec, vbeSetup, NULL }; + +static pointer +vbeSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + return (pointer)1; +} diff --git a/xorg-server/hw/xfree86/vgahw/Makefile.am b/xorg-server/hw/xfree86/vgahw/Makefile.am new file mode 100644 index 000000000..f48e46a11 --- /dev/null +++ b/xorg-server/hw/xfree86/vgahw/Makefile.am @@ -0,0 +1,9 @@ +module_LTLIBRARIES = libvgahw.la +libvgahw_la_LDFLAGS = -avoid-version +libvgahw_la_SOURCES = vgaHW.c vgaHWmodule.c +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +sdk_HEADERS = vgaHW.h + +EXTRA_DIST = vgaCmap.c diff --git a/xorg-server/hw/xfree86/vgahw/Makefile.in b/xorg-server/hw/xfree86/vgahw/Makefile.in new file mode 100644 index 000000000..ab31d5354 --- /dev/null +++ b/xorg-server/hw/xfree86/vgahw/Makefile.in @@ -0,0 +1,702 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/vgahw +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libvgahw_la_LIBADD = +am_libvgahw_la_OBJECTS = vgaHW.lo vgaHWmodule.lo +libvgahw_la_OBJECTS = $(am_libvgahw_la_OBJECTS) +libvgahw_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libvgahw_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libvgahw_la_SOURCES) +DIST_SOURCES = $(libvgahw_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libvgahw.la +libvgahw_la_LDFLAGS = -avoid-version +libvgahw_la_SOURCES = vgaHW.c vgaHWmodule.c +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +sdk_HEADERS = vgaHW.h +EXTRA_DIST = vgaCmap.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/vgahw/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/vgahw/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libvgahw.la: $(libvgahw_la_OBJECTS) $(libvgahw_la_DEPENDENCIES) + $(libvgahw_la_LINK) -rpath $(moduledir) $(libvgahw_la_OBJECTS) $(libvgahw_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgaHW.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgaHWmodule.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/vgahw/vgaCmap.c b/xorg-server/hw/xfree86/vgahw/vgaCmap.c new file mode 100644 index 000000000..44043c6c7 --- /dev/null +++ b/xorg-server/hw/xfree86/vgahw/vgaCmap.c @@ -0,0 +1,302 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * 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 Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "windowstr.h" +#include "compiler.h" +#include "mipointer.h" +#include "micmap.h" + +#include "xf86.h" +#include "vgaHW.h" + +#define _XF86DGA_SERVER_ +#include <X11/extensions/xf86dgastr.h> +#include "dgaproc.h" + + +#define NOMAPYET (ColormapPtr) 0 + +int +vgaListInstalledColormaps(pScreen, pmaps) + ScreenPtr pScreen; + Colormap *pmaps; +{ + /* By the time we are processing requests, we can guarantee that there + * is always a colormap installed */ + + *pmaps = miInstalledMaps[pScreen->myNum]->mid; + return(1); +} + +int +vgaGetInstalledColormaps(pScreen, pmaps) + ScreenPtr pScreen; + ColormapPtr *pmaps; +{ + /* By the time we are processing requests, we can guarantee that there + * is always a colormap installed */ + + *pmaps = miInstalledMaps[pScreen->myNum]; + return(1); +} + +int vgaCheckColorMap(ColormapPtr pmap) +{ + return (pmap != miInstalledMaps[pmap->pScreen->myNum]); +} + + +void +vgaStoreColors(pmap, ndef, pdefs) + ColormapPtr pmap; + int ndef; + xColorItem *pdefs; +{ + int i; + unsigned char *cmap, *tmp = NULL; + xColorItem directDefs[256]; + Bool new_overscan = FALSE; + Bool writeColormap; + + /* This can get called before the ScrnInfoRec is installed so we + can't rely on getting it with XF86SCRNINFO() */ + int scrnIndex = pmap->pScreen->myNum; + ScrnInfoPtr scrninfp = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(scrninfp); + + unsigned char overscan = hwp->ModeReg.Attribute[OVERSCAN]; + unsigned char tmp_overscan = 0; + + if (vgaCheckColorMap(pmap)) + return; + + if ((pmap->pVisual->class | DynamicClass) == DirectColor) + { + ndef = miExpandDirectColors (pmap, ndef, pdefs, directDefs); + pdefs = directDefs; + } + + writeColormap = scrninfp->vtSema; + if (DGAAvailable(scrnIndex)) + { + writeColormap = writeColormap || + (DGAGetDirectMode(scrnIndex) && + !(DGAGetFlags(scrnIndex) & XF86DGADirectColormap)) || + (DGAGetFlags(scrnIndex) & XF86DGAHasColormap); + } + + if (writeColormap) + hwp->enablePalette(hwp); + + for(i = 0; i < ndef; i++) + { + if (pdefs[i].pixel == overscan) + { + new_overscan = TRUE; + } + cmap = &(hwp->ModeReg.DAC[pdefs[i].pixel*3]); + if (scrninfp->rgbBits == 8) { + cmap[0] = pdefs[i].red >> 8; + cmap[1] = pdefs[i].green >> 8; + cmap[2] = pdefs[i].blue >> 8; + } + else { + cmap[0] = pdefs[i].red >> 10; + cmap[1] = pdefs[i].green >> 10; + cmap[2] = pdefs[i].blue >> 10; + } +#if 0 + if (clgd6225Lcd) + { + /* The LCD doesn't like white */ + if (cmap[0] == 63) cmap[0]= 62; + if (cmap[1] == 63) cmap[1]= 62; + if (cmap[2] == 63) cmap[2]= 62; + } +#endif + + if (writeColormap) + { + if (hwp->ShowOverscan && i == 255) + continue; + hwp->writeDacWriteAddr(hwp, pdefs[i].pixel); + DACDelay(hwp); + hwp->writeDacData(hwp, cmap[0]); + DACDelay(hwp); + hwp->writeDacData(hwp, cmap[1]); + DACDelay(hwp); + hwp->writeDacData(hwp, cmap[2]); + DACDelay(hwp); + } + } + if (new_overscan && !hwp->ShowOverscan) + { + new_overscan = FALSE; + for(i = 0; i < ndef; i++) + { + if (pdefs[i].pixel == overscan) + { + if ((pdefs[i].red != 0) || + (pdefs[i].green != 0) || + (pdefs[i].blue != 0)) + { + new_overscan = TRUE; + tmp_overscan = overscan; + tmp = &(hwp->ModeReg.DAC[pdefs[i].pixel*3]); + } + break; + } + } + if (new_overscan) + { + /* + * Find a black pixel, or the nearest match. + */ + for (i=255; i >= 0; i--) + { + cmap = &(hwp->ModeReg.DAC[i*3]); + if ((cmap[0] == 0) && (cmap[1] == 0) && (cmap[2] == 0)) + { + overscan = i; + break; + } + else + { + if ((cmap[0] < tmp[0]) && + (cmap[1] < tmp[1]) && (cmap[2] < tmp[2])) + { + tmp = cmap; + tmp_overscan = i; + } + } + } + if (i < 0) + { + overscan = tmp_overscan; + } + hwp->ModeReg.Attribute[OVERSCAN] = overscan; + if (writeColormap) + { + hwp->writeAttr(hwp, OVERSCAN, overscan); + } + } + } + + if (writeColormap) + hwp->disablePalette(hwp); +} + + +void +vgaInstallColormap(pmap) + ColormapPtr pmap; +{ + ColormapPtr oldmap = miInstalledMaps[pmap->pScreen->myNum]; + int entries; + Pixel * ppix; + xrgb * prgb; + xColorItem *defs; + int i; + + + if (pmap == oldmap) + return; + + if ((pmap->pVisual->class | DynamicClass) == DirectColor) + entries = (pmap->pVisual->redMask | + pmap->pVisual->greenMask | + pmap->pVisual->blueMask) + 1; + else + entries = pmap->pVisual->ColormapEntries; + + ppix = (Pixel *)xalloc( entries * sizeof(Pixel)); + prgb = (xrgb *)xalloc( entries * sizeof(xrgb)); + defs = (xColorItem *)xalloc(entries * sizeof(xColorItem)); + + if ( oldmap != NOMAPYET) + WalkTree( pmap->pScreen, TellLostMap, &oldmap->mid); + + miInstalledMaps[pmap->pScreen->myNum] = pmap; + + for ( i=0; i<entries; i++) ppix[i] = i; + + QueryColors( pmap, entries, ppix, prgb); + + for ( i=0; i<entries; i++) /* convert xrgbs to xColorItems */ + { + defs[i].pixel = ppix[i]; + defs[i].red = prgb[i].red; + defs[i].green = prgb[i].green; + defs[i].blue = prgb[i].blue; + defs[i].flags = DoRed|DoGreen|DoBlue; + } + pmap->pScreen->StoreColors(pmap, entries, defs); + + WalkTree(pmap->pScreen, TellGainedMap, &pmap->mid); + + xfree(ppix); + xfree(prgb); + xfree(defs); +} + + +void +vgaUninstallColormap(pmap) + ColormapPtr pmap; +{ + + ColormapPtr defColormap; + + if ( pmap != miInstalledMaps[pmap->pScreen->myNum] ) + return; + + defColormap = (ColormapPtr) LookupIDByType( pmap->pScreen->defColormap, + RT_COLORMAP); + + if (defColormap == miInstalledMaps[pmap->pScreen->myNum]) + return; + + (*pmap->pScreen->InstallColormap) (defColormap); +} + + +void +vgaHandleColormaps(ScreenPtr pScreen, ScrnInfoPtr scrnp) +{ + if (scrnp->bitsPerPixel > 1) { + if (scrnp->bitsPerPixel <= 8) { /* For 8bpp SVGA and VGA16 */ + pScreen->InstallColormap = vgaInstallColormap; + pScreen->UninstallColormap = vgaUninstallColormap; + pScreen->ListInstalledColormaps = vgaListInstalledColormaps; + pScreen->StoreColors = vgaStoreColors; + } + } +} + diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.c b/xorg-server/hw/xfree86/vgahw/vgaHW.c new file mode 100644 index 000000000..ccbd19574 --- /dev/null +++ b/xorg-server/hw/xfree86/vgahw/vgaHW.c @@ -0,0 +1,2004 @@ + +/* + * + * Copyright 1991-1999 by The XFree86 Project, Inc. + * + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + */ + +#define _NEED_SYSI86 + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <X11/X.h> +#include "misc.h" + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "vgaHW.h" + +#include "compiler.h" + +#include "xf86cmap.h" + +#include "Pci.h" + +#ifndef SAVE_FONT1 +#define SAVE_FONT1 1 +#endif + +/* + * These used to be OS-specific, which made this module have an undesirable + * OS dependency. Define them by default for all platforms. + */ +#ifndef NEED_SAVED_CMAP +#define NEED_SAVED_CMAP +#endif +#ifndef SAVE_TEXT +#define SAVE_TEXT 1 +#endif +#ifndef SAVE_FONT2 +#define SAVE_FONT2 1 +#endif + +/* bytes per plane to save for text */ +#define TEXT_AMOUNT 16384 + +/* bytes per plane to save for font data */ +#define FONT_AMOUNT (8*8192) + +#if 0 +/* Override all of these for now */ +#undef SAVE_FONT1 +#define SAVE_FONT1 1 +#undef SAVE_FONT2 +#define SAVE_FONT2 1 +#undef SAVE_TEST +#define SAVE_TEST 1 +#undef FONT_AMOUNT +#define FONT_AMOUNT 65536 +#undef TEXT_AMOUNT +#define TEXT_AMOUNT 65536 +#endif + +/* DAC indices for white and black */ +#define WHITE_VALUE 0x3F +#define BLACK_VALUE 0x00 +#define OVERSCAN_VALUE 0x01 + + +/* Use a private definition of this here */ +#undef VGAHWPTR +#define VGAHWPTRLVAL(p) (p)->privates[vgaHWPrivateIndex].ptr +#define VGAHWPTR(p) ((vgaHWPtr)(VGAHWPTRLVAL(p))) + +static int vgaHWPrivateIndex = -1; + +#define DAC_TEST_MASK 0x3F + +#ifdef NEED_SAVED_CMAP +/* This default colourmap is used only when it can't be read from the VGA */ + +static CARD8 defaultDAC[768] = +{ + 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42, + 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42, + 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63, + 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63, + 0, 0, 0, 5, 5, 5, 8, 8, 8, 11, 11, 11, + 14, 14, 14, 17, 17, 17, 20, 20, 20, 24, 24, 24, + 28, 28, 28, 32, 32, 32, 36, 36, 36, 40, 40, 40, + 45, 45, 45, 50, 50, 50, 56, 56, 56, 63, 63, 63, + 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, 63, + 63, 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, + 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, 0, + 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, 0, + 0, 63, 0, 0, 63, 16, 0, 63, 31, 0, 63, 47, + 0, 63, 63, 0, 47, 63, 0, 31, 63, 0, 16, 63, + 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, 63, + 63, 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, + 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, 31, + 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, 31, + 31, 63, 31, 31, 63, 39, 31, 63, 47, 31, 63, 55, + 31, 63, 63, 31, 55, 63, 31, 47, 63, 31, 39, 63, + 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, 63, + 63, 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, + 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, 45, + 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, 45, + 45, 63, 45, 45, 63, 49, 45, 63, 54, 45, 63, 58, + 45, 63, 63, 45, 58, 63, 45, 54, 63, 45, 49, 63, + 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, 28, + 28, 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, + 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, 0, + 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, 0, + 0, 28, 0, 0, 28, 7, 0, 28, 14, 0, 28, 21, + 0, 28, 28, 0, 21, 28, 0, 14, 28, 0, 7, 28, + 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, 28, + 28, 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, + 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, 14, + 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, 14, + 14, 28, 14, 14, 28, 17, 14, 28, 21, 14, 28, 24, + 14, 28, 28, 14, 24, 28, 14, 21, 28, 14, 17, 28, + 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, 28, + 28, 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, + 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, 20, + 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, 20, + 20, 28, 20, 20, 28, 22, 20, 28, 24, 20, 28, 26, + 20, 28, 28, 20, 26, 28, 20, 24, 28, 20, 22, 28, + 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, 16, + 16, 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, + 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, 0, + 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, 0, + 0, 16, 0, 0, 16, 4, 0, 16, 8, 0, 16, 12, + 0, 16, 16, 0, 12, 16, 0, 8, 16, 0, 4, 16, + 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, 16, + 16, 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, + 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, 8, + 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, 8, + 8, 16, 8, 8, 16, 10, 8, 16, 12, 8, 16, 14, + 8, 16, 16, 8, 14, 16, 8, 12, 16, 8, 10, 16, + 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, 16, + 16, 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, + 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, 11, + 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, 11, + 11, 16, 11, 11, 16, 12, 11, 16, 13, 11, 16, 15, + 11, 16, 16, 11, 15, 16, 11, 13, 16, 11, 12, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +#endif /* NEED_SAVED_CMAP */ + +/* + * Standard VGA versions of the register access functions. + */ +static void +stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index); + outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET, value); +} + +static CARD8 +stdReadCrtc(vgaHWPtr hwp, CARD8 index) +{ + outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index); + return inb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET); +} + +static void +stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index); + outb(hwp->PIOOffset + VGA_GRAPH_DATA, value); +} + +static CARD8 +stdReadGr(vgaHWPtr hwp, CARD8 index) +{ + outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index); + return inb(hwp->PIOOffset + VGA_GRAPH_DATA); +} + +static void +stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_SEQ_INDEX, index); + outb(hwp->PIOOffset + VGA_SEQ_DATA, value); +} + +static CARD8 +stdReadSeq(vgaHWPtr hwp, CARD8 index) +{ + outb(hwp->PIOOffset + VGA_SEQ_INDEX, index); + return inb(hwp->PIOOffset + VGA_SEQ_DATA); +} + +static CARD8 +stdReadST00(vgaHWPtr hwp) +{ + return inb(hwp->PIOOffset + VGA_IN_STAT_0); +} + +static CARD8 +stdReadST01(vgaHWPtr hwp) +{ + return inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); +} + +static CARD8 +stdReadFCR(vgaHWPtr hwp) +{ + return inb(hwp->PIOOffset + VGA_FEATURE_R); +} + +static void +stdWriteFCR(vgaHWPtr hwp, CARD8 value) +{ + outb(hwp->IOBase + hwp->PIOOffset + VGA_FEATURE_W_OFFSET,value); +} + +static void +stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); + outb(hwp->PIOOffset + VGA_ATTR_INDEX, index); + outb(hwp->PIOOffset + VGA_ATTR_DATA_W, value); +} + +static CARD8 +stdReadAttr(vgaHWPtr hwp, CARD8 index) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); + outb(hwp->PIOOffset + VGA_ATTR_INDEX, index); + return inb(hwp->PIOOffset + VGA_ATTR_DATA_R); +} + +static void +stdWriteMiscOut(vgaHWPtr hwp, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_MISC_OUT_W, value); +} + +static CARD8 +stdReadMiscOut(vgaHWPtr hwp) +{ + return inb(hwp->PIOOffset + VGA_MISC_OUT_R); +} + +static void +stdEnablePalette(vgaHWPtr hwp) +{ + (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); + outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x00); + hwp->paletteEnabled = TRUE; +} + +static void +stdDisablePalette(vgaHWPtr hwp) +{ + (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET); + outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x20); + hwp->paletteEnabled = FALSE; +} + +static void +stdWriteDacMask(vgaHWPtr hwp, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_DAC_MASK, value); +} + +static CARD8 +stdReadDacMask(vgaHWPtr hwp) +{ + return inb(hwp->PIOOffset + VGA_DAC_MASK); +} + +static void +stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_DAC_READ_ADDR, value); +} + +static void +stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_DAC_WRITE_ADDR, value); +} + +static void +stdWriteDacData(vgaHWPtr hwp, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_DAC_DATA, value); +} + +static CARD8 +stdReadDacData(vgaHWPtr hwp) +{ + return inb(hwp->PIOOffset + VGA_DAC_DATA); +} + +static CARD8 +stdReadEnable(vgaHWPtr hwp) +{ + return inb(hwp->PIOOffset + VGA_ENABLE); +} + +static void +stdWriteEnable(vgaHWPtr hwp, CARD8 value) +{ + outb(hwp->PIOOffset + VGA_ENABLE, value); +} + +void +vgaHWSetStdFuncs(vgaHWPtr hwp) +{ + hwp->writeCrtc = stdWriteCrtc; + hwp->readCrtc = stdReadCrtc; + hwp->writeGr = stdWriteGr; + hwp->readGr = stdReadGr; + hwp->readST00 = stdReadST00; + hwp->readST01 = stdReadST01; + hwp->readFCR = stdReadFCR; + hwp->writeFCR = stdWriteFCR; + hwp->writeAttr = stdWriteAttr; + hwp->readAttr = stdReadAttr; + hwp->writeSeq = stdWriteSeq; + hwp->readSeq = stdReadSeq; + hwp->writeMiscOut = stdWriteMiscOut; + hwp->readMiscOut = stdReadMiscOut; + hwp->enablePalette = stdEnablePalette; + hwp->disablePalette = stdDisablePalette; + hwp->writeDacMask = stdWriteDacMask; + hwp->readDacMask = stdReadDacMask; + hwp->writeDacWriteAddr = stdWriteDacWriteAddr; + hwp->writeDacReadAddr = stdWriteDacReadAddr; + hwp->writeDacData = stdWriteDacData; + hwp->readDacData = stdReadDacData; + hwp->PIOOffset = 0; + hwp->readEnable = stdReadEnable; + hwp->writeEnable = stdWriteEnable; +} + +/* + * MMIO versions of the register access functions. These require + * hwp->MemBase to be set in such a way that when the standard VGA port + * adderss is added the correct memory address results. + */ + +#define minb(p) MMIO_IN8(hwp->MMIOBase, (hwp->MMIOOffset + (p))) +#define moutb(p,v) MMIO_OUT8(hwp->MMIOBase, (hwp->MMIOOffset + (p)),(v)) + +static void +mmioWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + moutb(hwp->IOBase + VGA_CRTC_DATA_OFFSET, value); +} + +static CARD8 +mmioReadCrtc(vgaHWPtr hwp, CARD8 index) +{ + moutb(hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index); + return minb(hwp->IOBase + VGA_CRTC_DATA_OFFSET); +} + +static void +mmioWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + moutb(VGA_GRAPH_INDEX, index); + moutb(VGA_GRAPH_DATA, value); +} + +static CARD8 +mmioReadGr(vgaHWPtr hwp, CARD8 index) +{ + moutb(VGA_GRAPH_INDEX, index); + return minb(VGA_GRAPH_DATA); +} + +static void +mmioWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + moutb(VGA_SEQ_INDEX, index); + moutb(VGA_SEQ_DATA, value); +} + +static CARD8 +mmioReadSeq(vgaHWPtr hwp, CARD8 index) +{ + moutb(VGA_SEQ_INDEX, index); + return minb(VGA_SEQ_DATA); +} + +static CARD8 +mmioReadST00(vgaHWPtr hwp) +{ + return minb(VGA_IN_STAT_0); +} + +static CARD8 +mmioReadST01(vgaHWPtr hwp) +{ + return minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); +} + +static CARD8 +mmioReadFCR(vgaHWPtr hwp) +{ + return minb(VGA_FEATURE_R); +} + +static void +mmioWriteFCR(vgaHWPtr hwp, CARD8 value) +{ + moutb(hwp->IOBase + VGA_FEATURE_W_OFFSET,value); +} + +static void +mmioWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, index); + moutb(VGA_ATTR_DATA_W, value); +} + +static CARD8 +mmioReadAttr(vgaHWPtr hwp, CARD8 index) +{ + if (hwp->paletteEnabled) + index &= ~0x20; + else + index |= 0x20; + + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, index); + return minb(VGA_ATTR_DATA_R); +} + +static void +mmioWriteMiscOut(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_MISC_OUT_W, value); +} + +static CARD8 +mmioReadMiscOut(vgaHWPtr hwp) +{ + return minb(VGA_MISC_OUT_R); +} + +static void +mmioEnablePalette(vgaHWPtr hwp) +{ + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, 0x00); + hwp->paletteEnabled = TRUE; +} + +static void +mmioDisablePalette(vgaHWPtr hwp) +{ + (void) minb(hwp->IOBase + VGA_IN_STAT_1_OFFSET); + moutb(VGA_ATTR_INDEX, 0x20); + hwp->paletteEnabled = FALSE; +} + +static void +mmioWriteDacMask(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_MASK, value); +} + +static CARD8 +mmioReadDacMask(vgaHWPtr hwp) +{ + return minb(VGA_DAC_MASK); +} + +static void +mmioWriteDacReadAddr(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_READ_ADDR, value); +} + +static void +mmioWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_WRITE_ADDR, value); +} + +static void +mmioWriteDacData(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_DAC_DATA, value); +} + +static CARD8 +mmioReadDacData(vgaHWPtr hwp) +{ + return minb(VGA_DAC_DATA); +} + +static CARD8 +mmioReadEnable(vgaHWPtr hwp) +{ + return minb(VGA_ENABLE); +} + +static void +mmioWriteEnable(vgaHWPtr hwp, CARD8 value) +{ + moutb(VGA_ENABLE, value); +} + +void +vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset) +{ + hwp->writeCrtc = mmioWriteCrtc; + hwp->readCrtc = mmioReadCrtc; + hwp->writeGr = mmioWriteGr; + hwp->readGr = mmioReadGr; + hwp->readST00 = mmioReadST00; + hwp->readST01 = mmioReadST01; + hwp->readFCR = mmioReadFCR; + hwp->writeFCR = mmioWriteFCR; + hwp->writeAttr = mmioWriteAttr; + hwp->readAttr = mmioReadAttr; + hwp->writeSeq = mmioWriteSeq; + hwp->readSeq = mmioReadSeq; + hwp->writeMiscOut = mmioWriteMiscOut; + hwp->readMiscOut = mmioReadMiscOut; + hwp->enablePalette = mmioEnablePalette; + hwp->disablePalette = mmioDisablePalette; + hwp->writeDacMask = mmioWriteDacMask; + hwp->readDacMask = mmioReadDacMask; + hwp->writeDacWriteAddr = mmioWriteDacWriteAddr; + hwp->writeDacReadAddr = mmioWriteDacReadAddr; + hwp->writeDacData = mmioWriteDacData; + hwp->readDacData = mmioReadDacData; + hwp->MMIOBase = base; + hwp->MMIOOffset = offset; + hwp->readEnable = mmioReadEnable; + hwp->writeEnable = mmioWriteEnable; +} + +/* + * vgaHWProtect -- + * Protect VGA registers and memory from corruption during loads. + */ + +void +vgaHWProtect(ScrnInfoPtr pScrn, Bool on) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + + unsigned char tmp; + + if (pScrn->vtSema) { + if (on) { + /* + * Turn off screen and disable sequencer. + */ + tmp = hwp->readSeq(hwp, 0x01); + + vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */ + hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */ + + hwp->enablePalette(hwp); + } else { + /* + * Reenable sequencer, then turn on screen. + */ + + tmp = hwp->readSeq(hwp, 0x01); + + hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */ + vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */ + + hwp->disablePalette(hwp); + } + } +} + +vgaHWProtectProc *vgaHWProtectWeak(void) { + return vgaHWProtect; +} + +/* + * vgaHWBlankScreen -- blank the screen. + */ + +void +vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + unsigned char scrn; + + scrn = hwp->readSeq(hwp, 0x01); + + if (on) { + scrn &= ~0x20; /* enable screen */ + } else { + scrn |= 0x20; /* blank screen */ + } + + vgaHWSeqReset(hwp, TRUE); + hwp->writeSeq(hwp, 0x01, scrn); /* change mode */ + vgaHWSeqReset(hwp, FALSE); +} + +vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) { + return vgaHWBlankScreen; +} + +/* + * vgaHWSaveScreen -- blank the screen. + */ + +Bool +vgaHWSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = NULL; + Bool on; + + if (pScreen != NULL) + pScrn = xf86Screens[pScreen->myNum]; + + on = xf86IsUnblank(mode); + +#if 0 + if (on) + SetTimeSinceLastInputEvent(); +#endif + + if ((pScrn != NULL) && pScrn->vtSema) { + vgaHWBlankScreen(pScrn, on); + } + return (TRUE); +} + + +/* + * vgaHWDPMSSet -- Sets VESA Display Power Management Signaling (DPMS) Mode + * + * This generic VGA function can only set the Off and On modes. If the + * Standby and Suspend modes are to be supported, a chip specific replacement + * for this function must be written. + */ + +void +vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) +{ + unsigned char seq1 = 0, crtc17 = 0; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + if (!pScrn->vtSema) return; + + switch (PowerManagementMode) { + case DPMSModeOn: + /* Screen: On; HSync: On, VSync: On */ + seq1 = 0x00; + crtc17 = 0x80; + break; + case DPMSModeStandby: + /* Screen: Off; HSync: Off, VSync: On -- Not Supported */ + seq1 = 0x20; + crtc17 = 0x80; + break; + case DPMSModeSuspend: + /* Screen: Off; HSync: On, VSync: Off -- Not Supported */ + seq1 = 0x20; + crtc17 = 0x80; + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off, VSync: Off */ + seq1 = 0x20; + crtc17 = 0x00; + break; + } + hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */ + seq1 |= hwp->readSeq(hwp, 0x01) & ~0x20; + hwp->writeSeq(hwp, 0x01, seq1); + crtc17 |= hwp->readCrtc(hwp, 0x17) & ~0x80; + usleep(10000); + hwp->writeCrtc(hwp, 0x17, crtc17); + hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */ +} + + +/* + * vgaHWSeqReset + * perform a sequencer reset. + */ + +void +vgaHWSeqReset(vgaHWPtr hwp, Bool start) +{ + if (start) + hwp->writeSeq(hwp, 0x00, 0x01); /* Synchronous Reset */ + else + hwp->writeSeq(hwp, 0x00, 0x03); /* End Reset */ +} + + +void +vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore) +{ +#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int savedIOBase; + unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4; + Bool doMap = FALSE; + + /* If nothing to do, return now */ + if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo) + return; + + if (hwp->Base == NULL) { + doMap = TRUE; + if (!vgaHWMapMem(scrninfp)) { + xf86DrvMsg(scrninfp->scrnIndex, X_ERROR, + "vgaHWRestoreFonts: vgaHWMapMem() failed\n"); + return; + } + } + + /* save the registers that are needed here */ + miscOut = hwp->readMiscOut(hwp); + attr10 = hwp->readAttr(hwp, 0x10); + gr1 = hwp->readGr(hwp, 0x01); + gr3 = hwp->readGr(hwp, 0x03); + gr4 = hwp->readGr(hwp, 0x04); + gr5 = hwp->readGr(hwp, 0x05); + gr6 = hwp->readGr(hwp, 0x06); + gr8 = hwp->readGr(hwp, 0x08); + seq2 = hwp->readSeq(hwp, 0x02); + seq4 = hwp->readSeq(hwp, 0x04); + + /* save hwp->IOBase and temporarily set it for colour mode */ + savedIOBase = hwp->IOBase; + hwp->IOBase = VGA_IOBASE_COLOR; + + /* Force into colour mode */ + hwp->writeMiscOut(hwp, miscOut | 0x01); + + vgaHWBlankScreen(scrninfp, FALSE); + + /* + * here we temporarily switch to 16 colour planar mode, to simply + * copy the font-info and saved text. + * + * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly! + */ +#if 0 + hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */ +#endif + + hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */ + hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */ + hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */ + + if (scrninfp->depth == 4) { + /* GJA */ + hwp->writeGr(hwp, 0x03, 0x00); /* don't rotate, write unmodified */ + hwp->writeGr(hwp, 0x08, 0xFF); /* write all bits in a byte */ + hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */ + } + +#if SAVE_FONT1 + if (hwp->FontInfo1) { + hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */ + hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */ + slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT); + } +#endif + +#if SAVE_FONT2 + if (hwp->FontInfo2) { + hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */ + hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */ + slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT); + } +#endif + +#if SAVE_TEXT + if (hwp->TextInfo) { + hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */ + hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */ + slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT); + hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */ + hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */ + slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT, + hwp->Base, TEXT_AMOUNT); + } +#endif + + vgaHWBlankScreen(scrninfp, TRUE); + + /* restore the registers that were changed */ + hwp->writeMiscOut(hwp, miscOut); + hwp->writeAttr(hwp, 0x10, attr10); + hwp->writeGr(hwp, 0x01, gr1); + hwp->writeGr(hwp, 0x03, gr3); + hwp->writeGr(hwp, 0x04, gr4); + hwp->writeGr(hwp, 0x05, gr5); + hwp->writeGr(hwp, 0x06, gr6); + hwp->writeGr(hwp, 0x08, gr8); + hwp->writeSeq(hwp, 0x02, seq2); + hwp->writeSeq(hwp, 0x04, seq4); + hwp->IOBase = savedIOBase; + + if (doMap) + vgaHWUnmapMem(scrninfp); + +#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */ +} + + +void +vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int i; + + if (restore->MiscOutReg & 0x01) + hwp->IOBase = VGA_IOBASE_COLOR; + else + hwp->IOBase = VGA_IOBASE_MONO; + + hwp->writeMiscOut(hwp, restore->MiscOutReg); + + for (i = 1; i < restore->numSequencer; i++) + hwp->writeSeq(hwp, i, restore->Sequencer[i]); + + /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */ + hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80); + + for (i = 0; i < restore->numCRTC; i++) + hwp->writeCrtc(hwp, i, restore->CRTC[i]); + + for (i = 0; i < restore->numGraphics; i++) + hwp->writeGr(hwp, i, restore->Graphics[i]); + + hwp->enablePalette(hwp); + for (i = 0; i < restore->numAttribute; i++) + hwp->writeAttr(hwp, i, restore->Attribute[i]); + hwp->disablePalette(hwp); +} + + +void +vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int i; + +#if 0 + hwp->enablePalette(hwp); +#endif + + hwp->writeDacMask(hwp, 0xFF); + hwp->writeDacWriteAddr(hwp, 0x00); + for (i = 0; i < 768; i++) { + hwp->writeDacData(hwp, restore->DAC[i]); + DACDelay(hwp); + } + + hwp->disablePalette(hwp); +} + + +/* + * vgaHWRestore -- + * restore the VGA state + */ + +void +vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags) +{ + if (flags & VGA_SR_MODE) + vgaHWRestoreMode(scrninfp, restore); + + if (flags & VGA_SR_FONTS) + vgaHWRestoreFonts(scrninfp, restore); + + if (flags & VGA_SR_CMAP) + vgaHWRestoreColormap(scrninfp, restore); +} + +void +vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save) +{ +#if SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int savedIOBase; + unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4; + Bool doMap = FALSE; + + if (hwp->Base == NULL) { + doMap = TRUE; + if (!vgaHWMapMem(scrninfp)) { + xf86DrvMsg(scrninfp->scrnIndex, X_ERROR, + "vgaHWSaveFonts: vgaHWMapMem() failed\n"); + return; + } + } + + /* If in graphics mode, don't save anything */ + attr10 = hwp->readAttr(hwp, 0x10); + if (attr10 & 0x01) + return; + + /* save the registers that are needed here */ + miscOut = hwp->readMiscOut(hwp); + gr4 = hwp->readGr(hwp, 0x04); + gr5 = hwp->readGr(hwp, 0x05); + gr6 = hwp->readGr(hwp, 0x06); + seq2 = hwp->readSeq(hwp, 0x02); + seq4 = hwp->readSeq(hwp, 0x04); + + /* save hwp->IOBase and temporarily set it for colour mode */ + savedIOBase = hwp->IOBase; + hwp->IOBase = VGA_IOBASE_COLOR; + + /* Force into colour mode */ + hwp->writeMiscOut(hwp, miscOut | 0x01); + + vgaHWBlankScreen(scrninfp, FALSE); + + /* + * get the character sets, and text screen if required + */ + /* + * Here we temporarily switch to 16 colour planar mode, to simply + * copy the font-info + * + * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly! + */ +#if 0 + hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */ +#endif + + hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */ + hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */ + hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */ + +#if SAVE_FONT1 + if (hwp->FontInfo1 || (hwp->FontInfo1 = xalloc(FONT_AMOUNT))) { + hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */ + hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */ + slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT); + } +#endif /* SAVE_FONT1 */ +#if SAVE_FONT2 + if (hwp->FontInfo2 || (hwp->FontInfo2 = xalloc(FONT_AMOUNT))) { + hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */ + hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */ + slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT); + } +#endif /* SAVE_FONT2 */ +#if SAVE_TEXT + if (hwp->TextInfo || (hwp->TextInfo = xalloc(2 * TEXT_AMOUNT))) { + hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */ + hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */ + slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT); + hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */ + hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */ + slowbcopy_frombus(hwp->Base, + (unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT); + } +#endif /* SAVE_TEXT */ + + /* Restore clobbered registers */ + hwp->writeAttr(hwp, 0x10, attr10); + hwp->writeSeq(hwp, 0x02, seq2); + hwp->writeSeq(hwp, 0x04, seq4); + hwp->writeGr(hwp, 0x04, gr4); + hwp->writeGr(hwp, 0x05, gr5); + hwp->writeGr(hwp, 0x06, gr6); + hwp->writeMiscOut(hwp, miscOut); + hwp->IOBase = savedIOBase; + + vgaHWBlankScreen(scrninfp, TRUE); + + if (doMap) + vgaHWUnmapMem(scrninfp); + +#endif /* SAVE_TEXT || SAVE_FONT1 || SAVE_FONT2 */ +} + +void +vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + int i; + + save->MiscOutReg = hwp->readMiscOut(hwp); + if (save->MiscOutReg & 0x01) + hwp->IOBase = VGA_IOBASE_COLOR; + else + hwp->IOBase = VGA_IOBASE_MONO; + + for (i = 0; i < save->numCRTC; i++) { + save->CRTC[i] = hwp->readCrtc(hwp, i); +#ifdef DEBUG + ErrorF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]); +#endif + } + + hwp->enablePalette(hwp); + for (i = 0; i < save->numAttribute; i++) { + save->Attribute[i] = hwp->readAttr(hwp, i); +#ifdef DEBUG + ErrorF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]); +#endif + } + hwp->disablePalette(hwp); + + for (i = 0; i < save->numGraphics; i++) { + save->Graphics[i] = hwp->readGr(hwp, i); +#ifdef DEBUG + ErrorF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]); +#endif + } + + for (i = 1; i < save->numSequencer; i++) { + save->Sequencer[i] = hwp->readSeq(hwp, i); +#ifdef DEBUG + ErrorF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]); +#endif + } +} + + +void +vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save) +{ + vgaHWPtr hwp = VGAHWPTR(scrninfp); + Bool readError = FALSE; + int i; + +#ifdef NEED_SAVED_CMAP + /* + * Some ET4000 chips from 1991 have a HW bug that prevents the reading + * of the color lookup table. Mask rev 9042EAI is known to have this bug. + * + * If the colourmap is not readable, we set the saved map to a default + * map (taken from Ferraro's "Programmer's Guide to the EGA and VGA + * Cards" 2nd ed). + */ + + /* Only save it once */ + if (hwp->cmapSaved) + return; + +#if 0 + hwp->enablePalette(hwp); +#endif + + hwp->writeDacMask(hwp, 0xFF); + + /* + * check if we can read the lookup table + */ + hwp->writeDacReadAddr(hwp, 0x00); + for (i = 0; i < 6; i++) { + save->DAC[i] = hwp->readDacData(hwp); +#ifdef DEBUG + switch (i % 3) { + case 0: + ErrorF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]); + break; + case 1: + ErrorF("0x%02x, ", save->DAC[i]); + break; + case 2: + ErrorF("0x%02x\n", save->DAC[i]); + } +#endif + } + + /* + * Check if we can read the palette - + * use foreground color to prevent flashing. + */ + hwp->writeDacWriteAddr(hwp, 0x01); + for (i = 3; i < 6; i++) + hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK); + hwp->writeDacReadAddr(hwp, 0x01); + for (i = 3; i < 6; i++) { + if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK)) + readError = TRUE; + } + hwp->writeDacWriteAddr(hwp, 0x01); + for (i = 3; i < 6; i++) + hwp->writeDacData(hwp, save->DAC[i]); + + if (readError) { + /* + * save the default lookup table + */ + memmove(save->DAC, defaultDAC, 768); + xf86DrvMsg(scrninfp->scrnIndex, X_WARNING, + "Cannot read colourmap from VGA. Will restore with default\n"); + } else { + /* save the colourmap */ + hwp->writeDacReadAddr(hwp, 0x02); + for (i = 6; i < 768; i++) { + save->DAC[i] = hwp->readDacData(hwp); + DACDelay(hwp); +#ifdef DEBUG + switch (i % 3) { + case 0: + ErrorF("DAC[0x%02x] = 0x%02x, ", i / 3, save->DAC[i]); + break; + case 1: + ErrorF("0x%02x, ", save->DAC[i]); + break; + case 2: + ErrorF("0x%02x\n", save->DAC[i]); + } +#endif + } + } + + hwp->disablePalette(hwp); + hwp->cmapSaved = TRUE; +#endif +} + +/* + * vgaHWSave -- + * save the current VGA state + */ + +void +vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags) +{ + if (save == NULL) + return; + + if (flags & VGA_SR_CMAP) + vgaHWSaveColormap(scrninfp, save); + + if (flags & VGA_SR_MODE) + vgaHWSaveMode(scrninfp, save); + + if (flags & VGA_SR_FONTS) + vgaHWSaveFonts(scrninfp, save); +} + + +/* + * vgaHWInit -- + * Handle the initialization, etc. of a screen. + * Return FALSE on failure. + */ + +Bool +vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode) +{ + unsigned int i; + vgaHWPtr hwp; + vgaRegPtr regp; + int depth = scrninfp->depth; + + /* + * make sure the vgaHWRec is allocated + */ + if (!vgaHWGetHWRec(scrninfp)) + return FALSE; + hwp = VGAHWPTR(scrninfp); + regp = &hwp->ModeReg; + + /* + * compute correct Hsync & Vsync polarity + */ + if ((mode->Flags & (V_PHSYNC | V_NHSYNC)) + && (mode->Flags & (V_PVSYNC | V_NVSYNC))) + { + regp->MiscOutReg = 0x23; + if (mode->Flags & V_NHSYNC) regp->MiscOutReg |= 0x40; + if (mode->Flags & V_NVSYNC) regp->MiscOutReg |= 0x80; + } + else + { + int VDisplay = mode->VDisplay; + if (mode->Flags & V_DBLSCAN) + VDisplay *= 2; + if (mode->VScan > 1) + VDisplay *= mode->VScan; + if (VDisplay < 400) + regp->MiscOutReg = 0xA3; /* +hsync -vsync */ + else if (VDisplay < 480) + regp->MiscOutReg = 0x63; /* -hsync +vsync */ + else if (VDisplay < 768) + regp->MiscOutReg = 0xE3; /* -hsync -vsync */ + else + regp->MiscOutReg = 0x23; /* +hsync +vsync */ + } + + regp->MiscOutReg |= (mode->ClockIndex & 0x03) << 2; + + /* + * Time Sequencer + */ + if (depth == 4) + regp->Sequencer[0] = 0x02; + else + regp->Sequencer[0] = 0x00; + if (mode->Flags & V_CLKDIV2) + regp->Sequencer[1] = 0x09; + else + 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 */ + + /* + * CRTC Controller + */ + regp->CRTC[0] = (mode->CrtcHTotal >> 3) - 5; + regp->CRTC[1] = (mode->CrtcHDisplay >> 3) - 1; + regp->CRTC[2] = (mode->CrtcHBlankStart >> 3) - 1; + regp->CRTC[3] = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F) | 0x80; + i = (((mode->CrtcHSkew << 2) + 0x10) & ~0x1F); + if (i < 0x80) + regp->CRTC[3] |= i; + regp->CRTC[4] = (mode->CrtcHSyncStart >> 3); + regp->CRTC[5] = ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2) + | (((mode->CrtcHSyncEnd >> 3)) & 0x1F); + regp->CRTC[6] = (mode->CrtcVTotal - 2) & 0xFF; + regp->CRTC[7] = (((mode->CrtcVTotal - 2) & 0x100) >> 8) + | (((mode->CrtcVDisplay - 1) & 0x100) >> 7) + | ((mode->CrtcVSyncStart & 0x100) >> 6) + | (((mode->CrtcVBlankStart - 1) & 0x100) >> 5) + | 0x10 + | (((mode->CrtcVTotal - 2) & 0x200) >> 4) + | (((mode->CrtcVDisplay - 1) & 0x200) >> 3) + | ((mode->CrtcVSyncStart & 0x200) >> 2); + regp->CRTC[8] = 0x00; + regp->CRTC[9] = (((mode->CrtcVBlankStart - 1) & 0x200) >> 4) | 0x40; + if (mode->Flags & V_DBLSCAN) + regp->CRTC[9] |= 0x80; + if (mode->VScan >= 32) + regp->CRTC[9] |= 0x1F; + else if (mode->VScan > 1) + regp->CRTC[9] |= mode->VScan - 1; + regp->CRTC[10] = 0x00; + regp->CRTC[11] = 0x00; + regp->CRTC[12] = 0x00; + regp->CRTC[13] = 0x00; + regp->CRTC[14] = 0x00; + regp->CRTC[15] = 0x00; + regp->CRTC[16] = mode->CrtcVSyncStart & 0xFF; + regp->CRTC[17] = (mode->CrtcVSyncEnd & 0x0F) | 0x20; + regp->CRTC[18] = (mode->CrtcVDisplay - 1) & 0xFF; + regp->CRTC[19] = scrninfp->displayWidth >> 4; /* just a guess */ + regp->CRTC[20] = 0x00; + regp->CRTC[21] = (mode->CrtcVBlankStart - 1) & 0xFF; + regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF; + if (depth < 8) + regp->CRTC[23] = 0xE3; + else + regp->CRTC[23] = 0xC3; + regp->CRTC[24] = 0xFF; + + vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO); + vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO); + + /* + * Theory resumes here.... + */ + + /* + * 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; /* only map 64k VGA memory !!!! */ + regp->Graphics[7] = 0x0F; + regp->Graphics[8] = 0xFF; + + if (depth == 1) { + /* Initialise the Mono map according to which bit-plane gets used */ + + Bool flipPixels = xf86GetFlipPixels(); + + 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- */ /* wrong for the ET4000 */ + if (!hwp->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; /* wrong for the ET4000 */ + else + regp->Attribute[16] = 0x41; /* wrong for the ET4000 */ + /* Attribute[17] (overscan) initialised in vgaHWGetHWRec() */ + } + regp->Attribute[18] = 0x0F; + regp->Attribute[19] = 0x00; + regp->Attribute[20] = 0x00; + + return(TRUE); +} + + /* + * OK, so much for theory. Now, let's deal with the >real< world... + * + * The above CRTC settings are precise in theory, except that many, if not + * most, VGA clones fail to reset the blanking signal when the character or + * line counter reaches [HV]Total. In this case, the signal is only + * unblanked when the counter reaches [HV]BlankEnd (mod 64, 128 or 256 as + * the case may be) at the start of the >next< scanline or frame, which + * means only part of the screen shows. This affects how null overscans + * are to be implemented on such adapters. + * + * Henceforth, VGA cores that implement this broken, but unfortunately + * common, behaviour are to be designated as KGA's, in honour of Koen + * Gadeyne, whose zeal to eliminate overscans (read: fury) set in motion + * a series of events that led to the discovery of this problem. + * + * Some VGA's are KGA's only in the horizontal, or only in the vertical, + * some in both, others in neither. Don't let anyone tell you there is + * such a thing as a VGA "standard"... And, thank the Creator for the fact + * that Hilbert spaces are not yet implemented in this industry. + * + * The following implements a trick suggested by David Dawes. This sets + * [HV]BlankEnd to zero if the blanking interval does not already contain a + * 0-point, and decrements it by one otherwise. In the latter case, this + * will produce a left and/or top overscan which the colourmap code will + * (still) need to ensure is as close to black as possible. This will make + * the behaviour consistent across all chipsets, while allowing all + * chipsets to display the entire screen. Non-KGA drivers can ignore the + * following in their own copy of this code. + * + * -- TSI @ UQV, 1998.08.21 + */ + +CARD32 +vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags) +{ + int nExtBits = (nBits < 6) ? 0 : nBits - 6; + CARD32 ExtBits; + CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6; + + regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) + | (((mode->CrtcHBlankEnd >> 3) - 1) & 0x1F); + regp->CRTC[5] = (regp->CRTC[5] & ~0x80) + | ((((mode->CrtcHBlankEnd >> 3) - 1) & 0x20) << 2); + ExtBits = ((mode->CrtcHBlankEnd >> 3) - 1) & ExtBitMask; + + /* First the horizontal case */ + if ((Flags & KGA_FIX_OVERSCAN) + && ((mode->CrtcHBlankEnd >> 3) == (mode->CrtcHTotal >> 3))) + { + int i = (regp->CRTC[3] & 0x1F) + | ((regp->CRTC[5] & 0x80) >> 2) + | ExtBits; + if (Flags & KGA_ENABLE_ON_ZERO) { + if ((i-- > (((mode->CrtcHBlankStart >> 3) - 1) + & (0x3F | ExtBitMask))) + && (mode->CrtcHBlankEnd == mode->CrtcHTotal)) + i = 0; + } else if (Flags & KGA_BE_TOT_DEC) + i--; + regp->CRTC[3] = (regp->CRTC[3] & ~0x1F) | (i & 0x1F); + regp->CRTC[5] = (regp->CRTC[5] & ~0x80) | ((i << 2) & 0x80); + ExtBits = i & ExtBitMask; + } + return ExtBits >> 6; +} + + /* + * The vertical case is a little trickier. Some VGA's ignore bit 0x80 of + * CRTC[22]. Also, in some cases, a zero CRTC[22] will still blank the + * very first scanline in a double- or multi-scanned mode. This last case + * needs further investigation. + */ +CARD32 +vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags) +{ + CARD32 ExtBits; + CARD32 nExtBits = (nBits < 8) ? 0 : (nBits - 8); + CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 8; + /* If width is not known nBits should be 0. In this + * case BitMask is set to 0 so we can check for it. */ + CARD32 BitMask = (nBits < 7) ? 0 : ((1 << nExtBits) - 1); + int VBlankStart = (mode->CrtcVBlankStart - 1) & 0xFF; + regp->CRTC[22] = (mode->CrtcVBlankEnd - 1) & 0xFF; + ExtBits = (mode->CrtcVBlankEnd - 1) & ExtBitMask; + + if ((Flags & KGA_FIX_OVERSCAN) + && (mode->CrtcVBlankEnd == mode->CrtcVTotal)) + /* Null top overscan */ + { + int i = regp->CRTC[22] | ExtBits; + if (Flags & KGA_ENABLE_ON_ZERO) { + if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask))) + || ((i > VBlankStart) && /* 8-bit case */ + ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */ + !(regp->CRTC[9] & 0x9F)) /* 1 scanline/row */ + i = 0; + else + i = (i - 1); + } else if (Flags & KGA_BE_TOT_DEC) + i = (i - 1); + + regp->CRTC[22] = i & 0xFF; + ExtBits = i & 0xFF00; + } + return ExtBits >> 8; +} + +/* + * these are some more hardware specific helpers, formerly in vga.c + */ +static void +vgaHWGetHWRecPrivate(void) +{ + if (vgaHWPrivateIndex < 0) + vgaHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + return; +} + + +static void +vgaHWFreeRegs(vgaRegPtr regp) +{ + if (regp->CRTC) + xfree (regp->CRTC); + + regp->CRTC = + regp->Sequencer = + regp->Graphics = + regp->Attribute = NULL; + + regp->numCRTC = + regp->numSequencer = + regp->numGraphics = + regp->numAttribute = 0; +} + + + +static Bool +vgaHWAllocRegs(vgaRegPtr regp) +{ + unsigned char *buf; + + if ((regp->numCRTC + regp->numSequencer + regp->numGraphics + + regp->numAttribute) == 0) + return FALSE; + + buf = xcalloc(regp->numCRTC + + regp->numSequencer + + regp->numGraphics + + regp->numAttribute, 1); + if (!buf) + return FALSE; + + regp->CRTC = buf; + regp->Sequencer = regp->CRTC + regp->numCRTC; + regp->Graphics = regp->Sequencer + regp->numSequencer; + regp->Attribute = regp->Graphics + regp->numGraphics; + + return TRUE; +} + + +Bool +vgaHWAllocDefaultRegs(vgaRegPtr regp) +{ + regp->numCRTC = VGA_NUM_CRTC; + regp->numSequencer = VGA_NUM_SEQ; + regp->numGraphics = VGA_NUM_GFX; + regp->numAttribute = VGA_NUM_ATTR; + + return vgaHWAllocRegs(regp); +} + + +Bool +vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer, + int numGraphics, int numAttribute) +{ +#define VGAHWMINNUM(regtype) \ + ((newMode.num##regtype < regp->num##regtype) ? \ + (newMode.num##regtype) : (regp->num##regtype)) +#define VGAHWCOPYREGSET(regtype) \ + memcpy (newMode.regtype, regp->regtype, VGAHWMINNUM(regtype)) + + vgaRegRec newMode, newSaved; + vgaRegPtr regp; + + regp = &VGAHWPTR(scrp)->ModeReg; + memcpy (&newMode, regp, sizeof(vgaRegRec)); + + /* allocate space for new registers */ + + regp = &newMode; + regp->numCRTC = numCRTC; + regp->numSequencer = numSequencer; + regp->numGraphics = numGraphics; + regp->numAttribute = numAttribute; + if (!vgaHWAllocRegs(regp)) + return FALSE; + + regp = &VGAHWPTR(scrp)->SavedReg; + memcpy (&newSaved, regp, sizeof(vgaRegRec)); + + regp = &newSaved; + regp->numCRTC = numCRTC; + regp->numSequencer = numSequencer; + regp->numGraphics = numGraphics; + regp->numAttribute = numAttribute; + if (!vgaHWAllocRegs(regp)) { + vgaHWFreeRegs(&newMode); + return FALSE; + } + + /* allocations succeeded, copy register data into new space */ + + regp = &VGAHWPTR(scrp)->ModeReg; + VGAHWCOPYREGSET(CRTC); + VGAHWCOPYREGSET(Sequencer); + VGAHWCOPYREGSET(Graphics); + VGAHWCOPYREGSET(Attribute); + + regp = &VGAHWPTR(scrp)->SavedReg; + VGAHWCOPYREGSET(CRTC); + VGAHWCOPYREGSET(Sequencer); + VGAHWCOPYREGSET(Graphics); + VGAHWCOPYREGSET(Attribute); + + /* free old register arrays */ + + regp = &VGAHWPTR(scrp)->ModeReg; + vgaHWFreeRegs(regp); + memcpy(regp, &newMode, sizeof(vgaRegRec)); + + regp = &VGAHWPTR(scrp)->SavedReg; + vgaHWFreeRegs(regp); + memcpy(regp, &newSaved, sizeof(vgaRegRec)); + + return TRUE; + +#undef VGAHWMINNUM +#undef VGAHWCOPYREGSET +} + + +Bool +vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src) +{ + vgaHWFreeRegs(dst); + + memcpy(dst, src, sizeof(vgaRegRec)); + + if (!vgaHWAllocRegs(dst)) + return FALSE; + + memcpy(dst->CRTC, src->CRTC, src->numCRTC); + memcpy(dst->Sequencer, src->Sequencer, src->numSequencer); + memcpy(dst->Graphics, src->Graphics, src->numGraphics); + memcpy(dst->Attribute, src->Attribute, src->numAttribute); + + return TRUE; +} + + +Bool +vgaHWGetHWRec(ScrnInfoPtr scrp) +{ + vgaRegPtr regp; + vgaHWPtr hwp; + int i; + + /* + * Let's make sure that the private exists and allocate one. + */ + vgaHWGetHWRecPrivate(); + /* + * New privates are always set to NULL, so we can check if the allocation + * has already been done. + */ + if (VGAHWPTR(scrp)) + return TRUE; + hwp = VGAHWPTRLVAL(scrp) = xnfcalloc(sizeof(vgaHWRec), 1); + regp = &VGAHWPTR(scrp)->ModeReg; + + if ((!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->SavedReg)) || + (!vgaHWAllocDefaultRegs(&VGAHWPTR(scrp)->ModeReg))) { + xfree(hwp); + return FALSE; + } + + if (scrp->bitsPerPixel == 1) { + rgb blackColour = scrp->display->blackColour, + whiteColour = scrp->display->whiteColour; + + if (blackColour.red > 0x3F) blackColour.red = 0x3F; + if (blackColour.green > 0x3F) blackColour.green = 0x3F; + if (blackColour.blue > 0x3F) blackColour.blue = 0x3F; + + if (whiteColour.red > 0x3F) whiteColour.red = 0x3F; + if (whiteColour.green > 0x3F) whiteColour.green = 0x3F; + if (whiteColour.blue > 0x3F) whiteColour.blue = 0x3F; + + if ((blackColour.red == whiteColour.red ) && + (blackColour.green == whiteColour.green) && + (blackColour.blue == whiteColour.blue )) { + blackColour.red ^= 0x3F; + blackColour.green ^= 0x3F; + blackColour.blue ^= 0x3F; + } + + /* + * initialize default colormap for monochrome + */ + for (i=0; i<3; i++) regp->DAC[i] = 0x00; + for (i=3; i<768; i++) regp->DAC[i] = 0x3F; + i = BLACK_VALUE * 3; + regp->DAC[i++] = blackColour.red; + regp->DAC[i++] = blackColour.green; + regp->DAC[i] = blackColour.blue; + i = WHITE_VALUE * 3; + regp->DAC[i++] = whiteColour.red; + regp->DAC[i++] = whiteColour.green; + regp->DAC[i] = whiteColour.blue; + i = OVERSCAN_VALUE * 3; + regp->DAC[i++] = 0x00; + regp->DAC[i++] = 0x00; + regp->DAC[i] = 0x00; + } else { + /* Set all colours to black */ + for (i=0; i<768; i++) regp->DAC[i] = 0x00; + /* ... and the overscan */ + if (scrp->depth >= 4) + regp->Attribute[OVERSCAN] = 0xFF; + } + if (xf86FindOption(scrp->confScreen->options, "ShowOverscan")) { + xf86MarkOptionUsedByName(scrp->confScreen->options, "ShowOverscan"); + xf86DrvMsg(scrp->scrnIndex, X_CONFIG, "Showing overscan area\n"); + regp->DAC[765] = 0x3F; + regp->DAC[766] = 0x00; + regp->DAC[767] = 0x3F; + regp->Attribute[OVERSCAN] = 0xFF; + hwp->ShowOverscan = TRUE; + } else + hwp->ShowOverscan = FALSE; + + hwp->paletteEnabled = FALSE; + hwp->cmapSaved = FALSE; + hwp->MapSize = 0; + hwp->pScrn = scrp; + + /* Initialise the function pointers with the standard VGA versions */ + vgaHWSetStdFuncs(hwp); + + hwp->PIOOffset = scrp->domainIOBase; + hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]); + + return TRUE; +} + + +void +vgaHWFreeHWRec(ScrnInfoPtr scrp) +{ + if (vgaHWPrivateIndex >= 0) { + vgaHWPtr hwp = VGAHWPTR(scrp); + + if (!hwp) + return; + + xfree(hwp->FontInfo1); + xfree(hwp->FontInfo2); + xfree(hwp->TextInfo); + + vgaHWFreeRegs (&hwp->ModeReg); + vgaHWFreeRegs (&hwp->SavedReg); + + xfree(hwp); + VGAHWPTRLVAL(scrp) = NULL; + } +} + + +Bool +vgaHWMapMem(ScrnInfoPtr scrp) +{ + vgaHWPtr hwp = VGAHWPTR(scrp); + int scr_index = scrp->scrnIndex; + + if (hwp->Base) + return TRUE; + + /* If not set, initialise with the defaults */ + if (hwp->MapSize == 0) + hwp->MapSize = VGA_DEFAULT_MEM_SIZE; + if (hwp->MapPhys == 0) + hwp->MapPhys = VGA_DEFAULT_PHYS_ADDR; + + /* + * Map as VIDMEM_MMIO_32BIT because WC + * is bad when there is page flipping. + * XXX This is not correct but we do it + * for now. + */ +#ifdef DEBUG + ErrorF("Mapping VGAMem\n"); +#endif + hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->dev, + hwp->MapPhys, hwp->MapSize); + return hwp->Base != NULL; +} + + +void +vgaHWUnmapMem(ScrnInfoPtr scrp) +{ + vgaHWPtr hwp = VGAHWPTR(scrp); + int scr_index = scrp->scrnIndex; + + if (hwp->Base == NULL) + return; + +#ifdef DEBUG + ErrorF("Unmapping VGAMem\n"); +#endif + xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize); + hwp->Base = NULL; +} + +int +vgaHWGetIndex() +{ + return vgaHWPrivateIndex; +} + + +void +vgaHWGetIOBase(vgaHWPtr hwp) +{ + hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ? + VGA_IOBASE_COLOR : VGA_IOBASE_MONO; + xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3, + "vgaHWGetIOBase: hwp->IOBase is 0x%04x, hwp->PIOOffset is 0x%04lx\n", + hwp->IOBase, hwp->PIOOffset); +} + + +void +vgaHWLock(vgaHWPtr hwp) +{ + /* Protect CRTC[0-7] */ + hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) | 0x80); +} + +void +vgaHWUnlock(vgaHWPtr hwp) +{ + /* Unprotect CRTC[0-7] */ + hwp->writeCrtc(hwp, 0x11, hwp->readCrtc(hwp, 0x11) & ~0x80); +} + + +void +vgaHWEnable(vgaHWPtr hwp) +{ + hwp->writeEnable(hwp, hwp->readEnable(hwp) | 0x01); +} + + +void +vgaHWDisable(vgaHWPtr hwp) +{ + hwp->writeEnable(hwp, hwp->readEnable(hwp) & ~0x01); +} + + +static void +vgaHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, + VisualPtr pVisual) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + int i, index; + + for (i = 0; i < numColors; i++) { + index = indices[i]; + hwp->writeDacWriteAddr(hwp, index); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].red); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].green); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].blue); + DACDelay(hwp); + } + + /* This shouldn't be necessary, but we'll play safe. */ + hwp->disablePalette(hwp); +} + + +static void +vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + + if (overscan < 0 || overscan > 255) + return; + + hwp->enablePalette(hwp); + hwp->writeAttr(hwp, OVERSCAN, overscan); + +#ifdef DEBUGOVERSCAN + { + int ov = hwp->readAttr(hwp, OVERSCAN); + int red, green, blue; + + hwp->writeDacReadAddr(hwp, ov); + red = hwp->readDacData(hwp); + green = hwp->readDacData(hwp); + blue = hwp->readDacData(hwp); + ErrorF("Overscan index is 0x%02x, colours are #%02x%02x%02x\n", + ov, red, green, blue); + } +#endif + + hwp->disablePalette(hwp); +} + + +Bool +vgaHWHandleColormaps(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (pScrn->depth > 1 && pScrn->depth <= 8) { + return xf86HandleColormaps(pScreen, 1 << pScrn->depth, + pScrn->rgbBits, vgaHWLoadPalette, + pScrn->depth > 4 ? vgaHWSetOverscan : NULL, + CMAP_RELOAD_ON_MODE_SWITCH); + } + return TRUE; +} + +/* ----------------------- DDC support ------------------------*/ +/* + * Adjust v_active, v_blank, v_sync, v_sync_end, v_blank_end, v_total + * to read out EDID at a faster rate. Allowed maximum is 25kHz with + * 20 usec v_sync active. Set positive v_sync polarity, turn off lightpen + * readback, enable access to cr00-cr07. + */ + +/* vertical timings */ +#define DISPLAY_END 0x04 +#define BLANK_START DISPLAY_END +#define SYNC_START BLANK_START +#define SYNC_END 0x09 +#define BLANK_END SYNC_END +#define V_TOTAL BLANK_END +/* this function doesn't have to be reentrant for our purposes */ +struct _vgaDdcSave { + unsigned char cr03; + unsigned char cr06; + unsigned char cr07; + unsigned char cr09; + unsigned char cr10; + unsigned char cr11; + unsigned char cr12; + unsigned char cr15; + unsigned char cr16; + unsigned char msr; +}; + +void +vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + unsigned char tmp; + struct _vgaDdcSave* save; + switch (speed) { + case DDC_FAST: + + if (hwp->ddc != NULL) break; + hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave),1); + save = (struct _vgaDdcSave *)hwp->ddc; + /* Lightpen register disable - allow access to cr10 & 11; just in case */ + save->cr03 = hwp->readCrtc(hwp, 0x03); + hwp->writeCrtc(hwp,0x03,(save->cr03 |0x80)); + save->cr12 = hwp->readCrtc(hwp, 0x12); + hwp->writeCrtc(hwp,0x12,DISPLAY_END); + save->cr15 = hwp->readCrtc(hwp, 0x15); + hwp->writeCrtc(hwp,0x15,BLANK_START); + save->cr10 = hwp->readCrtc(hwp, 0x10); + hwp->writeCrtc(hwp,0x10,SYNC_START); + save->cr11 = hwp->readCrtc(hwp, 0x11); + /* unprotect group 1 registers; just in case ...*/ + hwp->writeCrtc(hwp,0x11,((save->cr11 & 0x70) | SYNC_END)); + save->cr16 = hwp->readCrtc(hwp, 0x16); + hwp->writeCrtc(hwp,0x16,BLANK_END); + save->cr06 = hwp->readCrtc(hwp, 0x06); + hwp->writeCrtc(hwp,0x06,V_TOTAL); + /* all values have less than 8 bit - mask out 9th and 10th bits */ + save->cr09 = hwp->readCrtc(hwp, 0x09); + hwp->writeCrtc(hwp,0x09,(save->cr09 &0xDF)); + save->cr07 = hwp->readCrtc(hwp, 0x07); + hwp->writeCrtc(hwp,0x07,(save->cr07 &0x10)); + /* vsync polarity negativ & ensure a 25MHz clock */ + save->msr = hwp->readMiscOut(hwp); + hwp->writeMiscOut(hwp,((save->msr & 0xF3) | 0x80)); + break; + case DDC_SLOW: + if (hwp->ddc == NULL) break; + save = (struct _vgaDdcSave *)hwp->ddc; + hwp->writeMiscOut(hwp,save->msr); + hwp->writeCrtc(hwp,0x07,save->cr07); + tmp = hwp->readCrtc(hwp, 0x09); + hwp->writeCrtc(hwp,0x09,((save->cr09 & 0x20) | (tmp & 0xDF))); + hwp->writeCrtc(hwp,0x06,save->cr06); + hwp->writeCrtc(hwp,0x16,save->cr16); + hwp->writeCrtc(hwp,0x11,save->cr11); + hwp->writeCrtc(hwp,0x10,save->cr10); + hwp->writeCrtc(hwp,0x15,save->cr15); + hwp->writeCrtc(hwp,0x12,save->cr12); + hwp->writeCrtc(hwp,0x03,save->cr03); + xfree(save); + hwp->ddc = NULL; + break; + default: + break; + } +} + +DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void) { return vgaHWddc1SetSpeed; } + +SaveScreenProcPtr vgaHWSaveScreenWeak(void) { return vgaHWSaveScreen; } diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.h b/xorg-server/hw/xfree86/vgahw/vgaHW.h new file mode 100644 index 000000000..a38ea7559 --- /dev/null +++ b/xorg-server/hw/xfree86/vgahw/vgaHW.h @@ -0,0 +1,236 @@ + + +/* + * Copyright (c) 1997,1998 The XFree86 Project, Inc. + * + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Author: Dirk Hohndel + */ + +#ifndef _VGAHW_H +#define _VGAHW_H + +#include <X11/X.h> +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" +#include "colormapst.h" + +#include "xf86str.h" +#include "xf86Pci.h" + +#include "xf86DDC.h" + +#include "globals.h" +#define DPMS_SERVER +#include <X11/extensions/dpms.h> + +extern int vgaHWGetIndex(void); + +/* + * access macro + */ +#define VGAHWPTR(p) ((vgaHWPtr)((p)->privates[vgaHWGetIndex()].ptr)) + +/* 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 */ + +/* default number of VGA registers stored internally */ +#define VGA_NUM_CRTC 25 +#define VGA_NUM_SEQ 5 +#define VGA_NUM_GFX 9 +#define VGA_NUM_ATTR 21 + +/* Flags for vgaHWSave() and vgaHWRestore() */ +#define VGA_SR_MODE 0x01 +#define VGA_SR_FONTS 0x02 +#define VGA_SR_CMAP 0x04 +#define VGA_SR_ALL (VGA_SR_MODE | VGA_SR_FONTS | VGA_SR_CMAP) + +/* Defaults for the VGA memory window */ +#define VGA_DEFAULT_PHYS_ADDR 0xA0000 +#define VGA_DEFAULT_MEM_SIZE (64 * 1024) + +/* + * vgaRegRec contains settings of standard VGA registers. + */ +typedef struct { + unsigned char MiscOutReg; /* */ + unsigned char *CRTC; /* Crtc Controller */ + unsigned char *Sequencer; /* Video Sequencer */ + unsigned char *Graphics; /* Video Graphics */ + unsigned char *Attribute; /* Video Atribute */ + unsigned char DAC[768]; /* Internal Colorlookuptable */ + unsigned char numCRTC; /* number of CRTC registers, def=VGA_NUM_CRTC */ + unsigned char numSequencer; /* number of seq registers, def=VGA_NUM_SEQ */ + unsigned char numGraphics; /* number of gfx registers, def=VGA_NUM_GFX */ + unsigned char numAttribute; /* number of attr registers, def=VGA_NUM_ATTR */ +} vgaRegRec, *vgaRegPtr; + +typedef struct _vgaHWRec *vgaHWPtr; + +typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value); +typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx); +typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value); +typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp); +typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp); + + +/* + * vgaHWRec contains per-screen information required by the vgahw module. + * + * Note, the palette referred to by the paletteEnabled, enablePalette and + * disablePalette is the 16-entry (+overscan) EGA-compatible palette accessed + * via the first 17 attribute registers and not the main 8-bit palette. + */ +typedef struct _vgaHWRec { + pointer Base; /* Address of "VGA" memory */ + int MapSize; /* Size of "VGA" memory */ + unsigned long MapPhys; /* phys location of VGA mem */ + int IOBase; /* I/O Base address */ + CARD8 * MMIOBase; /* Pointer to MMIO start */ + int MMIOOffset; /* base + offset + vgareg + = mmioreg */ + pointer FontInfo1; /* save area for fonts in + plane 2 */ + pointer FontInfo2; /* save area for fonts in + plane 3 */ + pointer TextInfo; /* save area for text */ + vgaRegRec SavedReg; /* saved registers */ + vgaRegRec ModeReg; /* register settings for + current mode */ + Bool ShowOverscan; + Bool paletteEnabled; + Bool cmapSaved; + ScrnInfoPtr pScrn; + vgaHWWriteIndexProcPtr writeCrtc; + vgaHWReadIndexProcPtr readCrtc; + vgaHWWriteIndexProcPtr writeGr; + vgaHWReadIndexProcPtr readGr; + vgaHWReadProcPtr readST00; + vgaHWReadProcPtr readST01; + vgaHWReadProcPtr readFCR; + vgaHWWriteProcPtr writeFCR; + vgaHWWriteIndexProcPtr writeAttr; + vgaHWReadIndexProcPtr readAttr; + vgaHWWriteIndexProcPtr writeSeq; + vgaHWReadIndexProcPtr readSeq; + vgaHWWriteProcPtr writeMiscOut; + vgaHWReadProcPtr readMiscOut; + vgaHWMiscProcPtr enablePalette; + vgaHWMiscProcPtr disablePalette; + vgaHWWriteProcPtr writeDacMask; + vgaHWReadProcPtr readDacMask; + vgaHWWriteProcPtr writeDacWriteAddr; + vgaHWWriteProcPtr writeDacReadAddr; + vgaHWWriteProcPtr writeDacData; + vgaHWReadProcPtr readDacData; + pointer ddc; + IOADDRESS PIOOffset; /* offset + vgareg + = pioreg */ + vgaHWReadProcPtr readEnable; + vgaHWWriteProcPtr writeEnable; + struct pci_device *dev; +} vgaHWRec; + +/* Some macros that VGA drivers can use in their ChipProbe() function */ +#define VGAHW_GET_IOBASE() ((inb(VGA_MISC_OUT_R) & 0x01) ? \ + VGA_IOBASE_COLOR : VGA_IOBASE_MONO) + +#define OVERSCAN 0x11 /* Index of OverScan register */ + +/* Flags that define how overscan correction should take place */ +#define KGA_FIX_OVERSCAN 1 /* overcan correction required */ +#define KGA_ENABLE_ON_ZERO 2 /* if possible enable display at beginning */ + /* of next scanline/frame */ +#define KGA_BE_TOT_DEC 4 /* always fix problem by setting blank end */ + /* to total - 1 */ +#define BIT_PLANE 3 /* Which plane we write to in mono mode */ +#define BITS_PER_GUN 6 +#define COLORMAP_SIZE 256 + +#if defined(__powerpc__) || defined(__arm__) || defined(__s390__) +#define DACDelay(hw) /* No legacy VGA support */ +#else +#define DACDelay(hw) \ + do { \ + (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ + (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \ + } while (0) +#endif + +/* Function Prototypes */ + +/* vgaHW.c */ + +typedef void vgaHWProtectProc(ScrnInfoPtr, Bool); +typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool); + +void vgaHWSetStdFuncs(vgaHWPtr hwp); +void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset); +void vgaHWProtect(ScrnInfoPtr pScrn, Bool on); +vgaHWProtectProc *vgaHWProtectWeak(void); +Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode); +void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on); +vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void); +void vgaHWSeqReset(vgaHWPtr hwp, Bool start); +void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore); +void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore); +void vgaHWRestoreColormap(ScrnInfoPtr scrninfp, vgaRegPtr restore); +void vgaHWRestore(ScrnInfoPtr scrninfp, vgaRegPtr restore, int flags); +void vgaHWSaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save); +void vgaHWSaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save); +void vgaHWSaveColormap(ScrnInfoPtr scrninfp, vgaRegPtr save); +void vgaHWSave(ScrnInfoPtr scrninfp, vgaRegPtr save, int flags); +Bool vgaHWInit(ScrnInfoPtr scrnp, DisplayModePtr mode); +Bool vgaHWSetRegCounts(ScrnInfoPtr scrp, int numCRTC, int numSequencer, + int numGraphics, int numAttribute); +Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src); +Bool vgaHWGetHWRec(ScrnInfoPtr scrp); +void vgaHWFreeHWRec(ScrnInfoPtr scrp); +Bool vgaHWMapMem(ScrnInfoPtr scrp); +void vgaHWUnmapMem(ScrnInfoPtr scrp); +void vgaHWGetIOBase(vgaHWPtr hwp); +void vgaHWLock(vgaHWPtr hwp); +void vgaHWUnlock(vgaHWPtr hwp); +void vgaHWEnable(vgaHWPtr hwp); +void vgaHWDisable(vgaHWPtr hwp); +void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); +Bool vgaHWHandleColormaps(ScreenPtr pScreen); +void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed); +CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags); +CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, + unsigned int Flags); +Bool vgaHWAllocDefaultRegs(vgaRegPtr regp); + +DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void); +SaveScreenProcPtr vgaHWSaveScreenWeak(void); + +#endif /* _VGAHW_H */ diff --git a/xorg-server/hw/xfree86/vgahw/vgaHWmodule.c b/xorg-server/hw/xfree86/vgahw/vgaHWmodule.c new file mode 100644 index 000000000..d5c50d9ca --- /dev/null +++ b/xorg-server/hw/xfree86/vgahw/vgaHWmodule.c @@ -0,0 +1,24 @@ +/* + * Copyright 1998 by The XFree86 Project, Inc + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static XF86ModuleVersionInfo VersRec = { + "vgahw", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 0, 1, 0, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0, 0, 0, 0} +}; + +_X_EXPORT XF86ModuleData vgahwModuleData = { &VersRec, NULL, NULL }; diff --git a/xorg-server/hw/xfree86/x86emu/Makefile.am b/xorg-server/hw/xfree86/x86emu/Makefile.am new file mode 100644 index 000000000..acd249c7f --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/Makefile.am @@ -0,0 +1,27 @@ +noinst_LIBRARIES = libx86emu.a + +libx86emu_a_SOURCES = debug.c \ + decode.c \ + fpu.c \ + ops2.c \ + ops.c \ + prim_ops.c \ + sys.c \ + x86emu.h + +INCLUDES = + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +EXTRA_DIST = validate.c \ + x86emu/debug.h \ + x86emu/decode.h \ + x86emu/fpu.h \ + x86emu/fpu_regs.h \ + x86emu/ops.h \ + x86emu/prim_asm.h \ + x86emu/prim_ops.h \ + x86emu/prim_x86_gcc.h \ + x86emu/regs.h \ + x86emu/types.h \ + x86emu/x86emui.h diff --git a/xorg-server/hw/xfree86/x86emu/Makefile.in b/xorg-server/hw/xfree86/x86emu/Makefile.in new file mode 100644 index 000000000..50e43896a --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/Makefile.in @@ -0,0 +1,670 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/x86emu +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libx86emu_a_AR = $(AR) $(ARFLAGS) +libx86emu_a_LIBADD = +am_libx86emu_a_OBJECTS = debug.$(OBJEXT) decode.$(OBJEXT) \ + fpu.$(OBJEXT) ops2.$(OBJEXT) ops.$(OBJEXT) prim_ops.$(OBJEXT) \ + sys.$(OBJEXT) +libx86emu_a_OBJECTS = $(am_libx86emu_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libx86emu_a_SOURCES) +DIST_SOURCES = $(libx86emu_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LIBRARIES = libx86emu.a +libx86emu_a_SOURCES = debug.c \ + decode.c \ + fpu.c \ + ops2.c \ + ops.c \ + prim_ops.c \ + sys.c \ + x86emu.h + +INCLUDES = +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +EXTRA_DIST = validate.c \ + x86emu/debug.h \ + x86emu/decode.h \ + x86emu/fpu.h \ + x86emu/fpu_regs.h \ + x86emu/ops.h \ + x86emu/prim_asm.h \ + x86emu/prim_ops.h \ + x86emu/prim_x86_gcc.h \ + x86emu/regs.h \ + x86emu/types.h \ + x86emu/x86emui.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/x86emu/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/x86emu/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libx86emu.a: $(libx86emu_a_OBJECTS) $(libx86emu_a_DEPENDENCIES) + -rm -f libx86emu.a + $(libx86emu_a_AR) libx86emu.a $(libx86emu_a_OBJECTS) $(libx86emu_a_LIBADD) + $(RANLIB) libx86emu.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ops.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ops2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prim_ops.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sys.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/x86emu/debug.c b/xorg-server/hw/xfree86/x86emu/debug.c new file mode 100644 index 000000000..5eda90805 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/debug.c @@ -0,0 +1,430 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: This file contains the code to handle debugging of the +* emulator. +* +****************************************************************************/ + +#include "x86emu/x86emui.h" +#include <stdio.h> +#include <string.h> +#ifndef NO_SYS_HEADERS +#include <stdarg.h> +#include <stdlib.h> +#endif + +/*----------------------------- Implementation ----------------------------*/ + +#ifdef DEBUG + +static void print_encoded_bytes (u16 s, u16 o); +static void print_decoded_instruction (void); +static int parse_line (char *s, int *ps, int *n); + +/* should look something like debug's output. */ +void X86EMU_trace_regs (void) +{ + if (DEBUG_TRACE()) { + x86emu_dump_regs(); + } + if (DEBUG_DECODE() && ! DEBUG_DECODE_NOPRINT()) { + printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip); + print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip); + print_decoded_instruction(); + } +} + +void X86EMU_trace_xregs (void) +{ + if (DEBUG_TRACE()) { + x86emu_dump_xregs(); + } +} + +void x86emu_just_disassemble (void) +{ + /* + * This routine called if the flag DEBUG_DISASSEMBLE is set kind + * of a hack! + */ + printk("%04x:%04x ",M.x86.saved_cs, M.x86.saved_ip); + print_encoded_bytes( M.x86.saved_cs, M.x86.saved_ip); + print_decoded_instruction(); +} + +static void disassemble_forward (u16 seg, u16 off, int n) +{ + X86EMU_sysEnv tregs; + int i; + u8 op1; + /* + * hack, hack, hack. What we do is use the exact machinery set up + * for execution, except that now there is an additional state + * flag associated with the "execution", and we are using a copy + * of the register struct. All the major opcodes, once fully + * decoded, have the following two steps: TRACE_REGS(r,m); + * SINGLE_STEP(r,m); which disappear if DEBUG is not defined to + * the preprocessor. The TRACE_REGS macro expands to: + * + * if (debug&DEBUG_DISASSEMBLE) + * {just_disassemble(); goto EndOfInstruction;} + * if (debug&DEBUG_TRACE) trace_regs(r,m); + * + * ...... and at the last line of the routine. + * + * EndOfInstruction: end_instr(); + * + * Up to the point where TRACE_REG is expanded, NO modifications + * are done to any register EXCEPT the IP register, for fetch and + * decoding purposes. + * + * This was done for an entirely different reason, but makes a + * nice way to get the system to help debug codes. + */ + tregs = M; + tregs.x86.R_IP = off; + tregs.x86.R_CS = seg; + + /* reset the decoding buffers */ + tregs.x86.enc_str_pos = 0; + tregs.x86.enc_pos = 0; + + /* turn on the "disassemble only, no execute" flag */ + tregs.x86.debug |= DEBUG_DISASSEMBLE_F; + + /* DUMP NEXT n instructions to screen in straight_line fashion */ + /* + * This looks like the regular instruction fetch stream, except + * that when this occurs, each fetched opcode, upon seeing the + * DEBUG_DISASSEMBLE flag set, exits immediately after decoding + * the instruction. XXX --- CHECK THAT MEM IS NOT AFFECTED!!! + * Note the use of a copy of the register structure... + */ + for (i=0; i<n; i++) { + op1 = (*sys_rdb)(((u32)M.x86.R_CS<<4) + (M.x86.R_IP++)); + (x86emu_optab[op1])(op1); + } + /* end major hack mode. */ +} + +void x86emu_check_ip_access (void) +{ + /* NULL as of now */ +} + +void x86emu_check_sp_access (void) +{ +} + +void x86emu_check_mem_access (u32 dummy) +{ + /* check bounds, etc */ +} + +void x86emu_check_data_access (uint dummy1, uint dummy2) +{ + /* check bounds, etc */ +} + +void x86emu_inc_decoded_inst_len (int x) +{ + M.x86.enc_pos += x; +} + +void x86emu_decode_printf (char *x) +{ + sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",x); + M.x86.enc_str_pos += strlen(x); +} + +void x86emu_decode_printf2 (char *x, int y) +{ + char temp[100]; + sprintf(temp,x,y); + sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",temp); + M.x86.enc_str_pos += strlen(temp); +} + +void x86emu_end_instr (void) +{ + M.x86.enc_str_pos = 0; + M.x86.enc_pos = 0; +} + +static void print_encoded_bytes (u16 s, u16 o) +{ + int i; + char buf1[64]; + for (i=0; i< M.x86.enc_pos; i++) { + sprintf(buf1+2*i,"%02x", fetch_data_byte_abs(s,o+i)); + } + printk("%-20s",buf1); +} + +static void print_decoded_instruction (void) +{ + printk("%s", M.x86.decoded_buf); +} + +void x86emu_print_int_vect (u16 iv) +{ + u16 seg,off; + + if (iv > 256) return; + seg = fetch_data_word_abs(0,iv*4); + off = fetch_data_word_abs(0,iv*4+2); + printk("%04x:%04x ", seg, off); +} + +void X86EMU_dump_memory (u16 seg, u16 off, u32 amt) +{ + u32 start = off & 0xfffffff0; + u32 end = (off+16) & 0xfffffff0; + u32 i; + u32 current; + + current = start; + while (end <= off + amt) { + printk("%04x:%04x ", seg, start); + for (i=start; i< off; i++) + printk(" "); + for ( ; i< end; i++) + printk("%02x ", fetch_data_byte_abs(seg,i)); + printk("\n"); + start = end; + end = start + 16; + } +} + +void x86emu_single_step (void) +{ + char s[1024]; + int ps[10]; + int ntok; + int cmd; + int done; + int segment; + int offset; + static int breakpoint; + static int noDecode = 1; + + char *p; + + if (DEBUG_BREAK()) { + if (M.x86.saved_ip != breakpoint) { + return; + } else { + M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F; + M.x86.debug |= DEBUG_TRACE_F; + M.x86.debug &= ~DEBUG_BREAK_F; + print_decoded_instruction (); + X86EMU_trace_regs(); + } + } + done=0; + offset = M.x86.saved_ip; + while (!done) { + printk("-"); + p = fgets(s, 1023, stdin); + cmd = parse_line(s, ps, &ntok); + switch(cmd) { + case 'u': + disassemble_forward(M.x86.saved_cs,(u16)offset,10); + break; + case 'd': + if (ntok == 2) { + segment = M.x86.saved_cs; + offset = ps[1]; + X86EMU_dump_memory(segment,(u16)offset,16); + offset += 16; + } else if (ntok == 3) { + segment = ps[1]; + offset = ps[2]; + X86EMU_dump_memory(segment,(u16)offset,16); + offset += 16; + } else { + segment = M.x86.saved_cs; + X86EMU_dump_memory(segment,(u16)offset,16); + offset += 16; + } + break; + case 'c': + M.x86.debug ^= DEBUG_TRACECALL_F; + break; + case 's': + M.x86.debug ^= DEBUG_SVC_F | DEBUG_SYS_F | DEBUG_SYSINT_F; + break; + case 'r': + X86EMU_trace_regs(); + break; + case 'x': + X86EMU_trace_xregs(); + break; + case 'g': + if (ntok == 2) { + breakpoint = ps[1]; + if (noDecode) { + M.x86.debug |= DEBUG_DECODE_NOPRINT_F; + } else { + M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F; + } + M.x86.debug &= ~DEBUG_TRACE_F; + M.x86.debug |= DEBUG_BREAK_F; + done = 1; + } + break; + case 'q': + M.x86.debug |= DEBUG_EXIT; + return; + case 'P': + noDecode = (noDecode)?0:1; + printk("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE"); + break; + case 't': + case 0: + done = 1; + break; + } + } +} + +int X86EMU_trace_on(void) +{ + return M.x86.debug |= DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F; +} + +int X86EMU_trace_off(void) +{ + return M.x86.debug &= ~(DEBUG_STEP_F | DEBUG_DECODE_F | DEBUG_TRACE_F); +} + +static int parse_line (char *s, int *ps, int *n) +{ + int cmd; + + *n = 0; + while(*s == ' ' || *s == '\t') s++; + ps[*n] = *s; + switch (*s) { + case '\n': + *n += 1; + return 0; + default: + cmd = *s; + *n += 1; + } + + while (1) { + while (*s != ' ' && *s != '\t' && *s != '\n') s++; + + if (*s == '\n') + return cmd; + + while(*s == ' ' || *s == '\t') s++; + + sscanf(s,"%x",&ps[*n]); + *n += 1; + } +} + +#endif /* DEBUG */ + +void x86emu_dump_regs (void) +{ + printk("\tAX=%04x ", M.x86.R_AX ); + printk("BX=%04x ", M.x86.R_BX ); + printk("CX=%04x ", M.x86.R_CX ); + printk("DX=%04x ", M.x86.R_DX ); + printk("SP=%04x ", M.x86.R_SP ); + printk("BP=%04x ", M.x86.R_BP ); + printk("SI=%04x ", M.x86.R_SI ); + printk("DI=%04x\n", M.x86.R_DI ); + printk("\tDS=%04x ", M.x86.R_DS ); + printk("ES=%04x ", M.x86.R_ES ); + printk("SS=%04x ", M.x86.R_SS ); + printk("CS=%04x ", M.x86.R_CS ); + printk("IP=%04x ", M.x86.R_IP ); + if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */ + else printk("NV "); + if (ACCESS_FLAG(F_DF)) printk("DN "); + else printk("UP "); + if (ACCESS_FLAG(F_IF)) printk("EI "); + else printk("DI "); + if (ACCESS_FLAG(F_SF)) printk("NG "); + else printk("PL "); + if (ACCESS_FLAG(F_ZF)) printk("ZR "); + else printk("NZ "); + if (ACCESS_FLAG(F_AF)) printk("AC "); + else printk("NA "); + if (ACCESS_FLAG(F_PF)) printk("PE "); + else printk("PO "); + if (ACCESS_FLAG(F_CF)) printk("CY "); + else printk("NC "); + printk("\n"); +} + +void x86emu_dump_xregs (void) +{ + printk("\tEAX=%08x ", M.x86.R_EAX ); + printk("EBX=%08x ", M.x86.R_EBX ); + printk("ECX=%08x ", M.x86.R_ECX ); + printk("EDX=%08x \n", M.x86.R_EDX ); + printk("\tESP=%08x ", M.x86.R_ESP ); + printk("EBP=%08x ", M.x86.R_EBP ); + printk("ESI=%08x ", M.x86.R_ESI ); + printk("EDI=%08x\n", M.x86.R_EDI ); + printk("\tDS=%04x ", M.x86.R_DS ); + printk("ES=%04x ", M.x86.R_ES ); + printk("SS=%04x ", M.x86.R_SS ); + printk("CS=%04x ", M.x86.R_CS ); + printk("EIP=%08x\n\t", M.x86.R_EIP ); + if (ACCESS_FLAG(F_OF)) printk("OV "); /* CHECKED... */ + else printk("NV "); + if (ACCESS_FLAG(F_DF)) printk("DN "); + else printk("UP "); + if (ACCESS_FLAG(F_IF)) printk("EI "); + else printk("DI "); + if (ACCESS_FLAG(F_SF)) printk("NG "); + else printk("PL "); + if (ACCESS_FLAG(F_ZF)) printk("ZR "); + else printk("NZ "); + if (ACCESS_FLAG(F_AF)) printk("AC "); + else printk("NA "); + if (ACCESS_FLAG(F_PF)) printk("PE "); + else printk("PO "); + if (ACCESS_FLAG(F_CF)) printk("CY "); + else printk("NC "); + printk("\n"); +} diff --git a/xorg-server/hw/xfree86/x86emu/decode.c b/xorg-server/hw/xfree86/x86emu/decode.c new file mode 100644 index 000000000..9339f4c7f --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/decode.c @@ -0,0 +1,1092 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: This file includes subroutines which are related to +* instruction decoding and accessess of immediate data via IP. etc. +* +****************************************************************************/ + +#include <stdlib.h> +#include "x86emu/x86emui.h" + +/*----------------------------- Implementation ----------------------------*/ + +/**************************************************************************** +REMARKS: +Handles any pending asychronous interrupts. +****************************************************************************/ +static void x86emu_intr_handle(void) +{ + u8 intno; + + if (M.x86.intr & INTR_SYNCH) { + intno = M.x86.intno; + if (_X86EMU_intrTab[intno]) { + (*_X86EMU_intrTab[intno])(intno); + } else { + push_word((u16)M.x86.R_FLG); + CLEAR_FLAG(F_IF); + CLEAR_FLAG(F_TF); + push_word(M.x86.R_CS); + M.x86.R_CS = mem_access_word(intno * 4 + 2); + push_word(M.x86.R_IP); + M.x86.R_IP = mem_access_word(intno * 4); + M.x86.intr = 0; + } + } +} + +/**************************************************************************** +PARAMETERS: +intrnum - Interrupt number to raise + +REMARKS: +Raise the specified interrupt to be handled before the execution of the +next instruction. +****************************************************************************/ +void x86emu_intr_raise( + u8 intrnum) +{ + M.x86.intno = intrnum; + M.x86.intr |= INTR_SYNCH; +} + +/**************************************************************************** +REMARKS: +Main execution loop for the emulator. We return from here when the system +halts, which is normally caused by a stack fault when we return from the +original real mode call. +****************************************************************************/ +void X86EMU_exec(void) +{ + u8 op1; + + M.x86.intr = 0; + DB(x86emu_end_instr();) + + for (;;) { +DB( if (CHECK_IP_FETCH()) + x86emu_check_ip_access();) + /* If debugging, save the IP and CS values. */ + SAVE_IP_CS(M.x86.R_CS, M.x86.R_IP); + INC_DECODED_INST_LEN(1); + if (M.x86.intr) { + if (M.x86.intr & INTR_HALTED) { +DB( if (M.x86.R_SP != 0) { + printk("halted\n"); + X86EMU_trace_regs(); + } + else { + if (M.x86.debug) + printk("Service completed successfully\n"); + }) + return; + } + if (((M.x86.intr & INTR_SYNCH) && (M.x86.intno == 0 || M.x86.intno == 2)) || + !ACCESS_FLAG(F_IF)) { + x86emu_intr_handle(); + } + } + op1 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); + (*x86emu_optab[op1])(op1); + if (M.x86.debug & DEBUG_EXIT) { + M.x86.debug &= ~DEBUG_EXIT; + return; + } + } +} + +/**************************************************************************** +REMARKS: +Halts the system by setting the halted system flag. +****************************************************************************/ +void X86EMU_halt_sys(void) +{ + M.x86.intr |= INTR_HALTED; +} + +/**************************************************************************** +PARAMETERS: +mod - Mod value from decoded byte +regh - Reg h value from decoded byte +regl - Reg l value from decoded byte + +REMARKS: +Raise the specified interrupt to be handled before the execution of the +next instruction. + +NOTE: Do not inline this function, as (*sys_rdb) is already inline! +****************************************************************************/ +void fetch_decode_modrm( + int *mod, + int *regh, + int *regl) +{ + int fetched; + +DB( if (CHECK_IP_FETCH()) + x86emu_check_ip_access();) + fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); + INC_DECODED_INST_LEN(1); + *mod = (fetched >> 6) & 0x03; + *regh = (fetched >> 3) & 0x07; + *regl = (fetched >> 0) & 0x07; +} + +/**************************************************************************** +RETURNS: +Immediate byte value read from instruction queue + +REMARKS: +This function returns the immediate byte from the instruction queue, and +moves the instruction pointer to the next value. + +NOTE: Do not inline this function, as (*sys_rdb) is already inline! +****************************************************************************/ +u8 fetch_byte_imm(void) +{ + u8 fetched; + +DB( if (CHECK_IP_FETCH()) + x86emu_check_ip_access();) + fetched = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); + INC_DECODED_INST_LEN(1); + return fetched; +} + +/**************************************************************************** +RETURNS: +Immediate word value read from instruction queue + +REMARKS: +This function returns the immediate byte from the instruction queue, and +moves the instruction pointer to the next value. + +NOTE: Do not inline this function, as (*sys_rdw) is already inline! +****************************************************************************/ +u16 fetch_word_imm(void) +{ + u16 fetched; + +DB( if (CHECK_IP_FETCH()) + x86emu_check_ip_access();) + fetched = (*sys_rdw)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP)); + M.x86.R_IP += 2; + INC_DECODED_INST_LEN(2); + return fetched; +} + +/**************************************************************************** +RETURNS: +Immediate lone value read from instruction queue + +REMARKS: +This function returns the immediate byte from the instruction queue, and +moves the instruction pointer to the next value. + +NOTE: Do not inline this function, as (*sys_rdw) is already inline! +****************************************************************************/ +u32 fetch_long_imm(void) +{ + u32 fetched; + +DB( if (CHECK_IP_FETCH()) + x86emu_check_ip_access();) + fetched = (*sys_rdl)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP)); + M.x86.R_IP += 4; + INC_DECODED_INST_LEN(4); + return fetched; +} + +/**************************************************************************** +RETURNS: +Value of the default data segment + +REMARKS: +Inline function that returns the default data segment for the current +instruction. + +On the x86 processor, the default segment is not always DS if there is +no segment override. Address modes such as -3[BP] or 10[BP+SI] all refer to +addresses relative to SS (ie: on the stack). So, at the minimum, all +decodings of addressing modes would have to set/clear a bit describing +whether the access is relative to DS or SS. That is the function of the +cpu-state-varible M.x86.mode. There are several potential states: + + repe prefix seen (handled elsewhere) + repne prefix seen (ditto) + + cs segment override + ds segment override + es segment override + fs segment override + gs segment override + ss segment override + + ds/ss select (in absense of override) + +Each of the above 7 items are handled with a bit in the mode field. +****************************************************************************/ +_INLINE u32 get_data_segment(void) +{ +#define GET_SEGMENT(segment) + switch (M.x86.mode & SYSMODE_SEGMASK) { + case 0: /* default case: use ds register */ + case SYSMODE_SEGOVR_DS: + case SYSMODE_SEGOVR_DS | SYSMODE_SEG_DS_SS: + return M.x86.R_DS; + case SYSMODE_SEG_DS_SS: /* non-overridden, use ss register */ + return M.x86.R_SS; + case SYSMODE_SEGOVR_CS: + case SYSMODE_SEGOVR_CS | SYSMODE_SEG_DS_SS: + return M.x86.R_CS; + case SYSMODE_SEGOVR_ES: + case SYSMODE_SEGOVR_ES | SYSMODE_SEG_DS_SS: + return M.x86.R_ES; + case SYSMODE_SEGOVR_FS: + case SYSMODE_SEGOVR_FS | SYSMODE_SEG_DS_SS: + return M.x86.R_FS; + case SYSMODE_SEGOVR_GS: + case SYSMODE_SEGOVR_GS | SYSMODE_SEG_DS_SS: + return M.x86.R_GS; + case SYSMODE_SEGOVR_SS: + case SYSMODE_SEGOVR_SS | SYSMODE_SEG_DS_SS: + return M.x86.R_SS; + default: +#ifdef DEBUG + printk("error: should not happen: multiple overrides.\n"); +#endif + HALT_SYS(); + return 0; + } +} + +/**************************************************************************** +PARAMETERS: +offset - Offset to load data from + +RETURNS: +Byte value read from the absolute memory location. + +NOTE: Do not inline this function as (*sys_rdX) is already inline! +****************************************************************************/ +u8 fetch_data_byte( + uint offset) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access((u16)get_data_segment(), offset); +#endif + return (*sys_rdb)((get_data_segment() << 4) + offset); +} + +/**************************************************************************** +PARAMETERS: +offset - Offset to load data from + +RETURNS: +Word value read from the absolute memory location. + +NOTE: Do not inline this function as (*sys_rdX) is already inline! +****************************************************************************/ +u16 fetch_data_word( + uint offset) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access((u16)get_data_segment(), offset); +#endif + return (*sys_rdw)((get_data_segment() << 4) + offset); +} + +/**************************************************************************** +PARAMETERS: +offset - Offset to load data from + +RETURNS: +Long value read from the absolute memory location. + +NOTE: Do not inline this function as (*sys_rdX) is already inline! +****************************************************************************/ +u32 fetch_data_long( + uint offset) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access((u16)get_data_segment(), offset); +#endif + return (*sys_rdl)((get_data_segment() << 4) + offset); +} + +/**************************************************************************** +PARAMETERS: +segment - Segment to load data from +offset - Offset to load data from + +RETURNS: +Byte value read from the absolute memory location. + +NOTE: Do not inline this function as (*sys_rdX) is already inline! +****************************************************************************/ +u8 fetch_data_byte_abs( + uint segment, + uint offset) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access(segment, offset); +#endif + return (*sys_rdb)(((u32)segment << 4) + offset); +} + +/**************************************************************************** +PARAMETERS: +segment - Segment to load data from +offset - Offset to load data from + +RETURNS: +Word value read from the absolute memory location. + +NOTE: Do not inline this function as (*sys_rdX) is already inline! +****************************************************************************/ +u16 fetch_data_word_abs( + uint segment, + uint offset) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access(segment, offset); +#endif + return (*sys_rdw)(((u32)segment << 4) + offset); +} + +/**************************************************************************** +PARAMETERS: +segment - Segment to load data from +offset - Offset to load data from + +RETURNS: +Long value read from the absolute memory location. + +NOTE: Do not inline this function as (*sys_rdX) is already inline! +****************************************************************************/ +u32 fetch_data_long_abs( + uint segment, + uint offset) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access(segment, offset); +#endif + return (*sys_rdl)(((u32)segment << 4) + offset); +} + +/**************************************************************************** +PARAMETERS: +offset - Offset to store data at +val - Value to store + +REMARKS: +Writes a word value to an segmented memory location. The segment used is +the current 'default' segment, which may have been overridden. + +NOTE: Do not inline this function as (*sys_wrX) is already inline! +****************************************************************************/ +void store_data_byte( + uint offset, + u8 val) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access((u16)get_data_segment(), offset); +#endif + (*sys_wrb)((get_data_segment() << 4) + offset, val); +} + +/**************************************************************************** +PARAMETERS: +offset - Offset to store data at +val - Value to store + +REMARKS: +Writes a word value to an segmented memory location. The segment used is +the current 'default' segment, which may have been overridden. + +NOTE: Do not inline this function as (*sys_wrX) is already inline! +****************************************************************************/ +void store_data_word( + uint offset, + u16 val) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access((u16)get_data_segment(), offset); +#endif + (*sys_wrw)((get_data_segment() << 4) + offset, val); +} + +/**************************************************************************** +PARAMETERS: +offset - Offset to store data at +val - Value to store + +REMARKS: +Writes a long value to an segmented memory location. The segment used is +the current 'default' segment, which may have been overridden. + +NOTE: Do not inline this function as (*sys_wrX) is already inline! +****************************************************************************/ +void store_data_long( + uint offset, + u32 val) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access((u16)get_data_segment(), offset); +#endif + (*sys_wrl)((get_data_segment() << 4) + offset, val); +} + +/**************************************************************************** +PARAMETERS: +segment - Segment to store data at +offset - Offset to store data at +val - Value to store + +REMARKS: +Writes a byte value to an absolute memory location. + +NOTE: Do not inline this function as (*sys_wrX) is already inline! +****************************************************************************/ +void store_data_byte_abs( + uint segment, + uint offset, + u8 val) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access(segment, offset); +#endif + (*sys_wrb)(((u32)segment << 4) + offset, val); +} + +/**************************************************************************** +PARAMETERS: +segment - Segment to store data at +offset - Offset to store data at +val - Value to store + +REMARKS: +Writes a word value to an absolute memory location. + +NOTE: Do not inline this function as (*sys_wrX) is already inline! +****************************************************************************/ +void store_data_word_abs( + uint segment, + uint offset, + u16 val) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access(segment, offset); +#endif + (*sys_wrw)(((u32)segment << 4) + offset, val); +} + +/**************************************************************************** +PARAMETERS: +segment - Segment to store data at +offset - Offset to store data at +val - Value to store + +REMARKS: +Writes a long value to an absolute memory location. + +NOTE: Do not inline this function as (*sys_wrX) is already inline! +****************************************************************************/ +void store_data_long_abs( + uint segment, + uint offset, + u32 val) +{ +#ifdef DEBUG + if (CHECK_DATA_ACCESS()) + x86emu_check_data_access(segment, offset); +#endif + (*sys_wrl)(((u32)segment << 4) + offset, val); +} + +/**************************************************************************** +PARAMETERS: +reg - Register to decode + +RETURNS: +Pointer to the appropriate register + +REMARKS: +Return a pointer to the register given by the R/RM field of the +modrm byte, for byte operands. Also enables the decoding of instructions. +****************************************************************************/ +u8* decode_rm_byte_register( + int reg) +{ + switch (reg) { + case 0: + DECODE_PRINTF("AL"); + return &M.x86.R_AL; + case 1: + DECODE_PRINTF("CL"); + return &M.x86.R_CL; + case 2: + DECODE_PRINTF("DL"); + return &M.x86.R_DL; + case 3: + DECODE_PRINTF("BL"); + return &M.x86.R_BL; + case 4: + DECODE_PRINTF("AH"); + return &M.x86.R_AH; + case 5: + DECODE_PRINTF("CH"); + return &M.x86.R_CH; + case 6: + DECODE_PRINTF("DH"); + return &M.x86.R_DH; + case 7: + DECODE_PRINTF("BH"); + return &M.x86.R_BH; + } + HALT_SYS(); + return NULL; /* NOT REACHED OR REACHED ON ERROR */ +} + +/**************************************************************************** +PARAMETERS: +reg - Register to decode + +RETURNS: +Pointer to the appropriate register + +REMARKS: +Return a pointer to the register given by the R/RM field of the +modrm byte, for word operands. Also enables the decoding of instructions. +****************************************************************************/ +u16* decode_rm_word_register( + int reg) +{ + switch (reg) { + case 0: + DECODE_PRINTF("AX"); + return &M.x86.R_AX; + case 1: + DECODE_PRINTF("CX"); + return &M.x86.R_CX; + case 2: + DECODE_PRINTF("DX"); + return &M.x86.R_DX; + case 3: + DECODE_PRINTF("BX"); + return &M.x86.R_BX; + case 4: + DECODE_PRINTF("SP"); + return &M.x86.R_SP; + case 5: + DECODE_PRINTF("BP"); + return &M.x86.R_BP; + case 6: + DECODE_PRINTF("SI"); + return &M.x86.R_SI; + case 7: + DECODE_PRINTF("DI"); + return &M.x86.R_DI; + } + HALT_SYS(); + return NULL; /* NOTREACHED OR REACHED ON ERROR */ +} + +/**************************************************************************** +PARAMETERS: +reg - Register to decode + +RETURNS: +Pointer to the appropriate register + +REMARKS: +Return a pointer to the register given by the R/RM field of the +modrm byte, for dword operands. Also enables the decoding of instructions. +****************************************************************************/ +u32* decode_rm_long_register( + int reg) +{ + switch (reg) { + case 0: + DECODE_PRINTF("EAX"); + return &M.x86.R_EAX; + case 1: + DECODE_PRINTF("ECX"); + return &M.x86.R_ECX; + case 2: + DECODE_PRINTF("EDX"); + return &M.x86.R_EDX; + case 3: + DECODE_PRINTF("EBX"); + return &M.x86.R_EBX; + case 4: + DECODE_PRINTF("ESP"); + return &M.x86.R_ESP; + case 5: + DECODE_PRINTF("EBP"); + return &M.x86.R_EBP; + case 6: + DECODE_PRINTF("ESI"); + return &M.x86.R_ESI; + case 7: + DECODE_PRINTF("EDI"); + return &M.x86.R_EDI; + } + HALT_SYS(); + return NULL; /* NOTREACHED OR REACHED ON ERROR */ +} + +/**************************************************************************** +PARAMETERS: +reg - Register to decode + +RETURNS: +Pointer to the appropriate register + +REMARKS: +Return a pointer to the register given by the R/RM field of the +modrm byte, for word operands, modified from above for the weirdo +special case of segreg operands. Also enables the decoding of instructions. +****************************************************************************/ +u16* decode_rm_seg_register( + int reg) +{ + switch (reg) { + case 0: + DECODE_PRINTF("ES"); + return &M.x86.R_ES; + case 1: + DECODE_PRINTF("CS"); + return &M.x86.R_CS; + case 2: + DECODE_PRINTF("SS"); + return &M.x86.R_SS; + case 3: + DECODE_PRINTF("DS"); + return &M.x86.R_DS; + case 4: + DECODE_PRINTF("FS"); + return &M.x86.R_FS; + case 5: + DECODE_PRINTF("GS"); + return &M.x86.R_GS; + case 6: + case 7: + DECODE_PRINTF("ILLEGAL SEGREG"); + break; + } + HALT_SYS(); + return NULL; /* NOT REACHED OR REACHED ON ERROR */ +} + +/* + * + * return offset from the SIB Byte + */ +u32 decode_sib_address(int sib, int mod) +{ + u32 base = 0, i = 0, scale = 1; + + switch(sib & 0x07) { + case 0: + DECODE_PRINTF("[EAX]"); + base = M.x86.R_EAX; + break; + case 1: + DECODE_PRINTF("[ECX]"); + base = M.x86.R_ECX; + break; + case 2: + DECODE_PRINTF("[EDX]"); + base = M.x86.R_EDX; + break; + case 3: + DECODE_PRINTF("[EBX]"); + base = M.x86.R_EBX; + break; + case 4: + DECODE_PRINTF("[ESP]"); + base = M.x86.R_ESP; + M.x86.mode |= SYSMODE_SEG_DS_SS; + break; + case 5: + if (mod == 0) { + base = fetch_long_imm(); + DECODE_PRINTF2("%08x", base); + } else { + DECODE_PRINTF("[EBP]"); + base = M.x86.R_ESP; + M.x86.mode |= SYSMODE_SEG_DS_SS; + } + break; + case 6: + DECODE_PRINTF("[ESI]"); + base = M.x86.R_ESI; + break; + case 7: + DECODE_PRINTF("[EDI]"); + base = M.x86.R_EDI; + break; + } + switch ((sib >> 3) & 0x07) { + case 0: + DECODE_PRINTF("[EAX"); + i = M.x86.R_EAX; + break; + case 1: + DECODE_PRINTF("[ECX"); + i = M.x86.R_ECX; + break; + case 2: + DECODE_PRINTF("[EDX"); + i = M.x86.R_EDX; + break; + case 3: + DECODE_PRINTF("[EBX"); + i = M.x86.R_EBX; + break; + case 4: + i = 0; + break; + case 5: + DECODE_PRINTF("[EBP"); + i = M.x86.R_EBP; + break; + case 6: + DECODE_PRINTF("[ESI"); + i = M.x86.R_ESI; + break; + case 7: + DECODE_PRINTF("[EDI"); + i = M.x86.R_EDI; + break; + } + scale = 1 << ((sib >> 6) & 0x03); + if (((sib >> 3) & 0x07) != 4) { + if (scale == 1) { + DECODE_PRINTF("]"); + } else { + DECODE_PRINTF2("*%d]", scale); + } + } + return base + (i * scale); +} + +/**************************************************************************** +PARAMETERS: +rm - RM value to decode + +RETURNS: +Offset in memory for the address decoding + +REMARKS: +Return the offset given by mod=00 addressing. Also enables the +decoding of instructions. + +NOTE: The code which specifies the corresponding segment (ds vs ss) + below in the case of [BP+..]. The assumption here is that at the + point that this subroutine is called, the bit corresponding to + SYSMODE_SEG_DS_SS will be zero. After every instruction + except the segment override instructions, this bit (as well + as any bits indicating segment overrides) will be clear. So + if a SS access is needed, set this bit. Otherwise, DS access + occurs (unless any of the segment override bits are set). +****************************************************************************/ +u32 decode_rm00_address( + int rm) +{ + u32 offset; + int sib; + + if (M.x86.mode & SYSMODE_PREFIX_ADDR) { + /* 32-bit addressing */ + switch (rm) { + case 0: + DECODE_PRINTF("[EAX]"); + return M.x86.R_EAX; + case 1: + DECODE_PRINTF("[ECX]"); + return M.x86.R_ECX; + case 2: + DECODE_PRINTF("[EDX]"); + return M.x86.R_EDX; + case 3: + DECODE_PRINTF("[EBX]"); + return M.x86.R_EBX; + case 4: + sib = fetch_byte_imm(); + return decode_sib_address(sib, 0); + case 5: + offset = fetch_long_imm(); + DECODE_PRINTF2("[%08x]", offset); + return offset; + case 6: + DECODE_PRINTF("[ESI]"); + return M.x86.R_ESI; + case 7: + DECODE_PRINTF("[EDI]"); + return M.x86.R_EDI; + } + HALT_SYS(); + } else { + /* 16-bit addressing */ + switch (rm) { + case 0: + DECODE_PRINTF("[BX+SI]"); + return (M.x86.R_BX + M.x86.R_SI) & 0xffff; + case 1: + DECODE_PRINTF("[BX+DI]"); + return (M.x86.R_BX + M.x86.R_DI) & 0xffff; + case 2: + DECODE_PRINTF("[BP+SI]"); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + M.x86.R_SI) & 0xffff; + case 3: + DECODE_PRINTF("[BP+DI]"); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + M.x86.R_DI) & 0xffff; + case 4: + DECODE_PRINTF("[SI]"); + return M.x86.R_SI; + case 5: + DECODE_PRINTF("[DI]"); + return M.x86.R_DI; + case 6: + offset = fetch_word_imm(); + DECODE_PRINTF2("[%04x]", offset); + return offset; + case 7: + DECODE_PRINTF("[BX]"); + return M.x86.R_BX; + } + HALT_SYS(); + } + return 0; +} + +/**************************************************************************** +PARAMETERS: +rm - RM value to decode + +RETURNS: +Offset in memory for the address decoding + +REMARKS: +Return the offset given by mod=01 addressing. Also enables the +decoding of instructions. +****************************************************************************/ +u32 decode_rm01_address( + int rm) +{ + int displacement = 0; + int sib; + + /* Fetch disp8 if no SIB byte */ + if (!((M.x86.mode & SYSMODE_PREFIX_ADDR) && (rm == 4))) + displacement = (s8)fetch_byte_imm(); + + if (M.x86.mode & SYSMODE_PREFIX_ADDR) { + /* 32-bit addressing */ + switch (rm) { + case 0: + DECODE_PRINTF2("%d[EAX]", displacement); + return M.x86.R_EAX + displacement; + case 1: + DECODE_PRINTF2("%d[ECX]", displacement); + return M.x86.R_ECX + displacement; + case 2: + DECODE_PRINTF2("%d[EDX]", displacement); + return M.x86.R_EDX + displacement; + case 3: + DECODE_PRINTF2("%d[EBX]", displacement); + return M.x86.R_EBX + displacement; + case 4: + sib = fetch_byte_imm(); + displacement = (s8)fetch_byte_imm(); + DECODE_PRINTF2("%d", displacement); + return decode_sib_address(sib, 1) + displacement; + case 5: + DECODE_PRINTF2("%d[EBP]", displacement); + return M.x86.R_EBP + displacement; + case 6: + DECODE_PRINTF2("%d[ESI]", displacement); + return M.x86.R_ESI + displacement; + case 7: + DECODE_PRINTF2("%d[EDI]", displacement); + return M.x86.R_EDI + displacement; + } + HALT_SYS(); + } else { + /* 16-bit addressing */ + switch (rm) { + case 0: + DECODE_PRINTF2("%d[BX+SI]", displacement); + return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff; + case 1: + DECODE_PRINTF2("%d[BX+DI]", displacement); + return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff; + case 2: + DECODE_PRINTF2("%d[BP+SI]", displacement); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff; + case 3: + DECODE_PRINTF2("%d[BP+DI]", displacement); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff; + case 4: + DECODE_PRINTF2("%d[SI]", displacement); + return (M.x86.R_SI + displacement) & 0xffff; + case 5: + DECODE_PRINTF2("%d[DI]", displacement); + return (M.x86.R_DI + displacement) & 0xffff; + case 6: + DECODE_PRINTF2("%d[BP]", displacement); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + displacement) & 0xffff; + case 7: + DECODE_PRINTF2("%d[BX]", displacement); + return (M.x86.R_BX + displacement) & 0xffff; + } + HALT_SYS(); + } + return 0; /* SHOULD NOT HAPPEN */ +} + +/**************************************************************************** +PARAMETERS: +rm - RM value to decode + +RETURNS: +Offset in memory for the address decoding + +REMARKS: +Return the offset given by mod=10 addressing. Also enables the +decoding of instructions. +****************************************************************************/ +u32 decode_rm10_address( + int rm) +{ + u32 displacement = 0; + int sib; + + /* Fetch disp16 if 16-bit addr mode */ + if (!(M.x86.mode & SYSMODE_PREFIX_ADDR)) + displacement = (u16)fetch_word_imm(); + else { + /* Fetch disp32 if no SIB byte */ + if (rm != 4) + displacement = (u32)fetch_long_imm(); + } + + if (M.x86.mode & SYSMODE_PREFIX_ADDR) { + /* 32-bit addressing */ + switch (rm) { + case 0: + DECODE_PRINTF2("%08x[EAX]", displacement); + return M.x86.R_EAX + displacement; + case 1: + DECODE_PRINTF2("%08x[ECX]", displacement); + return M.x86.R_ECX + displacement; + case 2: + DECODE_PRINTF2("%08x[EDX]", displacement); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return M.x86.R_EDX + displacement; + case 3: + DECODE_PRINTF2("%08x[EBX]", displacement); + return M.x86.R_EBX + displacement; + case 4: + sib = fetch_byte_imm(); + displacement = (u32)fetch_long_imm(); + DECODE_PRINTF2("%08x", displacement); + return decode_sib_address(sib, 2) + displacement; + break; + case 5: + DECODE_PRINTF2("%08x[EBP]", displacement); + return M.x86.R_EBP + displacement; + case 6: + DECODE_PRINTF2("%08x[ESI]", displacement); + return M.x86.R_ESI + displacement; + case 7: + DECODE_PRINTF2("%08x[EDI]", displacement); + return M.x86.R_EDI + displacement; + } + HALT_SYS(); + } else { + /* 16-bit addressing */ + switch (rm) { + case 0: + DECODE_PRINTF2("%04x[BX+SI]", displacement); + return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff; + case 1: + DECODE_PRINTF2("%04x[BX+DI]", displacement); + return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff; + case 2: + DECODE_PRINTF2("%04x[BP+SI]", displacement); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff; + case 3: + DECODE_PRINTF2("%04x[BP+DI]", displacement); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff; + case 4: + DECODE_PRINTF2("%04x[SI]", displacement); + return (M.x86.R_SI + displacement) & 0xffff; + case 5: + DECODE_PRINTF2("%04x[DI]", displacement); + return (M.x86.R_DI + displacement) & 0xffff; + case 6: + DECODE_PRINTF2("%04x[BP]", displacement); + M.x86.mode |= SYSMODE_SEG_DS_SS; + return (M.x86.R_BP + displacement) & 0xffff; + case 7: + DECODE_PRINTF2("%04x[BX]", displacement); + return (M.x86.R_BX + displacement) & 0xffff; + } + HALT_SYS(); + } + return 0; + /*NOTREACHED */ +} diff --git a/xorg-server/hw/xfree86/x86emu/fpu.c b/xorg-server/hw/xfree86/x86emu/fpu.c new file mode 100644 index 000000000..b72de1ee5 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/fpu.c @@ -0,0 +1,965 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: This file contains the code to implement the decoding and +* emulation of the FPU instructions. +* +****************************************************************************/ + +#include "x86emu/x86emui.h" + +/*----------------------------- Implementation ----------------------------*/ + +/* opcode=0xd8 */ +void x86emuOp_esc_coprocess_d8(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("ESC D8\n"); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} + +#ifdef DEBUG + +static char *x86emu_fpu_op_d9_tab[] = { + "FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ", + "FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t", + + "FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ", + "FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t", + + "FLD\tDWORD PTR ", "ESC_D9\t", "FST\tDWORD PTR ", "FSTP\tDWORD PTR ", + "FLDENV\t", "FLDCW\t", "FSTENV\t", "FSTCW\t", +}; + +static char *x86emu_fpu_op_d9_tab1[] = { + "FLD\t", "FLD\t", "FLD\t", "FLD\t", + "FLD\t", "FLD\t", "FLD\t", "FLD\t", + + "FXCH\t", "FXCH\t", "FXCH\t", "FXCH\t", + "FXCH\t", "FXCH\t", "FXCH\t", "FXCH\t", + + "FNOP", "ESC_D9", "ESC_D9", "ESC_D9", + "ESC_D9", "ESC_D9", "ESC_D9", "ESC_D9", + + "FSTP\t", "FSTP\t", "FSTP\t", "FSTP\t", + "FSTP\t", "FSTP\t", "FSTP\t", "FSTP\t", + + "FCHS", "FABS", "ESC_D9", "ESC_D9", + "FTST", "FXAM", "ESC_D9", "ESC_D9", + + "FLD1", "FLDL2T", "FLDL2E", "FLDPI", + "FLDLG2", "FLDLN2", "FLDZ", "ESC_D9", + + "F2XM1", "FYL2X", "FPTAN", "FPATAN", + "FXTRACT", "ESC_D9", "FDECSTP", "FINCSTP", + + "FPREM", "FYL2XP1", "FSQRT", "ESC_D9", + "FRNDINT", "FSCALE", "ESC_D9", "ESC_D9", +}; + +#endif /* DEBUG */ + +/* opcode=0xd9 */ +void x86emuOp_esc_coprocess_d9(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset = 0; + u8 stkelem = 0; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (mod != 3) { + DECODE_PRINTINSTR32(x86emu_fpu_op_d9_tab, mod, rh, rl); + } else { + DECODE_PRINTF(x86emu_fpu_op_d9_tab1[(rh << 3) + rl]); + } +#endif + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + break; + case 3: /* register to register */ + stkelem = (u8)rl; + if (rh < 4) { + DECODE_PRINTF2("ST(%d)\n", stkelem); + } else { + DECODE_PRINTF("\n"); + } + break; + } +#ifdef X86EMU_FPU_PRESENT + /* execute */ + switch (mod) { + case 3: + switch (rh) { + case 0: + x86emu_fpu_R_fld(X86EMU_FPU_STKTOP, stkelem); + break; + case 1: + x86emu_fpu_R_fxch(X86EMU_FPU_STKTOP, stkelem); + break; + case 2: + switch (rl) { + case 0: + x86emu_fpu_R_nop(); + break; + default: + x86emu_fpu_illegal(); + break; + } + case 3: + x86emu_fpu_R_fstp(X86EMU_FPU_STKTOP, stkelem); + break; + case 4: + switch (rl) { + case 0: + x86emu_fpu_R_fchs(X86EMU_FPU_STKTOP); + break; + case 1: + x86emu_fpu_R_fabs(X86EMU_FPU_STKTOP); + break; + case 4: + x86emu_fpu_R_ftst(X86EMU_FPU_STKTOP); + break; + case 5: + x86emu_fpu_R_fxam(X86EMU_FPU_STKTOP); + break; + default: + /* 2,3,6,7 */ + x86emu_fpu_illegal(); + break; + } + break; + + case 5: + switch (rl) { + case 0: + x86emu_fpu_R_fld1(X86EMU_FPU_STKTOP); + break; + case 1: + x86emu_fpu_R_fldl2t(X86EMU_FPU_STKTOP); + break; + case 2: + x86emu_fpu_R_fldl2e(X86EMU_FPU_STKTOP); + break; + case 3: + x86emu_fpu_R_fldpi(X86EMU_FPU_STKTOP); + break; + case 4: + x86emu_fpu_R_fldlg2(X86EMU_FPU_STKTOP); + break; + case 5: + x86emu_fpu_R_fldln2(X86EMU_FPU_STKTOP); + break; + case 6: + x86emu_fpu_R_fldz(X86EMU_FPU_STKTOP); + break; + default: + /* 7 */ + x86emu_fpu_illegal(); + break; + } + break; + + case 6: + switch (rl) { + case 0: + x86emu_fpu_R_f2xm1(X86EMU_FPU_STKTOP); + break; + case 1: + x86emu_fpu_R_fyl2x(X86EMU_FPU_STKTOP); + break; + case 2: + x86emu_fpu_R_fptan(X86EMU_FPU_STKTOP); + break; + case 3: + x86emu_fpu_R_fpatan(X86EMU_FPU_STKTOP); + break; + case 4: + x86emu_fpu_R_fxtract(X86EMU_FPU_STKTOP); + break; + case 5: + x86emu_fpu_illegal(); + break; + case 6: + x86emu_fpu_R_decstp(); + break; + case 7: + x86emu_fpu_R_incstp(); + break; + } + break; + + case 7: + switch (rl) { + case 0: + x86emu_fpu_R_fprem(X86EMU_FPU_STKTOP); + break; + case 1: + x86emu_fpu_R_fyl2xp1(X86EMU_FPU_STKTOP); + break; + case 2: + x86emu_fpu_R_fsqrt(X86EMU_FPU_STKTOP); + break; + case 3: + x86emu_fpu_illegal(); + break; + case 4: + x86emu_fpu_R_frndint(X86EMU_FPU_STKTOP); + break; + case 5: + x86emu_fpu_R_fscale(X86EMU_FPU_STKTOP); + break; + case 6: + case 7: + default: + x86emu_fpu_illegal(); + break; + } + break; + + default: + switch (rh) { + case 0: + x86emu_fpu_M_fld(X86EMU_FPU_FLOAT, destoffset); + break; + case 1: + x86emu_fpu_illegal(); + break; + case 2: + x86emu_fpu_M_fst(X86EMU_FPU_FLOAT, destoffset); + break; + case 3: + x86emu_fpu_M_fstp(X86EMU_FPU_FLOAT, destoffset); + break; + case 4: + x86emu_fpu_M_fldenv(X86EMU_FPU_WORD, destoffset); + break; + case 5: + x86emu_fpu_M_fldcw(X86EMU_FPU_WORD, destoffset); + break; + case 6: + x86emu_fpu_M_fstenv(X86EMU_FPU_WORD, destoffset); + break; + case 7: + x86emu_fpu_M_fstcw(X86EMU_FPU_WORD, destoffset); + break; + } + } + } +#else + (void)destoffset; + (void)stkelem; +#endif /* X86EMU_FPU_PRESENT */ + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} + +#ifdef DEBUG + +char *x86emu_fpu_op_da_tab[] = { + "FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ", + "FICOMP\tDWORD PTR ", + "FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ", + "FIDIVR\tDWORD PTR ", + + "FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ", + "FICOMP\tDWORD PTR ", + "FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ", + "FIDIVR\tDWORD PTR ", + + "FIADD\tDWORD PTR ", "FIMUL\tDWORD PTR ", "FICOM\tDWORD PTR ", + "FICOMP\tDWORD PTR ", + "FISUB\tDWORD PTR ", "FISUBR\tDWORD PTR ", "FIDIV\tDWORD PTR ", + "FIDIVR\tDWORD PTR ", + + "ESC_DA ", "ESC_DA ", "ESC_DA ", "ESC_DA ", + "ESC_DA ", "ESC_DA ", "ESC_DA ", "ESC_DA ", +}; + +#endif /* DEBUG */ + +/* opcode=0xda */ +void x86emuOp_esc_coprocess_da(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset = 0; + u8 stkelem = 0; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + DECODE_PRINTINSTR32(x86emu_fpu_op_da_tab, mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + break; + case 3: /* register to register */ + stkelem = (u8)rl; + DECODE_PRINTF2("\tST(%d),ST\n", stkelem); + break; + } +#ifdef X86EMU_FPU_PRESENT + switch (mod) { + case 3: + x86emu_fpu_illegal(); + break; + default: + switch (rh) { + case 0: + x86emu_fpu_M_iadd(X86EMU_FPU_SHORT, destoffset); + break; + case 1: + x86emu_fpu_M_imul(X86EMU_FPU_SHORT, destoffset); + break; + case 2: + x86emu_fpu_M_icom(X86EMU_FPU_SHORT, destoffset); + break; + case 3: + x86emu_fpu_M_icomp(X86EMU_FPU_SHORT, destoffset); + break; + case 4: + x86emu_fpu_M_isub(X86EMU_FPU_SHORT, destoffset); + break; + case 5: + x86emu_fpu_M_isubr(X86EMU_FPU_SHORT, destoffset); + break; + case 6: + x86emu_fpu_M_idiv(X86EMU_FPU_SHORT, destoffset); + break; + case 7: + x86emu_fpu_M_idivr(X86EMU_FPU_SHORT, destoffset); + break; + } + } +#else + (void)destoffset; + (void)stkelem; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} + +#ifdef DEBUG + +char *x86emu_fpu_op_db_tab[] = { + "FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ", + "ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ", + + "FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ", + "ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ", + + "FILD\tDWORD PTR ", "ESC_DB\t19", "FIST\tDWORD PTR ", "FISTP\tDWORD PTR ", + "ESC_DB\t1C", "FLD\tTBYTE PTR ", "ESC_DB\t1E", "FSTP\tTBYTE PTR ", +}; + +#endif /* DEBUG */ + +/* opcode=0xdb */ +void x86emuOp_esc_coprocess_db(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset = 0; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (mod != 3) { + DECODE_PRINTINSTR32(x86emu_fpu_op_db_tab, mod, rh, rl); + } else if (rh == 4) { /* === 11 10 0 nnn */ + switch (rl) { + case 0: + DECODE_PRINTF("FENI\n"); + break; + case 1: + DECODE_PRINTF("FDISI\n"); + break; + case 2: + DECODE_PRINTF("FCLEX\n"); + break; + case 3: + DECODE_PRINTF("FINIT\n"); + break; + } + } else { + DECODE_PRINTF2("ESC_DB %0x\n", (mod << 6) + (rh << 3) + (rl)); + } +#endif /* DEBUG */ + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + break; + case 1: + destoffset = decode_rm01_address(rl); + break; + case 2: + destoffset = decode_rm10_address(rl); + break; + case 3: /* register to register */ + break; + } +#ifdef X86EMU_FPU_PRESENT + /* execute */ + switch (mod) { + case 3: + switch (rh) { + case 4: + switch (rl) { + case 0: + x86emu_fpu_R_feni(); + break; + case 1: + x86emu_fpu_R_fdisi(); + break; + case 2: + x86emu_fpu_R_fclex(); + break; + case 3: + x86emu_fpu_R_finit(); + break; + default: + x86emu_fpu_illegal(); + break; + } + break; + default: + x86emu_fpu_illegal(); + break; + } + break; + default: + switch (rh) { + case 0: + x86emu_fpu_M_fild(X86EMU_FPU_SHORT, destoffset); + break; + case 1: + x86emu_fpu_illegal(); + break; + case 2: + x86emu_fpu_M_fist(X86EMU_FPU_SHORT, destoffset); + break; + case 3: + x86emu_fpu_M_fistp(X86EMU_FPU_SHORT, destoffset); + break; + case 4: + x86emu_fpu_illegal(); + break; + case 5: + x86emu_fpu_M_fld(X86EMU_FPU_LDBL, destoffset); + break; + case 6: + x86emu_fpu_illegal(); + break; + case 7: + x86emu_fpu_M_fstp(X86EMU_FPU_LDBL, destoffset); + break; + } + } +#else + (void)destoffset; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} + +#ifdef DEBUG +char *x86emu_fpu_op_dc_tab[] = { + "FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ", + "FCOMP\tQWORD PTR ", + "FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ", + "FDIVR\tQWORD PTR ", + + "FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ", + "FCOMP\tQWORD PTR ", + "FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ", + "FDIVR\tQWORD PTR ", + + "FADD\tQWORD PTR ", "FMUL\tQWORD PTR ", "FCOM\tQWORD PTR ", + "FCOMP\tQWORD PTR ", + "FSUB\tQWORD PTR ", "FSUBR\tQWORD PTR ", "FDIV\tQWORD PTR ", + "FDIVR\tQWORD PTR ", + + "FADD\t", "FMUL\t", "FCOM\t", "FCOMP\t", + "FSUBR\t", "FSUB\t", "FDIVR\t", "FDIV\t", +}; +#endif /* DEBUG */ + +/* opcode=0xdc */ +void x86emuOp_esc_coprocess_dc(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset = 0; + u8 stkelem = 0; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + DECODE_PRINTINSTR32(x86emu_fpu_op_dc_tab, mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + break; + case 3: /* register to register */ + stkelem = (u8)rl; + DECODE_PRINTF2("\tST(%d),ST\n", stkelem); + break; + } +#ifdef X86EMU_FPU_PRESENT + /* execute */ + switch (mod) { + case 3: + switch (rh) { + case 0: + x86emu_fpu_R_fadd(stkelem, X86EMU_FPU_STKTOP); + break; + case 1: + x86emu_fpu_R_fmul(stkelem, X86EMU_FPU_STKTOP); + break; + case 2: + x86emu_fpu_R_fcom(stkelem, X86EMU_FPU_STKTOP); + break; + case 3: + x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP); + break; + case 4: + x86emu_fpu_R_fsubr(stkelem, X86EMU_FPU_STKTOP); + break; + case 5: + x86emu_fpu_R_fsub(stkelem, X86EMU_FPU_STKTOP); + break; + case 6: + x86emu_fpu_R_fdivr(stkelem, X86EMU_FPU_STKTOP); + break; + case 7: + x86emu_fpu_R_fdiv(stkelem, X86EMU_FPU_STKTOP); + break; + } + break; + default: + switch (rh) { + case 0: + x86emu_fpu_M_fadd(X86EMU_FPU_DOUBLE, destoffset); + break; + case 1: + x86emu_fpu_M_fmul(X86EMU_FPU_DOUBLE, destoffset); + break; + case 2: + x86emu_fpu_M_fcom(X86EMU_FPU_DOUBLE, destoffset); + break; + case 3: + x86emu_fpu_M_fcomp(X86EMU_FPU_DOUBLE, destoffset); + break; + case 4: + x86emu_fpu_M_fsub(X86EMU_FPU_DOUBLE, destoffset); + break; + case 5: + x86emu_fpu_M_fsubr(X86EMU_FPU_DOUBLE, destoffset); + break; + case 6: + x86emu_fpu_M_fdiv(X86EMU_FPU_DOUBLE, destoffset); + break; + case 7: + x86emu_fpu_M_fdivr(X86EMU_FPU_DOUBLE, destoffset); + break; + } + } +#else + (void)destoffset; + (void)stkelem; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} + +#ifdef DEBUG + +static char *x86emu_fpu_op_dd_tab[] = { + "FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ", + "FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t", + + "FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ", + "FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t", + + "FLD\tQWORD PTR ", "ESC_DD\t29,", "FST\tQWORD PTR ", "FSTP\tQWORD PTR ", + "FRSTOR\t", "ESC_DD\t2D,", "FSAVE\t", "FSTSW\t", + + "FFREE\t", "FXCH\t", "FST\t", "FSTP\t", + "ESC_DD\t2C,", "ESC_DD\t2D,", "ESC_DD\t2E,", "ESC_DD\t2F,", +}; + +#endif /* DEBUG */ + +/* opcode=0xdd */ +void x86emuOp_esc_coprocess_dd(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset = 0; + u8 stkelem = 0; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + DECODE_PRINTINSTR32(x86emu_fpu_op_dd_tab, mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + break; + case 3: /* register to register */ + stkelem = (u8)rl; + DECODE_PRINTF2("\tST(%d),ST\n", stkelem); + break; + } +#ifdef X86EMU_FPU_PRESENT + switch (mod) { + case 3: + switch (rh) { + case 0: + x86emu_fpu_R_ffree(stkelem); + break; + case 1: + x86emu_fpu_R_fxch(stkelem); + break; + case 2: + x86emu_fpu_R_fst(stkelem); /* register version */ + break; + case 3: + x86emu_fpu_R_fstp(stkelem); /* register version */ + break; + default: + x86emu_fpu_illegal(); + break; + } + break; + default: + switch (rh) { + case 0: + x86emu_fpu_M_fld(X86EMU_FPU_DOUBLE, destoffset); + break; + case 1: + x86emu_fpu_illegal(); + break; + case 2: + x86emu_fpu_M_fst(X86EMU_FPU_DOUBLE, destoffset); + break; + case 3: + x86emu_fpu_M_fstp(X86EMU_FPU_DOUBLE, destoffset); + break; + case 4: + x86emu_fpu_M_frstor(X86EMU_FPU_WORD, destoffset); + break; + case 5: + x86emu_fpu_illegal(); + break; + case 6: + x86emu_fpu_M_fsave(X86EMU_FPU_WORD, destoffset); + break; + case 7: + x86emu_fpu_M_fstsw(X86EMU_FPU_WORD, destoffset); + break; + } + } +#else + (void)destoffset; + (void)stkelem; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} + +#ifdef DEBUG + +static char *x86emu_fpu_op_de_tab[] = +{ + "FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ", + "FICOMP\tWORD PTR ", + "FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ", + "FIDIVR\tWORD PTR ", + + "FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ", + "FICOMP\tWORD PTR ", + "FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ", + "FIDIVR\tWORD PTR ", + + "FIADD\tWORD PTR ", "FIMUL\tWORD PTR ", "FICOM\tWORD PTR ", + "FICOMP\tWORD PTR ", + "FISUB\tWORD PTR ", "FISUBR\tWORD PTR ", "FIDIV\tWORD PTR ", + "FIDIVR\tWORD PTR ", + + "FADDP\t", "FMULP\t", "FCOMP\t", "FCOMPP\t", + "FSUBRP\t", "FSUBP\t", "FDIVRP\t", "FDIVP\t", +}; + +#endif /* DEBUG */ + +/* opcode=0xde */ +void x86emuOp_esc_coprocess_de(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset = 0; + u8 stkelem = 0; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + DECODE_PRINTINSTR32(x86emu_fpu_op_de_tab, mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + break; + case 3: /* register to register */ + stkelem = (u8)rl; + DECODE_PRINTF2("\tST(%d),ST\n", stkelem); + break; + } +#ifdef X86EMU_FPU_PRESENT + switch (mod) { + case 3: + switch (rh) { + case 0: + x86emu_fpu_R_faddp(stkelem, X86EMU_FPU_STKTOP); + break; + case 1: + x86emu_fpu_R_fmulp(stkelem, X86EMU_FPU_STKTOP); + break; + case 2: + x86emu_fpu_R_fcomp(stkelem, X86EMU_FPU_STKTOP); + break; + case 3: + if (stkelem == 1) + x86emu_fpu_R_fcompp(stkelem, X86EMU_FPU_STKTOP); + else + x86emu_fpu_illegal(); + break; + case 4: + x86emu_fpu_R_fsubrp(stkelem, X86EMU_FPU_STKTOP); + break; + case 5: + x86emu_fpu_R_fsubp(stkelem, X86EMU_FPU_STKTOP); + break; + case 6: + x86emu_fpu_R_fdivrp(stkelem, X86EMU_FPU_STKTOP); + break; + case 7: + x86emu_fpu_R_fdivp(stkelem, X86EMU_FPU_STKTOP); + break; + } + break; + default: + switch (rh) { + case 0: + x86emu_fpu_M_fiadd(X86EMU_FPU_WORD, destoffset); + break; + case 1: + x86emu_fpu_M_fimul(X86EMU_FPU_WORD, destoffset); + break; + case 2: + x86emu_fpu_M_ficom(X86EMU_FPU_WORD, destoffset); + break; + case 3: + x86emu_fpu_M_ficomp(X86EMU_FPU_WORD, destoffset); + break; + case 4: + x86emu_fpu_M_fisub(X86EMU_FPU_WORD, destoffset); + break; + case 5: + x86emu_fpu_M_fisubr(X86EMU_FPU_WORD, destoffset); + break; + case 6: + x86emu_fpu_M_fidiv(X86EMU_FPU_WORD, destoffset); + break; + case 7: + x86emu_fpu_M_fidivr(X86EMU_FPU_WORD, destoffset); + break; + } + } +#else + (void)destoffset; + (void)stkelem; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} + +#ifdef DEBUG + +static char *x86emu_fpu_op_df_tab[] = { + /* mod == 00 */ + "FILD\tWORD PTR ", "ESC_DF\t39\n", "FIST\tWORD PTR ", "FISTP\tWORD PTR ", + "FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ", + "FISTP\tQWORD PTR ", + + /* mod == 01 */ + "FILD\tWORD PTR ", "ESC_DF\t39 ", "FIST\tWORD PTR ", "FISTP\tWORD PTR ", + "FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ", + "FISTP\tQWORD PTR ", + + /* mod == 10 */ + "FILD\tWORD PTR ", "ESC_DF\t39 ", "FIST\tWORD PTR ", "FISTP\tWORD PTR ", + "FBLD\tTBYTE PTR ", "FILD\tQWORD PTR ", "FBSTP\tTBYTE PTR ", + "FISTP\tQWORD PTR ", + + /* mod == 11 */ + "FFREE\t", "FXCH\t", "FST\t", "FSTP\t", + "ESC_DF\t3C,", "ESC_DF\t3D,", "ESC_DF\t3E,", "ESC_DF\t3F," +}; + +#endif /* DEBUG */ + +/* opcode=0xdf */ +void x86emuOp_esc_coprocess_df(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset = 0; + u8 stkelem = 0; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + DECODE_PRINTINSTR32(x86emu_fpu_op_df_tab, mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + break; + case 3: /* register to register */ + stkelem = (u8)rl; + DECODE_PRINTF2("\tST(%d)\n", stkelem); + break; + } +#ifdef X86EMU_FPU_PRESENT + switch (mod) { + case 3: + switch (rh) { + case 0: + x86emu_fpu_R_ffree(stkelem); + break; + case 1: + x86emu_fpu_R_fxch(stkelem); + break; + case 2: + x86emu_fpu_R_fst(stkelem); /* register version */ + break; + case 3: + x86emu_fpu_R_fstp(stkelem); /* register version */ + break; + default: + x86emu_fpu_illegal(); + break; + } + break; + default: + switch (rh) { + case 0: + x86emu_fpu_M_fild(X86EMU_FPU_WORD, destoffset); + break; + case 1: + x86emu_fpu_illegal(); + break; + case 2: + x86emu_fpu_M_fist(X86EMU_FPU_WORD, destoffset); + break; + case 3: + x86emu_fpu_M_fistp(X86EMU_FPU_WORD, destoffset); + break; + case 4: + x86emu_fpu_M_fbld(X86EMU_FPU_BSD, destoffset); + break; + case 5: + x86emu_fpu_M_fild(X86EMU_FPU_LONG, destoffset); + break; + case 6: + x86emu_fpu_M_fbstp(X86EMU_FPU_BSD, destoffset); + break; + case 7: + x86emu_fpu_M_fistp(X86EMU_FPU_LONG, destoffset); + break; + } + } +#else + (void)destoffset; + (void)stkelem; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR_NO_TRACE(); +} diff --git a/xorg-server/hw/xfree86/x86emu/ops.c b/xorg-server/hw/xfree86/x86emu/ops.c new file mode 100644 index 000000000..37ae2c9c9 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/ops.c @@ -0,0 +1,11697 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: This file includes subroutines to implement the decoding +* and emulation of all the x86 processor instructions. +* +* There are approximately 250 subroutines in here, which correspond +* to the 256 byte-"opcodes" found on the 8086. The table which +* dispatches this is found in the files optab.[ch]. +* +* Each opcode proc has a comment preceeding it which gives it's table +* address. Several opcodes are missing (undefined) in the table. +* +* Each proc includes information for decoding (DECODE_PRINTF and +* DECODE_PRINTF2), debugging (TRACE_REGS, SINGLE_STEP), and misc +* functions (START_OF_INSTR, END_OF_INSTR). +* +* Many of the procedures are *VERY* similar in coding. This has +* allowed for a very large amount of code to be generated in a fairly +* short amount of time (i.e. cut, paste, and modify). The result is +* that much of the code below could have been folded into subroutines +* for a large reduction in size of this file. The downside would be +* that there would be a penalty in execution speed. The file could +* also have been *MUCH* larger by inlining certain functions which +* were called. This could have resulted even faster execution. The +* prime directive I used to decide whether to inline the code or to +* modularize it, was basically: 1) no unnecessary subroutine calls, +* 2) no routines more than about 200 lines in size, and 3) modularize +* any code that I might not get right the first time. The fetch_* +* subroutines fall into the latter category. The The decode_* fall +* into the second category. The coding of the "switch(mod){ .... }" +* in many of the subroutines below falls into the first category. +* Especially, the coding of {add,and,or,sub,...}_{byte,word} +* subroutines are an especially glaring case of the third guideline. +* Since so much of the code is cloned from other modules (compare +* opcode #00 to opcode #01), making the basic operations subroutine +* calls is especially important; otherwise mistakes in coding an +* "add" would represent a nightmare in maintenance. +* +****************************************************************************/ + +#include "x86emu/x86emui.h" + +/*----------------------------- Implementation ----------------------------*/ + +/**************************************************************************** +PARAMETERS: +op1 - Instruction op code + +REMARKS: +Handles illegal opcodes. +****************************************************************************/ +static void x86emuOp_illegal_op( + u8 op1) +{ + START_OF_INSTR(); + if (M.x86.R_SP != 0) { + DECODE_PRINTF("ILLEGAL X86 OPCODE\n"); + TRACE_REGS(); + DB( printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n", + M.x86.R_CS, M.x86.R_IP-1,op1)); + HALT_SYS(); + } + else { + /* If we get here, it means the stack pointer is back to zero + * so we are just returning from an emulator service call + * so therte is no need to display an error message. We trap + * the emulator with an 0xF1 opcode to finish the service + * call. + */ + X86EMU_halt_sys(); + } + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x00 +****************************************************************************/ +static void x86emuOp_add_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + u8 *destreg, *srcreg; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("ADD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x01 +****************************************************************************/ +static void x86emuOp_add_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("ADD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = add_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x02 +****************************************************************************/ +static void x86emuOp_add_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("ADD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x03 +****************************************************************************/ +static void x86emuOp_add_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("ADD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_word(*destreg, srcval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = add_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x04 +****************************************************************************/ +static void x86emuOp_add_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("ADD\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + M.x86.R_AL = add_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x05 +****************************************************************************/ +static void x86emuOp_add_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("ADD\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("ADD\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = add_long(M.x86.R_EAX, srcval); + } else { + M.x86.R_AX = add_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x06 +****************************************************************************/ +static void x86emuOp_push_ES(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("PUSH\tES\n"); + TRACE_AND_STEP(); + push_word(M.x86.R_ES); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x07 +****************************************************************************/ +static void x86emuOp_pop_ES(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("POP\tES\n"); + TRACE_AND_STEP(); + M.x86.R_ES = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x08 +****************************************************************************/ +static void x86emuOp_or_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("OR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x09 +****************************************************************************/ +static void x86emuOp_or_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("OR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = or_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0a +****************************************************************************/ +static void x86emuOp_or_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("OR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0b +****************************************************************************/ +static void x86emuOp_or_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("OR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_word(*destreg, srcval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = or_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0c +****************************************************************************/ +static void x86emuOp_or_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("OR\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + M.x86.R_AL = or_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0d +****************************************************************************/ +static void x86emuOp_or_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("OR\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("OR\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = or_long(M.x86.R_EAX, srcval); + } else { + M.x86.R_AX = or_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0e +****************************************************************************/ +static void x86emuOp_push_CS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("PUSH\tCS\n"); + TRACE_AND_STEP(); + push_word(M.x86.R_CS); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f. Escape for two-byte opcode (286 or better) +****************************************************************************/ +static void x86emuOp_two_byte(u8 X86EMU_UNUSED(op1)) +{ + u8 op2 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); + INC_DECODED_INST_LEN(1); + (*x86emu_optab2[op2])(op2); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x10 +****************************************************************************/ +static void x86emuOp_adc_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("ADC\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x11 +****************************************************************************/ +static void x86emuOp_adc_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("ADC\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = adc_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x12 +****************************************************************************/ +static void x86emuOp_adc_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("ADC\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x13 +****************************************************************************/ +static void x86emuOp_adc_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("ADC\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_word(*destreg, srcval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = adc_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x14 +****************************************************************************/ +static void x86emuOp_adc_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("ADC\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + M.x86.R_AL = adc_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x15 +****************************************************************************/ +static void x86emuOp_adc_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("ADC\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("ADC\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = adc_long(M.x86.R_EAX, srcval); + } else { + M.x86.R_AX = adc_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x16 +****************************************************************************/ +static void x86emuOp_push_SS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("PUSH\tSS\n"); + TRACE_AND_STEP(); + push_word(M.x86.R_SS); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x17 +****************************************************************************/ +static void x86emuOp_pop_SS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("POP\tSS\n"); + TRACE_AND_STEP(); + M.x86.R_SS = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x18 +****************************************************************************/ +static void x86emuOp_sbb_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("SBB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x19 +****************************************************************************/ +static void x86emuOp_sbb_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("SBB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sbb_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x1a +****************************************************************************/ +static void x86emuOp_sbb_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("SBB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x1b +****************************************************************************/ +static void x86emuOp_sbb_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("SBB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_word(*destreg, srcval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sbb_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x1c +****************************************************************************/ +static void x86emuOp_sbb_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("SBB\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + M.x86.R_AL = sbb_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x1d +****************************************************************************/ +static void x86emuOp_sbb_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("SBB\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("SBB\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = sbb_long(M.x86.R_EAX, srcval); + } else { + M.x86.R_AX = sbb_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x1e +****************************************************************************/ +static void x86emuOp_push_DS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("PUSH\tDS\n"); + TRACE_AND_STEP(); + push_word(M.x86.R_DS); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x1f +****************************************************************************/ +static void x86emuOp_pop_DS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("POP\tDS\n"); + TRACE_AND_STEP(); + M.x86.R_DS = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x20 +****************************************************************************/ +static void x86emuOp_and_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("AND\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x21 +****************************************************************************/ +static void x86emuOp_and_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("AND\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = and_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x22 +****************************************************************************/ +static void x86emuOp_and_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("AND\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x23 +****************************************************************************/ +static void x86emuOp_and_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("AND\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_long(*destreg, srcval); + break; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_word(*destreg, srcval); + break; + } + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = and_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x24 +****************************************************************************/ +static void x86emuOp_and_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("AND\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + M.x86.R_AL = and_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x25 +****************************************************************************/ +static void x86emuOp_and_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("AND\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("AND\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = and_long(M.x86.R_EAX, srcval); + } else { + M.x86.R_AX = and_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x26 +****************************************************************************/ +static void x86emuOp_segovr_ES(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("ES:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_SEGOVR_ES; + /* + * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4 + * opcode subroutines we do not want to do this. + */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x27 +****************************************************************************/ +static void x86emuOp_daa(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("DAA\n"); + TRACE_AND_STEP(); + M.x86.R_AL = daa_byte(M.x86.R_AL); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x28 +****************************************************************************/ +static void x86emuOp_sub_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("SUB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x29 +****************************************************************************/ +static void x86emuOp_sub_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("SUB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = sub_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x2a +****************************************************************************/ +static void x86emuOp_sub_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("SUB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x2b +****************************************************************************/ +static void x86emuOp_sub_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("SUB\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_word(*destreg, srcval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = sub_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x2c +****************************************************************************/ +static void x86emuOp_sub_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("SUB\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + M.x86.R_AL = sub_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x2d +****************************************************************************/ +static void x86emuOp_sub_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("SUB\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("SUB\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = sub_long(M.x86.R_EAX, srcval); + } else { + M.x86.R_AX = sub_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x2e +****************************************************************************/ +static void x86emuOp_segovr_CS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("CS:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_SEGOVR_CS; + /* note no DECODE_CLEAR_SEGOVR here. */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x2f +****************************************************************************/ +static void x86emuOp_das(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("DAS\n"); + TRACE_AND_STEP(); + M.x86.R_AL = das_byte(M.x86.R_AL); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x30 +****************************************************************************/ +static void x86emuOp_xor_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("XOR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_byte(destval, *srcreg); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x31 +****************************************************************************/ +static void x86emuOp_xor_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("XOR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_long(destval, *srcreg); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = xor_word(destval, *srcreg); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x32 +****************************************************************************/ +static void x86emuOp_xor_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("XOR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x33 +****************************************************************************/ +static void x86emuOp_xor_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("XOR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_word(*destreg, srcval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = xor_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x34 +****************************************************************************/ +static void x86emuOp_xor_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("XOR\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + M.x86.R_AL = xor_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x35 +****************************************************************************/ +static void x86emuOp_xor_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XOR\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("XOR\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = xor_long(M.x86.R_EAX, srcval); + } else { + M.x86.R_AX = xor_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x36 +****************************************************************************/ +static void x86emuOp_segovr_SS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("SS:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_SEGOVR_SS; + /* no DECODE_CLEAR_SEGOVR ! */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x37 +****************************************************************************/ +static void x86emuOp_aaa(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("AAA\n"); + TRACE_AND_STEP(); + M.x86.R_AX = aaa_word(M.x86.R_AX); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x38 +****************************************************************************/ +static void x86emuOp_cmp_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + u8 *destreg, *srcreg; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("CMP\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(destval, *srcreg); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(destval, *srcreg); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(destval, *srcreg); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x39 +****************************************************************************/ +static void x86emuOp_cmp_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("CMP\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(destval, *srcreg); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(destval, *srcreg); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(destval, *srcreg); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(destval, *srcreg); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(destval, *srcreg); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(destval, *srcreg); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x3a +****************************************************************************/ +static void x86emuOp_cmp_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("CMP\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(*destreg, srcval); + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(*destreg, srcval); + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(*destreg, srcval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x3b +****************************************************************************/ +static void x86emuOp_cmp_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("CMP\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(*destreg, srcval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(*destreg, srcval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(*destreg, srcval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + cmp_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x3c +****************************************************************************/ +static void x86emuOp_cmp_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("CMP\tAL,"); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + cmp_byte(M.x86.R_AL, srcval); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x3d +****************************************************************************/ +static void x86emuOp_cmp_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("CMP\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("CMP\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + cmp_long(M.x86.R_EAX, srcval); + } else { + cmp_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x3e +****************************************************************************/ +static void x86emuOp_segovr_DS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("DS:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_SEGOVR_DS; + /* NO DECODE_CLEAR_SEGOVR! */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x3f +****************************************************************************/ +static void x86emuOp_aas(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("AAS\n"); + TRACE_AND_STEP(); + M.x86.R_AX = aas_word(M.x86.R_AX); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x40 +****************************************************************************/ +static void x86emuOp_inc_AX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tEAX\n"); + } else { + DECODE_PRINTF("INC\tAX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = inc_long(M.x86.R_EAX); + } else { + M.x86.R_AX = inc_word(M.x86.R_AX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x41 +****************************************************************************/ +static void x86emuOp_inc_CX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tECX\n"); + } else { + DECODE_PRINTF("INC\tCX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ECX = inc_long(M.x86.R_ECX); + } else { + M.x86.R_CX = inc_word(M.x86.R_CX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x42 +****************************************************************************/ +static void x86emuOp_inc_DX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tEDX\n"); + } else { + DECODE_PRINTF("INC\tDX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDX = inc_long(M.x86.R_EDX); + } else { + M.x86.R_DX = inc_word(M.x86.R_DX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x43 +****************************************************************************/ +static void x86emuOp_inc_BX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tEBX\n"); + } else { + DECODE_PRINTF("INC\tBX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBX = inc_long(M.x86.R_EBX); + } else { + M.x86.R_BX = inc_word(M.x86.R_BX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x44 +****************************************************************************/ +static void x86emuOp_inc_SP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tESP\n"); + } else { + DECODE_PRINTF("INC\tSP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESP = inc_long(M.x86.R_ESP); + } else { + M.x86.R_SP = inc_word(M.x86.R_SP); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x45 +****************************************************************************/ +static void x86emuOp_inc_BP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tEBP\n"); + } else { + DECODE_PRINTF("INC\tBP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBP = inc_long(M.x86.R_EBP); + } else { + M.x86.R_BP = inc_word(M.x86.R_BP); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x46 +****************************************************************************/ +static void x86emuOp_inc_SI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tESI\n"); + } else { + DECODE_PRINTF("INC\tSI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESI = inc_long(M.x86.R_ESI); + } else { + M.x86.R_SI = inc_word(M.x86.R_SI); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x47 +****************************************************************************/ +static void x86emuOp_inc_DI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tEDI\n"); + } else { + DECODE_PRINTF("INC\tDI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDI = inc_long(M.x86.R_EDI); + } else { + M.x86.R_DI = inc_word(M.x86.R_DI); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x48 +****************************************************************************/ +static void x86emuOp_dec_AX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tEAX\n"); + } else { + DECODE_PRINTF("DEC\tAX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = dec_long(M.x86.R_EAX); + } else { + M.x86.R_AX = dec_word(M.x86.R_AX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x49 +****************************************************************************/ +static void x86emuOp_dec_CX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tECX\n"); + } else { + DECODE_PRINTF("DEC\tCX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ECX = dec_long(M.x86.R_ECX); + } else { + M.x86.R_CX = dec_word(M.x86.R_CX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x4a +****************************************************************************/ +static void x86emuOp_dec_DX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tEDX\n"); + } else { + DECODE_PRINTF("DEC\tDX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDX = dec_long(M.x86.R_EDX); + } else { + M.x86.R_DX = dec_word(M.x86.R_DX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x4b +****************************************************************************/ +static void x86emuOp_dec_BX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tEBX\n"); + } else { + DECODE_PRINTF("DEC\tBX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBX = dec_long(M.x86.R_EBX); + } else { + M.x86.R_BX = dec_word(M.x86.R_BX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x4c +****************************************************************************/ +static void x86emuOp_dec_SP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tESP\n"); + } else { + DECODE_PRINTF("DEC\tSP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESP = dec_long(M.x86.R_ESP); + } else { + M.x86.R_SP = dec_word(M.x86.R_SP); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x4d +****************************************************************************/ +static void x86emuOp_dec_BP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tEBP\n"); + } else { + DECODE_PRINTF("DEC\tBP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBP = dec_long(M.x86.R_EBP); + } else { + M.x86.R_BP = dec_word(M.x86.R_BP); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x4e +****************************************************************************/ +static void x86emuOp_dec_SI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tESI\n"); + } else { + DECODE_PRINTF("DEC\tSI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESI = dec_long(M.x86.R_ESI); + } else { + M.x86.R_SI = dec_word(M.x86.R_SI); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x4f +****************************************************************************/ +static void x86emuOp_dec_DI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tEDI\n"); + } else { + DECODE_PRINTF("DEC\tDI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDI = dec_long(M.x86.R_EDI); + } else { + M.x86.R_DI = dec_word(M.x86.R_DI); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x50 +****************************************************************************/ +static void x86emuOp_push_AX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tEAX\n"); + } else { + DECODE_PRINTF("PUSH\tAX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_EAX); + } else { + push_word(M.x86.R_AX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x51 +****************************************************************************/ +static void x86emuOp_push_CX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tECX\n"); + } else { + DECODE_PRINTF("PUSH\tCX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_ECX); + } else { + push_word(M.x86.R_CX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x52 +****************************************************************************/ +static void x86emuOp_push_DX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tEDX\n"); + } else { + DECODE_PRINTF("PUSH\tDX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_EDX); + } else { + push_word(M.x86.R_DX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x53 +****************************************************************************/ +static void x86emuOp_push_BX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tEBX\n"); + } else { + DECODE_PRINTF("PUSH\tBX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_EBX); + } else { + push_word(M.x86.R_BX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x54 +****************************************************************************/ +static void x86emuOp_push_SP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tESP\n"); + } else { + DECODE_PRINTF("PUSH\tSP\n"); + } + TRACE_AND_STEP(); + /* Always push (E)SP, since we are emulating an i386 and above + * processor. This is necessary as some BIOS'es use this to check + * what type of processor is in the system. + */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_ESP); + } else { + push_word((u16)(M.x86.R_SP)); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x55 +****************************************************************************/ +static void x86emuOp_push_BP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tEBP\n"); + } else { + DECODE_PRINTF("PUSH\tBP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_EBP); + } else { + push_word(M.x86.R_BP); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x56 +****************************************************************************/ +static void x86emuOp_push_SI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tESI\n"); + } else { + DECODE_PRINTF("PUSH\tSI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_ESI); + } else { + push_word(M.x86.R_SI); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x57 +****************************************************************************/ +static void x86emuOp_push_DI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSH\tEDI\n"); + } else { + DECODE_PRINTF("PUSH\tDI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_EDI); + } else { + push_word(M.x86.R_DI); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x58 +****************************************************************************/ +static void x86emuOp_pop_AX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tEAX\n"); + } else { + DECODE_PRINTF("POP\tAX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = pop_long(); + } else { + M.x86.R_AX = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x59 +****************************************************************************/ +static void x86emuOp_pop_CX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tECX\n"); + } else { + DECODE_PRINTF("POP\tCX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ECX = pop_long(); + } else { + M.x86.R_CX = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x5a +****************************************************************************/ +static void x86emuOp_pop_DX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tEDX\n"); + } else { + DECODE_PRINTF("POP\tDX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDX = pop_long(); + } else { + M.x86.R_DX = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x5b +****************************************************************************/ +static void x86emuOp_pop_BX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tEBX\n"); + } else { + DECODE_PRINTF("POP\tBX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBX = pop_long(); + } else { + M.x86.R_BX = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x5c +****************************************************************************/ +static void x86emuOp_pop_SP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tESP\n"); + } else { + DECODE_PRINTF("POP\tSP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESP = pop_long(); + } else { + M.x86.R_SP = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x5d +****************************************************************************/ +static void x86emuOp_pop_BP(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tEBP\n"); + } else { + DECODE_PRINTF("POP\tBP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBP = pop_long(); + } else { + M.x86.R_BP = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x5e +****************************************************************************/ +static void x86emuOp_pop_SI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tESI\n"); + } else { + DECODE_PRINTF("POP\tSI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESI = pop_long(); + } else { + M.x86.R_SI = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x5f +****************************************************************************/ +static void x86emuOp_pop_DI(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POP\tEDI\n"); + } else { + DECODE_PRINTF("POP\tDI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDI = pop_long(); + } else { + M.x86.R_DI = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x60 +****************************************************************************/ +static void x86emuOp_push_all(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSHAD\n"); + } else { + DECODE_PRINTF("PUSHA\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 old_sp = M.x86.R_ESP; + + push_long(M.x86.R_EAX); + push_long(M.x86.R_ECX); + push_long(M.x86.R_EDX); + push_long(M.x86.R_EBX); + push_long(old_sp); + push_long(M.x86.R_EBP); + push_long(M.x86.R_ESI); + push_long(M.x86.R_EDI); + } else { + u16 old_sp = M.x86.R_SP; + + push_word(M.x86.R_AX); + push_word(M.x86.R_CX); + push_word(M.x86.R_DX); + push_word(M.x86.R_BX); + push_word(old_sp); + push_word(M.x86.R_BP); + push_word(M.x86.R_SI); + push_word(M.x86.R_DI); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x61 +****************************************************************************/ +static void x86emuOp_pop_all(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POPAD\n"); + } else { + DECODE_PRINTF("POPA\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDI = pop_long(); + M.x86.R_ESI = pop_long(); + M.x86.R_EBP = pop_long(); + M.x86.R_ESP += 4; /* skip ESP */ + M.x86.R_EBX = pop_long(); + M.x86.R_EDX = pop_long(); + M.x86.R_ECX = pop_long(); + M.x86.R_EAX = pop_long(); + } else { + M.x86.R_DI = pop_word(); + M.x86.R_SI = pop_word(); + M.x86.R_BP = pop_word(); + M.x86.R_SP += 2; /* skip SP */ + M.x86.R_BX = pop_word(); + M.x86.R_DX = pop_word(); + M.x86.R_CX = pop_word(); + M.x86.R_AX = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/*opcode 0x62 ILLEGAL OP, calls x86emuOp_illegal_op() */ +/*opcode 0x63 ILLEGAL OP, calls x86emuOp_illegal_op() */ + +/**************************************************************************** +REMARKS: +Handles opcode 0x64 +****************************************************************************/ +static void x86emuOp_segovr_FS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("FS:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_SEGOVR_FS; + /* + * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4 + * opcode subroutines we do not want to do this. + */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x65 +****************************************************************************/ +static void x86emuOp_segovr_GS(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("GS:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_SEGOVR_GS; + /* + * note the lack of DECODE_CLEAR_SEGOVR(r) since, here is one of 4 + * opcode subroutines we do not want to do this. + */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x66 - prefix for 32-bit register +****************************************************************************/ +static void x86emuOp_prefix_data(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("DATA:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_PREFIX_DATA; + /* note no DECODE_CLEAR_SEGOVR here. */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x67 - prefix for 32-bit address +****************************************************************************/ +static void x86emuOp_prefix_addr(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("ADDR:\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_PREFIX_ADDR; + /* note no DECODE_CLEAR_SEGOVR here. */ + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x68 +****************************************************************************/ +static void x86emuOp_push_word_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 imm; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + imm = fetch_long_imm(); + } else { + imm = fetch_word_imm(); + } + DECODE_PRINTF2("PUSH\t%x\n", imm); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(imm); + } else { + push_word((u16)imm); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x69 +****************************************************************************/ +static void x86emuOp_imul_word_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("IMUL\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + s32 imm; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + s16 imm; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + res = (s16)srcval * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + s32 imm; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + s16 imm; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + res = (s16)srcval * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + s32 imm; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + s16 imm; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + res = (s16)srcval * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + u32 res_lo,res_hi; + s32 imm; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg,*srcreg; + u32 res; + s16 imm; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + res = (s16)*srcreg * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x6a +****************************************************************************/ +static void x86emuOp_push_byte_IMM(u8 X86EMU_UNUSED(op1)) +{ + s16 imm; + + START_OF_INSTR(); + imm = (s8)fetch_byte_imm(); + DECODE_PRINTF2("PUSH\t%d\n", imm); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long((s32)imm); + } else { + push_word(imm); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x6b +****************************************************************************/ +static void x86emuOp_imul_byte_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + s8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("IMUL\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + res = (s16)srcval * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + res = (s16)srcval * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)srcval,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + res = (s16)srcval * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)*srcreg,(s32)imm); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg,*srcreg; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%d\n", (s32)imm); + res = (s16)*srcreg * (s16)imm; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x6c +****************************************************************************/ +static void x86emuOp_ins_byte(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("INSB\n"); + ins(1); + TRACE_AND_STEP(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x6d +****************************************************************************/ +static void x86emuOp_ins_word(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INSD\n"); + ins(4); + } else { + DECODE_PRINTF("INSW\n"); + ins(2); + } + TRACE_AND_STEP(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x6e +****************************************************************************/ +static void x86emuOp_outs_byte(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("OUTSB\n"); + outs(1); + TRACE_AND_STEP(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x6f +****************************************************************************/ +static void x86emuOp_outs_word(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("OUTSD\n"); + outs(4); + } else { + DECODE_PRINTF("OUTSW\n"); + outs(2); + } + TRACE_AND_STEP(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x70 +****************************************************************************/ +static void x86emuOp_jump_near_O(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if overflow flag is set */ + START_OF_INSTR(); + DECODE_PRINTF("JO\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_OF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x71 +****************************************************************************/ +static void x86emuOp_jump_near_NO(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if overflow is not set */ + START_OF_INSTR(); + DECODE_PRINTF("JNO\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (!ACCESS_FLAG(F_OF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x72 +****************************************************************************/ +static void x86emuOp_jump_near_B(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if carry flag is set. */ + START_OF_INSTR(); + DECODE_PRINTF("JB\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_CF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x73 +****************************************************************************/ +static void x86emuOp_jump_near_NB(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if carry flag is clear. */ + START_OF_INSTR(); + DECODE_PRINTF("JNB\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (!ACCESS_FLAG(F_CF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x74 +****************************************************************************/ +static void x86emuOp_jump_near_Z(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if zero flag is set. */ + START_OF_INSTR(); + DECODE_PRINTF("JZ\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_ZF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x75 +****************************************************************************/ +static void x86emuOp_jump_near_NZ(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if zero flag is clear. */ + START_OF_INSTR(); + DECODE_PRINTF("JNZ\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (!ACCESS_FLAG(F_ZF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x76 +****************************************************************************/ +static void x86emuOp_jump_near_BE(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if carry flag is set or if the zero + flag is set. */ + START_OF_INSTR(); + DECODE_PRINTF("JBE\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x77 +****************************************************************************/ +static void x86emuOp_jump_near_NBE(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if carry flag is clear and if the zero + flag is clear */ + START_OF_INSTR(); + DECODE_PRINTF("JNBE\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (!(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF))) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x78 +****************************************************************************/ +static void x86emuOp_jump_near_S(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if sign flag is set */ + START_OF_INSTR(); + DECODE_PRINTF("JS\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_SF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x79 +****************************************************************************/ +static void x86emuOp_jump_near_NS(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if sign flag is clear */ + START_OF_INSTR(); + DECODE_PRINTF("JNS\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (!ACCESS_FLAG(F_SF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x7a +****************************************************************************/ +static void x86emuOp_jump_near_P(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if parity flag is set (even parity) */ + START_OF_INSTR(); + DECODE_PRINTF("JP\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_PF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x7b +****************************************************************************/ +static void x86emuOp_jump_near_NP(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + + /* jump to byte offset if parity flag is clear (odd parity) */ + START_OF_INSTR(); + DECODE_PRINTF("JNP\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (!ACCESS_FLAG(F_PF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x7c +****************************************************************************/ +static void x86emuOp_jump_near_L(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + int sf, of; + + /* jump to byte offset if sign flag not equal to overflow flag. */ + START_OF_INSTR(); + DECODE_PRINTF("JL\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + sf = ACCESS_FLAG(F_SF) != 0; + of = ACCESS_FLAG(F_OF) != 0; + if (sf ^ of) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x7d +****************************************************************************/ +static void x86emuOp_jump_near_NL(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + int sf, of; + + /* jump to byte offset if sign flag not equal to overflow flag. */ + START_OF_INSTR(); + DECODE_PRINTF("JNL\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + sf = ACCESS_FLAG(F_SF) != 0; + of = ACCESS_FLAG(F_OF) != 0; + /* note: inverse of above, but using == instead of xor. */ + if (sf == of) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x7e +****************************************************************************/ +static void x86emuOp_jump_near_LE(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + int sf, of; + + /* jump to byte offset if sign flag not equal to overflow flag + or the zero flag is set */ + START_OF_INSTR(); + DECODE_PRINTF("JLE\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + sf = ACCESS_FLAG(F_SF) != 0; + of = ACCESS_FLAG(F_OF) != 0; + if ((sf ^ of) || ACCESS_FLAG(F_ZF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x7f +****************************************************************************/ +static void x86emuOp_jump_near_NLE(u8 X86EMU_UNUSED(op1)) +{ + s8 offset; + u16 target; + int sf, of; + + /* jump to byte offset if sign flag equal to overflow flag. + and the zero flag is clear */ + START_OF_INSTR(); + DECODE_PRINTF("JNLE\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + (s16)offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + sf = ACCESS_FLAG(F_SF) != 0; + of = ACCESS_FLAG(F_OF) != 0; + if ((sf == of) && !ACCESS_FLAG(F_ZF)) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +static u8 (*opc80_byte_operation[])(u8 d, u8 s) = +{ + add_byte, /* 00 */ + or_byte, /* 01 */ + adc_byte, /* 02 */ + sbb_byte, /* 03 */ + and_byte, /* 04 */ + sub_byte, /* 05 */ + xor_byte, /* 06 */ + cmp_byte, /* 07 */ +}; + +/**************************************************************************** +REMARKS: +Handles opcode 0x80 +****************************************************************************/ +static void x86emuOp_opc80_byte_RM_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg; + uint destoffset; + u8 imm; + u8 destval; + + /* + * Weirdo special case instruction format. Part of the opcode + * held below in "RH". Doubly nested case would result, except + * that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + + switch (rh) { + case 0: + DECODE_PRINTF("ADD\t"); + break; + case 1: + DECODE_PRINTF("OR\t"); + break; + case 2: + DECODE_PRINTF("ADC\t"); + break; + case 3: + DECODE_PRINTF("SBB\t"); + break; + case 4: + DECODE_PRINTF("AND\t"); + break; + case 5: + DECODE_PRINTF("SUB\t"); + break; + case 6: + DECODE_PRINTF("XOR\t"); + break; + case 7: + DECODE_PRINTF("CMP\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + switch (mod) { + case 0: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc80_byte_operation[rh]) (destval, imm); + if (rh != 7) + store_data_byte(destoffset, destval); + break; + case 1: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc80_byte_operation[rh]) (destval, imm); + if (rh != 7) + store_data_byte(destoffset, destval); + break; + case 2: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc80_byte_operation[rh]) (destval, imm); + if (rh != 7) + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc80_byte_operation[rh]) (*destreg, imm); + if (rh != 7) + *destreg = destval; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +static u16 (*opc81_word_operation[])(u16 d, u16 s) = +{ + add_word, /*00 */ + or_word, /*01 */ + adc_word, /*02 */ + sbb_word, /*03 */ + and_word, /*04 */ + sub_word, /*05 */ + xor_word, /*06 */ + cmp_word, /*07 */ +}; + +static u32 (*opc81_long_operation[])(u32 d, u32 s) = +{ + add_long, /*00 */ + or_long, /*01 */ + adc_long, /*02 */ + sbb_long, /*03 */ + and_long, /*04 */ + sub_long, /*05 */ + xor_long, /*06 */ + cmp_long, /*07 */ +}; + +/**************************************************************************** +REMARKS: +Handles opcode 0x81 +****************************************************************************/ +static void x86emuOp_opc81_word_RM_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + /* + * Weirdo special case instruction format. Part of the opcode + * held below in "RH". Doubly nested case would result, except + * that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + + switch (rh) { + case 0: + DECODE_PRINTF("ADD\t"); + break; + case 1: + DECODE_PRINTF("OR\t"); + break; + case 2: + DECODE_PRINTF("ADC\t"); + break; + case 3: + DECODE_PRINTF("SBB\t"); + break; + case 4: + DECODE_PRINTF("AND\t"); + break; + case 5: + DECODE_PRINTF("SUB\t"); + break; + case 6: + DECODE_PRINTF("XOR\t"); + break; + case 7: + DECODE_PRINTF("CMP\t"); + break; + } + } +#endif + /* + * Know operation, decode the mod byte to find the addressing + * mode. + */ + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + imm = fetch_long_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_long_operation[rh]) (destval, imm); + if (rh != 7) + store_data_long(destoffset, destval); + } else { + u16 destval,imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + imm = fetch_word_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_word_operation[rh]) (destval, imm); + if (rh != 7) + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + imm = fetch_long_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_long_operation[rh]) (destval, imm); + if (rh != 7) + store_data_long(destoffset, destval); + } else { + u16 destval,imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + imm = fetch_word_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_word_operation[rh]) (destval, imm); + if (rh != 7) + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + imm = fetch_long_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_long_operation[rh]) (destval, imm); + if (rh != 7) + store_data_long(destoffset, destval); + } else { + u16 destval,imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + imm = fetch_word_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_word_operation[rh]) (destval, imm); + if (rh != 7) + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 destval,imm; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + imm = fetch_long_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_long_operation[rh]) (*destreg, imm); + if (rh != 7) + *destreg = destval; + } else { + u16 *destreg; + u16 destval,imm; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + imm = fetch_word_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc81_word_operation[rh]) (*destreg, imm); + if (rh != 7) + *destreg = destval; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +static u8 (*opc82_byte_operation[])(u8 s, u8 d) = +{ + add_byte, /*00 */ + or_byte, /*01 *//*YYY UNUSED ???? */ + adc_byte, /*02 */ + sbb_byte, /*03 */ + and_byte, /*04 *//*YYY UNUSED ???? */ + sub_byte, /*05 */ + xor_byte, /*06 *//*YYY UNUSED ???? */ + cmp_byte, /*07 */ +}; + +/**************************************************************************** +REMARKS: +Handles opcode 0x82 +****************************************************************************/ +static void x86emuOp_opc82_byte_RM_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg; + uint destoffset; + u8 imm; + u8 destval; + + /* + * Weirdo special case instruction format. Part of the opcode + * held below in "RH". Doubly nested case would result, except + * that the decoded instruction Similar to opcode 81, except that + * the immediate byte is sign extended to a word length. + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + switch (rh) { + case 0: + DECODE_PRINTF("ADD\t"); + break; + case 1: + DECODE_PRINTF("OR\t"); + break; + case 2: + DECODE_PRINTF("ADC\t"); + break; + case 3: + DECODE_PRINTF("SBB\t"); + break; + case 4: + DECODE_PRINTF("AND\t"); + break; + case 5: + DECODE_PRINTF("SUB\t"); + break; + case 6: + DECODE_PRINTF("XOR\t"); + break; + case 7: + DECODE_PRINTF("CMP\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + switch (mod) { + case 0: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm00_address(rl); + destval = fetch_data_byte(destoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc82_byte_operation[rh]) (destval, imm); + if (rh != 7) + store_data_byte(destoffset, destval); + break; + case 1: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm01_address(rl); + destval = fetch_data_byte(destoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc82_byte_operation[rh]) (destval, imm); + if (rh != 7) + store_data_byte(destoffset, destval); + break; + case 2: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + destval = fetch_data_byte(destoffset); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc82_byte_operation[rh]) (destval, imm); + if (rh != 7) + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc82_byte_operation[rh]) (*destreg, imm); + if (rh != 7) + *destreg = destval; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +static u16 (*opc83_word_operation[])(u16 s, u16 d) = +{ + add_word, /*00 */ + or_word, /*01 *//*YYY UNUSED ???? */ + adc_word, /*02 */ + sbb_word, /*03 */ + and_word, /*04 *//*YYY UNUSED ???? */ + sub_word, /*05 */ + xor_word, /*06 *//*YYY UNUSED ???? */ + cmp_word, /*07 */ +}; + +static u32 (*opc83_long_operation[])(u32 s, u32 d) = +{ + add_long, /*00 */ + or_long, /*01 *//*YYY UNUSED ???? */ + adc_long, /*02 */ + sbb_long, /*03 */ + and_long, /*04 *//*YYY UNUSED ???? */ + sub_long, /*05 */ + xor_long, /*06 *//*YYY UNUSED ???? */ + cmp_long, /*07 */ +}; + +/**************************************************************************** +REMARKS: +Handles opcode 0x83 +****************************************************************************/ +static void x86emuOp_opc83_word_RM_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + /* + * Weirdo special case instruction format. Part of the opcode + * held below in "RH". Doubly nested case would result, except + * that the decoded instruction Similar to opcode 81, except that + * the immediate byte is sign extended to a word length. + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + switch (rh) { + case 0: + DECODE_PRINTF("ADD\t"); + break; + case 1: + DECODE_PRINTF("OR\t"); + break; + case 2: + DECODE_PRINTF("ADC\t"); + break; + case 3: + DECODE_PRINTF("SBB\t"); + break; + case 4: + DECODE_PRINTF("AND\t"); + break; + case 5: + DECODE_PRINTF("SUB\t"); + break; + case 6: + DECODE_PRINTF("XOR\t"); + break; + case 7: + DECODE_PRINTF("CMP\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm00_address(rl); + destval = fetch_data_long(destoffset); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_long_operation[rh]) (destval, imm); + if (rh != 7) + store_data_long(destoffset, destval); + } else { + u16 destval,imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm00_address(rl); + destval = fetch_data_word(destoffset); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_word_operation[rh]) (destval, imm); + if (rh != 7) + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm01_address(rl); + destval = fetch_data_long(destoffset); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_long_operation[rh]) (destval, imm); + if (rh != 7) + store_data_long(destoffset, destval); + } else { + u16 destval,imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm01_address(rl); + destval = fetch_data_word(destoffset); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_word_operation[rh]) (destval, imm); + if (rh != 7) + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm10_address(rl); + destval = fetch_data_long(destoffset); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_long_operation[rh]) (destval, imm); + if (rh != 7) + store_data_long(destoffset, destval); + } else { + u16 destval,imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm10_address(rl); + destval = fetch_data_word(destoffset); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_word_operation[rh]) (destval, imm); + if (rh != 7) + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 destval,imm; + + destreg = DECODE_RM_LONG_REGISTER(rl); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_long_operation[rh]) (*destreg, imm); + if (rh != 7) + *destreg = destval; + } else { + u16 *destreg; + u16 destval,imm; + + destreg = DECODE_RM_WORD_REGISTER(rl); + imm = (s8) fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + destval = (*opc83_word_operation[rh]) (*destreg, imm); + if (rh != 7) + *destreg = destval; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x84 +****************************************************************************/ +static void x86emuOp_test_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + + START_OF_INSTR(); + DECODE_PRINTF("TEST\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_byte(destval, *srcreg); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_byte(destval, *srcreg); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_byte(destval, *srcreg); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_byte(*destreg, *srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x85 +****************************************************************************/ +static void x86emuOp_test_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("TEST\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_long(destval, *srcreg); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_word(destval, *srcreg); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_long(destval, *srcreg); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_word(destval, *srcreg); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_long(destval, *srcreg); + } else { + u16 destval; + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_word(destval, *srcreg); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_long(*destreg, *srcreg); + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + test_word(*destreg, *srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x86 +****************************************************************************/ +static void x86emuOp_xchg_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + u8 destval; + u8 tmp; + + START_OF_INSTR(); + DECODE_PRINTF("XCHG\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_byte(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_byte(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_byte(destoffset); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = *destreg; + *destreg = tmp; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x87 +****************************************************************************/ +static void x86emuOp_xchg_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("XCHG\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg; + u32 destval,tmp; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_long(destoffset, destval); + } else { + u16 *srcreg; + u16 destval,tmp; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg; + u32 destval,tmp; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_long(destoffset, destval); + } else { + u16 *srcreg; + u16 destval,tmp; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg; + u32 destval,tmp; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_long(destoffset); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_long(destoffset, destval); + } else { + u16 *srcreg; + u16 destval,tmp; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + destval = fetch_data_word(destoffset); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = destval; + destval = tmp; + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + u32 tmp; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = *destreg; + *destreg = tmp; + } else { + u16 *destreg,*srcreg; + u16 tmp; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + tmp = *srcreg; + *srcreg = *destreg; + *destreg = tmp; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x88 +****************************************************************************/ +static void x86emuOp_mov_byte_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_byte(destoffset, *srcreg); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_byte(destoffset, *srcreg); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_byte(destoffset, *srcreg); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x89 +****************************************************************************/ +static void x86emuOp_mov_word_RM_R(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u32 destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_long(destoffset, *srcreg); + } else { + u16 *srcreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_word(destoffset, *srcreg); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_long(destoffset, *srcreg); + } else { + u16 *srcreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_word(destoffset, *srcreg); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_long(destoffset, *srcreg); + } else { + u16 *srcreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + store_data_word(destoffset, *srcreg); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + } else { + u16 *destreg,*srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x8a +****************************************************************************/ +static void x86emuOp_mov_byte_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg, *srcreg; + uint srcoffset; + u8 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 1: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 2: + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x8b +****************************************************************************/ +static void x86emuOp_mov_word_R_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg, *srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + } else { + u16 *destreg, *srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x8c +****************************************************************************/ +static void x86emuOp_mov_word_RM_SR(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u16 *destreg, *srcreg; + uint destoffset; + u16 destval; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + srcreg = decode_rm_seg_register(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = *srcreg; + store_data_word(destoffset, destval); + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + srcreg = decode_rm_seg_register(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = *srcreg; + store_data_word(destoffset, destval); + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + srcreg = decode_rm_seg_register(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = *srcreg; + store_data_word(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcreg = decode_rm_seg_register(rh); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x8d +****************************************************************************/ +static void x86emuOp_lea_word_R_M(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u16 *srcreg; + uint destoffset; + +/* + * TODO: Need to handle address size prefix! + * + * lea eax,[eax+ebx*2] ?? + */ + + START_OF_INSTR(); + DECODE_PRINTF("LEA\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *srcreg = (u16)destoffset; + break; + case 1: + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *srcreg = (u16)destoffset; + break; + case 2: + srcreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *srcreg = (u16)destoffset; + break; + case 3: /* register to register */ + /* undefined. Do nothing. */ + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x8e +****************************************************************************/ +static void x86emuOp_mov_word_SR_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u16 *destreg, *srcreg; + uint srcoffset; + u16 srcval; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = decode_rm_seg_register(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 1: + destreg = decode_rm_seg_register(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 2: + destreg = decode_rm_seg_register(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 3: /* register to register */ + destreg = decode_rm_seg_register(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + break; + } + /* + * Clean up, and reset all the R_xSP pointers to the correct + * locations. This is about 3x too much overhead (doing all the + * segreg ptrs when only one is needed, but this instruction + * *cannot* be that common, and this isn't too much work anyway. + */ + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x8f +****************************************************************************/ +static void x86emuOp_pop_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("POP\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + if (rh != 0) { + DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n"); + HALT_SYS(); + } + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = pop_long(); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = pop_word(); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = pop_long(); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = pop_word(); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = pop_long(); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + destval = pop_word(); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = pop_long(); + } else { + u16 *destreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = pop_word(); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x90 +****************************************************************************/ +static void x86emuOp_nop(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("NOP\n"); + TRACE_AND_STEP(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x91 +****************************************************************************/ +static void x86emuOp_xchg_word_AX_CX(u8 X86EMU_UNUSED(op1)) +{ + u32 tmp; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XCHG\tEAX,ECX\n"); + } else { + DECODE_PRINTF("XCHG\tAX,CX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + tmp = M.x86.R_EAX; + M.x86.R_EAX = M.x86.R_ECX; + M.x86.R_ECX = tmp; + } else { + tmp = M.x86.R_AX; + M.x86.R_AX = M.x86.R_CX; + M.x86.R_CX = (u16)tmp; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x92 +****************************************************************************/ +static void x86emuOp_xchg_word_AX_DX(u8 X86EMU_UNUSED(op1)) +{ + u32 tmp; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XCHG\tEAX,EDX\n"); + } else { + DECODE_PRINTF("XCHG\tAX,DX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + tmp = M.x86.R_EAX; + M.x86.R_EAX = M.x86.R_EDX; + M.x86.R_EDX = tmp; + } else { + tmp = M.x86.R_AX; + M.x86.R_AX = M.x86.R_DX; + M.x86.R_DX = (u16)tmp; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x93 +****************************************************************************/ +static void x86emuOp_xchg_word_AX_BX(u8 X86EMU_UNUSED(op1)) +{ + u32 tmp; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XCHG\tEAX,EBX\n"); + } else { + DECODE_PRINTF("XCHG\tAX,BX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + tmp = M.x86.R_EAX; + M.x86.R_EAX = M.x86.R_EBX; + M.x86.R_EBX = tmp; + } else { + tmp = M.x86.R_AX; + M.x86.R_AX = M.x86.R_BX; + M.x86.R_BX = (u16)tmp; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x94 +****************************************************************************/ +static void x86emuOp_xchg_word_AX_SP(u8 X86EMU_UNUSED(op1)) +{ + u32 tmp; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XCHG\tEAX,ESP\n"); + } else { + DECODE_PRINTF("XCHG\tAX,SP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + tmp = M.x86.R_EAX; + M.x86.R_EAX = M.x86.R_ESP; + M.x86.R_ESP = tmp; + } else { + tmp = M.x86.R_AX; + M.x86.R_AX = M.x86.R_SP; + M.x86.R_SP = (u16)tmp; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x95 +****************************************************************************/ +static void x86emuOp_xchg_word_AX_BP(u8 X86EMU_UNUSED(op1)) +{ + u32 tmp; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XCHG\tEAX,EBP\n"); + } else { + DECODE_PRINTF("XCHG\tAX,BP\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + tmp = M.x86.R_EAX; + M.x86.R_EAX = M.x86.R_EBP; + M.x86.R_EBP = tmp; + } else { + tmp = M.x86.R_AX; + M.x86.R_AX = M.x86.R_BP; + M.x86.R_BP = (u16)tmp; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x96 +****************************************************************************/ +static void x86emuOp_xchg_word_AX_SI(u8 X86EMU_UNUSED(op1)) +{ + u32 tmp; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XCHG\tEAX,ESI\n"); + } else { + DECODE_PRINTF("XCHG\tAX,SI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + tmp = M.x86.R_EAX; + M.x86.R_EAX = M.x86.R_ESI; + M.x86.R_ESI = tmp; + } else { + tmp = M.x86.R_AX; + M.x86.R_AX = M.x86.R_SI; + M.x86.R_SI = (u16)tmp; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x97 +****************************************************************************/ +static void x86emuOp_xchg_word_AX_DI(u8 X86EMU_UNUSED(op1)) +{ + u32 tmp; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("XCHG\tEAX,EDI\n"); + } else { + DECODE_PRINTF("XCHG\tAX,DI\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + tmp = M.x86.R_EAX; + M.x86.R_EAX = M.x86.R_EDI; + M.x86.R_EDI = tmp; + } else { + tmp = M.x86.R_AX; + M.x86.R_AX = M.x86.R_DI; + M.x86.R_DI = (u16)tmp; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x98 +****************************************************************************/ +static void x86emuOp_cbw(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("CWDE\n"); + } else { + DECODE_PRINTF("CBW\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + if (M.x86.R_AX & 0x8000) { + M.x86.R_EAX |= 0xffff0000; + } else { + M.x86.R_EAX &= 0x0000ffff; + } + } else { + if (M.x86.R_AL & 0x80) { + M.x86.R_AH = 0xff; + } else { + M.x86.R_AH = 0x0; + } + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x99 +****************************************************************************/ +static void x86emuOp_cwd(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("CDQ\n"); + } else { + DECODE_PRINTF("CWD\n"); + } + DECODE_PRINTF("CWD\n"); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + if (M.x86.R_EAX & 0x80000000) { + M.x86.R_EDX = 0xffffffff; + } else { + M.x86.R_EDX = 0x0; + } + } else { + if (M.x86.R_AX & 0x8000) { + M.x86.R_DX = 0xffff; + } else { + M.x86.R_DX = 0x0; + } + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x9a +****************************************************************************/ +static void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 farseg, faroff; + + START_OF_INSTR(); + DECODE_PRINTF("CALL\t"); + faroff = fetch_word_imm(); + farseg = fetch_word_imm(); + DECODE_PRINTF2("%04x:", farseg); + DECODE_PRINTF2("%04x\n", faroff); + CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR "); + + /* XXX + * + * Hooked interrupt vectors calling into our "BIOS" will cause + * problems unless all intersegment stuff is checked for BIOS + * access. Check needed here. For moment, let it alone. + */ + TRACE_AND_STEP(); + push_word(M.x86.R_CS); + M.x86.R_CS = farseg; + push_word(M.x86.R_IP); + M.x86.R_IP = faroff; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x9b +****************************************************************************/ +static void x86emuOp_wait(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("WAIT"); + TRACE_AND_STEP(); + /* NADA. */ + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x9c +****************************************************************************/ +static void x86emuOp_pushf_word(u8 X86EMU_UNUSED(op1)) +{ + u32 flags; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("PUSHFD\n"); + } else { + DECODE_PRINTF("PUSHF\n"); + } + TRACE_AND_STEP(); + + /* clear out *all* bits not representing flags, and turn on real bits */ + flags = (M.x86.R_EFLG & F_MSK) | F_ALWAYS_ON; + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(flags); + } else { + push_word((u16)flags); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x9d +****************************************************************************/ +static void x86emuOp_popf_word(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("POPFD\n"); + } else { + DECODE_PRINTF("POPF\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EFLG = pop_long(); + } else { + M.x86.R_FLG = pop_word(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x9e +****************************************************************************/ +static void x86emuOp_sahf(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("SAHF\n"); + TRACE_AND_STEP(); + /* clear the lower bits of the flag register */ + M.x86.R_FLG &= 0xffffff00; + /* or in the AH register into the flags register */ + M.x86.R_FLG |= M.x86.R_AH; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x9f +****************************************************************************/ +static void x86emuOp_lahf(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("LAHF\n"); + TRACE_AND_STEP(); + M.x86.R_AH = (u8)(M.x86.R_FLG & 0xff); + /*undocumented TC++ behavior??? Nope. It's documented, but + you have too look real hard to notice it. */ + M.x86.R_AH |= 0x2; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa0 +****************************************************************************/ +static void x86emuOp_mov_AL_M_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 offset; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tAL,"); + offset = fetch_word_imm(); + DECODE_PRINTF2("[%04x]\n", offset); + TRACE_AND_STEP(); + M.x86.R_AL = fetch_data_byte(offset); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa1 +****************************************************************************/ +static void x86emuOp_mov_AX_M_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 offset; + + START_OF_INSTR(); + offset = fetch_word_imm(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF2("MOV\tEAX,[%04x]\n", offset); + } else { + DECODE_PRINTF2("MOV\tAX,[%04x]\n", offset); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = fetch_data_long(offset); + } else { + M.x86.R_AX = fetch_data_word(offset); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa2 +****************************************************************************/ +static void x86emuOp_mov_M_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 offset; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + offset = fetch_word_imm(); + DECODE_PRINTF2("[%04x],AL\n", offset); + TRACE_AND_STEP(); + store_data_byte(offset, M.x86.R_AL); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa3 +****************************************************************************/ +static void x86emuOp_mov_M_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 offset; + + START_OF_INSTR(); + offset = fetch_word_imm(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF2("MOV\t[%04x],EAX\n", offset); + } else { + DECODE_PRINTF2("MOV\t[%04x],AX\n", offset); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + store_data_long(offset, M.x86.R_EAX); + } else { + store_data_word(offset, M.x86.R_AX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa4 +****************************************************************************/ +static void x86emuOp_movs_byte(u8 X86EMU_UNUSED(op1)) +{ + u8 val; + u32 count; + int inc; + + START_OF_INSTR(); + DECODE_PRINTF("MOVS\tBYTE\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -1; + else + inc = 1; + TRACE_AND_STEP(); + count = 1; + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* move them until CX is ZERO. */ + count = M.x86.R_CX; + M.x86.R_CX = 0; + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } + while (count--) { + val = fetch_data_byte(M.x86.R_SI); + store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, val); + M.x86.R_SI += inc; + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa5 +****************************************************************************/ +static void x86emuOp_movs_word(u8 X86EMU_UNUSED(op1)) +{ + u32 val; + int inc; + u32 count; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOVS\tDWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -4; + else + inc = 4; + } else { + DECODE_PRINTF("MOVS\tWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -2; + else + inc = 2; + } + TRACE_AND_STEP(); + count = 1; + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* move them until CX is ZERO. */ + count = M.x86.R_CX; + M.x86.R_CX = 0; + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } + while (count--) { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + val = fetch_data_long(M.x86.R_SI); + store_data_long_abs(M.x86.R_ES, M.x86.R_DI, val); + } else { + val = fetch_data_word(M.x86.R_SI); + store_data_word_abs(M.x86.R_ES, M.x86.R_DI, (u16)val); + } + M.x86.R_SI += inc; + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa6 +****************************************************************************/ +static void x86emuOp_cmps_byte(u8 X86EMU_UNUSED(op1)) +{ + s8 val1, val2; + int inc; + + START_OF_INSTR(); + DECODE_PRINTF("CMPS\tBYTE\n"); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -1; + else + inc = 1; + + if (M.x86.mode & SYSMODE_PREFIX_REPE) { + /* REPE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + val1 = fetch_data_byte(M.x86.R_SI); + val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); + cmp_byte(val1, val2); + M.x86.R_CX -= 1; + M.x86.R_SI += inc; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF) == 0) + break; + } + M.x86.mode &= ~SYSMODE_PREFIX_REPE; + } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { + /* REPNE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + val1 = fetch_data_byte(M.x86.R_SI); + val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); + cmp_byte(val1, val2); + M.x86.R_CX -= 1; + M.x86.R_SI += inc; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF)) + break; /* zero flag set means equal */ + } + M.x86.mode &= ~SYSMODE_PREFIX_REPNE; + } else { + val1 = fetch_data_byte(M.x86.R_SI); + val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); + cmp_byte(val1, val2); + M.x86.R_SI += inc; + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa7 +****************************************************************************/ +static void x86emuOp_cmps_word(u8 X86EMU_UNUSED(op1)) +{ + u32 val1,val2; + int inc; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("CMPS\tDWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -4; + else + inc = 4; + } else { + DECODE_PRINTF("CMPS\tWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -2; + else + inc = 2; + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_REPE) { + /* REPE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + val1 = fetch_data_long(M.x86.R_SI); + val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); + cmp_long(val1, val2); + } else { + val1 = fetch_data_word(M.x86.R_SI); + val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); + cmp_word((u16)val1, (u16)val2); + } + M.x86.R_CX -= 1; + M.x86.R_SI += inc; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF) == 0) + break; + } + M.x86.mode &= ~SYSMODE_PREFIX_REPE; + } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { + /* REPNE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + val1 = fetch_data_long(M.x86.R_SI); + val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); + cmp_long(val1, val2); + } else { + val1 = fetch_data_word(M.x86.R_SI); + val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); + cmp_word((u16)val1, (u16)val2); + } + M.x86.R_CX -= 1; + M.x86.R_SI += inc; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF)) + break; /* zero flag set means equal */ + } + M.x86.mode &= ~SYSMODE_PREFIX_REPNE; + } else { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + val1 = fetch_data_long(M.x86.R_SI); + val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); + cmp_long(val1, val2); + } else { + val1 = fetch_data_word(M.x86.R_SI); + val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); + cmp_word((u16)val1, (u16)val2); + } + M.x86.R_SI += inc; + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa8 +****************************************************************************/ +static void x86emuOp_test_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + int imm; + + START_OF_INSTR(); + DECODE_PRINTF("TEST\tAL,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%04x\n", imm); + TRACE_AND_STEP(); + test_byte(M.x86.R_AL, (u8)imm); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xa9 +****************************************************************************/ +static void x86emuOp_test_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("TEST\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("TEST\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + test_long(M.x86.R_EAX, srcval); + } else { + test_word(M.x86.R_AX, (u16)srcval); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xaa +****************************************************************************/ +static void x86emuOp_stos_byte(u8 X86EMU_UNUSED(op1)) +{ + int inc; + + START_OF_INSTR(); + DECODE_PRINTF("STOS\tBYTE\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -1; + else + inc = 1; + TRACE_AND_STEP(); + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL); + M.x86.R_CX -= 1; + M.x86.R_DI += inc; + } + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } else { + store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AL); + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xab +****************************************************************************/ +static void x86emuOp_stos_word(u8 X86EMU_UNUSED(op1)) +{ + int inc; + u32 count; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("STOS\tDWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -4; + else + inc = 4; + } else { + DECODE_PRINTF("STOS\tWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -2; + else + inc = 2; + } + TRACE_AND_STEP(); + count = 1; + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* move them until CX is ZERO. */ + count = M.x86.R_CX; + M.x86.R_CX = 0; + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } + while (count--) { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + store_data_long_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_EAX); + } else { + store_data_word_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AX); + } + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xac +****************************************************************************/ +static void x86emuOp_lods_byte(u8 X86EMU_UNUSED(op1)) +{ + int inc; + + START_OF_INSTR(); + DECODE_PRINTF("LODS\tBYTE\n"); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -1; + else + inc = 1; + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + M.x86.R_AL = fetch_data_byte(M.x86.R_SI); + M.x86.R_CX -= 1; + M.x86.R_SI += inc; + } + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } else { + M.x86.R_AL = fetch_data_byte(M.x86.R_SI); + M.x86.R_SI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xad +****************************************************************************/ +static void x86emuOp_lods_word(u8 X86EMU_UNUSED(op1)) +{ + int inc; + u32 count; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("LODS\tDWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -4; + else + inc = 4; + } else { + DECODE_PRINTF("LODS\tWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -2; + else + inc = 2; + } + TRACE_AND_STEP(); + count = 1; + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* move them until CX is ZERO. */ + count = M.x86.R_CX; + M.x86.R_CX = 0; + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } + while (count--) { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = fetch_data_long(M.x86.R_SI); + } else { + M.x86.R_AX = fetch_data_word(M.x86.R_SI); + } + M.x86.R_SI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xae +****************************************************************************/ +static void x86emuOp_scas_byte(u8 X86EMU_UNUSED(op1)) +{ + s8 val2; + int inc; + + START_OF_INSTR(); + DECODE_PRINTF("SCAS\tBYTE\n"); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -1; + else + inc = 1; + if (M.x86.mode & SYSMODE_PREFIX_REPE) { + /* REPE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); + cmp_byte(M.x86.R_AL, val2); + M.x86.R_CX -= 1; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF) == 0) + break; + } + M.x86.mode &= ~SYSMODE_PREFIX_REPE; + } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { + /* REPNE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); + cmp_byte(M.x86.R_AL, val2); + M.x86.R_CX -= 1; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF)) + break; /* zero flag set means equal */ + } + M.x86.mode &= ~SYSMODE_PREFIX_REPNE; + } else { + val2 = fetch_data_byte_abs(M.x86.R_ES, M.x86.R_DI); + cmp_byte(M.x86.R_AL, val2); + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xaf +****************************************************************************/ +static void x86emuOp_scas_word(u8 X86EMU_UNUSED(op1)) +{ + int inc; + u32 val; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("SCAS\tDWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -4; + else + inc = 4; + } else { + DECODE_PRINTF("SCAS\tWORD\n"); + if (ACCESS_FLAG(F_DF)) /* down */ + inc = -2; + else + inc = 2; + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_REPE) { + /* REPE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); + cmp_long(M.x86.R_EAX, val); + } else { + val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); + cmp_word(M.x86.R_AX, (u16)val); + } + M.x86.R_CX -= 1; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF) == 0) + break; + } + M.x86.mode &= ~SYSMODE_PREFIX_REPE; + } else if (M.x86.mode & SYSMODE_PREFIX_REPNE) { + /* REPNE */ + /* move them until CX is ZERO. */ + while (M.x86.R_CX != 0) { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); + cmp_long(M.x86.R_EAX, val); + } else { + val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); + cmp_word(M.x86.R_AX, (u16)val); + } + M.x86.R_CX -= 1; + M.x86.R_DI += inc; + if (ACCESS_FLAG(F_ZF)) + break; /* zero flag set means equal */ + } + M.x86.mode &= ~SYSMODE_PREFIX_REPNE; + } else { + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI); + cmp_long(M.x86.R_EAX, val); + } else { + val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI); + cmp_word(M.x86.R_AX, (u16)val); + } + M.x86.R_DI += inc; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb0 +****************************************************************************/ +static void x86emuOp_mov_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tAL,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_AL = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb1 +****************************************************************************/ +static void x86emuOp_mov_byte_CL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tCL,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_CL = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb2 +****************************************************************************/ +static void x86emuOp_mov_byte_DL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tDL,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_DL = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb3 +****************************************************************************/ +static void x86emuOp_mov_byte_BL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tBL,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_BL = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb4 +****************************************************************************/ +static void x86emuOp_mov_byte_AH_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tAH,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_AH = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb5 +****************************************************************************/ +static void x86emuOp_mov_byte_CH_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tCH,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_CH = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb6 +****************************************************************************/ +static void x86emuOp_mov_byte_DH_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tDH,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_DH = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb7 +****************************************************************************/ +static void x86emuOp_mov_byte_BH_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\tBH,"); + imm = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", imm); + TRACE_AND_STEP(); + M.x86.R_BH = imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb8 +****************************************************************************/ +static void x86emuOp_mov_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tEAX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tAX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = srcval; + } else { + M.x86.R_AX = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xb9 +****************************************************************************/ +static void x86emuOp_mov_word_CX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tECX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tCX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ECX = srcval; + } else { + M.x86.R_CX = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xba +****************************************************************************/ +static void x86emuOp_mov_word_DX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tEDX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tDX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDX = srcval; + } else { + M.x86.R_DX = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xbb +****************************************************************************/ +static void x86emuOp_mov_word_BX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tEBX,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tBX,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBX = srcval; + } else { + M.x86.R_BX = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xbc +****************************************************************************/ +static void x86emuOp_mov_word_SP_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tESP,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tSP,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESP = srcval; + } else { + M.x86.R_SP = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xbd +****************************************************************************/ +static void x86emuOp_mov_word_BP_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tEBP,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tBP,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EBP = srcval; + } else { + M.x86.R_BP = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xbe +****************************************************************************/ +static void x86emuOp_mov_word_SI_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tESI,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tSI,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ESI = srcval; + } else { + M.x86.R_SI = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xbf +****************************************************************************/ +static void x86emuOp_mov_word_DI_IMM(u8 X86EMU_UNUSED(op1)) +{ + u32 srcval; + + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("MOV\tEDI,"); + srcval = fetch_long_imm(); + } else { + DECODE_PRINTF("MOV\tDI,"); + srcval = fetch_word_imm(); + } + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EDI = srcval; + } else { + M.x86.R_DI = (u16)srcval; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/* used by opcodes c0, d0, and d2. */ +static u8(*opcD0_byte_operation[])(u8 d, u8 s) = +{ + rol_byte, + ror_byte, + rcl_byte, + rcr_byte, + shl_byte, + shr_byte, + shl_byte, /* sal_byte === shl_byte by definition */ + sar_byte, +}; + +/**************************************************************************** +REMARKS: +Handles opcode 0xc0 +****************************************************************************/ +static void x86emuOp_opcC0_byte_RM_MEM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg; + uint destoffset; + u8 destval; + u8 amt; + + /* + * Yet another weirdo special case instruction format. Part of + * the opcode held below in "RH". Doubly nested case would + * result, except that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + + switch (rh) { + case 0: + DECODE_PRINTF("ROL\t"); + break; + case 1: + DECODE_PRINTF("ROR\t"); + break; + case 2: + DECODE_PRINTF("RCL\t"); + break; + case 3: + DECODE_PRINTF("RCR\t"); + break; + case 4: + DECODE_PRINTF("SHL\t"); + break; + case 5: + DECODE_PRINTF("SHR\t"); + break; + case 6: + DECODE_PRINTF("SAL\t"); + break; + case 7: + DECODE_PRINTF("SAR\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + switch (mod) { + case 0: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm00_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, amt); + store_data_byte(destoffset, destval); + break; + case 1: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm01_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, amt); + store_data_byte(destoffset, destval); + break; + case 2: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, amt); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (*destreg, amt); + *destreg = destval; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/* used by opcodes c1, d1, and d3. */ +static u16(*opcD1_word_operation[])(u16 s, u8 d) = +{ + rol_word, + ror_word, + rcl_word, + rcr_word, + shl_word, + shr_word, + shl_word, /* sal_byte === shl_byte by definition */ + sar_word, +}; + +/* used by opcodes c1, d1, and d3. */ +static u32 (*opcD1_long_operation[])(u32 s, u8 d) = +{ + rol_long, + ror_long, + rcl_long, + rcr_long, + shl_long, + shr_long, + shl_long, /* sal_byte === shl_byte by definition */ + sar_long, +}; + +/**************************************************************************** +REMARKS: +Handles opcode 0xc1 +****************************************************************************/ +static void x86emuOp_opcC1_word_RM_MEM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + u8 amt; + + /* + * Yet another weirdo special case instruction format. Part of + * the opcode held below in "RH". Doubly nested case would + * result, except that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + + switch (rh) { + case 0: + DECODE_PRINTF("ROL\t"); + break; + case 1: + DECODE_PRINTF("ROR\t"); + break; + case 2: + DECODE_PRINTF("RCL\t"); + break; + case 3: + DECODE_PRINTF("RCR\t"); + break; + case 4: + DECODE_PRINTF("SHL\t"); + break; + case 5: + DECODE_PRINTF("SHR\t"); + break; + case 6: + DECODE_PRINTF("SAL\t"); + break; + case 7: + DECODE_PRINTF("SAR\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm00_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, amt); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm00_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, amt); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm01_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, amt); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm01_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, amt); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm10_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, amt); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm10_address(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, amt); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + TRACE_AND_STEP(); + *destreg = (*opcD1_long_operation[rh]) (*destreg, amt); + } else { + u16 *destreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + amt = fetch_byte_imm(); + DECODE_PRINTF2(",%x\n", amt); + TRACE_AND_STEP(); + *destreg = (*opcD1_word_operation[rh]) (*destreg, amt); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc2 +****************************************************************************/ +static void x86emuOp_ret_near_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 imm; + + START_OF_INSTR(); + DECODE_PRINTF("RET\t"); + imm = fetch_word_imm(); + DECODE_PRINTF2("%x\n", imm); + RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip); + TRACE_AND_STEP(); + M.x86.R_IP = pop_word(); + M.x86.R_SP += imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc3 +****************************************************************************/ +static void x86emuOp_ret_near(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("RET\n"); + RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip); + TRACE_AND_STEP(); + M.x86.R_IP = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc4 +****************************************************************************/ +static void x86emuOp_les_R_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rh, rl; + u16 *dstreg; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("LES\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_ES = fetch_data_word(srcoffset + 2); + break; + case 1: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_ES = fetch_data_word(srcoffset + 2); + break; + case 2: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_ES = fetch_data_word(srcoffset + 2); + break; + case 3: /* register to register */ + /* UNDEFINED! */ + TRACE_AND_STEP(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc5 +****************************************************************************/ +static void x86emuOp_lds_R_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rh, rl; + u16 *dstreg; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("LDS\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_DS = fetch_data_word(srcoffset + 2); + break; + case 1: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_DS = fetch_data_word(srcoffset + 2); + break; + case 2: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_DS = fetch_data_word(srcoffset + 2); + break; + case 3: /* register to register */ + /* UNDEFINED! */ + TRACE_AND_STEP(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc6 +****************************************************************************/ +static void x86emuOp_mov_byte_RM_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg; + uint destoffset; + u8 imm; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + if (rh != 0) { + DECODE_PRINTF("ILLEGAL DECODE OF OPCODE c6\n"); + HALT_SYS(); + } + switch (mod) { + case 0: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm00_address(rl); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%2x\n", imm); + TRACE_AND_STEP(); + store_data_byte(destoffset, imm); + break; + case 1: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm01_address(rl); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%2x\n", imm); + TRACE_AND_STEP(); + store_data_byte(destoffset, imm); + break; + case 2: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%2x\n", imm); + TRACE_AND_STEP(); + store_data_byte(destoffset, imm); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + imm = fetch_byte_imm(); + DECODE_PRINTF2(",%2x\n", imm); + TRACE_AND_STEP(); + *destreg = imm; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc7 +****************************************************************************/ +static void x86emuOp_mov_word_RM_IMM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("MOV\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + if (rh != 0) { + DECODE_PRINTF("ILLEGAL DECODE OF OPCODE 8F\n"); + HALT_SYS(); + } + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm00_address(rl); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + store_data_long(destoffset, imm); + } else { + u16 imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm00_address(rl); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + store_data_word(destoffset, imm); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm01_address(rl); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + store_data_long(destoffset, imm); + } else { + u16 imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm01_address(rl); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + store_data_word(destoffset, imm); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 imm; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm10_address(rl); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + store_data_long(destoffset, imm); + } else { + u16 imm; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm10_address(rl); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + store_data_word(destoffset, imm); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 imm; + + destreg = DECODE_RM_LONG_REGISTER(rl); + imm = fetch_long_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + *destreg = imm; + } else { + u16 *destreg; + u16 imm; + + destreg = DECODE_RM_WORD_REGISTER(rl); + imm = fetch_word_imm(); + DECODE_PRINTF2(",%x\n", imm); + TRACE_AND_STEP(); + *destreg = imm; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc8 +****************************************************************************/ +static void x86emuOp_enter(u8 X86EMU_UNUSED(op1)) +{ + u16 local,frame_pointer; + u8 nesting; + int i; + + START_OF_INSTR(); + local = fetch_word_imm(); + nesting = fetch_byte_imm(); + DECODE_PRINTF2("ENTER %x\n", local); + DECODE_PRINTF2(",%x\n", nesting); + TRACE_AND_STEP(); + push_word(M.x86.R_BP); + frame_pointer = M.x86.R_SP; + if (nesting > 0) { + for (i = 1; i < nesting; i++) { + M.x86.R_BP -= 2; + push_word(fetch_data_word_abs(M.x86.R_SS, M.x86.R_BP)); + } + push_word(frame_pointer); + } + M.x86.R_BP = frame_pointer; + M.x86.R_SP = (u16)(M.x86.R_SP - local); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xc9 +****************************************************************************/ +static void x86emuOp_leave(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("LEAVE\n"); + TRACE_AND_STEP(); + M.x86.R_SP = M.x86.R_BP; + M.x86.R_BP = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xca +****************************************************************************/ +static void x86emuOp_ret_far_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 imm; + + START_OF_INSTR(); + DECODE_PRINTF("RETF\t"); + imm = fetch_word_imm(); + DECODE_PRINTF2("%x\n", imm); + RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip); + TRACE_AND_STEP(); + M.x86.R_IP = pop_word(); + M.x86.R_CS = pop_word(); + M.x86.R_SP += imm; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xcb +****************************************************************************/ +static void x86emuOp_ret_far(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("RETF\n"); + RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip); + TRACE_AND_STEP(); + M.x86.R_IP = pop_word(); + M.x86.R_CS = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xcc +****************************************************************************/ +static void x86emuOp_int3(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("INT 3\n"); + TRACE_AND_STEP(); + if (_X86EMU_intrTab[3]) { + (*_X86EMU_intrTab[3])(3); + } else { + push_word((u16)M.x86.R_FLG); + CLEAR_FLAG(F_IF); + CLEAR_FLAG(F_TF); + push_word(M.x86.R_CS); + M.x86.R_CS = mem_access_word(3 * 4 + 2); + push_word(M.x86.R_IP); + M.x86.R_IP = mem_access_word(3 * 4); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xcd +****************************************************************************/ +static void x86emuOp_int_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 intnum; + + START_OF_INSTR(); + DECODE_PRINTF("INT\t"); + intnum = fetch_byte_imm(); + DECODE_PRINTF2("%x\n", intnum); + TRACE_AND_STEP(); + if (_X86EMU_intrTab[intnum]) { + (*_X86EMU_intrTab[intnum])(intnum); + } else { + push_word((u16)M.x86.R_FLG); + CLEAR_FLAG(F_IF); + CLEAR_FLAG(F_TF); + push_word(M.x86.R_CS); + M.x86.R_CS = mem_access_word(intnum * 4 + 2); + push_word(M.x86.R_IP); + M.x86.R_IP = mem_access_word(intnum * 4); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xce +****************************************************************************/ +static void x86emuOp_into(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("INTO\n"); + TRACE_AND_STEP(); + if (ACCESS_FLAG(F_OF)) { + if (_X86EMU_intrTab[4]) { + (*_X86EMU_intrTab[4])(4); + } else { + push_word((u16)M.x86.R_FLG); + CLEAR_FLAG(F_IF); + CLEAR_FLAG(F_TF); + push_word(M.x86.R_CS); + M.x86.R_CS = mem_access_word(4 * 4 + 2); + push_word(M.x86.R_IP); + M.x86.R_IP = mem_access_word(4 * 4); + } + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xcf +****************************************************************************/ +static void x86emuOp_iret(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("IRET\n"); + + TRACE_AND_STEP(); + + M.x86.R_IP = pop_word(); + M.x86.R_CS = pop_word(); + M.x86.R_FLG = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xd0 +****************************************************************************/ +static void x86emuOp_opcD0_byte_RM_1(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg; + uint destoffset; + u8 destval; + + /* + * Yet another weirdo special case instruction format. Part of + * the opcode held below in "RH". Doubly nested case would + * result, except that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + switch (rh) { + case 0: + DECODE_PRINTF("ROL\t"); + break; + case 1: + DECODE_PRINTF("ROR\t"); + break; + case 2: + DECODE_PRINTF("RCL\t"); + break; + case 3: + DECODE_PRINTF("RCR\t"); + break; + case 4: + DECODE_PRINTF("SHL\t"); + break; + case 5: + DECODE_PRINTF("SHR\t"); + break; + case 6: + DECODE_PRINTF("SAL\t"); + break; + case 7: + DECODE_PRINTF("SAR\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + switch (mod) { + case 0: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, 1); + store_data_byte(destoffset, destval); + break; + case 1: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, 1); + store_data_byte(destoffset, destval); + break; + case 2: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, 1); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(",1\n"); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (*destreg, 1); + *destreg = destval; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xd1 +****************************************************************************/ +static void x86emuOp_opcD1_word_RM_1(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + /* + * Yet another weirdo special case instruction format. Part of + * the opcode held below in "RH". Doubly nested case would + * result, except that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + switch (rh) { + case 0: + DECODE_PRINTF("ROL\t"); + break; + case 1: + DECODE_PRINTF("ROR\t"); + break; + case 2: + DECODE_PRINTF("RCL\t"); + break; + case 3: + DECODE_PRINTF("RCR\t"); + break; + case 4: + DECODE_PRINTF("SHL\t"); + break; + case 5: + DECODE_PRINTF("SHR\t"); + break; + case 6: + DECODE_PRINTF("SAL\t"); + break; + case 7: + DECODE_PRINTF("SAR\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, 1); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, 1); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, 1); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, 1); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, 1); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(",1\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, 1); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *destreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(",1\n"); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (*destreg, 1); + *destreg = destval; + } else { + u16 destval; + u16 *destreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(",1\n"); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (*destreg, 1); + *destreg = destval; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xd2 +****************************************************************************/ +static void x86emuOp_opcD2_byte_RM_CL(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg; + uint destoffset; + u8 destval; + u8 amt; + + /* + * Yet another weirdo special case instruction format. Part of + * the opcode held below in "RH". Doubly nested case would + * result, except that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + switch (rh) { + case 0: + DECODE_PRINTF("ROL\t"); + break; + case 1: + DECODE_PRINTF("ROR\t"); + break; + case 2: + DECODE_PRINTF("RCL\t"); + break; + case 3: + DECODE_PRINTF("RCR\t"); + break; + case 4: + DECODE_PRINTF("SHL\t"); + break; + case 5: + DECODE_PRINTF("SHR\t"); + break; + case 6: + DECODE_PRINTF("SAL\t"); + break; + case 7: + DECODE_PRINTF("SAR\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + amt = M.x86.R_CL; + switch (mod) { + case 0: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, amt); + store_data_byte(destoffset, destval); + break; + case 1: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, amt); + store_data_byte(destoffset, destval); + break; + case 2: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (destval, amt); + store_data_byte(destoffset, destval); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = (*opcD0_byte_operation[rh]) (*destreg, amt); + *destreg = destval; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xd3 +****************************************************************************/ +static void x86emuOp_opcD3_word_RM_CL(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + u8 amt; + + /* + * Yet another weirdo special case instruction format. Part of + * the opcode held below in "RH". Doubly nested case would + * result, except that the decoded instruction + */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + switch (rh) { + case 0: + DECODE_PRINTF("ROL\t"); + break; + case 1: + DECODE_PRINTF("ROR\t"); + break; + case 2: + DECODE_PRINTF("RCL\t"); + break; + case 3: + DECODE_PRINTF("RCR\t"); + break; + case 4: + DECODE_PRINTF("SHL\t"); + break; + case 5: + DECODE_PRINTF("SHR\t"); + break; + case 6: + DECODE_PRINTF("SAL\t"); + break; + case 7: + DECODE_PRINTF("SAR\t"); + break; + } + } +#endif + /* know operation, decode the mod byte to find the addressing + mode. */ + amt = M.x86.R_CL; + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, amt); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, amt); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, amt); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, amt); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_long_operation[rh]) (destval, amt); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("WORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(",CL\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = (*opcD1_word_operation[rh]) (destval, amt); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + *destreg = (*opcD1_long_operation[rh]) (*destreg, amt); + } else { + u16 *destreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + *destreg = (*opcD1_word_operation[rh]) (*destreg, amt); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xd4 +****************************************************************************/ +static void x86emuOp_aam(u8 X86EMU_UNUSED(op1)) +{ + u8 a; + + START_OF_INSTR(); + DECODE_PRINTF("AAM\n"); + a = fetch_byte_imm(); /* this is a stupid encoding. */ + if (a != 10) { + /* fix: add base decoding + aam_word(u8 val, int base a) */ + DECODE_PRINTF("ERROR DECODING AAM\n"); + TRACE_REGS(); + HALT_SYS(); + } + TRACE_AND_STEP(); + /* note the type change here --- returning AL and AH in AX. */ + M.x86.R_AX = aam_word(M.x86.R_AL); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xd5 +****************************************************************************/ +static void x86emuOp_aad(u8 X86EMU_UNUSED(op1)) +{ + u8 a; + + START_OF_INSTR(); + DECODE_PRINTF("AAD\n"); + a = fetch_byte_imm(); + if (a != 10) { + /* fix: add base decoding + aad_word(u16 val, int base a) */ + DECODE_PRINTF("ERROR DECODING AAM\n"); + TRACE_REGS(); + HALT_SYS(); + } + TRACE_AND_STEP(); + M.x86.R_AX = aad_word(M.x86.R_AX); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/* opcode 0xd6 ILLEGAL OPCODE */ + +/**************************************************************************** +REMARKS: +Handles opcode 0xd7 +****************************************************************************/ +static void x86emuOp_xlat(u8 X86EMU_UNUSED(op1)) +{ + u16 addr; + + START_OF_INSTR(); + DECODE_PRINTF("XLAT\n"); + TRACE_AND_STEP(); + addr = (u16)(M.x86.R_BX + (u8)M.x86.R_AL); + M.x86.R_AL = fetch_data_byte(addr); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/* instuctions D8 .. DF are in i87_ops.c */ + +/**************************************************************************** +REMARKS: +Handles opcode 0xe0 +****************************************************************************/ +static void x86emuOp_loopne(u8 X86EMU_UNUSED(op1)) +{ + s16 ip; + + START_OF_INSTR(); + DECODE_PRINTF("LOOPNE\t"); + ip = (s8) fetch_byte_imm(); + ip += (s16) M.x86.R_IP; + DECODE_PRINTF2("%04x\n", ip); + TRACE_AND_STEP(); + M.x86.R_CX -= 1; + if (M.x86.R_CX != 0 && !ACCESS_FLAG(F_ZF)) /* CX != 0 and !ZF */ + M.x86.R_IP = ip; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe1 +****************************************************************************/ +static void x86emuOp_loope(u8 X86EMU_UNUSED(op1)) +{ + s16 ip; + + START_OF_INSTR(); + DECODE_PRINTF("LOOPE\t"); + ip = (s8) fetch_byte_imm(); + ip += (s16) M.x86.R_IP; + DECODE_PRINTF2("%04x\n", ip); + TRACE_AND_STEP(); + M.x86.R_CX -= 1; + if (M.x86.R_CX != 0 && ACCESS_FLAG(F_ZF)) /* CX != 0 and ZF */ + M.x86.R_IP = ip; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe2 +****************************************************************************/ +static void x86emuOp_loop(u8 X86EMU_UNUSED(op1)) +{ + s16 ip; + + START_OF_INSTR(); + DECODE_PRINTF("LOOP\t"); + ip = (s8) fetch_byte_imm(); + ip += (s16) M.x86.R_IP; + DECODE_PRINTF2("%04x\n", ip); + TRACE_AND_STEP(); + M.x86.R_CX -= 1; + if (M.x86.R_CX != 0) + M.x86.R_IP = ip; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe3 +****************************************************************************/ +static void x86emuOp_jcxz(u8 X86EMU_UNUSED(op1)) +{ + u16 target; + s8 offset; + + /* jump to byte offset if overflow flag is set */ + START_OF_INSTR(); + DECODE_PRINTF("JCXZ\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + if (M.x86.R_CX == 0) + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe4 +****************************************************************************/ +static void x86emuOp_in_byte_AL_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 port; + + START_OF_INSTR(); + DECODE_PRINTF("IN\t"); + port = (u8) fetch_byte_imm(); + DECODE_PRINTF2("%x,AL\n", port); + TRACE_AND_STEP(); + M.x86.R_AL = (*sys_inb)(port); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe5 +****************************************************************************/ +static void x86emuOp_in_word_AX_IMM(u8 X86EMU_UNUSED(op1)) +{ + u8 port; + + START_OF_INSTR(); + DECODE_PRINTF("IN\t"); + port = (u8) fetch_byte_imm(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF2("EAX,%x\n", port); + } else { + DECODE_PRINTF2("AX,%x\n", port); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = (*sys_inl)(port); + } else { + M.x86.R_AX = (*sys_inw)(port); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe6 +****************************************************************************/ +static void x86emuOp_out_byte_IMM_AL(u8 X86EMU_UNUSED(op1)) +{ + u8 port; + + START_OF_INSTR(); + DECODE_PRINTF("OUT\t"); + port = (u8) fetch_byte_imm(); + DECODE_PRINTF2("%x,AL\n", port); + TRACE_AND_STEP(); + (*sys_outb)(port, M.x86.R_AL); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe7 +****************************************************************************/ +static void x86emuOp_out_word_IMM_AX(u8 X86EMU_UNUSED(op1)) +{ + u8 port; + + START_OF_INSTR(); + DECODE_PRINTF("OUT\t"); + port = (u8) fetch_byte_imm(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF2("%x,EAX\n", port); + } else { + DECODE_PRINTF2("%x,AX\n", port); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + (*sys_outl)(port, M.x86.R_EAX); + } else { + (*sys_outw)(port, M.x86.R_AX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe8 +****************************************************************************/ +static void x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1)) +{ + s16 ip; + + START_OF_INSTR(); + DECODE_PRINTF("CALL\t"); + ip = (s16) fetch_word_imm(); + ip += (s16) M.x86.R_IP; /* CHECK SIGN */ + DECODE_PRINTF2("%04x\n", (u16)ip); + CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip, ""); + TRACE_AND_STEP(); + push_word(M.x86.R_IP); + M.x86.R_IP = ip; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xe9 +****************************************************************************/ +static void x86emuOp_jump_near_IMM(u8 X86EMU_UNUSED(op1)) +{ + int ip; + + START_OF_INSTR(); + DECODE_PRINTF("JMP\t"); + ip = (s16)fetch_word_imm(); + ip += (s16)M.x86.R_IP; + DECODE_PRINTF2("%04x\n", (u16)ip); + TRACE_AND_STEP(); + M.x86.R_IP = (u16)ip; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xea +****************************************************************************/ +static void x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 cs, ip; + + START_OF_INSTR(); + DECODE_PRINTF("JMP\tFAR "); + ip = fetch_word_imm(); + cs = fetch_word_imm(); + DECODE_PRINTF2("%04x:", cs); + DECODE_PRINTF2("%04x\n", ip); + TRACE_AND_STEP(); + M.x86.R_IP = ip; + M.x86.R_CS = cs; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xeb +****************************************************************************/ +static void x86emuOp_jump_byte_IMM(u8 X86EMU_UNUSED(op1)) +{ + u16 target; + s8 offset; + + START_OF_INSTR(); + DECODE_PRINTF("JMP\t"); + offset = (s8)fetch_byte_imm(); + target = (u16)(M.x86.R_IP + offset); + DECODE_PRINTF2("%x\n", target); + TRACE_AND_STEP(); + M.x86.R_IP = target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xec +****************************************************************************/ +static void x86emuOp_in_byte_AL_DX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("IN\tAL,DX\n"); + TRACE_AND_STEP(); + M.x86.R_AL = (*sys_inb)(M.x86.R_DX); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xed +****************************************************************************/ +static void x86emuOp_in_word_AX_DX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("IN\tEAX,DX\n"); + } else { + DECODE_PRINTF("IN\tAX,DX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_EAX = (*sys_inl)(M.x86.R_DX); + } else { + M.x86.R_AX = (*sys_inw)(M.x86.R_DX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xee +****************************************************************************/ +static void x86emuOp_out_byte_DX_AL(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("OUT\tDX,AL\n"); + TRACE_AND_STEP(); + (*sys_outb)(M.x86.R_DX, M.x86.R_AL); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xef +****************************************************************************/ +static void x86emuOp_out_word_DX_AX(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("OUT\tDX,EAX\n"); + } else { + DECODE_PRINTF("OUT\tDX,AX\n"); + } + TRACE_AND_STEP(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + (*sys_outl)(M.x86.R_DX, M.x86.R_EAX); + } else { + (*sys_outw)(M.x86.R_DX, M.x86.R_AX); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf0 +****************************************************************************/ +static void x86emuOp_lock(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("LOCK:\n"); + TRACE_AND_STEP(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/*opcode 0xf1 ILLEGAL OPERATION */ + +/**************************************************************************** +REMARKS: +Handles opcode 0xf2 +****************************************************************************/ +static void x86emuOp_repne(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("REPNE\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_PREFIX_REPNE; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf3 +****************************************************************************/ +static void x86emuOp_repe(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("REPE\n"); + TRACE_AND_STEP(); + M.x86.mode |= SYSMODE_PREFIX_REPE; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf4 +****************************************************************************/ +static void x86emuOp_halt(u8 X86EMU_UNUSED(op1)) +{ + START_OF_INSTR(); + DECODE_PRINTF("HALT\n"); + TRACE_AND_STEP(); + HALT_SYS(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf5 +****************************************************************************/ +static void x86emuOp_cmc(u8 X86EMU_UNUSED(op1)) +{ + /* complement the carry flag. */ + START_OF_INSTR(); + DECODE_PRINTF("CMC\n"); + TRACE_AND_STEP(); + TOGGLE_FLAG(F_CF); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf6 +****************************************************************************/ +static void x86emuOp_opcF6_byte_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + u8 *destreg; + uint destoffset; + u8 destval, srcval; + + /* long, drawn out code follows. Double switch for a total + of 32 cases. */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: /* mod=00 */ + switch (rh) { + case 0: /* test byte imm */ + DECODE_PRINTF("TEST\tBYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%02x\n", srcval); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + test_byte(destval, srcval); + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n"); + HALT_SYS(); + break; + case 2: + DECODE_PRINTF("NOT\tBYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = not_byte(destval); + store_data_byte(destoffset, destval); + break; + case 3: + DECODE_PRINTF("NEG\tBYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = neg_byte(destval); + store_data_byte(destoffset, destval); + break; + case 4: + DECODE_PRINTF("MUL\tBYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + mul_byte(destval); + break; + case 5: + DECODE_PRINTF("IMUL\tBYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + imul_byte(destval); + break; + case 6: + DECODE_PRINTF("DIV\tBYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + div_byte(destval); + break; + case 7: + DECODE_PRINTF("IDIV\tBYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + idiv_byte(destval); + break; + } + break; /* end mod==00 */ + case 1: /* mod=01 */ + switch (rh) { + case 0: /* test byte imm */ + DECODE_PRINTF("TEST\tBYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%02x\n", srcval); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + test_byte(destval, srcval); + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n"); + HALT_SYS(); + break; + case 2: + DECODE_PRINTF("NOT\tBYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = not_byte(destval); + store_data_byte(destoffset, destval); + break; + case 3: + DECODE_PRINTF("NEG\tBYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = neg_byte(destval); + store_data_byte(destoffset, destval); + break; + case 4: + DECODE_PRINTF("MUL\tBYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + mul_byte(destval); + break; + case 5: + DECODE_PRINTF("IMUL\tBYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + imul_byte(destval); + break; + case 6: + DECODE_PRINTF("DIV\tBYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + div_byte(destval); + break; + case 7: + DECODE_PRINTF("IDIV\tBYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + idiv_byte(destval); + break; + } + break; /* end mod==01 */ + case 2: /* mod=10 */ + switch (rh) { + case 0: /* test byte imm */ + DECODE_PRINTF("TEST\tBYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%02x\n", srcval); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + test_byte(destval, srcval); + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n"); + HALT_SYS(); + break; + case 2: + DECODE_PRINTF("NOT\tBYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = not_byte(destval); + store_data_byte(destoffset, destval); + break; + case 3: + DECODE_PRINTF("NEG\tBYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = neg_byte(destval); + store_data_byte(destoffset, destval); + break; + case 4: + DECODE_PRINTF("MUL\tBYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + mul_byte(destval); + break; + case 5: + DECODE_PRINTF("IMUL\tBYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + imul_byte(destval); + break; + case 6: + DECODE_PRINTF("DIV\tBYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + div_byte(destval); + break; + case 7: + DECODE_PRINTF("IDIV\tBYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + idiv_byte(destval); + break; + } + break; /* end mod==10 */ + case 3: /* mod=11 */ + switch (rh) { + case 0: /* test byte imm */ + DECODE_PRINTF("TEST\t"); + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF(","); + srcval = fetch_byte_imm(); + DECODE_PRINTF2("%02x\n", srcval); + TRACE_AND_STEP(); + test_byte(*destreg, srcval); + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n"); + HALT_SYS(); + break; + case 2: + DECODE_PRINTF("NOT\t"); + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = not_byte(*destreg); + break; + case 3: + DECODE_PRINTF("NEG\t"); + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = neg_byte(*destreg); + break; + case 4: + DECODE_PRINTF("MUL\t"); + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + mul_byte(*destreg); /*!!! */ + break; + case 5: + DECODE_PRINTF("IMUL\t"); + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + imul_byte(*destreg); + break; + case 6: + DECODE_PRINTF("DIV\t"); + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + div_byte(*destreg); + break; + case 7: + DECODE_PRINTF("IDIV\t"); + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + idiv_byte(*destreg); + break; + } + break; /* end mod==11 */ + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf7 +****************************************************************************/ +static void x86emuOp_opcF7_word_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rl, rh; + uint destoffset; + + /* long, drawn out code follows. Double switch for a total + of 32 cases. */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: /* mod=00 */ + switch (rh) { + case 0: /* test word imm */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,srcval; + + DECODE_PRINTF("TEST\tDWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + srcval = fetch_long_imm(); + DECODE_PRINTF2("%x\n", srcval); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + test_long(destval, srcval); + } else { + u16 destval,srcval; + + DECODE_PRINTF("TEST\tWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + srcval = fetch_word_imm(); + DECODE_PRINTF2("%x\n", srcval); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + test_word(destval, srcval); + } + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F7\n"); + HALT_SYS(); + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("NOT\tDWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = not_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("NOT\tWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = not_word(destval); + store_data_word(destoffset, destval); + } + break; + case 3: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("NEG\tDWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = neg_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("NEG\tWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = neg_word(destval); + store_data_word(destoffset, destval); + } + break; + case 4: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("MUL\tDWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + mul_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("MUL\tWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + mul_word(destval); + } + break; + case 5: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("IMUL\tDWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + imul_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("IMUL\tWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + imul_word(destval); + } + break; + case 6: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DIV\tDWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + div_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("DIV\tWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + div_word(destval); + } + break; + case 7: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("IDIV\tDWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + idiv_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("IDIV\tWORD PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + idiv_word(destval); + } + break; + } + break; /* end mod==00 */ + case 1: /* mod=01 */ + switch (rh) { + case 0: /* test word imm */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,srcval; + + DECODE_PRINTF("TEST\tDWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + srcval = fetch_long_imm(); + DECODE_PRINTF2("%x\n", srcval); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + test_long(destval, srcval); + } else { + u16 destval,srcval; + + DECODE_PRINTF("TEST\tWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + srcval = fetch_word_imm(); + DECODE_PRINTF2("%x\n", srcval); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + test_word(destval, srcval); + } + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=01 RH=01 OP=F6\n"); + HALT_SYS(); + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("NOT\tDWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = not_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("NOT\tWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = not_word(destval); + store_data_word(destoffset, destval); + } + break; + case 3: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("NEG\tDWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = neg_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("NEG\tWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = neg_word(destval); + store_data_word(destoffset, destval); + } + break; + case 4: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("MUL\tDWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + mul_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("MUL\tWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + mul_word(destval); + } + break; + case 5: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("IMUL\tDWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + imul_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("IMUL\tWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + imul_word(destval); + } + break; + case 6: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DIV\tDWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + div_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("DIV\tWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + div_word(destval); + } + break; + case 7: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("IDIV\tDWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + idiv_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("IDIV\tWORD PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + idiv_word(destval); + } + break; + } + break; /* end mod==01 */ + case 2: /* mod=10 */ + switch (rh) { + case 0: /* test word imm */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval,srcval; + + DECODE_PRINTF("TEST\tDWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + srcval = fetch_long_imm(); + DECODE_PRINTF2("%x\n", srcval); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + test_long(destval, srcval); + } else { + u16 destval,srcval; + + DECODE_PRINTF("TEST\tWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + srcval = fetch_word_imm(); + DECODE_PRINTF2("%x\n", srcval); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + test_word(destval, srcval); + } + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=10 RH=01 OP=F6\n"); + HALT_SYS(); + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("NOT\tDWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = not_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("NOT\tWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = not_word(destval); + store_data_word(destoffset, destval); + } + break; + case 3: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("NEG\tDWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = neg_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + DECODE_PRINTF("NEG\tWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = neg_word(destval); + store_data_word(destoffset, destval); + } + break; + case 4: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("MUL\tDWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + mul_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("MUL\tWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + mul_word(destval); + } + break; + case 5: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("IMUL\tDWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + imul_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("IMUL\tWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + imul_word(destval); + } + break; + case 6: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("DIV\tDWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + div_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("DIV\tWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + div_word(destval); + } + break; + case 7: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + DECODE_PRINTF("IDIV\tDWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + idiv_long(destval); + } else { + u16 destval; + + DECODE_PRINTF("IDIV\tWORD PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + idiv_word(destval); + } + break; + } + break; /* end mod==10 */ + case 3: /* mod=11 */ + switch (rh) { + case 0: /* test word imm */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + DECODE_PRINTF("TEST\t"); + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + srcval = fetch_long_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + test_long(*destreg, srcval); + } else { + u16 *destreg; + u16 srcval; + + DECODE_PRINTF("TEST\t"); + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + srcval = fetch_word_imm(); + DECODE_PRINTF2("%x\n", srcval); + TRACE_AND_STEP(); + test_word(*destreg, srcval); + } + break; + case 1: + DECODE_PRINTF("ILLEGAL OP MOD=00 RH=01 OP=F6\n"); + HALT_SYS(); + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + DECODE_PRINTF("NOT\t"); + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = not_long(*destreg); + } else { + u16 *destreg; + + DECODE_PRINTF("NOT\t"); + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = not_word(*destreg); + } + break; + case 3: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + DECODE_PRINTF("NEG\t"); + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = neg_long(*destreg); + } else { + u16 *destreg; + + DECODE_PRINTF("NEG\t"); + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = neg_word(*destreg); + } + break; + case 4: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + DECODE_PRINTF("MUL\t"); + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + mul_long(*destreg); /*!!! */ + } else { + u16 *destreg; + + DECODE_PRINTF("MUL\t"); + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + mul_word(*destreg); /*!!! */ + } + break; + case 5: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + DECODE_PRINTF("IMUL\t"); + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + imul_long(*destreg); + } else { + u16 *destreg; + + DECODE_PRINTF("IMUL\t"); + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + imul_word(*destreg); + } + break; + case 6: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + DECODE_PRINTF("DIV\t"); + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + div_long(*destreg); + } else { + u16 *destreg; + + DECODE_PRINTF("DIV\t"); + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + div_word(*destreg); + } + break; + case 7: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + DECODE_PRINTF("IDIV\t"); + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + idiv_long(*destreg); + } else { + u16 *destreg; + + DECODE_PRINTF("IDIV\t"); + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + idiv_word(*destreg); + } + break; + } + break; /* end mod==11 */ + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf8 +****************************************************************************/ +static void x86emuOp_clc(u8 X86EMU_UNUSED(op1)) +{ + /* clear the carry flag. */ + START_OF_INSTR(); + DECODE_PRINTF("CLC\n"); + TRACE_AND_STEP(); + CLEAR_FLAG(F_CF); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xf9 +****************************************************************************/ +static void x86emuOp_stc(u8 X86EMU_UNUSED(op1)) +{ + /* set the carry flag. */ + START_OF_INSTR(); + DECODE_PRINTF("STC\n"); + TRACE_AND_STEP(); + SET_FLAG(F_CF); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xfa +****************************************************************************/ +static void x86emuOp_cli(u8 X86EMU_UNUSED(op1)) +{ + /* clear interrupts. */ + START_OF_INSTR(); + DECODE_PRINTF("CLI\n"); + TRACE_AND_STEP(); + CLEAR_FLAG(F_IF); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xfb +****************************************************************************/ +static void x86emuOp_sti(u8 X86EMU_UNUSED(op1)) +{ + /* enable interrupts. */ + START_OF_INSTR(); + DECODE_PRINTF("STI\n"); + TRACE_AND_STEP(); + SET_FLAG(F_IF); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xfc +****************************************************************************/ +static void x86emuOp_cld(u8 X86EMU_UNUSED(op1)) +{ + /* clear interrupts. */ + START_OF_INSTR(); + DECODE_PRINTF("CLD\n"); + TRACE_AND_STEP(); + CLEAR_FLAG(F_DF); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xfd +****************************************************************************/ +static void x86emuOp_std(u8 X86EMU_UNUSED(op1)) +{ + /* clear interrupts. */ + START_OF_INSTR(); + DECODE_PRINTF("STD\n"); + TRACE_AND_STEP(); + SET_FLAG(F_DF); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xfe +****************************************************************************/ +static void x86emuOp_opcFE_byte_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rh, rl; + u8 destval; + uint destoffset; + u8 *destreg; + + /* Yet another special case instruction. */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + + switch (rh) { + case 0: + DECODE_PRINTF("INC\t"); + break; + case 1: + DECODE_PRINTF("DEC\t"); + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + DECODE_PRINTF2("ILLEGAL OP MAJOR OP 0xFE MINOR OP %x \n", mod); + HALT_SYS(); + break; + } + } +#endif + switch (mod) { + case 0: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + switch (rh) { + case 0: /* inc word ptr ... */ + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = inc_byte(destval); + store_data_byte(destoffset, destval); + break; + case 1: /* dec word ptr ... */ + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = dec_byte(destval); + store_data_byte(destoffset, destval); + break; + } + break; + case 1: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + switch (rh) { + case 0: + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = inc_byte(destval); + store_data_byte(destoffset, destval); + break; + case 1: + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = dec_byte(destval); + store_data_byte(destoffset, destval); + break; + } + break; + case 2: + DECODE_PRINTF("BYTE PTR "); + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + switch (rh) { + case 0: + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = inc_byte(destval); + store_data_byte(destoffset, destval); + break; + case 1: + destval = fetch_data_byte(destoffset); + TRACE_AND_STEP(); + destval = dec_byte(destval); + store_data_byte(destoffset, destval); + break; + } + break; + case 3: + destreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + switch (rh) { + case 0: + TRACE_AND_STEP(); + *destreg = inc_byte(*destreg); + break; + case 1: + TRACE_AND_STEP(); + *destreg = dec_byte(*destreg); + break; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0xff +****************************************************************************/ +static void x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1)) +{ + int mod, rh, rl; + uint destoffset = 0; + u16 *destreg; + u16 destval,destval2; + + /* Yet another special case instruction. */ + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); +#ifdef DEBUG + if (DEBUG_DECODE()) { + /* XXX DECODE_PRINTF may be changed to something more + general, so that it is important to leave the strings + in the same format, even though the result is that the + above test is done twice. */ + + switch (rh) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("INC\tDWORD PTR "); + } else { + DECODE_PRINTF("INC\tWORD PTR "); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + DECODE_PRINTF("DEC\tDWORD PTR "); + } else { + DECODE_PRINTF("DEC\tWORD PTR "); + } + break; + case 2: + DECODE_PRINTF("CALL\t"); + break; + case 3: + DECODE_PRINTF("CALL\tFAR "); + break; + case 4: + DECODE_PRINTF("JMP\t"); + break; + case 5: + DECODE_PRINTF("JMP\tFAR "); + break; + case 6: + DECODE_PRINTF("PUSH\t"); + break; + case 7: + DECODE_PRINTF("ILLEGAL DECODING OF OPCODE FF\t"); + HALT_SYS(); + break; + } + } +#endif + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + switch (rh) { + case 0: /* inc word ptr ... */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = inc_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = inc_word(destval); + store_data_word(destoffset, destval); + } + break; + case 1: /* dec word ptr ... */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = dec_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = dec_word(destval); + store_data_word(destoffset, destval); + } + break; + case 2: /* call word ptr ... */ + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + push_word(M.x86.R_IP); + M.x86.R_IP = destval; + break; + case 3: /* call far ptr ... */ + destval = fetch_data_word(destoffset); + destval2 = fetch_data_word(destoffset + 2); + TRACE_AND_STEP(); + push_word(M.x86.R_CS); + M.x86.R_CS = destval2; + push_word(M.x86.R_IP); + M.x86.R_IP = destval; + break; + case 4: /* jmp word ptr ... */ + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + M.x86.R_IP = destval; + break; + case 5: /* jmp far ptr ... */ + destval = fetch_data_word(destoffset); + destval2 = fetch_data_word(destoffset + 2); + TRACE_AND_STEP(); + M.x86.R_IP = destval; + M.x86.R_CS = destval2; + break; + case 6: /* push word ptr ... */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + push_long(destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + push_word(destval); + } + break; + } + break; + case 1: + destoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + switch (rh) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = inc_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = inc_word(destval); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = dec_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = dec_word(destval); + store_data_word(destoffset, destval); + } + break; + case 2: /* call word ptr ... */ + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + push_word(M.x86.R_IP); + M.x86.R_IP = destval; + break; + case 3: /* call far ptr ... */ + destval = fetch_data_word(destoffset); + destval2 = fetch_data_word(destoffset + 2); + TRACE_AND_STEP(); + push_word(M.x86.R_CS); + M.x86.R_CS = destval2; + push_word(M.x86.R_IP); + M.x86.R_IP = destval; + break; + case 4: /* jmp word ptr ... */ + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + M.x86.R_IP = destval; + break; + case 5: /* jmp far ptr ... */ + destval = fetch_data_word(destoffset); + destval2 = fetch_data_word(destoffset + 2); + TRACE_AND_STEP(); + M.x86.R_IP = destval; + M.x86.R_CS = destval2; + break; + case 6: /* push word ptr ... */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + push_long(destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + push_word(destval); + } + break; + } + break; + case 2: + destoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + switch (rh) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = inc_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = inc_word(destval); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + destval = dec_long(destval); + store_data_long(destoffset, destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + destval = dec_word(destval); + store_data_word(destoffset, destval); + } + break; + case 2: /* call word ptr ... */ + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + push_word(M.x86.R_IP); + M.x86.R_IP = destval; + break; + case 3: /* call far ptr ... */ + destval = fetch_data_word(destoffset); + destval2 = fetch_data_word(destoffset + 2); + TRACE_AND_STEP(); + push_word(M.x86.R_CS); + M.x86.R_CS = destval2; + push_word(M.x86.R_IP); + M.x86.R_IP = destval; + break; + case 4: /* jmp word ptr ... */ + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + M.x86.R_IP = destval; + break; + case 5: /* jmp far ptr ... */ + destval = fetch_data_word(destoffset); + destval2 = fetch_data_word(destoffset + 2); + TRACE_AND_STEP(); + M.x86.R_IP = destval; + M.x86.R_CS = destval2; + break; + case 6: /* push word ptr ... */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + + destval = fetch_data_long(destoffset); + TRACE_AND_STEP(); + push_long(destval); + } else { + u16 destval; + + destval = fetch_data_word(destoffset); + TRACE_AND_STEP(); + push_word(destval); + } + break; + } + break; + case 3: + switch (rh) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = inc_long(*destreg); + } else { + u16 *destreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = inc_word(*destreg); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = dec_long(*destreg); + } else { + u16 *destreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = dec_word(*destreg); + } + break; + case 2: /* call word ptr ... */ + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + push_word(M.x86.R_IP); + M.x86.R_IP = *destreg; + break; + case 3: /* jmp far ptr ... */ + DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n"); + TRACE_AND_STEP(); + HALT_SYS(); + break; + + case 4: /* jmp ... */ + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + M.x86.R_IP = (u16) (*destreg); + break; + case 5: /* jmp far ptr ... */ + DECODE_PRINTF("OPERATION UNDEFINED 0XFF \n"); + TRACE_AND_STEP(); + HALT_SYS(); + break; + case 6: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + push_long(*destreg); + } else { + u16 *destreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + push_word(*destreg); + } + break; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/*************************************************************************** + * Single byte operation code table: + **************************************************************************/ +void (*x86emu_optab[256])(u8) = +{ +/* 0x00 */ x86emuOp_add_byte_RM_R, +/* 0x01 */ x86emuOp_add_word_RM_R, +/* 0x02 */ x86emuOp_add_byte_R_RM, +/* 0x03 */ x86emuOp_add_word_R_RM, +/* 0x04 */ x86emuOp_add_byte_AL_IMM, +/* 0x05 */ x86emuOp_add_word_AX_IMM, +/* 0x06 */ x86emuOp_push_ES, +/* 0x07 */ x86emuOp_pop_ES, + +/* 0x08 */ x86emuOp_or_byte_RM_R, +/* 0x09 */ x86emuOp_or_word_RM_R, +/* 0x0a */ x86emuOp_or_byte_R_RM, +/* 0x0b */ x86emuOp_or_word_R_RM, +/* 0x0c */ x86emuOp_or_byte_AL_IMM, +/* 0x0d */ x86emuOp_or_word_AX_IMM, +/* 0x0e */ x86emuOp_push_CS, +/* 0x0f */ x86emuOp_two_byte, + +/* 0x10 */ x86emuOp_adc_byte_RM_R, +/* 0x11 */ x86emuOp_adc_word_RM_R, +/* 0x12 */ x86emuOp_adc_byte_R_RM, +/* 0x13 */ x86emuOp_adc_word_R_RM, +/* 0x14 */ x86emuOp_adc_byte_AL_IMM, +/* 0x15 */ x86emuOp_adc_word_AX_IMM, +/* 0x16 */ x86emuOp_push_SS, +/* 0x17 */ x86emuOp_pop_SS, + +/* 0x18 */ x86emuOp_sbb_byte_RM_R, +/* 0x19 */ x86emuOp_sbb_word_RM_R, +/* 0x1a */ x86emuOp_sbb_byte_R_RM, +/* 0x1b */ x86emuOp_sbb_word_R_RM, +/* 0x1c */ x86emuOp_sbb_byte_AL_IMM, +/* 0x1d */ x86emuOp_sbb_word_AX_IMM, +/* 0x1e */ x86emuOp_push_DS, +/* 0x1f */ x86emuOp_pop_DS, + +/* 0x20 */ x86emuOp_and_byte_RM_R, +/* 0x21 */ x86emuOp_and_word_RM_R, +/* 0x22 */ x86emuOp_and_byte_R_RM, +/* 0x23 */ x86emuOp_and_word_R_RM, +/* 0x24 */ x86emuOp_and_byte_AL_IMM, +/* 0x25 */ x86emuOp_and_word_AX_IMM, +/* 0x26 */ x86emuOp_segovr_ES, +/* 0x27 */ x86emuOp_daa, + +/* 0x28 */ x86emuOp_sub_byte_RM_R, +/* 0x29 */ x86emuOp_sub_word_RM_R, +/* 0x2a */ x86emuOp_sub_byte_R_RM, +/* 0x2b */ x86emuOp_sub_word_R_RM, +/* 0x2c */ x86emuOp_sub_byte_AL_IMM, +/* 0x2d */ x86emuOp_sub_word_AX_IMM, +/* 0x2e */ x86emuOp_segovr_CS, +/* 0x2f */ x86emuOp_das, + +/* 0x30 */ x86emuOp_xor_byte_RM_R, +/* 0x31 */ x86emuOp_xor_word_RM_R, +/* 0x32 */ x86emuOp_xor_byte_R_RM, +/* 0x33 */ x86emuOp_xor_word_R_RM, +/* 0x34 */ x86emuOp_xor_byte_AL_IMM, +/* 0x35 */ x86emuOp_xor_word_AX_IMM, +/* 0x36 */ x86emuOp_segovr_SS, +/* 0x37 */ x86emuOp_aaa, + +/* 0x38 */ x86emuOp_cmp_byte_RM_R, +/* 0x39 */ x86emuOp_cmp_word_RM_R, +/* 0x3a */ x86emuOp_cmp_byte_R_RM, +/* 0x3b */ x86emuOp_cmp_word_R_RM, +/* 0x3c */ x86emuOp_cmp_byte_AL_IMM, +/* 0x3d */ x86emuOp_cmp_word_AX_IMM, +/* 0x3e */ x86emuOp_segovr_DS, +/* 0x3f */ x86emuOp_aas, + +/* 0x40 */ x86emuOp_inc_AX, +/* 0x41 */ x86emuOp_inc_CX, +/* 0x42 */ x86emuOp_inc_DX, +/* 0x43 */ x86emuOp_inc_BX, +/* 0x44 */ x86emuOp_inc_SP, +/* 0x45 */ x86emuOp_inc_BP, +/* 0x46 */ x86emuOp_inc_SI, +/* 0x47 */ x86emuOp_inc_DI, + +/* 0x48 */ x86emuOp_dec_AX, +/* 0x49 */ x86emuOp_dec_CX, +/* 0x4a */ x86emuOp_dec_DX, +/* 0x4b */ x86emuOp_dec_BX, +/* 0x4c */ x86emuOp_dec_SP, +/* 0x4d */ x86emuOp_dec_BP, +/* 0x4e */ x86emuOp_dec_SI, +/* 0x4f */ x86emuOp_dec_DI, + +/* 0x50 */ x86emuOp_push_AX, +/* 0x51 */ x86emuOp_push_CX, +/* 0x52 */ x86emuOp_push_DX, +/* 0x53 */ x86emuOp_push_BX, +/* 0x54 */ x86emuOp_push_SP, +/* 0x55 */ x86emuOp_push_BP, +/* 0x56 */ x86emuOp_push_SI, +/* 0x57 */ x86emuOp_push_DI, + +/* 0x58 */ x86emuOp_pop_AX, +/* 0x59 */ x86emuOp_pop_CX, +/* 0x5a */ x86emuOp_pop_DX, +/* 0x5b */ x86emuOp_pop_BX, +/* 0x5c */ x86emuOp_pop_SP, +/* 0x5d */ x86emuOp_pop_BP, +/* 0x5e */ x86emuOp_pop_SI, +/* 0x5f */ x86emuOp_pop_DI, + +/* 0x60 */ x86emuOp_push_all, +/* 0x61 */ x86emuOp_pop_all, +/* 0x62 */ x86emuOp_illegal_op, /* bound */ +/* 0x63 */ x86emuOp_illegal_op, /* arpl */ +/* 0x64 */ x86emuOp_segovr_FS, +/* 0x65 */ x86emuOp_segovr_GS, +/* 0x66 */ x86emuOp_prefix_data, +/* 0x67 */ x86emuOp_prefix_addr, + +/* 0x68 */ x86emuOp_push_word_IMM, +/* 0x69 */ x86emuOp_imul_word_IMM, +/* 0x6a */ x86emuOp_push_byte_IMM, +/* 0x6b */ x86emuOp_imul_byte_IMM, +/* 0x6c */ x86emuOp_ins_byte, +/* 0x6d */ x86emuOp_ins_word, +/* 0x6e */ x86emuOp_outs_byte, +/* 0x6f */ x86emuOp_outs_word, + +/* 0x70 */ x86emuOp_jump_near_O, +/* 0x71 */ x86emuOp_jump_near_NO, +/* 0x72 */ x86emuOp_jump_near_B, +/* 0x73 */ x86emuOp_jump_near_NB, +/* 0x74 */ x86emuOp_jump_near_Z, +/* 0x75 */ x86emuOp_jump_near_NZ, +/* 0x76 */ x86emuOp_jump_near_BE, +/* 0x77 */ x86emuOp_jump_near_NBE, + +/* 0x78 */ x86emuOp_jump_near_S, +/* 0x79 */ x86emuOp_jump_near_NS, +/* 0x7a */ x86emuOp_jump_near_P, +/* 0x7b */ x86emuOp_jump_near_NP, +/* 0x7c */ x86emuOp_jump_near_L, +/* 0x7d */ x86emuOp_jump_near_NL, +/* 0x7e */ x86emuOp_jump_near_LE, +/* 0x7f */ x86emuOp_jump_near_NLE, + +/* 0x80 */ x86emuOp_opc80_byte_RM_IMM, +/* 0x81 */ x86emuOp_opc81_word_RM_IMM, +/* 0x82 */ x86emuOp_opc82_byte_RM_IMM, +/* 0x83 */ x86emuOp_opc83_word_RM_IMM, +/* 0x84 */ x86emuOp_test_byte_RM_R, +/* 0x85 */ x86emuOp_test_word_RM_R, +/* 0x86 */ x86emuOp_xchg_byte_RM_R, +/* 0x87 */ x86emuOp_xchg_word_RM_R, + +/* 0x88 */ x86emuOp_mov_byte_RM_R, +/* 0x89 */ x86emuOp_mov_word_RM_R, +/* 0x8a */ x86emuOp_mov_byte_R_RM, +/* 0x8b */ x86emuOp_mov_word_R_RM, +/* 0x8c */ x86emuOp_mov_word_RM_SR, +/* 0x8d */ x86emuOp_lea_word_R_M, +/* 0x8e */ x86emuOp_mov_word_SR_RM, +/* 0x8f */ x86emuOp_pop_RM, + +/* 0x90 */ x86emuOp_nop, +/* 0x91 */ x86emuOp_xchg_word_AX_CX, +/* 0x92 */ x86emuOp_xchg_word_AX_DX, +/* 0x93 */ x86emuOp_xchg_word_AX_BX, +/* 0x94 */ x86emuOp_xchg_word_AX_SP, +/* 0x95 */ x86emuOp_xchg_word_AX_BP, +/* 0x96 */ x86emuOp_xchg_word_AX_SI, +/* 0x97 */ x86emuOp_xchg_word_AX_DI, + +/* 0x98 */ x86emuOp_cbw, +/* 0x99 */ x86emuOp_cwd, +/* 0x9a */ x86emuOp_call_far_IMM, +/* 0x9b */ x86emuOp_wait, +/* 0x9c */ x86emuOp_pushf_word, +/* 0x9d */ x86emuOp_popf_word, +/* 0x9e */ x86emuOp_sahf, +/* 0x9f */ x86emuOp_lahf, + +/* 0xa0 */ x86emuOp_mov_AL_M_IMM, +/* 0xa1 */ x86emuOp_mov_AX_M_IMM, +/* 0xa2 */ x86emuOp_mov_M_AL_IMM, +/* 0xa3 */ x86emuOp_mov_M_AX_IMM, +/* 0xa4 */ x86emuOp_movs_byte, +/* 0xa5 */ x86emuOp_movs_word, +/* 0xa6 */ x86emuOp_cmps_byte, +/* 0xa7 */ x86emuOp_cmps_word, +/* 0xa8 */ x86emuOp_test_AL_IMM, +/* 0xa9 */ x86emuOp_test_AX_IMM, +/* 0xaa */ x86emuOp_stos_byte, +/* 0xab */ x86emuOp_stos_word, +/* 0xac */ x86emuOp_lods_byte, +/* 0xad */ x86emuOp_lods_word, +/* 0xac */ x86emuOp_scas_byte, +/* 0xad */ x86emuOp_scas_word, + + +/* 0xb0 */ x86emuOp_mov_byte_AL_IMM, +/* 0xb1 */ x86emuOp_mov_byte_CL_IMM, +/* 0xb2 */ x86emuOp_mov_byte_DL_IMM, +/* 0xb3 */ x86emuOp_mov_byte_BL_IMM, +/* 0xb4 */ x86emuOp_mov_byte_AH_IMM, +/* 0xb5 */ x86emuOp_mov_byte_CH_IMM, +/* 0xb6 */ x86emuOp_mov_byte_DH_IMM, +/* 0xb7 */ x86emuOp_mov_byte_BH_IMM, + +/* 0xb8 */ x86emuOp_mov_word_AX_IMM, +/* 0xb9 */ x86emuOp_mov_word_CX_IMM, +/* 0xba */ x86emuOp_mov_word_DX_IMM, +/* 0xbb */ x86emuOp_mov_word_BX_IMM, +/* 0xbc */ x86emuOp_mov_word_SP_IMM, +/* 0xbd */ x86emuOp_mov_word_BP_IMM, +/* 0xbe */ x86emuOp_mov_word_SI_IMM, +/* 0xbf */ x86emuOp_mov_word_DI_IMM, + +/* 0xc0 */ x86emuOp_opcC0_byte_RM_MEM, +/* 0xc1 */ x86emuOp_opcC1_word_RM_MEM, +/* 0xc2 */ x86emuOp_ret_near_IMM, +/* 0xc3 */ x86emuOp_ret_near, +/* 0xc4 */ x86emuOp_les_R_IMM, +/* 0xc5 */ x86emuOp_lds_R_IMM, +/* 0xc6 */ x86emuOp_mov_byte_RM_IMM, +/* 0xc7 */ x86emuOp_mov_word_RM_IMM, +/* 0xc8 */ x86emuOp_enter, +/* 0xc9 */ x86emuOp_leave, +/* 0xca */ x86emuOp_ret_far_IMM, +/* 0xcb */ x86emuOp_ret_far, +/* 0xcc */ x86emuOp_int3, +/* 0xcd */ x86emuOp_int_IMM, +/* 0xce */ x86emuOp_into, +/* 0xcf */ x86emuOp_iret, + +/* 0xd0 */ x86emuOp_opcD0_byte_RM_1, +/* 0xd1 */ x86emuOp_opcD1_word_RM_1, +/* 0xd2 */ x86emuOp_opcD2_byte_RM_CL, +/* 0xd3 */ x86emuOp_opcD3_word_RM_CL, +/* 0xd4 */ x86emuOp_aam, +/* 0xd5 */ x86emuOp_aad, +/* 0xd6 */ x86emuOp_illegal_op, /* Undocumented SETALC instruction */ +/* 0xd7 */ x86emuOp_xlat, +/* 0xd8 */ x86emuOp_esc_coprocess_d8, +/* 0xd9 */ x86emuOp_esc_coprocess_d9, +/* 0xda */ x86emuOp_esc_coprocess_da, +/* 0xdb */ x86emuOp_esc_coprocess_db, +/* 0xdc */ x86emuOp_esc_coprocess_dc, +/* 0xdd */ x86emuOp_esc_coprocess_dd, +/* 0xde */ x86emuOp_esc_coprocess_de, +/* 0xdf */ x86emuOp_esc_coprocess_df, + +/* 0xe0 */ x86emuOp_loopne, +/* 0xe1 */ x86emuOp_loope, +/* 0xe2 */ x86emuOp_loop, +/* 0xe3 */ x86emuOp_jcxz, +/* 0xe4 */ x86emuOp_in_byte_AL_IMM, +/* 0xe5 */ x86emuOp_in_word_AX_IMM, +/* 0xe6 */ x86emuOp_out_byte_IMM_AL, +/* 0xe7 */ x86emuOp_out_word_IMM_AX, + +/* 0xe8 */ x86emuOp_call_near_IMM, +/* 0xe9 */ x86emuOp_jump_near_IMM, +/* 0xea */ x86emuOp_jump_far_IMM, +/* 0xeb */ x86emuOp_jump_byte_IMM, +/* 0xec */ x86emuOp_in_byte_AL_DX, +/* 0xed */ x86emuOp_in_word_AX_DX, +/* 0xee */ x86emuOp_out_byte_DX_AL, +/* 0xef */ x86emuOp_out_word_DX_AX, + +/* 0xf0 */ x86emuOp_lock, +/* 0xf1 */ x86emuOp_illegal_op, +/* 0xf2 */ x86emuOp_repne, +/* 0xf3 */ x86emuOp_repe, +/* 0xf4 */ x86emuOp_halt, +/* 0xf5 */ x86emuOp_cmc, +/* 0xf6 */ x86emuOp_opcF6_byte_RM, +/* 0xf7 */ x86emuOp_opcF7_word_RM, + +/* 0xf8 */ x86emuOp_clc, +/* 0xf9 */ x86emuOp_stc, +/* 0xfa */ x86emuOp_cli, +/* 0xfb */ x86emuOp_sti, +/* 0xfc */ x86emuOp_cld, +/* 0xfd */ x86emuOp_std, +/* 0xfe */ x86emuOp_opcFE_byte_RM, +/* 0xff */ x86emuOp_opcFF_word_RM, +}; diff --git a/xorg-server/hw/xfree86/x86emu/ops2.c b/xorg-server/hw/xfree86/x86emu/ops2.c new file mode 100644 index 000000000..a1eda76d7 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/ops2.c @@ -0,0 +1,2897 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: This file includes subroutines to implement the decoding +* and emulation of all the x86 extended two-byte processor +* instructions. +* +****************************************************************************/ + +#include "x86emu/x86emui.h" + +#undef bswap_32 +#define bswap_32(x) (((x & 0xff000000) >> 24) | \ + ((x & 0x00ff0000) >> 8) | \ + ((x & 0x0000ff00) << 8) | \ + ((x & 0x000000ff) << 24)) + +/*----------------------------- Implementation ----------------------------*/ + +/**************************************************************************** +PARAMETERS: +op1 - Instruction op code + +REMARKS: +Handles illegal opcodes. +****************************************************************************/ +static void x86emuOp2_illegal_op( + u8 op2) +{ + START_OF_INSTR(); + DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n"); + TRACE_REGS(); + printk("%04x:%04x: %02X ILLEGAL EXTENDED X86 OPCODE!\n", + M.x86.R_CS, M.x86.R_IP-2,op2); + HALT_SYS(); + END_OF_INSTR(); +} + +#define xorl(a,b) ((a) && !(b)) || (!(a) && (b)) + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0x31 +****************************************************************************/ +static void x86emuOp2_rdtsc(u8 X86EMU_UNUSED(op2)) +{ +#ifdef __HAS_LONG_LONG__ + static u64 counter = 0; +#else + static u32 counter = 0; +#endif + + counter += 0x10000; + + /* read timestamp counter */ + /* + * Note that instead of actually trying to accurately measure this, we just + * increase the counter by a fixed amount every time we hit one of these + * instructions. Feel free to come up with a better method. + */ + START_OF_INSTR(); + DECODE_PRINTF("RDTSC\n"); + TRACE_AND_STEP(); +#ifdef __HAS_LONG_LONG__ + M.x86.R_EAX = counter & 0xffffffff; + M.x86.R_EDX = counter >> 32; +#else + M.x86.R_EAX = counter; + M.x86.R_EDX = 0; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0x80-0x8F +****************************************************************************/ +static void x86emuOp2_long_jump(u8 op2) +{ + s32 target; + char *name = 0; + int cond = 0; + + /* conditional jump to word offset. */ + START_OF_INSTR(); + switch (op2) { + case 0x80: + name = "JO\t"; + cond = ACCESS_FLAG(F_OF); + break; + case 0x81: + name = "JNO\t"; + cond = !ACCESS_FLAG(F_OF); + break; + case 0x82: + name = "JB\t"; + cond = ACCESS_FLAG(F_CF); + break; + case 0x83: + name = "JNB\t"; + cond = !ACCESS_FLAG(F_CF); + break; + case 0x84: + name = "JZ\t"; + cond = ACCESS_FLAG(F_ZF); + break; + case 0x85: + name = "JNZ\t"; + cond = !ACCESS_FLAG(F_ZF); + break; + case 0x86: + name = "JBE\t"; + cond = ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF); + break; + case 0x87: + name = "JNBE\t"; + cond = !(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)); + break; + case 0x88: + name = "JS\t"; + cond = ACCESS_FLAG(F_SF); + break; + case 0x89: + name = "JNS\t"; + cond = !ACCESS_FLAG(F_SF); + break; + case 0x8a: + name = "JP\t"; + cond = ACCESS_FLAG(F_PF); + break; + case 0x8b: + name = "JNP\t"; + cond = !ACCESS_FLAG(F_PF); + break; + case 0x8c: + name = "JL\t"; + cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)); + break; + case 0x8d: + name = "JNL\t"; + cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF))); + break; + case 0x8e: + name = "JLE\t"; + cond = (xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || + ACCESS_FLAG(F_ZF)); + break; + case 0x8f: + name = "JNLE\t"; + cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || + ACCESS_FLAG(F_ZF)); + break; + } + DECODE_PRINTF(name); + (void)name; + target = (s16) fetch_word_imm(); + target += (s16) M.x86.R_IP; + DECODE_PRINTF2("%04x\n", target); + TRACE_AND_STEP(); + if (cond) + M.x86.R_IP = (u16)target; + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0x90-0x9F +****************************************************************************/ +static void x86emuOp2_set_byte(u8 op2) +{ + int mod, rl, rh; + uint destoffset; + u8 *destreg; + char *name = 0; + int cond = 0; + + START_OF_INSTR(); + switch (op2) { + case 0x90: + name = "SETO\t"; + cond = ACCESS_FLAG(F_OF); + break; + case 0x91: + name = "SETNO\t"; + cond = !ACCESS_FLAG(F_OF); + break; + case 0x92: + name = "SETB\t"; + cond = ACCESS_FLAG(F_CF); + break; + case 0x93: + name = "SETNB\t"; + cond = !ACCESS_FLAG(F_CF); + break; + case 0x94: + name = "SETZ\t"; + cond = ACCESS_FLAG(F_ZF); + break; + case 0x95: + name = "SETNZ\t"; + cond = !ACCESS_FLAG(F_ZF); + break; + case 0x96: + name = "SETBE\t"; + cond = ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF); + break; + case 0x97: + name = "SETNBE\t"; + cond = !(ACCESS_FLAG(F_CF) || ACCESS_FLAG(F_ZF)); + break; + case 0x98: + name = "SETS\t"; + cond = ACCESS_FLAG(F_SF); + break; + case 0x99: + name = "SETNS\t"; + cond = !ACCESS_FLAG(F_SF); + break; + case 0x9a: + name = "SETP\t"; + cond = ACCESS_FLAG(F_PF); + break; + case 0x9b: + name = "SETNP\t"; + cond = !ACCESS_FLAG(F_PF); + break; + case 0x9c: + name = "SETL\t"; + cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)); + break; + case 0x9d: + name = "SETNL\t"; + cond = xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)); + break; + case 0x9e: + name = "SETLE\t"; + cond = (xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || + ACCESS_FLAG(F_ZF)); + break; + case 0x9f: + name = "SETNLE\t"; + cond = !(xorl(ACCESS_FLAG(F_SF), ACCESS_FLAG(F_OF)) || + ACCESS_FLAG(F_ZF)); + break; + } + DECODE_PRINTF(name); + (void)name; + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destoffset = decode_rm00_address(rl); + TRACE_AND_STEP(); + store_data_byte(destoffset, cond ? 0x01 : 0x00); + break; + case 1: + destoffset = decode_rm01_address(rl); + TRACE_AND_STEP(); + store_data_byte(destoffset, cond ? 0x01 : 0x00); + break; + case 2: + destoffset = decode_rm10_address(rl); + TRACE_AND_STEP(); + store_data_byte(destoffset, cond ? 0x01 : 0x00); + break; + case 3: /* register to register */ + destreg = DECODE_RM_BYTE_REGISTER(rl); + TRACE_AND_STEP(); + *destreg = cond ? 0x01 : 0x00; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xa0 +****************************************************************************/ +static void x86emuOp2_push_FS(u8 X86EMU_UNUSED(op2)) +{ + START_OF_INSTR(); + DECODE_PRINTF("PUSH\tFS\n"); + TRACE_AND_STEP(); + push_word(M.x86.R_FS); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xa1 +****************************************************************************/ +static void x86emuOp2_pop_FS(u8 X86EMU_UNUSED(op2)) +{ + START_OF_INSTR(); + DECODE_PRINTF("POP\tFS\n"); + TRACE_AND_STEP(); + M.x86.R_FS = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output +Handles opcode 0x0f,0xa2 +****************************************************************************/ +static void x86emuOp2_cpuid(u8 X86EMU_UNUSED(op2)) +{ + START_OF_INSTR(); + DECODE_PRINTF("CPUID\n"); + TRACE_AND_STEP(); + cpuid(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xa3 +****************************************************************************/ +static void x86emuOp2_bt_R(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + int bit,disp; + + START_OF_INSTR(); + DECODE_PRINTF("BT\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval; + u32 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); + } else { + u16 srcval; + u16 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval; + u32 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); + } else { + u16 srcval; + u16 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval; + u32 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); + } else { + u16 srcval; + u16 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + CONDITIONAL_SET_FLAG(srcval & (0x1 << bit),F_CF); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg,*shiftreg; + + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit),F_CF); + } else { + u16 *srcreg,*shiftreg; + + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + CONDITIONAL_SET_FLAG(*srcreg & (0x1 << bit),F_CF); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xa4 +****************************************************************************/ +static void x86emuOp2_shld_IMM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint destoffset; + u8 shift; + + START_OF_INSTR(); + DECODE_PRINTF("SHLD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shld_long(destval,*shiftreg,shift); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shld_word(destval,*shiftreg,shift); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shld_long(destval,*shiftreg,shift); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shld_word(destval,*shiftreg,shift); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shld_long(destval,*shiftreg,shift); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shld_word(destval,*shiftreg,shift); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*shiftreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + *destreg = shld_long(*destreg,*shiftreg,shift); + } else { + u16 *destreg,*shiftreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + *destreg = shld_word(*destreg,*shiftreg,shift); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xa5 +****************************************************************************/ +static void x86emuOp2_shld_CL(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("SHLD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shld_long(destval,*shiftreg,M.x86.R_CL); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shld_word(destval,*shiftreg,M.x86.R_CL); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shld_long(destval,*shiftreg,M.x86.R_CL); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shld_word(destval,*shiftreg,M.x86.R_CL); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shld_long(destval,*shiftreg,M.x86.R_CL); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shld_word(destval,*shiftreg,M.x86.R_CL); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*shiftreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + *destreg = shld_long(*destreg,*shiftreg,M.x86.R_CL); + } else { + u16 *destreg,*shiftreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + *destreg = shld_word(*destreg,*shiftreg,M.x86.R_CL); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xa8 +****************************************************************************/ +static void x86emuOp2_push_GS(u8 X86EMU_UNUSED(op2)) +{ + START_OF_INSTR(); + DECODE_PRINTF("PUSH\tGS\n"); + TRACE_AND_STEP(); + push_word(M.x86.R_GS); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xa9 +****************************************************************************/ +static void x86emuOp2_pop_GS(u8 X86EMU_UNUSED(op2)) +{ + START_OF_INSTR(); + DECODE_PRINTF("POP\tGS\n"); + TRACE_AND_STEP(); + M.x86.R_GS = pop_word(); + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xab +****************************************************************************/ +static void x86emuOp2_bts_R(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + int bit,disp; + + START_OF_INSTR(); + DECODE_PRINTF("BTS\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval | mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, srcval | mask); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval | mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, srcval | mask); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval | mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, srcval | mask); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg,*shiftreg; + u32 mask; + + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + *srcreg |= mask; + } else { + u16 *srcreg,*shiftreg; + u16 mask; + + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + *srcreg |= mask; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xac +****************************************************************************/ +static void x86emuOp2_shrd_IMM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint destoffset; + u8 shift; + + START_OF_INSTR(); + DECODE_PRINTF("SHLD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shrd_long(destval,*shiftreg,shift); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shrd_word(destval,*shiftreg,shift); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shrd_long(destval,*shiftreg,shift); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shrd_word(destval,*shiftreg,shift); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shrd_long(destval,*shiftreg,shift); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shrd_word(destval,*shiftreg,shift); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*shiftreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + *destreg = shrd_long(*destreg,*shiftreg,shift); + } else { + u16 *destreg,*shiftreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + DECODE_PRINTF2("%d\n", shift); + TRACE_AND_STEP(); + *destreg = shrd_word(*destreg,*shiftreg,shift); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xad +****************************************************************************/ +static void x86emuOp2_shrd_CL(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint destoffset; + + START_OF_INSTR(); + DECODE_PRINTF("SHLD\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shrd_long(destval,*shiftreg,M.x86.R_CL); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shrd_word(destval,*shiftreg,M.x86.R_CL); + store_data_word(destoffset, destval); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shrd_long(destval,*shiftreg,M.x86.R_CL); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shrd_word(destval,*shiftreg,M.x86.R_CL); + store_data_word(destoffset, destval); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 destval; + u32 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_long(destoffset); + destval = shrd_long(destval,*shiftreg,M.x86.R_CL); + store_data_long(destoffset, destval); + } else { + u16 destval; + u16 *shiftreg; + + destoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + destval = fetch_data_word(destoffset); + destval = shrd_word(destval,*shiftreg,M.x86.R_CL); + store_data_word(destoffset, destval); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*shiftreg; + + destreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + *destreg = shrd_long(*destreg,*shiftreg,M.x86.R_CL); + } else { + u16 *destreg,*shiftreg; + + destreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(",CL\n"); + TRACE_AND_STEP(); + *destreg = shrd_word(*destreg,*shiftreg,M.x86.R_CL); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xaf +****************************************************************************/ +static void x86emuOp2_imul_R_RM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("IMUL\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_long(srcoffset); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + TRACE_AND_STEP(); + res = (s16)*destreg * (s16)srcval; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_long(srcoffset); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + TRACE_AND_STEP(); + res = (s16)*destreg * (s16)srcval; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_long(srcoffset); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)srcval); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg; + u16 srcval; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + TRACE_AND_STEP(); + res = (s16)*destreg * (s16)srcval; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg,*srcreg; + u32 res_lo,res_hi; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_LONG_REGISTER(rl); + TRACE_AND_STEP(); + imul_long_direct(&res_lo,&res_hi,(s32)*destreg,(s32)*srcreg); + if (res_hi != 0) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u32)res_lo; + } else { + u16 *destreg,*srcreg; + u32 res; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + res = (s16)*destreg * (s16)*srcreg; + if (res > 0xFFFF) { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } + *destreg = (u16)res; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xb2 +****************************************************************************/ +static void x86emuOp2_lss_R_IMM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rh, rl; + u16 *dstreg; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("LSS\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_SS = fetch_data_word(srcoffset + 2); + break; + case 1: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_SS = fetch_data_word(srcoffset + 2); + break; + case 2: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_SS = fetch_data_word(srcoffset + 2); + break; + case 3: /* register to register */ + /* UNDEFINED! */ + TRACE_AND_STEP(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xb3 +****************************************************************************/ +static void x86emuOp2_btr_R(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + int bit,disp; + + START_OF_INSTR(); + DECODE_PRINTF("BTR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval & ~mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, (u16)(srcval & ~mask)); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval & ~mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, (u16)(srcval & ~mask)); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval & ~mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, (u16)(srcval & ~mask)); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg,*shiftreg; + u32 mask; + + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + *srcreg &= ~mask; + } else { + u16 *srcreg,*shiftreg; + u16 mask; + + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + *srcreg &= ~mask; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xb4 +****************************************************************************/ +static void x86emuOp2_lfs_R_IMM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rh, rl; + u16 *dstreg; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("LFS\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_FS = fetch_data_word(srcoffset + 2); + break; + case 1: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_FS = fetch_data_word(srcoffset + 2); + break; + case 2: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_FS = fetch_data_word(srcoffset + 2); + break; + case 3: /* register to register */ + /* UNDEFINED! */ + TRACE_AND_STEP(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xb5 +****************************************************************************/ +static void x86emuOp2_lgs_R_IMM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rh, rl; + u16 *dstreg; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("LGS\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_GS = fetch_data_word(srcoffset + 2); + break; + case 1: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_GS = fetch_data_word(srcoffset + 2); + break; + case 2: + dstreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *dstreg = fetch_data_word(srcoffset); + M.x86.R_GS = fetch_data_word(srcoffset + 2); + break; + case 3: /* register to register */ + /* UNDEFINED! */ + TRACE_AND_STEP(); + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xb6 +****************************************************************************/ +static void x86emuOp2_movzx_byte_R_RM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("MOVZX\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_byte(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u8 *srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + } else { + u16 *destreg; + u8 *srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xb7 +****************************************************************************/ +static void x86emuOp2_movzx_word_R_RM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + u32 *destreg; + u32 srcval; + u16 *srcreg; + + START_OF_INSTR(); + DECODE_PRINTF("MOVZX\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 1: + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 2: + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = fetch_data_word(srcoffset); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 3: /* register to register */ + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = *srcreg; + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xba +****************************************************************************/ +static void x86emuOp2_btX_I(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + int bit; + + START_OF_INSTR(); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (rh) { + case 4: + DECODE_PRINTF("BT\t"); + break; + case 5: + DECODE_PRINTF("BTS\t"); + break; + case 6: + DECODE_PRINTF("BTR\t"); + break; + case 7: + DECODE_PRINTF("BTC\t"); + break; + default: + DECODE_PRINTF("ILLEGAL EXTENDED X86 OPCODE\n"); + TRACE_REGS(); + printk("%04x:%04x: %02X%02X ILLEGAL EXTENDED X86 OPCODE EXTENSION!\n", + M.x86.R_CS, M.x86.R_IP-3,op2, (mod<<6)|(rh<<3)|rl); + HALT_SYS(); + } + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, mask; + u8 shift; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0x1F; + srcval = fetch_data_long(srcoffset); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + switch (rh) { + case 5: + store_data_long(srcoffset, srcval | mask); + break; + case 6: + store_data_long(srcoffset, srcval & ~mask); + break; + case 7: + store_data_long(srcoffset, srcval ^ mask); + break; + default: + break; + } + } else { + u16 srcval, mask; + u8 shift; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0xF; + srcval = fetch_data_word(srcoffset); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + switch (rh) { + case 5: + store_data_word(srcoffset, srcval | mask); + break; + case 6: + store_data_word(srcoffset, srcval & ~mask); + break; + case 7: + store_data_word(srcoffset, srcval ^ mask); + break; + default: + break; + } + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, mask; + u8 shift; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0x1F; + srcval = fetch_data_long(srcoffset); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + switch (rh) { + case 5: + store_data_long(srcoffset, srcval | mask); + break; + case 6: + store_data_long(srcoffset, srcval & ~mask); + break; + case 7: + store_data_long(srcoffset, srcval ^ mask); + break; + default: + break; + } + } else { + u16 srcval, mask; + u8 shift; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0xF; + srcval = fetch_data_word(srcoffset); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + switch (rh) { + case 5: + store_data_word(srcoffset, srcval | mask); + break; + case 6: + store_data_word(srcoffset, srcval & ~mask); + break; + case 7: + store_data_word(srcoffset, srcval ^ mask); + break; + default: + break; + } + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, mask; + u8 shift; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0x1F; + srcval = fetch_data_long(srcoffset); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + switch (rh) { + case 5: + store_data_long(srcoffset, srcval | mask); + break; + case 6: + store_data_long(srcoffset, srcval & ~mask); + break; + case 7: + store_data_long(srcoffset, srcval ^ mask); + break; + default: + break; + } + } else { + u16 srcval, mask; + u8 shift; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0xF; + srcval = fetch_data_word(srcoffset); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + switch (rh) { + case 5: + store_data_word(srcoffset, srcval | mask); + break; + case 6: + store_data_word(srcoffset, srcval & ~mask); + break; + case 7: + store_data_word(srcoffset, srcval ^ mask); + break; + default: + break; + } + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg; + u32 mask; + u8 shift; + + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0x1F; + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + switch (rh) { + case 5: + *srcreg |= mask; + break; + case 6: + *srcreg &= ~mask; + break; + case 7: + *srcreg ^= mask; + break; + default: + break; + } + } else { + u16 *srcreg; + u16 mask; + u8 shift; + + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shift = fetch_byte_imm(); + TRACE_AND_STEP(); + bit = shift & 0xF; + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + switch (rh) { + case 5: + *srcreg |= mask; + break; + case 6: + *srcreg &= ~mask; + break; + case 7: + *srcreg ^= mask; + break; + default: + break; + } + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xbb +****************************************************************************/ +static void x86emuOp2_btc_R(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + int bit,disp; + + START_OF_INSTR(); + DECODE_PRINTF("BTC\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval ^ mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, (u16)(srcval ^ mask)); + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval ^ mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, (u16)(srcval ^ mask)); + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval,mask; + u32 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + disp = (s16)*shiftreg >> 5; + srcval = fetch_data_long(srcoffset+disp); + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_long(srcoffset+disp, srcval ^ mask); + } else { + u16 srcval,mask; + u16 *shiftreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + disp = (s16)*shiftreg >> 4; + srcval = fetch_data_word(srcoffset+disp); + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(srcval & mask,F_CF); + store_data_word(srcoffset+disp, (u16)(srcval ^ mask)); + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *srcreg,*shiftreg; + u32 mask; + + srcreg = DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0x1F; + mask = (0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + *srcreg ^= mask; + } else { + u16 *srcreg,*shiftreg; + u16 mask; + + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + shiftreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + bit = *shiftreg & 0xF; + mask = (u16)(0x1 << bit); + CONDITIONAL_SET_FLAG(*srcreg & mask,F_CF); + *srcreg ^= mask; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xbc +****************************************************************************/ +static void x86emuOp2_bsf(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("BSF\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch(mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_long(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 32; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_word(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 16; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_long(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 32; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_word(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 16; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_long(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 32; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_word(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 16; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcval = *DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 32; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcval = *DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 0; *dstreg < 16; (*dstreg)++) + if ((srcval >> *dstreg) & 1) break; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xbd +****************************************************************************/ +static void x86emuOp2_bsr(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("BSR\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch(mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_long(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 31; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcoffset = decode_rm00_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_word(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 15; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_long(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 31; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcoffset = decode_rm01_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_word(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 15; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_long(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 31; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcoffset = decode_rm10_address(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + srcval = fetch_data_word(srcoffset); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 15; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 srcval, *dstreg; + + srcval = *DECODE_RM_LONG_REGISTER(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_LONG_REGISTER(rh); + TRACE_AND_STEP(); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 31; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } else { + u16 srcval, *dstreg; + + srcval = *DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF(","); + dstreg = DECODE_RM_WORD_REGISTER(rh); + TRACE_AND_STEP(); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); + for(*dstreg = 15; *dstreg > 0; (*dstreg)--) + if ((srcval >> *dstreg) & 1) break; + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xbe +****************************************************************************/ +static void x86emuOp2_movsx_byte_R_RM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + + START_OF_INSTR(); + DECODE_PRINTF("MOVSX\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = (s32)((s8)fetch_data_byte(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = (s16)((s8)fetch_data_byte(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 1: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = (s32)((s8)fetch_data_byte(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = (s16)((s8)fetch_data_byte(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 2: + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u32 srcval; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = (s32)((s8)fetch_data_byte(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } else { + u16 *destreg; + u16 srcval; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = (s16)((s8)fetch_data_byte(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + } + break; + case 3: /* register to register */ + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + u32 *destreg; + u8 *srcreg; + + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = (s32)((s8)*srcreg); + } else { + u16 *destreg; + u8 *srcreg; + + destreg = DECODE_RM_WORD_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_BYTE_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = (s16)((s8)*srcreg); + } + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0xbf +****************************************************************************/ +static void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2)) +{ + int mod, rl, rh; + uint srcoffset; + u32 *destreg; + u32 srcval; + u16 *srcreg; + + START_OF_INSTR(); + DECODE_PRINTF("MOVSX\t"); + FETCH_DECODE_MODRM(mod, rh, rl); + switch (mod) { + case 0: + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm00_address(rl); + srcval = (s32)((s16)fetch_data_word(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 1: + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm01_address(rl); + srcval = (s32)((s16)fetch_data_word(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 2: + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcoffset = decode_rm10_address(rl); + srcval = (s32)((s16)fetch_data_word(srcoffset)); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = srcval; + break; + case 3: /* register to register */ + destreg = DECODE_RM_LONG_REGISTER(rh); + DECODE_PRINTF(","); + srcreg = DECODE_RM_WORD_REGISTER(rl); + DECODE_PRINTF("\n"); + TRACE_AND_STEP(); + *destreg = (s32)((s16)*srcreg); + break; + } + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/* Handles opcodes 0xc8-0xcf */ +static void x86emuOp2_bswap(u8 X86EMU_UNUSED(op2)) +{ + START_OF_INSTR(); + DECODE_PRINTF("BSWAP\n"); + TRACE_AND_STEP(); + + switch (op2) { + case 0xc8: + M.x86.R_EAX = bswap_32(M.x86.R_EAX); + break; + case 0xc9: + M.x86.R_ECX = bswap_32(M.x86.R_ECX); + break; + case 0xca: + M.x86.R_EDX = bswap_32(M.x86.R_EDX); + break; + case 0xcb: + M.x86.R_EBX = bswap_32(M.x86.R_EBX); + break; + case 0xcc: + M.x86.R_ESP = bswap_32(M.x86.R_ESP); + break; + case 0xcd: + M.x86.R_EBP = bswap_32(M.x86.R_EBP); + break; + case 0xce: + M.x86.R_ESI = bswap_32(M.x86.R_ESI); + break; + case 0xcf: + M.x86.R_EDI = bswap_32(M.x86.R_EDI); + break; + default: + /* can't happen */ + break; + } + + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + +/*************************************************************************** + * Double byte operation code table: + **************************************************************************/ +void (*x86emu_optab2[256])(u8) = +{ +/* 0x00 */ x86emuOp2_illegal_op, /* Group F (ring 0 PM) */ +/* 0x01 */ x86emuOp2_illegal_op, /* Group G (ring 0 PM) */ +/* 0x02 */ x86emuOp2_illegal_op, /* lar (ring 0 PM) */ +/* 0x03 */ x86emuOp2_illegal_op, /* lsl (ring 0 PM) */ +/* 0x04 */ x86emuOp2_illegal_op, +/* 0x05 */ x86emuOp2_illegal_op, /* loadall (undocumented) */ +/* 0x06 */ x86emuOp2_illegal_op, /* clts (ring 0 PM) */ +/* 0x07 */ x86emuOp2_illegal_op, /* loadall (undocumented) */ +/* 0x08 */ x86emuOp2_illegal_op, /* invd (ring 0 PM) */ +/* 0x09 */ x86emuOp2_illegal_op, /* wbinvd (ring 0 PM) */ +/* 0x0a */ x86emuOp2_illegal_op, +/* 0x0b */ x86emuOp2_illegal_op, +/* 0x0c */ x86emuOp2_illegal_op, +/* 0x0d */ x86emuOp2_illegal_op, +/* 0x0e */ x86emuOp2_illegal_op, +/* 0x0f */ x86emuOp2_illegal_op, + +/* 0x10 */ x86emuOp2_illegal_op, +/* 0x11 */ x86emuOp2_illegal_op, +/* 0x12 */ x86emuOp2_illegal_op, +/* 0x13 */ x86emuOp2_illegal_op, +/* 0x14 */ x86emuOp2_illegal_op, +/* 0x15 */ x86emuOp2_illegal_op, +/* 0x16 */ x86emuOp2_illegal_op, +/* 0x17 */ x86emuOp2_illegal_op, +/* 0x18 */ x86emuOp2_illegal_op, +/* 0x19 */ x86emuOp2_illegal_op, +/* 0x1a */ x86emuOp2_illegal_op, +/* 0x1b */ x86emuOp2_illegal_op, +/* 0x1c */ x86emuOp2_illegal_op, +/* 0x1d */ x86emuOp2_illegal_op, +/* 0x1e */ x86emuOp2_illegal_op, +/* 0x1f */ x86emuOp2_illegal_op, + +/* 0x20 */ x86emuOp2_illegal_op, /* mov reg32,creg (ring 0 PM) */ +/* 0x21 */ x86emuOp2_illegal_op, /* mov reg32,dreg (ring 0 PM) */ +/* 0x22 */ x86emuOp2_illegal_op, /* mov creg,reg32 (ring 0 PM) */ +/* 0x23 */ x86emuOp2_illegal_op, /* mov dreg,reg32 (ring 0 PM) */ +/* 0x24 */ x86emuOp2_illegal_op, /* mov reg32,treg (ring 0 PM) */ +/* 0x25 */ x86emuOp2_illegal_op, +/* 0x26 */ x86emuOp2_illegal_op, /* mov treg,reg32 (ring 0 PM) */ +/* 0x27 */ x86emuOp2_illegal_op, +/* 0x28 */ x86emuOp2_illegal_op, +/* 0x29 */ x86emuOp2_illegal_op, +/* 0x2a */ x86emuOp2_illegal_op, +/* 0x2b */ x86emuOp2_illegal_op, +/* 0x2c */ x86emuOp2_illegal_op, +/* 0x2d */ x86emuOp2_illegal_op, +/* 0x2e */ x86emuOp2_illegal_op, +/* 0x2f */ x86emuOp2_illegal_op, + +/* 0x30 */ x86emuOp2_illegal_op, +/* 0x31 */ x86emuOp2_rdtsc, +/* 0x32 */ x86emuOp2_illegal_op, +/* 0x33 */ x86emuOp2_illegal_op, +/* 0x34 */ x86emuOp2_illegal_op, +/* 0x35 */ x86emuOp2_illegal_op, +/* 0x36 */ x86emuOp2_illegal_op, +/* 0x37 */ x86emuOp2_illegal_op, +/* 0x38 */ x86emuOp2_illegal_op, +/* 0x39 */ x86emuOp2_illegal_op, +/* 0x3a */ x86emuOp2_illegal_op, +/* 0x3b */ x86emuOp2_illegal_op, +/* 0x3c */ x86emuOp2_illegal_op, +/* 0x3d */ x86emuOp2_illegal_op, +/* 0x3e */ x86emuOp2_illegal_op, +/* 0x3f */ x86emuOp2_illegal_op, + +/* 0x40 */ x86emuOp2_illegal_op, +/* 0x41 */ x86emuOp2_illegal_op, +/* 0x42 */ x86emuOp2_illegal_op, +/* 0x43 */ x86emuOp2_illegal_op, +/* 0x44 */ x86emuOp2_illegal_op, +/* 0x45 */ x86emuOp2_illegal_op, +/* 0x46 */ x86emuOp2_illegal_op, +/* 0x47 */ x86emuOp2_illegal_op, +/* 0x48 */ x86emuOp2_illegal_op, +/* 0x49 */ x86emuOp2_illegal_op, +/* 0x4a */ x86emuOp2_illegal_op, +/* 0x4b */ x86emuOp2_illegal_op, +/* 0x4c */ x86emuOp2_illegal_op, +/* 0x4d */ x86emuOp2_illegal_op, +/* 0x4e */ x86emuOp2_illegal_op, +/* 0x4f */ x86emuOp2_illegal_op, + +/* 0x50 */ x86emuOp2_illegal_op, +/* 0x51 */ x86emuOp2_illegal_op, +/* 0x52 */ x86emuOp2_illegal_op, +/* 0x53 */ x86emuOp2_illegal_op, +/* 0x54 */ x86emuOp2_illegal_op, +/* 0x55 */ x86emuOp2_illegal_op, +/* 0x56 */ x86emuOp2_illegal_op, +/* 0x57 */ x86emuOp2_illegal_op, +/* 0x58 */ x86emuOp2_illegal_op, +/* 0x59 */ x86emuOp2_illegal_op, +/* 0x5a */ x86emuOp2_illegal_op, +/* 0x5b */ x86emuOp2_illegal_op, +/* 0x5c */ x86emuOp2_illegal_op, +/* 0x5d */ x86emuOp2_illegal_op, +/* 0x5e */ x86emuOp2_illegal_op, +/* 0x5f */ x86emuOp2_illegal_op, + +/* 0x60 */ x86emuOp2_illegal_op, +/* 0x61 */ x86emuOp2_illegal_op, +/* 0x62 */ x86emuOp2_illegal_op, +/* 0x63 */ x86emuOp2_illegal_op, +/* 0x64 */ x86emuOp2_illegal_op, +/* 0x65 */ x86emuOp2_illegal_op, +/* 0x66 */ x86emuOp2_illegal_op, +/* 0x67 */ x86emuOp2_illegal_op, +/* 0x68 */ x86emuOp2_illegal_op, +/* 0x69 */ x86emuOp2_illegal_op, +/* 0x6a */ x86emuOp2_illegal_op, +/* 0x6b */ x86emuOp2_illegal_op, +/* 0x6c */ x86emuOp2_illegal_op, +/* 0x6d */ x86emuOp2_illegal_op, +/* 0x6e */ x86emuOp2_illegal_op, +/* 0x6f */ x86emuOp2_illegal_op, + +/* 0x70 */ x86emuOp2_illegal_op, +/* 0x71 */ x86emuOp2_illegal_op, +/* 0x72 */ x86emuOp2_illegal_op, +/* 0x73 */ x86emuOp2_illegal_op, +/* 0x74 */ x86emuOp2_illegal_op, +/* 0x75 */ x86emuOp2_illegal_op, +/* 0x76 */ x86emuOp2_illegal_op, +/* 0x77 */ x86emuOp2_illegal_op, +/* 0x78 */ x86emuOp2_illegal_op, +/* 0x79 */ x86emuOp2_illegal_op, +/* 0x7a */ x86emuOp2_illegal_op, +/* 0x7b */ x86emuOp2_illegal_op, +/* 0x7c */ x86emuOp2_illegal_op, +/* 0x7d */ x86emuOp2_illegal_op, +/* 0x7e */ x86emuOp2_illegal_op, +/* 0x7f */ x86emuOp2_illegal_op, + +/* 0x80 */ x86emuOp2_long_jump, +/* 0x81 */ x86emuOp2_long_jump, +/* 0x82 */ x86emuOp2_long_jump, +/* 0x83 */ x86emuOp2_long_jump, +/* 0x84 */ x86emuOp2_long_jump, +/* 0x85 */ x86emuOp2_long_jump, +/* 0x86 */ x86emuOp2_long_jump, +/* 0x87 */ x86emuOp2_long_jump, +/* 0x88 */ x86emuOp2_long_jump, +/* 0x89 */ x86emuOp2_long_jump, +/* 0x8a */ x86emuOp2_long_jump, +/* 0x8b */ x86emuOp2_long_jump, +/* 0x8c */ x86emuOp2_long_jump, +/* 0x8d */ x86emuOp2_long_jump, +/* 0x8e */ x86emuOp2_long_jump, +/* 0x8f */ x86emuOp2_long_jump, + +/* 0x90 */ x86emuOp2_set_byte, +/* 0x91 */ x86emuOp2_set_byte, +/* 0x92 */ x86emuOp2_set_byte, +/* 0x93 */ x86emuOp2_set_byte, +/* 0x94 */ x86emuOp2_set_byte, +/* 0x95 */ x86emuOp2_set_byte, +/* 0x96 */ x86emuOp2_set_byte, +/* 0x97 */ x86emuOp2_set_byte, +/* 0x98 */ x86emuOp2_set_byte, +/* 0x99 */ x86emuOp2_set_byte, +/* 0x9a */ x86emuOp2_set_byte, +/* 0x9b */ x86emuOp2_set_byte, +/* 0x9c */ x86emuOp2_set_byte, +/* 0x9d */ x86emuOp2_set_byte, +/* 0x9e */ x86emuOp2_set_byte, +/* 0x9f */ x86emuOp2_set_byte, + +/* 0xa0 */ x86emuOp2_push_FS, +/* 0xa1 */ x86emuOp2_pop_FS, +/* 0xa2 */ x86emuOp2_cpuid, +/* 0xa3 */ x86emuOp2_bt_R, +/* 0xa4 */ x86emuOp2_shld_IMM, +/* 0xa5 */ x86emuOp2_shld_CL, +/* 0xa6 */ x86emuOp2_illegal_op, +/* 0xa7 */ x86emuOp2_illegal_op, +/* 0xa8 */ x86emuOp2_push_GS, +/* 0xa9 */ x86emuOp2_pop_GS, +/* 0xaa */ x86emuOp2_illegal_op, +/* 0xab */ x86emuOp2_bts_R, +/* 0xac */ x86emuOp2_shrd_IMM, +/* 0xad */ x86emuOp2_shrd_CL, +/* 0xae */ x86emuOp2_illegal_op, +/* 0xaf */ x86emuOp2_imul_R_RM, + +/* 0xb0 */ x86emuOp2_illegal_op, /* TODO: cmpxchg */ +/* 0xb1 */ x86emuOp2_illegal_op, /* TODO: cmpxchg */ +/* 0xb2 */ x86emuOp2_lss_R_IMM, +/* 0xb3 */ x86emuOp2_btr_R, +/* 0xb4 */ x86emuOp2_lfs_R_IMM, +/* 0xb5 */ x86emuOp2_lgs_R_IMM, +/* 0xb6 */ x86emuOp2_movzx_byte_R_RM, +/* 0xb7 */ x86emuOp2_movzx_word_R_RM, +/* 0xb8 */ x86emuOp2_illegal_op, +/* 0xb9 */ x86emuOp2_illegal_op, +/* 0xba */ x86emuOp2_btX_I, +/* 0xbb */ x86emuOp2_btc_R, +/* 0xbc */ x86emuOp2_bsf, +/* 0xbd */ x86emuOp2_bsr, +/* 0xbe */ x86emuOp2_movsx_byte_R_RM, +/* 0xbf */ x86emuOp2_movsx_word_R_RM, + +/* 0xc0 */ x86emuOp2_illegal_op, /* TODO: xadd */ +/* 0xc1 */ x86emuOp2_illegal_op, /* TODO: xadd */ +/* 0xc2 */ x86emuOp2_illegal_op, +/* 0xc3 */ x86emuOp2_illegal_op, +/* 0xc4 */ x86emuOp2_illegal_op, +/* 0xc5 */ x86emuOp2_illegal_op, +/* 0xc6 */ x86emuOp2_illegal_op, +/* 0xc7 */ x86emuOp2_illegal_op, +/* 0xc8 */ x86emuOp2_bswap, +/* 0xc9 */ x86emuOp2_bswap, +/* 0xca */ x86emuOp2_bswap, +/* 0xcb */ x86emuOp2_bswap, +/* 0xcc */ x86emuOp2_bswap, +/* 0xcd */ x86emuOp2_bswap, +/* 0xce */ x86emuOp2_bswap, +/* 0xcf */ x86emuOp2_bswap, + +/* 0xd0 */ x86emuOp2_illegal_op, +/* 0xd1 */ x86emuOp2_illegal_op, +/* 0xd2 */ x86emuOp2_illegal_op, +/* 0xd3 */ x86emuOp2_illegal_op, +/* 0xd4 */ x86emuOp2_illegal_op, +/* 0xd5 */ x86emuOp2_illegal_op, +/* 0xd6 */ x86emuOp2_illegal_op, +/* 0xd7 */ x86emuOp2_illegal_op, +/* 0xd8 */ x86emuOp2_illegal_op, +/* 0xd9 */ x86emuOp2_illegal_op, +/* 0xda */ x86emuOp2_illegal_op, +/* 0xdb */ x86emuOp2_illegal_op, +/* 0xdc */ x86emuOp2_illegal_op, +/* 0xdd */ x86emuOp2_illegal_op, +/* 0xde */ x86emuOp2_illegal_op, +/* 0xdf */ x86emuOp2_illegal_op, + +/* 0xe0 */ x86emuOp2_illegal_op, +/* 0xe1 */ x86emuOp2_illegal_op, +/* 0xe2 */ x86emuOp2_illegal_op, +/* 0xe3 */ x86emuOp2_illegal_op, +/* 0xe4 */ x86emuOp2_illegal_op, +/* 0xe5 */ x86emuOp2_illegal_op, +/* 0xe6 */ x86emuOp2_illegal_op, +/* 0xe7 */ x86emuOp2_illegal_op, +/* 0xe8 */ x86emuOp2_illegal_op, +/* 0xe9 */ x86emuOp2_illegal_op, +/* 0xea */ x86emuOp2_illegal_op, +/* 0xeb */ x86emuOp2_illegal_op, +/* 0xec */ x86emuOp2_illegal_op, +/* 0xed */ x86emuOp2_illegal_op, +/* 0xee */ x86emuOp2_illegal_op, +/* 0xef */ x86emuOp2_illegal_op, + +/* 0xf0 */ x86emuOp2_illegal_op, +/* 0xf1 */ x86emuOp2_illegal_op, +/* 0xf2 */ x86emuOp2_illegal_op, +/* 0xf3 */ x86emuOp2_illegal_op, +/* 0xf4 */ x86emuOp2_illegal_op, +/* 0xf5 */ x86emuOp2_illegal_op, +/* 0xf6 */ x86emuOp2_illegal_op, +/* 0xf7 */ x86emuOp2_illegal_op, +/* 0xf8 */ x86emuOp2_illegal_op, +/* 0xf9 */ x86emuOp2_illegal_op, +/* 0xfa */ x86emuOp2_illegal_op, +/* 0xfb */ x86emuOp2_illegal_op, +/* 0xfc */ x86emuOp2_illegal_op, +/* 0xfd */ x86emuOp2_illegal_op, +/* 0xfe */ x86emuOp2_illegal_op, +/* 0xff */ x86emuOp2_illegal_op, +}; diff --git a/xorg-server/hw/xfree86/x86emu/prim_ops.c b/xorg-server/hw/xfree86/x86emu/prim_ops.c new file mode 100644 index 000000000..41968e1a7 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/prim_ops.c @@ -0,0 +1,2722 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: This file contains the code to implement the primitive +* machine operations used by the emulation code in ops.c +* +* Carry Chain Calculation +* +* This represents a somewhat expensive calculation which is +* apparently required to emulate the setting of the OF and AF flag. +* The latter is not so important, but the former is. The overflow +* flag is the XOR of the top two bits of the carry chain for an +* addition (similar for subtraction). Since we do not want to +* simulate the addition in a bitwise manner, we try to calculate the +* carry chain given the two operands and the result. +* +* So, given the following table, which represents the addition of two +* bits, we can derive a formula for the carry chain. +* +* a b cin r cout +* 0 0 0 0 0 +* 0 0 1 1 0 +* 0 1 0 1 0 +* 0 1 1 0 1 +* 1 0 0 1 0 +* 1 0 1 0 1 +* 1 1 0 0 1 +* 1 1 1 1 1 +* +* Construction of table for cout: +* +* ab +* r \ 00 01 11 10 +* |------------------ +* 0 | 0 1 1 1 +* 1 | 0 0 1 0 +* +* By inspection, one gets: cc = ab + r'(a + b) +* +* That represents alot of operations, but NO CHOICE.... +* +* Borrow Chain Calculation. +* +* The following table represents the subtraction of two bits, from +* which we can derive a formula for the borrow chain. +* +* a b bin r bout +* 0 0 0 0 0 +* 0 0 1 1 1 +* 0 1 0 1 1 +* 0 1 1 0 1 +* 1 0 0 1 0 +* 1 0 1 0 0 +* 1 1 0 0 0 +* 1 1 1 1 1 +* +* Construction of table for cout: +* +* ab +* r \ 00 01 11 10 +* |------------------ +* 0 | 0 1 0 0 +* 1 | 1 1 1 0 +* +* By inspection, one gets: bc = a'b + r(a' + b) +* +****************************************************************************/ + +#include <stdlib.h> + +#define PRIM_OPS_NO_REDEFINE_ASM +#include "x86emu/x86emui.h" + +#if defined(__GNUC__) +# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__) || defined(__x86_64__) +# include "x86emu/prim_x86_gcc.h" +# endif +#endif + +/*------------------------- Global Variables ------------------------------*/ + +static u32 x86emu_parity_tab[8] = +{ + 0x96696996, + 0x69969669, + 0x69969669, + 0x96696996, + 0x69969669, + 0x96696996, + 0x96696996, + 0x69969669, +}; + +#define PARITY(x) (((x86emu_parity_tab[(x) / 32] >> ((x) % 32)) & 1) == 0) +#define XOR2(x) (((x) ^ ((x)>>1)) & 0x1) + +/*----------------------------- Implementation ----------------------------*/ + +/**************************************************************************** +REMARKS: +Implements the AAA instruction and side effects. +****************************************************************************/ +u16 aaa_word(u16 d) +{ + u16 res; + if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) { + d += 0x6; + d += 0x100; + SET_FLAG(F_AF); + SET_FLAG(F_CF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + } + res = (u16)(d & 0xFF0F); + CLEAR_FLAG(F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the AAA instruction and side effects. +****************************************************************************/ +u16 aas_word(u16 d) +{ + u16 res; + if ((d & 0xf) > 0x9 || ACCESS_FLAG(F_AF)) { + d -= 0x6; + d -= 0x100; + SET_FLAG(F_AF); + SET_FLAG(F_CF); + } else { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + } + res = (u16)(d & 0xFF0F); + CLEAR_FLAG(F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the AAD instruction and side effects. +****************************************************************************/ +u16 aad_word(u16 d) +{ + u16 l; + u8 hb, lb; + + hb = (u8)((d >> 8) & 0xff); + lb = (u8)((d & 0xff)); + l = (u16)((lb + 10 * hb) & 0xFF); + + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(l & 0x80, F_SF); + CONDITIONAL_SET_FLAG(l == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF); + return l; +} + +/**************************************************************************** +REMARKS: +Implements the AAM instruction and side effects. +****************************************************************************/ +u16 aam_word(u8 d) +{ + u16 h, l; + + h = (u16)(d / 10); + l = (u16)(d % 10); + l |= (u16)(h << 8); + + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(l & 0x80, F_SF); + CONDITIONAL_SET_FLAG(l == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(l & 0xff), F_PF); + return l; +} + +/**************************************************************************** +REMARKS: +Implements the ADC instruction and side effects. +****************************************************************************/ +u8 adc_byte(u8 d, u8 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 cc; + + if (ACCESS_FLAG(F_CF)) + res = 1 + d + s; + else + res = d + s; + + CONDITIONAL_SET_FLAG(res & 0x100, F_CF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (s & d) | ((~res) & (s | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the ADC instruction and side effects. +****************************************************************************/ +u16 adc_word(u16 d, u16 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 cc; + + if (ACCESS_FLAG(F_CF)) + res = 1 + d + s; + else + res = d + s; + + CONDITIONAL_SET_FLAG(res & 0x10000, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (s & d) | ((~res) & (s | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the ADC instruction and side effects. +****************************************************************************/ +u32 adc_long(u32 d, u32 s) +{ + register u32 lo; /* all operands in native machine order */ + register u32 hi; + register u32 res; + register u32 cc; + + if (ACCESS_FLAG(F_CF)) { + lo = 1 + (d & 0xFFFF) + (s & 0xFFFF); + res = 1 + d + s; + } + else { + lo = (d & 0xFFFF) + (s & 0xFFFF); + res = d + s; + } + hi = (lo >> 16) + (d >> 16) + (s >> 16); + + CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (s & d) | ((~res) & (s | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the ADD instruction and side effects. +****************************************************************************/ +u8 add_byte(u8 d, u8 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 cc; + + res = d + s; + CONDITIONAL_SET_FLAG(res & 0x100, F_CF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (s & d) | ((~res) & (s | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the ADD instruction and side effects. +****************************************************************************/ +u16 add_word(u16 d, u16 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 cc; + + res = d + s; + CONDITIONAL_SET_FLAG(res & 0x10000, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (s & d) | ((~res) & (s | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the ADD instruction and side effects. +****************************************************************************/ +u32 add_long(u32 d, u32 s) +{ + register u32 lo; /* all operands in native machine order */ + register u32 hi; + register u32 res; + register u32 cc; + + lo = (d & 0xFFFF) + (s & 0xFFFF); + res = d + s; + hi = (lo >> 16) + (d >> 16) + (s >> 16); + + CONDITIONAL_SET_FLAG(hi & 0x10000, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (s & d) | ((~res) & (s | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + + return res; +} + +/**************************************************************************** +REMARKS: +Implements the AND instruction and side effects. +****************************************************************************/ +u8 and_byte(u8 d, u8 s) +{ + register u8 res; /* all operands in native machine order */ + + res = d & s; + + /* set the flags */ + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the AND instruction and side effects. +****************************************************************************/ +u16 and_word(u16 d, u16 s) +{ + register u16 res; /* all operands in native machine order */ + + res = d & s; + + /* set the flags */ + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the AND instruction and side effects. +****************************************************************************/ +u32 and_long(u32 d, u32 s) +{ + register u32 res; /* all operands in native machine order */ + + res = d & s; + + /* set the flags */ + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the CMP instruction and side effects. +****************************************************************************/ +u8 cmp_byte(u8 d, u8 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - s; + CLEAR_FLAG(F_CF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return d; +} + +/**************************************************************************** +REMARKS: +Implements the CMP instruction and side effects. +****************************************************************************/ +u16 cmp_word(u16 d, u16 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return d; +} + +/**************************************************************************** +REMARKS: +Implements the CMP instruction and side effects. +****************************************************************************/ +u32 cmp_long(u32 d, u32 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return d; +} + +/**************************************************************************** +REMARKS: +Implements the DAA instruction and side effects. +****************************************************************************/ +u8 daa_byte(u8 d) +{ + u32 res = d; + if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) { + res += 6; + SET_FLAG(F_AF); + } + if (res > 0x9F || ACCESS_FLAG(F_CF)) { + res += 0x60; + SET_FLAG(F_CF); + } + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG((res & 0xFF) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the DAS instruction and side effects. +****************************************************************************/ +u8 das_byte(u8 d) +{ + if ((d & 0xf) > 9 || ACCESS_FLAG(F_AF)) { + d -= 6; + SET_FLAG(F_AF); + } + if (d > 0x9F || ACCESS_FLAG(F_CF)) { + d -= 0x60; + SET_FLAG(F_CF); + } + CONDITIONAL_SET_FLAG(d & 0x80, F_SF); + CONDITIONAL_SET_FLAG(d == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(d & 0xff), F_PF); + return d; +} + +/**************************************************************************** +REMARKS: +Implements the DEC instruction and side effects. +****************************************************************************/ +u8 dec_byte(u8 d) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - 1; + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + /* based on sub_byte, uses s==1. */ + bc = (res & (~d | 1)) | (~d & 1); + /* carry flag unchanged */ + CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the DEC instruction and side effects. +****************************************************************************/ +u16 dec_word(u16 d) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - 1; + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + /* based on the sub_byte routine, with s==1 */ + bc = (res & (~d | 1)) | (~d & 1); + /* carry flag unchanged */ + CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the DEC instruction and side effects. +****************************************************************************/ +u32 dec_long(u32 d) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - 1; + + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | 1)) | (~d & 1); + /* carry flag unchanged */ + CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the INC instruction and side effects. +****************************************************************************/ +u8 inc_byte(u8 d) +{ + register u32 res; /* all operands in native machine order */ + register u32 cc; + + res = d + 1; + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = ((1 & d) | (~res)) & (1 | d); + CONDITIONAL_SET_FLAG(XOR2(cc >> 6), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the INC instruction and side effects. +****************************************************************************/ +u16 inc_word(u16 d) +{ + register u32 res; /* all operands in native machine order */ + register u32 cc; + + res = d + 1; + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (1 & d) | ((~res) & (1 | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 14), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the INC instruction and side effects. +****************************************************************************/ +u32 inc_long(u32 d) +{ + register u32 res; /* all operands in native machine order */ + register u32 cc; + + res = d + 1; + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the carry chain SEE NOTE AT TOP. */ + cc = (1 & d) | ((~res) & (1 | d)); + CONDITIONAL_SET_FLAG(XOR2(cc >> 30), F_OF); + CONDITIONAL_SET_FLAG(cc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the OR instruction and side effects. +****************************************************************************/ +u8 or_byte(u8 d, u8 s) +{ + register u8 res; /* all operands in native machine order */ + + res = d | s; + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the OR instruction and side effects. +****************************************************************************/ +u16 or_word(u16 d, u16 s) +{ + register u16 res; /* all operands in native machine order */ + + res = d | s; + /* set the carry flag to be bit 8 */ + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the OR instruction and side effects. +****************************************************************************/ +u32 or_long(u32 d, u32 s) +{ + register u32 res; /* all operands in native machine order */ + + res = d | s; + + /* set the carry flag to be bit 8 */ + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the OR instruction and side effects. +****************************************************************************/ +u8 neg_byte(u8 s) +{ + register u8 res; + register u8 bc; + + CONDITIONAL_SET_FLAG(s != 0, F_CF); + res = (u8)-s; + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res), F_PF); + /* calculate the borrow chain --- modified such that d=0. + substitutiing d=0 into bc= res&(~d|s)|(~d&s); + (the one used for sub) and simplifying, since ~d=0xff..., + ~d|s == 0xffff..., and res&0xfff... == res. Similarly + ~d&s == s. So the simplified result is: */ + bc = res | s; + CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the OR instruction and side effects. +****************************************************************************/ +u16 neg_word(u16 s) +{ + register u16 res; + register u16 bc; + + CONDITIONAL_SET_FLAG(s != 0, F_CF); + res = (u16)-s; + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain --- modified such that d=0. + substitutiing d=0 into bc= res&(~d|s)|(~d&s); + (the one used for sub) and simplifying, since ~d=0xff..., + ~d|s == 0xffff..., and res&0xfff... == res. Similarly + ~d&s == s. So the simplified result is: */ + bc = res | s; + CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the OR instruction and side effects. +****************************************************************************/ +u32 neg_long(u32 s) +{ + register u32 res; + register u32 bc; + + CONDITIONAL_SET_FLAG(s != 0, F_CF); + res = (u32)-s; + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain --- modified such that d=0. + substitutiing d=0 into bc= res&(~d|s)|(~d&s); + (the one used for sub) and simplifying, since ~d=0xff..., + ~d|s == 0xffff..., and res&0xfff... == res. Similarly + ~d&s == s. So the simplified result is: */ + bc = res | s; + CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the NOT instruction and side effects. +****************************************************************************/ +u8 not_byte(u8 s) +{ + return ~s; +} + +/**************************************************************************** +REMARKS: +Implements the NOT instruction and side effects. +****************************************************************************/ +u16 not_word(u16 s) +{ + return ~s; +} + +/**************************************************************************** +REMARKS: +Implements the NOT instruction and side effects. +****************************************************************************/ +u32 not_long(u32 s) +{ + return ~s; +} + +/**************************************************************************** +REMARKS: +Implements the RCL instruction and side effects. +****************************************************************************/ +u8 rcl_byte(u8 d, u8 s) +{ + register unsigned int res, cnt, mask, cf; + + /* s is the rotate distance. It varies from 0 - 8. */ + /* have + + CF B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0 + + want to rotate through the carry by "s" bits. We could + loop, but that's inefficient. So the width is 9, + and we split into three parts: + + The new carry flag (was B_n) + the stuff in B_n-1 .. B_0 + the stuff in B_7 .. B_n+1 + + The new rotate is done mod 9, and given this, + for a rotation of n bits (mod 9) the new carry flag is + then located n bits from the MSB. The low part is + then shifted up cnt bits, and the high part is or'd + in. Using CAPS for new values, and lowercase for the + original values, this can be expressed as: + + IF n > 0 + 1) CF <- b_(8-n) + 2) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_0 + 3) B_(n-1) <- cf + 4) B_(n-2) .. B_0 <- b_7 .. b_(8-(n-1)) + */ + res = d; + if ((cnt = s % 9) != 0) { + /* extract the new CARRY FLAG. */ + /* CF <- b_(8-n) */ + cf = (d >> (8 - cnt)) & 0x1; + + /* get the low stuff which rotated + into the range B_7 .. B_cnt */ + /* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_0 */ + /* note that the right hand side done by the mask */ + res = (d << cnt) & 0xff; + + /* now the high stuff which rotated around + into the positions B_cnt-2 .. B_0 */ + /* B_(n-2) .. B_0 <- b_7 .. b_(8-(n-1)) */ + /* shift it downward, 7-(n-2) = 9-n positions. + and mask off the result before or'ing in. + */ + mask = (1 << (cnt - 1)) - 1; + res |= (d >> (9 - cnt)) & mask; + + /* if the carry flag was set, or it in. */ + if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ + /* B_(n-1) <- cf */ + res |= 1 << (cnt - 1); + } + /* set the new carry flag, based on the variable "cf" */ + CONDITIONAL_SET_FLAG(cf, F_CF); + /* OVERFLOW is set *IFF* cnt==1, then it is the + xor of CF and the most significant bit. Blecck. */ + /* parenthesized this expression since it appears to + be causing OF to be misset */ + CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 6) & 0x2)), + F_OF); + + } + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the RCL instruction and side effects. +****************************************************************************/ +u16 rcl_word(u16 d, u8 s) +{ + register unsigned int res, cnt, mask, cf; + + res = d; + if ((cnt = s % 17) != 0) { + cf = (d >> (16 - cnt)) & 0x1; + res = (d << cnt) & 0xffff; + mask = (1 << (cnt - 1)) - 1; + res |= (d >> (17 - cnt)) & mask; + if (ACCESS_FLAG(F_CF)) { + res |= 1 << (cnt - 1); + } + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 14) & 0x2)), + F_OF); + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the RCL instruction and side effects. +****************************************************************************/ +u32 rcl_long(u32 d, u8 s) +{ + register u32 res, cnt, mask, cf; + + res = d; + if ((cnt = s % 33) != 0) { + cf = (d >> (32 - cnt)) & 0x1; + res = (d << cnt) & 0xffffffff; + mask = (1 << (cnt - 1)) - 1; + res |= (d >> (33 - cnt)) & mask; + if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ + res |= 1 << (cnt - 1); + } + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG(cnt == 1 && XOR2(cf + ((res >> 30) & 0x2)), + F_OF); + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the RCR instruction and side effects. +****************************************************************************/ +u8 rcr_byte(u8 d, u8 s) +{ + u32 res, cnt; + u32 mask, cf, ocf = 0; + + /* rotate right through carry */ + /* + s is the rotate distance. It varies from 0 - 8. + d is the byte object rotated. + + have + + CF B_7 B_6 B_5 B_4 B_3 B_2 B_1 B_0 + + The new rotate is done mod 9, and given this, + for a rotation of n bits (mod 9) the new carry flag is + then located n bits from the LSB. The low part is + then shifted up cnt bits, and the high part is or'd + in. Using CAPS for new values, and lowercase for the + original values, this can be expressed as: + + IF n > 0 + 1) CF <- b_(n-1) + 2) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) + 3) B_(8-n) <- cf + 4) B_(7) .. B_(8-(n-1)) <- b_(n-2) .. b_(0) + */ + res = d; + if ((cnt = s % 9) != 0) { + /* extract the new CARRY FLAG. */ + /* CF <- b_(n-1) */ + if (cnt == 1) { + cf = d & 0x1; + /* note hackery here. Access_flag(..) evaluates to either + 0 if flag not set + non-zero if flag is set. + doing access_flag(..) != 0 casts that into either + 0..1 in any representation of the flags register + (i.e. packed bit array or unpacked.) + */ + ocf = ACCESS_FLAG(F_CF) != 0; + } else + cf = (d >> (cnt - 1)) & 0x1; + + /* B_(8-(n+1)) .. B_(0) <- b_(7) .. b_n */ + /* note that the right hand side done by the mask + This is effectively done by shifting the + object to the right. The result must be masked, + in case the object came in and was treated + as a negative number. Needed??? */ + + mask = (1 << (8 - cnt)) - 1; + res = (d >> cnt) & mask; + + /* now the high stuff which rotated around + into the positions B_cnt-2 .. B_0 */ + /* B_(7) .. B_(8-(n-1)) <- b_(n-2) .. b_(0) */ + /* shift it downward, 7-(n-2) = 9-n positions. + and mask off the result before or'ing in. + */ + res |= (d << (9 - cnt)); + + /* if the carry flag was set, or it in. */ + if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ + /* B_(8-n) <- cf */ + res |= 1 << (8 - cnt); + } + /* set the new carry flag, based on the variable "cf" */ + CONDITIONAL_SET_FLAG(cf, F_CF); + /* OVERFLOW is set *IFF* cnt==1, then it is the + xor of CF and the most significant bit. Blecck. */ + /* parenthesized... */ + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 6) & 0x2)), + F_OF); + } + } + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the RCR instruction and side effects. +****************************************************************************/ +u16 rcr_word(u16 d, u8 s) +{ + u32 res, cnt; + u32 mask, cf, ocf = 0; + + /* rotate right through carry */ + res = d; + if ((cnt = s % 17) != 0) { + if (cnt == 1) { + cf = d & 0x1; + ocf = ACCESS_FLAG(F_CF) != 0; + } else + cf = (d >> (cnt - 1)) & 0x1; + mask = (1 << (16 - cnt)) - 1; + res = (d >> cnt) & mask; + res |= (d << (17 - cnt)); + if (ACCESS_FLAG(F_CF)) { + res |= 1 << (16 - cnt); + } + CONDITIONAL_SET_FLAG(cf, F_CF); + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 14) & 0x2)), + F_OF); + } + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the RCR instruction and side effects. +****************************************************************************/ +u32 rcr_long(u32 d, u8 s) +{ + u32 res, cnt; + u32 mask, cf, ocf = 0; + + /* rotate right through carry */ + res = d; + if ((cnt = s % 33) != 0) { + if (cnt == 1) { + cf = d & 0x1; + ocf = ACCESS_FLAG(F_CF) != 0; + } else + cf = (d >> (cnt - 1)) & 0x1; + mask = (1 << (32 - cnt)) - 1; + res = (d >> cnt) & mask; + if (cnt != 1) + res |= (d << (33 - cnt)); + if (ACCESS_FLAG(F_CF)) { /* carry flag is set */ + res |= 1 << (32 - cnt); + } + CONDITIONAL_SET_FLAG(cf, F_CF); + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(ocf + ((d >> 30) & 0x2)), + F_OF); + } + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the ROL instruction and side effects. +****************************************************************************/ +u8 rol_byte(u8 d, u8 s) +{ + register unsigned int res, cnt, mask; + + /* rotate left */ + /* + s is the rotate distance. It varies from 0 - 8. + d is the byte object rotated. + + have + + CF B_7 ... B_0 + + The new rotate is done mod 8. + Much simpler than the "rcl" or "rcr" operations. + + IF n > 0 + 1) B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) + 2) B_(n-1) .. B_(0) <- b_(7) .. b_(8-n) + */ + res = d; + if ((cnt = s % 8) != 0) { + /* B_(7) .. B_(n) <- b_(8-(n+1)) .. b_(0) */ + res = (d << cnt); + + /* B_(n-1) .. B_(0) <- b_(7) .. b_(8-n) */ + mask = (1 << cnt) - 1; + res |= (d >> (8 - cnt)) & mask; + + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x1, F_CF); + /* OVERFLOW is set *IFF* s==1, then it is the + xor of CF and the most significant bit. Blecck. */ + CONDITIONAL_SET_FLAG(s == 1 && + XOR2((res & 0x1) + ((res >> 6) & 0x2)), + F_OF); + } if (s != 0) { + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x1, F_CF); + } + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the ROL instruction and side effects. +****************************************************************************/ +u16 rol_word(u16 d, u8 s) +{ + register unsigned int res, cnt, mask; + + res = d; + if ((cnt = s % 16) != 0) { + res = (d << cnt); + mask = (1 << cnt) - 1; + res |= (d >> (16 - cnt)) & mask; + CONDITIONAL_SET_FLAG(res & 0x1, F_CF); + CONDITIONAL_SET_FLAG(s == 1 && + XOR2((res & 0x1) + ((res >> 14) & 0x2)), + F_OF); + } if (s != 0) { + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x1, F_CF); + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the ROL instruction and side effects. +****************************************************************************/ +u32 rol_long(u32 d, u8 s) +{ + register u32 res, cnt, mask; + + res = d; + if ((cnt = s % 32) != 0) { + res = (d << cnt); + mask = (1 << cnt) - 1; + res |= (d >> (32 - cnt)) & mask; + CONDITIONAL_SET_FLAG(res & 0x1, F_CF); + CONDITIONAL_SET_FLAG(s == 1 && + XOR2((res & 0x1) + ((res >> 30) & 0x2)), + F_OF); + } if (s != 0) { + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x1, F_CF); + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the ROR instruction and side effects. +****************************************************************************/ +u8 ror_byte(u8 d, u8 s) +{ + register unsigned int res, cnt, mask; + + /* rotate right */ + /* + s is the rotate distance. It varies from 0 - 8. + d is the byte object rotated. + + have + + B_7 ... B_0 + + The rotate is done mod 8. + + IF n > 0 + 1) B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) + 2) B_(7) .. B_(8-n) <- b_(n-1) .. b_(0) + */ + res = d; + if ((cnt = s % 8) != 0) { /* not a typo, do nada if cnt==0 */ + /* B_(7) .. B_(8-n) <- b_(n-1) .. b_(0) */ + res = (d << (8 - cnt)); + + /* B_(8-(n+1)) .. B_(0) <- b_(7) .. b_(n) */ + mask = (1 << (8 - cnt)) - 1; + res |= (d >> (cnt)) & mask; + + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x80, F_CF); + /* OVERFLOW is set *IFF* s==1, then it is the + xor of the two most significant bits. Blecck. */ + CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 6), F_OF); + } else if (s != 0) { + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x80, F_CF); + } + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the ROR instruction and side effects. +****************************************************************************/ +u16 ror_word(u16 d, u8 s) +{ + register unsigned int res, cnt, mask; + + res = d; + if ((cnt = s % 16) != 0) { + res = (d << (16 - cnt)); + mask = (1 << (16 - cnt)) - 1; + res |= (d >> (cnt)) & mask; + CONDITIONAL_SET_FLAG(res & 0x8000, F_CF); + CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 14), F_OF); + } else if (s != 0) { + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x8000, F_CF); + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the ROR instruction and side effects. +****************************************************************************/ +u32 ror_long(u32 d, u8 s) +{ + register u32 res, cnt, mask; + + res = d; + if ((cnt = s % 32) != 0) { + res = (d << (32 - cnt)); + mask = (1 << (32 - cnt)) - 1; + res |= (d >> (cnt)) & mask; + CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF); + CONDITIONAL_SET_FLAG(s == 1 && XOR2(res >> 30), F_OF); + } else if (s != 0) { + /* set the new carry flag, Note that it is the low order + bit of the result!!! */ + CONDITIONAL_SET_FLAG(res & 0x80000000, F_CF); + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the SHL instruction and side effects. +****************************************************************************/ +u8 shl_byte(u8 d, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 8) { + cnt = s % 8; + + /* last bit shifted out goes into carry flag */ + if (cnt > 0) { + res = d << cnt; + cf = d & (1 << (8 - cnt)); + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = (u8) d; + } + + if (cnt == 1) { + /* Needs simplification. */ + CONDITIONAL_SET_FLAG( + (((res & 0x80) == 0x80) ^ + (ACCESS_FLAG(F_CF) != 0)), + /* was (M.x86.R_FLG&F_CF)==F_CF)), */ + F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80, F_CF); + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_PF); + SET_FLAG(F_ZF); + } + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the SHL instruction and side effects. +****************************************************************************/ +u16 shl_word(u16 d, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 16) { + cnt = s % 16; + if (cnt > 0) { + res = d << cnt; + cf = d & (1 << (16 - cnt)); + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = (u16) d; + } + + if (cnt == 1) { + CONDITIONAL_SET_FLAG( + (((res & 0x8000) == 0x8000) ^ + (ACCESS_FLAG(F_CF) != 0)), + F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CONDITIONAL_SET_FLAG((d << (s-1)) & 0x8000, F_CF); + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_PF); + SET_FLAG(F_ZF); + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the SHL instruction and side effects. +****************************************************************************/ +u32 shl_long(u32 d, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 32) { + cnt = s % 32; + if (cnt > 0) { + res = d << cnt; + cf = d & (1 << (32 - cnt)); + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = d; + } + if (cnt == 1) { + CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^ + (ACCESS_FLAG(F_CF) != 0)), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80000000, F_CF); + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_PF); + SET_FLAG(F_ZF); + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the SHR instruction and side effects. +****************************************************************************/ +u8 shr_byte(u8 d, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 8) { + cnt = s % 8; + if (cnt > 0) { + cf = d & (1 << (cnt - 1)); + res = d >> cnt; + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = (u8) d; + } + + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(res >> 6), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CONDITIONAL_SET_FLAG((d >> (s-1)) & 0x1, F_CF); + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_PF); + SET_FLAG(F_ZF); + } + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the SHR instruction and side effects. +****************************************************************************/ +u16 shr_word(u16 d, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 16) { + cnt = s % 16; + if (cnt > 0) { + cf = d & (1 << (cnt - 1)); + res = d >> cnt; + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = d; + } + + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + SET_FLAG(F_ZF); + CLEAR_FLAG(F_SF); + CLEAR_FLAG(F_PF); + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the SHR instruction and side effects. +****************************************************************************/ +u32 shr_long(u32 d, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 32) { + cnt = s % 32; + if (cnt > 0) { + cf = d & (1 << (cnt - 1)); + res = d >> cnt; + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = d; + } + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + SET_FLAG(F_ZF); + CLEAR_FLAG(F_SF); + CLEAR_FLAG(F_PF); + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the SAR instruction and side effects. +****************************************************************************/ +u8 sar_byte(u8 d, u8 s) +{ + unsigned int cnt, res, cf, mask, sf; + + res = d; + sf = d & 0x80; + cnt = s % 8; + if (cnt > 0 && cnt < 8) { + mask = (1 << (8 - cnt)) - 1; + cf = d & (1 << (cnt - 1)); + res = (d >> cnt) & mask; + CONDITIONAL_SET_FLAG(cf, F_CF); + if (sf) { + res |= ~mask; + } + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + } else if (cnt >= 8) { + if (sf) { + res = 0xff; + SET_FLAG(F_CF); + CLEAR_FLAG(F_ZF); + SET_FLAG(F_SF); + SET_FLAG(F_PF); + } else { + res = 0; + CLEAR_FLAG(F_CF); + SET_FLAG(F_ZF); + CLEAR_FLAG(F_SF); + CLEAR_FLAG(F_PF); + } + } + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the SAR instruction and side effects. +****************************************************************************/ +u16 sar_word(u16 d, u8 s) +{ + unsigned int cnt, res, cf, mask, sf; + + sf = d & 0x8000; + cnt = s % 16; + res = d; + if (cnt > 0 && cnt < 16) { + mask = (1 << (16 - cnt)) - 1; + cf = d & (1 << (cnt - 1)); + res = (d >> cnt) & mask; + CONDITIONAL_SET_FLAG(cf, F_CF); + if (sf) { + res |= ~mask; + } + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else if (cnt >= 16) { + if (sf) { + res = 0xffff; + SET_FLAG(F_CF); + CLEAR_FLAG(F_ZF); + SET_FLAG(F_SF); + SET_FLAG(F_PF); + } else { + res = 0; + CLEAR_FLAG(F_CF); + SET_FLAG(F_ZF); + CLEAR_FLAG(F_SF); + CLEAR_FLAG(F_PF); + } + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the SAR instruction and side effects. +****************************************************************************/ +u32 sar_long(u32 d, u8 s) +{ + u32 cnt, res, cf, mask, sf; + + sf = d & 0x80000000; + cnt = s % 32; + res = d; + if (cnt > 0 && cnt < 32) { + mask = (1 << (32 - cnt)) - 1; + cf = d & (1 << (cnt - 1)); + res = (d >> cnt) & mask; + CONDITIONAL_SET_FLAG(cf, F_CF); + if (sf) { + res |= ~mask; + } + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else if (cnt >= 32) { + if (sf) { + res = 0xffffffff; + SET_FLAG(F_CF); + CLEAR_FLAG(F_ZF); + SET_FLAG(F_SF); + SET_FLAG(F_PF); + } else { + res = 0; + CLEAR_FLAG(F_CF); + SET_FLAG(F_ZF); + CLEAR_FLAG(F_SF); + CLEAR_FLAG(F_PF); + } + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the SHLD instruction and side effects. +****************************************************************************/ +u16 shld_word (u16 d, u16 fill, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 16) { + cnt = s % 16; + if (cnt > 0) { + res = (d << cnt) | (fill >> (16-cnt)); + cf = d & (1 << (16 - cnt)); + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = d; + } + if (cnt == 1) { + CONDITIONAL_SET_FLAG((((res & 0x8000) == 0x8000) ^ + (ACCESS_FLAG(F_CF) != 0)), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CONDITIONAL_SET_FLAG((d << (s-1)) & 0x8000, F_CF); + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_PF); + SET_FLAG(F_ZF); + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the SHLD instruction and side effects. +****************************************************************************/ +u32 shld_long (u32 d, u32 fill, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 32) { + cnt = s % 32; + if (cnt > 0) { + res = (d << cnt) | (fill >> (32-cnt)); + cf = d & (1 << (32 - cnt)); + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = d; + } + if (cnt == 1) { + CONDITIONAL_SET_FLAG((((res & 0x80000000) == 0x80000000) ^ + (ACCESS_FLAG(F_CF) != 0)), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CONDITIONAL_SET_FLAG((d << (s-1)) & 0x80000000, F_CF); + CLEAR_FLAG(F_OF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_PF); + SET_FLAG(F_ZF); + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the SHRD instruction and side effects. +****************************************************************************/ +u16 shrd_word (u16 d, u16 fill, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 16) { + cnt = s % 16; + if (cnt > 0) { + cf = d & (1 << (cnt - 1)); + res = (d >> cnt) | (fill << (16 - cnt)); + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = d; + } + + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(res >> 14), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + SET_FLAG(F_ZF); + CLEAR_FLAG(F_SF); + CLEAR_FLAG(F_PF); + } + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the SHRD instruction and side effects. +****************************************************************************/ +u32 shrd_long (u32 d, u32 fill, u8 s) +{ + unsigned int cnt, res, cf; + + if (s < 32) { + cnt = s % 32; + if (cnt > 0) { + cf = d & (1 << (cnt - 1)); + res = (d >> cnt) | (fill << (32 - cnt)); + CONDITIONAL_SET_FLAG(cf, F_CF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + } else { + res = d; + } + if (cnt == 1) { + CONDITIONAL_SET_FLAG(XOR2(res >> 30), F_OF); + } else { + CLEAR_FLAG(F_OF); + } + } else { + res = 0; + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + SET_FLAG(F_ZF); + CLEAR_FLAG(F_SF); + CLEAR_FLAG(F_PF); + } + return res; +} + +/**************************************************************************** +REMARKS: +Implements the SBB instruction and side effects. +****************************************************************************/ +u8 sbb_byte(u8 d, u8 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + if (ACCESS_FLAG(F_CF)) + res = d - s - 1; + else + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the SBB instruction and side effects. +****************************************************************************/ +u16 sbb_word(u16 d, u16 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + if (ACCESS_FLAG(F_CF)) + res = d - s - 1; + else + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the SBB instruction and side effects. +****************************************************************************/ +u32 sbb_long(u32 d, u32 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + if (ACCESS_FLAG(F_CF)) + res = d - s - 1; + else + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the SUB instruction and side effects. +****************************************************************************/ +u8 sub_byte(u8 d, u8 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG((res & 0xff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x80, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 6), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return (u8)res; +} + +/**************************************************************************** +REMARKS: +Implements the SUB instruction and side effects. +****************************************************************************/ +u16 sub_word(u16 d, u16 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x8000, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 14), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return (u16)res; +} + +/**************************************************************************** +REMARKS: +Implements the SUB instruction and side effects. +****************************************************************************/ +u32 sub_long(u32 d, u32 s) +{ + register u32 res; /* all operands in native machine order */ + register u32 bc; + + res = d - s; + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG((res & 0xffffffff) == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + + /* calculate the borrow chain. See note at top */ + bc = (res & (~d | s)) | (~d & s); + CONDITIONAL_SET_FLAG(bc & 0x80000000, F_CF); + CONDITIONAL_SET_FLAG(XOR2(bc >> 30), F_OF); + CONDITIONAL_SET_FLAG(bc & 0x8, F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the TEST instruction and side effects. +****************************************************************************/ +void test_byte(u8 d, u8 s) +{ + register u32 res; /* all operands in native machine order */ + + res = d & s; + + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + /* AF == dont care */ + CLEAR_FLAG(F_CF); +} + +/**************************************************************************** +REMARKS: +Implements the TEST instruction and side effects. +****************************************************************************/ +void test_word(u16 d, u16 s) +{ + register u32 res; /* all operands in native machine order */ + + res = d & s; + + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + /* AF == dont care */ + CLEAR_FLAG(F_CF); +} + +/**************************************************************************** +REMARKS: +Implements the TEST instruction and side effects. +****************************************************************************/ +void test_long(u32 d, u32 s) +{ + register u32 res; /* all operands in native machine order */ + + res = d & s; + + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + /* AF == dont care */ + CLEAR_FLAG(F_CF); +} + +/**************************************************************************** +REMARKS: +Implements the XOR instruction and side effects. +****************************************************************************/ +u8 xor_byte(u8 d, u8 s) +{ + register u8 res; /* all operands in native machine order */ + + res = d ^ s; + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(res & 0x80, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res), F_PF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the XOR instruction and side effects. +****************************************************************************/ +u16 xor_word(u16 d, u16 s) +{ + register u16 res; /* all operands in native machine order */ + + res = d ^ s; + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(res & 0x8000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the XOR instruction and side effects. +****************************************************************************/ +u32 xor_long(u32 d, u32 s) +{ + register u32 res; /* all operands in native machine order */ + + res = d ^ s; + CLEAR_FLAG(F_OF); + CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF); + CONDITIONAL_SET_FLAG(res == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF); + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + return res; +} + +/**************************************************************************** +REMARKS: +Implements the IMUL instruction and side effects. +****************************************************************************/ +void imul_byte(u8 s) +{ + s16 res = (s16)((s8)M.x86.R_AL * (s8)s); + + M.x86.R_AX = res; + if (((M.x86.R_AL & 0x80) == 0 && M.x86.R_AH == 0x00) || + ((M.x86.R_AL & 0x80) != 0 && M.x86.R_AH == 0xFF)) { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } else { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } +} + +/**************************************************************************** +REMARKS: +Implements the IMUL instruction and side effects. +****************************************************************************/ +void imul_word(u16 s) +{ + s32 res = (s16)M.x86.R_AX * (s16)s; + + M.x86.R_AX = (u16)res; + M.x86.R_DX = (u16)(res >> 16); + if (((M.x86.R_AX & 0x8000) == 0 && M.x86.R_DX == 0x00) || + ((M.x86.R_AX & 0x8000) != 0 && M.x86.R_DX == 0xFF)) { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } else { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } +} + +/**************************************************************************** +REMARKS: +Implements the IMUL instruction and side effects. +****************************************************************************/ +void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s) +{ +#ifdef __HAS_LONG_LONG__ + s64 res = (s64)(s32)d * (s32)s; + + *res_lo = (u32)res; + *res_hi = (u32)(res >> 32); +#else + u32 d_lo,d_hi,d_sign; + u32 s_lo,s_hi,s_sign; + u32 rlo_lo,rlo_hi,rhi_lo; + + if ((d_sign = d & 0x80000000) != 0) + d = -d; + d_lo = d & 0xFFFF; + d_hi = d >> 16; + if ((s_sign = s & 0x80000000) != 0) + s = -s; + s_lo = s & 0xFFFF; + s_hi = s >> 16; + rlo_lo = d_lo * s_lo; + rlo_hi = (d_hi * s_lo + d_lo * s_hi) + (rlo_lo >> 16); + rhi_lo = d_hi * s_hi + (rlo_hi >> 16); + *res_lo = (rlo_hi << 16) | (rlo_lo & 0xFFFF); + *res_hi = rhi_lo; + if (d_sign != s_sign) { + d = ~*res_lo; + s = (((d & 0xFFFF) + 1) >> 16) + (d >> 16); + *res_lo = ~*res_lo+1; + *res_hi = ~*res_hi+(s >> 16); + } +#endif +} + +/**************************************************************************** +REMARKS: +Implements the IMUL instruction and side effects. +****************************************************************************/ +void imul_long(u32 s) +{ + imul_long_direct(&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s); + if (((M.x86.R_EAX & 0x80000000) == 0 && M.x86.R_EDX == 0x00) || + ((M.x86.R_EAX & 0x80000000) != 0 && M.x86.R_EDX == 0xFF)) { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } else { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } +} + +/**************************************************************************** +REMARKS: +Implements the MUL instruction and side effects. +****************************************************************************/ +void mul_byte(u8 s) +{ + u16 res = (u16)(M.x86.R_AL * s); + + M.x86.R_AX = res; + if (M.x86.R_AH == 0) { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } else { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } +} + +/**************************************************************************** +REMARKS: +Implements the MUL instruction and side effects. +****************************************************************************/ +void mul_word(u16 s) +{ + u32 res = M.x86.R_AX * s; + + M.x86.R_AX = (u16)res; + M.x86.R_DX = (u16)(res >> 16); + if (M.x86.R_DX == 0) { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } else { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } +} + +/**************************************************************************** +REMARKS: +Implements the MUL instruction and side effects. +****************************************************************************/ +void mul_long(u32 s) +{ +#ifdef __HAS_LONG_LONG__ + u64 res = (u64)M.x86.R_EAX * s; + + M.x86.R_EAX = (u32)res; + M.x86.R_EDX = (u32)(res >> 32); +#else + u32 a,a_lo,a_hi; + u32 s_lo,s_hi; + u32 rlo_lo,rlo_hi,rhi_lo; + + a = M.x86.R_EAX; + a_lo = a & 0xFFFF; + a_hi = a >> 16; + s_lo = s & 0xFFFF; + s_hi = s >> 16; + rlo_lo = a_lo * s_lo; + rlo_hi = (a_hi * s_lo + a_lo * s_hi) + (rlo_lo >> 16); + rhi_lo = a_hi * s_hi + (rlo_hi >> 16); + M.x86.R_EAX = (rlo_hi << 16) | (rlo_lo & 0xFFFF); + M.x86.R_EDX = rhi_lo; +#endif + + if (M.x86.R_EDX == 0) { + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_OF); + } else { + SET_FLAG(F_CF); + SET_FLAG(F_OF); + } +} + +/**************************************************************************** +REMARKS: +Implements the IDIV instruction and side effects. +****************************************************************************/ +void idiv_byte(u8 s) +{ + s32 dvd, div, mod; + + dvd = (s16)M.x86.R_AX; + if (s == 0) { + x86emu_intr_raise(0); + return; + } + div = dvd / (s8)s; + mod = dvd % (s8)s; + if (abs(div) > 0x7f) { + x86emu_intr_raise(0); + return; + } + M.x86.R_AL = (s8) div; + M.x86.R_AH = (s8) mod; +} + +/**************************************************************************** +REMARKS: +Implements the IDIV instruction and side effects. +****************************************************************************/ +void idiv_word(u16 s) +{ + s32 dvd, div, mod; + + dvd = (((s32)M.x86.R_DX) << 16) | M.x86.R_AX; + if (s == 0) { + x86emu_intr_raise(0); + return; + } + div = dvd / (s16)s; + mod = dvd % (s16)s; + if (abs(div) > 0x7fff) { + x86emu_intr_raise(0); + return; + } + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_SF); + CONDITIONAL_SET_FLAG(div == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); + + M.x86.R_AX = (u16)div; + M.x86.R_DX = (u16)mod; +} + +/**************************************************************************** +REMARKS: +Implements the IDIV instruction and side effects. +****************************************************************************/ +void idiv_long(u32 s) +{ +#ifdef __HAS_LONG_LONG__ + s64 dvd, div, mod; + + dvd = (((s64)M.x86.R_EDX) << 32) | M.x86.R_EAX; + if (s == 0) { + x86emu_intr_raise(0); + return; + } + div = dvd / (s32)s; + mod = dvd % (s32)s; + if (abs(div) > 0x7fffffff) { + x86emu_intr_raise(0); + return; + } +#else + s32 div = 0, mod; + s32 h_dvd = M.x86.R_EDX; + u32 l_dvd = M.x86.R_EAX; + u32 abs_s = s & 0x7FFFFFFF; + u32 abs_h_dvd = h_dvd & 0x7FFFFFFF; + u32 h_s = abs_s >> 1; + u32 l_s = abs_s << 31; + int counter = 31; + int carry; + + if (s == 0) { + x86emu_intr_raise(0); + return; + } + do { + div <<= 1; + carry = (l_dvd >= l_s) ? 0 : 1; + + if (abs_h_dvd < (h_s + carry)) { + h_s >>= 1; + l_s = abs_s << (--counter); + continue; + } else { + abs_h_dvd -= (h_s + carry); + l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1) + : (l_dvd - l_s); + h_s >>= 1; + l_s = abs_s << (--counter); + div |= 1; + continue; + } + + } while (counter > -1); + /* overflow */ + if (abs_h_dvd || (l_dvd > abs_s)) { + x86emu_intr_raise(0); + return; + } + /* sign */ + div |= ((h_dvd & 0x10000000) ^ (s & 0x10000000)); + mod = l_dvd; + +#endif + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_ZF); + CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); + + M.x86.R_EAX = (u32)div; + M.x86.R_EDX = (u32)mod; +} + +/**************************************************************************** +REMARKS: +Implements the DIV instruction and side effects. +****************************************************************************/ +void div_byte(u8 s) +{ + u32 dvd, div, mod; + + dvd = M.x86.R_AX; + if (s == 0) { + x86emu_intr_raise(0); + return; + } + div = dvd / (u8)s; + mod = dvd % (u8)s; + if (abs(div) > 0xff) { + x86emu_intr_raise(0); + return; + } + M.x86.R_AL = (u8)div; + M.x86.R_AH = (u8)mod; +} + +/**************************************************************************** +REMARKS: +Implements the DIV instruction and side effects. +****************************************************************************/ +void div_word(u16 s) +{ + u32 dvd, div, mod; + + dvd = (((u32)M.x86.R_DX) << 16) | M.x86.R_AX; + if (s == 0) { + x86emu_intr_raise(0); + return; + } + div = dvd / (u16)s; + mod = dvd % (u16)s; + if (abs(div) > 0xffff) { + x86emu_intr_raise(0); + return; + } + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_SF); + CONDITIONAL_SET_FLAG(div == 0, F_ZF); + CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); + + M.x86.R_AX = (u16)div; + M.x86.R_DX = (u16)mod; +} + +/**************************************************************************** +REMARKS: +Implements the DIV instruction and side effects. +****************************************************************************/ +void div_long(u32 s) +{ +#ifdef __HAS_LONG_LONG__ + u64 dvd, div, mod; + + dvd = (((u64)M.x86.R_EDX) << 32) | M.x86.R_EAX; + if (s == 0) { + x86emu_intr_raise(0); + return; + } + div = dvd / (u32)s; + mod = dvd % (u32)s; + if (abs(div) > 0xffffffff) { + x86emu_intr_raise(0); + return; + } +#else + s32 div = 0, mod; + s32 h_dvd = M.x86.R_EDX; + u32 l_dvd = M.x86.R_EAX; + + u32 h_s = s; + u32 l_s = 0; + int counter = 32; + int carry; + + if (s == 0) { + x86emu_intr_raise(0); + return; + } + do { + div <<= 1; + carry = (l_dvd >= l_s) ? 0 : 1; + + if (h_dvd < (h_s + carry)) { + h_s >>= 1; + l_s = s << (--counter); + continue; + } else { + h_dvd -= (h_s + carry); + l_dvd = carry ? ((0xFFFFFFFF - l_s) + l_dvd + 1) + : (l_dvd - l_s); + h_s >>= 1; + l_s = s << (--counter); + div |= 1; + continue; + } + + } while (counter > -1); + /* overflow */ + if (h_dvd || (l_dvd > s)) { + x86emu_intr_raise(0); + return; + } + mod = l_dvd; +#endif + CLEAR_FLAG(F_CF); + CLEAR_FLAG(F_AF); + CLEAR_FLAG(F_SF); + SET_FLAG(F_ZF); + CONDITIONAL_SET_FLAG(PARITY(mod & 0xff), F_PF); + + M.x86.R_EAX = (u32)div; + M.x86.R_EDX = (u32)mod; +} + +/**************************************************************************** +REMARKS: +Implements the IN string instruction and side effects. +****************************************************************************/ +void ins(int size) +{ + int inc = size; + + if (ACCESS_FLAG(F_DF)) { + inc = -size; + } + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* in until CX is ZERO. */ + u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ? + M.x86.R_ECX : M.x86.R_CX); + switch (size) { + case 1: + while (count--) { + store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, + (*sys_inb)(M.x86.R_DX)); + M.x86.R_DI += inc; + } + break; + + case 2: + while (count--) { + store_data_word_abs(M.x86.R_ES, M.x86.R_DI, + (*sys_inw)(M.x86.R_DX)); + M.x86.R_DI += inc; + } + break; + case 4: + while (count--) { + store_data_long_abs(M.x86.R_ES, M.x86.R_DI, + (*sys_inl)(M.x86.R_DX)); + M.x86.R_DI += inc; + break; + } + } + M.x86.R_CX = 0; + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ECX = 0; + } + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } else { + switch (size) { + case 1: + store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, + (*sys_inb)(M.x86.R_DX)); + break; + case 2: + store_data_word_abs(M.x86.R_ES, M.x86.R_DI, + (*sys_inw)(M.x86.R_DX)); + break; + case 4: + store_data_long_abs(M.x86.R_ES, M.x86.R_DI, + (*sys_inl)(M.x86.R_DX)); + break; + } + M.x86.R_DI += inc; + } +} + +/**************************************************************************** +REMARKS: +Implements the OUT string instruction and side effects. +****************************************************************************/ +void outs(int size) +{ + int inc = size; + + if (ACCESS_FLAG(F_DF)) { + inc = -size; + } + if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) { + /* dont care whether REPE or REPNE */ + /* out until CX is ZERO. */ + u32 count = ((M.x86.mode & SYSMODE_PREFIX_DATA) ? + M.x86.R_ECX : M.x86.R_CX); + switch (size) { + case 1: + while (count--) { + (*sys_outb)(M.x86.R_DX, + fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI)); + M.x86.R_SI += inc; + } + break; + + case 2: + while (count--) { + (*sys_outw)(M.x86.R_DX, + fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI)); + M.x86.R_SI += inc; + } + break; + case 4: + while (count--) { + (*sys_outl)(M.x86.R_DX, + fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI)); + M.x86.R_SI += inc; + break; + } + } + M.x86.R_CX = 0; + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + M.x86.R_ECX = 0; + } + M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE); + } else { + switch (size) { + case 1: + (*sys_outb)(M.x86.R_DX, + fetch_data_byte_abs(M.x86.R_ES, M.x86.R_SI)); + break; + case 2: + (*sys_outw)(M.x86.R_DX, + fetch_data_word_abs(M.x86.R_ES, M.x86.R_SI)); + break; + case 4: + (*sys_outl)(M.x86.R_DX, + fetch_data_long_abs(M.x86.R_ES, M.x86.R_SI)); + break; + } + M.x86.R_SI += inc; + } +} + +/**************************************************************************** +PARAMETERS: +addr - Address to fetch word from + +REMARKS: +Fetches a word from emulator memory using an absolute address. +****************************************************************************/ +u16 mem_access_word(int addr) +{ +DB( if (CHECK_MEM_ACCESS()) + x86emu_check_mem_access(addr);) + return (*sys_rdw)(addr); +} + +/**************************************************************************** +REMARKS: +Pushes a word onto the stack. + +NOTE: Do not inline this, as (*sys_wrX) is already inline! +****************************************************************************/ +void push_word(u16 w) +{ +DB( if (CHECK_SP_ACCESS()) + x86emu_check_sp_access();) + M.x86.R_SP -= 2; + (*sys_wrw)(((u32)M.x86.R_SS << 4) + M.x86.R_SP, w); +} + +/**************************************************************************** +REMARKS: +Pushes a long onto the stack. + +NOTE: Do not inline this, as (*sys_wrX) is already inline! +****************************************************************************/ +void push_long(u32 w) +{ +DB( if (CHECK_SP_ACCESS()) + x86emu_check_sp_access();) + M.x86.R_SP -= 4; + (*sys_wrl)(((u32)M.x86.R_SS << 4) + M.x86.R_SP, w); +} + +/**************************************************************************** +REMARKS: +Pops a word from the stack. + +NOTE: Do not inline this, as (*sys_rdX) is already inline! +****************************************************************************/ +u16 pop_word(void) +{ + register u16 res; + +DB( if (CHECK_SP_ACCESS()) + x86emu_check_sp_access();) + res = (*sys_rdw)(((u32)M.x86.R_SS << 4) + M.x86.R_SP); + M.x86.R_SP += 2; + return res; +} + +/**************************************************************************** +REMARKS: +Pops a long from the stack. + +NOTE: Do not inline this, as (*sys_rdX) is already inline! +****************************************************************************/ +u32 pop_long(void) +{ + register u32 res; + +DB( if (CHECK_SP_ACCESS()) + x86emu_check_sp_access();) + res = (*sys_rdl)(((u32)M.x86.R_SS << 4) + M.x86.R_SP); + M.x86.R_SP += 4; + return res; +} + +/**************************************************************************** +REMARKS: +CPUID takes EAX/ECX as inputs, writes EAX/EBX/ECX/EDX as output +****************************************************************************/ +void cpuid (void) +{ + u32 feature = M.x86.R_EAX; + +#ifdef X86EMU_HAS_HW_CPUID + /* If the platform allows it, we will base our values on the real + * results from the CPUID instruction. We limit support to the + * first two features, and the results of those are sanitized. + */ + if (feature <= 1) + hw_cpuid(&M.x86.R_EAX, &M.x86.R_EBX, &M.x86.R_ECX, &M.x86.R_EDX); +#endif + + switch (feature) { + case 0: + /* Regardless if we have real data from the hardware, the emulator + * will only support upto feature 1, which we set in register EAX. + * Registers EBX:EDX:ECX contain a string identifying the CPU. + */ + M.x86.R_EAX = 1; +#ifndef X86EMU_HAS_HW_CPUID + /* EBX:EDX:ECX = "GenuineIntel" */ + M.x86.R_EBX = 0x756e6547; + M.x86.R_EDX = 0x49656e69; + M.x86.R_ECX = 0x6c65746e; +#endif + break; + case 1: +#ifndef X86EMU_HAS_HW_CPUID + /* If we don't have x86 compatible hardware, we return values from an + * Intel 486dx4; which was one of the first processors to have CPUID. + */ + M.x86.R_EAX = 0x00000480; + M.x86.R_EBX = 0x00000000; + M.x86.R_ECX = 0x00000000; + M.x86.R_EDX = 0x00000002; /* VME */ +#else + /* In the case that we have hardware CPUID instruction, we make sure + * that the features reported are limited to TSC and VME. + */ + M.x86.R_EDX &= 0x00000012; +#endif + break; + default: + /* Finally, we don't support any additional features. Most CPUs + * return all zeros when queried for invalid or unsupported feature + * numbers. + */ + M.x86.R_EAX = 0; + M.x86.R_EBX = 0; + M.x86.R_ECX = 0; + M.x86.R_EDX = 0; + break; + } +} + diff --git a/xorg-server/hw/xfree86/x86emu/sys.c b/xorg-server/hw/xfree86/x86emu/sys.c new file mode 100644 index 000000000..4d90ea315 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/sys.c @@ -0,0 +1,663 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: This file includes subroutines which are related to +* programmed I/O and memory access. Included in this module +* are default functions with limited usefulness. For real +* uses these functions will most likely be overriden by the +* user library. +* +****************************************************************************/ + +#include "x86emu.h" +#include "x86emu/x86emui.h" +#include "x86emu/regs.h" +#include "x86emu/debug.h" +#include "x86emu/prim_ops.h" +#ifndef NO_SYS_HEADERS +#include <string.h> +#endif +/*------------------------- Global Variables ------------------------------*/ + +X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */ +X86EMU_intrFuncs _X86EMU_intrTab[256]; + +/*----------------------------- Implementation ----------------------------*/ +#if defined(__alpha__) || defined(__alpha) +/* to cope with broken egcs-1.1.2 :-(((( */ + +#define ALPHA_UALOADS +/* + * inline functions to do unaligned accesses + * from linux/include/asm-alpha/unaligned.h + */ + +/* + * EGCS 1.1 knows about arbitrary unaligned loads. Define some + * packed structures to talk about such things with. + */ + +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) +struct __una_u64 { unsigned long x __attribute__((packed)); }; +struct __una_u32 { unsigned int x __attribute__((packed)); }; +struct __una_u16 { unsigned short x __attribute__((packed)); }; +#endif + +static __inline__ unsigned long ldq_u(unsigned long * r11) +{ +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u64 *ptr = (const struct __una_u64 *) r11; + return ptr->x; +#else + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extql %0,%2,%0\n\t" + "extqh %1,%2,%1" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(const unsigned long *)(7+(char *) r11))); + return r1 | r2; +#endif +} + +static __inline__ unsigned long ldl_u(unsigned int * r11) +{ +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u32 *ptr = (const struct __una_u32 *) r11; + return ptr->x; +#else + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extll %0,%2,%0\n\t" + "extlh %1,%2,%1" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(const unsigned long *)(3+(char *) r11))); + return r1 | r2; +#endif +} + +static __inline__ unsigned long ldw_u(unsigned short * r11) +{ +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + const struct __una_u16 *ptr = (const struct __una_u16 *) r11; + return ptr->x; +#else + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extwl %0,%2,%0\n\t" + "extwh %1,%2,%1" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(const unsigned long *)(1+(char *) r11))); + return r1 | r2; +#endif +} + +/* + * Elemental unaligned stores + */ + +static __inline__ void stq_u(unsigned long r5, unsigned long * r11) +{ +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u64 *ptr = (struct __una_u64 *) r11; + ptr->x = r5; +#else + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "insqh %6,%7,%5\n\t" + "insql %6,%7,%4\n\t" + "mskqh %3,%7,%3\n\t" + "mskql %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(7+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +#endif +} + +static __inline__ void stl_u(unsigned long r5, unsigned int * r11) +{ +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u32 *ptr = (struct __una_u32 *) r11; + ptr->x = r5; +#else + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inslh %6,%7,%5\n\t" + "insll %6,%7,%4\n\t" + "msklh %3,%7,%3\n\t" + "mskll %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(3+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +#endif +} + +static __inline__ void stw_u(unsigned long r5, unsigned short * r11) +{ +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91)) + struct __una_u16 *ptr = (struct __una_u16 *) r11; + ptr->x = r5; +#else + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inswh %6,%7,%5\n\t" + "inswl %6,%7,%4\n\t" + "mskwh %3,%7,%3\n\t" + "mskwl %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(1+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +#endif +} + +#elif defined(__GNUC__) && ((__GNUC__ < 3)) && \ + (defined (__ia64__) || defined (ia64__)) +#define IA64_UALOADS +/* + * EGCS 1.1 knows about arbitrary unaligned loads. Define some + * packed structures to talk about such things with. + */ +struct __una_u64 { unsigned long x __attribute__((packed)); }; +struct __una_u32 { unsigned int x __attribute__((packed)); }; +struct __una_u16 { unsigned short x __attribute__((packed)); }; + +static __inline__ unsigned long +__uldq (const unsigned long * r11) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *) r11; + return ptr->x; +} + +static __inline__ unsigned long +uldl (const unsigned int * r11) +{ + const struct __una_u32 *ptr = (const struct __una_u32 *) r11; + return ptr->x; +} + +static __inline__ unsigned long +uldw (const unsigned short * r11) +{ + const struct __una_u16 *ptr = (const struct __una_u16 *) r11; + return ptr->x; +} + +static __inline__ void +ustq (unsigned long r5, unsigned long * r11) +{ + struct __una_u64 *ptr = (struct __una_u64 *) r11; + ptr->x = r5; +} + +static __inline__ void +ustl (unsigned long r5, unsigned int * r11) +{ + struct __una_u32 *ptr = (struct __una_u32 *) r11; + ptr->x = r5; +} + +static __inline__ void +ustw (unsigned long r5, unsigned short * r11) +{ + struct __una_u16 *ptr = (struct __una_u16 *) r11; + ptr->x = r5; +} + +#endif + +/**************************************************************************** +PARAMETERS: +addr - Emulator memory address to read + +RETURNS: +Byte value read from emulator memory. + +REMARKS: +Reads a byte value from the emulator memory. +****************************************************************************/ +u8 X86API rdb( + u32 addr) +{ + u8 val; + + if (addr > M.mem_size - 1) { + DB(printk("mem_read: address %#lx out of range!\n", addr);) + HALT_SYS(); + } + val = *(u8*)(M.mem_base + addr); +DB( if (DEBUG_MEM_TRACE()) + printk("%#08x 1 -> %#x\n", addr, val);) + return val; +} + +/**************************************************************************** +PARAMETERS: +addr - Emulator memory address to read + +RETURNS: +Word value read from emulator memory. + +REMARKS: +Reads a word value from the emulator memory. +****************************************************************************/ +u16 X86API rdw( + u32 addr) +{ + u16 val = 0; + + if (addr > M.mem_size - 2) { + DB(printk("mem_read: address %#lx out of range!\n", addr);) + HALT_SYS(); + } +#ifdef __BIG_ENDIAN__ + if (addr & 0x1) { + val = (*(u8*)(M.mem_base + addr) | + (*(u8*)(M.mem_base + addr + 1) << 8)); + } + else +#endif +#if defined(ALPHA_UALOADS) + val = ldw_u((u16*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + val = uldw((u16*)(M.mem_base + addr)); +#else + val = *(u16*)(M.mem_base + addr); +#endif + DB( if (DEBUG_MEM_TRACE()) + printk("%#08x 2 -> %#x\n", addr, val);) + return val; +} + +/**************************************************************************** +PARAMETERS: +addr - Emulator memory address to read + +RETURNS: +Long value read from emulator memory. +REMARKS: +Reads a long value from the emulator memory. +****************************************************************************/ +u32 X86API rdl( + u32 addr) +{ + u32 val = 0; + + if (addr > M.mem_size - 4) { + DB(printk("mem_read: address %#lx out of range!\n", addr);) + HALT_SYS(); + } +#ifdef __BIG_ENDIAN__ + if (addr & 0x3) { + val = (*(u8*)(M.mem_base + addr + 0) | + (*(u8*)(M.mem_base + addr + 1) << 8) | + (*(u8*)(M.mem_base + addr + 2) << 16) | + (*(u8*)(M.mem_base + addr + 3) << 24)); + } + else +#endif +#if defined(ALPHA_UALOADS) + val = ldl_u((u32*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + val = uldl((u32*)(M.mem_base + addr)); +#else + val = *(u32*)(M.mem_base + addr); +#endif +DB( if (DEBUG_MEM_TRACE()) + printk("%#08x 4 -> %#x\n", addr, val);) + return val; +} + +/**************************************************************************** +PARAMETERS: +addr - Emulator memory address to read +val - Value to store + +REMARKS: +Writes a byte value to emulator memory. +****************************************************************************/ +void X86API wrb( + u32 addr, + u8 val) +{ +DB( if (DEBUG_MEM_TRACE()) + printk("%#08x 1 <- %#x\n", addr, val);) + if (addr > M.mem_size - 1) { + DB(printk("mem_write: address %#lx out of range!\n", addr);) + HALT_SYS(); + } + *(u8*)(M.mem_base + addr) = val; +} + +/**************************************************************************** +PARAMETERS: +addr - Emulator memory address to read +val - Value to store + +REMARKS: +Writes a word value to emulator memory. +****************************************************************************/ +void X86API wrw( + u32 addr, + u16 val) +{ +DB( if (DEBUG_MEM_TRACE()) + printk("%#08x 2 <- %#x\n", addr, val);) + if (addr > M.mem_size - 2) { + DB(printk("mem_write: address %#lx out of range!\n", addr);) + HALT_SYS(); + } +#ifdef __BIG_ENDIAN__ + if (addr & 0x1) { + *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff; + *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff; + } + else +#endif +#if defined(ALPHA_UALOADS) + stw_u(val,(u16*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + ustw(val,(u16*)(M.mem_base + addr)); +#else + *(u16*)(M.mem_base + addr) = val; +#endif +} + +/**************************************************************************** +PARAMETERS: +addr - Emulator memory address to read +val - Value to store + +REMARKS: +Writes a long value to emulator memory. +****************************************************************************/ +void X86API wrl( + u32 addr, + u32 val) +{ +DB( if (DEBUG_MEM_TRACE()) + printk("%#08x 4 <- %#x\n", addr, val);) + if (addr > M.mem_size - 4) { + DB(printk("mem_write: address %#lx out of range!\n", addr);) + HALT_SYS(); + } +#ifdef __BIG_ENDIAN__ + if (addr & 0x1) { + *(u8*)(M.mem_base + addr + 0) = (val >> 0) & 0xff; + *(u8*)(M.mem_base + addr + 1) = (val >> 8) & 0xff; + *(u8*)(M.mem_base + addr + 2) = (val >> 16) & 0xff; + *(u8*)(M.mem_base + addr + 3) = (val >> 24) & 0xff; + } + else +#endif +#if defined(ALPHA_UALOADS) + stl_u(val,(u32*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + ustl(val,(u32*)(M.mem_base + addr)); +#else + *(u32*)(M.mem_base + addr) = val; +#endif +} + +/**************************************************************************** +PARAMETERS: +addr - PIO address to read +RETURN: +0 +REMARKS: +Default PIO byte read function. Doesn't perform real inb. +****************************************************************************/ +static u8 X86API p_inb( + X86EMU_pioAddr addr) +{ +DB( if (DEBUG_IO_TRACE()) + printk("inb %#04x \n", addr);) + return 0; +} + +/**************************************************************************** +PARAMETERS: +addr - PIO address to read +RETURN: +0 +REMARKS: +Default PIO word read function. Doesn't perform real inw. +****************************************************************************/ +static u16 X86API p_inw( + X86EMU_pioAddr addr) +{ +DB( if (DEBUG_IO_TRACE()) + printk("inw %#04x \n", addr);) + return 0; +} + +/**************************************************************************** +PARAMETERS: +addr - PIO address to read +RETURN: +0 +REMARKS: +Default PIO long read function. Doesn't perform real inl. +****************************************************************************/ +static u32 X86API p_inl( + X86EMU_pioAddr addr) +{ +DB( if (DEBUG_IO_TRACE()) + printk("inl %#04x \n", addr);) + return 0; +} + +/**************************************************************************** +PARAMETERS: +addr - PIO address to write +val - Value to store +REMARKS: +Default PIO byte write function. Doesn't perform real outb. +****************************************************************************/ +static void X86API p_outb( + X86EMU_pioAddr addr, + u8 val) +{ +DB( if (DEBUG_IO_TRACE()) + printk("outb %#02x -> %#04x \n", val, addr);) + return; +} + +/**************************************************************************** +PARAMETERS: +addr - PIO address to write +val - Value to store +REMARKS: +Default PIO word write function. Doesn't perform real outw. +****************************************************************************/ +static void X86API p_outw( + X86EMU_pioAddr addr, + u16 val) +{ +DB( if (DEBUG_IO_TRACE()) + printk("outw %#04x -> %#04x \n", val, addr);) + return; +} + +/**************************************************************************** +PARAMETERS: +addr - PIO address to write +val - Value to store +REMARKS: +Default PIO ;ong write function. Doesn't perform real outl. +****************************************************************************/ +static void X86API p_outl( + X86EMU_pioAddr addr, + u32 val) +{ +DB( if (DEBUG_IO_TRACE()) + printk("outl %#08x -> %#04x \n", val, addr);) + return; +} + +/*------------------------- Global Variables ------------------------------*/ + +u8 (X86APIP sys_rdb)(u32 addr) = rdb; +u16 (X86APIP sys_rdw)(u32 addr) = rdw; +u32 (X86APIP sys_rdl)(u32 addr) = rdl; +void (X86APIP sys_wrb)(u32 addr,u8 val) = wrb; +void (X86APIP sys_wrw)(u32 addr,u16 val) = wrw; +void (X86APIP sys_wrl)(u32 addr,u32 val) = wrl; +u8 (X86APIP sys_inb)(X86EMU_pioAddr addr) = p_inb; +u16 (X86APIP sys_inw)(X86EMU_pioAddr addr) = p_inw; +u32 (X86APIP sys_inl)(X86EMU_pioAddr addr) = p_inl; +void (X86APIP sys_outb)(X86EMU_pioAddr addr, u8 val) = p_outb; +void (X86APIP sys_outw)(X86EMU_pioAddr addr, u16 val) = p_outw; +void (X86APIP sys_outl)(X86EMU_pioAddr addr, u32 val) = p_outl; + +/*----------------------------- Setup -------------------------------------*/ + +/**************************************************************************** +PARAMETERS: +funcs - New memory function pointers to make active + +REMARKS: +This function is used to set the pointers to functions which access +memory space, allowing the user application to override these functions +and hook them out as necessary for their application. +****************************************************************************/ +void X86EMU_setupMemFuncs( + X86EMU_memFuncs *funcs) +{ + sys_rdb = funcs->rdb; + sys_rdw = funcs->rdw; + sys_rdl = funcs->rdl; + sys_wrb = funcs->wrb; + sys_wrw = funcs->wrw; + sys_wrl = funcs->wrl; +} + +/**************************************************************************** +PARAMETERS: +funcs - New programmed I/O function pointers to make active + +REMARKS: +This function is used to set the pointers to functions which access +I/O space, allowing the user application to override these functions +and hook them out as necessary for their application. +****************************************************************************/ +void X86EMU_setupPioFuncs( + X86EMU_pioFuncs *funcs) +{ + sys_inb = funcs->inb; + sys_inw = funcs->inw; + sys_inl = funcs->inl; + sys_outb = funcs->outb; + sys_outw = funcs->outw; + sys_outl = funcs->outl; +} + +/**************************************************************************** +PARAMETERS: +funcs - New interrupt vector table to make active + +REMARKS: +This function is used to set the pointers to functions which handle +interrupt processing in the emulator, allowing the user application to +hook interrupts as necessary for their application. Any interrupts that +are not hooked by the user application, and reflected and handled internally +in the emulator via the interrupt vector table. This allows the application +to get control when the code being emulated executes specific software +interrupts. +****************************************************************************/ +void X86EMU_setupIntrFuncs( + X86EMU_intrFuncs funcs[]) +{ + int i; + + for (i=0; i < 256; i++) + _X86EMU_intrTab[i] = NULL; + if (funcs) { + for (i = 0; i < 256; i++) + _X86EMU_intrTab[i] = funcs[i]; + } +} + +/**************************************************************************** +PARAMETERS: +int - New software interrupt to prepare for + +REMARKS: +This function is used to set up the emulator state to exceute a software +interrupt. This can be used by the user application code to allow an +interrupt to be hooked, examined and then reflected back to the emulator +so that the code in the emulator will continue processing the software +interrupt as per normal. This essentially allows system code to actively +hook and handle certain software interrupts as necessary. +****************************************************************************/ +void X86EMU_prepareForInt( + int num) +{ + push_word((u16)M.x86.R_FLG); + CLEAR_FLAG(F_IF); + CLEAR_FLAG(F_TF); + push_word(M.x86.R_CS); + M.x86.R_CS = mem_access_word(num * 4 + 2); + push_word(M.x86.R_IP); + M.x86.R_IP = mem_access_word(num * 4); + M.x86.intr = 0; +} diff --git a/xorg-server/hw/xfree86/x86emu/validate.c b/xorg-server/hw/xfree86/x86emu/validate.c new file mode 100644 index 000000000..239f6c1f3 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/validate.c @@ -0,0 +1,765 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: Watcom C 10.6 or later +* Environment: 32-bit DOS +* Developer: Kendall Bennett +* +* Description: Program to validate the x86 emulator library for +* correctness. We run the emulator primitive operations +* functions against the real x86 CPU, and compare the result +* and flags to ensure correctness. +* +* We use inline assembler to compile and build this program. +* +****************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include "x86emu.h" +#include "x86emu/prim_asm.h" + +/*-------------------------- Implementation -------------------------------*/ + +#define true 1 +#define false 0 + +#define ALL_FLAGS (F_CF | F_PF | F_AF | F_ZF | F_SF | F_OF) + +#define VAL_START_BINARY(parm_type,res_type,dmax,smax,dincr,sincr) \ +{ \ + parm_type d,s; \ + res_type r,r_asm; \ + ulong flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < dmax; d += dincr) { \ + for (s = 0; s < smax; s += sincr) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { + +#define VAL_TEST_BINARY(name) \ + r_asm = name##_asm(&flags,d,s); \ + r = name(d,s); \ + if (r != r_asm || M.x86.R_EFLG != flags) \ + failed = true; \ + if (failed || trace) { + +#define VAL_TEST_BINARY_VOID(name) \ + name##_asm(&flags,d,s); \ + name(d,s); \ + r = r_asm = 0; \ + if (M.x86.R_EFLG != flags) \ + failed = true; \ + if (failed || trace) { + +#define VAL_FAIL_BYTE_BYTE_BINARY(name) \ + if (failed) \ + printk("fail\n"); \ + printk("0x%02X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ + r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%02X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_FAIL_WORD_WORD_BINARY(name) \ + if (failed) \ + printk("fail\n"); \ + printk("0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ + r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_FAIL_LONG_LONG_BINARY(name) \ + if (failed) \ + printk("fail\n"); \ + printk("0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ + r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_END_BINARY() \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_BYTE_BYTE_BINARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u8,u8,0xFF,0xFF,1,1) \ + VAL_TEST_BINARY(name) \ + VAL_FAIL_BYTE_BYTE_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_WORD_WORD_BINARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u16,u16,0xFF00,0xFF00,0x100,0x100) \ + VAL_TEST_BINARY(name) \ + VAL_FAIL_WORD_WORD_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_LONG_LONG_BINARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u32,u32,0xFF000000,0xFF000000,0x1000000,0x1000000) \ + VAL_TEST_BINARY(name) \ + VAL_FAIL_LONG_LONG_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_VOID_BYTE_BINARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u8,u8,0xFF,0xFF,1,1) \ + VAL_TEST_BINARY_VOID(name) \ + VAL_FAIL_BYTE_BYTE_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_VOID_WORD_BINARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u16,u16,0xFF00,0xFF00,0x100,0x100) \ + VAL_TEST_BINARY_VOID(name) \ + VAL_FAIL_WORD_WORD_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_VOID_LONG_BINARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u32,u32,0xFF000000,0xFF000000,0x1000000,0x1000000) \ + VAL_TEST_BINARY_VOID(name) \ + VAL_FAIL_LONG_LONG_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_BYTE_ROTATE(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u8,u8,0xFF,8,1,1) \ + VAL_TEST_BINARY(name) \ + VAL_FAIL_BYTE_BYTE_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_WORD_ROTATE(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u16,u16,0xFF00,16,0x100,1) \ + VAL_TEST_BINARY(name) \ + VAL_FAIL_WORD_WORD_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_LONG_ROTATE(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_BINARY(u32,u32,0xFF000000,32,0x1000000,1) \ + VAL_TEST_BINARY(name) \ + VAL_FAIL_LONG_LONG_BINARY(name) \ + VAL_END_BINARY() + +#define VAL_START_TERNARY(parm_type,res_type,dmax,smax,dincr,sincr,maxshift)\ +{ \ + parm_type d,s; \ + res_type r,r_asm; \ + u8 shift; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < dmax; d += dincr) { \ + for (s = 0; s < smax; s += sincr) { \ + for (shift = 0; shift < maxshift; shift += 1) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { + +#define VAL_TEST_TERNARY(name) \ + r_asm = name##_asm(&flags,d,s,shift); \ + r = name(d,s,shift); \ + if (r != r_asm || M.x86.R_EFLG != flags) \ + failed = true; \ + if (failed || trace) { + +#define VAL_FAIL_WORD_WORD_TERNARY(name) \ + if (failed) \ + printk("fail\n"); \ + printk("0x%04X = %-15s(0x%04X,0x%04X,%d), flags = %s -> %s\n", \ + r, #name, d, s, shift, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%04X = %-15s(0x%04X,0x%04X,%d), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, s, shift, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_FAIL_LONG_LONG_TERNARY(name) \ + if (failed) \ + printk("fail\n"); \ + printk("0x%08X = %-15s(0x%08X,0x%08X,%d), flags = %s -> %s\n", \ + r, #name, d, s, shift, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%08X = %-15s(0x%08X,0x%08X,%d), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, s, shift, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_END_TERNARY() \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_WORD_ROTATE_DBL(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_TERNARY(u16,u16,0xFF00,0xFF00,0x100,0x100,16) \ + VAL_TEST_TERNARY(name) \ + VAL_FAIL_WORD_WORD_TERNARY(name) \ + VAL_END_TERNARY() + +#define VAL_LONG_ROTATE_DBL(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_TERNARY(u32,u32,0xFF000000,0xFF000000,0x1000000,0x1000000,32) \ + VAL_TEST_TERNARY(name) \ + VAL_FAIL_LONG_LONG_TERNARY(name) \ + VAL_END_TERNARY() + +#define VAL_START_UNARY(parm_type,max,incr) \ +{ \ + parm_type d,r,r_asm; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < max; d += incr) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { + +#define VAL_TEST_UNARY(name) \ + r_asm = name##_asm(&flags,d); \ + r = name(d); \ + if (r != r_asm || M.x86.R_EFLG != flags) { \ + failed = true; + +#define VAL_FAIL_BYTE_UNARY(name) \ + printk("fail\n"); \ + printk("0x%02X = %-15s(0x%02X), flags = %s -> %s\n", \ + r, #name, d, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%02X = %-15s(0x%02X), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_FAIL_WORD_UNARY(name) \ + printk("fail\n"); \ + printk("0x%04X = %-15s(0x%04X), flags = %s -> %s\n", \ + r, #name, d, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%04X = %-15s(0x%04X), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_FAIL_LONG_UNARY(name) \ + printk("fail\n"); \ + printk("0x%08X = %-15s(0x%08X), flags = %s -> %s\n", \ + r, #name, d, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%08X = %-15s(0x%08X), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, print_flags(buf1,inflags), print_flags(buf2,flags)); + +#define VAL_END_UNARY() \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | ALL_FLAGS; \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_BYTE_UNARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_UNARY(u8,0xFF,0x1) \ + VAL_TEST_UNARY(name) \ + VAL_FAIL_BYTE_UNARY(name) \ + VAL_END_UNARY() + +#define VAL_WORD_UNARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_UNARY(u16,0xFF00,0x100) \ + VAL_TEST_UNARY(name) \ + VAL_FAIL_WORD_UNARY(name) \ + VAL_END_UNARY() + +#define VAL_WORD_BYTE_UNARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_UNARY(u16,0xFF,0x1) \ + VAL_TEST_UNARY(name) \ + VAL_FAIL_WORD_UNARY(name) \ + VAL_END_UNARY() + +#define VAL_LONG_UNARY(name) \ + printk("Validating %s ... ", #name); \ + VAL_START_UNARY(u32,0xFF000000,0x1000000) \ + VAL_TEST_UNARY(name) \ + VAL_FAIL_LONG_UNARY(name) \ + VAL_END_UNARY() + +#define VAL_BYTE_MUL(name) \ + printk("Validating %s ... ", #name); \ +{ \ + u8 d,s; \ + u16 r,r_asm; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < 0xFF; d += 1) { \ + for (s = 0; s < 0xFF; s += 1) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { \ + name##_asm(&flags,&r_asm,d,s); \ + M.x86.R_AL = d; \ + name(s); \ + r = M.x86.R_AX; \ + if (r != r_asm || M.x86.R_EFLG != flags) \ + failed = true; \ + if (failed || trace) { \ + if (failed) \ + printk("fail\n"); \ + printk("0x%04X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ + r, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%04X = %-15s(0x%02X,0x%02X), flags = %s -> %s\n", \ + r_asm, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_WORD_MUL(name) \ + printk("Validating %s ... ", #name); \ +{ \ + u16 d,s; \ + u16 r_lo,r_asm_lo; \ + u16 r_hi,r_asm_hi; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < 0xFF00; d += 0x100) { \ + for (s = 0; s < 0xFF00; s += 0x100) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { \ + name##_asm(&flags,&r_asm_lo,&r_asm_hi,d,s); \ + M.x86.R_AX = d; \ + name(s); \ + r_lo = M.x86.R_AX; \ + r_hi = M.x86.R_DX; \ + if (r_lo != r_asm_lo || r_hi != r_asm_hi || M.x86.R_EFLG != flags)\ + failed = true; \ + if (failed || trace) { \ + if (failed) \ + printk("fail\n"); \ + printk("0x%04X:0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ + r_hi,r_lo, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%04X:0x%04X = %-15s(0x%04X,0x%04X), flags = %s -> %s\n", \ + r_asm_hi,r_asm_lo, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_LONG_MUL(name) \ + printk("Validating %s ... ", #name); \ +{ \ + u32 d,s; \ + u32 r_lo,r_asm_lo; \ + u32 r_hi,r_asm_hi; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < 0xFF000000; d += 0x1000000) { \ + for (s = 0; s < 0xFF000000; s += 0x1000000) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { \ + name##_asm(&flags,&r_asm_lo,&r_asm_hi,d,s); \ + M.x86.R_EAX = d; \ + name(s); \ + r_lo = M.x86.R_EAX; \ + r_hi = M.x86.R_EDX; \ + if (r_lo != r_asm_lo || r_hi != r_asm_hi || M.x86.R_EFLG != flags)\ + failed = true; \ + if (failed || trace) { \ + if (failed) \ + printk("fail\n"); \ + printk("0x%08X:0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ + r_hi,r_lo, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%08X:0x%08X = %-15s(0x%08X,0x%08X), flags = %s -> %s\n", \ + r_asm_hi,r_asm_lo, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_BYTE_DIV(name) \ + printk("Validating %s ... ", #name); \ +{ \ + u16 d,s; \ + u8 r_quot,r_rem,r_asm_quot,r_asm_rem; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < 0xFF00; d += 0x100) { \ + for (s = 1; s < 0xFF; s += 1) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { \ + M.x86.intr = 0; \ + M.x86.R_AX = d; \ + name(s); \ + r_quot = M.x86.R_AL; \ + r_rem = M.x86.R_AH; \ + if (M.x86.intr & INTR_SYNCH) \ + continue; \ + name##_asm(&flags,&r_asm_quot,&r_asm_rem,d,s); \ + if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \ + failed = true; \ + if (failed || trace) { \ + if (failed) \ + printk("fail\n"); \ + printk("0x%02X:0x%02X = %-15s(0x%04X,0x%02X), flags = %s -> %s\n", \ + r_quot, r_rem, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%02X:0x%02X = %-15s(0x%04X,0x%02X), flags = %s -> %s\n", \ + r_asm_quot, r_asm_rem, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_WORD_DIV(name) \ + printk("Validating %s ... ", #name); \ +{ \ + u32 d,s; \ + u16 r_quot,r_rem,r_asm_quot,r_asm_rem; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < 0xFF000000; d += 0x1000000) { \ + for (s = 0x100; s < 0xFF00; s += 0x100) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { \ + M.x86.intr = 0; \ + M.x86.R_AX = d & 0xFFFF; \ + M.x86.R_DX = d >> 16; \ + name(s); \ + r_quot = M.x86.R_AX; \ + r_rem = M.x86.R_DX; \ + if (M.x86.intr & INTR_SYNCH) \ + continue; \ + name##_asm(&flags,&r_asm_quot,&r_asm_rem,d & 0xFFFF,d >> 16,s);\ + if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \ + failed = true; \ + if (failed || trace) { \ + if (failed) \ + printk("fail\n"); \ + printk("0x%04X:0x%04X = %-15s(0x%08X,0x%04X), flags = %s -> %s\n", \ + r_quot, r_rem, #name, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%04X:0x%04X = %-15s(0x%08X,0x%04X), flags = %s -> %s\n", \ + r_asm_quot, r_asm_rem, #name"_asm", d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +#define VAL_LONG_DIV(name) \ + printk("Validating %s ... ", #name); \ +{ \ + u32 d,s; \ + u32 r_quot,r_rem,r_asm_quot,r_asm_rem; \ + u32 flags,inflags; \ + int f,failed = false; \ + char buf1[80],buf2[80]; \ + for (d = 0; d < 0xFF000000; d += 0x1000000) { \ + for (s = 0x100; s < 0xFF00; s += 0x100) { \ + M.x86.R_EFLG = inflags = flags = def_flags; \ + for (f = 0; f < 2; f++) { \ + M.x86.intr = 0; \ + M.x86.R_EAX = d; \ + M.x86.R_EDX = 0; \ + name(s); \ + r_quot = M.x86.R_EAX; \ + r_rem = M.x86.R_EDX; \ + if (M.x86.intr & INTR_SYNCH) \ + continue; \ + name##_asm(&flags,&r_asm_quot,&r_asm_rem,d,0,s); \ + if (r_quot != r_asm_quot || r_rem != r_asm_rem || M.x86.R_EFLG != flags) \ + failed = true; \ + if (failed || trace) { \ + if (failed) \ + printk("fail\n"); \ + printk("0x%08X:0x%08X = %-15s(0x%08X:0x%08X,0x%08X), flags = %s -> %s\n", \ + r_quot, r_rem, #name, 0, d, s, print_flags(buf1,inflags), print_flags(buf2,M.x86.R_EFLG)); \ + printk("0x%08X:0x%08X = %-15s(0x%08X:0x%08X,0x%08X), flags = %s -> %s\n", \ + r_asm_quot, r_asm_rem, #name"_asm", 0, d, s, print_flags(buf1,inflags), print_flags(buf2,flags)); \ + } \ + M.x86.R_EFLG = inflags = flags = def_flags | (ALL_FLAGS & ~F_OF); \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (failed) \ + break; \ + } \ + if (!failed) \ + printk("passed\n"); \ +} + +void printk(const char *fmt, ...) +{ + va_list argptr; + va_start(argptr, fmt); + vfprintf(stdout, fmt, argptr); + fflush(stdout); + va_end(argptr); +} + +char * print_flags(char *buf,ulong flags) +{ + char *separator = ""; + + buf[0] = 0; + if (flags & F_CF) { + strcat(buf,separator); + strcat(buf,"CF"); + separator = ","; + } + if (flags & F_PF) { + strcat(buf,separator); + strcat(buf,"PF"); + separator = ","; + } + if (flags & F_AF) { + strcat(buf,separator); + strcat(buf,"AF"); + separator = ","; + } + if (flags & F_ZF) { + strcat(buf,separator); + strcat(buf,"ZF"); + separator = ","; + } + if (flags & F_SF) { + strcat(buf,separator); + strcat(buf,"SF"); + separator = ","; + } + if (flags & F_OF) { + strcat(buf,separator); + strcat(buf,"OF"); + separator = ","; + } + if (separator[0] == 0) + strcpy(buf,"None"); + return buf; +} + +int main(int argc) +{ + ulong def_flags; + int trace = false; + + if (argc > 1) + trace = true; + memset(&M, 0, sizeof(M)); + def_flags = get_flags_asm() & ~ALL_FLAGS; + + VAL_WORD_UNARY(aaa_word); + VAL_WORD_UNARY(aas_word); + + VAL_WORD_UNARY(aad_word); + VAL_WORD_UNARY(aam_word); + + VAL_BYTE_BYTE_BINARY(adc_byte); + VAL_WORD_WORD_BINARY(adc_word); + VAL_LONG_LONG_BINARY(adc_long); + + VAL_BYTE_BYTE_BINARY(add_byte); + VAL_WORD_WORD_BINARY(add_word); + VAL_LONG_LONG_BINARY(add_long); + + VAL_BYTE_BYTE_BINARY(and_byte); + VAL_WORD_WORD_BINARY(and_word); + VAL_LONG_LONG_BINARY(and_long); + + VAL_BYTE_BYTE_BINARY(cmp_byte); + VAL_WORD_WORD_BINARY(cmp_word); + VAL_LONG_LONG_BINARY(cmp_long); + + VAL_BYTE_UNARY(daa_byte); + VAL_BYTE_UNARY(das_byte); // Fails for 0x9A (out of range anyway) + + VAL_BYTE_UNARY(dec_byte); + VAL_WORD_UNARY(dec_word); + VAL_LONG_UNARY(dec_long); + + VAL_BYTE_UNARY(inc_byte); + VAL_WORD_UNARY(inc_word); + VAL_LONG_UNARY(inc_long); + + VAL_BYTE_BYTE_BINARY(or_byte); + VAL_WORD_WORD_BINARY(or_word); + VAL_LONG_LONG_BINARY(or_long); + + VAL_BYTE_UNARY(neg_byte); + VAL_WORD_UNARY(neg_word); + VAL_LONG_UNARY(neg_long); + + VAL_BYTE_UNARY(not_byte); + VAL_WORD_UNARY(not_word); + VAL_LONG_UNARY(not_long); + + VAL_BYTE_ROTATE(rcl_byte); + VAL_WORD_ROTATE(rcl_word); + VAL_LONG_ROTATE(rcl_long); + + VAL_BYTE_ROTATE(rcr_byte); + VAL_WORD_ROTATE(rcr_word); + VAL_LONG_ROTATE(rcr_long); + + VAL_BYTE_ROTATE(rol_byte); + VAL_WORD_ROTATE(rol_word); + VAL_LONG_ROTATE(rol_long); + + VAL_BYTE_ROTATE(ror_byte); + VAL_WORD_ROTATE(ror_word); + VAL_LONG_ROTATE(ror_long); + + VAL_BYTE_ROTATE(shl_byte); + VAL_WORD_ROTATE(shl_word); + VAL_LONG_ROTATE(shl_long); + + VAL_BYTE_ROTATE(shr_byte); + VAL_WORD_ROTATE(shr_word); + VAL_LONG_ROTATE(shr_long); + + VAL_BYTE_ROTATE(sar_byte); + VAL_WORD_ROTATE(sar_word); + VAL_LONG_ROTATE(sar_long); + + VAL_WORD_ROTATE_DBL(shld_word); + VAL_LONG_ROTATE_DBL(shld_long); + + VAL_WORD_ROTATE_DBL(shrd_word); + VAL_LONG_ROTATE_DBL(shrd_long); + + VAL_BYTE_BYTE_BINARY(sbb_byte); + VAL_WORD_WORD_BINARY(sbb_word); + VAL_LONG_LONG_BINARY(sbb_long); + + VAL_BYTE_BYTE_BINARY(sub_byte); + VAL_WORD_WORD_BINARY(sub_word); + VAL_LONG_LONG_BINARY(sub_long); + + VAL_BYTE_BYTE_BINARY(xor_byte); + VAL_WORD_WORD_BINARY(xor_word); + VAL_LONG_LONG_BINARY(xor_long); + + VAL_VOID_BYTE_BINARY(test_byte); + VAL_VOID_WORD_BINARY(test_word); + VAL_VOID_LONG_BINARY(test_long); + + VAL_BYTE_MUL(imul_byte); + VAL_WORD_MUL(imul_word); + VAL_LONG_MUL(imul_long); + + VAL_BYTE_MUL(mul_byte); + VAL_WORD_MUL(mul_word); + VAL_LONG_MUL(mul_long); + + VAL_BYTE_DIV(idiv_byte); + VAL_WORD_DIV(idiv_word); + VAL_LONG_DIV(idiv_long); + + VAL_BYTE_DIV(div_byte); + VAL_WORD_DIV(div_word); + VAL_LONG_DIV(div_long); + + return 0; +} diff --git a/xorg-server/hw/xfree86/x86emu/x86emu.h b/xorg-server/hw/xfree86/x86emu/x86emu.h new file mode 100644 index 000000000..795e2d688 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu.h @@ -0,0 +1,198 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for public specific functions. +* Any application linking against us should only +* include this header +* +****************************************************************************/ + +#ifndef __X86EMU_X86EMU_H +#define __X86EMU_X86EMU_H + +#ifdef SCITECH +#include "scitech.h" +#define X86API _ASMAPI +#define X86APIP _ASMAPIP +typedef int X86EMU_pioAddr; +#else +#include "x86emu/types.h" +#define X86API +#define X86APIP * +#endif +#include "x86emu/regs.h" + +/*---------------------- Macros and type definitions ----------------------*/ + +#ifdef PACK +# pragma PACK /* Don't pack structs with function pointers! */ +#endif + +/**************************************************************************** +REMARKS: +Data structure containing ponters to programmed I/O functions used by the +emulator. This is used so that the user program can hook all programmed +I/O for the emulator to handled as necessary by the user program. By +default the emulator contains simple functions that do not do access the +hardware in any way. To allow the emualtor access the hardware, you will +need to override the programmed I/O functions using the X86EMU_setupPioFuncs +function. + +HEADER: +x86emu.h + +MEMBERS: +inb - Function to read a byte from an I/O port +inw - Function to read a word from an I/O port +inl - Function to read a dword from an I/O port +outb - Function to write a byte to an I/O port +outw - Function to write a word to an I/O port +outl - Function to write a dword to an I/O port +****************************************************************************/ +typedef struct { + u8 (X86APIP inb)(X86EMU_pioAddr addr); + u16 (X86APIP inw)(X86EMU_pioAddr addr); + u32 (X86APIP inl)(X86EMU_pioAddr addr); + void (X86APIP outb)(X86EMU_pioAddr addr, u8 val); + void (X86APIP outw)(X86EMU_pioAddr addr, u16 val); + void (X86APIP outl)(X86EMU_pioAddr addr, u32 val); + } X86EMU_pioFuncs; + +/**************************************************************************** +REMARKS: +Data structure containing ponters to memory access functions used by the +emulator. This is used so that the user program can hook all memory +access functions as necessary for the emulator. By default the emulator +contains simple functions that only access the internal memory of the +emulator. If you need specialised functions to handle access to different +types of memory (ie: hardware framebuffer accesses and BIOS memory access +etc), you will need to override this using the X86EMU_setupMemFuncs +function. + +HEADER: +x86emu.h + +MEMBERS: +rdb - Function to read a byte from an address +rdw - Function to read a word from an address +rdl - Function to read a dword from an address +wrb - Function to write a byte to an address +wrw - Function to write a word to an address +wrl - Function to write a dword to an address +****************************************************************************/ +typedef struct { + u8 (X86APIP rdb)(u32 addr); + u16 (X86APIP rdw)(u32 addr); + u32 (X86APIP rdl)(u32 addr); + void (X86APIP wrb)(u32 addr, u8 val); + void (X86APIP wrw)(u32 addr, u16 val); + void (X86APIP wrl)(u32 addr, u32 val); + } X86EMU_memFuncs; + +/**************************************************************************** + Here are the default memory read and write + function in case they are needed as fallbacks. +***************************************************************************/ +extern u8 X86API rdb(u32 addr); +extern u16 X86API rdw(u32 addr); +extern u32 X86API rdl(u32 addr); +extern void X86API wrb(u32 addr, u8 val); +extern void X86API wrw(u32 addr, u16 val); +extern void X86API wrl(u32 addr, u32 val); + +#ifdef END_PACK +# pragma END_PACK +#endif + +/*--------------------- type definitions -----------------------------------*/ + +typedef void (X86APIP X86EMU_intrFuncs)(int num); +extern X86EMU_intrFuncs _X86EMU_intrTab[256]; + +/*-------------------------- Function Prototypes --------------------------*/ + +#ifdef __cplusplus +extern "C" { /* Use "C" linkage when in C++ mode */ +#endif + +void X86EMU_setupMemFuncs(X86EMU_memFuncs *funcs); +void X86EMU_setupPioFuncs(X86EMU_pioFuncs *funcs); +void X86EMU_setupIntrFuncs(X86EMU_intrFuncs funcs[]); +void X86EMU_prepareForInt(int num); + +/* decode.c */ + +void X86EMU_exec(void); +void X86EMU_halt_sys(void); + +#ifdef DEBUG +#define HALT_SYS() \ + printk("halt_sys: file %s, line %d\n", __FILE__, __LINE__), \ + X86EMU_halt_sys() +#else +#define HALT_SYS() X86EMU_halt_sys() +#endif + +/* Debug options */ + +#define DEBUG_DECODE_F 0x000001 /* print decoded instruction */ +#define DEBUG_TRACE_F 0x000002 /* dump regs before/after execution */ +#define DEBUG_STEP_F 0x000004 +#define DEBUG_DISASSEMBLE_F 0x000008 +#define DEBUG_BREAK_F 0x000010 +#define DEBUG_SVC_F 0x000020 +#define DEBUG_SAVE_IP_CS_F 0x000040 +#define DEBUG_FS_F 0x000080 +#define DEBUG_PROC_F 0x000100 +#define DEBUG_SYSINT_F 0x000200 /* bios system interrupts. */ +#define DEBUG_TRACECALL_F 0x000400 +#define DEBUG_INSTRUMENT_F 0x000800 +#define DEBUG_MEM_TRACE_F 0x001000 +#define DEBUG_IO_TRACE_F 0x002000 +#define DEBUG_TRACECALL_REGS_F 0x004000 +#define DEBUG_DECODE_NOPRINT_F 0x008000 +#define DEBUG_EXIT 0x010000 +#define DEBUG_SYS_F (DEBUG_SVC_F|DEBUG_FS_F|DEBUG_PROC_F) + +void X86EMU_trace_regs(void); +void X86EMU_trace_xregs(void); +void X86EMU_dump_memory(u16 seg, u16 off, u32 amt); +int X86EMU_trace_on(void); +int X86EMU_trace_off(void); + +#ifdef __cplusplus +} /* End of "C" linkage for C++ */ +#endif + +#endif /* __X86EMU_X86EMU_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/debug.h b/xorg-server/hw/xfree86/x86emu/x86emu/debug.h new file mode 100644 index 000000000..47aacb6c3 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/debug.h @@ -0,0 +1,210 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for debug definitions. +* +****************************************************************************/ + +#ifndef __X86EMU_DEBUG_H +#define __X86EMU_DEBUG_H + +/*---------------------- Macros and type definitions ----------------------*/ + +/* checks to be enabled for "runtime" */ + +#define CHECK_IP_FETCH_F 0x1 +#define CHECK_SP_ACCESS_F 0x2 +#define CHECK_MEM_ACCESS_F 0x4 /*using regular linear pointer */ +#define CHECK_DATA_ACCESS_F 0x8 /*using segment:offset*/ + +#ifdef DEBUG +# define CHECK_IP_FETCH() (M.x86.check & CHECK_IP_FETCH_F) +# define CHECK_SP_ACCESS() (M.x86.check & CHECK_SP_ACCESS_F) +# define CHECK_MEM_ACCESS() (M.x86.check & CHECK_MEM_ACCESS_F) +# define CHECK_DATA_ACCESS() (M.x86.check & CHECK_DATA_ACCESS_F) +#else +# define CHECK_IP_FETCH() +# define CHECK_SP_ACCESS() +# define CHECK_MEM_ACCESS() +# define CHECK_DATA_ACCESS() +#endif + +#ifdef DEBUG +# define DEBUG_INSTRUMENT() (M.x86.debug & DEBUG_INSTRUMENT_F) +# define DEBUG_DECODE() (M.x86.debug & DEBUG_DECODE_F) +# define DEBUG_TRACE() (M.x86.debug & DEBUG_TRACE_F) +# define DEBUG_STEP() (M.x86.debug & DEBUG_STEP_F) +# define DEBUG_DISASSEMBLE() (M.x86.debug & DEBUG_DISASSEMBLE_F) +# define DEBUG_BREAK() (M.x86.debug & DEBUG_BREAK_F) +# define DEBUG_SVC() (M.x86.debug & DEBUG_SVC_F) +# define DEBUG_SAVE_IP_CS() (M.x86.debug & DEBUG_SAVE_IP_CS_F) + +# define DEBUG_FS() (M.x86.debug & DEBUG_FS_F) +# define DEBUG_PROC() (M.x86.debug & DEBUG_PROC_F) +# define DEBUG_SYSINT() (M.x86.debug & DEBUG_SYSINT_F) +# define DEBUG_TRACECALL() (M.x86.debug & DEBUG_TRACECALL_F) +# define DEBUG_TRACECALLREGS() (M.x86.debug & DEBUG_TRACECALL_REGS_F) +# define DEBUG_SYS() (M.x86.debug & DEBUG_SYS_F) +# define DEBUG_MEM_TRACE() (M.x86.debug & DEBUG_MEM_TRACE_F) +# define DEBUG_IO_TRACE() (M.x86.debug & DEBUG_IO_TRACE_F) +# define DEBUG_DECODE_NOPRINT() (M.x86.debug & DEBUG_DECODE_NOPRINT_F) +#else +# define DEBUG_INSTRUMENT() 0 +# define DEBUG_DECODE() 0 +# define DEBUG_TRACE() 0 +# define DEBUG_STEP() 0 +# define DEBUG_DISASSEMBLE() 0 +# define DEBUG_BREAK() 0 +# define DEBUG_SVC() 0 +# define DEBUG_SAVE_IP_CS() 0 +# define DEBUG_FS() 0 +# define DEBUG_PROC() 0 +# define DEBUG_SYSINT() 0 +# define DEBUG_TRACECALL() 0 +# define DEBUG_TRACECALLREGS() 0 +# define DEBUG_SYS() 0 +# define DEBUG_MEM_TRACE() 0 +# define DEBUG_IO_TRACE() 0 +# define DEBUG_DECODE_NOPRINT() 0 +#endif + +#ifdef DEBUG + +# define DECODE_PRINTF(x) if (DEBUG_DECODE()) \ + x86emu_decode_printf(x) +# define DECODE_PRINTF2(x,y) if (DEBUG_DECODE()) \ + x86emu_decode_printf2(x,y) + +/* + * The following allow us to look at the bytes of an instruction. The + * first INCR_INSTRN_LEN, is called everytime bytes are consumed in + * the decoding process. The SAVE_IP_CS is called initially when the + * major opcode of the instruction is accessed. + */ +#define INC_DECODED_INST_LEN(x) \ + if (DEBUG_DECODE()) \ + x86emu_inc_decoded_inst_len(x) + +#define SAVE_IP_CS(x,y) \ + if (DEBUG_DECODE() | DEBUG_TRACECALL() | DEBUG_BREAK() \ + | DEBUG_IO_TRACE() | DEBUG_SAVE_IP_CS()) { \ + M.x86.saved_cs = x; \ + M.x86.saved_ip = y; \ + } +#else +# define INC_DECODED_INST_LEN(x) +# define DECODE_PRINTF(x) +# define DECODE_PRINTF2(x,y) +# define SAVE_IP_CS(x,y) +#endif + +#ifdef DEBUG +#define TRACE_REGS() \ + if (DEBUG_DISASSEMBLE()) { \ + x86emu_just_disassemble(); \ + goto EndOfTheInstructionProcedure; \ + } \ + if (DEBUG_TRACE() || DEBUG_DECODE()) X86EMU_trace_regs() +#else +# define TRACE_REGS() +#endif + +#ifdef DEBUG +# define SINGLE_STEP() if (DEBUG_STEP()) x86emu_single_step() +#else +# define SINGLE_STEP() +#endif + +#define TRACE_AND_STEP() \ + TRACE_REGS(); \ + SINGLE_STEP() + +#ifdef DEBUG +# define START_OF_INSTR() +# define END_OF_INSTR() EndOfTheInstructionProcedure: x86emu_end_instr(); +# define END_OF_INSTR_NO_TRACE() x86emu_end_instr(); +#else +# define START_OF_INSTR() +# define END_OF_INSTR() +# define END_OF_INSTR_NO_TRACE() +#endif + +#ifdef DEBUG +# define CALL_TRACE(u,v,w,x,s) \ + if (DEBUG_TRACECALLREGS()) \ + x86emu_dump_regs(); \ + if (DEBUG_TRACECALL()) \ + printk("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x); +# define RETURN_TRACE(n,u,v) \ + if (DEBUG_TRACECALLREGS()) \ + x86emu_dump_regs(); \ + if (DEBUG_TRACECALL()) \ + printk("%04x:%04x: %s\n",u,v,n); +#else +# define CALL_TRACE(u,v,w,x,s) +# define RETURN_TRACE(n,u,v) +#endif + +#ifdef DEBUG +#define DB(x) x +#else +#define DB(x) +#endif + +/*-------------------------- Function Prototypes --------------------------*/ + +#ifdef __cplusplus +extern "C" { /* Use "C" linkage when in C++ mode */ +#endif + +extern void x86emu_inc_decoded_inst_len (int x); +extern void x86emu_decode_printf (char *x); +extern void x86emu_decode_printf2 (char *x, int y); +extern void x86emu_just_disassemble (void); +extern void x86emu_single_step (void); +extern void x86emu_end_instr (void); +extern void x86emu_dump_regs (void); +extern void x86emu_dump_xregs (void); +extern void x86emu_print_int_vect (u16 iv); +extern void x86emu_instrument_instruction (void); +extern void x86emu_check_ip_access (void); +extern void x86emu_check_sp_access (void); +extern void x86emu_check_mem_access (u32 p); +extern void x86emu_check_data_access (uint s, uint o); + +#ifdef __cplusplus +} /* End of "C" linkage for C++ */ +#endif + +#endif /* __X86EMU_DEBUG_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/decode.h b/xorg-server/hw/xfree86/x86emu/x86emu/decode.h new file mode 100644 index 000000000..61cd4dc10 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/decode.h @@ -0,0 +1,88 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for instruction decoding logic. +* +****************************************************************************/ + +#ifndef __X86EMU_DECODE_H +#define __X86EMU_DECODE_H + +/*---------------------- Macros and type definitions ----------------------*/ + +/* Instruction Decoding Stuff */ + +#define FETCH_DECODE_MODRM(mod,rh,rl) fetch_decode_modrm(&mod,&rh,&rl) +#define DECODE_RM_BYTE_REGISTER(r) decode_rm_byte_register(r) +#define DECODE_RM_WORD_REGISTER(r) decode_rm_word_register(r) +#define DECODE_RM_LONG_REGISTER(r) decode_rm_long_register(r) +#define DECODE_CLEAR_SEGOVR() M.x86.mode &= ~SYSMODE_CLRMASK + +/*-------------------------- Function Prototypes --------------------------*/ + +#ifdef __cplusplus +extern "C" { /* Use "C" linkage when in C++ mode */ +#endif + +void x86emu_intr_raise (u8 type); +void fetch_decode_modrm (int *mod,int *regh,int *regl); +u8 fetch_byte_imm (void); +u16 fetch_word_imm (void); +u32 fetch_long_imm (void); +u8 fetch_data_byte (uint offset); +u8 fetch_data_byte_abs (uint segment, uint offset); +u16 fetch_data_word (uint offset); +u16 fetch_data_word_abs (uint segment, uint offset); +u32 fetch_data_long (uint offset); +u32 fetch_data_long_abs (uint segment, uint offset); +void store_data_byte (uint offset, u8 val); +void store_data_byte_abs (uint segment, uint offset, u8 val); +void store_data_word (uint offset, u16 val); +void store_data_word_abs (uint segment, uint offset, u16 val); +void store_data_long (uint offset, u32 val); +void store_data_long_abs (uint segment, uint offset, u32 val); +u8* decode_rm_byte_register(int reg); +u16* decode_rm_word_register(int reg); +u32* decode_rm_long_register(int reg); +u16* decode_rm_seg_register(int reg); +u32 decode_rm00_address(int rm); +u32 decode_rm01_address(int rm); +u32 decode_rm10_address(int rm); +u32 decode_sib_address(int sib, int mod); + +#ifdef __cplusplus +} /* End of "C" linkage for C++ */ +#endif + +#endif /* __X86EMU_DECODE_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/fpu.h b/xorg-server/hw/xfree86/x86emu/x86emu/fpu.h new file mode 100644 index 000000000..5fb271463 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/fpu.h @@ -0,0 +1,61 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for FPU instruction decoding. +* +****************************************************************************/ + +#ifndef __X86EMU_FPU_H +#define __X86EMU_FPU_H + +#ifdef __cplusplus +extern "C" { /* Use "C" linkage when in C++ mode */ +#endif + +/* these have to be defined, whether 8087 support compiled in or not. */ + +extern void x86emuOp_esc_coprocess_d8 (u8 op1); +extern void x86emuOp_esc_coprocess_d9 (u8 op1); +extern void x86emuOp_esc_coprocess_da (u8 op1); +extern void x86emuOp_esc_coprocess_db (u8 op1); +extern void x86emuOp_esc_coprocess_dc (u8 op1); +extern void x86emuOp_esc_coprocess_dd (u8 op1); +extern void x86emuOp_esc_coprocess_de (u8 op1); +extern void x86emuOp_esc_coprocess_df (u8 op1); + +#ifdef __cplusplus +} /* End of "C" linkage for C++ */ +#endif + +#endif /* __X86EMU_FPU_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/fpu_regs.h b/xorg-server/hw/xfree86/x86emu/x86emu/fpu_regs.h new file mode 100644 index 000000000..e59b80783 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/fpu_regs.h @@ -0,0 +1,119 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for FPU register definitions. +* +****************************************************************************/ + +#ifndef __X86EMU_FPU_REGS_H +#define __X86EMU_FPU_REGS_H + +#ifdef X86_FPU_SUPPORT + +#ifdef PACK +# pragma PACK +#endif + +/* Basic 8087 register can hold any of the following values: */ + +union x86_fpu_reg_u { + s8 tenbytes[10]; + double dval; + float fval; + s16 sval; + s32 lval; + }; + +struct x86_fpu_reg { + union x86_fpu_reg_u reg; + char tag; + }; + +/* + * Since we are not going to worry about the problems of aliasing + * registers, every time a register is modified, its result type is + * set in the tag fields for that register. If some operation + * attempts to access the type in a way inconsistent with its current + * storage format, then we flag the operation. If common, we'll + * attempt the conversion. + */ + +#define X86_FPU_VALID 0x80 +#define X86_FPU_REGTYP(r) ((r) & 0x7F) + +#define X86_FPU_WORD 0x0 +#define X86_FPU_SHORT 0x1 +#define X86_FPU_LONG 0x2 +#define X86_FPU_FLOAT 0x3 +#define X86_FPU_DOUBLE 0x4 +#define X86_FPU_LDBL 0x5 +#define X86_FPU_BSD 0x6 + +#define X86_FPU_STKTOP 0 + +struct x86_fpu_registers { + struct x86_fpu_reg x86_fpu_stack[8]; + int x86_fpu_flags; + int x86_fpu_config; /* rounding modes, etc. */ + short x86_fpu_tos, x86_fpu_bos; + }; + +#ifdef END_PACK +# pragma END_PACK +#endif + +/* + * There are two versions of the following macro. + * + * One version is for opcode D9, for which there are more than 32 + * instructions encoded in the second byte of the opcode. + * + * The other version, deals with all the other 7 i87 opcodes, for + * which there are only 32 strings needed to describe the + * instructions. + */ + +#endif /* X86_FPU_SUPPORT */ + +#ifdef DEBUG +# define DECODE_PRINTINSTR32(t,mod,rh,rl) \ + DECODE_PRINTF(t[(mod<<3)+(rh)]); +# define DECODE_PRINTINSTR256(t,mod,rh,rl) \ + DECODE_PRINTF(t[(mod<<6)+(rh<<3)+(rl)]); +#else +# define DECODE_PRINTINSTR32(t,mod,rh,rl) +# define DECODE_PRINTINSTR256(t,mod,rh,rl) +#endif + +#endif /* __X86EMU_FPU_REGS_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/ops.h b/xorg-server/hw/xfree86/x86emu/x86emu/ops.h new file mode 100644 index 000000000..65ea67654 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/ops.h @@ -0,0 +1,45 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for operand decoding functions. +* +****************************************************************************/ + +#ifndef __X86EMU_OPS_H +#define __X86EMU_OPS_H + +extern void (*x86emu_optab[0x100])(u8 op1); +extern void (*x86emu_optab2[0x100])(u8 op2); + +#endif /* __X86EMU_OPS_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/prim_asm.h b/xorg-server/hw/xfree86/x86emu/x86emu/prim_asm.h new file mode 100644 index 000000000..e023cf88d --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/prim_asm.h @@ -0,0 +1,970 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: Watcom C++ 10.6 or later +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Inline assembler versions of the primitive operand +* functions for faster performance. At the moment this is +* x86 inline assembler, but these functions could be replaced +* with native inline assembler for each supported processor +* platform. +* +****************************************************************************/ + +#ifndef __X86EMU_PRIM_ASM_H +#define __X86EMU_PRIM_ASM_H + +#ifdef __WATCOMC__ + +#ifndef VALIDATE +#define __HAVE_INLINE_ASSEMBLER__ +#endif + +u32 get_flags_asm(void); +#pragma aux get_flags_asm = \ + "pushf" \ + "pop eax" \ + value [eax] \ + modify exact [eax]; + +u16 aaa_word_asm(u32 *flags,u16 d); +#pragma aux aaa_word_asm = \ + "push [edi]" \ + "popf" \ + "aaa" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] \ + value [ax] \ + modify exact [ax]; + +u16 aas_word_asm(u32 *flags,u16 d); +#pragma aux aas_word_asm = \ + "push [edi]" \ + "popf" \ + "aas" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] \ + value [ax] \ + modify exact [ax]; + +u16 aad_word_asm(u32 *flags,u16 d); +#pragma aux aad_word_asm = \ + "push [edi]" \ + "popf" \ + "aad" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] \ + value [ax] \ + modify exact [ax]; + +u16 aam_word_asm(u32 *flags,u8 d); +#pragma aux aam_word_asm = \ + "push [edi]" \ + "popf" \ + "aam" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] \ + value [ax] \ + modify exact [ax]; + +u8 adc_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux adc_byte_asm = \ + "push [edi]" \ + "popf" \ + "adc al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 adc_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux adc_word_asm = \ + "push [edi]" \ + "popf" \ + "adc ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 adc_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux adc_long_asm = \ + "push [edi]" \ + "popf" \ + "adc eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +u8 add_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux add_byte_asm = \ + "push [edi]" \ + "popf" \ + "add al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 add_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux add_word_asm = \ + "push [edi]" \ + "popf" \ + "add ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 add_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux add_long_asm = \ + "push [edi]" \ + "popf" \ + "add eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +u8 and_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux and_byte_asm = \ + "push [edi]" \ + "popf" \ + "and al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 and_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux and_word_asm = \ + "push [edi]" \ + "popf" \ + "and ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 and_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux and_long_asm = \ + "push [edi]" \ + "popf" \ + "and eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +u8 cmp_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux cmp_byte_asm = \ + "push [edi]" \ + "popf" \ + "cmp al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 cmp_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux cmp_word_asm = \ + "push [edi]" \ + "popf" \ + "cmp ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 cmp_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux cmp_long_asm = \ + "push [edi]" \ + "popf" \ + "cmp eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +u8 daa_byte_asm(u32 *flags,u8 d); +#pragma aux daa_byte_asm = \ + "push [edi]" \ + "popf" \ + "daa" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] \ + value [al] \ + modify exact [al]; + +u8 das_byte_asm(u32 *flags,u8 d); +#pragma aux das_byte_asm = \ + "push [edi]" \ + "popf" \ + "das" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] \ + value [al] \ + modify exact [al]; + +u8 dec_byte_asm(u32 *flags,u8 d); +#pragma aux dec_byte_asm = \ + "push [edi]" \ + "popf" \ + "dec al" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] \ + value [al] \ + modify exact [al]; + +u16 dec_word_asm(u32 *flags,u16 d); +#pragma aux dec_word_asm = \ + "push [edi]" \ + "popf" \ + "dec ax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] \ + value [ax] \ + modify exact [ax]; + +u32 dec_long_asm(u32 *flags,u32 d); +#pragma aux dec_long_asm = \ + "push [edi]" \ + "popf" \ + "dec eax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] \ + value [eax] \ + modify exact [eax]; + +u8 inc_byte_asm(u32 *flags,u8 d); +#pragma aux inc_byte_asm = \ + "push [edi]" \ + "popf" \ + "inc al" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] \ + value [al] \ + modify exact [al]; + +u16 inc_word_asm(u32 *flags,u16 d); +#pragma aux inc_word_asm = \ + "push [edi]" \ + "popf" \ + "inc ax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] \ + value [ax] \ + modify exact [ax]; + +u32 inc_long_asm(u32 *flags,u32 d); +#pragma aux inc_long_asm = \ + "push [edi]" \ + "popf" \ + "inc eax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] \ + value [eax] \ + modify exact [eax]; + +u8 or_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux or_byte_asm = \ + "push [edi]" \ + "popf" \ + "or al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 or_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux or_word_asm = \ + "push [edi]" \ + "popf" \ + "or ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 or_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux or_long_asm = \ + "push [edi]" \ + "popf" \ + "or eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +u8 neg_byte_asm(u32 *flags,u8 d); +#pragma aux neg_byte_asm = \ + "push [edi]" \ + "popf" \ + "neg al" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] \ + value [al] \ + modify exact [al]; + +u16 neg_word_asm(u32 *flags,u16 d); +#pragma aux neg_word_asm = \ + "push [edi]" \ + "popf" \ + "neg ax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] \ + value [ax] \ + modify exact [ax]; + +u32 neg_long_asm(u32 *flags,u32 d); +#pragma aux neg_long_asm = \ + "push [edi]" \ + "popf" \ + "neg eax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] \ + value [eax] \ + modify exact [eax]; + +u8 not_byte_asm(u32 *flags,u8 d); +#pragma aux not_byte_asm = \ + "push [edi]" \ + "popf" \ + "not al" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] \ + value [al] \ + modify exact [al]; + +u16 not_word_asm(u32 *flags,u16 d); +#pragma aux not_word_asm = \ + "push [edi]" \ + "popf" \ + "not ax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] \ + value [ax] \ + modify exact [ax]; + +u32 not_long_asm(u32 *flags,u32 d); +#pragma aux not_long_asm = \ + "push [edi]" \ + "popf" \ + "not eax" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] \ + value [eax] \ + modify exact [eax]; + +u8 rcl_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux rcl_byte_asm = \ + "push [edi]" \ + "popf" \ + "rcl al,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [cl] \ + value [al] \ + modify exact [al cl]; + +u16 rcl_word_asm(u32 *flags,u16 d, u8 s); +#pragma aux rcl_word_asm = \ + "push [edi]" \ + "popf" \ + "rcl ax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [cl] \ + value [ax] \ + modify exact [ax cl]; + +u32 rcl_long_asm(u32 *flags,u32 d, u8 s); +#pragma aux rcl_long_asm = \ + "push [edi]" \ + "popf" \ + "rcl eax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [cl] \ + value [eax] \ + modify exact [eax cl]; + +u8 rcr_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux rcr_byte_asm = \ + "push [edi]" \ + "popf" \ + "rcr al,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [cl] \ + value [al] \ + modify exact [al cl]; + +u16 rcr_word_asm(u32 *flags,u16 d, u8 s); +#pragma aux rcr_word_asm = \ + "push [edi]" \ + "popf" \ + "rcr ax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [cl] \ + value [ax] \ + modify exact [ax cl]; + +u32 rcr_long_asm(u32 *flags,u32 d, u8 s); +#pragma aux rcr_long_asm = \ + "push [edi]" \ + "popf" \ + "rcr eax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [cl] \ + value [eax] \ + modify exact [eax cl]; + +u8 rol_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux rol_byte_asm = \ + "push [edi]" \ + "popf" \ + "rol al,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [cl] \ + value [al] \ + modify exact [al cl]; + +u16 rol_word_asm(u32 *flags,u16 d, u8 s); +#pragma aux rol_word_asm = \ + "push [edi]" \ + "popf" \ + "rol ax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [cl] \ + value [ax] \ + modify exact [ax cl]; + +u32 rol_long_asm(u32 *flags,u32 d, u8 s); +#pragma aux rol_long_asm = \ + "push [edi]" \ + "popf" \ + "rol eax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [cl] \ + value [eax] \ + modify exact [eax cl]; + +u8 ror_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux ror_byte_asm = \ + "push [edi]" \ + "popf" \ + "ror al,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [cl] \ + value [al] \ + modify exact [al cl]; + +u16 ror_word_asm(u32 *flags,u16 d, u8 s); +#pragma aux ror_word_asm = \ + "push [edi]" \ + "popf" \ + "ror ax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [cl] \ + value [ax] \ + modify exact [ax cl]; + +u32 ror_long_asm(u32 *flags,u32 d, u8 s); +#pragma aux ror_long_asm = \ + "push [edi]" \ + "popf" \ + "ror eax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [cl] \ + value [eax] \ + modify exact [eax cl]; + +u8 shl_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux shl_byte_asm = \ + "push [edi]" \ + "popf" \ + "shl al,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [cl] \ + value [al] \ + modify exact [al cl]; + +u16 shl_word_asm(u32 *flags,u16 d, u8 s); +#pragma aux shl_word_asm = \ + "push [edi]" \ + "popf" \ + "shl ax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [cl] \ + value [ax] \ + modify exact [ax cl]; + +u32 shl_long_asm(u32 *flags,u32 d, u8 s); +#pragma aux shl_long_asm = \ + "push [edi]" \ + "popf" \ + "shl eax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [cl] \ + value [eax] \ + modify exact [eax cl]; + +u8 shr_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux shr_byte_asm = \ + "push [edi]" \ + "popf" \ + "shr al,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [cl] \ + value [al] \ + modify exact [al cl]; + +u16 shr_word_asm(u32 *flags,u16 d, u8 s); +#pragma aux shr_word_asm = \ + "push [edi]" \ + "popf" \ + "shr ax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [cl] \ + value [ax] \ + modify exact [ax cl]; + +u32 shr_long_asm(u32 *flags,u32 d, u8 s); +#pragma aux shr_long_asm = \ + "push [edi]" \ + "popf" \ + "shr eax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [cl] \ + value [eax] \ + modify exact [eax cl]; + +u8 sar_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux sar_byte_asm = \ + "push [edi]" \ + "popf" \ + "sar al,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [cl] \ + value [al] \ + modify exact [al cl]; + +u16 sar_word_asm(u32 *flags,u16 d, u8 s); +#pragma aux sar_word_asm = \ + "push [edi]" \ + "popf" \ + "sar ax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [cl] \ + value [ax] \ + modify exact [ax cl]; + +u32 sar_long_asm(u32 *flags,u32 d, u8 s); +#pragma aux sar_long_asm = \ + "push [edi]" \ + "popf" \ + "sar eax,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [cl] \ + value [eax] \ + modify exact [eax cl]; + +u16 shld_word_asm(u32 *flags,u16 d, u16 fill, u8 s); +#pragma aux shld_word_asm = \ + "push [edi]" \ + "popf" \ + "shld ax,dx,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [dx] [cl] \ + value [ax] \ + modify exact [ax dx cl]; + +u32 shld_long_asm(u32 *flags,u32 d, u32 fill, u8 s); +#pragma aux shld_long_asm = \ + "push [edi]" \ + "popf" \ + "shld eax,edx,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [edx] [cl] \ + value [eax] \ + modify exact [eax edx cl]; + +u16 shrd_word_asm(u32 *flags,u16 d, u16 fill, u8 s); +#pragma aux shrd_word_asm = \ + "push [edi]" \ + "popf" \ + "shrd ax,dx,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [dx] [cl] \ + value [ax] \ + modify exact [ax dx cl]; + +u32 shrd_long_asm(u32 *flags,u32 d, u32 fill, u8 s); +#pragma aux shrd_long_asm = \ + "push [edi]" \ + "popf" \ + "shrd eax,edx,cl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [edx] [cl] \ + value [eax] \ + modify exact [eax edx cl]; + +u8 sbb_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux sbb_byte_asm = \ + "push [edi]" \ + "popf" \ + "sbb al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 sbb_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux sbb_word_asm = \ + "push [edi]" \ + "popf" \ + "sbb ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 sbb_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux sbb_long_asm = \ + "push [edi]" \ + "popf" \ + "sbb eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +u8 sub_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux sub_byte_asm = \ + "push [edi]" \ + "popf" \ + "sub al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 sub_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux sub_word_asm = \ + "push [edi]" \ + "popf" \ + "sub ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 sub_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux sub_long_asm = \ + "push [edi]" \ + "popf" \ + "sub eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +void test_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux test_byte_asm = \ + "push [edi]" \ + "popf" \ + "test al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + modify exact [al bl]; + +void test_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux test_word_asm = \ + "push [edi]" \ + "popf" \ + "test ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + modify exact [ax bx]; + +void test_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux test_long_asm = \ + "push [edi]" \ + "popf" \ + "test eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + modify exact [eax ebx]; + +u8 xor_byte_asm(u32 *flags,u8 d, u8 s); +#pragma aux xor_byte_asm = \ + "push [edi]" \ + "popf" \ + "xor al,bl" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [al] [bl] \ + value [al] \ + modify exact [al bl]; + +u16 xor_word_asm(u32 *flags,u16 d, u16 s); +#pragma aux xor_word_asm = \ + "push [edi]" \ + "popf" \ + "xor ax,bx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [ax] [bx] \ + value [ax] \ + modify exact [ax bx]; + +u32 xor_long_asm(u32 *flags,u32 d, u32 s); +#pragma aux xor_long_asm = \ + "push [edi]" \ + "popf" \ + "xor eax,ebx" \ + "pushf" \ + "pop [edi]" \ + parm [edi] [eax] [ebx] \ + value [eax] \ + modify exact [eax ebx]; + +void imul_byte_asm(u32 *flags,u16 *ax,u8 d,u8 s); +#pragma aux imul_byte_asm = \ + "push [edi]" \ + "popf" \ + "imul bl" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],ax" \ + parm [edi] [esi] [al] [bl] \ + modify exact [esi ax bl]; + +void imul_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 d,u16 s); +#pragma aux imul_word_asm = \ + "push [edi]" \ + "popf" \ + "imul bx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],ax" \ + "mov [ecx],dx" \ + parm [edi] [esi] [ecx] [ax] [bx]\ + modify exact [esi edi ax bx dx]; + +void imul_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 d,u32 s); +#pragma aux imul_long_asm = \ + "push [edi]" \ + "popf" \ + "imul ebx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],eax" \ + "mov [ecx],edx" \ + parm [edi] [esi] [ecx] [eax] [ebx] \ + modify exact [esi edi eax ebx edx]; + +void mul_byte_asm(u32 *flags,u16 *ax,u8 d,u8 s); +#pragma aux mul_byte_asm = \ + "push [edi]" \ + "popf" \ + "mul bl" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],ax" \ + parm [edi] [esi] [al] [bl] \ + modify exact [esi ax bl]; + +void mul_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 d,u16 s); +#pragma aux mul_word_asm = \ + "push [edi]" \ + "popf" \ + "mul bx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],ax" \ + "mov [ecx],dx" \ + parm [edi] [esi] [ecx] [ax] [bx]\ + modify exact [esi edi ax bx dx]; + +void mul_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 d,u32 s); +#pragma aux mul_long_asm = \ + "push [edi]" \ + "popf" \ + "mul ebx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],eax" \ + "mov [ecx],edx" \ + parm [edi] [esi] [ecx] [eax] [ebx] \ + modify exact [esi edi eax ebx edx]; + +void idiv_byte_asm(u32 *flags,u8 *al,u8 *ah,u16 d,u8 s); +#pragma aux idiv_byte_asm = \ + "push [edi]" \ + "popf" \ + "idiv bl" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],al" \ + "mov [ecx],ah" \ + parm [edi] [esi] [ecx] [ax] [bl]\ + modify exact [esi edi ax bl]; + +void idiv_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 dlo,u16 dhi,u16 s); +#pragma aux idiv_word_asm = \ + "push [edi]" \ + "popf" \ + "idiv bx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],ax" \ + "mov [ecx],dx" \ + parm [edi] [esi] [ecx] [ax] [dx] [bx]\ + modify exact [esi edi ax dx bx]; + +void idiv_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 dlo,u32 dhi,u32 s); +#pragma aux idiv_long_asm = \ + "push [edi]" \ + "popf" \ + "idiv ebx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],eax" \ + "mov [ecx],edx" \ + parm [edi] [esi] [ecx] [eax] [edx] [ebx]\ + modify exact [esi edi eax edx ebx]; + +void div_byte_asm(u32 *flags,u8 *al,u8 *ah,u16 d,u8 s); +#pragma aux div_byte_asm = \ + "push [edi]" \ + "popf" \ + "div bl" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],al" \ + "mov [ecx],ah" \ + parm [edi] [esi] [ecx] [ax] [bl]\ + modify exact [esi edi ax bl]; + +void div_word_asm(u32 *flags,u16 *ax,u16 *dx,u16 dlo,u16 dhi,u16 s); +#pragma aux div_word_asm = \ + "push [edi]" \ + "popf" \ + "div bx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],ax" \ + "mov [ecx],dx" \ + parm [edi] [esi] [ecx] [ax] [dx] [bx]\ + modify exact [esi edi ax dx bx]; + +void div_long_asm(u32 *flags,u32 *eax,u32 *edx,u32 dlo,u32 dhi,u32 s); +#pragma aux div_long_asm = \ + "push [edi]" \ + "popf" \ + "div ebx" \ + "pushf" \ + "pop [edi]" \ + "mov [esi],eax" \ + "mov [ecx],edx" \ + parm [edi] [esi] [ecx] [eax] [edx] [ebx]\ + modify exact [esi edi eax edx ebx]; + +#endif + +#endif /* __X86EMU_PRIM_ASM_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/prim_ops.h b/xorg-server/hw/xfree86/x86emu/x86emu/prim_ops.h new file mode 100644 index 000000000..6ac2a29f6 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/prim_ops.h @@ -0,0 +1,142 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for primitive operation functions. +* +****************************************************************************/ + +#ifndef __X86EMU_PRIM_OPS_H +#define __X86EMU_PRIM_OPS_H + +#ifdef __cplusplus +extern "C" { /* Use "C" linkage when in C++ mode */ +#endif + +u16 aaa_word (u16 d); +u16 aas_word (u16 d); +u16 aad_word (u16 d); +u16 aam_word (u8 d); +u8 adc_byte (u8 d, u8 s); +u16 adc_word (u16 d, u16 s); +u32 adc_long (u32 d, u32 s); +u8 add_byte (u8 d, u8 s); +u16 add_word (u16 d, u16 s); +u32 add_long (u32 d, u32 s); +u8 and_byte (u8 d, u8 s); +u16 and_word (u16 d, u16 s); +u32 and_long (u32 d, u32 s); +u8 cmp_byte (u8 d, u8 s); +u16 cmp_word (u16 d, u16 s); +u32 cmp_long (u32 d, u32 s); +u8 daa_byte (u8 d); +u8 das_byte (u8 d); +u8 dec_byte (u8 d); +u16 dec_word (u16 d); +u32 dec_long (u32 d); +u8 inc_byte (u8 d); +u16 inc_word (u16 d); +u32 inc_long (u32 d); +u8 or_byte (u8 d, u8 s); +u16 or_word (u16 d, u16 s); +u32 or_long (u32 d, u32 s); +u8 neg_byte (u8 s); +u16 neg_word (u16 s); +u32 neg_long (u32 s); +u8 not_byte (u8 s); +u16 not_word (u16 s); +u32 not_long (u32 s); +u8 rcl_byte (u8 d, u8 s); +u16 rcl_word (u16 d, u8 s); +u32 rcl_long (u32 d, u8 s); +u8 rcr_byte (u8 d, u8 s); +u16 rcr_word (u16 d, u8 s); +u32 rcr_long (u32 d, u8 s); +u8 rol_byte (u8 d, u8 s); +u16 rol_word (u16 d, u8 s); +u32 rol_long (u32 d, u8 s); +u8 ror_byte (u8 d, u8 s); +u16 ror_word (u16 d, u8 s); +u32 ror_long (u32 d, u8 s); +u8 shl_byte (u8 d, u8 s); +u16 shl_word (u16 d, u8 s); +u32 shl_long (u32 d, u8 s); +u8 shr_byte (u8 d, u8 s); +u16 shr_word (u16 d, u8 s); +u32 shr_long (u32 d, u8 s); +u8 sar_byte (u8 d, u8 s); +u16 sar_word (u16 d, u8 s); +u32 sar_long (u32 d, u8 s); +u16 shld_word (u16 d, u16 fill, u8 s); +u32 shld_long (u32 d, u32 fill, u8 s); +u16 shrd_word (u16 d, u16 fill, u8 s); +u32 shrd_long (u32 d, u32 fill, u8 s); +u8 sbb_byte (u8 d, u8 s); +u16 sbb_word (u16 d, u16 s); +u32 sbb_long (u32 d, u32 s); +u8 sub_byte (u8 d, u8 s); +u16 sub_word (u16 d, u16 s); +u32 sub_long (u32 d, u32 s); +void test_byte (u8 d, u8 s); +void test_word (u16 d, u16 s); +void test_long (u32 d, u32 s); +u8 xor_byte (u8 d, u8 s); +u16 xor_word (u16 d, u16 s); +u32 xor_long (u32 d, u32 s); +void imul_byte (u8 s); +void imul_word (u16 s); +void imul_long (u32 s); +void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s); +void mul_byte (u8 s); +void mul_word (u16 s); +void mul_long (u32 s); +void idiv_byte (u8 s); +void idiv_word (u16 s); +void idiv_long (u32 s); +void div_byte (u8 s); +void div_word (u16 s); +void div_long (u32 s); +void ins (int size); +void outs (int size); +u16 mem_access_word (int addr); +void push_word (u16 w); +void push_long (u32 w); +u16 pop_word (void); +u32 pop_long (void); +void cpuid (void); + +#ifdef __cplusplus +} /* End of "C" linkage for C++ */ +#endif + +#endif /* __X86EMU_PRIM_OPS_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h b/xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h new file mode 100644 index 000000000..5a443cdbf --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/prim_x86_gcc.h @@ -0,0 +1,79 @@ +/**************************************************************************** +* +* Inline helpers for x86emu +* +* Copyright (C) 2008 Bart Trojanowski, Symbio Technologies, LLC +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: GNU C +* Environment: GCC on i386 or x86-64 +* Developer: Bart Trojanowski +* +* Description: This file defines a few x86 macros that can be used by the +* emulator to execute native instructions. +* +* For PIC vs non-PIC code refer to: +* http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well +* +****************************************************************************/ +#ifndef __X86EMU_PRIM_X86_GCC_H +#define __X86EMU_PRIM_X86_GCC_H + +#include "x86emu/types.h" + +#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__) || defined(__x86_64__)) +#error This file is intended to be used by gcc on i386 or x86-64 system +#endif + +#if defined(__PIC__) && defined(__i386__) + +#define X86EMU_HAS_HW_CPUID 1 +static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d) +{ + __asm__ __volatile__ ("pushl %%ebx \n\t" + "cpuid \n\t" + "movl %%ebx, %1 \n\t" + "popl %%ebx \n\t" + : "=a" (*a), "=r" (*b), + "=c" (*c), "=d" (*d) + : "a" (*a), "c" (*c) + : "cc"); +} + +#else // ! (__PIC__ && __i386__) + +#define x86EMU_HAS_HW_CPUID 1 +static inline void hw_cpuid (u32 *a, u32 *b, u32 *c, u32 *d) +{ + __asm__ __volatile__ ("cpuid" + : "=a" (*a), "=b" (*b), + "=c" (*c), "=d" (*d) + : "a" (*a), "c" (*c) + : "cc"); +} + +#endif // __PIC__ && __i386__ + + +#endif // __X86EMU_PRIM_X86_GCC_H diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/regs.h b/xorg-server/hw/xfree86/x86emu/x86emu/regs.h new file mode 100644 index 000000000..52cf8e41b --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/regs.h @@ -0,0 +1,337 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for x86 register definitions. +* +****************************************************************************/ + +#ifndef __X86EMU_REGS_H +#define __X86EMU_REGS_H + +/*---------------------- Macros and type definitions ----------------------*/ + +#ifdef PACK +# pragma PACK +#endif + +/* + * General EAX, EBX, ECX, EDX type registers. Note that for + * portability, and speed, the issue of byte swapping is not addressed + * in the registers. All registers are stored in the default format + * available on the host machine. The only critical issue is that the + * registers should line up EXACTLY in the same manner as they do in + * the 386. That is: + * + * EAX & 0xff === AL + * EAX & 0xffff == AX + * + * etc. The result is that alot of the calculations can then be + * done using the native instruction set fully. + */ + +#ifdef __BIG_ENDIAN__ + +typedef struct { + u32 e_reg; + } I32_reg_t; + +typedef struct { + u16 filler0, x_reg; + } I16_reg_t; + +typedef struct { + u8 filler0, filler1, h_reg, l_reg; + } I8_reg_t; + +#else /* !__BIG_ENDIAN__ */ + +typedef struct { + u32 e_reg; + } I32_reg_t; + +typedef struct { + u16 x_reg; + } I16_reg_t; + +typedef struct { + u8 l_reg, h_reg; + } I8_reg_t; + +#endif /* BIG_ENDIAN */ + +typedef union { + I32_reg_t I32_reg; + I16_reg_t I16_reg; + I8_reg_t I8_reg; + } i386_general_register; + +struct i386_general_regs { + i386_general_register A, B, C, D; + }; + +typedef struct i386_general_regs Gen_reg_t; + +struct i386_special_regs { + i386_general_register SP, BP, SI, DI, IP; + u32 FLAGS; + }; + +/* + * Segment registers here represent the 16 bit quantities + * CS, DS, ES, SS. + */ + +struct i386_segment_regs { + u16 CS, DS, SS, ES, FS, GS; + }; + +/* 8 bit registers */ +#define R_AH gen.A.I8_reg.h_reg +#define R_AL gen.A.I8_reg.l_reg +#define R_BH gen.B.I8_reg.h_reg +#define R_BL gen.B.I8_reg.l_reg +#define R_CH gen.C.I8_reg.h_reg +#define R_CL gen.C.I8_reg.l_reg +#define R_DH gen.D.I8_reg.h_reg +#define R_DL gen.D.I8_reg.l_reg + +/* 16 bit registers */ +#define R_AX gen.A.I16_reg.x_reg +#define R_BX gen.B.I16_reg.x_reg +#define R_CX gen.C.I16_reg.x_reg +#define R_DX gen.D.I16_reg.x_reg + +/* 32 bit extended registers */ +#define R_EAX gen.A.I32_reg.e_reg +#define R_EBX gen.B.I32_reg.e_reg +#define R_ECX gen.C.I32_reg.e_reg +#define R_EDX gen.D.I32_reg.e_reg + +/* special registers */ +#define R_SP spc.SP.I16_reg.x_reg +#define R_BP spc.BP.I16_reg.x_reg +#define R_SI spc.SI.I16_reg.x_reg +#define R_DI spc.DI.I16_reg.x_reg +#define R_IP spc.IP.I16_reg.x_reg +#define R_FLG spc.FLAGS + +/* special registers */ +#define R_SP spc.SP.I16_reg.x_reg +#define R_BP spc.BP.I16_reg.x_reg +#define R_SI spc.SI.I16_reg.x_reg +#define R_DI spc.DI.I16_reg.x_reg +#define R_IP spc.IP.I16_reg.x_reg +#define R_FLG spc.FLAGS + +/* special registers */ +#define R_ESP spc.SP.I32_reg.e_reg +#define R_EBP spc.BP.I32_reg.e_reg +#define R_ESI spc.SI.I32_reg.e_reg +#define R_EDI spc.DI.I32_reg.e_reg +#define R_EIP spc.IP.I32_reg.e_reg +#define R_EFLG spc.FLAGS + +/* segment registers */ +#define R_CS seg.CS +#define R_DS seg.DS +#define R_SS seg.SS +#define R_ES seg.ES +#define R_FS seg.FS +#define R_GS seg.GS + +/* flag conditions */ +#define FB_CF 0x0001 /* CARRY flag */ +#define FB_PF 0x0004 /* PARITY flag */ +#define FB_AF 0x0010 /* AUX flag */ +#define FB_ZF 0x0040 /* ZERO flag */ +#define FB_SF 0x0080 /* SIGN flag */ +#define FB_TF 0x0100 /* TRAP flag */ +#define FB_IF 0x0200 /* INTERRUPT ENABLE flag */ +#define FB_DF 0x0400 /* DIR flag */ +#define FB_OF 0x0800 /* OVERFLOW flag */ + +/* 80286 and above always have bit#1 set */ +#define F_ALWAYS_ON (0x0002) /* flag bits always on */ + +/* + * Define a mask for only those flag bits we will ever pass back + * (via PUSHF) + */ +#define F_MSK (FB_CF|FB_PF|FB_AF|FB_ZF|FB_SF|FB_TF|FB_IF|FB_DF|FB_OF) + +/* following bits masked in to a 16bit quantity */ + +#define F_CF 0x0001 /* CARRY flag */ +#define F_PF 0x0004 /* PARITY flag */ +#define F_AF 0x0010 /* AUX flag */ +#define F_ZF 0x0040 /* ZERO flag */ +#define F_SF 0x0080 /* SIGN flag */ +#define F_TF 0x0100 /* TRAP flag */ +#define F_IF 0x0200 /* INTERRUPT ENABLE flag */ +#define F_DF 0x0400 /* DIR flag */ +#define F_OF 0x0800 /* OVERFLOW flag */ + +#define TOGGLE_FLAG(flag) (M.x86.R_FLG ^= (flag)) +#define SET_FLAG(flag) (M.x86.R_FLG |= (flag)) +#define CLEAR_FLAG(flag) (M.x86.R_FLG &= ~(flag)) +#define ACCESS_FLAG(flag) (M.x86.R_FLG & (flag)) +#define CLEARALL_FLAG(m) (M.x86.R_FLG = 0) + +#define CONDITIONAL_SET_FLAG(COND,FLAG) \ + if (COND) SET_FLAG(FLAG); else CLEAR_FLAG(FLAG) + +#define F_PF_CALC 0x010000 /* PARITY flag has been calced */ +#define F_ZF_CALC 0x020000 /* ZERO flag has been calced */ +#define F_SF_CALC 0x040000 /* SIGN flag has been calced */ + +#define F_ALL_CALC 0xff0000 /* All have been calced */ + +/* + * Emulator machine state. + * Segment usage control. + */ +#define SYSMODE_SEG_DS_SS 0x00000001 +#define SYSMODE_SEGOVR_CS 0x00000002 +#define SYSMODE_SEGOVR_DS 0x00000004 +#define SYSMODE_SEGOVR_ES 0x00000008 +#define SYSMODE_SEGOVR_FS 0x00000010 +#define SYSMODE_SEGOVR_GS 0x00000020 +#define SYSMODE_SEGOVR_SS 0x00000040 +#define SYSMODE_PREFIX_REPE 0x00000080 +#define SYSMODE_PREFIX_REPNE 0x00000100 +#define SYSMODE_PREFIX_DATA 0x00000200 +#define SYSMODE_PREFIX_ADDR 0x00000400 +#define SYSMODE_INTR_PENDING 0x10000000 +#define SYSMODE_EXTRN_INTR 0x20000000 +#define SYSMODE_HALTED 0x40000000 + +#define SYSMODE_SEGMASK (SYSMODE_SEG_DS_SS | \ + SYSMODE_SEGOVR_CS | \ + SYSMODE_SEGOVR_DS | \ + SYSMODE_SEGOVR_ES | \ + SYSMODE_SEGOVR_FS | \ + SYSMODE_SEGOVR_GS | \ + SYSMODE_SEGOVR_SS) +#define SYSMODE_CLRMASK (SYSMODE_SEG_DS_SS | \ + SYSMODE_SEGOVR_CS | \ + SYSMODE_SEGOVR_DS | \ + SYSMODE_SEGOVR_ES | \ + SYSMODE_SEGOVR_FS | \ + SYSMODE_SEGOVR_GS | \ + SYSMODE_SEGOVR_SS | \ + SYSMODE_PREFIX_DATA | \ + SYSMODE_PREFIX_ADDR) + +#define INTR_SYNCH 0x1 +#define INTR_ASYNCH 0x2 +#define INTR_HALTED 0x4 + +typedef struct { + struct i386_general_regs gen; + struct i386_special_regs spc; + struct i386_segment_regs seg; + /* + * MODE contains information on: + * REPE prefix 2 bits repe,repne + * SEGMENT overrides 5 bits normal,DS,SS,CS,ES + * Delayed flag set 3 bits (zero, signed, parity) + * reserved 6 bits + * interrupt # 8 bits instruction raised interrupt + * BIOS video segregs 4 bits + * Interrupt Pending 1 bits + * Extern interrupt 1 bits + * Halted 1 bits + */ + u32 mode; + volatile int intr; /* mask of pending interrupts */ + int debug; +#ifdef DEBUG + int check; + u16 saved_ip; + u16 saved_cs; + int enc_pos; + int enc_str_pos; + char decode_buf[32]; /* encoded byte stream */ + char decoded_buf[256]; /* disassembled strings */ +#endif + u8 intno; + u8 __pad[3]; + } X86EMU_regs; + +/**************************************************************************** +REMARKS: +Structure maintaining the emulator machine state. + +MEMBERS: +mem_base - Base real mode memory for the emulator +mem_size - Size of the real mode memory block for the emulator +private - private data pointer +x86 - X86 registers +****************************************************************************/ +typedef struct { + unsigned long mem_base; + unsigned long mem_size; + void* private; + X86EMU_regs x86; + } X86EMU_sysEnv; + +#ifdef END_PACK +# pragma END_PACK +#endif + +/*----------------------------- Global Variables --------------------------*/ + +#ifdef __cplusplus +extern "C" { /* Use "C" linkage when in C++ mode */ +#endif + +/* Global emulator machine state. + * + * We keep it global to avoid pointer dereferences in the code for speed. + */ + +extern X86EMU_sysEnv _X86EMU_env; +#define M _X86EMU_env + +/*-------------------------- Function Prototypes --------------------------*/ + +/* Function to log information at runtime */ + +void printk(const char *fmt, ...); + +#ifdef __cplusplus +} /* End of "C" linkage for C++ */ +#endif + +#endif /* __X86EMU_REGS_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/types.h b/xorg-server/hw/xfree86/x86emu/x86emu/types.h new file mode 100644 index 000000000..2d41b0f18 --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/types.h @@ -0,0 +1,106 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for x86 emulator type definitions. +* +****************************************************************************/ + + +#ifndef __X86EMU_TYPES_H +#define __X86EMU_TYPES_H + +#ifndef NO_SYS_HEADERS +#include <sys/types.h> +#endif + +/* + * The following kludge is an attempt to work around typedef conflicts with + * <sys/types.h>. + */ +#define u8 x86emuu8 +#define u16 x86emuu16 +#define u32 x86emuu32 +#define u64 x86emuu64 +#define s8 x86emus8 +#define s16 x86emus16 +#define s32 x86emus32 +#define s64 x86emus64 +#define uint x86emuuint +#define sint x86emusint + +/*---------------------- Macros and type definitions ----------------------*/ + +/* Currently only for Linux/32bit */ +#undef __HAS_LONG_LONG__ +#if defined(__GNUC__) && !defined(NO_LONG_LONG) +#define __HAS_LONG_LONG__ +#endif + +/* Taken from Xmd.h */ +#undef NUM32 +#if defined (_LP64) || \ + defined(__alpha) || defined(__alpha__) || \ + defined(__ia64__) || defined(ia64) || \ + defined(__sparc64__) || \ + defined(__s390x__) || \ + (defined(__hppa__) && defined(__LP64)) || \ + defined(__amd64__) || defined(amd64) || defined(__x86_64__) || \ + (defined(__sgi) && (_MIPS_SZLONG == 64)) +#define NUM32 int +#else +#define NUM32 long +#endif + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned NUM32 u32; +#ifdef __HAS_LONG_LONG__ +typedef unsigned long long u64; +#endif + +typedef char s8; +typedef short s16; +typedef NUM32 s32; +#ifdef __HAS_LONG_LONG__ +typedef long long s64; +#endif + +typedef unsigned int uint; +typedef int sint; + +typedef u16 X86EMU_pioAddr; + +#undef NUM32 + +#endif /* __X86EMU_TYPES_H */ diff --git a/xorg-server/hw/xfree86/x86emu/x86emu/x86emui.h b/xorg-server/hw/xfree86/x86emu/x86emu/x86emui.h new file mode 100644 index 000000000..112ee366f --- /dev/null +++ b/xorg-server/hw/xfree86/x86emu/x86emu/x86emui.h @@ -0,0 +1,102 @@ +/**************************************************************************** +* +* Realmode X86 Emulator Library +* +* Copyright (C) 1996-1999 SciTech Software, Inc. +* Copyright (C) David Mosberger-Tang +* Copyright (C) 1999 Egbert Eich +* +* ======================================================================== +* +* 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 the authors not be used +* in advertising or publicity pertaining to distribution of the software +* without specific, written prior permission. The authors makes no +* representations about the suitability of this software for any purpose. +* It is provided "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS 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. +* +* ======================================================================== +* +* Language: ANSI C +* Environment: Any +* Developer: Kendall Bennett +* +* Description: Header file for system specific functions. These functions +* are always compiled and linked in the OS depedent libraries, +* and never in a binary portable driver. +* +****************************************************************************/ + + +#ifndef __X86EMU_X86EMUI_H +#define __X86EMU_X86EMUI_H + +/* If we are compiling in C++ mode, we can compile some functions as + * inline to increase performance (however the code size increases quite + * dramatically in this case). + */ + +#if defined(__cplusplus) && !defined(_NO_INLINE) +#define _INLINE inline +#else +#define _INLINE static +#endif + +/* Get rid of unused parameters in C++ compilation mode */ + +#ifdef __cplusplus +#define X86EMU_UNUSED(v) +#else +#define X86EMU_UNUSED(v) v +#endif + +#include "x86emu.h" +#include "x86emu/regs.h" +#include "x86emu/debug.h" +#include "x86emu/decode.h" +#include "x86emu/ops.h" +#include "x86emu/prim_ops.h" +#include "x86emu/fpu.h" +#include "x86emu/fpu_regs.h" + +#ifndef NO_SYS_HEADERS +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#endif +/*--------------------------- Inline Functions ----------------------------*/ + +#ifdef __cplusplus +extern "C" { /* Use "C" linkage when in C++ mode */ +#endif + +extern u8 (X86APIP sys_rdb)(u32 addr); +extern u16 (X86APIP sys_rdw)(u32 addr); +extern u32 (X86APIP sys_rdl)(u32 addr); +extern void (X86APIP sys_wrb)(u32 addr,u8 val); +extern void (X86APIP sys_wrw)(u32 addr,u16 val); +extern void (X86APIP sys_wrl)(u32 addr,u32 val); + +extern u8 (X86APIP sys_inb)(X86EMU_pioAddr addr); +extern u16 (X86APIP sys_inw)(X86EMU_pioAddr addr); +extern u32 (X86APIP sys_inl)(X86EMU_pioAddr addr); +extern void (X86APIP sys_outb)(X86EMU_pioAddr addr,u8 val); +extern void (X86APIP sys_outw)(X86EMU_pioAddr addr,u16 val); +extern void (X86APIP sys_outl)(X86EMU_pioAddr addr,u32 val); + +#ifdef __cplusplus +} /* End of "C" linkage for C++ */ +#endif + +#endif /* __X86EMU_X86EMUI_H */ diff --git a/xorg-server/hw/xfree86/xaa/Makefile.am b/xorg-server/hw/xfree86/xaa/Makefile.am new file mode 100644 index 000000000..bd8267ad8 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/Makefile.am @@ -0,0 +1,74 @@ +LSB_FIRST = l-xaaBitmap.c l-xaaStipple.c l-xaaTEGlyph.c +LSB_3_FIRST = l3-xaaBitmap.c l3-xaaStipple.c +MSB_FIRST = m-xaaBitmap.c m-xaaStipple.c m-xaaTEGlyph.c +MSB_3_FIRST = m3-xaaBitmap.c m3-xaaStipple.c +LSB_FIXED = lf-xaaBitmap.c lf-xaaStipple.c lf-xaaTEGlyph.c +LSB_3_FIXED = lf3-xaaBitmap.c lf3-xaaStipple.c +MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c +MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c +POLYSEG = s-xaaLine.c s-xaaDashLine.c + +libxaa_la_LDFLAGS = -avoid-version +if COMPOSITE +libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la +endif + +module_LTLIBRARIES = libxaa.la +libxaa_la_SOURCES = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c \ + xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \ + xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \ + xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c xaaWrapper.c \ + xaaRect.c xaaLineMisc.c xaaBitOrder.c \ + xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \ + xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \ + xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \ + $(LSB_FIRST) $(MSB_FIRST) $(LSB_FIXED) $(MSB_FIXED) \ + $(LSB_3_FIRST) $(MSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIXED) +${POLYSEG}: + echo "#define POLYSEGMENT" > $@ + echo '#include "$(srcdir)/${@:s-%=%}"' >> $@ +${LSB_FIRST}: + echo "#define LSBFIRST" > $@ + echo '#include "$(srcdir)/${@:l-%=%}"' >> $@ +${LSB_3_FIRST}: + echo "#define LSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@ +${LSB_FIXED}: + echo "#define LSBFIRST" > $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@ +${LSB_3_FIXED}: + echo "#define LSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@ +${MSB_FIRST}: + echo "#define MSBFIRST" > $@ + echo '#include "$(srcdir)/${@:m-%=%}"' >> $@ +${MSB_3_FIRST}: + echo "#define MSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@ +${MSB_FIXED}: + echo "#define MSBFIRST" > $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@ +${MSB_3_FIXED}: + echo "#define MSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@ + +DISTCLEANFILES = $(POLYSEG) \ + $(LSB_FIRST) $(LSB_FIXED) $(MSB_FIRST) $(MSB_FIXED) \ + $(LSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIRST) $(MSB_3_FIXED) + +sdk_HEADERS = xaa.h xaalocal.h xaarop.h xaaWrapper.h +EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \ + xaaStipple.c xaaTEGlyph.c xaaNonTEGlyph.c xaaBitmap.c \ + xaaTEGlyphBlt.S XAA.HOWTO + +INCLUDES = $(XORG_INCS) + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xfree86/xaa/Makefile.in b/xorg-server/hw/xfree86/xaa/Makefile.in new file mode 100644 index 000000000..bea296fa0 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/Makefile.in @@ -0,0 +1,836 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/xaa +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +@COMPOSITE_TRUE@libxaa_la_DEPENDENCIES = \ +@COMPOSITE_TRUE@ $(top_builddir)/miext/cw/libcw.la +am__objects_1 = s-xaaLine.lo s-xaaDashLine.lo +am__objects_2 = l-xaaBitmap.lo l-xaaStipple.lo l-xaaTEGlyph.lo +am__objects_3 = m-xaaBitmap.lo m-xaaStipple.lo m-xaaTEGlyph.lo +am__objects_4 = lf-xaaBitmap.lo lf-xaaStipple.lo lf-xaaTEGlyph.lo +am__objects_5 = mf-xaaBitmap.lo mf-xaaStipple.lo mf-xaaTEGlyph.lo +am__objects_6 = l3-xaaBitmap.lo l3-xaaStipple.lo +am__objects_7 = m3-xaaBitmap.lo m3-xaaStipple.lo +am__objects_8 = lf3-xaaBitmap.lo lf3-xaaStipple.lo +am__objects_9 = mf3-xaaBitmap.lo mf3-xaaStipple.lo +am_libxaa_la_OBJECTS = xaaInit.lo xaaGC.lo xaaInitAccel.lo \ + xaaFallback.lo xaaBitBlt.lo xaaCpyArea.lo xaaGCmisc.lo \ + xaaCpyWin.lo xaaCpyPlane.lo xaaFillRect.lo xaaTEText.lo \ + xaaNonTEText.lo xaaPCache.lo xaaSpans.lo xaaROP.lo xaaImage.lo \ + xaaWrapper.lo xaaRect.lo xaaLineMisc.lo xaaBitOrder.lo \ + xaaFillPoly.lo xaaWideLine.lo xaaTables.lo xaaFillArc.lo \ + xaaLine.lo xaaDashLine.lo xaaOverlay.lo xaaOffscreen.lo \ + xaaOverlayDF.lo xaaStateChange.lo xaaPict.lo $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) \ + $(am__objects_5) $(am__objects_6) $(am__objects_7) \ + $(am__objects_8) $(am__objects_9) +libxaa_la_OBJECTS = $(am_libxaa_la_OBJECTS) +libxaa_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libxaa_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxaa_la_SOURCES) +DIST_SOURCES = $(libxaa_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +LSB_FIRST = l-xaaBitmap.c l-xaaStipple.c l-xaaTEGlyph.c +LSB_3_FIRST = l3-xaaBitmap.c l3-xaaStipple.c +MSB_FIRST = m-xaaBitmap.c m-xaaStipple.c m-xaaTEGlyph.c +MSB_3_FIRST = m3-xaaBitmap.c m3-xaaStipple.c +LSB_FIXED = lf-xaaBitmap.c lf-xaaStipple.c lf-xaaTEGlyph.c +LSB_3_FIXED = lf3-xaaBitmap.c lf3-xaaStipple.c +MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c +MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c +POLYSEG = s-xaaLine.c s-xaaDashLine.c +libxaa_la_LDFLAGS = -avoid-version +@COMPOSITE_TRUE@libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la +module_LTLIBRARIES = libxaa.la +libxaa_la_SOURCES = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c \ + xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \ + xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \ + xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c xaaWrapper.c \ + xaaRect.c xaaLineMisc.c xaaBitOrder.c \ + xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \ + xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \ + xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \ + $(LSB_FIRST) $(MSB_FIRST) $(LSB_FIXED) $(MSB_FIXED) \ + $(LSB_3_FIRST) $(MSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIXED) + +DISTCLEANFILES = $(POLYSEG) \ + $(LSB_FIRST) $(LSB_FIXED) $(MSB_FIRST) $(MSB_FIXED) \ + $(LSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIRST) $(MSB_3_FIXED) + +sdk_HEADERS = xaa.h xaalocal.h xaarop.h xaaWrapper.h +EXTRA_DIST = xaacexp.h xaawrap.h xaaLine.c xaaDashLine.c \ + xaaStipple.c xaaTEGlyph.c xaaNonTEGlyph.c xaaBitmap.c \ + xaaTEGlyphBlt.S XAA.HOWTO + +INCLUDES = $(XORG_INCS) +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/xaa/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/xaa/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libxaa.la: $(libxaa_la_OBJECTS) $(libxaa_la_DEPENDENCIES) + $(libxaa_la_LINK) -rpath $(moduledir) $(libxaa_la_OBJECTS) $(libxaa_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/l-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/l-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/l-xaaTEGlyph.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/l3-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/l3-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lf-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lf-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lf-xaaTEGlyph.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lf3-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lf3-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m-xaaTEGlyph.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m3-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m3-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf-xaaTEGlyph.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf3-xaaBitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf3-xaaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s-xaaDashLine.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s-xaaLine.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaBitBlt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaBitOrder.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaCpyArea.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaCpyPlane.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaCpyWin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaDashLine.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaFallback.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaFillArc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaFillPoly.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaFillRect.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaGC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaGCmisc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaImage.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaInit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaInitAccel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaLine.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaLineMisc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaNonTEText.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaOffscreen.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaOverlay.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaOverlayDF.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaPCache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaPict.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaROP.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaRect.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaSpans.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaStateChange.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaTEText.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaTables.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaWideLine.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaaWrapper.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + +${POLYSEG}: + echo "#define POLYSEGMENT" > $@ + echo '#include "$(srcdir)/${@:s-%=%}"' >> $@ +${LSB_FIRST}: + echo "#define LSBFIRST" > $@ + echo '#include "$(srcdir)/${@:l-%=%}"' >> $@ +${LSB_3_FIRST}: + echo "#define LSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@ +${LSB_FIXED}: + echo "#define LSBFIRST" > $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@ +${LSB_3_FIXED}: + echo "#define LSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@ +${MSB_FIRST}: + echo "#define MSBFIRST" > $@ + echo '#include "$(srcdir)/${@:m-%=%}"' >> $@ +${MSB_3_FIRST}: + echo "#define MSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@ +${MSB_FIXED}: + echo "#define MSBFIRST" > $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@ +${MSB_3_FIXED}: + echo "#define MSBFIRST" > $@ + echo "#define TRIPLE_BITS" >> $@ + echo "#define FIXEDBASE" >> $@ + echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/xaa/XAA.HOWTO b/xorg-server/hw/xfree86/xaa/XAA.HOWTO new file mode 100644 index 000000000..cbd71c138 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/XAA.HOWTO @@ -0,0 +1,1427 @@ + + + XAA.HOWTO + + This file describes how to add basic XAA support to a chipset driver. + +0) What is XAA +1) XAA Initialization and Shutdown +2) The Primitives + 2.0 Generic Flags + 2.1 Screen to Screen Copies + 2.2 Solid Fills + 2.3 Solid Lines + 2.4 Dashed Lines + 2.5 Color Expand Fills + 2.5.1 Screen to Screen Color Expansion + 2.5.2 CPU to Screen Color Expansion + 2.5.2.1 The Direct Method + 2.5.2.2 The Indirect Method + 2.6 8x8 Mono Pattern Fills + 2.7 8x8 Color Pattern Fills + 2.8 Image Writes + 2.8.1 The Direct Method + 2.8.2 The Indirect Method + 2.9 Clipping +3) The Pixmap Cache +4) Offscreen Pixmaps + +/********************************************************************/ + +0) WHAT IS XAA + + XAA (the XFree86 Acceleration Architecture) is a device dependent +layer that encapsulates the unaccelerated framebuffer rendering layer, +intercepting rendering commands sent to it from higher levels of the +server. For rendering tasks where hardware acceleration is not +possible, XAA allows the requests to proceed to the software rendering +code. Otherwise, XAA breaks the sometimes complicated X primitives +into simpler primitives more suitable for hardware acceleration and +will use accelerated functions exported by the chipset driver to +render these. + + XAA provides a simple, easy to use driver interface that allows +the driver to communicate its acceleration capabilities and restrictions +back to XAA. XAA will use the information provided by the driver +to determine whether or not acceleration will be possible for a +particular X primitive. + + + +1) XAA INITIALIZATION AND SHUTDOWN + + All relevant prototypes and defines are in xaa.h. + + To Initialize the XAA layer, the driver should allocate an XAAInfoRec +via XAACreateInfoRec(), fill it out as described in this document +and pass it to XAAInit(). XAAInit() must be called _after_ the +framebuffer initialization (usually cfb?ScreenInit or similar) since +it is "wrapping" that layer. XAAInit() should be called _before_ the +cursor initialization (usually miDCInitialize) since the cursor +layer needs to "wrap" all the rendering code including XAA. + + When shutting down, the driver should free the XAAInfoRec +structure in its CloseScreen function via XAADestroyInfoRec(). +The prototypes for the functions mentioned above are as follows: + + XAAInfoRecPtr XAACreateInfoRec(void); + Bool XAAInit(ScreenPtr, XAAInfoRecPtr); + void XAADestroyInfoRec(XAAInfoRec); + + The driver informs XAA of it's acceleration capablities by +filling out an XAAInfoRec structure and passing it to XAAInit(). +The XAAInfoRec structure contains many fields, most of which are +function pointers and flags. Each primitive will typically have +two functions and a set of flags associated with it, but it may +have more. These two functions are the "SetupFor" and "Subsequent" +functions. The "SetupFor" function tells the driver that the +hardware should be initialized for a particular type of graphics +operation. After the "SetupFor" function, one or more calls to the +"Subsequent" function will be made to indicate that an instance +of the particular primitive should be rendered by the hardware. +The details of each instance (width, height, etc...) are given +with each "Subsequent" function. The set of flags associated +with each primitive lets the driver tell XAA what its hardware +limitations are (eg. It doesn't support a planemask, it can only +do one of the raster-ops, etc...). + + Of the XAAInfoRec fields, one is required. This is the +Sync function. XAA initialization will fail if this function +is not provided. + +void Sync(ScrnInfoPtr pScrn) /* Required */ + + Sync will be called when XAA needs to be certain that all + graphics coprocessor operations are finished, such as when + the framebuffer must be written to or read from directly + and it must be certain that the accelerator will not be + overwriting the area of interest. + + One needs to make certain that the Sync function not only + waits for the accelerator fifo to empty, but that it waits for + the rendering of that last operation to complete. + + It is guaranteed that no direct framebuffer access will + occur after a "SetupFor" or "Subsequent" function without + the Sync function being called first. + + + +2) THE PRIMITIVES + +2.0 Generic Flags + + Each primitive type has a set of flags associated with it which +allow the driver to tell XAA what the hardware limitations are. +The common ones are as follows: + +/* Foreground, Background, rop and planemask restrictions */ + + GXCOPY_ONLY + + This indicates that the accelerator only supports GXcopy + for the particular primitive. + + ROP_NEEDS_SOURCE + + This indicates that the accelerator doesn't supports a + particular primitive with rops that don't involve the source. + These rops are GXclear, GXnoop, GXinvert and GXset. If neither + this flag nor GXCOPY_ONLY is defined, it is assumed that the + accelerator supports all 16 raster operations (rops) for that + primitive. + + NO_PLANEMASK + + This indicates that the accelerator does not support a hardware + write planemask for the particular primitive. + + RGB_EQUAL + + This indicates that the particular primitive requires the red, + green and blue bytes of the foreground color (and background color, + if applicable) to be equal. This is useful for 24bpp when a graphics + coprocessor is used in 8bpp mode, which is not uncommon in older + hardware since some have no support for or only limited support for + acceleration at 24bpp. This way, many operations will be accelerated + for the common case of "grayscale" colors. This flag should only + be used in 24bpp. + + In addition to the common ones listed above which are possible for +nearly all primitives, each primitive may have its own flags specific +to that primitive. If such flags exist they are documented in the +descriptions of those primitives below. + + + + +2.1 Screen to Screen Copies + + The SetupFor and Subsequent ScreenToScreenCopy functions provide + an interface for copying rectangular areas from video memory to + video memory. To accelerate this primitive the driver should + provide both the SetupFor and Subsequent functions and indicate + the hardware restrictions via the ScreenToScreenCopyFlags. The + NO_PLANEMASK, GXCOPY_ONLY and ROP_NEEDS_SOURCE flags as described + in Section 2.0 are valid as well as the following: + + NO_TRANSPARENCY + + This indicates that the accelerator does not support skipping + of color keyed pixels when copying from the source to the destination. + + TRANSPARENCY_GXCOPY_ONLY + + This indicates that the accelerator supports skipping of color keyed + pixels only when the rop is GXcopy. + + ONLY_LEFT_TO_RIGHT_BITBLT + + This indicates that the hardware only accepts blitting when the + x direction is positive. + + ONLY_TWO_BITBLT_DIRECTIONS + + This indicates that the hardware can only cope with blitting when + the direction of x is the same as the direction in y. + + +void SetupForScreenToScreenCopy( ScrnInfoPtr pScrn, + int xdir, int ydir, + int rop, + unsigned int planemask, + int trans_color ) + + When this is called, SubsequentScreenToScreenCopy will be called + one or more times directly after. If ydir is 1, then the accelerator + should copy starting from the top (minimum y) of the source and + proceed downward. If ydir is -1, then the accelerator should copy + starting from the bottom of the source (maximum y) and proceed + upward. If xdir is 1, then the accelerator should copy each + y scanline starting from the leftmost pixel of the source. If + xdir is -1, it should start from the rightmost pixel. + If trans_color is not -1 then trans_color indicates that the + accelerator should not copy pixels with the color trans_color + from the source to the destination, but should skip them. + Trans_color is always -1 if the NO_TRANSPARENCY flag is set. + + +void SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, + int x1, int y1, + int x2, int y2, + int width, int height) + + Copy a rectangle "width" x "height" from the source (x1,y1) to the + destination (x2,y2) using the parameters passed by the last + SetupForScreenToScreenCopy call. (x1,y1) and (x2,y2) always denote + the upper left hand corners of the source and destination regardless + of which xdir and ydir values are given by SetupForScreenToScreenCopy. + + + +2.2 Solid Fills + + The SetupFor and Subsequent SolidFill(Rect/Trap) functions provide + an interface for filling rectangular areas of the screen with a + foreground color. To accelerate this primitive the driver should + provide both the SetupForSolidFill and SubsequentSolidFillRect + functions and indicate the hardware restrictions via the SolidFillFlags. + The driver may optionally provide a SubsequentSolidFillTrap if + it is capable of rendering the primitive correctly. + The GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags + as described in Section 2.0 are valid. + + +void SetupForSolidFill(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) + + SetupForSolidFill indicates that any combination of the following + may follow it. + + SubsequentSolidFillRect + SubsequentSolidFillTrap + + + +void SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) + + Fill a rectangle of dimensions "w" by "h" with origin at (x,y) + using the color, rop and planemask given by the last + SetupForSolidFill call. + +void SubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR) + + These parameters describe a trapezoid via a version of + Bresenham's parameters. "y" is the top line. "h" is the + number of spans to be filled in the positive Y direction. + "left" and "right" indicate the starting X values of the + left and right edges. dy/dx describes the edge slope. + These are not the deltas between the beginning and ending + points on an edge. They merely describe the slope. "e" is + the initial error term. It's the relationships between dx, + dy and e that define the edge. + If your engine does not do bresenham trapezoids or does + not allow the programmer to specify the error term then + you are not expected to be able to accelerate them. + + +2.3 Solid Lines + + XAA provides an interface for drawing thin lines. In order to + draw X lines correctly a high degree of accuracy is required. + This usually limits line acceleration to hardware which has a + Bresenham line engine, though depending on the algorithm used, + other line engines may come close if they accept 16 bit line + deltas. XAA has both a Bresenham line interface and a two-point + line interface for drawing lines of arbitrary orientation. + Additionally there is a SubsequentSolidHorVertLine which will + be used for all horizontal and vertical lines. Horizontal and + vertical lines are handled separately since hardware that doesn't + have a line engine (or has one that is unusable due to precision + problems) can usually draw these lines by some other method such + as drawing them as thin rectangles. Even for hardware that can + draw arbitrary lines via the Bresenham or two-point interfaces, + the SubsequentSolidHorVertLine is used for horizontal and vertical + lines since most hardware is able to render the horizontal lines + and sometimes the vertical lines faster by other methods (Hint: + try rendering horizontal lines as flattened rectangles). If you have + not provided a SubsequentSolidHorVertLine but you have provided + Bresenham or two-point lines, a SubsequentSolidHorVertLine function + will be supplied for you. + + The flags field associated with Solid Lines is SolidLineFlags and + the GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags as + described in Section 2.0 are valid restrictions. + + Some line engines have line biases hardcoded to comply with + Microsoft line biasing rules. A tell-tale sign of this is the + hardware lines not matching the software lines in the zeroth and + fourth octants. The driver can set the flag: + + MICROSOFT_ZERO_LINE_BIAS + + in the AccelInfoRec.Flags field to adjust the software lines to + match the hardware lines. This is in the generic flags field + rather than the SolidLineFlags since this flag applies to all + software zero-width lines on the screen and not just the solid ones. + + +void SetupForSolidLine(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) + + SetupForSolidLine indicates that any combination of the following + may follow it. + + SubsequentSolidBresenhamLine + SubsequentSolidTwoPointLine + SubsequentSolidHorVertLine + + +void SubsequentSolidHorVertLine( ScrnInfoPtr pScrn, + int x, int y, int len, int dir ) + + All vertical and horizontal solid thin lines are rendered with + this function. The line starts at coordinate (x,y) and extends + "len" pixels inclusive. In the direction indicated by "dir." + The direction is either DEGREES_O or DEGREES_270. That is, it + always extends to the right or down. + + + +void SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, + int x1, int y1, int x2, int y2, int flags) + + Draw a line from (x1,y1) to (x2,y2). If the flags field contains + the flag OMIT_LAST, the last pixel should not be drawn. Otherwise, + the pixel at (x2,y2) should be drawn. + + If you use the TwoPoint line interface there is a good possibility + that your line engine has hard-coded line biases that do not match + the default X zero-width lines. If so, you may need to set the + MICROSOFT_ZERO_LINE_BIAS flag described above. Note that since + any vertex in the 16-bit signed coordinate system is valid, your + line engine is expected to handle 16-bit values if you have hardware + line clipping enabled. If your engine cannot handle 16-bit values, + you should not use hardware line clipping. + + +void SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, + int x, int y, int major, int minor, int err, int len, int octant) + + "X" and "y" are the starting point of the line. "Major" and "minor" + are the major and minor step constants. "Err" is the initial error + term. "Len" is the number of pixels to be drawn (inclusive). "Octant" + can be any combination of the following flags OR'd together: + + Y_MAJOR Y is the major axis (X otherwise) + X_DECREASING The line is drawn from right to left + Y_DECREASING The line is drawn from bottom to top + + The major, minor and err terms are the "raw" Bresenham parameters + consistent with a line engine that does: + + e = err; + while(len--) { + DRAW_POINT(x,y); + e += minor; + if(e >= 0) { + e -= major; + TAKE_ONE_STEP_ALONG_MINOR_AXIS; + } + TAKE_ONE_STEP_ALONG_MAJOR_AXIS; + } + + IBM 8514 style Bresenham line interfaces require their parameters + modified in the following way: + + Axial = minor; + Diagonal = minor - major; + Error = minor + err; + +SolidBresenhamLineErrorTermBits + + This field allows the driver to tell XAA how many bits large its + Bresenham parameter registers are. Many engines have registers that + only accept 12 or 13 bit Bresenham parameters, and the parameters + for clipped lines may overflow these if they are not scaled down. + If this field is not set, XAA will assume the engine can accomodate + 16 bit parameters, otherwise, it will scale the parameters to the + size specified. + + +2.4 Dashed Lines + + The same degree of accuracy required by the solid lines is required + for drawing dashed lines as well. The dash pattern itself is a + buffer of binary data where ones are expanded into the foreground + color and zeros either correspond to the background color or + indicate transparency depending on whether or not DoubleDash or + OnOffDashes are being drawn. + + The flags field associated with dashed Lines is DashedLineFlags and + the GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags as + described in Section 2.0 are valid restrictions. Additionally, the + following flags are valid: + + NO_TRANSPARENCY + + This indicates that the driver cannot support dashed lines + with transparent backgrounds (OnOffDashes). + + TRANSPARENCY_ONLY + + This indicates that the driver cannot support dashes with + both a foreground and background color (DoubleDashes). + + LINE_PATTERN_POWER_OF_2_ONLY + + This indicates that only patterns with a power of 2 length + can be accelerated. + + LINE_PATTERN_LSBFIRST_MSBJUSTIFIED + LINE_PATTERN_LSBFIRST_LSBJUSTIFIED + LINE_PATTERN_MSBFIRST_MSBJUSTIFIED + LINE_PATTERN_MSBFIRST_LSBJUSTIFIED + + These describe how the line pattern should be packed. + The pattern buffer is DWORD padded. LSBFIRST indicates + that the pattern runs from the LSB end to the MSB end. + MSBFIRST indicates that the pattern runs from the MSB end + to the LSB end. When the pattern does not completely fill + the DWORD padded buffer, the pattern will be justified + towards the MSB or LSB end based on the flags above. + + + The following field indicates the maximum length dash pattern that + should be accelerated. + + int DashPatternMaxLength + + +void SetupForDashedLine(ScrnInfoPtr pScrn, + int fg, int bg, int rop, unsigned int planemask, + int length, unsigned char *pattern) + + + SetupForDashedLine indicates that any combination of the following + may follow it. + + SubsequentDashedBresenhamLine + SubsequentDashedTwoPointLine + + If "bg" is -1, then the background (pixels corresponding to clear + bits in the pattern) should remain unmodified. "Bg" indicates the + background color otherwise. "Length" indicates the length of + the pattern in bits and "pattern" points to the DWORD padded buffer + holding the pattern which has been packed according to the flags + set above. + + +void SubsequentDashedTwoPointLine( ScrnInfoPtr pScrn, + int x1, int y1, int x2, int y2, int flags, int phase) + +void SubsequentDashedBresenhamLine(ScrnInfoPtr pScrn, + int x1, int y1, int major, int minor, int err, int len, int octant, + int phase) + + These are the same as the SubsequentSolidTwoPointLine and + SubsequentBresenhamLine functions except for the addition + of the "phase" field which indicates the offset into the dash + pattern that the pixel at (x1,y1) corresponds to. + + As with the SubsequentBresenhamLine, there is an + + int DashedBresenhamLineErrorTermBits + + field which indicates the size of the error term registers + used with dashed lines. This is usually the same value as + the field for the solid lines (because it's usually the same + register). + + + +2.5 Color Expansion Fills + + When filling a color expansion rectangle, the accelerator + paints each pixel depending on whether or not a bit in a + corresponding bitmap is set or clear. Opaque expansions are + when a set bit corresponds to the foreground color and a clear + bit corresponds to the background color. A transparent expansion + is when a set bit corresponds to the foreground color and a + clear bit indicates that the pixel should remain unmodified. + + The graphics accelerator usually has access to the source + bitmap in one of two ways: 1) the bitmap data is sent serially + to the accelerator by the CPU through some memory mapped aperture + or 2) the accelerator reads the source bitmap out of offscreen + video memory. Some types of primitives are better suited towards + one method or the other. Type 2 is useful for reusable patterns + such as stipples which can be cached in offscreen memory. The + aperature method can be used for stippling but the CPU must pass + the data across the bus each time a stippled fill is to be performed. + For expanding 1bpp client pixmaps or text strings to the screen, + the aperature method is usually superior because the intermediate + copy in offscreen memory needed by the second method would only be + used once. Unfortunately, many accelerators can only do one of these + methods and not both. + + XAA provides both ScreenToScreen and CPUToScreen color expansion + interfaces for doing color expansion fills. The ScreenToScreen + functions can only be used with hardware that supports reading + of source bitmaps from offscreen video memory, and these are only + used for cacheable patterns such as stipples. There are two + variants of the CPUToScreen routines - a direct method intended + for hardware that has a transfer aperature, and an indirect method + intended for hardware without transfer aperatures or hardware + with unusual transfer requirements. Hardware that can only expand + bitmaps from video memory should supply ScreenToScreen routines + but also ScanlineCPUToScreen (indirect) routines to optimize transfers + of non-cacheable data. Hardware that can only accept source bitmaps + through an aperature should supply CPUToScreen (or ScanlineCPUToScreen) + routines. Hardware that can do both should provide both ScreenToScreen + and CPUToScreen routines. + + For both ScreenToScreen and CPUToScreen interfaces, the GXCOPY_ONLY, + ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags described in + Section 2.0 are valid as well as the following: + + /* bit order requirements (one of these must be set) */ + + BIT_ORDER_IN_BYTE_LSBFIRST + + This indicates that least significant bit in each byte of the source + data corresponds to the leftmost of that block of 8 pixels. This + is the prefered format. + + BIT_ORDER_IN_BYTE_MSBFIRST + + This indicates that most significant bit in each byte of the source + data corresponds to the leftmost of that block of 8 pixels. + + /* transparency restrictions */ + + NO_TRANSPARENCY + + This indicates that the accelerator cannot do a transparent expansion. + + TRANSPARENCY_ONLY + + This indicates that the accelerator cannot do an opaque expansion. + In cases where where the background needs to be filled, XAA will + render the primitive in two passes when using the CPUToScreen + interface, but will not do so with the ScreenToScreen interface + since that would require caching of two patterns. Some + ScreenToScreen hardware may be able to render two passes at the + driver level and remove the TRANSPARENCY_ONLY restriction if + it can render pixels corresponding to the zero bits. + + + +2.5.1 Screen To Screen Color Expansion + + The ScreenToScreenColorExpandFill routines provide an interface + for doing expansion blits from source patterns stored in offscreen + video memory. + + void SetupForScreenToScreenColorExpandFill (ScrnInfoPtr pScrn, + int fg, int bg, + int rop, unsigned int planemask) + + + Ones in the source bitmap will correspond to the fg color. + Zeros in the source bitmap will correspond to the bg color + unless bg = -1. In that case the pixels corresponding to the + zeros in the bitmap shall be left unmodified by the accelerator. + + For hardware that doesn't allow an easy implementation of skipleft, the + driver can replace CacheMonoStipple function with one that stores multiple + rotated copies of the stipple and select between them. In this case the + driver should set CacheColorExpandDensity to tell XAA how many copies of + the pattern are stored in the width of a cache slot. For instance if the + hardware can specify the starting address in bytes, then 8 rotated copies + of the stipple are needed and CacheColorExpandDensity should be set to 8. + + void SubsequentScreenToScreenColorExpandFill( ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int srcx, int srcy, int offset ) + + + Fill a rectangle "w" x "h" at location (x,y). The source pitch + between scanlines is the framebuffer pitch (pScrn->displayWidth + pixels) and srcx and srcy indicate the start of the source pattern + in units of framebuffer pixels. "Offset" indicates the bit offset + into the pattern that corresponds to the pixel being painted at + "x" on the screen. Some hardware accepts source coordinates in + units of bits which makes implementation of the offset trivial. + In that case, the bit address of the source bit corresponding to + the pixel painted at (x,y) would be: + + (srcy * pScrn->displayWidth + srcx) * pScrn->bitsPerPixel + offset + + It should be noted that the offset assumes LSBFIRST hardware. + For MSBFIRST hardware, the driver may need to implement the + offset by bliting only from byte boundaries and hardware clipping. + + + +2.5.2 CPU To Screen Color Expansion + + + The CPUToScreenColorExpandFill routines provide an interface for + doing expansion blits from source patterns stored in system memory. + There are two varieties of this primitive, a CPUToScreenColorExpandFill + and a ScanlineCPUToScreenColorExpandFill. With the + CPUToScreenColorExpandFill method, the source data is sent serially + through a memory mapped aperature. With the Scanline version, the + data is rendered scanline at a time into intermediate buffers with + a call to SubsequentColorExpandScanline following each scanline. + + These two methods have separate flags fields, the + CPUToScreenColorExpandFillFlags and ScanlineCPUToScreenColorExpandFillFlags + respectively. Flags specific to one method or the other are described + in sections 2.5.2.1 and 2.5.2.2 but for both cases the bit order and + transparency restrictions listed at the beginning of section 2.5 are + valid as well as the following: + + /* clipping (optional) */ + + LEFT_EDGE_CLIPPING + + This indicates that the accelerator supports omission of up to + 31 pixels on the left edge of the rectangle to be filled. This + is beneficial since it allows transfer of the source bitmap to + always occur from DWORD boundaries. + + LEFT_EDGE_CLIPPING_NEGATIVE_X + + This flag indicates that the accelerator can render color expansion + rectangles even if the value of x origin is negative (off of + the screen on the left edge). + + /* misc */ + + TRIPLE_BITS_24BPP + + When enabled (must be in 24bpp mode), color expansion functions + are expected to require three times the amount of bits to be + transferred so that 24bpp grayscale colors can be used with color + expansion in 8bpp coprocessor mode. Each bit is expanded to 3 + bits when writing the monochrome data. + + + 2.5.1 The Direct Method + + + Using the direct method of color expansion XAA will send all + bitmap data to the accelerator serially through an memory mapped + transfer window defined by the following two fields: + + unsigned char *ColorExpandBase + + This indicates the memory address of the beginning of the aperture. + + int ColorExpandRange + + This indicates the size in bytes of the aperture. + + The driver should specify how the transfered data should be padded. + There are options for both the padding of each Y scanline and for the + total transfer to the aperature. + One of the following two flags must be set: + + CPU_TRANSFER_PAD_DWORD + + This indicates that the total transfer (sum of all scanlines) sent + to the aperature must be DWORD padded. This is the default behavior. + + CPU_TRANSFER_PAD_QWORD + + This indicates that the total transfer (sum of all scanlines) sent + to the aperature must be QWORD padded. With this set, XAA will send + an extra DWORD to the aperature when needed to ensure that only + an even number of DWORDs are sent. + + And then there are the flags for padding of each scanline: + + SCANLINE_PAD_DWORD + + This indicates that each Y scanline should be DWORD padded. + This is the only option available and is the default. + + Finally, there is the CPU_TRANSFER_BASE_FIXED flag which indicates + that the aperture is a single register rather than a range of + registers, and XAA should write all of the data to the first DWORD. + If the ColorExpandRange is not large enough to accomodate scanlines + the width of the screen, this option will be forced. That is, the + ColorExpandRange must be: + + ((virtualX + 31)/32) * 4 bytes or more. + + ((virtualX + 62)/32 * 4) if LEFT_EDGE_CLIPPING_NEGATIVE_X is set. + + If the TRIPLE_BITS_24BPP flag is set, the required area should be + multiplied by three. + + +void SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask) + + + + Ones in the source bitmap will correspond to the fg color. + Zeros in the source bitmap will correspond to the bg color + unless bg = -1. In that case the pixels corresponding to the + zeros in the bitmap shall be left unmodified by the accelerator. + + +void SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft ) + + When this function is called, the accelerator should be setup + to fill a rectangle of dimension "w" by "h" with origin at (x,y) + in the fill style prescribed by the last call to + SetupForCPUToScreenColorExpandFill. XAA will pass the data to + the aperture immediately after this function is called. If the + skipleft is non-zero (and LEFT_EDGE_CLIPPING has been enabled), then + the accelerator _should_not_ render skipleft pixels on the leftmost + edge of the rectangle. Some engines have an alignment feature + like this built in, some others can do this using a clipping + window. + + It can be arranged for XAA to call Sync() after it is through + calling the Subsequent function by setting SYNC_AFTER_COLOR_EXPAND + in the CPUToScreenColorExpandFillFlags. This can provide the driver + with an oportunity to reset a clipping window if needed. + + +2.5.2 The Indirect Method + + Using the indirect method, XAA will render the bitmap data scanline + at a time to one or more buffers. These buffers may be memory + mapped apertures or just intermediate storage. + + int NumScanlineColorExpandBuffers + + This indicates the number of buffers available. + + unsigned char **ScanlineColorExpandBuffers + + This is an array of pointers to the memory locations of each buffer. + Each buffer is expected to be large enough to accommodate scanlines + the width of the screen. That is: + + ((virtualX + 31)/32) * 4 bytes or more. + + ((virtualX + 62)/32 * 4) if LEFT_EDGE_CLIPPING_NEGATIVE_X is set. + + Scanlines are always DWORD padded. + If the TRIPLE_BITS_24BPP flag is set, the required area should be + multiplied by three. + + +void SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask) + + Ones in the source bitmap will correspond to the fg color. + Zeros in the source bitmap will correspond to the bg color + unless bg = -1. In that case the pixels corresponding to the + zeros in the bitmap shall be left unmodified by the accelerator. + + +void SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft ) + +void SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) + + + When SubsequentScanlineCPUToScreenColorExpandFill is called, XAA + will begin transfering the source data scanline at a time, calling + SubsequentColorExpandScanline after each scanline. If more than + one buffer is available, XAA will cycle through the buffers. + Subsequent scanlines will use the next buffer and go back to the + buffer 0 again when the last buffer is reached. The index into + the ScanlineColorExpandBuffers array is presented as "bufno" + with each SubsequentColorExpandScanline call. + + The skipleft field is the same as for the direct method. + + The indirect method can be use to send the source data directly + to a memory mapped aperture represented by a single color expand + buffer, scanline at a time, but more commonly it is used to place + the data into offscreen video memory so that the accelerator can + blit it to the visible screen from there. In the case where the + accelerator permits rendering into offscreen video memory while + the accelerator is active, several buffers can be used so that + XAA can be placing source data into the next buffer while the + accelerator is blitting the current buffer. For cases where + the accelerator requires some special manipulation of the source + data first, the buffers can be in system memory. The CPU can + manipulate these buffers and then send the data to the accelerator. + + + +2.6 8x8 Mono Pattern Fills + + XAA provides support for two types of 8x8 hardware patterns - + "Mono" patterns and "Color" patterns. Mono pattern data is + 64 bits of color expansion data with ones indicating the + foreground color and zeros indicating the background color. + The source bitmaps for the 8x8 mono patterns can be presented + to the graphics accelerator in one of two ways. They can be + passed as two DWORDS to the 8x8 mono pattern functions or + they can be cached in offscreen memory and their locations + passed to the 8x8 mono pattern functions. In addition to the + GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags + defined in Section 2.0, the following are defined for the + Mono8x8PatternFillFlags: + + HARDWARE_PATTERN_PROGRAMMED_BITS + + This indicates that the 8x8 patterns should be packed into two + DWORDS and passed to the 8x8 mono pattern functions. The default + behavior is to cache the patterns in offscreen video memory and + pass the locations of these patterns to the functions instead. + The pixmap cache must be enabled for the default behavior (8x8 + pattern caching) to work. See Section 3 for how to enable the + pixmap cache. The pixmap cache is not necessary for + HARDWARE_PATTERN_PROGRAMMED_BITS. + + HARDWARE_PATTERN_PROGRAMMED_ORIGIN + + If the hardware supports programmable pattern offsets then + this option should be set. See the table below for further + infomation. + + HARDWARE_PATTERN_SCREEN_ORIGIN + + Some hardware wants the pattern offset specified with respect to the + upper left-hand corner of the primitive being drawn. Other hardware + needs the option HARDWARE_PATTERN_SCREEN_ORIGIN set to indicate that + all pattern offsets should be referenced to the upper left-hand + corner of the screen. HARDWARE_PATTERN_SCREEN_ORIGIN is preferable + since this is more natural for the X-Window system and offsets will + have to be recalculated for each Subsequent function otherwise. + + BIT_ORDER_IN_BYTE_MSBFIRST + BIT_ORDER_IN_BYTE_LSBFIRST + + As with other color expansion routines this indicates whether the + most or the least significant bit in each byte from the pattern is + the leftmost on the screen. + + TRANSPARENCY_ONLY + NO_TRANSPARENCY + + This means the same thing as for the color expansion rect routines + except that for TRANSPARENCY_ONLY XAA will not render the primitive + in two passes since this is more easily handled by the driver. + It is recommended that TRANSPARENCY_ONLY hardware handle rendering + of opaque patterns in two passes (the background can be filled as + a rectangle in GXcopy) in the Subsequent function so that the + TRANSPARENCY_ONLY restriction can be removed. + + + + Additional information about cached patterns... + For the case where HARDWARE_PATTERN_PROGRAMMED_BITS is not set and + the pattern must be cached in offscreen memory, the first pattern + starts at the cache slot boundary which is set by the + CachePixelGranularity field used to configure the pixmap cache. + One should ensure that the CachePixelGranularity reflects any + alignment restrictions that the accelerator may put on 8x8 pattern + storage locations. When HARDWARE_PATTERN_PROGRAMMED_ORIGIN is set + there is only one pattern stored. When this flag is not set, + all 64 pre-rotated copies of the pattern are cached in offscreen memory. + The MonoPatternPitch field can be used to specify the X position pixel + granularity that each of these patterns must align on. If the + MonoPatternPitch is not supplied, the patterns will be densely packed + within the cache slot. The behavior of the default XAA 8x8 pattern + caching mechanism to store all 8x8 patterns linearly in video memory. + If the accelerator needs the patterns stored in a more unusual fashion, + the driver will need to provide its own 8x8 mono pattern caching + routines for XAA to use. + + The following table describes the meanings of the "patx" and "paty" + fields in both the SetupFor and Subsequent functions. + + With HARDWARE_PATTERN_SCREEN_ORIGIN + ----------------------------------- + + HARDWARE_PATTERN_PROGRAMMED_BITS and HARDWARE_PATTERN_PROGRAMMED_ORIGIN + + SetupFor: patx and paty are the first and second DWORDS of the + 8x8 mono pattern. + + Subsequent: patx and paty are the x,y offset into that pattern. + All Subsequent calls will have the same offset in + the case of HARDWARE_PATTERN_SCREEN_ORIGIN so only + the offset specified by the first Subsequent call + after a SetupFor call will need to be observed. + + HARDWARE_PATTERN_PROGRAMMED_BITS only + + SetupFor: patx and paty hold the first and second DWORDS of + the 8x8 mono pattern pre-rotated to match the desired + offset. + + Subsequent: These just hold the same patterns and can be ignored. + + HARDWARE_PATTERN_PROGRAMMED_ORIGIN only + + SetupFor: patx and paty hold the x,y coordinates of the offscreen + memory location where the 8x8 pattern is stored. The + bits are stored linearly in memory at that location. + + Subsequent: patx and paty hold the offset into the pattern. + All Subsequent calls will have the same offset in + the case of HARDWARE_PATTERN_SCREEN_ORIGIN so only + the offset specified by the first Subsequent call + after a SetupFor call will need to be observed. + + Neither programmed bits or origin + + SetupFor: patx and paty hold the x,y coordinates of the offscreen + memory location where the pre-rotated 8x8 pattern is + stored. + + Subsequent: patx and paty are the same as in the SetupFor function + and can be ignored. + + + Without HARDWARE_PATTERN_SCREEN_ORIGIN + -------------------------------------- + + HARDWARE_PATTERN_PROGRAMMED_BITS and HARDWARE_PATTERN_PROGRAMMED_ORIGIN + + SetupFor: patx and paty are the first and second DWORDS of the + 8x8 mono pattern. + + Subsequent: patx and paty are the x,y offset into that pattern. + + HARDWARE_PATTERN_PROGRAMMED_BITS only + + SetupFor: patx and paty holds the first and second DWORDS of + the unrotated 8x8 mono pattern. This can be ignored. + + Subsequent: patx and paty hold the rotated 8x8 pattern to be + rendered. + + HARDWARE_PATTERN_PROGRAMMED_ORIGIN only + + SetupFor: patx and paty hold the x,y coordinates of the offscreen + memory location where the 8x8 pattern is stored. The + bits are stored linearly in memory at that location. + + Subsequent: patx and paty hold the offset into the pattern. + + Neither programmed bits or origin + + SetupFor: patx and paty hold the x,y coordinates of the offscreen + memory location where the unrotated 8x8 pattern is + stored. This can be ignored. + + Subsequent: patx and paty hold the x,y coordinates of the + rotated 8x8 pattern to be rendered. + + + +void SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, + int fg, int bg, int rop, unsigned int planemask) + + SetupForMono8x8PatternFill indicates that any combination of the + following may follow it. + + SubsequentMono8x8PatternFillRect + SubsequentMono8x8PatternFillTrap + + The fg, bg, rop and planemask fields have the same meaning as the + ones used for the other color expansion routines. Patx's and paty's + meaning can be determined from the table above. + + +void SubsequentMono8x8PatternFillRect( ScrnInfoPtr pScrn, + int patx, int paty, int x, int y, int w, int h) + + Fill a rectangle of dimensions "w" by "h" with origin at (x,y) + using the parameters give by the last SetupForMono8x8PatternFill + call. The meanings of patx and paty can be determined by the + table above. + +void SubsequentMono8x8PatternFillTrap( ScrnInfoPtr pScrn, + int patx, int paty, int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR ) + + The meanings of patx and paty can be determined by the table above. + The rest of the fields have the same meanings as those in the + SubsequentSolidFillTrap function. + + + +2.7 8x8 Color Pattern Fills + + 8x8 color pattern data is 64 pixels of full color data that + is stored linearly in offscreen video memory. 8x8 color patterns + are useful as a substitute for 8x8 mono patterns when tiling, + doing opaque stipples, or in the case where transperency is + supported, regular stipples. 8x8 color pattern fills also have + the additional benefit of being able to tile full color 8x8 + patterns instead of just 2 color ones like the mono patterns. + However, full color 8x8 patterns aren't used very often in the + X Window system so you might consider passing this primitive + by if you already can do mono patterns, especially if they + require alot of cache area. Color8x8PatternFillFlags is + the flags field for this primitive and the GXCOPY_ONLY, + ROP_NEEDS_SOURCE and NO_PLANEMASK flags as described in + Section 2.0 are valid as well as the following: + + + HARDWARE_PATTERN_PROGRAMMED_ORIGIN + + If the hardware supports programmable pattern offsets then + this option should be set. + + HARDWARE_PATTERN_SCREEN_ORIGIN + + Some hardware wants the pattern offset specified with respect to the + upper left-hand corner of the primitive being drawn. Other hardware + needs the option HARDWARE_PATTERN_SCREEN_ORIGIN set to indicate that + all pattern offsets should be referenced to the upper left-hand + corner of the screen. HARDWARE_PATTERN_SCREEN_ORIGIN is preferable + since this is more natural for the X-Window system and offsets will + have to be recalculated for each Subsequent function otherwise. + + NO_TRANSPARENCY + TRANSPARENCY_GXCOPY_ONLY + + These mean the same as for the ScreenToScreenCopy functions. + + + The following table describes the meanings of patx and paty passed + to the SetupFor and Subsequent fields: + + HARDWARE_PATTERN_PROGRAMMED_ORIGIN && HARDWARE_PATTERN_SCREEN_ORIGIN + + SetupFor: patx and paty hold the x,y location of the unrotated + pattern. + + Subsequent: patx and paty hold the pattern offset. For the case + of HARDWARE_PATTERN_SCREEN_ORIGIN all Subsequent calls + have the same offset so only the first call will need + to be observed. + + + HARDWARE_PATTERN_PROGRAMMED_ORIGIN only + + SetupFor: patx and paty hold the x,y location of the unrotated + pattern. + + Subsequent: patx and paty hold the pattern offset. + + HARDWARE_PATTERN_SCREEN_ORIGIN + + SetupFor: patx and paty hold the x,y location of the rotated pattern. + + Subsequent: patx and paty hold the same location as the SetupFor + function so these can be ignored. + + neither flag + + SetupFor: patx and paty hold the x,y location of the unrotated + pattern. This can be ignored. + + Subsequent: patx and paty hold the x,y location of the rotated + pattern. + + Additional information about cached patterns... + All 8x8 color patterns are cached in offscreen video memory so + the pixmap cache must be enabled to use them. The first pattern + starts at the cache slot boundary which is set by the + CachePixelGranularity field used to configure the pixmap cache. + One should ensure that the CachePixelGranularity reflects any + alignment restrictions that the accelerator may put on 8x8 pattern + storage locations. When HARDWARE_PATTERN_PROGRAMMED_ORIGIN is set + there is only one pattern stored. When this flag is not set, + all 64 rotations off the pattern are accessible but it is assumed + that the accelerator is capable of accessing data stored on 8 + pixel boundaries. If the accelerator has stricter alignment + requirements than this the dirver will need to provide its own + 8x8 color pattern caching routines. + + +void SetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, + int rop, unsigned int planemask, int trans_color) + + SetupForColor8x8PatternFill indicates that any combination of the + following may follow it. + + SubsequentColor8x8PatternFillRect + SubsequentColor8x8PatternFillTrap (not implemented yet) + + For the meanings of patx and paty, see the table above. Trans_color + means the same as for the ScreenToScreenCopy functions. + + + +void SubsequentColor8x8PatternFillRect( ScrnInfoPtr pScrn, + int patx, int paty, int x, int y, int w, int h) + + Fill a rectangle of dimensions "w" by "h" with origin at (x,y) + using the parameters give by the last SetupForColor8x8PatternFill + call. The meanings of patx and paty can be determined by the + table above. + +void SubsequentColor8x8PatternFillTrap( ScrnInfoPtr pScrn, + int patx, int paty, int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR ) + + For the meanings of patx and paty, see the table above. + The rest of the fields have the same meanings as those in the + SubsequentSolidFillTrap function. + + + +2.8 Image Writes + + XAA provides a mechanism for transfering full color pixel data from + system memory to video memory through the accelerator. This is + useful for dealing with alignment issues and performing raster ops + on the data when writing it to the framebuffer. As with color + expansion rectangles, there is a direct and indirect method. The + direct method sends all data through a memory mapped aperature. + The indirect method sends the data to an intermediated buffer scanline + at a time. + + The direct and indirect methods have separate flags fields, the + ImageWriteFlags and ScanlineImageWriteFlags respectively. + Flags specific to one method or the other are described in sections + 2.8.1 and 2.8.2 but for both cases the GXCOPY_ONLY, ROP_NEEDS_SOURCE + and NO_PLANEMASK flags described in Section 2.0 are valid as well as + the following: + + NO_GXCOPY + + In order to have accelerated image transfers faster than the + software versions for GXcopy, the engine needs to support clipping, + be using the direct method and have a large enough image transfer + range so that CPU_TRANSFER_BASE_FIXED doesn't need to be set. + If these are not supported, then it is unlikely that transfering + the data through the accelerator will be of any advantage for the + simple case of GXcopy. In fact, it may be much slower. For such + cases it's probably best to set the NO_GXCOPY flag so that + Image writes will only be used for the more complicated rops. + + /* transparency restrictions */ + + NO_TRANSPARENCY + + This indicates that the accelerator does not support skipping + of color keyed pixels when copying from the source to the destination. + + TRANSPARENCY_GXCOPY_ONLY + + This indicates that the accelerator supports skipping of color keyed + pixels only when the rop is GXcopy. + + /* clipping (optional) */ + + LEFT_EDGE_CLIPPING + + This indicates that the accelerator supports omission of up to + 3 pixels on the left edge of the rectangle to be filled. This + is beneficial since it allows transfer from the source pixmap to + always occur from DWORD boundaries. + + LEFT_EDGE_CLIPPING_NEGATIVE_X + + This flag indicates that the accelerator can fill areas with + image write data even if the value of x origin is negative (off of + the screen on the left edge). + + +2.8.1 The Direct Method + + Using the direct method of ImageWrite XAA will send all + bitmap data to the accelerator serially through an memory mapped + transfer window defined by the following two fields: + + unsigned char *ImageWriteBase + + This indicates the memory address of the beginning of the aperture. + + int ImageWriteRange + + This indicates the size in bytes of the aperture. + + The driver should specify how the transfered data should be padded. + There are options for both the padding of each Y scanline and for the + total transfer to the aperature. + One of the following two flags must be set: + + CPU_TRANSFER_PAD_DWORD + + This indicates that the total transfer (sum of all scanlines) sent + to the aperature must be DWORD padded. This is the default behavior. + + CPU_TRANSFER_PAD_QWORD + + This indicates that the total transfer (sum of all scanlines) sent + to the aperature must be QWORD padded. With this set, XAA will send + an extra DWORD to the aperature when needed to ensure that only + an even number of DWORDs are sent. + + And then there are the flags for padding of each scanline: + + SCANLINE_PAD_DWORD + + This indicates that each Y scanline should be DWORD padded. + This is the only option available and is the default. + + Finally, there is the CPU_TRANSFER_BASE_FIXED flag which indicates + that the aperture is a single register rather than a range of + registers, and XAA should write all of the data to the first DWORD. + XAA will automatically select CPU_TRANSFER_BASE_FIXED if the + ImageWriteRange is not large enough to accomodate an entire scanline. + + +void SetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, + int trans_color, int bpp, int depth) + + If trans_color is not -1 then trans_color indicates the transparency + color key and pixels with color trans_color passed through the + aperature should not be transfered to the screen but should be + skipped. Bpp and depth indicate the bits per pixel and depth of + the source pixmap. Trans_color is always -1 if the NO_TRANSPARENCY + flag is set. + + +void SubsequentImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft) + + + Data passed through the aperature should be copied to a rectangle + of width "w" and height "h" with origin (x,y). If LEFT_EDGE_CLIPPING + has been enabled, skipleft will correspond to the number of pixels + on the left edge that should not be drawn. Skipleft is zero + otherwise. + + It can be arranged for XAA to call Sync() after it is through + calling the Subsequent functions by setting SYNC_AFTER_IMAGE_WRITE + in the ImageWriteFlags. This can provide the driver with an + oportunity to reset a clipping window if needed. + +2.8.2 The Indirect Method + + Using the indirect method, XAA will render the pixel data scanline + at a time to one or more buffers. These buffers may be memory + mapped apertures or just intermediate storage. + + int NumScanlineImageWriteBuffers + + This indicates the number of buffers available. + + unsigned char **ScanlineImageWriteBuffers + + This is an array of pointers to the memory locations of each buffer. + Each buffer is expected to be large enough to accommodate scanlines + the width of the screen. That is: + + pScrn->VirtualX * pScreen->bitsPerPixel/8 bytes or more. + + If LEFT_EDGE_CLIPPING_NEGATIVE_X is set, add an additional 4 + bytes to that requirement in 8 and 16bpp, 12 bytes in 24bpp. + + Scanlines are always DWORD padded. + +void SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int trans_color, + int bpp, int depth) + + If trans_color is not -1 then trans_color indicates the transparency + color key and pixels with color trans_color in the buffer should not + be transfered to the screen but should be skipped. Bpp and depth + indicate the bits per pixel and depth of the source bitmap. + Trans_color is always -1 if the NO_TRANSPARENCY flag is set. + + +void SubsequentImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft) + + +void SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) + + + When SubsequentImageWriteRect is called, XAA will begin + transfering the source data scanline at a time, calling + SubsequentImageWriteScanline after each scanline. If more than + one buffer is available, XAA will cycle through the buffers. + Subsequent scanlines will use the next buffer and go back to the + buffer 0 again when the last buffer is reached. The index into + the ScanlineImageWriteBuffers array is presented as "bufno" + with each SubsequentImageWriteScanline call. + + The skipleft field is the same as for the direct method. + + The indirect method can be use to send the source data directly + to a memory mapped aperture represented by a single image write + buffer, scanline at a time, but more commonly it is used to place + the data into offscreen video memory so that the accelerator can + blit it to the visible screen from there. In the case where the + accelerator permits rendering into offscreen video memory while + the accelerator is active, several buffers can be used so that + XAA can be placing source data into the next buffer while the + accelerator is blitting the current buffer. For cases where + the accelerator requires some special manipulation of the source + data first, the buffers can be in system memory. The CPU can + manipulate these buffers and then send the data to the accelerator. + + +2.9 Clipping + + XAA supports hardware clipping rectangles. To use clipping + in this way it is expected that the graphics accelerator can + clip primitives with verticies anywhere in the 16 bit signed + coordinate system. + +void SetClippingRectangle ( ScrnInfoPtr pScrn, + int left, int top, int right, int bottom) + +void DisableClipping (ScrnInfoPtr pScrn) + + When SetClippingRectangle is called, all hardware rendering + following it should be clipped to the rectangle specified + until DisableClipping is called. + + The ClippingFlags field indicates which operations this sort + of Set/Disable pairing can be used with. Any of the following + flags may be OR'd together. + + HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND + HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY + HARDWARE_CLIP_MONO_8x8_FILL + HARDWARE_CLIP_COLOR_8x8_FILL + HARDWARE_CLIP_SOLID_FILL + HARDWARE_CLIP_DASHED_LINE + HARDWARE_CLIP_SOLID_LINE + + + +3) XAA PIXMAP CACHE + + /* NOTE: XAA has no knowledge of framebuffer particulars so until + the framebuffer is able to render into offscreen memory, usage + of the pixmap cache requires that the driver provide ImageWrite + routines or a WritePixmap or WritePixmapToCache replacement so + that patterns can even be placed in the cache. + + ADDENDUM: XAA can now load the pixmap cache without requiring + that the driver supply an ImageWrite function, but this can + only be done on linear framebuffers. If you have a linear + framebuffer, set LINEAR_FRAMEBUFFER in the XAAInfoRec.Flags + field and XAA will then be able to upload pixmaps into the + cache without the driver providing functions to do so. + */ + + + The XAA pixmap cache provides a mechanism for caching of patterns + in offscreen video memory so that tiled fills and in some cases + stippling can be done by blitting the source patterns from offscreen + video memory. The pixmap cache also provides the mechanism for caching + of 8x8 color and mono hardware patterns. Any unused offscreen video + memory gets used for the pixmap cache and that information is + provided by the XFree86 Offscreen Memory Manager. XAA registers a + callback with the manager so that it can be informed of any changes + in the offscreen memory configuration. The driver writer does not + need to deal with any of this since it is all automatic. The driver + merely needs to initialize the Offscreen Memory Manager as described + in the DESIGN document and set the PIXMAP_CACHE flag in the + XAAInfoRec.Flags field. The Offscreen Memory Manager initialization + must occur before XAA is initialized or else pixmap cache + initialization will fail. + + PixmapCacheFlags is an XAAInfoRec field which allows the driver to + control pixmap cache behavior to some extent. Currently only one + flag is defined: + + DO_NOT_BLIT_STIPPLES + + This indicates that the stippling should not be done by blitting + from the pixmap cache. This does not apply to 8x8 pattern fills. + + + CachePixelGranularity is an optional field. If the hardware requires + that a 8x8 patterns have some particular pixel alignment it should + be reflected in this field. Ignoring this field or setting it to + zero or one means there are no alignment issues. + + +4) OFFSCREEN PIXMAPS + + XAA has the ability to store pixmap drawables in offscreen video + memory and render into them with full hardware acceleration. Placement + of pixmaps in the cache is done automatically on a first-come basis and + only if there is room. To enable this feature, set the OFFSCREEN_PIXMAPS + flag in the XAAInfoRec.Flags field. This is only available when a + ScreenToScreenCopy function is provided, when the Offscreen memory + manager has been initialized and when the LINEAR_FRAMEBUFFER flag is + also set. + + int maxOffPixWidth + int maxOffPixHeight + + These two fields allow the driver to limit the maximum dimensions + of an offscreen pixmap. If one of these is not set, it is assumed + that there is no limit on that dimension. Note that if an offscreen + pixmap with a particular dimension is allowed, then your driver will be + expected to render primitives as large as that pixmap. + +$XFree86: xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO,v 1.12 2000/04/12 14:44:42 tsi Exp $ diff --git a/xorg-server/hw/xfree86/xaa/l-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/l-xaaBitmap.c new file mode 100644 index 000000000..4b20dee13 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/l-xaaBitmap.c @@ -0,0 +1,2 @@ +#define LSBFIRST +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/l-xaaStipple.c b/xorg-server/hw/xfree86/xaa/l-xaaStipple.c new file mode 100644 index 000000000..91c52c778 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/l-xaaStipple.c @@ -0,0 +1,2 @@ +#define LSBFIRST +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/l-xaaTEGlyph.c b/xorg-server/hw/xfree86/xaa/l-xaaTEGlyph.c new file mode 100644 index 000000000..e58359cd2 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/l-xaaTEGlyph.c @@ -0,0 +1,2 @@ +#define LSBFIRST +#include "./xaaTEGlyph.c" diff --git a/xorg-server/hw/xfree86/xaa/l3-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/l3-xaaBitmap.c new file mode 100644 index 000000000..0c1fd552d --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/l3-xaaBitmap.c @@ -0,0 +1,3 @@ +#define LSBFIRST +#define TRIPLE_BITS +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/l3-xaaStipple.c b/xorg-server/hw/xfree86/xaa/l3-xaaStipple.c new file mode 100644 index 000000000..9a182c695 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/l3-xaaStipple.c @@ -0,0 +1,3 @@ +#define LSBFIRST +#define TRIPLE_BITS +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/lf-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/lf-xaaBitmap.c new file mode 100644 index 000000000..031407b9c --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/lf-xaaBitmap.c @@ -0,0 +1,3 @@ +#define LSBFIRST +#define FIXEDBASE +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/lf-xaaStipple.c b/xorg-server/hw/xfree86/xaa/lf-xaaStipple.c new file mode 100644 index 000000000..d91265890 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/lf-xaaStipple.c @@ -0,0 +1,3 @@ +#define LSBFIRST +#define FIXEDBASE +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/lf-xaaTEGlyph.c b/xorg-server/hw/xfree86/xaa/lf-xaaTEGlyph.c new file mode 100644 index 000000000..c578603f3 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/lf-xaaTEGlyph.c @@ -0,0 +1,3 @@ +#define LSBFIRST +#define FIXEDBASE +#include "./xaaTEGlyph.c" diff --git a/xorg-server/hw/xfree86/xaa/lf3-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/lf3-xaaBitmap.c new file mode 100644 index 000000000..0607a7390 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/lf3-xaaBitmap.c @@ -0,0 +1,4 @@ +#define LSBFIRST +#define TRIPLE_BITS +#define FIXEDBASE +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/lf3-xaaStipple.c b/xorg-server/hw/xfree86/xaa/lf3-xaaStipple.c new file mode 100644 index 000000000..af1698b99 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/lf3-xaaStipple.c @@ -0,0 +1,4 @@ +#define LSBFIRST +#define TRIPLE_BITS +#define FIXEDBASE +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/m-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/m-xaaBitmap.c new file mode 100644 index 000000000..d0e3cb33d --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/m-xaaBitmap.c @@ -0,0 +1,2 @@ +#define MSBFIRST +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/m-xaaStipple.c b/xorg-server/hw/xfree86/xaa/m-xaaStipple.c new file mode 100644 index 000000000..1ba789918 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/m-xaaStipple.c @@ -0,0 +1,2 @@ +#define MSBFIRST +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/m-xaaTEGlyph.c b/xorg-server/hw/xfree86/xaa/m-xaaTEGlyph.c new file mode 100644 index 000000000..521390c32 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/m-xaaTEGlyph.c @@ -0,0 +1,2 @@ +#define MSBFIRST +#include "./xaaTEGlyph.c" diff --git a/xorg-server/hw/xfree86/xaa/m3-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/m3-xaaBitmap.c new file mode 100644 index 000000000..7b4ce814d --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/m3-xaaBitmap.c @@ -0,0 +1,3 @@ +#define MSBFIRST +#define TRIPLE_BITS +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/m3-xaaStipple.c b/xorg-server/hw/xfree86/xaa/m3-xaaStipple.c new file mode 100644 index 000000000..eb2c83e8d --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/m3-xaaStipple.c @@ -0,0 +1,3 @@ +#define MSBFIRST +#define TRIPLE_BITS +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/mf-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/mf-xaaBitmap.c new file mode 100644 index 000000000..36075e65d --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/mf-xaaBitmap.c @@ -0,0 +1,3 @@ +#define MSBFIRST +#define FIXEDBASE +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/mf-xaaStipple.c b/xorg-server/hw/xfree86/xaa/mf-xaaStipple.c new file mode 100644 index 000000000..41b469c71 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/mf-xaaStipple.c @@ -0,0 +1,3 @@ +#define MSBFIRST +#define FIXEDBASE +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/mf-xaaTEGlyph.c b/xorg-server/hw/xfree86/xaa/mf-xaaTEGlyph.c new file mode 100644 index 000000000..3fd657b4b --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/mf-xaaTEGlyph.c @@ -0,0 +1,3 @@ +#define MSBFIRST +#define FIXEDBASE +#include "./xaaTEGlyph.c" diff --git a/xorg-server/hw/xfree86/xaa/mf3-xaaBitmap.c b/xorg-server/hw/xfree86/xaa/mf3-xaaBitmap.c new file mode 100644 index 000000000..630775c52 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/mf3-xaaBitmap.c @@ -0,0 +1,4 @@ +#define MSBFIRST +#define TRIPLE_BITS +#define FIXEDBASE +#include "./xaaBitmap.c" diff --git a/xorg-server/hw/xfree86/xaa/mf3-xaaStipple.c b/xorg-server/hw/xfree86/xaa/mf3-xaaStipple.c new file mode 100644 index 000000000..c9a86d008 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/mf3-xaaStipple.c @@ -0,0 +1,4 @@ +#define MSBFIRST +#define TRIPLE_BITS +#define FIXEDBASE +#include "./xaaStipple.c" diff --git a/xorg-server/hw/xfree86/xaa/s-xaaDashLine.c b/xorg-server/hw/xfree86/xaa/s-xaaDashLine.c new file mode 100644 index 000000000..5ad3deb92 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/s-xaaDashLine.c @@ -0,0 +1,2 @@ +#define POLYSEGMENT +#include "./xaaDashLine.c" diff --git a/xorg-server/hw/xfree86/xaa/s-xaaLine.c b/xorg-server/hw/xfree86/xaa/s-xaaLine.c new file mode 100644 index 000000000..12a37f419 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/s-xaaLine.c @@ -0,0 +1,2 @@ +#define POLYSEGMENT +#include "./xaaLine.c" diff --git a/xorg-server/hw/xfree86/xaa/xaa.h b/xorg-server/hw/xfree86/xaa/xaa.h new file mode 100644 index 000000000..1dc7ed2d5 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaa.h @@ -0,0 +1,1399 @@ + +#ifndef _XAA_H +#define _XAA_H + +/* + + ******** OPERATION SPECIFIC FLAGS ********* + + **** solid/dashed line flags **** + +--------- -------- +23 LINE_PATTERN_LSBFIRST_MSBJUSTIFIED +22 LINE_PATTERN_LSBFIRST_LSBJUSTIFIED +21 LINE_PATTERN_MSBFIRST_MSBJUSTIFIED +20 LINE_PATTERN_MSBFIRST_LSBJUSTIFIED +19 LINE_PATTERN_POWER_OF_2_ONLY +18 LINE_LIMIT_COORDS +17 . +16 . +--------- ------- + + **** screen to screen copy flags **** + +--------- -------- +23 ONLY_LEFT_TO_RIGHT_BITBLT +22 ONLY_TWO_BITBLT_DIRECTIONS +21 . +20 . +19 . +18 . +17 . +16 . +--------- ------- + + **** clipping flags **** + +--------- -------- +23 . +22 HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND +21 HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY +20 HARDWARE_CLIP_MONO_8x8_FILL +19 HARDWARE_CLIP_COLOR_8x8_FILL +18 HARDWARE_CLIP_SOLID_FILL +17 HARDWARE_CLIP_DASHED_LINE +16 HARDWARE_CLIP_SOLID_LINE +--------- ------- + + + **** hardware pattern flags **** + +--------- -------- +23 . +22 . +21 HARDWARE_PATTERN_SCREEN_ORIGIN +20 . +19 . +18 . +17 HARDWARE_PATTERN_PROGRAMMED_ORIGIN +16 HARDWARE_PATTERN_PROGRAMMED_BITS +--------- ------- + + **** write pixmap flags **** + +--------- -------- +23 . +22 . +21 . +20 . +19 . +18 . +17 . +16 CONVERT_32BPP_TO_24BPP +--------- ------- + + + ******** GENERIC FLAGS ********* + +--------- ------- +15 SYNC_AFTER_COLOR_EXPAND +14 CPU_TRANSFER_PAD_QWORD +13 . +12 LEFT_EDGE_CLIPPING_NEGATIVE_X +11 LEFT_EDGE_CLIPPING +10 CPU_TRANSFER_BASE_FIXED + 9 BIT_ORDER_IN_BYTE_MSBFIRST + 8 TRANSPARENCY_GXCOPY_ONLY +--------- ------- + 7 NO_TRANSPARENCY + 6 TRANSPARENCY_ONLY + 5 ROP_NEEDS_SOURCE + 4 TRIPLE_BITS_24BPP + 3 RGB_EQUAL + 2 NO_PLANEMASK + 1 NO_GXCOPY + 0 GXCOPY_ONLY +--------- ------- + + +*/ + +#include "gcstruct.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "regionstr.h" +#include "xf86fbman.h" + +#ifdef RENDER +#include "picturestr.h" +#endif + +/* Flags */ +#define PIXMAP_CACHE 0x00000001 +#define MICROSOFT_ZERO_LINE_BIAS 0x00000002 +#define OFFSCREEN_PIXMAPS 0x00000004 +#define LINEAR_FRAMEBUFFER 0x00000008 + + +/* GC fg, bg, and planemask restrictions */ +#define GXCOPY_ONLY 0x00000001 +#define NO_GXCOPY 0x00000002 +#define NO_PLANEMASK 0x00000004 +#define RGB_EQUAL 0x00000008 +#define TRIPLE_BITS_24BPP 0x00000010 +#define ROP_NEEDS_SOURCE 0x00000020 + +/* transparency restrictions */ +#define TRANSPARENCY_ONLY 0x00000040 +#define NO_TRANSPARENCY 0x00000080 +#define TRANSPARENCY_GXCOPY_ONLY 0x00000100 + +/* bit order restrictions */ +#define BIT_ORDER_IN_BYTE_MSBFIRST 0x00000200 +#define BIT_ORDER_IN_BYTE_LSBFIRST 0x00000000 + +/* transfer base restriction */ +#define CPU_TRANSFER_BASE_FIXED 0x00000400 + +/* skipleft restrictions */ +#define LEFT_EDGE_CLIPPING 0x00000800 +#define LEFT_EDGE_CLIPPING_NEGATIVE_X 0x00001000 + +/* data padding */ +#define CPU_TRANSFER_PAD_DWORD 0x00000000 +#define CPU_TRANSFER_PAD_QWORD 0x00004000 +#define SCANLINE_PAD_DWORD 0x00000000 + +#define SYNC_AFTER_COLOR_EXPAND 0x00008000 +#define SYNC_AFTER_IMAGE_WRITE SYNC_AFTER_COLOR_EXPAND + +/* hardware pattern */ +#define HARDWARE_PATTERN_PROGRAMMED_BITS 0x00010000 +#define HARDWARE_PATTERN_PROGRAMMED_ORIGIN 0x00020000 +#define HARDWARE_PATTERN_SCREEN_ORIGIN 0x00200000 + +/* copyarea flags */ +#define ONLY_TWO_BITBLT_DIRECTIONS 0x00400000 +#define ONLY_LEFT_TO_RIGHT_BITBLT 0x00800000 + +/* line flags */ +#define LINE_PATTERN_LSBFIRST_MSBJUSTIFIED 0x00800000 +#define LINE_PATTERN_LSBFIRST_LSBJUSTIFIED 0x00400000 +#define LINE_PATTERN_MSBFIRST_MSBJUSTIFIED 0x00200000 +#define LINE_PATTERN_MSBFIRST_LSBJUSTIFIED 0x00100000 +#define LINE_PATTERN_POWER_OF_2_ONLY 0x00080000 +#define LINE_LIMIT_COORDS 0x00040000 + +/* clipping flags */ +#define HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND 0x00400000 +#define HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY 0x00200000 +#define HARDWARE_CLIP_MONO_8x8_FILL 0x00100000 +#define HARDWARE_CLIP_COLOR_8x8_FILL 0x00080000 +#define HARDWARE_CLIP_SOLID_FILL 0x00040000 +#define HARDWARE_CLIP_DASHED_LINE 0x00020000 +#define HARDWARE_CLIP_SOLID_LINE 0x00010000 + +#define HARDWARE_CLIP_LINE 0x00000000 + + +/* image write flags */ +#define CONVERT_32BPP_TO_24BPP 0x00010000 + +/* pixmap cache flags */ +#define CACHE_MONO_8x8 0x00000001 +#define CACHE_COLOR_8x8 0x00000002 +#define DO_NOT_BLIT_STIPPLES 0x00000004 +#define DO_NOT_TILE_MONO_DATA 0x00000008 +#define DO_NOT_TILE_COLOR_DATA 0x00000010 + + +#define DEGREES_0 0 +#define DEGREES_90 1 +#define DEGREES_180 2 +#define DEGREES_270 3 + +#define OMIT_LAST 1 + +/* render flags */ + +#define XAA_RENDER_POWER_OF_2_TILE_ONLY 0x00000008 +#define XAA_RENDER_NO_SRC_ALPHA 0x00000004 +#define XAA_RENDER_IMPRECISE_ONLY 0x00000002 +#define XAA_RENDER_NO_TILE 0x00000001 + +#define XAA_RENDER_REPEAT 0x00000001 + +typedef void (* ValidateGCProcPtr)( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +typedef struct { + unsigned char *bits; + int width; + int height; + int yoff; + int srcwidth; + int start; + int end; +} NonTEGlyphInfo, *NonTEGlyphPtr; + + +typedef struct { + int x; + int y; + int w; + int h; + int orig_w; + int orig_h; + unsigned long serialNumber; + int pat0; + int pat1; + int fg; + int bg; + int trans_color; + DDXPointPtr offsets; + DevUnion devPrivate; +} XAACacheInfoRec, *XAACacheInfoPtr; + + +typedef struct _PixmapLink { + PixmapPtr pPix; + struct _PixmapLink *next; + FBAreaPtr area; +} PixmapLink, *PixmapLinkPtr; + +typedef struct _XAAInfoRec { + ScrnInfoPtr pScrn; + int Flags; + + void (*Sync)( + ScrnInfoPtr pScrn + ); + + /* Restore Accel State is a driver callback that is used + * when another screen on the same device has been active. + * This allows multihead on a single device to work. + * If The entityProp has IS_SHARED_ACCEL defined then this + * function is required. + */ + + void (*RestoreAccelState)( + ScrnInfoPtr pScrn + ); + + /***************** Low Level *****************/ + +/* Blits */ + void (*SetupForScreenToScreenCopy)( + ScrnInfoPtr pScrn, + int xdir, int ydir, + int rop, + unsigned int planemask, + int trans_color + ); + int ScreenToScreenCopyFlags; + + void (*SubsequentScreenToScreenCopy)( + ScrnInfoPtr pScrn, + int xsrc, int ysrc, + int xdst, int ydst, + int w, int h + ); + + +/* Solid fills */ + void (*SetupForSolidFill)( + ScrnInfoPtr pScrn, + int color, + int rop, + unsigned int planemask + ); + int SolidFillFlags; + + void (*SubsequentSolidFillRect)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h + ); + + void (*SubsequentSolidFillTrap)( + ScrnInfoPtr pScrn, + int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR + ); + + +/* Solid lines */ + + void (*SetupForSolidLine)( + ScrnInfoPtr pScrn, + int color, + int rop, + unsigned int planemask + ); + int SolidLineFlags; + + void (*SubsequentSolidTwoPointLine)( + ScrnInfoPtr pScrn, + int xa, int ya, int xb, int yb, int flags + ); + + void (*SubsequentSolidBresenhamLine)( + ScrnInfoPtr pScrn, + int x, int y, int absmaj, int absmin, int err, int len, int octant + ); + int SolidBresenhamLineErrorTermBits; + + void (*SubsequentSolidHorVertLine)( + ScrnInfoPtr pScrn, + int x, int y, int len, int dir + ); + +/* Dashed lines */ + + void (*SetupForDashedLine)( + ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask, + int length, + unsigned char *pattern + ); + int DashedLineFlags; + int DashPatternMaxLength; + + void (*SubsequentDashedTwoPointLine)( + ScrnInfoPtr pScrn, + int xa, int ya, int xb, int yb, int flags, int phase + ); + + void (*SubsequentDashedBresenhamLine)( + ScrnInfoPtr pScrn, + int x, int y, int absmaj, int absmin, int err, int len, int flags, + int phase + ); + int DashedBresenhamLineErrorTermBits; + +/* Clipper */ + + void (*SetClippingRectangle) ( + ScrnInfoPtr pScrn, + int left, int top, int right, int bottom + ); + int ClippingFlags; + + void (*DisableClipping)(ScrnInfoPtr pScrn); + +/* 8x8 mono pattern fills */ + void (*SetupForMono8x8PatternFill)( + ScrnInfoPtr pScrn, + int patx, int paty, + int fg, int bg, + int rop, + unsigned int planemask + ); + int Mono8x8PatternFillFlags; + + void (*SubsequentMono8x8PatternFillRect)( + ScrnInfoPtr pScrn, + int patx, int paty, + int x, int y, int w, int h + ); + + void (*SubsequentMono8x8PatternFillTrap)( + ScrnInfoPtr pScrn, + int patx, int paty, + int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR + ); + +/* 8x8 color pattern fills */ + + void (*SetupForColor8x8PatternFill)( + ScrnInfoPtr pScrn, + int patx, int paty, + int rop, + unsigned int planemask, + int transparency_color + ); + int Color8x8PatternFillFlags; + + void (*SubsequentColor8x8PatternFillRect)( + ScrnInfoPtr pScrn, + int patx, int paty, + int x, int y, int w, int h + ); + + void (*SubsequentColor8x8PatternFillTrap)( + ScrnInfoPtr pScrn, + int patx, int paty, + int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR + ); + + +/* Color expansion */ + + void (*SetupForCPUToScreenColorExpandFill)( + ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask + ); + int CPUToScreenColorExpandFillFlags; + + void (*SubsequentCPUToScreenColorExpandFill)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft + ); + + unsigned char *ColorExpandBase; + int ColorExpandRange; + + +/* Scanline color expansion */ + + void (*SetupForScanlineCPUToScreenColorExpandFill)( + ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask + ); + int ScanlineCPUToScreenColorExpandFillFlags; + + void (*SubsequentScanlineCPUToScreenColorExpandFill)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft + ); + + void (*SubsequentColorExpandScanline)( + ScrnInfoPtr pScrn, + int bufno + ); + + int NumScanlineColorExpandBuffers; + unsigned char **ScanlineColorExpandBuffers; + +/* Screen to screen color expansion */ + + void (*SetupForScreenToScreenColorExpandFill) ( + ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask + ); + int ScreenToScreenColorExpandFillFlags; + + void (*SubsequentScreenToScreenColorExpandFill)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int srcx, int srcy, int skipleft + ); + + +/* Image transfers */ + + void (*SetupForImageWrite)( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth + ); + int ImageWriteFlags; + + void (*SubsequentImageWriteRect)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft + ); + unsigned char *ImageWriteBase; + int ImageWriteRange; + +/* Scanline Image transfers */ + + void (*SetupForScanlineImageWrite)( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth + ); + int ScanlineImageWriteFlags; + + void (*SubsequentScanlineImageWriteRect)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft + ); + + void (*SubsequentImageWriteScanline) ( + ScrnInfoPtr pScrn, + int bufno + ); + + int NumScanlineImageWriteBuffers; + unsigned char **ScanlineImageWriteBuffers; + + /* Image Reads - OBSOLETE AND NOT USED */ + + void (*SetupForImageRead) ( + ScrnInfoPtr pScrn, + int bpp, int depth + ); + int ImageReadFlags; + + unsigned char *ImageReadBase; + int ImageReadRange; + + void (*SubsequentImageReadRect)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h + ); + + + /***************** Mid Level *****************/ + void (*ScreenToScreenBitBlt)( + ScrnInfoPtr pScrn, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir, + int alu, + unsigned int planmask + ); + int ScreenToScreenBitBltFlags; + + void (*WriteBitmap) ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask + ); + int WriteBitmapFlags; + + void (*FillSolidRects)( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox + ); + int FillSolidRectsFlags; + + void (*FillMono8x8PatternRects)( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int pat0, int pat1, + int xorg, int yorg + ); + int FillMono8x8PatternRectsFlags; + + void (*FillColor8x8PatternRects)( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + XAACacheInfoPtr pCache + ); + int FillColor8x8PatternRectsFlags; + + void (*FillCacheBltRects)( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + XAACacheInfoPtr pCache + ); + int FillCacheBltRectsFlags; + + void (*FillColorExpandRects)( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix + ); + int FillColorExpandRectsFlags; + + void (*FillCacheExpandRects)( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix + ); + int FillCacheExpandRectsFlags; + + void (*FillImageWriteRects)( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix + ); + int FillImageWriteRectsFlags; + + + void (*FillSolidSpans)( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int n, + DDXPointPtr points, + int *widths, + int fSorted + ); + int FillSolidSpansFlags; + + void (*FillMono8x8PatternSpans)( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr points, + int *widths, + int fSorted, + int pat0, int pat1, + int xorg, int yorg + ); + int FillMono8x8PatternSpansFlags; + + void (*FillColor8x8PatternSpans)( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr points, + int *widths, + int fSorted, + XAACacheInfoPtr pCache, + int xorg, int yorg + ); + int FillColor8x8PatternSpansFlags; + + void (*FillCacheBltSpans)( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr points, + int *widths, + int fSorted, + XAACacheInfoPtr pCache, + int xorg, int yorg + ); + int FillCacheBltSpansFlags; + + void (*FillColorExpandSpans)( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr points, + int *widths, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix + ); + int FillColorExpandSpansFlags; + + void (*FillCacheExpandSpans)( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix + ); + int FillCacheExpandSpansFlags; + + void (*TEGlyphRenderer)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask + ); + int TEGlyphRendererFlags; + + void (*NonTEGlyphRenderer)( + ScrnInfoPtr pScrn, + int x, int y, int n, + NonTEGlyphPtr glyphs, + BoxPtr pbox, + int fg, int rop, + unsigned int planemask + ); + int NonTEGlyphRendererFlags; + + void (*WritePixmap) ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth + ); + int WritePixmapFlags; + + void (*ReadPixmap) ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *dst, + int dstwidth, + int bpp, int depth + ); + int ReadPixmapFlags; + + /***************** GC Level *****************/ + RegionPtr (*CopyArea)( + DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty + ); + int CopyAreaFlags; + + RegionPtr (*CopyPlane)( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane + ); + int CopyPlaneFlags; + + void (*PushPixelsSolid) ( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDrawable, + int dx, int dy, + int xOrg, int yOrg + ); + int PushPixelsFlags; + + /** PolyFillRect **/ + + void (*PolyFillRectSolid)( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit + ); + int PolyFillRectSolidFlags; + + void (*PolyFillRectStippled)( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit + ); + int PolyFillRectStippledFlags; + + void (*PolyFillRectOpaqueStippled)( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit + ); + int PolyFillRectOpaqueStippledFlags; + + void (*PolyFillRectTiled)( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit + ); + int PolyFillRectTiledFlags; + + /** FillSpans **/ + + void (*FillSpansSolid)( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted + ); + int FillSpansSolidFlags; + + void (*FillSpansStippled)( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted + ); + int FillSpansStippledFlags; + + void (*FillSpansOpaqueStippled)( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted + ); + int FillSpansOpaqueStippledFlags; + + void (*FillSpansTiled)( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted + ); + int FillSpansTiledFlags; + + int (*PolyText8TE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars + ); + int PolyText8TEFlags; + + int (*PolyText16TE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars + ); + int PolyText16TEFlags; + + void (*ImageText8TE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars + ); + int ImageText8TEFlags; + + void (*ImageText16TE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars + ); + int ImageText16TEFlags; + + void (*ImageGlyphBltTE) ( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase + ); + int ImageGlyphBltTEFlags; + + void (*PolyGlyphBltTE) ( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase + ); + int PolyGlyphBltTEFlags; + + int (*PolyText8NonTE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars + ); + int PolyText8NonTEFlags; + + int (*PolyText16NonTE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars + ); + int PolyText16NonTEFlags; + + void (*ImageText8NonTE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars + ); + int ImageText8NonTEFlags; + + void (*ImageText16NonTE) ( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars + ); + int ImageText16NonTEFlags; + + void (*ImageGlyphBltNonTE) ( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase + ); + int ImageGlyphBltNonTEFlags; + + void (*PolyGlyphBltNonTE) ( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase + ); + int PolyGlyphBltNonTEFlags; + + void (*PolyRectangleThinSolid)( + DrawablePtr pDrawable, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit + ); + int PolyRectangleThinSolidFlags; + + void (*PolylinesWideSolid)( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts + ); + int PolylinesWideSolidFlags; + + void (*PolylinesThinSolid)( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts + ); + int PolylinesThinSolidFlags; + + void (*PolySegmentThinSolid)( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg + ); + int PolySegmentThinSolidFlags; + + void (*PolylinesThinDashed)( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts + ); + int PolylinesThinDashedFlags; + + void (*PolySegmentThinDashed)( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg + ); + int PolySegmentThinDashedFlags; + + void (*FillPolygonSolid)( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn + ); + int FillPolygonSolidFlags; + + void (*FillPolygonStippled)( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn + ); + int FillPolygonStippledFlags; + + void (*FillPolygonOpaqueStippled)( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn + ); + int FillPolygonOpaqueStippledFlags; + + void (*FillPolygonTiled)( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn + ); + int FillPolygonTiledFlags; + + void (*PolyFillArcSolid)( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs + ); + int PolyFillArcSolidFlags; + + void (*PutImage)( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, + int y, + int w, + int h, + int leftPad, + int format, + char *pImage + ); + int PutImageFlags; + + /* Validation masks */ + + unsigned long FillSpansMask; + ValidateGCProcPtr ValidateFillSpans; + unsigned long SetSpansMask; + ValidateGCProcPtr ValidateSetSpans; + unsigned long PutImageMask; + ValidateGCProcPtr ValidatePutImage; + unsigned long CopyAreaMask; + ValidateGCProcPtr ValidateCopyArea; + unsigned long CopyPlaneMask; + ValidateGCProcPtr ValidateCopyPlane; + unsigned long PolyPointMask; + ValidateGCProcPtr ValidatePolyPoint; + unsigned long PolylinesMask; + ValidateGCProcPtr ValidatePolylines; + unsigned long PolySegmentMask; + ValidateGCProcPtr ValidatePolySegment; + unsigned long PolyRectangleMask; + ValidateGCProcPtr ValidatePolyRectangle; + unsigned long PolyArcMask; + ValidateGCProcPtr ValidatePolyArc; + unsigned long FillPolygonMask; + ValidateGCProcPtr ValidateFillPolygon; + unsigned long PolyFillRectMask; + ValidateGCProcPtr ValidatePolyFillRect; + unsigned long PolyFillArcMask; + ValidateGCProcPtr ValidatePolyFillArc; + unsigned long PolyText8Mask; + ValidateGCProcPtr ValidatePolyText8; + unsigned long PolyText16Mask; + ValidateGCProcPtr ValidatePolyText16; + unsigned long ImageText8Mask; + ValidateGCProcPtr ValidateImageText8; + unsigned long ImageText16Mask; + ValidateGCProcPtr ValidateImageText16; + unsigned long PolyGlyphBltMask; + ValidateGCProcPtr ValidatePolyGlyphBlt; + unsigned long ImageGlyphBltMask; + ValidateGCProcPtr ValidateImageGlyphBlt; + unsigned long PushPixelsMask; + ValidateGCProcPtr ValidatePushPixels; + + void (*ComputeDash)(GCPtr pGC); + + /* Pixmap Cache */ + + int PixmapCacheFlags; + Bool UsingPixmapCache; + Bool CanDoMono8x8; + Bool CanDoColor8x8; + + void (*InitPixmapCache)( + ScreenPtr pScreen, + RegionPtr areas, + pointer data + ); + void (*ClosePixmapCache)( + ScreenPtr pScreen + ); + + int (*StippledFillChooser)(GCPtr pGC); + int (*OpaqueStippledFillChooser)(GCPtr pGC); + int (*TiledFillChooser)(GCPtr pGC); + + int CachePixelGranularity; + int MaxCacheableTileWidth; + int MaxCacheableTileHeight; + int MaxCacheableStippleWidth; + int MaxCacheableStippleHeight; + + XAACacheInfoPtr (*CacheTile)( + ScrnInfoPtr Scrn, PixmapPtr pPix + ); + XAACacheInfoPtr (*CacheStipple)( + ScrnInfoPtr Scrn, PixmapPtr pPix, + int fg, int bg + ); + XAACacheInfoPtr (*CacheMonoStipple)( + ScrnInfoPtr Scrn, PixmapPtr pPix + ); + XAACacheInfoPtr (*CacheMono8x8Pattern)( + ScrnInfoPtr Scrn, int pat0, int pat1 + ); + XAACacheInfoPtr (*CacheColor8x8Pattern)( + ScrnInfoPtr Scrn, PixmapPtr pPix, + int fg, int bg + ); + + + int MonoPatternPitch; + int CacheWidthMono8x8Pattern; + int CacheHeightMono8x8Pattern; + + int ColorPatternPitch; + int CacheWidthColor8x8Pattern; + int CacheHeightColor8x8Pattern; + + int CacheColorExpandDensity; + + void (*WriteBitmapToCache) ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int fg, int bg + ); + void (*WritePixmapToCache) ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int bpp, int depth + ); + void (*WriteMono8x8PatternToCache)( + ScrnInfoPtr pScrn, + XAACacheInfoPtr pCache + ); + void (*WriteColor8x8PatternToCache)( + ScrnInfoPtr pScrn, + PixmapPtr pPix, + XAACacheInfoPtr pCache + ); + + char* PixmapCachePrivate; + + /* Miscellaneous */ + + GC ScratchGC; + int PreAllocSize; + unsigned char *PreAllocMem; + + CharInfoPtr CharInfo[255]; + NonTEGlyphInfo GlyphInfo[255]; + + unsigned int FullPlanemask; /* deprecated */ + + PixmapLinkPtr OffscreenPixmaps; + int maxOffPixWidth; + int maxOffPixHeight; + + XAACacheInfoRec ScratchCacheInfoRec; + + BoxPtr ClipBox; + + Bool NeedToSync; + + char *dgaSaves; + + /* These can be supplied to override the defaults */ + + GetImageProcPtr GetImage; + GetSpansProcPtr GetSpans; + CopyWindowProcPtr CopyWindow; + BackingStoreSaveAreasProcPtr SaveAreas; + BackingStoreRestoreAreasProcPtr RestoreAreas; + + unsigned int offscreenDepths; + Bool offscreenDepthsInitialized; + + CARD32 FullPlanemasks[32]; + +#ifdef RENDER + Bool (*Composite) ( + CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height + ); + + Bool (*Glyphs) ( + CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs + ); + + /* The old SetupForCPUToScreenAlphaTexture function is no longer used because + * it doesn't pass in enough information to write a conforming + * implementation. See SetupForCPUToScreenAlphaTexture2. + */ + Bool (*SetupForCPUToScreenAlphaTexture) ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags + ); + void (*SubsequentCPUToScreenAlphaTexture) ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height + ); + int CPUToScreenAlphaTextureFlags; + CARD32 * CPUToScreenAlphaTextureFormats; + + /* The old SetupForCPUToScreenTexture function is no longer used because + * it doesn't pass in enough information to write a conforming + * implementation. See SetupForCPUToScreenTexture2. + */ + Bool (*SetupForCPUToScreenTexture) ( + ScrnInfoPtr pScrn, + int op, + int texType, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags + ); + void (*SubsequentCPUToScreenTexture) ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height + ); + int CPUToScreenTextureFlags; + CARD32 * CPUToScreenTextureFormats; + + +#endif + + /* these were added for 4.3.0 */ + BoxRec SolidLineLimits; + BoxRec DashedLineLimits; + +#ifdef RENDER + /* These were added for X.Org 6.8.0 */ + Bool (*SetupForCPUToScreenAlphaTexture2) ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 maskFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags + ); + CARD32 *CPUToScreenAlphaTextureDstFormats; + + Bool (*SetupForCPUToScreenTexture2) ( + ScrnInfoPtr pScrn, + int op, + CARD32 srcFormat, + CARD32 dstFormat, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags + ); + CARD32 *CPUToScreenTextureDstFormats; +#endif /* RENDER */ +} XAAInfoRec, *XAAInfoRecPtr; + +#define SET_SYNC_FLAG(infoRec) (infoRec)->NeedToSync = TRUE + + +Bool +XAAInit( + ScreenPtr pScreen, + XAAInfoRecPtr infoRec +); + +XAAInfoRecPtr XAACreateInfoRec(void); + +void +XAADestroyInfoRec( + XAAInfoRecPtr infoRec +); + +typedef void (*DepthChangeFuncPtr) (ScrnInfoPtr pScrn, int depth); + +Bool +XAAInitDualFramebufferOverlay( + ScreenPtr pScreen, + DepthChangeFuncPtr callback +); + +#endif /* _XAA_H */ diff --git a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c new file mode 100644 index 000000000..ebba74e55 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c @@ -0,0 +1,221 @@ + +/* + This is a lighter version of cfbBitBlt. We calculate the boxes + when accelerating pixmap->screen and screen->screen copies. + We also pass the GC to the doBitBlt function so that it has access + to the fg and bg so CopyPlane can use this. +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "mi.h" +#include "pixmapstr.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "xaalocal.h" + + +RegionPtr +XAABitBlt( + DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr), + unsigned long bitPlane ) +{ + + RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */ + RegionPtr prgnExposed; + Bool freeSrcClip = FALSE; + RegionRec rgnDst; + DDXPointPtr pptSrc, ppt; + DDXPointRec origDest; + BoxPtr pbox; + BoxRec fastBox; + int i, dx, dy, numRects; + xRectangle origSource; + int fastClip = 0; /* for fast clipping with pixmap source */ + int fastExpose = 0; /* for fast exposures with pixmap source */ + + origSource.x = srcx; + origSource.y = srcy; + origSource.width = width; + origSource.height = height; + origDest.x = dstx; + origDest.y = dsty; + + if((pSrcDrawable != pDstDrawable) && + pSrcDrawable->pScreen->SourceValidate) { + (*pSrcDrawable->pScreen->SourceValidate) ( + pSrcDrawable, srcx, srcy, width, height); + } + + srcx += pSrcDrawable->x; + srcy += pSrcDrawable->y; + + /* clip the source */ + if (pSrcDrawable->type == DRAWABLE_PIXMAP) { + if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE)) + prgnSrcClip = pGC->pCompositeClip; + else + fastClip = 1; + } else { /* Window */ + if (pGC->subWindowMode == IncludeInferiors) { + if (!((WindowPtr) pSrcDrawable)->parent) { + /* + * special case bitblt from root window in + * IncludeInferiors mode; just like from a pixmap + */ + fastClip = 1; + } else if ((pSrcDrawable == pDstDrawable) && + (pGC->clientClipType == CT_NONE)) { + prgnSrcClip = pGC->pCompositeClip; + } else { + prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable); + freeSrcClip = TRUE; + } + } else { + prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList; + } + } + + fastBox.x1 = srcx; + fastBox.y1 = srcy; + fastBox.x2 = srcx + width; + fastBox.y2 = srcy + height; + + /* Don't create a source region if we are doing a fast clip */ + if (fastClip) { + fastExpose = 1; + /* + * clip the source; if regions extend beyond the source size, + * make sure exposure events get sent + */ + if (fastBox.x1 < pSrcDrawable->x) { + fastBox.x1 = pSrcDrawable->x; + fastExpose = 0; + } + if (fastBox.y1 < pSrcDrawable->y) { + fastBox.y1 = pSrcDrawable->y; + fastExpose = 0; + } + if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width) { + fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width; + fastExpose = 0; + } + if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height) { + fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height; + fastExpose = 0; + } + } else { + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip); + } + + dstx += pDstDrawable->x; + dsty += pDstDrawable->y; + + if (pDstDrawable->type == DRAWABLE_WINDOW) { + if (!((WindowPtr)pDstDrawable)->realized) { + if (!fastClip) + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return NULL; + } + } + + dx = srcx - dstx; + dy = srcy - dsty; + + /* Translate and clip the dst to the destination composite clip */ + if (fastClip) { + RegionPtr cclip; + + /* Translate the region directly */ + fastBox.x1 -= dx; + fastBox.x2 -= dx; + fastBox.y1 -= dy; + fastBox.y2 -= dy; + + /* If the destination composite clip is one rectangle we can + do the clip directly. Otherwise we have to create a full + blown region and call intersect */ + + cclip = pGC->pCompositeClip; + if (REGION_NUM_RECTS(cclip) == 1) { + BoxPtr pBox = REGION_RECTS(cclip); + + if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1; + if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2; + if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1; + if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2; + + /* Check to see if the region is empty */ + if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) { + REGION_NULL(pGC->pScreen, &rgnDst); + } else { + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + } + } else { + /* We must turn off fastClip now, since we must create + a full blown region. It is intersected with the + composite clip below. */ + fastClip = 0; + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1); + } + } else { + REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy); + } + + if (!fastClip) { + REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, + pGC->pCompositeClip); + } + + /* Do bit blitting */ + numRects = REGION_NUM_RECTS(&rgnDst); + if (numRects && width && height) { + if(!(pptSrc = (DDXPointPtr)xalloc(numRects * + sizeof(DDXPointRec)))) { + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return NULL; + } + pbox = REGION_RECTS(&rgnDst); + ppt = pptSrc; + for (i = numRects; --i >= 0; pbox++, ppt++) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + (*doBitBlt) (pSrcDrawable, pDstDrawable, pGC, &rgnDst, pptSrc); + xfree(pptSrc); + } + + prgnExposed = NULL; + if (pGC->fExpose) { + /* Pixmap sources generate a NoExposed (we return NULL to do this) */ + if (!fastExpose) + prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, + origSource.x, origSource.y, + (int)origSource.width, + (int)origSource.height, + origDest.x, origDest.y, bitPlane); + } + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return prgnExposed; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaBitOrder.c b/xorg-server/hw/xfree86/xaa/xaaBitOrder.c new file mode 100644 index 000000000..9dbd00f3c --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaBitOrder.c @@ -0,0 +1,16 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/Xmd.h> +CARD32 XAAReverseBitOrder(CARD32 v); + +CARD32 +XAAReverseBitOrder(CARD32 v) +{ + return (((0x01010101 & v) << 7) | ((0x02020202 & v) << 5) | + ((0x04040404 & v) << 3) | ((0x08080808 & v) << 1) | + ((0x10101010 & v) >> 1) | ((0x20202020 & v) >> 3) | + ((0x40404040 & v) >> 5) | ((0x80808080 & v) >> 7)); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaBitmap.c b/xorg-server/hw/xfree86/xaa/xaaBitmap.c new file mode 100644 index 000000000..f7ae78d3f --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaBitmap.c @@ -0,0 +1,476 @@ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xaa.h" +#include "xaalocal.h" +#include "xaacexp.h" +#include "xf86.h" + + +/********** byte swapping ***************/ + + +#ifdef FIXEDBASE +# define DEST(i) *dest +# define RETURN(i) return(dest) +#else +# define DEST(i) dest[i] +# define RETURN(i) return(dest + i) +#endif + +#ifdef MSBFIRST +# define SOURCE(i) SWAP_BITS_IN_BYTES(src[i]) +#else +# define SOURCE(i) src[i] +#endif + + +typedef CARD32 *(* BitmapScanlineProcPtr)(CARD32 *, CARD32 *, int, int); + +#ifdef TRIPLE_BITS +static CARD32* +BitmapScanline( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = *src; + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = *src; + WRITE_BITS2(bits); + } else if (count == 1) { + bits = *src; + WRITE_BITS1(bits); + } + + return base; +} + +static CARD32* +BitmapScanline_Inverted( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = ~(*src); + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = ~(*src); + WRITE_BITS2(bits); + } else if (count == 1) { + bits = ~(*src); + WRITE_BITS1(bits); + } + + return base; +} + + +static CARD32* +BitmapScanline_Shifted( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)); + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)); + WRITE_BITS2(bits); + } else if (count == 1) { + bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)); + WRITE_BITS1(bits); + } + + return base; +} + +static CARD32* +BitmapScanline_Shifted_Inverted( + CARD32 *src, CARD32 *base, + int count, int skipleft ) +{ + CARD32 bits; + + while(count >= 3) { + bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft))); + WRITE_BITS3(bits); + src++; + count -= 3; + } + if (count == 2) { + bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft))); + WRITE_BITS2(bits); + } else if (count == 1) { + bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft))); + WRITE_BITS1(bits); + } + + return base; +} + +#define BitmapScanline_Shifted_Careful BitmapScanline_Shifted +#define BitmapScanline_Shifted_Inverted_Careful BitmapScanline_Shifted_Inverted + +#else +static CARD32* +BitmapScanline( + CARD32 *src, CARD32 *dest, + int count, int skipleft ) +{ + while(count >= 4) { + DEST(0) = SOURCE(0); + DEST(1) = SOURCE(1); + DEST(2) = SOURCE(2); + DEST(3) = SOURCE(3); + count -= 4; + src += 4; +#ifndef FIXEDBASE + dest += 4; +#endif + } + + if(!count) return dest; + DEST(0) = SOURCE(0); + if(count == 1) RETURN(1); + DEST(1) = SOURCE(1); + if(count == 2) RETURN(2); + DEST(2) = SOURCE(2); + RETURN(3); +} + +static CARD32* +BitmapScanline_Inverted( + CARD32 *src, CARD32 *dest, + int count, int skipleft ) +{ + while(count >= 4) { + DEST(0) = ~SOURCE(0); + DEST(1) = ~SOURCE(1); + DEST(2) = ~SOURCE(2); + DEST(3) = ~SOURCE(3); + count -= 4; + src += 4; +#ifndef FIXEDBASE + dest += 4; +#endif + } + + if(!count) return dest; + DEST(0) = ~SOURCE(0); + if(count == 1) RETURN(1); + DEST(1) = ~SOURCE(1); + if(count == 2) RETURN(2); + DEST(2) = ~SOURCE(2); + RETURN(3); +} + + +static CARD32* +BitmapScanline_Shifted( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + while(count--) { + register CARD32 tmp = SHIFT_R(*bits,skipleft) | + SHIFT_L(*(bits + 1),(32 - skipleft)); + WRITE_BITS(tmp); + bits++; + } + return base; +} + +static CARD32* +BitmapScanline_Shifted_Inverted( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + while(count--) { + register CARD32 tmp = ~(SHIFT_R(*bits,skipleft) | + SHIFT_L(*(bits + 1),(32 - skipleft))); + WRITE_BITS(tmp); + bits++; + } + return base; +} + +static CARD32* +BitmapScanline_Shifted_Careful( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + register CARD32 tmp; + while(--count) { + tmp = SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft)); + WRITE_BITS(tmp); + bits++; + } + tmp = SHIFT_R(*bits,skipleft); + WRITE_BITS(tmp); + + return base; +} + +static CARD32* +BitmapScanline_Shifted_Inverted_Careful( + CARD32 *bits, CARD32 *base, + int count, int skipleft ) +{ + register CARD32 tmp; + while(--count) { + tmp = ~(SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft))); + WRITE_BITS(tmp); + bits++; + } + tmp = ~(SHIFT_R(*bits,skipleft)); + WRITE_BITS(tmp); + return base; +} + +#endif + +/* + When the accelerator is TRANSPARENCY_ONLY, WriteBitmap can do + the fill in two passes, inverting the source on the second pass. + For GXcopy we can fill the backing rectangle as a solid rect and + avoid the invert. +*/ + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAWriteBitmapColorExpand3)( +#else +EXPNAME(XAAWriteBitmapColorExpand)( +#endif + ScrnInfoPtr pScrn, + int x, int y, int w, int H, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32* base; + unsigned char *srcp = src; + int SecondPassColor = -1; + int shift = 0, dwords; + BitmapScanlineProcPtr firstFunc; + BitmapScanlineProcPtr secondFunc; + int flag; + int h = H; + +#ifdef TRIPLE_BITS + if((bg != -1) && + ((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) || + ((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) && + (!CHECK_RGB_EQUAL(bg))))) { +#else + if((bg != -1) && + (infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) { +#endif + if((rop == GXcopy) && infoRec->SetupForSolidFill) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + } else SecondPassColor = bg; + bg = -1; + } + +#ifdef TRIPLE_BITS + if(skipleft) { +#else + if(skipleft && + (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) || + (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) && + (skipleft > x)))) { +#endif + if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) { + /* don't read past the end */ + firstFunc = BitmapScanline_Shifted_Careful; + secondFunc = BitmapScanline_Shifted_Inverted_Careful; + } else { + firstFunc = BitmapScanline_Shifted; + secondFunc = BitmapScanline_Shifted_Inverted; + } + shift = skipleft; + skipleft = 0; + } else { + firstFunc = BitmapScanline; + secondFunc = BitmapScanline_Inverted; + w += skipleft; + x -= skipleft; + } + +#ifdef TRIPLE_BITS + dwords = (3 * w + 31) >> 5; +#else + dwords = (w + 31) >> 5; +#endif + +SECOND_PASS: + + flag = (infoRec->CPUToScreenColorExpandFillFlags + & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01); + (*infoRec->SetupForCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + (*infoRec->SubsequentCPUToScreenColorExpandFill)( + pScrn, x, y, w, h, skipleft); + + base = (CARD32*)infoRec->ColorExpandBase; + +#ifndef FIXEDBASE + if((dwords * h) <= infoRec->ColorExpandRange) + while(h--) { + base = (*firstFunc)((CARD32*)srcp, base, dwords, shift); + srcp += srcwidth; + } + else +#endif + while(h--) { + (*firstFunc)((CARD32*)srcp, base, dwords, shift); + srcp += srcwidth; + } + + if(flag){ + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + + if(SecondPassColor != -1) { + h = H; /* Reset height */ + fg = SecondPassColor; + SecondPassColor = -1; + firstFunc = secondFunc; + srcp = src; + goto SECOND_PASS; + } + + if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + +#ifndef FIXEDBASE + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAWriteBitmapScanlineColorExpand3)( +#else +EXPNAME(XAAWriteBitmapScanlineColorExpand)( +#endif + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32* base; + unsigned char *srcp = src; + int SecondPassColor = -1; + int shift = 0, dwords, bufferNo; + BitmapScanlineProcPtr firstFunc; + BitmapScanlineProcPtr secondFunc; + +#ifdef TRIPLE_BITS + if((bg != -1) && + ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) + || ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) && + (!CHECK_RGB_EQUAL(bg))))) { +#else + if((bg != -1) && + (infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)){ +#endif + if((rop == GXcopy) && infoRec->SetupForSolidFill) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + } else SecondPassColor = bg; + bg = -1; + } + +#ifdef TRIPLE_BITS + if(skipleft) { +#else + if(skipleft && + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + LEFT_EDGE_CLIPPING) || + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) { +#endif + if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) { + /* don't read past the end */ + firstFunc = BitmapScanline_Shifted_Careful; + secondFunc = BitmapScanline_Shifted_Inverted_Careful; + } else { + firstFunc = BitmapScanline_Shifted; + secondFunc = BitmapScanline_Shifted_Inverted; + } + shift = skipleft; + skipleft = 0; + } else { + firstFunc = BitmapScanline; + secondFunc = BitmapScanline_Inverted; + w += skipleft; + x -= skipleft; + } + +#ifdef TRIPLE_BITS + dwords = (3 * w + 31) >> 5; +#else + dwords = (w + 31) >> 5; +#endif + +SECOND_PASS: + + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask); + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, x, y, w, h, skipleft); + + bufferNo = 0; + + while(h--) { + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + (*firstFunc)((CARD32*)srcp, base, dwords, shift); + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + srcp += srcwidth; + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + } + + if(SecondPassColor != -1) { + fg = SecondPassColor; + SecondPassColor = -1; + firstFunc = secondFunc; + srcp = src; + goto SECOND_PASS; + } + + SET_SYNC_FLAG(infoRec); +} + +#endif diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c new file mode 100644 index 000000000..6c991e100 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c @@ -0,0 +1,387 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "migc.h" +#include "gcstruct.h" +#include "pixmapstr.h" + +/* + Written mostly by Harm Hanemaayer (H.Hanemaayer@inter.nl.net). + */ + + +RegionPtr +XAACopyArea( + DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(pDstDrawable->type == DRAWABLE_WINDOW) { + if((pSrcDrawable->type == DRAWABLE_WINDOW) || + IS_OFFSCREEN_PIXMAP(pSrcDrawable)){ + if(infoRec->ScreenToScreenBitBlt && + CHECK_ROP(pGC,infoRec->ScreenToScreenBitBltFlags) && + CHECK_ROPSRC(pGC,infoRec->ScreenToScreenBitBltFlags) && + CHECK_PLANEMASK(pGC,infoRec->ScreenToScreenBitBltFlags)) + return (XAABitBlt( pSrcDrawable, pDstDrawable, + pGC, srcx, srcy, width, height, dstx, dsty, + XAADoBitBlt, 0L)); + } else { + if(infoRec->WritePixmap && + ((pDstDrawable->bitsPerPixel == pSrcDrawable->bitsPerPixel) || + ((pDstDrawable->bitsPerPixel == 24) && + (pSrcDrawable->bitsPerPixel == 32) && + (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP))) && + CHECK_ROP(pGC,infoRec->WritePixmapFlags) && + CHECK_ROPSRC(pGC,infoRec->WritePixmapFlags) && + CHECK_PLANEMASK(pGC,infoRec->WritePixmapFlags) && + CHECK_NO_GXCOPY(pGC,infoRec->WritePixmapFlags)) + return (XAABitBlt( pSrcDrawable, pDstDrawable, + pGC, srcx, srcy, width, height, dstx, dsty, + XAADoImageWrite, 0L)); + } + } else if(IS_OFFSCREEN_PIXMAP(pDstDrawable)){ + if((pSrcDrawable->type == DRAWABLE_WINDOW) || + IS_OFFSCREEN_PIXMAP(pSrcDrawable)){ + if(infoRec->ScreenToScreenBitBlt && + CHECK_ROP(pGC,infoRec->ScreenToScreenBitBltFlags) && + CHECK_ROPSRC(pGC,infoRec->ScreenToScreenBitBltFlags) && + CHECK_PLANEMASK(pGC,infoRec->ScreenToScreenBitBltFlags)) + return (XAABitBlt( pSrcDrawable, pDstDrawable, + pGC, srcx, srcy, width, height, dstx, dsty, + XAADoBitBlt, 0L)); + } + } + + return (XAAFallbackOps.CopyArea(pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, dstx, dsty)); +} + + +void +XAADoBitBlt( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + RegionPtr prgnDst, + DDXPointPtr pptSrc ) +{ + int nbox, careful; + BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2; + DDXPointPtr pptTmp, pptNew1, pptNew2; + int xdir, ydir; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + /* XXX we have to err on the side of safety when both are windows, + * because we don't know if IncludeInferiors is being used. + */ + careful = ((pSrc == pDst) || + ((pSrc->type == DRAWABLE_WINDOW) && + (pDst->type == DRAWABLE_WINDOW))); + + pbox = REGION_RECTS(prgnDst); + nbox = REGION_NUM_RECTS(prgnDst); + + pboxNew1 = NULL; + pptNew1 = NULL; + pboxNew2 = NULL; + pptNew2 = NULL; + if (careful && (pptSrc->y < pbox->y1)) { + /* walk source botttom to top */ + ydir = -1; + + if (nbox > 1) { + /* keep ordering in each band, reverse order of bands */ + pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox); + if(!pboxNew1) + return; + pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox); + if(!pptNew1) { + xfree(pboxNew1); + return; + } + pboxBase = pboxNext = pbox+nbox-1; + while (pboxBase >= pbox) { + while ((pboxNext >= pbox) && + (pboxBase->y1 == pboxNext->y1)) + pboxNext--; + pboxTmp = pboxNext+1; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp <= pboxBase) { + *pboxNew1++ = *pboxTmp++; + *pptNew1++ = *pptTmp++; + } + pboxBase = pboxNext; + } + pboxNew1 -= nbox; + pbox = pboxNew1; + pptNew1 -= nbox; + pptSrc = pptNew1; + } + } else { + /* walk source top to bottom */ + ydir = 1; + } + + if (careful && (pptSrc->x < pbox->x1)) { + /* walk source right to left */ + xdir = -1; + + if (nbox > 1) { + /* reverse order of rects in each band */ + pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox); + pptNew2 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox); + if(!pboxNew2 || !pptNew2) { + if (pptNew2) xfree(pptNew2); + if (pboxNew2) xfree(pboxNew2); + if (pboxNew1) { + xfree(pptNew1); + xfree(pboxNew1); + } + return; + } + pboxBase = pboxNext = pbox; + while (pboxBase < pbox+nbox) { + while ((pboxNext < pbox+nbox) && + (pboxNext->y1 == pboxBase->y1)) + pboxNext++; + pboxTmp = pboxNext; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp != pboxBase) { + *pboxNew2++ = *--pboxTmp; + *pptNew2++ = *--pptTmp; + } + pboxBase = pboxNext; + } + pboxNew2 -= nbox; + pbox = pboxNew2; + pptNew2 -= nbox; + pptSrc = pptNew2; + } + } else { + /* walk source left to right */ + xdir = 1; + } + + (*infoRec->ScreenToScreenBitBlt)(infoRec->pScrn, nbox, pptSrc, pbox, + xdir, ydir, pGC->alu, pGC->planemask); + + if (pboxNew2) { + xfree(pptNew2); + xfree(pboxNew2); + } + if (pboxNew1) { + xfree(pptNew1); + xfree(pboxNew1); + } + +} + +void +XAADoImageWrite( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + RegionPtr prgnDst, + DDXPointPtr pptSrc ) +{ + int srcwidth; + unsigned char* psrcBase; /* start of image */ + unsigned char* srcPntr; /* index into the image */ + BoxPtr pbox = REGION_RECTS(prgnDst); + int nbox = REGION_NUM_RECTS(prgnDst); + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int Bpp = pSrc->bitsPerPixel >> 3; + + psrcBase = (unsigned char *)((PixmapPtr)pSrc)->devPrivate.ptr; + srcwidth = (int)((PixmapPtr)pSrc)->devKind; + + for(; nbox; pbox++, pptSrc++, nbox--) { + srcPntr = psrcBase + (pptSrc->y * srcwidth) + (pptSrc->x * Bpp); + + (*infoRec->WritePixmap)(infoRec->pScrn, pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, srcPntr, srcwidth, + pGC->alu, pGC->planemask, -1, pSrc->bitsPerPixel, pSrc->depth); + } +} + + +void +XAADoImageRead( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + RegionPtr prgnDst, + DDXPointPtr pptSrc ) +{ + int dstwidth; + unsigned char* pdstBase; /* start of image */ + unsigned char* dstPntr; /* index into the image */ + BoxPtr pbox = REGION_RECTS(prgnDst); + int nbox = REGION_NUM_RECTS(prgnDst); + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int Bpp = pSrc->bitsPerPixel >> 3; /* wouldn't get here unless both + src and dst have same bpp */ + + pdstBase = (unsigned char *)((PixmapPtr)pDst)->devPrivate.ptr; + dstwidth = (int)((PixmapPtr)pDst)->devKind; + + for(; nbox; pbox++, pptSrc++, nbox--) { + dstPntr = pdstBase + (pbox->y1 * dstwidth) + (pbox->x1 * Bpp); + + (*infoRec->ReadPixmap)(infoRec->pScrn, pptSrc->x, pptSrc->y, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, dstPntr, dstwidth, + pSrc->bitsPerPixel, pSrc->depth); + } +} + + +void +XAAScreenToScreenBitBlt( + ScrnInfoPtr pScrn, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir, + int alu, + unsigned int planemask ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int dirsetup; + + if ((!(infoRec->CopyAreaFlags & ONLY_TWO_BITBLT_DIRECTIONS) + || (xdir == ydir)) && + (!(infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT) + || (xdir == 1))) { + (*infoRec->SetupForScreenToScreenCopy)(pScrn, + xdir, ydir, alu, planemask, -1); + for (; nbox; pbox++, pptSrc++, nbox--) + (*infoRec->SubsequentScreenToScreenCopy)(pScrn,pptSrc->x, pptSrc->y, + pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + SET_SYNC_FLAG(infoRec); + return; + } + + if (infoRec->CopyAreaFlags & ONLY_LEFT_TO_RIGHT_BITBLT) { + /* + * This is the case of a chip that only supports xdir = 1, + * with ydir = 1 or ydir = -1, but we have xdir = -1. + */ + (*infoRec->SetupForScreenToScreenCopy)(pScrn, + 1, ydir, alu, planemask, -1); + for (; nbox; pbox++, pptSrc++, nbox--) + if (pptSrc->y != pbox->y1 || pptSrc->x >= pbox->x1) + /* No problem. Do a xdir = 1 blit instead. */ + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pptSrc->x, pptSrc->y, pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + else + { + /* + * This is the difficult case. Needs striping into + * non-overlapping horizontal chunks. + */ + int stripeWidth, w, fullStripes, extra, i; + stripeWidth = 16; + w = pbox->x2 - pbox->x1; + if (pbox->x1 - pptSrc->x < stripeWidth) + stripeWidth = pbox->x1 - pptSrc->x; + fullStripes = w / stripeWidth; + extra = w % stripeWidth; + + /* First, take care of the little bit on the far right */ + if (extra) + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pptSrc->x + fullStripes * stripeWidth, pptSrc->y, + pbox->x1 + fullStripes * stripeWidth, pbox->y1, + extra, pbox->y2 - pbox->y1); + + /* Now, take care of the rest of the blit */ + for (i = fullStripes - 1; i >= 0; i--) + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pptSrc->x + i * stripeWidth, pptSrc->y, + pbox->x1 + i * stripeWidth, pbox->y1, + stripeWidth, pbox->y2 - pbox->y1); + } + SET_SYNC_FLAG(infoRec); + return; + } + + /* + * Now the case of a chip that only supports xdir = ydir = 1 or + * xdir = ydir = -1, but we have xdir != ydir. + */ + dirsetup = 0; /* No direction set up yet. */ + for (; nbox; pbox++, pptSrc++, nbox--) { + if (xdir == 1 && pptSrc->y != pbox->y1) { + /* Do a xdir = ydir = -1 blit instead. */ + if (dirsetup != -1) { + (*infoRec->SetupForScreenToScreenCopy)(pScrn, + -1, -1, alu, planemask, -1); + dirsetup = -1; + } + (*infoRec->SubsequentScreenToScreenCopy)(pScrn,pptSrc->x, pptSrc->y, + pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + } + else if (xdir == -1 && pptSrc->y != pbox->y1) { + /* Do a xdir = ydir = 1 blit instead. */ + if (dirsetup != 1) { + (*infoRec->SetupForScreenToScreenCopy)(pScrn, + 1, 1, alu, planemask, -1); + dirsetup = 1; + } + (*infoRec->SubsequentScreenToScreenCopy)(pScrn,pptSrc->x, pptSrc->y, + pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + } + else + if (xdir == 1) { + /* + * xdir = 1, ydir = -1. + * Perform line-by-line xdir = ydir = 1 blits, going up. + */ + int i; + if (dirsetup != 1) { + (*infoRec->SetupForScreenToScreenCopy)(pScrn, + 1, 1, alu, planemask, -1); + dirsetup = 1; + } + for (i = pbox->y2 - pbox->y1 - 1; i >= 0; i--) + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pptSrc->x, pptSrc->y + i, pbox->x1, pbox->y1 + i, + pbox->x2 - pbox->x1, 1); + } + else { + /* + * xdir = -1, ydir = 1. + * Perform line-by-line xdir = ydir = -1 blits, going down. + */ + int i; + if (dirsetup != -1) { + (*infoRec->SetupForScreenToScreenCopy)(pScrn, + -1, -1, alu, planemask, -1); + dirsetup = -1; + } + for (i = 0; i < pbox->y2 - pbox->y1; i++) + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pptSrc->x, pptSrc->y + i, pbox->x1, pbox->y1 + i, + pbox->x2 - pbox->x1, 1); + } + } /* next box */ + SET_SYNC_FLAG(infoRec); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c new file mode 100644 index 000000000..cd9e9d47f --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c @@ -0,0 +1,210 @@ + +/* + A CopyPlane function that handles bitmap->screen copies and + sends anything else to the Fallback. + + Also, a PushPixels for solid fill styles. + + Written by Mark Vojkovich (markv@valinux.com) + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#include "servermd.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "mi.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" + +static void XAACopyPlane1toNColorExpand(DrawablePtr pSrc, DrawablePtr pDst, + GCPtr pGC, RegionPtr rgnDst, + DDXPointPtr pptSrc); +static void XAACopyPlaneNtoNColorExpand(DrawablePtr pSrc, DrawablePtr pDst, + GCPtr pGC, RegionPtr rgnDst, + DDXPointPtr pptSrc); + + +static unsigned long TmpBitPlane; + +RegionPtr +XAACopyPlaneColorExpansion( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + if((pSrc->type == DRAWABLE_PIXMAP) && !XAA_DEPTH_BUG(pGC)) { + if(pSrc->bitsPerPixel == 1) { + return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy, + width, height, dstx, dsty, + XAACopyPlane1toNColorExpand, bitPlane)); + } else if(bitPlane < (1 << pDst->depth)){ + TmpBitPlane = bitPlane; + return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy, + width, height, dstx, dsty, + XAACopyPlaneNtoNColorExpand, bitPlane)); + } + } + + return (XAAFallbackOps.CopyPlane(pSrc, pDst, pGC, srcx, srcy, + width, height, dstx, dsty, bitPlane)); +} + + +static void +XAACopyPlane1toNColorExpand( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + RegionPtr rgnDst, + DDXPointPtr pptSrc ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + BoxPtr pbox = REGION_RECTS(rgnDst); + int numrects = REGION_NUM_RECTS(rgnDst); + unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr; + int srcwidth = ((PixmapPtr)pSrc)->devKind; + + while(numrects--) { + (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, + src + (srcwidth * pptSrc->y) + ((pptSrc->x >> 5) << 2), + srcwidth, pptSrc->x & 31, + pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask); + pbox++; pptSrc++; + } +} + + +static void +XAACopyPlaneNtoNColorExpand( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + RegionPtr rgnDst, + DDXPointPtr pptSrc +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + BoxPtr pbox = REGION_RECTS(rgnDst); + int numrects = REGION_NUM_RECTS(rgnDst); + unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr; + unsigned char *data, *srcPtr, *dataPtr; + int srcwidth = ((PixmapPtr)pSrc)->devKind; + int pitch, width, height, h, i, index, offset; + int Bpp = pSrc->bitsPerPixel >> 3; + unsigned long mask = TmpBitPlane; + + if(TmpBitPlane < 8) { + offset = 0; + } else if(TmpBitPlane < 16) { + offset = 1; + mask >>= 8; + } else if(TmpBitPlane < 24) { + offset = 2; + mask >>= 16; + } else { + offset = 3; + mask >>= 24; + } + + if(IS_OFFSCREEN_PIXMAP(pSrc)) + SYNC_CHECK(pSrc); + + while(numrects--) { + width = pbox->x2 - pbox->x1; + h = height = pbox->y2 - pbox->y1; + pitch = BitmapBytePad(width); + + if(!(data = xalloc(height * pitch))) + goto ALLOC_FAILED; + + bzero(data, height * pitch); + + dataPtr = data; + srcPtr = ((pptSrc->y) * srcwidth) + src + + ((pptSrc->x) * Bpp) + offset; + + while(h--) { + for(i = index = 0; i < width; i++, index += Bpp) { + if(mask & srcPtr[index]) + dataPtr[i >> 3] |= (1 << (i & 7)); + } + dataPtr += pitch; + srcPtr += srcwidth; + } + + (*infoRec->WriteBitmap)(infoRec->pScrn, + pbox->x1, pbox->y1, width, height, data, pitch, 0, + pGC->fgPixel, pGC->bgPixel, pGC->alu, pGC->planemask); + + xfree(data); + +ALLOC_FAILED: + + pbox++; pptSrc++; + } +} + +void +XAAPushPixelsSolidColorExpansion( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, + int xOrg, int yOrg ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip); + BoxPtr pbox, pClipBoxes; + int nboxes, srcx, srcy; + xRectangle TheRect; + unsigned char *src = pBitMap->devPrivate.ptr; + int srcwidth = pBitMap->devKind; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + TheRect.x = xOrg; + TheRect.y = yOrg; + TheRect.width = dx; + TheRect.height = dy; + + if(MaxBoxes > (infoRec->PreAllocSize/sizeof(BoxRec))) { + pClipBoxes = xalloc(MaxBoxes * sizeof(BoxRec)); + if(!pClipBoxes) return; + } else pClipBoxes = (BoxPtr)infoRec->PreAllocMem; + + nboxes = XAAGetRectClipBoxes(pGC, pClipBoxes, 1, &TheRect); + pbox = pClipBoxes; + + while(nboxes--) { + srcx = pbox->x1 - xOrg; + srcy = pbox->y1 - yOrg; + (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, + src + (srcwidth * srcy) + ((srcx >> 5) << 2), + srcwidth, srcx & 31, + pGC->fgPixel, -1, pGC->alu, pGC->planemask); + pbox++; + } + + if(pClipBoxes != (BoxPtr)infoRec->PreAllocMem) + xfree(pClipBoxes); +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c new file mode 100644 index 000000000..ecdc9a3be --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c @@ -0,0 +1,82 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "xaawrap.h" + +/* + Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net). +*/ + +void +XAACopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc ) +{ + DDXPointPtr pptSrc, ppt; + RegionRec rgnDst; + BoxPtr pbox; + int dx, dy, nbox; + WindowPtr pwinRoot; + ScreenPtr pScreen = pWin->drawable.pScreen; + XAAInfoRecPtr infoRec = + GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable)); + + if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) { + XAA_SCREEN_PROLOGUE (pScreen, CopyWindow); + if(infoRec->pScrn->vtSema && infoRec->NeedToSync) { + (*infoRec->Sync)(infoRec->pScrn); + infoRec->NeedToSync = FALSE; + } + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); + XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAACopyWindow); + return; + } + + pwinRoot = WindowTable[pScreen->myNum]; + + REGION_NULL(pScreen, &rgnDst); + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); + REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc); + + pbox = REGION_RECTS(&rgnDst); + nbox = REGION_NUM_RECTS(&rgnDst); + if(!nbox || + !(pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec)))) { + REGION_UNINIT(pScreen, &rgnDst); + return; + } + ppt = pptSrc; + + while(nbox--) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + ppt++; pbox++; + } + + infoRec->ScratchGC.planemask = ~0L; + infoRec->ScratchGC.alu = GXcopy; + + XAADoBitBlt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + &(infoRec->ScratchGC), &rgnDst, pptSrc); + + xfree(pptSrc); + REGION_UNINIT(pScreen, &rgnDst); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaDashLine.c b/xorg-server/hw/xfree86/xaa/xaaDashLine.c new file mode 100644 index 000000000..63233e05d --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaDashLine.c @@ -0,0 +1,334 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include <X11/X.h> +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "miline.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + + +void +#ifdef POLYSEGMENT +XAAPolySegmentDashed( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg +#else +XAAPolyLinesDashed( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, /* Origin or Previous */ + int npt, /* number of points */ + DDXPointPtr pptInit +#endif +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); + BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); + int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + int xorg = pDrawable->x; + int yorg = pDrawable->y; + int nbox; + BoxPtr pbox; +#ifndef POLYSEGMENT + DDXPointPtr ppt; +#endif + unsigned int oc1, oc2; + int dmin, dmaj, e, octant; + int x1, x2, y1, y2, tmp, len, offset; + int PatternLength, PatternOffset; + + if(!nboxInit) + return; + + if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) { + int minValX = infoRec->DashedLineLimits.x1; + int maxValX = infoRec->DashedLineLimits.x2; + int minValY = infoRec->DashedLineLimits.y1; + int maxValY = infoRec->DashedLineLimits.y2; +#ifdef POLYSEGMENT + int n = nseg; + xSegment *s = pSeg; + + while (n--) +#else + int n = npt; + int xorgtmp = xorg; + int yorgtmp = yorg; + + ppt = pptInit; + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; + while (--n) +#endif + { +#ifdef POLYSEGMENT + x1 = s->x1 + xorg; + y1 = s->y1 + yorg; + x2 = s->x2 + xorg; + y2 = s->y2 + yorg; + s++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) { + xorgtmp = x1; + yorgtmp = y1; + } + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; +#endif + if (x1 > maxValX || x1 < minValX || + x2 > maxValX || x2 < minValX || + y1 > maxValY || y1 < minValY || + y2 > maxValY || y2 < minValY) { +#ifdef POLYSEGMENT + XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); +#else + XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); +#endif + return; + } + } + } + + PatternLength = pGCPriv->DashLength; + PatternOffset = pGC->dashOffset % PatternLength; + + (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel, + (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1, + pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern); + + +#ifdef POLYSEGMENT + while (nseg--) +#else + ppt = pptInit; + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; + while(--npt) +#endif + { + nbox = nboxInit; + pbox = pboxInit; + +#ifdef POLYSEGMENT + x1 = pSeg->x1 + xorg; + y1 = pSeg->y1 + yorg; + x2 = pSeg->x2 + xorg; + y2 = pSeg->y2 + yorg; + pSeg++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) { + xorg = x1; + yorg = y1; + } + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; +#endif + + + if (infoRec->SubsequentDashedBresenhamLine) { + if((dmaj = x2 - x1) < 0) { + dmaj = -dmaj; + octant = XDECREASING; + } else octant = 0; + + if((dmin = y2 - y1) < 0) { + dmin = -dmin; + octant |= YDECREASING; + } + + if(dmin >= dmaj){ + tmp = dmin; dmin = dmaj; dmaj = tmp; + octant |= YMAJOR; + } + + e = -dmaj - ((bias >> octant) & 1); + len = dmaj; + dmin <<= 1; + dmaj <<= 1; + } else { /* Muffle compiler */ + dmin = dmaj = e = octant = len = 0; + } + + while(nbox--) { + oc1 = oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if (!(oc1 | oc2)) { /* uncliped */ + if(infoRec->SubsequentDashedTwoPointLine) { + (*infoRec->SubsequentDashedTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST, PatternOffset); + } else { + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant, PatternOffset); + } + break; + } else if (oc1 & oc2) { /* completely clipped */ + pbox++; + } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) { + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); + + if(infoRec->SubsequentDashedBresenhamLine) { + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant, PatternOffset); + } else { + (*infoRec->SubsequentDashedTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST, PatternOffset + ); + } + (*infoRec->DisableClipping)(infoRec->pScrn); + pbox++; + } else { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int err, adx, ady; + + if(octant & YMAJOR) { + ady = dmaj >> 1; + adx = dmin >> 1; + } else { + ady = dmin >> 1; + adx = dmaj >> 1; + } + + if (miZeroClipLine(pbox->x1, pbox->y1, + pbox->x2 - 1, pbox->y2 - 1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + + if (octant & YMAJOR) + len = abs(new_y2 - new_y1); + else + len = abs(new_x2 - new_x1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) { + int abserr, clipdx, clipdy; + /* unwind bresenham error term to first point */ + if (clip1) { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + + if (octant & YMAJOR) + err = e + clipdy*dmin - clipdx*dmaj; + else + err = e + clipdx*dmin - clipdy*dmaj; + } else + err = e; + +#define range infoRec->DashedBresenhamLineErrorTermBits + abserr = abs(err); + while((abserr & range) || + (dmaj & range) || + (dmin & range)) { + dmin >>= 1; + dmaj >>= 1; + abserr >>= 1; + err /= 2; + } + + if(octant & YMAJOR) + offset = abs(new_y1 - y1); + else + offset = abs(new_x1 - x1); + + offset += PatternOffset; + offset %= PatternLength; + + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, new_x1, new_y1, + dmaj, dmin, err, len, octant, offset); + } + pbox++; + } + } /* while (nbox--) */ +#ifndef POLYSEGMENT + len = abs(y2 - y1); + tmp = abs(x2 - x1); + PatternOffset += (len > tmp) ? len : tmp; + PatternOffset %= PatternLength; +#endif + } /* while (nline--) */ + +#ifndef POLYSEGMENT + /* paint the last point if the end style isn't CapNotLast. + (Assume that a projecting, butt, or round cap that is one + pixel wide is the same as the single pixel of the endpoint.) + */ + + if ((pGC->capStyle != CapNotLast) && + ((ppt->x + xorg != pptInit->x + pDrawable->x) || + (ppt->y + yorg != pptInit->y + pDrawable->y) || + (ppt == pptInit + 1))) + { + nbox = nboxInit; + pbox = pboxInit; + while (nbox--) { + if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && + (x2 < pbox->x2) && (y2 < pbox->y2)) + { + if(infoRec->SubsequentDashedTwoPointLine) { + (*infoRec->SubsequentDashedTwoPointLine)( + infoRec->pScrn, x2, y2, x2, y2, 0, + PatternOffset); + } else { + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, x2, y2, 2, 0, -1, + 1, 0, PatternOffset); + } + break; + } else + pbox++; + } + } +#endif + + SET_SYNC_FLAG(infoRec); +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaFallback.c b/xorg-server/hw/xfree86/xaa/xaaFallback.c new file mode 100644 index 000000000..7ab4031f8 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaFallback.c @@ -0,0 +1,352 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "xaawrap.h" + + + +static void +XAAFillSpansFallback( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAASetSpansFallback( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAPutImageFallback( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + XAA_GC_OP_EPILOGUE(pGC); +} + +static RegionPtr +XAACopyAreaFallback( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty ) +{ + RegionPtr ret; + + XAA_GC_OP_PROLOGUE(pGC); + if((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) || + IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) { + SYNC_CHECK(pGC); + } + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + XAA_GC_OP_EPILOGUE(pGC); + return ret; +} + +static RegionPtr +XAACopyPlaneFallback( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane ) +{ + RegionPtr ret; + + XAA_GC_OP_PROLOGUE(pGC); + if((pSrc->type == DRAWABLE_WINDOW) || (pDst->type == DRAWABLE_WINDOW) || + IS_OFFSCREEN_PIXMAP(pSrc) || IS_OFFSCREEN_PIXMAP(pDst)) { + SYNC_CHECK(pGC); + } + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + XAA_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +XAAPolyPointFallback( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + XAA_GC_OP_EPILOGUE(pGC); +} + + +static void +XAAPolylinesFallback( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAPolySegmentFallback( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAPolyRectangleFallback( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAPolyArcFallback( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAFillPolygonFallback( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + XAA_GC_OP_EPILOGUE(pGC); +} + + +static void +XAAPolyFillRectFallback( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + XAA_GC_OP_EPILOGUE(pGC); +} + + +static void +XAAPolyFillArcFallback( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + XAA_GC_OP_EPILOGUE(pGC); +} + +static int +XAAPolyText8Fallback( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars ) +{ + int ret; + + XAA_GC_OP_PROLOGUE(pGC); + SYNC_CHECK(pGC); + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + XAA_GC_OP_EPILOGUE(pGC); + return ret; +} + +static int +XAAPolyText16Fallback( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars ) +{ + int ret; + + XAA_GC_OP_PROLOGUE(pGC); + SYNC_CHECK(pGC); + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + XAA_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +XAAImageText8Fallback( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAImageText16Fallback( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + XAA_GC_OP_EPILOGUE(pGC); +} + + +static void +XAAImageGlyphBltFallback( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAPolyGlyphBltFallback( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase); + XAA_GC_OP_EPILOGUE(pGC); +} + +static void +XAAPushPixelsFallback( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg ) +{ + XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC); + SYNC_CHECK(pGC); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + XAA_GC_OP_EPILOGUE(pGC); +} + +GCOps XAAFallbackOps = { + XAAFillSpansFallback, XAASetSpansFallback, + XAAPutImageFallback, XAACopyAreaFallback, + XAACopyPlaneFallback, XAAPolyPointFallback, + XAAPolylinesFallback, XAAPolySegmentFallback, + XAAPolyRectangleFallback, XAAPolyArcFallback, + XAAFillPolygonFallback, XAAPolyFillRectFallback, + XAAPolyFillArcFallback, XAAPolyText8Fallback, + XAAPolyText16Fallback, XAAImageText8Fallback, + XAAImageText16Fallback, XAAImageGlyphBltFallback, + XAAPolyGlyphBltFallback, XAAPushPixelsFallback, + {NULL} /* devPrivate */ +}; + +GCOps *XAAGetFallbackOps(void) +{ + return &XAAFallbackOps; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaFillArc.c b/xorg-server/hw/xfree86/xaa/xaaFillArc.c new file mode 100644 index 000000000..d3ebc22fc --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaFillArc.c @@ -0,0 +1,217 @@ +/* + * Copyright 1996 The XFree86 Project + * + * 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 + * HARM HANEMAAYER 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. + * + * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net). + */ + +/* + * Filled solid arcs, based on cfbfillarc.c. + * + * Fill arc using calls to low-level span fill. Because the math for + * each span can be done concurrently with the drawing of the span + * with a graphics coprocessor operation, this is faster than just + * using miPolyFillArc, which first calculates all the spans and then + * calls FillSpans. + * + * Clipped arcs are dispatched to FillSpans. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <limits.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "mifillarc.h" +#include "mi.h" + +/* + * This is based on the integer-math versions from mi. Perhaps on a + * Pentium, the floating-point (double)-math version is faster. + */ + +static void +XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + register int x, y, e; + int yk, xk, ym, xm, dx, dy, xorg, yorg; + int slw; + miFillArcRec info; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + miFillArcSetup(arc, &info); + MIFILLARCSETUP(); + if (pGC->miTranslate) + { + xorg += pDraw->x; + yorg += pDraw->y; + } + while (y > 0) + { + MIFILLARCSTEP(slw); + if (slw > 0) { + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x, + yorg - y, slw, 1); + if (miFillArcLower(slw)) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + xorg - x, yorg + y + dy, slw, 1); + } + } + + SET_SYNC_FLAG(infoRec); +} + + +#define ADDSPAN(l,r) \ + if (r >= l) \ + (*infoRec->SubsequentSolidFillRect)( \ + infoRec->pScrn, l, ya, r - l + 1, 1); + +#define ADDSLICESPANS(flip) \ + if (!flip) \ + { \ + ADDSPAN(xl, xr); \ + } \ + else \ + { \ + xc = xorg - x; \ + ADDSPAN(xc, xr); \ + xc += slw - 1; \ + ADDSPAN(xl, xc); \ + } + +static void +XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; + register int x, y, e; + miFillArcRec info; + miArcSliceRec slice; + int ya, xl, xr, xc; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + miFillArcSetup(arc, &info); + miFillArcSliceSetup(arc, &slice, pGC); + MIFILLARCSETUP(); + slw = arc->height; + if (slice.flip_top || slice.flip_bot) + slw += (arc->height >> 1) + 1; + if (pGC->miTranslate) + { + xorg += pDraw->x; + yorg += pDraw->y; + slice.edge1.x += pDraw->x; + slice.edge2.x += pDraw->x; + } + while (y > 0) + { + MIFILLARCSTEP(slw); + MIARCSLICESTEP(slice.edge1); + MIARCSLICESTEP(slice.edge2); + if (miFillSliceUpper(slice)) + { + ya = yorg - y; + MIARCSLICEUPPER(xl, xr, slice, slw); + + ADDSLICESPANS(slice.flip_top); + } + if (miFillSliceLower(slice)) + { + ya = yorg + y + dy; + MIARCSLICELOWER(xl, xr, slice, slw); + ADDSLICESPANS(slice.flip_bot); + } + } + + SET_SYNC_FLAG(infoRec); +} + + +void +XAAPolyFillArcSolid(pDraw, pGC, narcs, parcs) + DrawablePtr pDraw; + GCPtr pGC; + int narcs; + xArc *parcs; +{ + register xArc *arc; + register int i; + int x2, y2; + BoxRec box; + RegionPtr cclip; + + cclip = pGC->pCompositeClip; + + if(!REGION_NUM_RECTS(cclip)) + return; + + for (arc = parcs, i = narcs; --i >= 0; arc++) + { + if (miFillArcEmpty(arc)) + continue; + if (miCanFillArc(arc)) + { + box.x1 = arc->x + pDraw->x; + box.y1 = arc->y + pDraw->y; + /* + * Because box.x2 and box.y2 get truncated to 16 bits, and the + * RECT_IN_REGION test treats the resulting number as a signed + * integer, the RECT_IN_REGION test alone can go the wrong way. + * This can result in a server crash because the rendering + * routines in this file deal directly with cpu addresses + * of pixels to be stored, and do not clip or otherwise check + * that all such addresses are within their respective pixmaps. + * So we only allow the RECT_IN_REGION test to be used for + * values that can be expressed correctly in a signed short. + */ + x2 = box.x1 + (int)arc->width + 1; + box.x2 = x2; + y2 = box.y1 + (int)arc->height + 1; + box.y2 = y2; + if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) && + (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) ) + { + if ((arc->angle2 >= FULLCIRCLE) || + (arc->angle2 <= -FULLCIRCLE)) + XAAFillEllipseSolid(pDraw, pGC, arc); + else + XAAFillArcSliceSolid(pDraw, pGC, arc); + continue; + } + } + miPolyFillArc(pDraw, pGC, 1, arc); + } +} diff --git a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c new file mode 100644 index 000000000..6f11e35ff --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c @@ -0,0 +1,962 @@ + +/* + * Copyright 1996 The XFree86 Project + * + * 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 + * HARM HANEMAAYER 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. + * + */ + +/* + * Written by Mark Vojkovich. Loosly based on an original version + * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which + * only did solid rectangles and didn't have trapezoid support. + * + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "mi.h" +#include "micoord.h" + +#include "xaa.h" +#include "xaalocal.h" + +#define POLY_USE_MI 0 +#define POLY_FULLY_CLIPPED 1 +#define POLY_IS_EASY 2 + + +#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\ + x = intToX(vertex); \ + if ((dy = intToY(c) - y)) { \ + DX = dx = intToX(c) - x; \ + step = 0; \ + if (dx >= 0) \ + { \ + e = 0; \ + sign = 1; \ + if (dx >= dy) {\ + step = dx / dy; \ + dx %= dy; \ + } \ + } \ + else \ + { \ + e = 1 - dy; \ + sign = -1; \ + dx = -dx; \ + if (dx >= dy) { \ + step = - (dx / dy); \ + dx %= dy; \ + } \ + } \ + } \ + x += origin; \ + vertex = c; \ +} + +#define Step(x,dx,dy,e,sign,step) {\ + x += step; \ + if ((e += dx) > 0) \ + { \ + x += sign; \ + e -= dy; \ + } \ +} + +#define FixError(x, dx, dy, e, sign, step, h) { \ + e += (h) * dx; \ + x += (h) * step; \ + if(e > 0) { \ + x += e * sign/dy; \ + e %= dy; \ + if(e) { \ + x += sign; \ + e -= dy; \ + } \ + } \ +} + + +/* + XAAIsEasyPoly - + + Checks CoordModeOrigin one rect polygons to see if we need + to use Mi. + Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY + as well as the pointer to the "top" point and the y + extents. +*/ + +int +XAAIsEasyPolygon( + DDXPointPtr ptsIn, + int count, + BoxPtr extents, + int origin, + DDXPointPtr *topPoint, /* return */ + int *topY, int *bottomY, /* return */ + int shape +){ + int c = 0, vertex1, vertex2; + + *topY = 32767; + *bottomY = 0; + + origin -= (origin & 0x8000) << 1; + vertex1 = extents->x1 - origin; + vertex2 = extents->x2 - origin /* - 0x00010001 */; + /* I think this was an error in cfb ^ */ + + if (shape == Convex) { + while (count--) { + c = *((int*)ptsIn); + if (((c - vertex1) | (vertex2 - c)) & 0x80008000) + return POLY_USE_MI; + + c = intToY(c); + if (c < *topY) { + *topY = c; + *topPoint = ptsIn; + } + ptsIn++; + if (c > *bottomY) *bottomY = c; + } + } else { + int yFlip = 0; + int dx2, dx1, x1, x2; + + x2 = x1 = -1; + dx2 = dx1 = 1; + + while (count--) { + c = *((int*)ptsIn); + if (((c - vertex1) | (vertex2 - c)) & 0x80008000) + return POLY_USE_MI; + c = intToY(c); + if (c < *topY) { + *topY = c; + *topPoint = ptsIn; + } + ptsIn++; + if (c > *bottomY) *bottomY = c; + if (c == x1) + continue; + if (dx1 > 0) { + if (x2 < 0) x2 = c; + else dx2 = dx1 = (c - x1) >> 31; + } else if ((c - x1) >> 31 != dx1) { + dx1 = ~dx1; + yFlip++; + } + x1 = c; + } + x1 = (x2 - c) >> 31; + if (x1 != dx1) yFlip++; + if (x1 != dx2) yFlip++; + if (yFlip != 2) { + if(*topY == *bottomY) + return POLY_FULLY_CLIPPED; + else + return POLY_USE_MI; + } + } + if (*topY == *bottomY) + return POLY_FULLY_CLIPPED; + + return POLY_IS_EASY; +} + +void +XAAFillPolygonSolid( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int origin, vertex1, vertex2; + int *vertex1p, *vertex2p, *endp; + int x1 = 0, x2 = 0; + int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; + int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; + int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; + int c, y, maxy, h, yoffset; + DDXPointPtr topPoint; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + if (mode == CoordModePrevious) { + register DDXPointPtr ppt = ptsIn + 1; + + for (origin = 1; origin < count; origin++, ppt++) { + ppt->x += (ppt-1)->x; + ppt->y += (ppt-1)->y; + } + mode = CoordModeOrigin; + } + + if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + origin = coordToInt(pDraw->x, pDraw->y); + + switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, + origin, &topPoint, &y, &maxy, shape) ) { + case POLY_USE_MI: + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + case POLY_FULLY_CLIPPED: + return; + } + + endp = (int*)ptsIn + count; + vertex2p = vertex1p = (int *)topPoint; + origin = pDraw->x; + yoffset = pDraw->y; + vertex2 = vertex1 = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + while(1) { + if (y == intToY(vertex1)) { + do { + if (vertex1p == (int *) ptsIn) + vertex1p = endp; + c = *--vertex1p; + Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) + } while (y >= intToY(vertex1)); + h = dy1; + } else { + Step(x1,dx1,dy1,e1,sign1,step1) + h = intToY(vertex1) - y; + } + if (y == intToY(vertex2)) { + do { + c = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; + Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) + } while (y >= intToY(vertex2)); + if (dy2 < h) + h = dy2; + } else { + Step(x2,dx2,dy2,e2,sign2,step2) + if ((c = (intToY(vertex2) - y)) < h) + h = c; + } + + /* fill spans for this segment */ + if(DX1 | DX2) { + if(infoRec->SubsequentSolidFillTrap && (h > 6)) { + if(x1 == x2) { + while(x1 == x2) { + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + if(y == maxy) break; + if(!h) continue; + } + + if(x1 < x2) + (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, + y + yoffset, h, + x1, DX1, dy1, e1, + x2 - 1, DX2, dy2, e2); + else + (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, + y + yoffset, h, + x2, DX2, dy2, e2, + x1 - 1, DX1, dy1, e1); + y += h; + if(--h) { + FixError(x1,dx1,dy1,e1,sign1,step1,h); + FixError(x2,dx2,dy2,e2,sign2,step2,h); + h = 0; + } + } else { + while(1) { + if (x2 > x1) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x1, y + yoffset, x2 - x1, 1); + else if (x1 > x2) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x2, y + yoffset, x1 - x2, 1); + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + } + } else { + if (x2 > x1) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x1, y + yoffset, x2 - x1, h); + else if (x1 > x2) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x2, y + yoffset, x1 - x2, h); + + y += h; + h = 0; + } + if (y == maxy) break; + } + SET_SYNC_FLAG(infoRec); +} + + + + +void +XAAFillPolygonHelper( + ScrnInfoPtr pScrn, + DDXPointPtr ptsIn, + int count, + DDXPointPtr topPoint, + int y, + int maxy, + int origin, + RectFuncPtr RectFunc, + TrapFuncPtr TrapFunc, + int xorg, + int yorg, + XAACacheInfoPtr pCache +){ + int *vertex1p, *vertex2p, *endp; + int vertex1, vertex2; + int x1 = 0, x2 = 0; + int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; + int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; + int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; + int c, h, yoffset; + + + endp = (int*)ptsIn + count; + vertex2p = vertex1p = (int *)topPoint; + yoffset = intToY(origin); + origin = intToX(origin); + vertex2 = vertex1 = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *)ptsIn; + + while(1) { + if (y == intToY(vertex1)) { + do { + if (vertex1p == (int *) ptsIn) + vertex1p = endp; + c = *--vertex1p; + Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) + } while (y >= intToY(vertex1)); + h = dy1; + } else { + Step(x1,dx1,dy1,e1,sign1,step1) + h = intToY(vertex1) - y; + } + if (y == intToY(vertex2)) { + do { + c = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; + Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) + } while (y >= intToY(vertex2)); + if (dy2 < h) + h = dy2; + } else { + Step(x2,dx2,dy2,e2,sign2,step2) + if ((c = (intToY(vertex2) - y)) < h) + h = c; + } + + /* fill spans for this segment */ + if(DX1 | DX2) { + if(TrapFunc && (h > 6)) { + if(x1 == x2) { + while(x1 == x2) { + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + if(y == maxy) break; + if(!h) continue; + } + + if(x1 < x2) + (*TrapFunc)(pScrn, y + yoffset, h, + x1, DX1, dy1, e1, + x2 - 1, DX2, dy2, e2, xorg, yorg, pCache); + else + (*TrapFunc)(pScrn, y + yoffset, h, + x2, DX2, dy2, e2, + x1 - 1, DX1, dy1, e1, xorg, yorg, pCache); + y += h; + if(--h) { + FixError(x1,dx1,dy1,e1,sign1,step1,h); + FixError(x2,dx2,dy2,e2,sign2,step2,h); + h = 0; + } + } else { + while(1) { + if (x2 > x1) + (*RectFunc)(pScrn, + x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache); + else if (x1 > x2) + (*RectFunc)(pScrn, + x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache); + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + } + } else { + if (x2 > x1) + (*RectFunc)(pScrn, + x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache); + else if (x1 > x2) + (*RectFunc)(pScrn, + x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache); + + y += h; + h = 0; + } + if (y == maxy) break; + } +} + + /*****************\ + | Solid Helpers | + \*****************/ + +static void +SolidTrapHelper( + ScrnInfoPtr pScrn, + int y, int h, + int x1, int dx1, int dy1, int e1, + int x2, int dx2, int dy2, int e2, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentSolidFillTrap) (pScrn, + y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); +} + +static void +SolidRectHelper ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); +} + + + /*********************\ + | Mono 8x8 Patterns | + \*********************/ + +static void +Mono8x8PatternTrapHelper_ScreenOrigin( + ScrnInfoPtr pScrn, + int y, int h, + int x1, int dx1, int dy1, int e1, + int x2, int dx2, int dy2, int e2, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg, + y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); +} + +static void +Mono8x8PatternRectHelper_ScreenOrigin ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, + x, y, w, h); +} + +static void +Mono8x8PatternRectHelper ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + xorg = (x - xorg) & 0x07; + yorg = (y - yorg) & 0x07; + + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + int patx = pCache->pat0; + int paty = pCache->pat1; + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } else { + int slot = (yorg << 3) + xorg; + xorg = pCache->x + pCache->offsets[slot].x; + yorg = pCache->y + pCache->offsets[slot].y; + } + } + + + (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, + x, y, w, h); +} + + + + /****************\ + | Cache Expand | + \****************/ + + +static void +CacheExpandRectHelper ( + ScrnInfoPtr pScrn, + int X, int Y, int Width, int Height, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; + int cacheWidth; + + cacheWidth = (pCache->w * pScrn->bitsPerPixel) / + infoRec->CacheColorExpandDensity; + + phaseY = (Y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (X - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + + while(1) { + w = Width; skipleft = phaseX; x = X; + blit_h = pCache->h - phaseY; + if(blit_h > Height) blit_h = Height; + + while(1) { + blit_w = cacheWidth - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenColorExpandFill)( + pScrn, x, Y, blit_w, blit_h, + pCache->x, pCache->y + phaseY, skipleft); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + Height -= blit_h; + if(!Height) break; + Y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } +} + + + + /**************\ + | Cache Blit | + \**************/ + + +static void +CacheBltRectHelper ( + ScrnInfoPtr pScrn, + int X, int Y, int Width, int Height, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; + + phaseY = (Y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (X - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + + while(1) { + w = Width; skipleft = phaseX; x = X; + blit_h = pCache->h - phaseY; + if(blit_h > Height) blit_h = Height; + + while(1) { + blit_w = pCache->w - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + skipleft, pCache->y + phaseY, + x, Y, blit_w, blit_h); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + Height -= blit_h; + if(!Height) break; + Y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } +} + + + /**********************\ + | Stippled Polygons | + \**********************/ + + +void +XAAFillPolygonStippled( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + int origin, type, patx, paty, fg, bg; + int y, maxy, xorg, yorg; + DDXPointPtr topPoint; + XAACacheInfoPtr pCache = NULL; + RectFuncPtr RectFunc = NULL; + TrapFuncPtr TrapFunc = NULL; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + if (mode == CoordModePrevious) { + register DDXPointPtr ppt = ptsIn + 1; + + for (origin = 1; origin < count; origin++, ppt++) { + ppt->x += (ppt-1)->x; + ppt->y += (ppt-1)->y; + } + mode = CoordModeOrigin; + } + + if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + + if(pGC->fillStyle == FillStippled) { + type = (*infoRec->StippledFillChooser)(pGC); + fg = pGC->fgPixel; bg = -1; + } else { + type = (*infoRec->OpaqueStippledFillChooser)(pGC); + fg = pGC->fgPixel; bg = pGC->bgPixel; + } + + + if(!type) { + (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + origin = pDraw->x; + + switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, + origin, &topPoint, &y, &maxy, shape) ) { + case POLY_USE_MI: + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + case POLY_FULLY_CLIPPED: + return; + } + + xorg = (pDraw->x + pGC->patOrg.x); + yorg = (pDraw->y + pGC->patOrg.y); + + + if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) { + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg, + pGC->alu, pGC->planemask); + + RectFunc = SolidRectHelper; + TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL; + } else + switch(type) { + case DO_MONO_8x8: + patx = pPriv->pattern0; paty = pPriv->pattern1; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_SCREEN_ORIGIN) { + xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; + if(infoRec->SubsequentMono8x8PatternFillTrap) + TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; + } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + } else { + pCache = &(infoRec->ScratchCacheInfoRec); + pCache->pat0 = patx; + pCache->pat1 = paty; + } + RectFunc = Mono8x8PatternRectHelper; + } + + (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, + patx, paty, fg, bg, pGC->alu, pGC->planemask); + break; + case DO_CACHE_EXPAND: + pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple); + + (*infoRec->SetupForScreenToScreenColorExpandFill)( + infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask); + + RectFunc = CacheExpandRectHelper; + break; + case DO_CACHE_BLT: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + fg, bg); + (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, + pGC->alu, pGC->planemask, pCache->trans_color); + + RectFunc = CacheBltRectHelper; + break; + default: + return; + } + + + XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, + y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); + + SET_SYNC_FLAG(infoRec); +} + + + + + /*******************\ + | Tiled Polygons | + \*******************/ + + +void +XAAFillPolygonTiled( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + int origin, type, patx, paty; + int y, maxy, xorg, yorg; + DDXPointPtr topPoint; + XAACacheInfoPtr pCache = NULL; + RectFuncPtr RectFunc = NULL; + TrapFuncPtr TrapFunc = NULL; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + if (mode == CoordModePrevious) { + register DDXPointPtr ppt = ptsIn + 1; + + for (origin = 1; origin < count; origin++, ppt++) { + ppt->x += (ppt-1)->x; + ppt->y += (ppt-1)->y; + } + mode = CoordModeOrigin; + } + + if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + + type = (*infoRec->TiledFillChooser)(pGC); + + if(!type || (type == DO_IMAGE_WRITE)) { + (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + if(type == DO_COLOR_8x8) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + origin = pDraw->x; + + switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, + origin, &topPoint, &y, &maxy, shape) ) { + case POLY_USE_MI: + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + case POLY_FULLY_CLIPPED: + return; + } + + xorg = (pDraw->x + pGC->patOrg.x); + yorg = (pDraw->y + pGC->patOrg.y); + + switch(type) { + case DO_MONO_8x8: + patx = pPriv->pattern0; paty = pPriv->pattern1; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_SCREEN_ORIGIN) { + xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; + if(infoRec->SubsequentMono8x8PatternFillTrap) + TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; + } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + } + else { + pCache = &(infoRec->ScratchCacheInfoRec); + pCache->pat0 = patx; + pCache->pat1 = paty; + } + RectFunc = Mono8x8PatternRectHelper; + } + + (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, + patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask); + break; + case DO_CACHE_BLT: + pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); + (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, + pGC->alu, pGC->planemask, -1); + + RectFunc = CacheBltRectHelper; + break; + case DO_PIXMAP_COPY: + pCache = &(infoRec->ScratchCacheInfoRec); + pCache->x = pPriv->offscreenArea->box.x1; + pCache->y = pPriv->offscreenArea->box.y1; + pCache->w = pCache->orig_w = + pPriv->offscreenArea->box.x2 - pCache->x; + pCache->h = pCache->orig_h = + pPriv->offscreenArea->box.y2 - pCache->y; + + (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, + pGC->alu, pGC->planemask, -1); + + RectFunc = CacheBltRectHelper; + break; + default: + return; + } + + XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, + y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); + + SET_SYNC_FLAG(infoRec); +} + + diff --git a/xorg-server/hw/xfree86/xaa/xaaFillRect.c b/xorg-server/hw/xfree86/xaa/xaaFillRect.c new file mode 100644 index 000000000..55a30bbd6 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaFillRect.c @@ -0,0 +1,1095 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + + +static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int); +static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int); +static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int); + +void +XAAPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, /* number of rectangles to fill */ + xRectangle *prectInit /* Pointer to first rectangle to fill */ +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int xorg = pDraw->x; + int yorg = pDraw->y; + int type = 0; + ClipAndRenderRectsFunc function; + + if((nrectFill <= 0) || !pGC->planemask) + return; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + switch(pGC->fillStyle) { + case FillSolid: + type = DO_SOLID; + break; + case FillStippled: + type = (*infoRec->StippledFillChooser)(pGC); + break; + case FillOpaqueStippled: + if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects && + CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) && + CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) && + CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) && + CHECK_FG(pGC,infoRec->FillSolidRectsFlags)) + type = DO_SOLID; + else + type = (*infoRec->OpaqueStippledFillChooser)(pGC); + break; + case FillTiled: + type = (*infoRec->TiledFillChooser)(pGC); + break; + } + + switch(type) { + case DO_SOLID: + function = XAARenderSolidRects; + break; + case DO_COLOR_8x8: + function = XAARenderColor8x8Rects; + break; + case DO_MONO_8x8: + function = XAARenderMono8x8Rects; + break; + case DO_CACHE_BLT: + function = XAARenderCacheBltRects; + break; + case DO_COLOR_EXPAND: + function = XAARenderColorExpandRects; + break; + case DO_CACHE_EXPAND: + function = XAARenderCacheExpandRects; + break; + case DO_IMAGE_WRITE: + function = XAARenderImageWriteRects; + break; + case DO_PIXMAP_COPY: + function = XAARenderPixmapCopyRects; + break; + default: + (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + return; + } + + if(xorg | yorg) { + int n = nrectFill; + xRectangle *prect = prectInit; + + while(n--) { + prect->x += xorg; + prect->y += yorg; + prect++; + } + } + + + XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg); +} + + + + /*********************\ + | Solid Rects | + \*********************/ + +static void +XAARenderSolidRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + (*infoRec->FillSolidRects) (infoRec->pScrn, + pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes); +} + + + /************************\ + | Mono 8x8 Rects | + \************************/ + +static void +XAARenderMono8x8Rects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + fg = pPriv->fg; bg = pPriv->bg; + break; + default: /* Muffle compiler */ + pPriv = NULL; /* Kaboom */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn, + fg, bg, pGC->alu, pGC->planemask, + nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); +} + + /*************************\ + | Color 8x8 Rects | + \*************************/ + +static void +XAARenderColor8x8Rects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + PixmapPtr pPix; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPix = pGC->tile.pixmap; + fg = -1; bg = -1; + break; + default: /* Muffle compiler */ + pPix = NULL; + fg = -1; bg = -1; + break; + } + + pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); + (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn, + pGC->alu, pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); +} + + + /****************************\ + | Color Expand Rects | + \****************************/ + +static void +XAARenderColorExpandRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); +} + + + /*************************\ + | Cache Blt Rects | + \*************************/ + +static void +XAARenderCacheBltRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + + switch(pGC->fillStyle) { + case FillStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, -1); + break; + case FillOpaqueStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, pGC->bgPixel); + break; + case FillTiled: + pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); + break; + default: /* Muffle compiler */ + pCache = NULL; + break; + } + + (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, + pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); +} + + + /****************************\ + | Cache Expand Rects | + \****************************/ + +static void +XAARenderCacheExpandRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); +} + + + + /***************************\ + | Image Write Rects | + \***************************/ + +static void +XAARenderImageWriteRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu, + pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->tile.pixmap); +} + + + + /***************************\ + | Pixmap Copy Rects | + \***************************/ + +static void +XAARenderPixmapCopyRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + + pCache->x = pPriv->offscreenArea->box.x1; + pCache->y = pPriv->offscreenArea->box.y1; + pCache->w = pCache->orig_w = + pPriv->offscreenArea->box.x2 - pCache->x; + pCache->h = pCache->orig_h = + pPriv->offscreenArea->box.y2 - pCache->y; + pCache->trans_color = -1; + + (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, + pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pCache); +} + + + + /************\ + | Solid | + \************/ + +void +XAAFillSolidRects( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int nBox, /* number of rectangles to fill */ + BoxPtr pBox /* Pointer to first rectangle to fill */ +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); + while(nBox--) { + (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + SET_SYNC_FLAG(infoRec); +} + + + + + /*********************\ + | 8x8 Mono Patterns | + \*********************/ + + +void +XAAFillMono8x8PatternRectsScreenOrigin( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int pattern0, int pattern1, + int xorigin, int yorigin +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + + if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = + (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + while(nBox--) { + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + SET_SYNC_FLAG(infoRec); +} + +void +XAAFillMono8x8PatternRects( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int pattern0, int pattern1, + int xorigin, int yorigin +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg, yorg; + XAACacheInfoPtr pCache = NULL; + + + if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + } + + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + + while(nBox--) { + xorg = (pBox->x1 - xorigin) & 0x07; + yorg = (pBox->y1 - yorigin) & 0x07; + + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + patx = pattern0; paty = pattern1; + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } else { + int slot = (yorg << 3) + xorg; + xorg = patx + pCache->offsets[slot].x; + yorg = paty + pCache->offsets[slot].y; + } + } + + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + /**********************\ + | 8x8 Color Patterns | + \**********************/ + + +void +XAAFillColor8x8PatternRectsScreenOrigin( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorigin, int yorigin, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pCache->x, paty = pCache->y; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + paty += pCache->offsets[slot].y; + patx += pCache->offsets[slot].x; + xorg = patx; yorg = paty; + } + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, + rop, planemask, pCache->trans_color); + + while(nBox--) { + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + SET_SYNC_FLAG(infoRec); +} + +void +XAAFillColor8x8PatternRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorigin, int yorigin, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int xorg, yorg; + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, + rop, planemask, pCache->trans_color); + + while(nBox--) { + xorg = (pBox->x1 - xorigin) & 0x07; + yorg = (pBox->y1 - yorigin) & 0x07; + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + yorg = pCache->y + pCache->offsets[slot].y; + xorg = pCache->x + pCache->offsets[slot].x; + } + + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + /***************\ + | Cache Blits | + \***************/ + +void +XAAFillCacheBltRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; + + (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, + pCache->trans_color); + + while(nBox--) { + y = pBox->y1; + phaseY = (y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (pBox->x1 - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + height = pBox->y2 - y; + width = pBox->x2 - pBox->x1; + +#if 0 + if (rop == GXcopy) { + while(1) { + w = width; skipleft = phaseX; x = pBox->x1; + blit_h = pCache->h - phaseY; + if(blit_h > height) blit_h = height; + + while(1) { + blit_w = pCache->w - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + skipleft, pCache->y + phaseY, + x, y, blit_w, blit_h); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + if(blit_w >= pCache->orig_w) break; + } + + /* Expand horizontally */ + if (w) { + skipleft -= phaseX; + if (skipleft < 0) skipleft += pCache->orig_w; + blit_w = x - pBox->x1 - skipleft; + while(w) { + if (blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pBox->x1 + skipleft, y, x, y, blit_w, blit_h); + w -= blit_w; + x += blit_w; + blit_w <<= 1; + } + } + + height -= blit_h; + if(!height) break; + y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + if(blit_h >= pCache->orig_h) break; + } + + /* Expand vertically */ + if (height) { + blit_w = pBox->x2 - pBox->x1; + phaseY -= (pBox->y1 - yorg) % pCache->orig_h; + if (phaseY < 0) phaseY += pCache->orig_h; + blit_h = y - pBox->y1 - phaseY; + while(height) { + if (blit_h > height) blit_h = height; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1, + pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h); + height -= blit_h; + y += blit_h; + blit_h <<= 1; + } + } + } else +#endif + { + while(1) { + w = width; skipleft = phaseX; x = pBox->x1; + blit_h = pCache->h - phaseY; + if(blit_h > height) blit_h = height; + + while(1) { + blit_w = pCache->w - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + skipleft, pCache->y + phaseY, + x, y, blit_w, blit_h); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + height -= blit_h; + if(!height) break; + y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } + } + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + + + /*******************\ + | Cache Expansion | + \*******************/ + + + +void +XAAFillCacheExpandRects( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; + int cacheWidth; + XAACacheInfoPtr pCache; + + pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); + + cacheWidth = (pCache->w * pScrn->bitsPerPixel) / + infoRec->CacheColorExpandDensity; + + (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, + planemask); + + while(nBox--) { + y = pBox->y1; + phaseY = (y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (pBox->x1 - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + height = pBox->y2 - y; + width = pBox->x2 - pBox->x1; + + while(1) { + w = width; skipleft = phaseX; x = pBox->x1; + blit_h = pCache->h - phaseY; + if(blit_h > height) blit_h = height; + + while(1) { + blit_w = cacheWidth - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenColorExpandFill)( + pScrn, x, y, blit_w, blit_h, + pCache->x, pCache->y + phaseY, skipleft); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + height -= blit_h; + if(!height) break; + y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + /******************\ + | Image Writes | + \******************/ + + + +/* This requires all LEFT_EDGE clipping. You get too many problems + with reading past the edge of the pattern otherwise */ + +static void +WriteColumn( + ScrnInfoPtr pScrn, + unsigned char *pSrc, + int x, int y, int w, int h, + int xoff, int yoff, + int pHeight, + int srcwidth, + int Bpp +) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + unsigned char *src; + Bool PlusOne = FALSE; + int skipleft, dwords; + + pSrc += (Bpp * xoff); + + if((skipleft = (long)pSrc & 0x03L)) { + if(Bpp == 3) + skipleft = 4 - skipleft; + else + skipleft /= Bpp; + + x -= skipleft; + w += skipleft; + + if(Bpp == 3) + pSrc -= 3 * skipleft; + else /* is this Alpha friendly ? */ + pSrc = (unsigned char*)((long)pSrc & ~0x03L); + } + + src = pSrc + (yoff * srcwidth); + + dwords = ((w * Bpp) + 3) >> 2; + + if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && + ((dwords * h) & 0x01)) { + PlusOne = TRUE; + } + + (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft); + + if(dwords > infoRec->ImageWriteRange) { + while(h--) { + XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src += srcwidth; + yoff++; + if(yoff >= pHeight) { + yoff = 0; + src = pSrc; + } + } + } else { + if(srcwidth == (dwords << 2)) { + int maxLines = infoRec->ImageWriteRange/dwords; + int step; + + while(h) { + step = pHeight - yoff; + if(step > maxLines) step = maxLines; + if(step > h) step = h; + + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords * step); + + src += (srcwidth * step); + yoff += step; + if(yoff >= pHeight) { + yoff = 0; + src = pSrc; + } + h -= step; + } + } else { + while(h--) { + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src += srcwidth; + yoff++; + if(yoff >= pHeight) { + yoff = 0; + src = pSrc; + } + } + } + } + + if(PlusOne) { + CARD32* base = (CARD32*)infoRec->ImageWriteBase; + *base = 0x00000000; + } +} + +void +XAAFillImageWriteRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, phaseY, phaseX, height, width, blit_w; + int pHeight = pPix->drawable.height; + int pWidth = pPix->drawable.width; + int Bpp = pPix->drawable.bitsPerPixel >> 3; + int srcwidth = pPix->devKind; + + (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1, + pPix->drawable.bitsPerPixel, pPix->drawable.depth); + + while(nBox--) { + x = pBox->x1; + phaseY = (pBox->y1 - yorg) % pHeight; + if(phaseY < 0) phaseY += pHeight; + phaseX = (x - xorg) % pWidth; + if(phaseX < 0) phaseX += pWidth; + height = pBox->y2 - pBox->y1; + width = pBox->x2 - x; + + while(1) { + blit_w = pWidth - phaseX; + if(blit_w > width) blit_w = width; + + WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1, + blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp); + + width -= blit_w; + if(!width) break; + x += blit_w; + phaseX = (phaseX + blit_w) % pWidth; + } + pBox++; + } + + if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + + + /*************\ + | Utilities | + \*************/ + + +void +XAAClipAndRenderRects( + GCPtr pGC, + ClipAndRenderRectsFunc BoxFunc, + int nrectFill, + xRectangle *prect, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int Right, Bottom, MaxBoxes; + BoxPtr pextent, pboxClipped, pboxClippedBase; + + MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec); + pboxClippedBase = (BoxPtr)infoRec->PreAllocMem; + pboxClipped = pboxClippedBase; + + if (REGION_NUM_RECTS(pGC->pCompositeClip) == 1) { + pextent = REGION_RECTS(pGC->pCompositeClip); + while (nrectFill--) { + pboxClipped->x1 = max(pextent->x1, prect->x); + pboxClipped->y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + pboxClipped->x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + pboxClipped->y2 = min(pextent->y2, Bottom); + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) { + pboxClipped++; + if(pboxClipped >= (pboxClippedBase + MaxBoxes)) { + (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); + pboxClipped = pboxClippedBase; + } + } + } + } else { + pextent = REGION_EXTENTS(pGC->pScreen, pGC->pCompositeClip); + while (nrectFill--) { + int n; + BoxRec box, *pbox; + + box.x1 = max(pextent->x1, prect->x); + box.y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + box.x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + box.y2 = min(pextent->y2, Bottom); + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = REGION_NUM_RECTS (pGC->pCompositeClip); + pbox = REGION_RECTS(pGC->pCompositeClip); + + /* 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 + MaxBoxes)) { + (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); + pboxClipped = pboxClippedBase; + } + } + } + } + } + + if(pboxClipped != pboxClippedBase) + (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase, + xorg, yorg); +} + + +int +XAAGetRectClipBoxes( + GCPtr pGC, + BoxPtr pboxClippedBase, + int nrectFill, + xRectangle *prectInit +){ + int Right, Bottom; + BoxPtr pextent, pboxClipped = pboxClippedBase; + xRectangle *prect = prectInit; + RegionPtr prgnClip = pGC->pCompositeClip; + + if (REGION_NUM_RECTS(prgnClip) == 1) { + pextent = REGION_RECTS(prgnClip); + while (nrectFill--) { + pboxClipped->x1 = max(pextent->x1, prect->x); + pboxClipped->y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + pboxClipped->x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + pboxClipped->y2 = min(pextent->y2, Bottom); + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) { + pboxClipped++; + } + } + } else { + pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); + while (nrectFill--) { + int n; + BoxRec box, *pbox; + + box.x1 = max(pextent->x1, prect->x); + box.y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + box.x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + box.y2 = min(pextent->y2, Bottom); + + 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++; + } + } + } + } + + return(pboxClipped - pboxClippedBase); +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaGC.c b/xorg-server/hw/xfree86/xaa/xaaGC.c new file mode 100644 index 000000000..e6083d529 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaGC.c @@ -0,0 +1,656 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "migc.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "xaawrap.h" + +static void XAAValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw); +static void XAAChangeGC(GCPtr pGC, unsigned long mask); +static void XAACopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); +static void XAADestroyGC(GCPtr pGC); +static void XAAChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects); +static void XAADestroyClip(GCPtr pGC); +static void XAACopyClip(GCPtr pgcDst, GCPtr pgcSrc); + +GCFuncs XAAGCFuncs = { + XAAValidateGC, XAAChangeGC, XAACopyGC, XAADestroyGC, + XAAChangeClip, XAADestroyClip, XAACopyClip +}; + +extern GCOps XAAPixmapOps; + +Bool +XAACreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); + Bool ret; + + XAA_SCREEN_PROLOGUE(pScreen,CreateGC); + + if((ret = (*pScreen->CreateGC)(pGC))) { + pGCPriv->wrapOps = NULL; + pGCPriv->wrapFuncs = pGC->funcs; + pGCPriv->XAAOps = &XAAFallbackOps; + pGCPriv->flags = 0; + pGCPriv->DashLength = 0; + pGCPriv->DashPattern = NULL; + pGCPriv->changes = 0; + /* initialize any other private fields here */ + pGC->funcs = &XAAGCFuncs; + } + + XAA_SCREEN_EPILOGUE(pScreen,CreateGC,XAACreateGC); + + return ret; +} + + +static void +XAAValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAA_GC_FUNC_PROLOGUE(pGC); + + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + + if((changes & GCPlaneMask) && + ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == + infoRec->FullPlanemasks[pGC->depth - 1])) + { + pGC->planemask = ~0; + } + + if(pGC->depth != 32) { + /* 0xffffffff is reserved for transparency */ + if(pGC->bgPixel == 0xffffffff) + pGC->bgPixel = 0x7fffffff; + if(pGC->fgPixel == 0xffffffff) + pGC->fgPixel = 0x7fffffff; + } + + if((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)){ + pGCPriv->flags = OPS_ARE_PIXMAP; + pGCPriv->changes |= changes; + + /* make sure we're not using videomemory pixmaps to render + onto system memory drawables */ + + if((pGC->fillStyle == FillTiled) && + IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) && + !OFFSCREEN_PIXMAP_LOCKED(pGC->tile.pixmap)) { + + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + FBAreaPtr area = pPriv->offscreenArea; + + XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */ + xf86FreeOffscreenArea(area); + } + } + else if(!infoRec->pScrn->vtSema && (pDraw->type == DRAWABLE_WINDOW)) { + pGCPriv->flags = 0; + pGCPriv->changes |= changes; + } + else { + if(!(pGCPriv->flags & OPS_ARE_ACCEL)) { + changes |= pGCPriv->changes; + pGCPriv->changes = 0; + } + pGCPriv->flags = OPS_ARE_ACCEL; + +#if 1 + /* Ugh. If we can't use the blitter on offscreen pixmaps used + as tiles, then we need to move them out as cfb can't handle + tiles with non-zero origins */ + + if((pGC->fillStyle == FillTiled) && + IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) && + (DO_PIXMAP_COPY != (*infoRec->TiledFillChooser)(pGC))) { + + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + FBAreaPtr area = pPriv->offscreenArea; + + XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */ + xf86FreeOffscreenArea(area); + } +#endif + } + + XAA_GC_FUNC_EPILOGUE(pGC); + + if(!(pGCPriv->flags & OPS_ARE_ACCEL)) return; + + if((changes & GCTile) && !pGC->tileIsPixel && pGC->tile.pixmap){ + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + + if(pixPriv->flags & DIRTY) { + pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK); + pGC->tile.pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + } + } + if((changes & GCStipple) && pGC->stipple){ + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + + if(pixPriv->flags & DIRTY) { + pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK); + pGC->stipple->drawable.serialNumber = NEXT_SERIAL_NUMBER; + } + } + + /* If our Ops are still the default ones we need to allocate new ones */ + if(pGC->ops == &XAAFallbackOps) { + if(!(pGCPriv->XAAOps = xalloc(sizeof(GCOps)))) { + pGCPriv->XAAOps = &XAAFallbackOps; + return; + } + /* make a modifiable copy of the default ops */ + memcpy(pGCPriv->XAAOps, &XAAFallbackOps, sizeof(GCOps)); + pGC->ops = pGCPriv->XAAOps; + changes = ~0; + } + + if(!changes) return; + + if((changes & GCDashList) && infoRec->ComputeDash) + infoRec->ComputeDash(pGC); + + if(changes & infoRec->FillSpansMask) + (*infoRec->ValidateFillSpans)(pGC, changes, pDraw); + + if(changes & infoRec->SetSpansMask) + (*infoRec->ValidateSetSpans)(pGC, changes, pDraw); + + if(changes & infoRec->PutImageMask) + (*infoRec->ValidatePutImage)(pGC, changes, pDraw); + + if(changes & infoRec->CopyAreaMask) + (*infoRec->ValidateCopyArea)(pGC, changes, pDraw); + + if(changes & infoRec->CopyPlaneMask) + (*infoRec->ValidateCopyPlane)(pGC, changes, pDraw); + + if(changes & infoRec->PolyPointMask) + (*infoRec->ValidatePolyPoint)(pGC, changes, pDraw); + + if(changes & infoRec->PolylinesMask) + (*infoRec->ValidatePolylines)(pGC, changes, pDraw); + + if(changes & infoRec->PolySegmentMask) + (*infoRec->ValidatePolySegment)(pGC, changes, pDraw); + + if(changes & infoRec->PolyRectangleMask) + (*infoRec->ValidatePolyRectangle)(pGC, changes, pDraw); + + if(changes & infoRec->PolyArcMask) + (*infoRec->ValidatePolyArc)(pGC, changes, pDraw); + + if(changes & infoRec->FillPolygonMask) + (*infoRec->ValidateFillPolygon)(pGC, changes, pDraw); + + if(changes & infoRec->PolyFillRectMask) + (*infoRec->ValidatePolyFillRect)(pGC, changes, pDraw); + + if(changes & infoRec->PolyFillArcMask) + (*infoRec->ValidatePolyFillArc)(pGC, changes, pDraw); + + if(changes & infoRec->PolyGlyphBltMask) + (*infoRec->ValidatePolyGlyphBlt)(pGC, changes, pDraw); + + if(changes & infoRec->ImageGlyphBltMask) + (*infoRec->ValidateImageGlyphBlt)(pGC, changes, pDraw); + + if(changes & infoRec->PolyText8Mask) + (*infoRec->ValidatePolyText8)(pGC, changes, pDraw); + + if(changes & infoRec->PolyText16Mask) + (*infoRec->ValidatePolyText16)(pGC, changes, pDraw); + + if(changes & infoRec->ImageText8Mask) + (*infoRec->ValidateImageText8)(pGC, changes, pDraw); + + if(changes & infoRec->ImageText16Mask) + (*infoRec->ValidateImageText16)(pGC, changes, pDraw); + + if(changes & infoRec->PushPixelsMask) + (*infoRec->ValidatePushPixels)(pGC, changes, pDraw); +} + + +static void +XAADestroyGC(GCPtr pGC) +{ + XAA_GC_FUNC_PROLOGUE (pGC); + + if(pGCPriv->XAAOps != &XAAFallbackOps) + xfree(pGCPriv->XAAOps); + + if(pGCPriv->DashPattern) + xfree(pGCPriv->DashPattern); + + (*pGC->funcs->DestroyGC)(pGC); + XAA_GC_FUNC_EPILOGUE (pGC); +} + +static void +XAAChangeGC ( + GCPtr pGC, + unsigned long mask +) +{ + XAA_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + XAA_GC_FUNC_EPILOGUE (pGC); + + /* we have to assume that shared memory pixmaps are dirty + because we can't wrap all operations on them */ + + if((mask & GCTile) && !pGC->tileIsPixel && + PIXMAP_IS_SHARED(pGC->tile.pixmap)) + { + XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + pPixPriv->flags |= DIRTY; + } + + if((mask & GCStipple) && PIXMAP_IS_SHARED(pGC->stipple)){ + XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + pPixPriv->flags |= DIRTY; + } +} + +static void +XAACopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst) +{ + XAA_GC_FUNC_PROLOGUE (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + XAA_GC_FUNC_EPILOGUE (pGCDst); +} +static void +XAAChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects ) +{ + XAA_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + XAA_GC_FUNC_EPILOGUE (pGC); +} + +static void +XAACopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + XAA_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + XAA_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +XAADestroyClip(GCPtr pGC) +{ + XAA_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + XAA_GC_FUNC_EPILOGUE (pGC); +} + +/**** Pixmap Wrappers ****/ + + + +static void +XAAFillSpansPixmap( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAASetSpansPixmap( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAAPutImagePixmap( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static RegionPtr +XAACopyAreaPixmap( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + RegionPtr ret; + + if(infoRec->pScrn->vtSema && + ((pSrc->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pSrc))) + { + if(infoRec->ReadPixmap && (pGC->alu == GXcopy) && + (pSrc->bitsPerPixel == pDst->bitsPerPixel) && + ((pGC->planemask & infoRec->FullPlanemasks[pSrc->depth - 1]) + == infoRec->FullPlanemasks[pSrc->depth - 1])) + { + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst)); + pixPriv->flags |= DIRTY; + + return (XAABitBlt( pSrc, pDst, pGC, + srcx, srcy, width, height, dstx, dsty, + XAADoImageRead, 0L)); + } else + if(infoRec->NeedToSync) { + (*infoRec->Sync)(infoRec->pScrn); + infoRec->NeedToSync = FALSE; + } + } + + { + XAA_PIXMAP_OP_PROLOGUE(pGC, pDst); + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + XAA_PIXMAP_OP_EPILOGUE(pGC); + } + return ret; +} + +static RegionPtr +XAACopyPlanePixmap( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + RegionPtr ret; + + XAA_PIXMAP_OP_PROLOGUE(pGC, pDst); + + if(infoRec->pScrn->vtSema && + ((pSrc->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pSrc))){ + if(infoRec->NeedToSync) { + (*infoRec->Sync)(infoRec->pScrn); + infoRec->NeedToSync = FALSE; + } + } + + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + XAA_PIXMAP_OP_EPILOGUE(pGC); + return ret; +} + +static void +XAAPolyPointPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + + +static void +XAAPolylinesPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAAPolySegmentPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAAPolyRectanglePixmap( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAAPolyArcPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAAFillPolygonPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + + +static void +XAAPolyFillRectPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + + +static void +XAAPolyFillArcPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static int +XAAPolyText8Pixmap( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + int ret; + + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + XAA_PIXMAP_OP_EPILOGUE(pGC); + return ret; +} + +static int +XAAPolyText16Pixmap( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + int ret; + + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + XAA_PIXMAP_OP_EPILOGUE(pGC); + return ret; +} + +static void +XAAImageText8Pixmap( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} +static void +XAAImageText16Pixmap( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + + +static void +XAAImageGlyphBltPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAAPolyGlyphBltPixmap( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +static void +XAAPushPixelsPixmap( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg +){ + XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + XAA_PIXMAP_OP_EPILOGUE(pGC); +} + +GCOps XAAPixmapOps = { + XAAFillSpansPixmap, XAASetSpansPixmap, + XAAPutImagePixmap, XAACopyAreaPixmap, + XAACopyPlanePixmap, XAAPolyPointPixmap, + XAAPolylinesPixmap, XAAPolySegmentPixmap, + XAAPolyRectanglePixmap, XAAPolyArcPixmap, + XAAFillPolygonPixmap, XAAPolyFillRectPixmap, + XAAPolyFillArcPixmap, XAAPolyText8Pixmap, + XAAPolyText16Pixmap, XAAImageText8Pixmap, + XAAImageText16Pixmap, XAAImageGlyphBltPixmap, + XAAPolyGlyphBltPixmap, XAAPushPixelsPixmap, + {NULL} /* devPrivate */ +}; diff --git a/xorg-server/hw/xfree86/xaa/xaaGCmisc.c b/xorg-server/hw/xfree86/xaa/xaaGCmisc.c new file mode 100644 index 000000000..5823cc064 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaGCmisc.c @@ -0,0 +1,429 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include <X11/fonts/fontstruct.h> +#include "dixfontstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "migc.h" +#include "mi.h" +#include "gcstruct.h" +#include "pixmapstr.h" + +void +XAAValidateCopyArea( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(infoRec->CopyArea && + CHECK_PLANEMASK(pGC,infoRec->CopyAreaFlags) && + CHECK_ROP(pGC,infoRec->CopyAreaFlags) && + CHECK_ROPSRC(pGC,infoRec->CopyAreaFlags) + ) + pGC->ops->CopyArea = infoRec->CopyArea; + else + pGC->ops->CopyArea = XAAFallbackOps.CopyArea; +} + +void +XAAValidatePutImage( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(infoRec->PutImage && + CHECK_PLANEMASK(pGC,infoRec->PutImageFlags) && + CHECK_ROP(pGC,infoRec->PutImageFlags) && + CHECK_ROPSRC(pGC,infoRec->PutImageFlags) && + CHECK_COLORS(pGC,infoRec->PutImageFlags) + ) + pGC->ops->PutImage = infoRec->PutImage; + else + pGC->ops->PutImage = XAAFallbackOps.PutImage; +} + +void +XAAValidateCopyPlane( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(infoRec->CopyPlane && + CHECK_PLANEMASK(pGC,infoRec->CopyPlaneFlags) && + CHECK_ROP(pGC,infoRec->CopyPlaneFlags) && + CHECK_ROPSRC(pGC,infoRec->CopyPlaneFlags) && + CHECK_COLORS(pGC,infoRec->CopyPlaneFlags) + ) + pGC->ops->CopyPlane = infoRec->CopyPlane; + else + pGC->ops->CopyPlane = XAAFallbackOps.CopyPlane; +} + +void +XAAValidatePushPixels( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(infoRec->PushPixelsSolid && + (pGC->fillStyle == FillSolid) && + CHECK_PLANEMASK(pGC,infoRec->PushPixelsFlags) && + CHECK_ROP(pGC,infoRec->PushPixelsFlags) && + CHECK_ROPSRC(pGC,infoRec->PushPixelsFlags) && + CHECK_FG(pGC,infoRec->PushPixelsFlags) && + (!(infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY) || + (pGC->alu == GXcopy)) + ) + pGC->ops->PushPixels = infoRec->PushPixelsSolid; + else + pGC->ops->PushPixels = XAAFallbackOps.PushPixels; + +} + + +/* We make the assumption that the FillSpans, PolyFillRect, FillPolygon + and PolyFillArc functions are linked in a way that they all have + the same rop/color/planemask restrictions. If the driver provides + a GC level replacement for these, it will need to supply a new + Validate functions if it breaks this assumption */ + + +void +XAAValidateFillSpans( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(pGC->fillStyle != FillTiled) changes &= ~GCTile; + if((pGC->fillStyle == FillTiled) || (pGC->fillStyle == FillSolid)) + changes &= ~GCStipple; + if(!changes) return; + + + pGC->ops->FillSpans = XAAFallbackOps.FillSpans; + pGC->ops->PolyFillRect = XAAFallbackOps.PolyFillRect; + pGC->ops->FillPolygon = XAAFallbackOps.FillPolygon; + pGC->ops->PolyFillArc = XAAFallbackOps.PolyFillArc; + + switch(pGC->fillStyle){ + case FillSolid: + if(infoRec->FillSpansSolid && + CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) && + CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) && + CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) && + CHECK_FG(pGC,infoRec->FillSpansSolidFlags) + ) { + pGC->ops->FillSpans = infoRec->FillSpansSolid; + pGC->ops->PolyFillRect = infoRec->PolyFillRectSolid; + pGC->ops->FillPolygon = infoRec->FillPolygonSolid; + pGC->ops->PolyFillArc = infoRec->PolyFillArcSolid; + } + break; + /* The [Stippled/OpaqueStippled/Tiled]FillChooser + functions do the validating */ + case FillStippled: + if(infoRec->FillSpansStippled) { + pGC->ops->FillSpans = infoRec->FillSpansStippled; + pGC->ops->PolyFillRect = infoRec->PolyFillRectStippled; + if(infoRec->FillPolygonStippled) + pGC->ops->FillPolygon = infoRec->FillPolygonStippled; + else pGC->ops->FillPolygon = miFillPolygon; + pGC->ops->PolyFillArc = miPolyFillArc; + } + break; + case FillOpaqueStippled: + if(infoRec->FillSpansOpaqueStippled) { + pGC->ops->FillSpans = infoRec->FillSpansOpaqueStippled; + pGC->ops->PolyFillRect = infoRec->PolyFillRectOpaqueStippled; + if(infoRec->FillPolygonOpaqueStippled) + pGC->ops->FillPolygon = infoRec->FillPolygonOpaqueStippled; + else pGC->ops->FillPolygon = miFillPolygon; + pGC->ops->PolyFillArc = miPolyFillArc; + } + break; + case FillTiled: + if(infoRec->FillSpansTiled) { + pGC->ops->FillSpans = infoRec->FillSpansTiled; + pGC->ops->PolyFillRect = infoRec->PolyFillRectTiled; + if(infoRec->FillPolygonTiled) + pGC->ops->FillPolygon = infoRec->FillPolygonTiled; + else pGC->ops->FillPolygon = miFillPolygon; + pGC->ops->PolyFillArc = miPolyFillArc; + } + break; + default: return; + } +} + + +/* We make the assumption that these Text8/16 and GlyphBlt functions + are linked in a way that they all have the same rop/color/planemask + restrictions. If the driver provides a GC level replacement for + these, it will need to supply a new Validate functions if it breaks + this assumption */ + +void +XAAValidatePolyGlyphBlt( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + Bool BigFont = FALSE; + + pGC->ops->PolyText8 = XAAFallbackOps.PolyText8; + pGC->ops->PolyText16 = XAAFallbackOps.PolyText16; + pGC->ops->PolyGlyphBlt = XAAFallbackOps.PolyGlyphBlt; + + if(!pGC->font) return; + if(pGC->fillStyle != FillSolid) return; + + if((FONTMAXBOUNDS(pGC->font, rightSideBearing) - + FONTMINBOUNDS(pGC->font, leftSideBearing) > 32)) + BigFont = TRUE; + + /* no funny business */ + if((FONTMINBOUNDS(pGC->font, characterWidth) <= 0) || + ((FONTASCENT(pGC->font) + FONTDESCENT(pGC->font)) <= 0)) + return; + + /* Check for TE Fonts */ + if(!TERMINALFONT(pGC->font) || BigFont) { + if(infoRec->PolyGlyphBltNonTE && + CHECK_PLANEMASK(pGC,infoRec->PolyGlyphBltNonTEFlags) && + CHECK_ROP(pGC,infoRec->PolyGlyphBltNonTEFlags) && + CHECK_ROPSRC(pGC,infoRec->PolyGlyphBltNonTEFlags) && + CHECK_FG(pGC,infoRec->PolyGlyphBltNonTEFlags) && + (!(infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY) || + (pGC->alu == GXcopy)) + ) { + pGC->ops->PolyText8 = infoRec->PolyText8NonTE; + pGC->ops->PolyText16 = infoRec->PolyText16NonTE; + pGC->ops->PolyGlyphBlt = infoRec->PolyGlyphBltNonTE; + } + } else { + if(infoRec->PolyGlyphBltTE && + CHECK_PLANEMASK(pGC,infoRec->PolyGlyphBltTEFlags) && + CHECK_ROP(pGC,infoRec->PolyGlyphBltTEFlags) && + CHECK_ROPSRC(pGC,infoRec->PolyGlyphBltNonTEFlags) && + CHECK_FG(pGC,infoRec->PolyGlyphBltTEFlags) && + (!(infoRec->PolyGlyphBltTEFlags & TRANSPARENCY_GXCOPY_ONLY) || + (pGC->alu == GXcopy)) + ) { + pGC->ops->PolyText8 = infoRec->PolyText8TE; + pGC->ops->PolyText16 = infoRec->PolyText16TE; + pGC->ops->PolyGlyphBlt = infoRec->PolyGlyphBltTE; + } + } +} + +void +XAAValidateImageGlyphBlt( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + Bool BigFont = FALSE; + + pGC->ops->ImageText8 = XAAFallbackOps.ImageText8; + pGC->ops->ImageText16 = XAAFallbackOps.ImageText16; + pGC->ops->ImageGlyphBlt = XAAFallbackOps.ImageGlyphBlt; + + if(!pGC->font) return; + + if((FONTMAXBOUNDS(pGC->font, rightSideBearing) - + FONTMINBOUNDS(pGC->font, leftSideBearing) > 32)) + BigFont = TRUE; + + /* no funny business */ + if((FONTMINBOUNDS(pGC->font, characterWidth) <= 0) || + ((FONTASCENT(pGC->font) + FONTDESCENT(pGC->font)) <= 0)) + return; + + + /* Check for TE Fonts */ + if(!TERMINALFONT(pGC->font) || BigFont || (pGC->depth == 32)) { + if(infoRec->ImageGlyphBltNonTE && + CHECK_PLANEMASK(pGC,infoRec->ImageGlyphBltNonTEFlags) && + CHECK_FG(pGC,infoRec->ImageGlyphBltNonTEFlags) && + infoRec->SetupForSolidFill && + CHECK_PLANEMASK(pGC,infoRec->SolidFillFlags) && + CHECK_BG(pGC,infoRec->SolidFillFlags)) + { + pGC->ops->ImageText8 = infoRec->ImageText8NonTE; + pGC->ops->ImageText16 = infoRec->ImageText16NonTE; + pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltNonTE; + } + } else if(infoRec->ImageGlyphBltTE && + CHECK_PLANEMASK(pGC,infoRec->ImageGlyphBltTEFlags)){ + if(!(infoRec->ImageGlyphBltTEFlags & TRANSPARENCY_ONLY) && + CHECK_COLORS(pGC,infoRec->ImageGlyphBltTEFlags)) + { + pGC->ops->ImageText8 = infoRec->ImageText8TE; + pGC->ops->ImageText16 = infoRec->ImageText16TE; + pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltTE; + } else { + if(CHECK_FG(pGC,infoRec->ImageGlyphBltTEFlags) && + infoRec->SetupForSolidFill && + CHECK_PLANEMASK(pGC,infoRec->SolidFillFlags) && + CHECK_BG(pGC,infoRec->SolidFillFlags)) + { + pGC->ops->ImageText8 = infoRec->ImageText8TE; + pGC->ops->ImageText16 = infoRec->ImageText16TE; + pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltTE; + } + } + } +} + + +void +XAAValidatePolylines( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); + + if(pGC->lineStyle == LineSolid) changes &= ~GCDashList; + if(!changes) return; + + pGC->ops->PolySegment = XAAFallbackOps.PolySegment; + pGC->ops->Polylines = XAAFallbackOps.Polylines; + pGC->ops->PolyRectangle = XAAFallbackOps.PolyRectangle; + pGC->ops->PolyArc = XAAFallbackOps.PolyArc; + + if((pGC->ops->FillSpans != XAAFallbackOps.FillSpans) && + (pGC->lineWidth > 0)){ + + pGC->ops->PolyArc = miPolyArc; + pGC->ops->PolySegment = miPolySegment; + pGC->ops->PolyRectangle = miPolyRectangle; + if(pGC->lineStyle == LineSolid) + pGC->ops->Polylines = miWideLine; + else + pGC->ops->Polylines = miWideDash; + } + + if((pGC->lineWidth == 0) && (pGC->fillStyle == FillSolid)) { + + if(pGC->lineStyle == LineSolid) { + + if(infoRec->PolyRectangleThinSolid && + CHECK_PLANEMASK(pGC,infoRec->PolyRectangleThinSolidFlags) && + CHECK_ROP(pGC,infoRec->PolyRectangleThinSolidFlags) && + CHECK_ROPSRC(pGC,infoRec->PolyRectangleThinSolidFlags) && + CHECK_FG(pGC,infoRec->PolyRectangleThinSolidFlags)) { + + pGC->ops->PolyRectangle = infoRec->PolyRectangleThinSolid; + } + + if(infoRec->PolySegmentThinSolid && + CHECK_PLANEMASK(pGC,infoRec->PolySegmentThinSolidFlags) && + CHECK_ROP(pGC,infoRec->PolySegmentThinSolidFlags) && + CHECK_ROPSRC(pGC,infoRec->PolySegmentThinSolidFlags) && + CHECK_FG(pGC,infoRec->PolySegmentThinSolidFlags)) { + + pGC->ops->PolySegment = infoRec->PolySegmentThinSolid; + } + + if(infoRec->PolylinesThinSolid && + CHECK_PLANEMASK(pGC,infoRec->PolylinesThinSolidFlags) && + CHECK_ROP(pGC,infoRec->PolylinesThinSolidFlags) && + CHECK_ROPSRC(pGC,infoRec->PolylinesThinSolidFlags) && + CHECK_FG(pGC,infoRec->PolylinesThinSolidFlags)) { + + pGC->ops->Polylines = infoRec->PolylinesThinSolid; + } + } else if((pGC->lineStyle == LineOnOffDash) && pGCPriv->DashPattern){ + + if(infoRec->PolySegmentThinDashed && + !(infoRec->PolySegmentThinDashedFlags & NO_TRANSPARENCY) && + ((pGC->alu == GXcopy) || !(infoRec->PolySegmentThinDashedFlags & + TRANSPARENCY_GXCOPY_ONLY)) && + CHECK_PLANEMASK(pGC,infoRec->PolySegmentThinDashedFlags) && + CHECK_ROP(pGC,infoRec->PolySegmentThinDashedFlags) && + CHECK_ROPSRC(pGC,infoRec->PolySegmentThinDashedFlags) && + CHECK_FG(pGC,infoRec->PolySegmentThinDashedFlags)) { + + pGC->ops->PolySegment = infoRec->PolySegmentThinDashed; + } + + if(infoRec->PolylinesThinDashed && + !(infoRec->PolylinesThinDashedFlags & NO_TRANSPARENCY) && + ((pGC->alu == GXcopy) || !(infoRec->PolylinesThinDashedFlags & + TRANSPARENCY_GXCOPY_ONLY)) && + CHECK_PLANEMASK(pGC,infoRec->PolylinesThinDashedFlags) && + CHECK_ROP(pGC,infoRec->PolylinesThinDashedFlags) && + CHECK_ROPSRC(pGC,infoRec->PolylinesThinDashedFlags) && + CHECK_FG(pGC,infoRec->PolylinesThinDashedFlags)) { + + pGC->ops->Polylines = infoRec->PolylinesThinDashed; + } + + if(pGC->ops->Polylines != XAAFallbackOps.Polylines) + pGC->ops->PolyRectangle = miPolyRectangle; + + } else if(pGCPriv->DashPattern && (pGC->depth != 32)) { + /* LineDoubleDash */ + if(infoRec->PolySegmentThinDashed && + !(infoRec->PolySegmentThinDashedFlags & TRANSPARENCY_ONLY) && + CHECK_PLANEMASK(pGC,infoRec->PolySegmentThinDashedFlags) && + CHECK_ROP(pGC,infoRec->PolySegmentThinDashedFlags) && + CHECK_ROPSRC(pGC,infoRec->PolySegmentThinDashedFlags) && + CHECK_COLORS(pGC,infoRec->PolySegmentThinDashedFlags)) { + + pGC->ops->PolySegment = infoRec->PolySegmentThinDashed; + } + + if(infoRec->PolylinesThinDashed && + !(infoRec->PolylinesThinDashedFlags & TRANSPARENCY_ONLY) && + CHECK_PLANEMASK(pGC,infoRec->PolylinesThinDashedFlags) && + CHECK_ROP(pGC,infoRec->PolylinesThinDashedFlags) && + CHECK_ROPSRC(pGC,infoRec->PolylinesThinDashedFlags) && + CHECK_COLORS(pGC,infoRec->PolylinesThinDashedFlags)) { + + pGC->ops->Polylines = infoRec->PolylinesThinDashed; + } + + if(pGC->ops->Polylines != XAAFallbackOps.Polylines) + pGC->ops->PolyRectangle = miPolyRectangle; + + } + } + + if(infoRec->PolylinesWideSolid && + (pGC->lineWidth > 0) && + (pGC->fillStyle == FillSolid) && + (pGC->lineStyle == LineSolid) && + CHECK_PLANEMASK(pGC,infoRec->PolylinesWideSolidFlags) && + CHECK_ROP(pGC,infoRec->PolylinesWideSolidFlags) && + CHECK_ROPSRC(pGC,infoRec->PolylinesWideSolidFlags) && + CHECK_FG(pGC,infoRec->PolylinesWideSolidFlags)) { + + pGC->ops->Polylines = infoRec->PolylinesWideSolid; + } +} diff --git a/xorg-server/hw/xfree86/xaa/xaaImage.c b/xorg-server/hw/xfree86/xaa/xaaImage.c new file mode 100644 index 000000000..910c7e1e2 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaImage.c @@ -0,0 +1,521 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#include "servermd.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "mi.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + +void XAAMoveDWORDS_FixedBase( + register CARD32* dest, + register CARD32* src, + register int dwords ) +{ + while(dwords & ~0x03) { + *dest = *src; + *dest = *(src + 1); + *dest = *(src + 2); + *dest = *(src + 3); + dwords -= 4; + src += 4; + } + + if(!dwords) return; + *dest = *src; + if(dwords == 1) return; + *dest = *(src + 1); + if(dwords == 2) return; + *dest = *(src + 2); +} + +void XAAMoveDWORDS( + register CARD32* dest, + register CARD32* src, + register int dwords ) +{ + while(dwords & ~0x03) { + *dest = *src; + *(dest + 1) = *(src + 1); + *(dest + 2) = *(src + 2); + *(dest + 3) = *(src + 3); + src += 4; + dest += 4; + dwords -= 4; + } + if(!dwords) return; + *dest = *src; + if(dwords == 1) return; + *(dest + 1) = *(src + 1); + if(dwords == 2) return; + *(dest + 2) = *(src + 2); +} + +void XAAMoveDWORDS_FixedSrc( + register CARD32* dest, + register CARD32* src, + register int dwords ) +{ + while(dwords & ~0x03) { + *dest = *src; + *(dest + 1) = *src; + *(dest + 2) = *src; + *(dest + 3) = *src; + dest += 4; + dwords -= 4; + } + if(!dwords) return; + *dest = *src; + if(dwords == 1) return; + *(dest + 1) = *src; + if(dwords == 2) return; + *(dest + 2) = *src; +} + +static void +XAAWritePixmap32To24( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *srcInit, + int srcwidth, /* bytes */ + int rop, + unsigned int planemask, + int trans +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int count, dwords = ((w * 3) + 3) >> 2; + CARD32 *src, *dst; + Bool PlusOne = FALSE; + + if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && + ((dwords * h) & 0x01)) { + PlusOne = TRUE; + } + + (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, trans, 24, 24); + (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, 0); + + if(dwords > infoRec->ImageWriteRange) { + dst = (CARD32*)infoRec->ImageWriteBase; + while(h--) { + src = (CARD32*)srcInit; + count = w; + + while(count >= 4) { + *dst = (src[0] & 0x00ffffff) | (src[1] << 24); + *dst = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16); + *dst = ((src[2] >> 16) & 0x000000ff) | (src[3] << 8); + src += 4; + count -= 4; + } + switch(count) { + case 0: break; + case 1: *dst = src[0]; + break; + case 2: *dst = (src[0] & 0x00ffffff) | (src[1] << 24); + *dst = src[1] >> 8; + break; + default: *dst = (src[0] & 0x00ffffff) | (src[1] << 24); + *dst = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16); + *dst = src[2] >> 16; + break; + } + srcInit += srcwidth; + } + } else { + while(h--) { + dst = (CARD32*)infoRec->ImageWriteBase; + src = (CARD32*)srcInit; + count = w; + + while(count >= 4) { + dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24); + dst[1] = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16); + dst[2] = ((src[2] >> 16) & 0x000000ff) | (src[3] << 8); + dst += 3; + src += 4; + count -= 4; + } + switch(count) { + case 0: break; + case 1: dst[0] = src[0]; + break; + case 2: dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24); + dst[1] = src[1] >> 8; + break; + default: dst[0] = (src[0] & 0x00ffffff) | (src[1] << 24); + dst[1] = ((src[1] >> 8) & 0x0000ffff) | (src[2] << 16); + dst[2] = src[2] >> 16; + break; + } + srcInit += srcwidth; + } + } + + if(PlusOne) { + CARD32* base = (CARD32*)infoRec->ImageWriteBase; + *base = 0x00000000; + } + + if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); + +} + +void +XAAWritePixmap ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, /* bytes */ + int rop, + unsigned int planemask, + int trans, + int bpp, int depth +){ + XAAInfoRecPtr infoRec; + int dwords, skipleft, Bpp; + Bool beCareful, PlusOne; + + if((bpp == 32) && (pScrn->bitsPerPixel == 24)) { + XAAWritePixmap32To24(pScrn, x, y, w, h, src, srcwidth, + rop, planemask, trans); + return; + } + + infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + beCareful = PlusOne = FALSE; + Bpp = bpp >> 3; + + if((skipleft = (long)src & 0x03L)) { + if(!(infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) { + skipleft = 0; + beCareful = TRUE; + goto BAD_ALIGNMENT; + } + + if(Bpp == 3) + skipleft = 4 - skipleft; + else + skipleft /= Bpp; + + if((x < skipleft) && !(infoRec->ImageWriteFlags & + LEFT_EDGE_CLIPPING_NEGATIVE_X)) { + skipleft = 0; + beCareful = TRUE; + goto BAD_ALIGNMENT; + } + + x -= skipleft; + w += skipleft; + + if(Bpp == 3) + src -= 3 * skipleft; + else /* is this Alpha friendly ? */ + src = (unsigned char*)((long)src & ~0x03L); + } + +BAD_ALIGNMENT: + + dwords = ((w * Bpp) + 3) >> 2; + + if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && + ((dwords * h) & 0x01)) { + PlusOne = TRUE; + } + + + (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, trans, bpp, depth); + (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft); + + if(beCareful) { + /* in cases with bad alignment we have to be careful not + to read beyond the end of the source */ + if(((x * Bpp) + (dwords << 2)) > srcwidth) h--; + else beCareful = FALSE; + } + + if(dwords > infoRec->ImageWriteRange) { + while(h--) { + XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src += srcwidth; + } + if(beCareful) { + int shift = ((long)src & 0x03L) << 3; + if(--dwords) + XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src = (unsigned char*)((long)(src + (dwords << 2)) & ~0x03L); + *((CARD32*)infoRec->ImageWriteBase) = *((CARD32*)src) >> shift; + } + } else { + if(srcwidth == (dwords << 2)) { + int decrement = infoRec->ImageWriteRange/dwords; + + while(h > decrement) { + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords * decrement); + src += (srcwidth * decrement); + h -= decrement; + } + if(h) { + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords * h); + if(beCareful) src += (srcwidth * h); + } + } else { + while(h--) { + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src += srcwidth; + } + } + + if(beCareful) { + int shift = ((long)src & 0x03L) << 3; + if(--dwords) + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src = (unsigned char*)((long)(src + (dwords << 2)) & ~0x03L); + + ((CARD32*)infoRec->ImageWriteBase)[dwords] = + *((CARD32*)src) >> shift; + } + } + + if(PlusOne) { + CARD32* base = (CARD32*)infoRec->ImageWriteBase; + *base = 0x00000000; + } + + if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + + +void +XAAWritePixmapScanline ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, /* bytes */ + int rop, + unsigned int planemask, + int trans, + int bpp, int depth +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int dwords, skipleft, bufferNo = 0, Bpp = bpp >> 3; + Bool beCareful = FALSE; + CARD32* base; + + if((skipleft = (long)src & 0x03L)) { + if(!(infoRec->ScanlineImageWriteFlags & LEFT_EDGE_CLIPPING)) { + skipleft = 0; + beCareful = TRUE; + goto BAD_ALIGNMENT; + } + + if(Bpp == 3) + skipleft = 4 - skipleft; + else + skipleft /= Bpp; + + if((x < skipleft) && !(infoRec->ScanlineImageWriteFlags & + LEFT_EDGE_CLIPPING_NEGATIVE_X)) { + skipleft = 0; + beCareful = TRUE; + goto BAD_ALIGNMENT; + } + + x -= skipleft; + w += skipleft; + + if(Bpp == 3) + src -= 3 * skipleft; + else + src = (unsigned char*)((long)src & ~0x03L); + } + +BAD_ALIGNMENT: + + dwords = ((w * Bpp) + 3) >> 2; + + (*infoRec->SetupForScanlineImageWrite)( + pScrn, rop, planemask, trans, bpp, depth); + (*infoRec->SubsequentScanlineImageWriteRect)(pScrn, x, y, w, h, skipleft); + + if(beCareful) { + /* in cases with bad alignment we have to be careful not + to read beyond the end of the source */ + if(((x * Bpp) + (dwords << 2)) > srcwidth) h--; + else beCareful = FALSE; + } + + while(h--) { + base = (CARD32*)infoRec->ScanlineImageWriteBuffers[bufferNo]; + XAAMoveDWORDS(base, (CARD32*)src, dwords); + (*infoRec->SubsequentImageWriteScanline)(pScrn, bufferNo++); + src += srcwidth; + if(bufferNo >= infoRec->NumScanlineImageWriteBuffers) + bufferNo = 0; + } + + if(beCareful) { + int shift = ((long)src & 0x03L) << 3; + base = (CARD32*)infoRec->ScanlineImageWriteBuffers[bufferNo]; + if(--dwords) + XAAMoveDWORDS(base,(CARD32*)src, dwords); + src = (unsigned char*)((long)(src + (dwords << 2)) & ~0x03L); + + base[dwords] = *((CARD32*)src) >> shift; + (*infoRec->SubsequentImageWriteScanline)(pScrn, bufferNo); + } + + SET_SYNC_FLAG(infoRec); +} + + +void +XAAPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, + int y, + int w, + int h, + int leftPad, + int format, + char *pImage +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int bpp = BitsPerPixel(depth); + Bool depthBug = FALSE; + if(!w || !h) return; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + depthBug = XAA_DEPTH_BUG(pGC); + + if(((format == ZPixmap) && infoRec->WritePixmap && + ((pDraw->bitsPerPixel == bpp) || + ((pDraw->bitsPerPixel == 24) && (bpp == 32) && + (infoRec->WritePixmapFlags & CONVERT_32BPP_TO_24BPP))) && + CHECK_ROP(pGC,infoRec->WritePixmapFlags) && + CHECK_ROPSRC(pGC,infoRec->WritePixmapFlags) && + CHECK_PLANEMASK(pGC,infoRec->WritePixmapFlags) && + CHECK_NO_GXCOPY(pGC,infoRec->WritePixmapFlags)) || + ((format == XYBitmap) && !depthBug && infoRec->WriteBitmap && + CHECK_ROP(pGC,infoRec->WriteBitmapFlags) && + CHECK_ROPSRC(pGC,infoRec->WriteBitmapFlags) && + CHECK_PLANEMASK(pGC,infoRec->WriteBitmapFlags) && + CHECK_COLORS(pGC,infoRec->WriteBitmapFlags) && + !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) || + ((format == XYPixmap) && !depthBug && infoRec->WriteBitmap && + CHECK_ROP(pGC,infoRec->WriteBitmapFlags) && + CHECK_ROPSRC(pGC,infoRec->WriteBitmapFlags) && + !(infoRec->WriteBitmapFlags & NO_PLANEMASK) && + !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))){ + + int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip); + BoxPtr pbox, pClipBoxes; + int nboxes, srcx, srcy, srcwidth; + xRectangle TheRect; + + TheRect.x = pDraw->x + x; + TheRect.y = pDraw->y + y; + TheRect.width = w; + TheRect.height = h; + + if(MaxBoxes > (infoRec->PreAllocSize/sizeof(BoxRec))) { + pClipBoxes = xalloc(MaxBoxes * sizeof(BoxRec)); + if(!pClipBoxes) return; + } else pClipBoxes = (BoxPtr)infoRec->PreAllocMem; + + nboxes = XAAGetRectClipBoxes(pGC, pClipBoxes, 1, &TheRect); + pbox = pClipBoxes; + + if(format == XYBitmap) { + srcwidth = BitmapBytePad(leftPad + w); + while(nboxes--) { + srcx = pbox->x1 - TheRect.x + leftPad; + srcy = pbox->y1 - TheRect.y; + (*infoRec->WriteBitmap)(infoRec->pScrn, pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, + (unsigned char*)pImage + + (srcwidth * srcy) + ((srcx >> 5) << 2), + srcwidth, srcx & 31, pGC->fgPixel, pGC->bgPixel, + pGC->alu, pGC->planemask); + pbox++; + } + } else if(format == ZPixmap) { + int Bpp = bpp >> 3; + srcwidth = PixmapBytePad(leftPad + w, depth); + while(nboxes--) { + srcx = pbox->x1 - TheRect.x + leftPad; + srcy = pbox->y1 - TheRect.y; + (*infoRec->WritePixmap)(infoRec->pScrn, pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, + (unsigned char*)pImage + + (srcwidth * srcy) + (srcx * Bpp), + srcwidth, pGC->alu, pGC->planemask, -1, + Bpp << 3, depth); + pbox++; + } + } else { /* XYPixmap */ + int depth = pGC->depth; + int numBox, increment; + unsigned long i, mask; + BoxPtr pntBox; + + srcwidth = BitmapBytePad(w + leftPad); + increment = h * srcwidth; + i = 1 << (depth - 1); + mask = ~0; + + if((infoRec->pScrn->overlayFlags & OVERLAY_8_32_PLANAR) && + (pGC->depth == 8)){ + i = 0x80000000; mask = 0xff000000; + } + + for(; i & mask; i >>= 1, pImage += increment) { + if(i & pGC->planemask) { + pntBox = pbox; + numBox = nboxes; + while(numBox--) { + srcx = pntBox->x1 - TheRect.x + leftPad; + srcy = pntBox->y1 - TheRect.y; + (*infoRec->WriteBitmap)(infoRec->pScrn, + pntBox->x1, pntBox->y1, + pntBox->x2 - pntBox->x1, + pntBox->y2 - pntBox->y1, + (unsigned char*)pImage + + (srcwidth * srcy) + ((srcx >> 5) << 2), + srcwidth, srcx & 31, ~0, 0, pGC->alu, i); + pntBox++; + } + } + } + + } + + if(pClipBoxes != (BoxPtr)infoRec->PreAllocMem) + xfree(pClipBoxes); + } else + XAAFallbackOps.PutImage(pDraw, pGC, depth, x, y, w, h, leftPad, + format, pImage); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaInit.c b/xorg-server/hw/xfree86/xaa/xaaInit.c new file mode 100644 index 000000000..22a35a0a0 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaInit.c @@ -0,0 +1,622 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "mi.h" +#include "miline.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" +#include "xf86fbman.h" +#include "servermd.h" + +#define MAX_PREALLOC_MEM 65536 /* MUST be >= 1024 */ + +#define MIN_OFFPIX_SIZE (320*200) + +static Bool XAACloseScreen(int i, ScreenPtr pScreen); +static void XAAGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, + unsigned int format, unsigned long planemask, + char *pdstLine); +static void XAAGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, + int *pwidth, int nspans, char *pdstStart); +static PixmapPtr XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, + unsigned usage_hint); +static Bool XAADestroyPixmap(PixmapPtr pPixmap); +static Bool XAAEnterVT (int index, int flags); +static void XAALeaveVT (int index, int flags); +static int XAASetDGAMode(int index, int num, DGADevicePtr devRet); +static void XAAEnableDisableFBAccess (int index, Bool enable); +static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask); + +static DevPrivateKey XAAScreenKey = &XAAScreenKey; +static DevPrivateKey XAAGCKey = &XAAGCKey; +static DevPrivateKey XAAPixmapKey = &XAAPixmapKey; + +DevPrivateKey XAAGetScreenKey(void) { + return XAAScreenKey; +} + +DevPrivateKey XAAGetGCKey(void) { + return XAAGCKey; +} + +DevPrivateKey XAAGetPixmapKey(void) { + return XAAPixmapKey; +} + +/* temp kludge */ +static Bool SwitchedOut = FALSE; + +XAAInfoRecPtr +XAACreateInfoRec() +{ + XAAInfoRecPtr infoRec; + + infoRec = xcalloc(1, sizeof(XAAInfoRec)); + if(infoRec) + infoRec->CachePixelGranularity = -1; + + return infoRec; +} + +void +XAADestroyInfoRec(XAAInfoRecPtr infoRec) +{ + if(!infoRec) return; + + if(infoRec->ClosePixmapCache) + (*infoRec->ClosePixmapCache)(infoRec->pScrn->pScreen); + + if(infoRec->PreAllocMem) + xfree(infoRec->PreAllocMem); + + if(infoRec->PixmapCachePrivate) + xfree(infoRec->PixmapCachePrivate); + + xfree(infoRec); +} + + +Bool +XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XAAScreenPtr pScreenPriv; + int i; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + /* Return successfully if no acceleration wanted */ + if (!infoRec) + return TRUE; + + if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec))) + return FALSE; + + if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec))) + return FALSE; + + if (!(pScreenPriv = xalloc(sizeof(XAAScreenRec)))) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv); + + if(!xf86FBManagerRunning(pScreen)) + infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS); + if(!(infoRec->Flags & LINEAR_FRAMEBUFFER)) + infoRec->Flags &= ~OFFSCREEN_PIXMAPS; + + if(!infoRec->FullPlanemask) { /* for backwards compatibility */ + infoRec->FullPlanemask = (1 << pScrn->depth) - 1; + infoRec->FullPlanemasks[pScrn->depth - 1] = infoRec->FullPlanemask; + } + + for(i = 0; i < 32; i++) { + if(!infoRec->FullPlanemasks[i]) /* keep any set by caller */ + infoRec->FullPlanemasks[i] = (1 << (i+1)) - 1; + } + + if(!XAAInitAccel(pScreen, infoRec)) return FALSE; + pScreenPriv->AccelInfoRec = infoRec; + infoRec->ScratchGC.pScreen = pScreen; + + + if(!infoRec->GetImage) + infoRec->GetImage = XAAGetImage; + if(!infoRec->GetSpans) + infoRec->GetSpans = XAAGetSpans; + if(!infoRec->CopyWindow) + infoRec->CopyWindow = XAACopyWindow; + + pScreenPriv->CreateGC = pScreen->CreateGC; + pScreen->CreateGC = XAACreateGC; + pScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = XAACloseScreen; + pScreenPriv->GetImage = pScreen->GetImage; + pScreen->GetImage = infoRec->GetImage; + pScreenPriv->GetSpans = pScreen->GetSpans; + pScreen->GetSpans = infoRec->GetSpans; + pScreenPriv->CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = infoRec->CopyWindow; + pScreenPriv->CreatePixmap = pScreen->CreatePixmap; + pScreen->CreatePixmap = XAACreatePixmap; + pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap; + pScreen->DestroyPixmap = XAADestroyPixmap; + pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; + pScreen->ChangeWindowAttributes = XAAChangeWindowAttributes; + + pScreenPriv->EnterVT = pScrn->EnterVT; + pScrn->EnterVT = XAAEnterVT; + pScreenPriv->LeaveVT = pScrn->LeaveVT; + pScrn->LeaveVT = XAALeaveVT; + pScreenPriv->SetDGAMode = pScrn->SetDGAMode; + pScrn->SetDGAMode = XAASetDGAMode; + pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; + pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess; + + pScreenPriv->WindowExposures = pScreen->WindowExposures; +#ifdef RENDER + if (ps) + { + pScreenPriv->Composite = ps->Composite; + ps->Composite = XAAComposite; + pScreenPriv->Glyphs = ps->Glyphs; + ps->Glyphs = XAAGlyphs; + } +#endif + if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR) + XAASetupOverlay8_32Planar(pScreen); + + infoRec->PreAllocMem = xalloc(MAX_PREALLOC_MEM); + if(infoRec->PreAllocMem) + infoRec->PreAllocSize = MAX_PREALLOC_MEM; + + if(infoRec->Flags & PIXMAP_CACHE) + xf86RegisterFreeBoxCallback(pScreen, infoRec->InitPixmapCache, + (pointer)infoRec); + + if(infoRec->Flags & MICROSOFT_ZERO_LINE_BIAS) + miSetZeroLineBias(pScreen, OCTANT1 | OCTANT2 | OCTANT3 | OCTANT4); + +#ifdef COMPOSITE + /* Initialize the composite wrapper. This needs to happen after the + * wrapping above (so it comes before us), but before all other extensions, + * so it doesn't confuse them. (particularly damage). + */ + miInitializeCompositeWrapper(pScreen); +#endif + + return TRUE; +} + + + +static Bool +XAACloseScreen (int i, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XAAScreenPtr pScreenPriv = + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); + + pScrn->EnterVT = pScreenPriv->EnterVT; + pScrn->LeaveVT = pScreenPriv->LeaveVT; + pScrn->EnableDisableFBAccess = pScreenPriv->EnableDisableFBAccess; + + pScreen->CreateGC = pScreenPriv->CreateGC; + pScreen->CloseScreen = pScreenPriv->CloseScreen; + pScreen->GetImage = pScreenPriv->GetImage; + pScreen->GetSpans = pScreenPriv->GetSpans; + pScreen->CopyWindow = pScreenPriv->CopyWindow; + pScreen->WindowExposures = pScreenPriv->WindowExposures; + pScreen->CreatePixmap = pScreenPriv->CreatePixmap; + pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap; + pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes; + + /* We leave it up to the client to free the XAAInfoRec */ + + xfree ((pointer) pScreenPriv); + + return (*pScreen->CloseScreen) (i, pScreen); +} + +static void +XAAGetImage ( + DrawablePtr pDraw, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planemask, + char *pdstLine +) +{ + ScreenPtr pScreen = pDraw->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + ScrnInfoPtr pScrn = infoRec->pScrn; + + if(pScrn->vtSema && + ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) + { + if(infoRec->ReadPixmap && (format == ZPixmap) && + ((planemask & infoRec->FullPlanemasks[pDraw->depth - 1]) == + infoRec->FullPlanemasks[pDraw->depth - 1]) && + (pDraw->bitsPerPixel == BitsPerPixel(pDraw->depth))) + { + (*infoRec->ReadPixmap)(pScrn, + sx + pDraw->x, sy + pDraw->y, w, h, + (unsigned char *)pdstLine, + PixmapBytePad(w, pDraw->depth), + pDraw->bitsPerPixel, pDraw->depth); + return; + } + SYNC_CHECK(pDraw); + } + + XAA_SCREEN_PROLOGUE (pScreen, GetImage); + (*pScreen->GetImage) (pDraw, sx, sy, w, h, format, planemask, pdstLine); + XAA_SCREEN_EPILOGUE (pScreen, GetImage, XAAGetImage); +} + +static void +XAAGetSpans ( + DrawablePtr pDraw, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pdstStart +) +{ + ScreenPtr pScreen = pDraw->pScreen; + XAA_SCREEN_PROLOGUE (pScreen, GetSpans); + if(xf86Screens[pScreen->myNum]->vtSema && + ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) { + SYNC_CHECK(pDraw); + } + (*pScreen->GetSpans) (pDraw, wMax, ppt, pwidth, nspans, pdstStart); + XAA_SCREEN_EPILOGUE (pScreen, GetSpans, XAAGetSpans); +} + + +static int +XAAPixmapBPP (ScreenPtr pScreen, int depth) +{ + PixmapPtr pPix; + int bpp; + DestroyPixmapProcPtr destroyPixmap; + + XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); + pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth, + CREATE_PIXMAP_USAGE_SCRATCH); + XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap); + if (!pPix) + return 0; + bpp = pPix->drawable.bitsPerPixel; + destroyPixmap = pScreen->DestroyPixmap; + XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap); + (*pScreen->DestroyPixmap) (pPix); + XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, destroyPixmap); + return bpp; +} + +static void +XAAInitializeOffscreenDepths (ScreenPtr pScreen) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + int d, dep; + + infoRec->offscreenDepthsInitialized = TRUE; + infoRec->offscreenDepths = 0; + if (infoRec->Flags & OFFSCREEN_PIXMAPS) { + for (d = 0; d < pScreen->numDepths; d++) { + dep = pScreen->allowedDepths[d].depth; + if (XAAPixmapBPP (pScreen, dep) == pScrn->bitsPerPixel) + infoRec->offscreenDepths |= (1 << (dep - 1)); + } + } +} + +static PixmapPtr +XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XAAPixmapPtr pPriv; + PixmapPtr pPix = NULL; + int size = w * h; + + if (w > 32767 || h > 32767) + return NullPixmap; + + if (!infoRec->offscreenDepthsInitialized) + XAAInitializeOffscreenDepths (pScreen); + + if(pScrn->vtSema && + (usage_hint != CREATE_PIXMAP_USAGE_GLYPH_PICTURE) && + (infoRec->offscreenDepths & (1 << (depth - 1))) && + (size >= MIN_OFFPIX_SIZE) && !SwitchedOut && + (!infoRec->maxOffPixWidth || (w <= infoRec->maxOffPixWidth)) && + (!infoRec->maxOffPixHeight || (h <= infoRec->maxOffPixHeight)) ) + { + PixmapLinkPtr pLink; + PixmapPtr pScreenPix; + FBAreaPtr area; + int gran = 0; + + switch(pScrn->bitsPerPixel) { + case 24: + case 8: gran = 4; break; + case 16: gran = 2; break; + case 32: gran = 1; break; + default: break; + } + + if(BITMAP_SCANLINE_PAD == 64) + gran *= 2; + + if(!(area = xf86AllocateOffscreenArea(pScreen, w, h, gran, 0, + XAARemoveAreaCallback, NULL))) { + goto BAILOUT; + } + + if(!(pLink = xalloc(sizeof(PixmapLink)))) { + xf86FreeOffscreenArea(area); + goto BAILOUT; + } + + XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); + pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, usage_hint); + XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap); + + if (!pPix) { + xfree (pLink); + xf86FreeOffscreenArea(area); + goto BAILOUT; + } + + pScreenPix = (*pScreen->GetScreenPixmap)(pScreen); + + pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + pPix->drawable.x = area->box.x1; + pPix->drawable.y = area->box.y1; + pPix->drawable.width = w; + pPix->drawable.height = h; + pPix->drawable.bitsPerPixel = pScrn->bitsPerPixel; + pPix->devKind = pScreenPix->devKind; + pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr; + area->devPrivate.ptr = pPix; + + pPriv->flags = OFFSCREEN; + pPriv->offscreenArea = area; + pPriv->freeData = FALSE; + + pLink->next = infoRec->OffscreenPixmaps; + pLink->pPix = pPix; + infoRec->OffscreenPixmaps = pLink; + return pPix; + } +BAILOUT: + XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); + pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint); + XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap); + + if(pPix) { + pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + pPriv->flags = 0; + pPriv->offscreenArea = NULL; + pPriv->freeData = FALSE; + if(!w || !h) /* either scratch or shared memory */ + pPriv->flags |= SHARED_PIXMAP; + } + + return pPix; +} + +static Bool +XAADestroyPixmap(PixmapPtr pPix) +{ + ScreenPtr pScreen = pPix->drawable.pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + Bool ret; + + if(pPix->refcnt == 1) { + if(pPriv->flags & OFFSCREEN) { + if(pPriv->flags & DGA_PIXMAP) + xfree(pPriv->offscreenArea); + else { + FBAreaPtr area = pPriv->offscreenArea; + PixmapLinkPtr pLink = infoRec->OffscreenPixmaps; + PixmapLinkPtr prev = NULL; + + while(pLink->pPix != pPix) { + prev = pLink; + pLink = pLink->next; + } + + if(prev) prev->next = pLink->next; + else infoRec->OffscreenPixmaps = pLink->next; + + if(!area) area = pLink->area; + + xf86FreeOffscreenArea(area); + pPriv->offscreenArea = NULL; + xfree(pLink); + } + } + + if(pPriv->freeData) { /* pixmaps that were once in video ram */ + xfree(pPix->devPrivate.ptr); + pPix->devPrivate.ptr = NULL; + } + } + + XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap); + ret = (*pScreen->DestroyPixmap) (pPix); + XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, XAADestroyPixmap); + + return ret; +} + +static Bool +XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + Bool ret; + + XAA_SCREEN_PROLOGUE (pScreen, ChangeWindowAttributes); + ret = (*pScreen->ChangeWindowAttributes) (pWin, mask); + XAA_SCREEN_EPILOGUE (pScreen, ChangeWindowAttributes, XAAChangeWindowAttributes); + + /* we have to assume that shared memory pixmaps are dirty + because we can't wrap operations on them */ + + if((mask & CWBackPixmap) && (pWin->backgroundState == BackgroundPixmap) && + PIXMAP_IS_SHARED(pWin->background.pixmap)) + { + XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->background.pixmap); + pPixPriv->flags |= DIRTY; + } + if((mask & CWBorderPixmap) && !(pWin->borderIsPixel) && + PIXMAP_IS_SHARED(pWin->border.pixmap)) + { + XAAPixmapPtr pPixPriv = XAA_GET_PIXMAP_PRIVATE(pWin->border.pixmap); + pPixPriv->flags |= DIRTY; + } + + return ret; +} + + + +/* These two aren't really needed for anything */ + +static Bool +XAAEnterVT(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + XAAScreenPtr pScreenPriv = + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); + + return((*pScreenPriv->EnterVT)(index, flags)); +} + +static void +XAALeaveVT(int index, int flags) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + XAAScreenPtr pScreenPriv = + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); + XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec; + + if(infoRec->NeedToSync) { + (*infoRec->Sync)(infoRec->pScrn); + infoRec->NeedToSync = FALSE; + } + + (*pScreenPriv->LeaveVT)(index, flags); +} + +typedef struct { + Bool UsingPixmapCache; + Bool CanDoColor8x8; + Bool CanDoMono8x8; +} SavedCacheState, *SavedCacheStatePtr; + +static int +XAASetDGAMode(int index, int num, DGADevicePtr devRet) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAAScreenPtr pScreenPriv = + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); + int ret; + + if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */ + SavedCacheStatePtr state = (SavedCacheStatePtr)infoRec->dgaSaves; + + infoRec->UsingPixmapCache = state->UsingPixmapCache; + infoRec->CanDoColor8x8 = state->CanDoColor8x8; + infoRec->CanDoMono8x8 = state->CanDoMono8x8; + xfree(infoRec->dgaSaves); + infoRec->dgaSaves = NULL; + } + + ret = (*pScreenPriv->SetDGAMode)(index, num, devRet); + if(ret != Success) return ret; + + if(num && devRet->pPix) { /* accelerate this pixmap */ + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(devRet->pPix); + FBAreaPtr area; + + if((area = xalloc(sizeof(FBArea)))) { + area->pScreen = pScreen; + area->box.x1 = 0; + area->box.x2 = 0; + area->box.y1 = devRet->mode->pixmapWidth; + area->box.y2 = devRet->mode->pixmapHeight; + area->granularity = 0; + area->MoveAreaCallback = 0; + area->RemoveAreaCallback = 0; + area->devPrivate.ptr = 0; + + pixPriv->flags |= OFFSCREEN | DGA_PIXMAP; + pixPriv->offscreenArea = area; + + if(!infoRec->dgaSaves) { /* save pixmap cache state */ + SavedCacheStatePtr state = xalloc(sizeof(SavedCacheState)); + + state->UsingPixmapCache = infoRec->UsingPixmapCache; + state->CanDoColor8x8 = infoRec->CanDoColor8x8; + state->CanDoMono8x8 = infoRec->CanDoMono8x8; + infoRec->dgaSaves = (char*)state; + + infoRec->UsingPixmapCache = FALSE; + if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8) + infoRec->CanDoMono8x8 = FALSE; + if(infoRec->PixmapCacheFlags & CACHE_COLOR_8x8) + infoRec->CanDoColor8x8 = FALSE; + } + } + } + + return ret; +} + + + +static void +XAAEnableDisableFBAccess (int index, Bool enable) +{ + ScreenPtr pScreen = screenInfo.screens[index]; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAAScreenPtr pScreenPriv = + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); + + if(!enable) { + if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps)) + XAAMoveOutOffscreenPixmaps(pScreen); + if(infoRec->Flags & PIXMAP_CACHE) + XAAInvalidatePixmapCache(pScreen); + SwitchedOut = TRUE; + } + + (*pScreenPriv->EnableDisableFBAccess)(index, enable); + + if(enable) { + if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps)) + XAAMoveInOffscreenPixmaps(pScreen); + SwitchedOut = FALSE; + } +} diff --git a/xorg-server/hw/xfree86/xaa/xaaInitAccel.c b/xorg-server/hw/xfree86/xaa/xaaInitAccel.c new file mode 100644 index 000000000..00483e3ed --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaInitAccel.c @@ -0,0 +1,1505 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xf86fbman.h" +#include "servermd.h" + +static const OptionInfoRec *XAAAvailableOptions(void *unused); + +/* + * XAA Config options + */ + +typedef enum { + XAAOPT_SCREEN_TO_SCREEN_COPY, + XAAOPT_SOLID_FILL_RECT, + XAAOPT_SOLID_FILL_TRAP, + XAAOPT_SOLID_TWO_POINT_LINE, + XAAOPT_SOLID_BRESENHAM_LINE, + XAAOPT_SOLID_HORVERT_LINE, + XAAOPT_DASHED_TWO_POINT_LINE, + XAAOPT_DASHED_BRESENHAM_LINE, + XAAOPT_MONO_8x8_PATTERN_FILL_RECT, + XAAOPT_MONO_8x8_PATTERN_FILL_TRAP, + XAAOPT_COL_8x8_PATTERN_FILL_RECT, + XAAOPT_COL_8x8_PATTERN_FILL_TRAP, + XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL, + XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL, + XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL, + XAAOPT_IMAGE_WRITE_RECT, + XAAOPT_SCANLINE_IMAGE_WRITE_RECT, + XAAOPT_WRITE_BITMAP, + XAAOPT_WRITE_PIXMAP, + XAAOPT_PIXMAP_CACHE, + XAAOPT_OFFSCREEN_PIXMAPS, + XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE +} XAAOpts; + +static const OptionInfoRec XAAOptions[] = { + {XAAOPT_SCREEN_TO_SCREEN_COPY, "XaaNoScreenToScreenCopy", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SOLID_FILL_RECT, "XaaNoSolidFillRect", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SOLID_FILL_TRAP, "XaaNoSolidFillTrap", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SOLID_TWO_POINT_LINE, "XaaNoSolidTwoPointLine", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SOLID_BRESENHAM_LINE, "XaaNoSolidBresenhamLine", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SOLID_HORVERT_LINE, "XaaNoSolidHorVertLine", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_DASHED_TWO_POINT_LINE, "XaaNoDashedTwoPointLine", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_DASHED_BRESENHAM_LINE, "XaaNoDashedBresenhamLine", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_MONO_8x8_PATTERN_FILL_RECT, "XaaNoMono8x8PatternFillRect", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_MONO_8x8_PATTERN_FILL_TRAP, "XaaNoMono8x8PatternFillTrap", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_COL_8x8_PATTERN_FILL_RECT, "XaaNoColor8x8PatternFillRect", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_COL_8x8_PATTERN_FILL_TRAP, "XaaNoColor8x8PatternFillTrap", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL, "XaaNoCPUToScreenColorExpandFill", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,"XaaNoScanlineCPUToScreenColorExpandFill", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL, "XaaNoScreenToScreenColorExpandFill", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_IMAGE_WRITE_RECT, "XaaNoImageWriteRect", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_SCANLINE_IMAGE_WRITE_RECT, "XaaNoScanlineImageWriteRect", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_WRITE_BITMAP, "XaaNoWriteBitmap", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_WRITE_PIXMAP, "XaaNoWritePixmap", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_PIXMAP_CACHE, "XaaNoPixmapCache", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_OFFSCREEN_PIXMAPS, "XaaNoOffscreenPixmaps", + OPTV_BOOLEAN, {0}, FALSE }, + {XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE, "XaaOffscreenPixmaps", + OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, + OPTV_NONE, {0}, FALSE } +}; + +static XF86ModuleVersionInfo xaaVersRec = +{ + "xaa", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 2, 0, + ABI_CLASS_VIDEODRV, /* requires the video driver ABI */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData xaaModuleData = { &xaaVersRec, NULL, NULL }; + +/*ARGSUSED*/ +static const OptionInfoRec * +XAAAvailableOptions(void *unused) +{ + return (XAAOptions); +} + +Bool +XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec) +{ + int index = pScreen->myNum; + ScrnInfoPtr pScrn = xf86Screens[index]; + Bool HaveScreenToScreenCopy = FALSE; + Bool HaveColorExpansion = FALSE; + Bool HaveScanlineColorExpansion = FALSE; + Bool HaveSolidFillRect = FALSE; + Bool HaveMono8x8PatternFillRect = FALSE; + Bool HaveColor8x8PatternFillRect = FALSE; + Bool HaveSolidFillTrap = FALSE; + Bool HaveMono8x8PatternFillTrap = FALSE; + Bool HaveColor8x8PatternFillTrap = FALSE; + Bool HaveSolidTwoPointLine = FALSE; + Bool HaveSolidBresenhamLine = FALSE; + Bool HaveSolidHorVertLine = FALSE; + Bool HaveDashedTwoPointLine = FALSE; + Bool HaveDashedBresenhamLine = FALSE; + Bool HaveImageWriteRect = FALSE; + Bool HaveScanlineImageWriteRect = FALSE; + Bool HaveScreenToScreenColorExpandFill = FALSE; + OptionInfoPtr options; + int is_shared = 0; + int i; + + options = xnfalloc(sizeof(XAAOptions)); + (void)memcpy(options, XAAOptions, sizeof(XAAOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + infoRec->pScrn = pScrn; + infoRec->NeedToSync = FALSE; + + /* must have a Sync function */ + if(!infoRec->Sync) return FALSE; + for(i = 0; i < pScrn->numEntities; i++) { + if(xf86IsEntityShared(pScrn->entityList[i])) is_shared = 1; + } + + /* If this PCI entity has IS_SHARED_ACCEL set in entityProp + * then a RestoreAccelState function is required + */ + if(!infoRec->RestoreAccelState && is_shared) return FALSE; + + if(infoRec->RestoreAccelState) { + if(!XAAInitStateWrap(pScreen, infoRec)) return FALSE; + } + + if (serverGeneration == 1) + xf86DrvMsg(index, X_INFO, + "Using XFree86 Acceleration Architecture (XAA)\n"); + + + /************** Low Level *************/ + + if(!infoRec->SetClippingRectangle || !infoRec->DisableClipping) { + infoRec->ClippingFlags = 0; + infoRec->SetClippingRectangle = NULL; + infoRec->DisableClipping = NULL; + } + + /**** CopyArea ****/ + + if(infoRec->SetupForScreenToScreenCopy && + infoRec->SubsequentScreenToScreenCopy && + !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COPY, FALSE)) { + HaveScreenToScreenCopy = TRUE; + } else { + infoRec->ScreenToScreenCopyFlags = 0; + infoRec->SetupForScreenToScreenCopy = NULL; + infoRec->SubsequentScreenToScreenCopy = NULL; + } + + /**** Solid Filled Rects ****/ + + if(infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect && + !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_RECT, FALSE)) { + HaveSolidFillRect = TRUE; + if(infoRec->SubsequentSolidFillTrap && + !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_TRAP, FALSE)) + HaveSolidFillTrap = TRUE; + else + infoRec->SubsequentSolidFillTrap = NULL; + } else { + infoRec->SolidFillFlags = 0; + infoRec->SetupForSolidFill = NULL; + infoRec->SubsequentSolidFillRect = NULL; + infoRec->SubsequentSolidFillTrap = NULL; + } + + /**** Solid lines ****/ + + if(infoRec->SetupForSolidLine) { + if(infoRec->SubsequentSolidTwoPointLine && + !xf86ReturnOptValBool(options, + XAAOPT_SOLID_TWO_POINT_LINE, FALSE)) + HaveSolidTwoPointLine = TRUE; + if(infoRec->SubsequentSolidBresenhamLine && + !xf86ReturnOptValBool(options, XAAOPT_SOLID_BRESENHAM_LINE, FALSE)) { + HaveSolidBresenhamLine = TRUE; + + if(infoRec->SolidBresenhamLineErrorTermBits) + infoRec->SolidBresenhamLineErrorTermBits = + ~((1 << infoRec->SolidBresenhamLineErrorTermBits) - 1); + } + + if(infoRec->SubsequentSolidHorVertLine && + !xf86ReturnOptValBool(options, + XAAOPT_SOLID_HORVERT_LINE, FALSE)) + HaveSolidHorVertLine = TRUE; + else if(HaveSolidTwoPointLine) { + infoRec->SubsequentSolidHorVertLine = + XAASolidHorVertLineAsTwoPoint; + HaveSolidHorVertLine = TRUE; + } else if(HaveSolidBresenhamLine) { + infoRec->SubsequentSolidHorVertLine = + XAASolidHorVertLineAsBresenham; + HaveSolidHorVertLine = TRUE; + } + } + + /* XXX Should this also check for XAAOPT_SOLID_HORVERT_LINE? */ + if (!HaveSolidTwoPointLine && + !HaveSolidBresenhamLine && + !HaveSolidHorVertLine && + HaveSolidFillRect) { + infoRec->SetupForSolidLine = infoRec->SetupForSolidFill; + infoRec->SubsequentSolidHorVertLine = XAASolidHorVertLineAsRects; + infoRec->SolidLineFlags = infoRec->SolidFillFlags; + HaveSolidHorVertLine = TRUE; + } + + if (!HaveSolidTwoPointLine) + infoRec->SubsequentSolidTwoPointLine = NULL; + if (!HaveSolidBresenhamLine) + infoRec->SubsequentSolidBresenhamLine = NULL; + if (!HaveSolidHorVertLine) + infoRec->SubsequentSolidHorVertLine = NULL; + + /* Disable all if nothing left over */ + if (!HaveSolidTwoPointLine && + !HaveSolidBresenhamLine && + !HaveSolidHorVertLine) { + infoRec->SolidLineFlags = 0; + infoRec->SetupForSolidLine = NULL; + } + + /**** 8x8 Mono Pattern Filled Rects ****/ + + if(infoRec->SetupForMono8x8PatternFill && + infoRec->SubsequentMono8x8PatternFillRect && + !xf86ReturnOptValBool(options, + XAAOPT_MONO_8x8_PATTERN_FILL_RECT, + FALSE)) { + HaveMono8x8PatternFillRect = TRUE; + if(infoRec->SubsequentMono8x8PatternFillTrap && + !xf86ReturnOptValBool(options, + XAAOPT_MONO_8x8_PATTERN_FILL_TRAP, + FALSE)) + HaveMono8x8PatternFillTrap = TRUE; + + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + infoRec->CanDoMono8x8 = TRUE; + } else { /* others require caching */ + int min_pitch; + infoRec->PixmapCacheFlags |= CACHE_MONO_8x8; + + switch(pScrn->bitsPerPixel) { + case 32: min_pitch = 2; break; + case 24: min_pitch = 3; break; + case 16: min_pitch = 4; break; + default: min_pitch = 8; break; + } + + if(min_pitch > infoRec->MonoPatternPitch) + infoRec->MonoPatternPitch = min_pitch; + + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN) { + if(!infoRec->CacheWidthMono8x8Pattern || + !infoRec->CacheHeightMono8x8Pattern) { + infoRec->CacheWidthMono8x8Pattern = + infoRec->MonoPatternPitch; + infoRec->CacheHeightMono8x8Pattern = 1; + } + } else { + int numPerLine = 128/infoRec->MonoPatternPitch; + + if(!infoRec->CacheWidthMono8x8Pattern || + !infoRec->CacheHeightMono8x8Pattern) { + infoRec->CacheWidthMono8x8Pattern = + numPerLine * infoRec->MonoPatternPitch; + infoRec->CacheHeightMono8x8Pattern = + (64 + numPerLine - 1)/numPerLine; + } + } + } + } else { + infoRec->Mono8x8PatternFillFlags = 0; + infoRec->SetupForMono8x8PatternFill = NULL; + infoRec->SubsequentMono8x8PatternFillRect = NULL; + } + + /**** Dashed lines ****/ + + if(infoRec->SetupForDashedLine && infoRec->DashPatternMaxLength) { + if(infoRec->SubsequentDashedTwoPointLine && + !xf86ReturnOptValBool(options, XAAOPT_DASHED_TWO_POINT_LINE, + FALSE)) + HaveDashedTwoPointLine = TRUE; + if(infoRec->SubsequentDashedBresenhamLine && + !xf86ReturnOptValBool(options, XAAOPT_DASHED_BRESENHAM_LINE, + FALSE)) { + HaveDashedBresenhamLine = TRUE; + + if(infoRec->DashedBresenhamLineErrorTermBits) + infoRec->DashedBresenhamLineErrorTermBits = + ~((1 << infoRec->DashedBresenhamLineErrorTermBits) - 1); + } + } + + if (!HaveDashedTwoPointLine) + infoRec->SubsequentDashedTwoPointLine = NULL; + if (!HaveDashedBresenhamLine) + infoRec->SubsequentDashedBresenhamLine = NULL; + + /* Disable all if nothing left over */ + if (!HaveDashedTwoPointLine && !HaveDashedBresenhamLine) { + infoRec->DashedLineFlags = 0; + infoRec->SetupForDashedLine = NULL; + } + + /**** 8x8 Color Pattern Filled Rects ****/ + + if(infoRec->SetupForColor8x8PatternFill && + infoRec->SubsequentColor8x8PatternFillRect && + !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_RECT, FALSE)) { + HaveColor8x8PatternFillRect = TRUE; + if(infoRec->SubsequentColor8x8PatternFillTrap && + !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_TRAP, + FALSE)) + HaveColor8x8PatternFillTrap = TRUE; + else + infoRec->SubsequentColor8x8PatternFillTrap = NULL; + + infoRec->PixmapCacheFlags |= CACHE_COLOR_8x8; + + if(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN) { + if(!infoRec->CacheWidthColor8x8Pattern || + !infoRec->CacheHeightColor8x8Pattern) { + infoRec->CacheWidthColor8x8Pattern = 64; + infoRec->CacheHeightColor8x8Pattern = 1; + } + } else { + if(!infoRec->CacheWidthColor8x8Pattern || + !infoRec->CacheHeightColor8x8Pattern) { + infoRec->CacheWidthColor8x8Pattern = 128; + infoRec->CacheHeightColor8x8Pattern = 8; + } + } + } else { + infoRec->Color8x8PatternFillFlags = 0; + infoRec->SetupForColor8x8PatternFill = NULL; + infoRec->SubsequentColor8x8PatternFillRect = NULL; + infoRec->SubsequentColor8x8PatternFillTrap = NULL; + } + + /**** Color Expansion ****/ + + if(infoRec->SetupForCPUToScreenColorExpandFill && + infoRec->ColorExpandBase && + infoRec->SubsequentCPUToScreenColorExpandFill && + !xf86ReturnOptValBool(options, XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL, + FALSE)) { + int dwordsNeeded = pScrn->virtualX; + + infoRec->ColorExpandRange >>= 2; /* convert to DWORDS */ + HaveColorExpansion = TRUE; + + if(infoRec->CPUToScreenColorExpandFillFlags & + LEFT_EDGE_CLIPPING_NEGATIVE_X) + dwordsNeeded += 31; + dwordsNeeded = (dwordsNeeded + 31) >> 5; + if(dwordsNeeded > infoRec->ColorExpandRange) + infoRec->CPUToScreenColorExpandFillFlags |= CPU_TRANSFER_BASE_FIXED; + } else { + infoRec->CPUToScreenColorExpandFillFlags = 0; + infoRec->SetupForCPUToScreenColorExpandFill = NULL; + infoRec->SubsequentCPUToScreenColorExpandFill = NULL; + } + + /**** Scanline Color Expansion ****/ + + if(infoRec->SetupForScanlineCPUToScreenColorExpandFill && + infoRec->SubsequentScanlineCPUToScreenColorExpandFill && + infoRec->SubsequentColorExpandScanline && + infoRec->ScanlineColorExpandBuffers && + (infoRec->NumScanlineColorExpandBuffers > 0) && + !xf86ReturnOptValBool(options, + XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL, + FALSE)) { + HaveScanlineColorExpansion = TRUE; + } else { + infoRec->ScanlineCPUToScreenColorExpandFillFlags = 0; + infoRec->SetupForScanlineCPUToScreenColorExpandFill = NULL; + infoRec->SubsequentScanlineCPUToScreenColorExpandFill = NULL; + infoRec->SubsequentColorExpandScanline = NULL; + } + + /**** Screen to Screen Color Expansion ****/ + + if(infoRec->SetupForScreenToScreenColorExpandFill && + infoRec->SubsequentScreenToScreenColorExpandFill && + !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL, + FALSE)) { + HaveScreenToScreenColorExpandFill = TRUE; + if (!infoRec->CacheColorExpandDensity) + infoRec->CacheColorExpandDensity = 1; + } else { + infoRec->ScreenToScreenColorExpandFillFlags = 0; + infoRec->SetupForScreenToScreenColorExpandFill = NULL; + infoRec->SubsequentScreenToScreenColorExpandFill = NULL; + } + + /**** Image Writes ****/ + + if(infoRec->SetupForImageWrite && infoRec->ImageWriteBase && + infoRec->SubsequentImageWriteRect && + !xf86ReturnOptValBool(options, XAAOPT_IMAGE_WRITE_RECT, FALSE)) { + + infoRec->ImageWriteRange >>= 2; /* convert to DWORDS */ + if(infoRec->ImageWriteFlags & CPU_TRANSFER_BASE_FIXED) + infoRec->ImageWriteRange = 0; + HaveImageWriteRect = TRUE; + } else { + infoRec->ImageWriteFlags = 0; + infoRec->SetupForImageWrite = NULL; + infoRec->SubsequentImageWriteRect = NULL; + } + + /**** Scanline Image Writes ****/ + + if(infoRec->SetupForScanlineImageWrite && + infoRec->SubsequentScanlineImageWriteRect && + infoRec->SubsequentImageWriteScanline && + infoRec->ScanlineImageWriteBuffers && + (infoRec->NumScanlineImageWriteBuffers > 0) && + !xf86ReturnOptValBool(options, XAAOPT_SCANLINE_IMAGE_WRITE_RECT, + FALSE)) { + HaveScanlineImageWriteRect = TRUE; + } else { + infoRec->ScanlineImageWriteFlags = 0; + infoRec->SetupForScanlineImageWrite = NULL; + infoRec->SubsequentScanlineImageWriteRect = NULL; + infoRec->SubsequentImageWriteScanline = NULL; + } + +#ifndef __i386__ + /* XAA makes some unaligned accesses when clipping is not available */ +# define CLIP_FLAGS (LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X) + if(HaveImageWriteRect && + ((infoRec->ImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS)) + { + HaveImageWriteRect = FALSE; + } + if(HaveScanlineImageWriteRect && + ((infoRec->ScanlineImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS)) + { + HaveScanlineImageWriteRect = FALSE; + } +#endif + + if (serverGeneration == 1) { + if(HaveScreenToScreenCopy) + xf86ErrorF("\tScreen to screen bit blits\n"); + if(HaveSolidFillRect) + xf86ErrorF("\tSolid filled rectangles\n"); + if(HaveSolidFillTrap) + xf86ErrorF("\tSolid filled trapezoids\n"); + if(HaveMono8x8PatternFillRect) + xf86ErrorF("\t8x8 mono pattern filled rectangles\n"); + if(HaveMono8x8PatternFillTrap) + xf86ErrorF("\t8x8 mono pattern filled trapezoids\n"); + if(HaveColor8x8PatternFillRect) + xf86ErrorF("\t8x8 color pattern filled rectangles\n"); + if(HaveColor8x8PatternFillTrap) + xf86ErrorF("\t8x8 color pattern filled trapezoids\n"); + + if(HaveColorExpansion) + xf86ErrorF("\tCPU to Screen color expansion\n"); + else if(HaveScanlineColorExpansion) + xf86ErrorF("\tIndirect CPU to Screen color expansion\n"); + + if(HaveScreenToScreenColorExpandFill) + xf86ErrorF("\tScreen to Screen color expansion\n"); + + if(HaveSolidTwoPointLine || HaveSolidBresenhamLine) + xf86ErrorF("\tSolid Lines\n"); + else if(HaveSolidHorVertLine) + xf86ErrorF("\tSolid Horizontal and Vertical Lines\n"); + + if(HaveDashedTwoPointLine || HaveDashedBresenhamLine) + xf86ErrorF("\tDashed Lines\n"); + + if(HaveImageWriteRect) + xf86ErrorF("\tImage Writes\n"); + else if(HaveScanlineImageWriteRect) + xf86ErrorF("\tScanline Image Writes\n"); + + } + +#define XAAMSG(s) do { if (serverGeneration == 1) xf86ErrorF(s); } while (0) + + if((infoRec->Flags & OFFSCREEN_PIXMAPS) && HaveScreenToScreenCopy && + xf86IsOptionSet(options, XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE)) + { + XAAMSG("\tOffscreen Pixmaps\n"); + } else { + infoRec->Flags &= ~OFFSCREEN_PIXMAPS; + } + + + /************** Mid Level *************/ + + /**** ScreenToScreenBitBlt ****/ + + if(infoRec->ScreenToScreenBitBlt) { + XAAMSG("\tDriver provided ScreenToScreenBitBlt replacement\n"); + } else if(HaveScreenToScreenCopy) { + infoRec->ScreenToScreenBitBlt = XAAScreenToScreenBitBlt; + infoRec->ScreenToScreenBitBltFlags = infoRec->ScreenToScreenCopyFlags; + } + + /**** FillSolidRects ****/ + + if(infoRec->FillSolidRects) { + XAAMSG("\tDriver provided FillSolidRects replacement\n"); + } else if(HaveSolidFillRect) { + infoRec->FillSolidRects = XAAFillSolidRects; + infoRec->FillSolidRectsFlags = infoRec->SolidFillFlags; + } + + /**** FillSolidSpans ****/ + + if(infoRec->FillSolidSpans) { + XAAMSG("\tDriver provided FillSolidSpans replacement\n"); + } else if(HaveSolidFillRect) { + infoRec->FillSolidSpans = XAAFillSolidSpans; + infoRec->FillSolidSpansFlags = infoRec->SolidFillFlags; + } + + /**** FillMono8x8PatternRects ****/ + + if(infoRec->FillMono8x8PatternRects) { + XAAMSG("\tDriver provided FillMono8x8PatternRects replacement\n"); + } else if(HaveMono8x8PatternFillRect) { + infoRec->FillMono8x8PatternRects = + (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ? + XAAFillMono8x8PatternRectsScreenOrigin : + XAAFillMono8x8PatternRects; + + infoRec->FillMono8x8PatternRectsFlags = + infoRec->Mono8x8PatternFillFlags; + } + + /**** FillMono8x8PatternSpans ****/ + + if(infoRec->FillMono8x8PatternSpans) { + XAAMSG("\tDriver provided FillMono8x8PatternSpans replacement\n"); + } else if(HaveMono8x8PatternFillRect) { + infoRec->FillMono8x8PatternSpans = + (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ? + XAAFillMono8x8PatternSpansScreenOrigin: + XAAFillMono8x8PatternSpans; + + infoRec->FillMono8x8PatternSpansFlags = + infoRec->Mono8x8PatternFillFlags; + } + + /**** FillColor8x8Rects ****/ + + if(infoRec->FillColor8x8PatternRects) { + XAAMSG("\tDriver provided FillColor8x8PatternRects replacement\n"); + } else if(HaveColor8x8PatternFillRect) { + infoRec->FillColor8x8PatternRects = + (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ? + XAAFillColor8x8PatternRectsScreenOrigin : + XAAFillColor8x8PatternRects; + + infoRec->FillColor8x8PatternRectsFlags = + infoRec->Color8x8PatternFillFlags; + } + + /**** FillColor8x8Spans ****/ + + if(infoRec->FillColor8x8PatternSpans) { + XAAMSG("\tDriver provided FillColor8x8PatternSpans replacement\n"); + } else if(HaveColor8x8PatternFillRect) { + infoRec->FillColor8x8PatternSpans = + (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ? + XAAFillColor8x8PatternSpansScreenOrigin: + XAAFillColor8x8PatternSpans; + + infoRec->FillColor8x8PatternSpansFlags = + infoRec->Color8x8PatternFillFlags; + } + + /**** FillCacheBltRects ****/ + + if(infoRec->FillCacheBltRects) { + XAAMSG("\tDriver provided FillCacheBltRects replacement\n"); + } else if(HaveScreenToScreenCopy) { + infoRec->FillCacheBltRects = XAAFillCacheBltRects; + infoRec->FillCacheBltRectsFlags = infoRec->ScreenToScreenCopyFlags; + } + + /**** FillCacheBltSpans ****/ + + if(infoRec->FillCacheBltSpans) { + XAAMSG("\tDriver provided FillCacheBltSpans replacement\n"); + } else if(HaveScreenToScreenCopy) { + infoRec->FillCacheBltSpans = XAAFillCacheBltSpans; + infoRec->FillCacheBltSpansFlags = infoRec->ScreenToScreenCopyFlags; + } + + /**** FillCacheExpandRects ****/ + + if(infoRec->FillCacheExpandRects) { + XAAMSG("\tDriver provided FillCacheExpandRects replacement\n"); + } else if(HaveScreenToScreenColorExpandFill) { + infoRec->FillCacheExpandRects = XAAFillCacheExpandRects; + infoRec->FillCacheExpandRectsFlags = + infoRec->ScreenToScreenColorExpandFillFlags; + } + + /**** FillCacheExpandSpans ****/ + + if(infoRec->FillCacheExpandSpans) { + XAAMSG("\tDriver provided FillCacheExpandSpans replacement\n"); + } else if(HaveScreenToScreenColorExpandFill) { + infoRec->FillCacheExpandSpans = XAAFillCacheExpandSpans; + infoRec->FillCacheExpandSpansFlags = + infoRec->ScreenToScreenColorExpandFillFlags; + } + + /**** FillColorExpandRects ****/ + + if(infoRec->FillColorExpandRects) { + XAAMSG("\tDriver provided FillColorExpandRects replacement\n"); + } else if(HaveColorExpansion) { + if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) { + if(infoRec->CPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandRects = + XAAFillColorExpandRects3MSBFirstFixedBase; + else + infoRec->FillColorExpandRects = + XAAFillColorExpandRects3MSBFirst; + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandRects = + XAAFillColorExpandRects3LSBFirstFixedBase; + else + infoRec->FillColorExpandRects = + XAAFillColorExpandRects3LSBFirst; + } + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandRects = + XAAFillColorExpandRectsMSBFirstFixedBase; + else + infoRec->FillColorExpandRects = + XAAFillColorExpandRectsMSBFirst; + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandRects = + XAAFillColorExpandRectsLSBFirstFixedBase; + else + infoRec->FillColorExpandRects = + XAAFillColorExpandRectsLSBFirst; + } + } + infoRec->FillColorExpandRectsFlags = + infoRec->CPUToScreenColorExpandFillFlags; + } else if(HaveScanlineColorExpansion) { + if (infoRec->ScanlineCPUToScreenColorExpandFillFlags & + TRIPLE_BITS_24BPP) { + if(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->FillColorExpandRects = + XAAFillScanlineColorExpandRects3MSBFirst; + else + infoRec->FillColorExpandRects = + XAAFillScanlineColorExpandRects3LSBFirst; + } else { + if(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->FillColorExpandRects = + XAAFillScanlineColorExpandRectsMSBFirst; + else + infoRec->FillColorExpandRects = + XAAFillScanlineColorExpandRectsLSBFirst; + } + infoRec->FillColorExpandRectsFlags = + infoRec->ScanlineCPUToScreenColorExpandFillFlags; + } + + /**** FillColorExpandSpans ****/ + + if(infoRec->FillColorExpandSpans) { + XAAMSG("\tDriver provided FillColorExpandSpans replacement\n"); + } else if(HaveColorExpansion) { + if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) { + if(infoRec->CPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpans3MSBFirstFixedBase; + else + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpans3MSBFirst; + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpans3LSBFirstFixedBase; + else + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpans3LSBFirst; + } + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpansMSBFirstFixedBase; + else + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpansMSBFirst; + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpansLSBFirstFixedBase; + else + infoRec->FillColorExpandSpans = + XAAFillColorExpandSpansLSBFirst; + } + } + infoRec->FillColorExpandSpansFlags = + infoRec->CPUToScreenColorExpandFillFlags; + } else if(HaveScanlineColorExpansion) { + if (infoRec->ScanlineCPUToScreenColorExpandFillFlags & + TRIPLE_BITS_24BPP) { + if(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->FillColorExpandSpans = + XAAFillScanlineColorExpandSpans3MSBFirst; + else + infoRec->FillColorExpandSpans = + XAAFillScanlineColorExpandSpans3LSBFirst; + } else { + if(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->FillColorExpandSpans = + XAAFillScanlineColorExpandSpansMSBFirst; + else + infoRec->FillColorExpandSpans = + XAAFillScanlineColorExpandSpansLSBFirst; + } + infoRec->FillColorExpandSpansFlags = + infoRec->ScanlineCPUToScreenColorExpandFillFlags; + } + + /**** FillImageWriteRects ****/ + + if(infoRec->FillImageWriteRects) { + XAAMSG("\tDriver provided FillImageWriteRects replacement\n"); + } else if(HaveImageWriteRect && + (infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) && + (infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) { + infoRec->FillImageWriteRects = XAAFillImageWriteRects; + infoRec->FillImageWriteRectsFlags = infoRec->ImageWriteFlags; + } + + /**** WriteBitmap ****/ + + if(infoRec->WriteBitmap && + !xf86ReturnOptValBool(options, XAAOPT_WRITE_BITMAP, FALSE)) { + XAAMSG("\tDriver provided WriteBitmap replacement\n"); + } else if(HaveColorExpansion) { + if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) { + if(infoRec->CPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->WriteBitmap = + XAAWriteBitmapColorExpand3MSBFirstFixedBase; + else + infoRec->WriteBitmap = XAAWriteBitmapColorExpand3MSBFirst; + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->WriteBitmap = + XAAWriteBitmapColorExpand3LSBFirstFixedBase; + else + infoRec->WriteBitmap = XAAWriteBitmapColorExpand3LSBFirst; + } + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->WriteBitmap = + XAAWriteBitmapColorExpandMSBFirstFixedBase; + else + infoRec->WriteBitmap = XAAWriteBitmapColorExpandMSBFirst; + } else { + if(infoRec->CPUToScreenColorExpandFillFlags & + CPU_TRANSFER_BASE_FIXED) + infoRec->WriteBitmap = + XAAWriteBitmapColorExpandLSBFirstFixedBase; + else + infoRec->WriteBitmap = XAAWriteBitmapColorExpandLSBFirst; + } + } + infoRec->WriteBitmapFlags = infoRec->CPUToScreenColorExpandFillFlags; + } else if(HaveScanlineColorExpansion) { + if (infoRec->ScanlineCPUToScreenColorExpandFillFlags & + TRIPLE_BITS_24BPP) { + if(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->WriteBitmap = + XAAWriteBitmapScanlineColorExpand3MSBFirst; + else + infoRec->WriteBitmap = + XAAWriteBitmapScanlineColorExpand3LSBFirst; + } else { + if(infoRec->ScanlineCPUToScreenColorExpandFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->WriteBitmap = + XAAWriteBitmapScanlineColorExpandMSBFirst; + else + infoRec->WriteBitmap = + XAAWriteBitmapScanlineColorExpandLSBFirst; + } + infoRec->WriteBitmapFlags = + infoRec->ScanlineCPUToScreenColorExpandFillFlags; + } else + infoRec->WriteBitmap = NULL; + + /**** TE Glyphs ****/ + + if (infoRec->TEGlyphRenderer) { + XAAMSG("\tDriver provided TEGlyphRenderer replacement\n"); + } else if (HaveColorExpansion) { + infoRec->TEGlyphRendererFlags = + infoRec->CPUToScreenColorExpandFillFlags; + + if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) { + if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) { + if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED) + infoRec->TEGlyphRenderer = + XAATEGlyphRenderer3MSBFirstFixedBase; + else + infoRec->TEGlyphRenderer = XAATEGlyphRenderer3MSBFirst; + } else { + if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED) + infoRec->TEGlyphRenderer = + XAATEGlyphRenderer3LSBFirstFixedBase; + else + infoRec->TEGlyphRenderer = XAATEGlyphRenderer3LSBFirst; + } + + if (!HaveSolidFillRect && + (infoRec->TEGlyphRendererFlags & RGB_EQUAL)) { + infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL; + XAAMSG("WARNING: TEGlyphRenderer cannot support RGB_EQUAL" + " without solid fills\n"); + } + } else { + if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) { + if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED) + infoRec->TEGlyphRenderer = + XAATEGlyphRendererMSBFirstFixedBase; + else + infoRec->TEGlyphRenderer = XAATEGlyphRendererMSBFirst; + } else { + if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED) + infoRec->TEGlyphRenderer = + XAATEGlyphRendererLSBFirstFixedBase; + else + infoRec->TEGlyphRenderer = XAATEGlyphRendererLSBFirst; + } + } + + if (!HaveSolidFillRect && + (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) { + infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY; + XAAMSG("WARNING: TEGlyphRenderer cannot support TRANPARENCY_ONLY" + " without solid fills\n"); + } + + } else if (HaveScanlineColorExpansion) { + infoRec->TEGlyphRendererFlags = + infoRec->ScanlineCPUToScreenColorExpandFillFlags; + + if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) { + if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3MSBFirst; + else + infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3LSBFirst; + + if (!HaveSolidFillRect && + (infoRec->TEGlyphRendererFlags & RGB_EQUAL)) { + infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL; + XAAMSG("WARNING: TEGlyphRenderer cannot support RGB_EQUAL" + " without solid fills\n"); + } + } else { + if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) + infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineMSBFirst; + else + infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineLSBFirst; + } + + if (!HaveSolidFillRect && + (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) { + infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY; + XAAMSG("WARNING: TEGlyphRenderer cannot support TRANPARENCY_ONLY" + " without solid fills\n"); + } + } + + /**** NonTE Glyphs ****/ + + if(infoRec->NonTEGlyphRenderer) { + XAAMSG("\tDriver provided NonTEGlyphRenderer replacement\n"); + } else if(infoRec->WriteBitmap && + !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) { + infoRec->NonTEGlyphRenderer = XAANonTEGlyphRenderer; + infoRec->NonTEGlyphRendererFlags = infoRec->WriteBitmapFlags; + } + + /**** WritePixmap ****/ + + if(infoRec->WritePixmap && + !xf86ReturnOptValBool(options, XAAOPT_WRITE_PIXMAP, FALSE)) { + XAAMSG("\tDriver provided WritePixmap replacement\n"); + } else if(HaveImageWriteRect) { + infoRec->WritePixmap = XAAWritePixmap; + infoRec->WritePixmapFlags = + infoRec->ImageWriteFlags | CONVERT_32BPP_TO_24BPP; + } else if(HaveScanlineImageWriteRect) { + infoRec->WritePixmap = XAAWritePixmapScanline; + infoRec->WritePixmapFlags = infoRec->ScanlineImageWriteFlags; + } else + infoRec->WritePixmap = NULL; + + /**** ReadPixmap ****/ + + if(infoRec->ReadPixmap) { + XAAMSG("\tDriver provided ReadPixmap replacement\n"); + } + + + /************** GC Level *************/ + + /**** CopyArea ****/ + + if(infoRec->CopyArea) { + XAAMSG("\tDriver provided GC level CopyArea replacement\n"); + } else if(infoRec->ScreenToScreenBitBlt) { + infoRec->CopyArea = XAACopyArea; + infoRec->CopyAreaFlags = infoRec->ScreenToScreenBitBltFlags; + + /* most GC level primitives use one mid-level primitive so + the GC level primitive gets the mid-level primitive flag + and we use that at GC validation time. But CopyArea uses + more than one mid-level primitive so we have to essentially + do a GC validation every time that primitive is used. + The CopyAreaFlags would only be used for filtering out the + common denominators. Here we assume that if you don't do + ScreenToScreenBitBlt you aren't going to do the others. + We also assume that ScreenToScreenBitBlt has the least + restrictions. */ + } + + if(infoRec->CopyPlane) { + XAAMSG("\tDriver provided GC level CopyPlane replacement\n"); + } else if(infoRec->WriteBitmap && + !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) { + infoRec->CopyPlane = XAACopyPlaneColorExpansion; + infoRec->CopyPlaneFlags = infoRec->WriteBitmapFlags; + } + + if(infoRec->PushPixelsSolid) { + XAAMSG("\tDriver provided GC level PushPixelsSolid replacement\n"); + } else if(infoRec->WriteBitmap && + !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) { + infoRec->PushPixelsSolid = XAAPushPixelsSolidColorExpansion; + infoRec->PushPixelsFlags = infoRec->WriteBitmapFlags; + } + + if(infoRec->FillSolidRects) { + if(!infoRec->PolyFillRectSolid) { + infoRec->PolyFillRectSolid = XAAPolyFillRect; + infoRec->PolyFillRectSolidFlags = infoRec->FillSolidRectsFlags; + } + } + if(infoRec->FillSolidSpans) { + if(!infoRec->FillSpansSolid) { + infoRec->FillSpansSolid = XAAFillSpans; + infoRec->FillSpansSolidFlags = infoRec->FillSolidSpansFlags; + } + } + + if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects || + infoRec->FillCacheBltRects || infoRec->FillColorExpandRects || + infoRec->FillCacheExpandRects) { + if(!infoRec->PolyFillRectStippled) { + + infoRec->PolyFillRectStippled = XAAPolyFillRect; + infoRec->PolyFillRectStippledFlags = 0; + } + } + + if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans || + infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans || + infoRec->FillCacheExpandSpans) { + if(!infoRec->FillSpansStippled) { + + infoRec->FillSpansStippled = XAAFillSpans; + infoRec->FillSpansStippledFlags = 0; + } + } + + if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects || + infoRec->FillCacheBltRects || infoRec->FillColorExpandRects || + infoRec->FillCacheExpandRects) { + if(!infoRec->PolyFillRectOpaqueStippled) { + + infoRec->PolyFillRectOpaqueStippled = XAAPolyFillRect; + infoRec->PolyFillRectOpaqueStippledFlags = 0; + } + } + + if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans || + infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans || + infoRec->FillCacheExpandSpans) { + if(!infoRec->FillSpansOpaqueStippled) { + + infoRec->FillSpansOpaqueStippled = XAAFillSpans; + infoRec->FillSpansOpaqueStippledFlags = 0; + } + } + + if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects || + infoRec->FillCacheBltRects || infoRec->FillImageWriteRects) { + if(!infoRec->PolyFillRectTiled) { + + infoRec->PolyFillRectTiled = XAAPolyFillRect; + infoRec->PolyFillRectTiledFlags = 0; + } + } + + if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans || + infoRec->FillCacheBltSpans) { + if(!infoRec->FillSpansTiled) { + + infoRec->FillSpansTiled = XAAFillSpans; + infoRec->FillSpansTiledFlags = 0; + } + } + + if(infoRec->TEGlyphRenderer && + !(infoRec->TEGlyphRendererFlags & NO_TRANSPARENCY)) { + + if(!infoRec->PolyText8TE) { + infoRec->PolyText8TE = XAAPolyText8TEColorExpansion; + infoRec->PolyText8TEFlags = infoRec->TEGlyphRendererFlags; + } + + if(!infoRec->PolyText16TE) { + infoRec->PolyText16TE = XAAPolyText16TEColorExpansion; + infoRec->PolyText16TEFlags = infoRec->TEGlyphRendererFlags; + } + + if(!infoRec->PolyGlyphBltTE) { + infoRec->PolyGlyphBltTE = XAAPolyGlyphBltTEColorExpansion; + infoRec->PolyGlyphBltTEFlags = infoRec->TEGlyphRendererFlags; + } + } + + if(infoRec->TEGlyphRenderer && + !(infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) { + + if(!infoRec->ImageText8TE) { + infoRec->ImageText8TE = XAAImageText8TEColorExpansion; + infoRec->ImageText8TEFlags = infoRec->TEGlyphRendererFlags; + } + + if(!infoRec->ImageText16TE) { + infoRec->ImageText16TE = XAAImageText16TEColorExpansion; + infoRec->ImageText16TEFlags = infoRec->TEGlyphRendererFlags; + } + + if(!infoRec->ImageGlyphBltTE) { + infoRec->ImageGlyphBltTE = XAAImageGlyphBltTEColorExpansion; + infoRec->ImageGlyphBltTEFlags = infoRec->TEGlyphRendererFlags; + } + } + + if(infoRec->NonTEGlyphRenderer) { + if(!infoRec->PolyText8NonTE) { + infoRec->PolyText8NonTE = XAAPolyText8NonTEColorExpansion; + infoRec->PolyText8NonTEFlags = infoRec->NonTEGlyphRendererFlags; + } + + if(!infoRec->PolyText16NonTE) { + infoRec->PolyText16NonTE = XAAPolyText16NonTEColorExpansion; + infoRec->PolyText16NonTEFlags = infoRec->NonTEGlyphRendererFlags; + } + if(!infoRec->PolyGlyphBltNonTE) { + infoRec->PolyGlyphBltNonTE = XAAPolyGlyphBltNonTEColorExpansion; + infoRec->PolyGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags; + } + } + + if(infoRec->NonTEGlyphRenderer && HaveSolidFillRect) { + if(!infoRec->ImageText8NonTE) { + infoRec->ImageText8NonTE = XAAImageText8NonTEColorExpansion; + infoRec->ImageText8NonTEFlags = infoRec->NonTEGlyphRendererFlags; + } + + if(!infoRec->ImageText16NonTE) { + infoRec->ImageText16NonTE = XAAImageText16NonTEColorExpansion; + infoRec->ImageText16NonTEFlags = infoRec->NonTEGlyphRendererFlags; + } + + if(!infoRec->ImageGlyphBltNonTE) { + infoRec->ImageGlyphBltNonTE = XAAImageGlyphBltNonTEColorExpansion; + infoRec->ImageGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags; + } + } + + if(!infoRec->PolyRectangleThinSolid && HaveSolidHorVertLine) { + infoRec->PolyRectangleThinSolid = XAAPolyRectangleThinSolid; + infoRec->PolyRectangleThinSolidFlags = infoRec->SolidLineFlags; + } + + if(!infoRec->FillPolygonSolid && HaveSolidFillRect) { + infoRec->FillPolygonSolid = XAAFillPolygonSolid; + infoRec->FillPolygonSolidFlags = infoRec->SolidFillFlags; + } + + if(!infoRec->FillPolygonStippled && (HaveMono8x8PatternFillRect || + HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) { + infoRec->FillPolygonStippled = XAAFillPolygonStippled; + infoRec->FillPolygonStippledFlags = infoRec->SolidFillFlags; + } + + if(!infoRec->FillPolygonOpaqueStippled && (HaveMono8x8PatternFillRect || + HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) { + infoRec->FillPolygonOpaqueStippled = XAAFillPolygonStippled; + infoRec->FillPolygonOpaqueStippledFlags = infoRec->SolidFillFlags; + } + + if(!infoRec->FillPolygonTiled && (HaveMono8x8PatternFillRect || + HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) { + infoRec->FillPolygonTiled = XAAFillPolygonTiled; + infoRec->FillPolygonTiledFlags = infoRec->SolidFillFlags; + } + + + if(!infoRec->PolyFillArcSolid && HaveSolidFillRect) { + infoRec->PolyFillArcSolid = XAAPolyFillArcSolid; + infoRec->PolyFillArcSolidFlags = infoRec->SolidFillFlags; + } + + if(!infoRec->PolylinesWideSolid && HaveSolidFillRect) { + infoRec->PolylinesWideSolid = XAAPolylinesWideSolid; + infoRec->PolylinesWideSolidFlags = + infoRec->SolidFillFlags | GXCOPY_ONLY; + } + + if(!infoRec->PutImage && (infoRec->WritePixmap || + (infoRec->WriteBitmap && + !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)))) { + infoRec->PutImage = XAAPutImage; + + /* See comment for CopyArea above. But here we make fewer + assumptions. The driver can provide the PutImageFlags if + it wants too */ + } + + if(HaveSolidHorVertLine && + (HaveSolidBresenhamLine || (HaveSolidTwoPointLine && + (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE)))){ + if(!infoRec->PolylinesThinSolid) { + infoRec->PolylinesThinSolid = XAAPolyLines; + infoRec->PolylinesThinSolidFlags = infoRec->SolidLineFlags; + } + if(!infoRec->PolySegmentThinSolid) { + infoRec->PolySegmentThinSolid = XAAPolySegment; + infoRec->PolySegmentThinSolidFlags = infoRec->SolidLineFlags; + } + } + + if(HaveDashedBresenhamLine || (HaveDashedTwoPointLine && + (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE))){ + if(!infoRec->PolylinesThinDashed) { + infoRec->PolylinesThinDashed = XAAPolyLinesDashed; + infoRec->PolylinesThinDashedFlags = infoRec->DashedLineFlags; + } + if(!infoRec->PolySegmentThinDashed) { + infoRec->PolySegmentThinDashed = XAAPolySegmentDashed; + infoRec->PolySegmentThinDashedFlags = infoRec->DashedLineFlags; + } + } + + if(infoRec->PolylinesThinDashed || infoRec->PolySegmentThinDashed) { + if(!infoRec->ComputeDash) + infoRec->ComputeDash = XAAComputeDash; + } + +#ifdef RENDER + { + Bool haveTexture = infoRec->CPUToScreenTextureFormats && + infoRec->CPUToScreenTextureDstFormats && + infoRec->SetupForCPUToScreenTexture2 && + infoRec->SubsequentCPUToScreenTexture; + Bool haveAlphaTexture = infoRec->CPUToScreenAlphaTextureFormats && + infoRec->CPUToScreenAlphaTextureDstFormats && + infoRec->SetupForCPUToScreenAlphaTexture2 && + infoRec->SubsequentCPUToScreenAlphaTexture; + + if(!infoRec->Composite && (haveTexture || haveAlphaTexture)) + infoRec->Composite = XAADoComposite; + + if(!infoRec->Glyphs && infoRec->WriteBitmap && + !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) + { + infoRec->Glyphs = XAADoGlyphs; + } + } +#endif + + /************ Validation Functions **************/ + + if(!infoRec->ValidateCopyArea && infoRec->CopyArea) { + infoRec->CopyAreaMask = GCWhenForced; + if((infoRec->CopyAreaFlags & GXCOPY_ONLY) || + (infoRec->CopyAreaFlags & ROP_NEEDS_SOURCE)) + infoRec->CopyAreaMask |= GCFunction; + if(infoRec->CopyAreaFlags & NO_PLANEMASK) + infoRec->CopyAreaMask |= GCPlaneMask; + infoRec->ValidateCopyArea = XAAValidateCopyArea; + } + + if(!infoRec->ValidateCopyPlane && infoRec->CopyPlane) { + infoRec->CopyPlaneMask = GCWhenForced; + if((infoRec->CopyPlaneFlags & GXCOPY_ONLY) || + (infoRec->CopyPlaneFlags & ROP_NEEDS_SOURCE)) + infoRec->CopyPlaneMask |= GCFunction; + if(infoRec->CopyPlaneFlags & NO_PLANEMASK) + infoRec->CopyPlaneMask |= GCPlaneMask; + if(infoRec->CopyPlaneFlags & RGB_EQUAL) + infoRec->CopyPlaneMask |= GCForeground | GCBackground; + infoRec->ValidateCopyPlane = XAAValidateCopyPlane; + } + + if(!infoRec->ValidatePutImage && infoRec->PutImage) { + infoRec->PutImageMask = GCWhenForced; + if((infoRec->PutImageFlags & GXCOPY_ONLY) || + (infoRec->PutImageFlags & ROP_NEEDS_SOURCE)) + infoRec->PutImageMask |= GCFunction; + if(infoRec->PutImageFlags & NO_PLANEMASK) + infoRec->PutImageMask |= GCPlaneMask; + if(infoRec->PutImageFlags & RGB_EQUAL) + infoRec->PutImageMask |= GCForeground | GCBackground; + infoRec->ValidatePutImage = XAAValidatePutImage; + } + + + if(!infoRec->ValidatePushPixels && infoRec->PushPixelsSolid) { + infoRec->PushPixelsMask = GCFillStyle; + if((infoRec->PushPixelsFlags & GXCOPY_ONLY) || + (infoRec->PushPixelsFlags & ROP_NEEDS_SOURCE) || + (infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY)) + infoRec->PushPixelsMask |= GCFunction; + if(infoRec->PushPixelsFlags & NO_PLANEMASK) + infoRec->PushPixelsMask |= GCPlaneMask; + if(infoRec->PushPixelsFlags & RGB_EQUAL) + infoRec->PushPixelsMask |= GCForeground; + infoRec->ValidatePushPixels = XAAValidatePushPixels; + } + + /* By default XAA assumes the FillSpans, PolyFillRects, FillPolygon + and PolyFillArcs have the same restrictions. If you supply GC + level replacements for any of these and alter this relationship + you may need to supply replacement validation routines */ + + if(!infoRec->ValidateFillSpans && + (infoRec->FillSpansSolid || infoRec->FillSpansStippled || + infoRec->FillSpansOpaqueStippled || infoRec->FillSpansTiled)) { + + int compositeFlags = infoRec->FillSpansSolidFlags | + infoRec->FillSpansStippledFlags | + infoRec->FillSpansOpaqueStippledFlags | + infoRec->FillSpansTiledFlags; + + infoRec->FillSpansMask = GCFillStyle | GCTile | GCStipple; + + if((compositeFlags & GXCOPY_ONLY) || + (compositeFlags & ROP_NEEDS_SOURCE)) + infoRec->FillSpansMask |= GCFunction; + if(compositeFlags & NO_PLANEMASK) + infoRec->FillSpansMask |= GCPlaneMask; + if(compositeFlags & RGB_EQUAL) + infoRec->FillSpansMask |= GCForeground; + infoRec->ValidateFillSpans = XAAValidateFillSpans; + } + + /* By default XAA only provides Validations for the GlyphBlt + functions and not the text higher up. This is because the + Text8/16 and GlyphBlt are linked. If you break this linkage, + you may need to have the driver supply its own Validation + routines */ + + if(!infoRec->ValidatePolyGlyphBlt && + (infoRec->PolyGlyphBltTE || infoRec->PolyGlyphBltNonTE)) { + int compositeFlags = infoRec->PolyGlyphBltTEFlags | + infoRec->PolyGlyphBltNonTEFlags; + + infoRec->PolyGlyphBltMask = GCFillStyle | GCFont; + if((compositeFlags & GXCOPY_ONLY) || + (compositeFlags & ROP_NEEDS_SOURCE) || + (infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY)) + infoRec->PolyGlyphBltMask |= GCFunction; + if(compositeFlags & NO_PLANEMASK) + infoRec->PolyGlyphBltMask |= GCPlaneMask; + if(compositeFlags & RGB_EQUAL) + infoRec->PolyGlyphBltMask |= GCForeground; + infoRec->ValidatePolyGlyphBlt = XAAValidatePolyGlyphBlt; + } + + if(!infoRec->ValidateImageGlyphBlt && + (infoRec->ImageGlyphBltTE || infoRec->ImageGlyphBltNonTE)) { + int compositeFlags = infoRec->ImageGlyphBltTEFlags | + infoRec->ImageGlyphBltNonTEFlags; + + if(infoRec->ImageGlyphBltNonTE) + compositeFlags |= infoRec->SolidFillFlags; + + infoRec->ImageGlyphBltMask = GCFont; + if(compositeFlags & NO_PLANEMASK) + infoRec->ImageGlyphBltMask |= GCPlaneMask; + if(compositeFlags & RGB_EQUAL) + infoRec->ImageGlyphBltMask |= GCForeground | GCBackground; + infoRec->ValidateImageGlyphBlt = XAAValidateImageGlyphBlt; + } + + /* By default XAA only provides a Validation function for the + Polylines and does segments and polylines at the same time */ + + if(!infoRec->ValidatePolylines && infoRec->ValidateFillSpans) { + int compositeFlags = infoRec->PolyRectangleThinSolidFlags | + infoRec->PolylinesWideSolidFlags | + infoRec->PolylinesThinSolidFlags | + infoRec->PolySegmentThinSolidFlags | + infoRec->PolySegmentThinDashedFlags | + infoRec->PolylinesThinDashedFlags; + + infoRec->ValidatePolylines = XAAValidatePolylines; + infoRec->PolylinesMask = + infoRec->FillSpansMask | GCLineStyle | GCLineWidth; + + if(infoRec->PolySegmentThinDashed || infoRec->PolylinesThinDashed) + infoRec->PolylinesMask |= GCDashList; + if(compositeFlags & NO_PLANEMASK) + infoRec->PolylinesMask |= GCPlaneMask; + if((compositeFlags & GXCOPY_ONLY) || + (compositeFlags & ROP_NEEDS_SOURCE)) + infoRec->PolylinesMask |= GCFunction; + if(compositeFlags & RGB_EQUAL) + infoRec->PolylinesMask |= GCForeground; + } + + + /**** Fill choosers ****/ + + if(!infoRec->StippledFillChooser) + infoRec->StippledFillChooser = XAAStippledFillChooser; + + if(!infoRec->OpaqueStippledFillChooser) + infoRec->OpaqueStippledFillChooser = XAAOpaqueStippledFillChooser; + + if(!infoRec->TiledFillChooser) + infoRec->TiledFillChooser = XAATiledFillChooser; + + + /**** Setup the pixmap cache ****/ + + if(infoRec->WriteBitmapToCache) {} + else if(infoRec->WriteBitmap && + !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) + infoRec->WriteBitmapToCache = XAAWriteBitmapToCache; + else if(infoRec->Flags & LINEAR_FRAMEBUFFER) + infoRec->WriteBitmapToCache = XAAWriteBitmapToCacheLinear; + else + infoRec->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES; + + if(infoRec->WritePixmapToCache) {} + else if(infoRec->WritePixmap && !(infoRec->WritePixmapFlags & NO_GXCOPY)) + infoRec->WritePixmapToCache = XAAWritePixmapToCache; + else if(infoRec->Flags & LINEAR_FRAMEBUFFER) + infoRec->WritePixmapToCache = XAAWritePixmapToCacheLinear; + else + infoRec->Flags &= ~PIXMAP_CACHE; + + if (xf86ReturnOptValBool(options, XAAOPT_PIXMAP_CACHE, FALSE)) + infoRec->Flags &= ~PIXMAP_CACHE; + + if(infoRec->WriteMono8x8PatternToCache) {} + else if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8) { + if(infoRec->WritePixmapToCache) + infoRec->WriteMono8x8PatternToCache = XAAWriteMono8x8PatternToCache; + else + infoRec->PixmapCacheFlags &= ~CACHE_MONO_8x8; + } + + if(infoRec->WriteColor8x8PatternToCache) {} + else if(infoRec->PixmapCacheFlags & CACHE_COLOR_8x8) { + if(infoRec->WritePixmapToCache && infoRec->WriteBitmapToCache) + infoRec->WriteColor8x8PatternToCache = XAAWriteColor8x8PatternToCache; + else + infoRec->PixmapCacheFlags &= ~CACHE_COLOR_8x8; + } + + if(infoRec->CachePixelGranularity < 0) { + switch(pScrn->bitsPerPixel) { + case 24: + case 8: infoRec->CachePixelGranularity = 4; break; + case 16: infoRec->CachePixelGranularity = 2; break; + case 32: infoRec->CachePixelGranularity = 1; break; + default: break; + } + + if(BITMAP_SCANLINE_PAD == 64) + infoRec->CachePixelGranularity *= 2; + } + + xfree(options); + + if(!infoRec->CacheTile && infoRec->WritePixmapToCache) + infoRec->CacheTile = XAACacheTile; + if(!infoRec->CacheMonoStipple && infoRec->WritePixmapToCache) + infoRec->CacheMonoStipple = XAACacheMonoStipple; + if(!infoRec->CacheStipple && infoRec->WriteBitmapToCache) + infoRec->CacheStipple = XAACacheStipple; + if(!infoRec->CacheMono8x8Pattern && infoRec->WriteMono8x8PatternToCache) + infoRec->CacheMono8x8Pattern = XAACacheMono8x8Pattern; + if(!infoRec->CacheColor8x8Pattern && infoRec->WriteColor8x8PatternToCache) + infoRec->CacheColor8x8Pattern = XAACacheColor8x8Pattern; + + if((infoRec->Flags & PIXMAP_CACHE) && !infoRec->InitPixmapCache) { + infoRec->InitPixmapCache = XAAInitPixmapCache; + infoRec->ClosePixmapCache = XAAClosePixmapCache; + } + + return TRUE; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaLine.c b/xorg-server/hw/xfree86/xaa/xaaLine.c new file mode 100644 index 000000000..7469de179 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaLine.c @@ -0,0 +1,394 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include <X11/X.h> +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "miline.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + + +void +#ifdef POLYSEGMENT +XAAPolySegment( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg +#else +XAAPolyLines( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, /* Origin or Previous */ + int npt, /* number of points */ + DDXPointPtr pptInit +#endif +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); + int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + int xorg = pDrawable->x; + int yorg = pDrawable->y; + int nbox; + BoxPtr pbox; +#ifndef POLYSEGMENT + DDXPointPtr ppt; +#endif + int x1, x2, y1, y2, tmp, len; + + if(!nboxInit) + return; + + if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) { + int minValX = infoRec->SolidLineLimits.x1; + int maxValX = infoRec->SolidLineLimits.x2; + int minValY = infoRec->SolidLineLimits.y1; + int maxValY = infoRec->SolidLineLimits.y2; +#ifdef POLYSEGMENT + int n = nseg; + xSegment *s = pSeg; + + while (n--) +#else + int n = npt; + int xorgtmp = xorg; + int yorgtmp = yorg; + + ppt = pptInit; + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; + while (--n) +#endif + { +#ifdef POLYSEGMENT + x1 = s->x1 + xorg; + y1 = s->y1 + yorg; + x2 = s->x2 + xorg; + y2 = s->y2 + yorg; + s++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) { + xorgtmp = x1; + yorgtmp = y1; + } + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; +#endif + if (x1 > maxValX || x1 < minValX || + x2 > maxValX || x2 < minValX || + y1 > maxValY || y1 < minValY || + y2 > maxValY || y2 < minValY) { +#ifdef POLYSEGMENT + XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); +#else + XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); +#endif + return; + } + } + } + + (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel, + pGC->alu, pGC->planemask); + +#ifdef POLYSEGMENT + while (nseg--) +#else + ppt = pptInit; + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; + while(--npt) +#endif + { + nbox = nboxInit; + pbox = pboxInit; + +#ifdef POLYSEGMENT + x1 = pSeg->x1 + xorg; + y1 = pSeg->y1 + yorg; + x2 = pSeg->x2 + xorg; + y2 = pSeg->y2 + yorg; + pSeg++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) { + xorg = x1; + yorg = y1; + } + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; +#endif + + if (x1 == x2) { /* vertical line */ + /* make the line go top to bottom of screen, keeping + endpoint semantics + */ + if (y1 > y2) { + tmp = y2; + y2 = y1 + 1; + y1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) y1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) y2++; +#endif + /* get to first band that might contain part of line */ + while(nbox && (pbox->y2 <= y1)) { + pbox++; + nbox--; + } + + /* stop when lower edge of box is beyond end of line */ + while(nbox && (y2 >= pbox->y1)) { + if ((x1 >= pbox->x1) && (x1 < pbox->x2)) { + tmp = max(y1, pbox->y1); + len = min(y2, pbox->y2) - tmp; + if (len) (*infoRec->SubsequentSolidHorVertLine)( + infoRec->pScrn, x1, tmp, len, DEGREES_270); + } + nbox--; + pbox++; + } +#ifndef POLYSEGMENT + y2 = ppt->y + yorg; +#endif + } else if (y1 == y2) { /* horizontal line */ + /* force line from left to right, keeping endpoint semantics */ + if (x1 > x2) { + tmp = x2; + x2 = x1 + 1; + x1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) x1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) x2++; +#endif + + /* find the correct band */ + while(nbox && (pbox->y2 <= y1)) { + pbox++; + nbox--; + } + + /* try to draw the line, if we haven't gone beyond it */ + if (nbox && (pbox->y1 <= y1)) { + int orig_y = pbox->y1; + /* when we leave this band, we're done */ + while(nbox && (orig_y == pbox->y1)) { + if (pbox->x2 <= x1) { + /* skip boxes until one might contain start point */ + nbox--; + pbox++; + continue; + } + + /* stop if left of box is beyond right of line */ + if (pbox->x1 >= x2) { + nbox = 0; + break; + } + + tmp = max(x1, pbox->x1); + len = min(x2, pbox->x2) - tmp; + if (len) (*infoRec->SubsequentSolidHorVertLine)( + infoRec->pScrn, tmp, y1, len, DEGREES_0); + nbox--; + pbox++; + } + } +#ifndef POLYSEGMENT + x2 = ppt->x + xorg; +#endif + } else{ /* sloped line */ + unsigned int oc1, oc2; + int dmin, dmaj, e, octant; + + if (infoRec->SubsequentSolidBresenhamLine) { + if((dmaj = x2 - x1) < 0) { + dmaj = -dmaj; + octant = XDECREASING; + } else octant = 0; + + if((dmin = y2 - y1) < 0) { + dmin = -dmin; + octant |= YDECREASING; + } + + if(dmin >= dmaj){ + tmp = dmin; dmin = dmaj; dmaj = tmp; + octant |= YMAJOR; + } + + e = -dmaj - ((bias >> octant) & 1); + len = dmaj; + dmin <<= 1; + dmaj <<= 1; + } else { /* Muffle compiler */ + dmin = dmaj = e = octant = len = 0; + } + + while(nbox--) { + oc1 = oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if (!(oc1 | oc2)) { /* unclipped */ + if(infoRec->SubsequentSolidTwoPointLine) { + (*infoRec->SubsequentSolidTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST + ); + } else { + (*infoRec->SubsequentSolidBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant); + } + break; + } else if (oc1 & oc2) { /* completely clipped */ + pbox++; + } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) { + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); + + if(infoRec->SubsequentSolidBresenhamLine) { + (*infoRec->SubsequentSolidBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant); + } else { + (*infoRec->SubsequentSolidTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST + ); + } + (*infoRec->DisableClipping)(infoRec->pScrn); + pbox++; + } else { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int err, adx, ady; + + if(octant & YMAJOR) { + ady = dmaj >> 1; + adx = dmin >> 1; + } else { + ady = dmin >> 1; + adx = dmaj >> 1; + } + + if (miZeroClipLine(pbox->x1, pbox->y1, + pbox->x2 - 1, pbox->y2 - 1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + + if (octant & YMAJOR) + len = abs(new_y2 - new_y1); + else + len = abs(new_x2 - new_x1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) { + int abserr, clipdx, clipdy; + /* unwind bresenham error term to first point */ + if (clip1) { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + + if (octant & YMAJOR) + err = e + clipdy*dmin - clipdx*dmaj; + else + err = e + clipdx*dmin - clipdy*dmaj; + } else + err = e; + +#define range infoRec->SolidBresenhamLineErrorTermBits + abserr = abs(err); + while((abserr & range) || + (dmaj & range) || + (dmin & range)) { + dmin >>= 1; + dmaj >>= 1; + abserr >>= 1; + err /= 2; + } + + (*infoRec->SubsequentSolidBresenhamLine)( + infoRec->pScrn, new_x1, new_y1, + dmaj, dmin, err, len, octant); + } + pbox++; + } + } /* while (nbox--) */ + } /* sloped line */ + } /* while (nline--) */ + +#ifndef POLYSEGMENT + /* paint the last point if the end style isn't CapNotLast. + (Assume that a projecting, butt, or round cap that is one + pixel wide is the same as the single pixel of the endpoint.) + */ + + if ((pGC->capStyle != CapNotLast) && + ((ppt->x + xorg != pptInit->x + pDrawable->x) || + (ppt->y + yorg != pptInit->y + pDrawable->y) || + (ppt == pptInit + 1))) + { + nbox = nboxInit; + pbox = pboxInit; + while (nbox--) + { + if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && + (x2 < pbox->x2) && (y2 < pbox->y2)) + { + (*infoRec->SubsequentSolidHorVertLine)( + infoRec->pScrn, x2, y2, 1, DEGREES_0); + break; + } + else + pbox++; + } + } +#endif + + SET_SYNC_FLAG(infoRec); +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c new file mode 100644 index 000000000..cefb59a8e --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c @@ -0,0 +1,151 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "miline.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + + +void +XAASolidHorVertLineAsRects( + ScrnInfoPtr pScrn, + int x, int y, int len, int dir +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + if(dir == DEGREES_0) + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, len, 1); + else + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, len); +} + + +void +XAASolidHorVertLineAsTwoPoint( + ScrnInfoPtr pScrn, + int x, int y, int len, int dir +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + len--; + + if(dir == DEGREES_0) + (*infoRec->SubsequentSolidTwoPointLine)(pScrn, x, y, x + len, y, 0); + else + (*infoRec->SubsequentSolidTwoPointLine)(pScrn, x, y, x, y + len, 0); +} + +void +XAASolidHorVertLineAsBresenham( + ScrnInfoPtr pScrn, + int x, int y, int len, int dir +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + if(dir == DEGREES_0) + (*infoRec->SubsequentSolidBresenhamLine)( + pScrn, x, y, len << 1, 0, -len, len, 0); + else + (*infoRec->SubsequentSolidBresenhamLine)( + pScrn, x, y, len << 1, 0, -len, len, YMAJOR); +} + + +void +XAAComputeDash(GCPtr pGC) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); + Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE; + int PatternLength = 0; + unsigned char* DashPtr = (unsigned char*)pGC->dash; + CARD32 *ptr; + int count = pGC->numInDashList; + int shift, value, direction; + Bool set; + + if(pGCPriv->DashPattern) + xfree(pGCPriv->DashPattern); + + pGCPriv->DashPattern = NULL; + pGCPriv->DashLength = 0; + + while(count--) + PatternLength += *(DashPtr++); + + if(!EvenDash) + PatternLength <<= 1; + + if(PatternLength > infoRec->DashPatternMaxLength) + return; + + if((infoRec->DashedLineFlags & LINE_PATTERN_POWER_OF_2_ONLY) && + (PatternLength & (PatternLength - 1))) + return; + + pGCPriv->DashPattern = xcalloc((PatternLength + 31) >> 5, 4); + if(!pGCPriv->DashPattern) return; + pGCPriv->DashLength = PatternLength; + + if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED | + LINE_PATTERN_LSBFIRST_LSBJUSTIFIED)) { + direction = 1; + set = TRUE; + DashPtr = (unsigned char*)pGC->dash; + } else { + direction = -1; + set = FALSE; + DashPtr = (unsigned char*)pGC->dash + pGC->numInDashList - 1; + } + + if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED | + LINE_PATTERN_MSBFIRST_MSBJUSTIFIED)) + shift = 32 - (PatternLength & 31); + else + shift = 0; + + ptr = (CARD32*)(pGCPriv->DashPattern); + +CONCATENATE: + + count = pGC->numInDashList; + + while(count--) { + value = *DashPtr; + DashPtr += direction; + while(value) { + if(value < (32 - shift)) { + if(set) *ptr |= XAAShiftMasks[value] << shift; + shift += value; + break; + } else { + if(set) *ptr |= ~0L << shift; + value -= (32 - shift); + shift = 0; + ptr++; + } + } + if(set) set = FALSE; + else set = TRUE; + } + + if(!EvenDash) { + EvenDash = TRUE; + if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED | + LINE_PATTERN_LSBFIRST_LSBJUSTIFIED)) + DashPtr = (unsigned char*)pGC->dash; + else + DashPtr = (unsigned char*)pGC->dash + pGC->numInDashList; + goto CONCATENATE; + } +} diff --git a/xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c b/xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c new file mode 100644 index 000000000..556650fb0 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaNonTEGlyph.c @@ -0,0 +1,200 @@ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xaa.h" +#include "xaalocal.h" +#include "xaacexp.h" +#include "xf86.h" + +/* Not used anymore because the algorithm isn't correct. It doesn't + handle overlapping characters properly */ + +#ifdef TRIPLE_BITS +#define NonTEGlyphFunc EXPNAME(XAANonTEGlyphScanlineFunc3) +#else +#define NonTEGlyphFunc EXPNAME(XAANonTEGlyphScanlineFunc) +#endif + +/******************************************************************** + + Here we have NonTEGlyphRenders for a bunch of different color + expansion types. The driver may provide its own renderer, but + this is the default one which renders using lower-level primitives + exported by the chipset driver. + +********************************************************************/ + +/* Since the dimensions of the text string and the backing rectangle + do not always coincide, it is possible that wBack or wText + may be 0! The NonTEGlyphRender must always check for this. */ + +/* This gets built for MSBFIRST or LSBFIRST with FIXEDBASE or not, + with TRIPLE_BITS or not. A total of 8 versions */ + +/* if the backing rectangle and text are of the same dimensions + then we can draw in one pass */ + +void +#ifdef TRIPLE_BITS +EXPNAME(XAANonTEGlyphRenderer3)( +#else +EXPNAME(XAANonTEGlyphRenderer)( +#endif + ScrnInfoPtr pScrn, + int xText, int wText, + int y, int h, int skipleft, int startline, + NonTEGlyphInfo *glyphp, + int fg, int rop, + unsigned int planemask ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32* base = (CARD32*)infoRec->ColorExpandBase; +#ifdef TRIPLE_BITS + int dwords = ((3 * wText + 31) >> 5) * h; +#else + int dwords = ((wText + 31) >> 5) * h; +#endif + + (*infoRec->SetupForCPUToScreenColorExpandFill)( + pScrn, fg, -1, rop, planemask); + (*infoRec->SubsequentCPUToScreenColorExpandFill)( + pScrn, xText, y, wText, h, 0); + +#ifndef FIXEDBASE +#ifdef TRIPLE_BITS + if((((3 * wText + 31) >> 5) * h) <= infoRec->ColorExpandRange) +#else + if((((wText + 31) >> 5) * h) <= infoRec->ColorExpandRange) +#endif + while(h--) + base = NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft); + else +#endif + while(h--) + NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft); + + if((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD) && + (dwords & 1)) { + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + + if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + +#ifndef FIXEDBASE +/* Scanline version of above gets built for LSBFIRST and MSBFIRST */ + +void +#ifdef TRIPLE_BITS +EXPNAME(XAANonTEGlyphRendererScanline3)( +#else +EXPNAME(XAANonTEGlyphRendererScanline)( +#endif + ScrnInfoPtr pScrn, + int xText, int wText, + int y, int h, int skipleft, int startline, + NonTEGlyphInfo *glyphp, + int fg, int rop, + unsigned int planemask ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int bufferNo = 0; + CARD32* base; + + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)( + pScrn, fg, -1, rop, planemask); + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, xText, y, wText, h, 0); + + while(h--) { + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft); + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + } + + SET_SYNC_FLAG(infoRec); +} + +#endif + +/******************************************************************** + + Generic NonTE scanline rendering code. + +********************************************************************/ + + +CARD32* +NonTEGlyphFunc( + CARD32 *base, + NonTEGlyphInfo *glyphp, + int line, int TotalWidth, int skipleft ) +{ + CARD32 bits = 0; + int shift = glyphp->width; + + if(skipleft) { + if((line >= glyphp->firstline) && (line <= glyphp->lastline)) + bits = SHIFT_R(glyphp->bitsp[line], skipleft); + shift -= skipleft; + } else if((line >= glyphp->firstline) && (line <= glyphp->lastline)) + bits = glyphp->bitsp[line]; + + + while(TotalWidth > 32) { + while(shift < 32) { + glyphp++; + if((line >= glyphp->firstline) && (line <= glyphp->lastline)) + bits |= SHIFT_L(glyphp->bitsp[line],shift); + shift += glyphp->width; + } +#ifdef TRIPLE_BITS + WRITE_BITS3(bits); +#else + WRITE_BITS(bits); +#endif + shift &= 31; + if(shift && + (line >= glyphp->firstline) && (line <= glyphp->lastline)) + bits = SHIFT_R(glyphp->bitsp[line], glyphp->width - shift); + else bits = 0; + TotalWidth -= 32; + } + + if(TotalWidth) { + TotalWidth -= shift; + while(TotalWidth > 0) { + glyphp++; + if((line >= glyphp->firstline) && (line <= glyphp->lastline)) + bits |= SHIFT_L(glyphp->bitsp[line], shift); + shift += glyphp->width; + TotalWidth -= glyphp->width; + } +#ifdef TRIPLE_BITS + if (shift >= 22) { + WRITE_BITS3(bits); + } else if (shift >= 11) { + WRITE_BITS2(bits); + } else { + WRITE_BITS1(bits); + } +#else + WRITE_BITS(bits); +#endif + } + + + return base; +} + + + + diff --git a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c new file mode 100644 index 000000000..d4661e879 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c @@ -0,0 +1,592 @@ + +/******************************************************************** + + In this file we have GC level replacements for PolyText8/16, + ImageText8/16, ImageGlyphBlt and PolyGlyphBlt for NonTE (proportional) + fonts. The idea is that everything in this file is device independent. + The mentioned GCOps are merely wrappers for the + PolyGlyphBltNonTEColorExpansion and ImageGlyphBltNonTEColorExpansion + functions which calculate the boxes containing arbitrarily clipped + text and passes them to the NonTEGlyphRenderer which will usually + be a lower level XAA function which renders these clipped glyphs using + the basic color expansion functions exported by the chipset driver. + The NonTEGlyphRenderer itself may optionally be driver supplied to + facilitate work-arounds/optimizations at a higher level than usual. + + Written by Mark Vojkovich (mvojkovi@ucsd.edu) + +********************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include <X11/fonts/font.h> +#include "scrnintstr.h" +#include "dixfontstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaacexp.h" +#include "xaalocal.h" +#include "gcstruct.h" +#include "pixmapstr.h" + + +static void ImageGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn, + int xInit, int yInit, FontPtr font, + int fg, int bg, unsigned planemask, + RegionPtr cclip, int nglyph, + unsigned char* gBase, CharInfoPtr *ppci); +static int PolyGlyphBltNonTEColorExpansion(ScrnInfoPtr pScrn, + int xInit, int yInit, FontPtr font, + int fg, int rop, unsigned planemask, + RegionPtr cclip, int nglyph, + unsigned char* gBase, CharInfoPtr *ppci); + +/******************************************************************** + + GC level replacements for PolyText8/16 and ImageText8/16 + for NonTE fonts when using color expansion. + +********************************************************************/ + + +int +XAAPolyText8NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + int width = 0; + + (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, + (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo); + + if(n) { + width = PolyGlyphBltNonTEColorExpansion( infoRec->pScrn, + x + pDraw->x, y + pDraw->y, pGC->font, + pGC->fgPixel, pGC->alu, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), + infoRec->CharInfo); + } + + return (x + width); +} + + +int +XAAPolyText16NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + int width = 0; + + (*pGC->font->get_glyphs)( + pGC->font, (unsigned long)count, (unsigned char *)chars, + (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, + &n, infoRec->CharInfo); + + if(n) { + width = PolyGlyphBltNonTEColorExpansion( infoRec->pScrn, + x + pDraw->x, y + pDraw->y, pGC->font, + pGC->fgPixel, pGC->alu, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), + infoRec->CharInfo); + } + + return (x + width); +} + + +void +XAAImageText8NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, + (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo); + + if(n) ImageGlyphBltNonTEColorExpansion( + infoRec->pScrn, x + pDraw->x, y + pDraw->y, + pGC->font, pGC->fgPixel, pGC->bgPixel, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo); +} + + +void +XAAImageText16NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + (*pGC->font->get_glyphs)( + pGC->font, (unsigned long)count, (unsigned char *)chars, + (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, + &n, infoRec->CharInfo); + + if(n) ImageGlyphBltNonTEColorExpansion( + infoRec->pScrn, x + pDraw->x, y + pDraw->y, + pGC->font, pGC->fgPixel, pGC->bgPixel, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo); +} + + + +/******************************************************************** + + GC level replacements for ImageGlyphBlt and PolyGlyphBlt for + NonTE fonts when using color expansion. + +********************************************************************/ + + +void +XAAImageGlyphBltNonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, /* array of character info */ + pointer pglyphBase /* start of array of glyphs */ +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + ImageGlyphBltNonTEColorExpansion( + infoRec->pScrn, xInit + pDraw->x, yInit + pDraw->y, + pGC->font, pGC->fgPixel, pGC->bgPixel, pGC->planemask, + pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci); +} + +void +XAAPolyGlyphBltNonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, /* array of character info */ + pointer pglyphBase /* start of array of glyphs */ +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + PolyGlyphBltNonTEColorExpansion( + infoRec->pScrn, xInit + pDraw->x, yInit + pDraw->y, + pGC->font, pGC->fgPixel, pGC->alu, pGC->planemask, + pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci); +} + + + + +/******************************************************************** + + ImageGlyphBltNonTEColorExpansion - + PolyGlyphBltNonTEColorExpansion - + + These guys compute the clipped pieces of text and send it to + the lower-level function which will handle acceleration of + arbitrarily clipped text. + +********************************************************************/ + + + +static int +CollectCharacterInfo( + NonTEGlyphPtr glyphs, + unsigned int nglyph, + CharInfoPtr *ppci, + FontPtr pfont +){ + int i, w = 0; + + for(i = 0; i < nglyph; i++, ppci++, glyphs++) { + glyphs->bits = (unsigned char*)((*ppci)->bits); + glyphs->start = w + (*ppci)->metrics.leftSideBearing; + glyphs->end = w + (*ppci)->metrics.rightSideBearing; + glyphs->yoff = (*ppci)->metrics.ascent; + glyphs->height = glyphs->yoff + (*ppci)->metrics.descent; + glyphs->srcwidth = PADGLYPHWIDTHBYTES(glyphs->end - glyphs->start); + w += (*ppci)->metrics.characterWidth; + } + return w; +} + + +static void +PolyGlyphBltAsSingleBitmap ( + ScrnInfoPtr pScrn, + int nglyph, + FontPtr font, + int xInit, + int yInit, + int nbox, + BoxPtr pbox, + int fg, + int rop, + unsigned planemask +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32 *block, *pntr, *bits; + int pitch, topLine, botLine, top, bot, height; + int Left, Right, Top, Bottom; + int LeftEdge, RightEdge; + int bitPitch, shift, size, i, skippix; + NonTEGlyphPtr glyphs = infoRec->GlyphInfo; + Bool extra; + + Left = xInit + infoRec->GlyphInfo[0].start; + Right = xInit + infoRec->GlyphInfo[nglyph - 1].end; + Top = yInit - FONTMAXBOUNDS(font,ascent); + Bottom = yInit + FONTMAXBOUNDS(font,descent); + + /* get into the first band that may contain part of our string */ + while(nbox && (Top >= pbox->y2)) { + pbox++; nbox--; + } + + if(!nbox) return; + + pitch = (Right - Left + 31) >> 5; + size = (pitch << 2) * (Bottom - Top); + block = (CARD32*)xalloc(size); + bzero(block, size); + + topLine = 10000; botLine = -10000; + + while(nglyph--) { + top = -glyphs->yoff; + bot = top + glyphs->height; + if(top < topLine) topLine = top; + if(bot > botLine) botLine = bot; + skippix = glyphs->start - infoRec->GlyphInfo[0].start; + bits = (CARD32*)glyphs->bits; + bitPitch = glyphs->srcwidth >> 2; + pntr = block + ((FONTMAXBOUNDS(font,ascent) + top) * pitch) + + (skippix >> 5); + shift = skippix & 31; + extra = ((shift + glyphs->end - glyphs->start) > 32); + + for(i = top; i < bot; i++) { + *pntr |= SHIFT_L(*bits, shift); + if(extra) + *(pntr + 1) |= SHIFT_R(*bits,32 - shift); + pntr += pitch; + bits += bitPitch; + } + + glyphs++; + } + + pntr = block + ((FONTMAXBOUNDS(font,ascent) + topLine) * pitch); + + Top = yInit + topLine; + Bottom = yInit + botLine; + + while(nbox && (Top >= pbox->y2)) { + pbox++; nbox--; + } + + while(nbox && (Bottom > pbox->y1)) { + LeftEdge = max(Left, pbox->x1); + RightEdge = min(Right, pbox->x2); + + if(RightEdge > LeftEdge) { + skippix = LeftEdge - Left; + topLine = max(Top, pbox->y1); + botLine = min(Bottom, pbox->y2); + height = botLine - topLine; + + if(height > 0) + (*infoRec->WriteBitmap)(pScrn, LeftEdge, topLine, + RightEdge - LeftEdge, height, + (unsigned char*)(pntr + ((topLine - Top) * pitch) + + (skippix >> 5)), + pitch << 2, skippix & 31, fg, -1, rop, planemask); + } + + nbox--; pbox++; + } + + xfree(block); +} + +static void +ImageGlyphBltNonTEColorExpansion( + ScrnInfoPtr pScrn, + int xInit, int yInit, + FontPtr font, + int fg, int bg, + unsigned planemask, + RegionPtr cclip, + int nglyph, + unsigned char* gBase, + CharInfoPtr *ppci +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int skippix, skipglyph, width, n, i; + int Left, Right, Top, Bottom; + int LeftEdge, RightEdge, ytop, ybot; + int nbox = REGION_NUM_RECTS(cclip); + BoxPtr pbox = REGION_RECTS(cclip); + Bool AlreadySetup = FALSE; + + width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font); + + /* find our backing rectangle dimensions */ + Left = xInit; + Right = Left + width; + Top = yInit - FONTASCENT(font); + Bottom = yInit + FONTDESCENT(font); + + /* get into the first band that may contain part of our box */ + while(nbox && (Top >= pbox->y2)) { + pbox++; nbox--; + } + + while(nbox && (Bottom >= pbox->y1)) { + /* handle backing rect first */ + LeftEdge = max(Left, pbox->x1); + RightEdge = min(Right, pbox->x2); + if(RightEdge > LeftEdge) { + ytop = max(Top, pbox->y1); + ybot = min(Bottom, pbox->y2); + + if(ybot > ytop) { + if(!AlreadySetup) { + (*infoRec->SetupForSolidFill)(pScrn, bg, GXcopy, planemask); + AlreadySetup = TRUE; + } + (*infoRec->SubsequentSolidFillRect)(pScrn, + LeftEdge, ytop, RightEdge - LeftEdge, ybot - ytop); + } + } + nbox--; pbox++; + } + + nbox = REGION_NUM_RECTS(cclip); + pbox = REGION_RECTS(cclip); + + if(infoRec->WriteBitmap && (nglyph > 1) && + ((FONTMAXBOUNDS(font, rightSideBearing) - + FONTMINBOUNDS(font, leftSideBearing)) <= 32)) + { + PolyGlyphBltAsSingleBitmap(pScrn, nglyph, font, + xInit, yInit, nbox, pbox, + fg, GXcopy, planemask); + + return; + } + + /* compute an approximate but covering bounding box */ + Left = xInit + infoRec->GlyphInfo[0].start; + Right = xInit + infoRec->GlyphInfo[nglyph - 1].end; + Top = yInit - FONTMAXBOUNDS(font,ascent); + Bottom = yInit + FONTMAXBOUNDS(font,descent); + + /* get into the first band that may contain part of our box */ + while(nbox && (Top >= pbox->y2)) { + pbox++; nbox--; + } + + /* stop when the lower edge of the box is beyond our string */ + while(nbox && (Bottom >= pbox->y1)) { + LeftEdge = max(Left, pbox->x1); + RightEdge = min(Right, pbox->x2); + + if(RightEdge > LeftEdge) { /* we're possibly drawing something */ + ytop = max(Top, pbox->y1); + ybot = min(Bottom, pbox->y2); + if(ybot > ytop) { + skippix = LeftEdge - xInit; + skipglyph = 0; + while(skippix >= infoRec->GlyphInfo[skipglyph].end) + skipglyph++; + + skippix = RightEdge - xInit; + n = 0; i = skipglyph; + while((i < nglyph) && (skippix > infoRec->GlyphInfo[i].start)) { + i++; n++; + } + + if(n) (*infoRec->NonTEGlyphRenderer)(pScrn, + xInit, yInit, n, infoRec->GlyphInfo + skipglyph, + pbox, fg, GXcopy, planemask); + } + } + + nbox--; pbox++; + } +} + + +static int +PolyGlyphBltNonTEColorExpansion( + ScrnInfoPtr pScrn, + int xInit, int yInit, + FontPtr font, + int fg, int rop, + unsigned planemask, + RegionPtr cclip, + int nglyph, + unsigned char* gBase, + CharInfoPtr *ppci +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int skippix, skipglyph, width, n, i; + int Left, Right, Top, Bottom; + int LeftEdge, RightEdge; + int nbox = REGION_NUM_RECTS(cclip); + BoxPtr pbox = REGION_RECTS(cclip); + + width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font); + + if(!nbox) + return width; + + if((infoRec->WriteBitmap) && (rop == GXcopy) && (nglyph > 1) && + ((FONTMAXBOUNDS(font, rightSideBearing) - + FONTMINBOUNDS(font, leftSideBearing)) <= 32)) { + + PolyGlyphBltAsSingleBitmap(pScrn, nglyph, font, + xInit, yInit, nbox, pbox, + fg, rop, planemask); + + return width; + } + + /* compute an approximate but covering bounding box */ + Left = xInit + infoRec->GlyphInfo[0].start; + Right = xInit + infoRec->GlyphInfo[nglyph - 1].end; + Top = yInit - FONTMAXBOUNDS(font,ascent); + Bottom = yInit + FONTMAXBOUNDS(font,descent); + + /* get into the first band that may contain part of our string */ + while(nbox && (Top >= pbox->y2)) { + pbox++; nbox--; + } + + /* stop when the lower edge of the box is beyond our string */ + while(nbox && (Bottom >= pbox->y1)) { + LeftEdge = max(Left, pbox->x1); + RightEdge = min(Right, pbox->x2); + + if(RightEdge > LeftEdge) { /* we're possibly drawing something */ + + skippix = LeftEdge - xInit; + skipglyph = 0; + while(skippix >= infoRec->GlyphInfo[skipglyph].end) + skipglyph++; + + skippix = RightEdge - xInit; + n = 0; i = skipglyph; + while((i < nglyph) && (skippix > infoRec->GlyphInfo[i].start)) { + i++; n++; + } + + if(n) (*infoRec->NonTEGlyphRenderer)(pScrn, + xInit, yInit, n, infoRec->GlyphInfo + skipglyph, + pbox, fg, rop, planemask); + } + + nbox--; pbox++; + } + return width; +} + + +/* It is possible that the none of the glyphs passed to the + NonTEGlyphRenderer will be drawn. This function being called + indicates that part of the text string's bounding box is visible + but not necessarily that any of the characters are visible */ + +void XAANonTEGlyphRenderer( + ScrnInfoPtr pScrn, + int x, int y, int n, + NonTEGlyphPtr glyphs, + BoxPtr pbox, + int fg, int rop, + unsigned int planemask +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x1, x2, y1, y2, i, w, h, skipleft, skiptop; + unsigned char *src; + + for(i = 0; i < n; i++, glyphs++) { + x1 = x + glyphs->start; + x2 = x + glyphs->end; + y1 = y - glyphs->yoff; + y2 = y1 + glyphs->height; + + if(y1 < pbox->y1) { + skiptop = pbox->y1 - y1; + y1 = pbox->y1; + } else skiptop = 0; + if(y2 > pbox->y2) y2 = pbox->y2; + h = y2 - y1; + if(h <= 0) continue; + + if(x1 < pbox->x1) { + skipleft = pbox->x1 - x1; + x1 = pbox->x1; + } else skipleft = 0; + if(x2 > pbox->x2) x2 = pbox->x2; + + w = x2 - x1; + + if(w > 0) { + src = glyphs->bits + (skiptop * glyphs->srcwidth); + + if(skipleft) { + src += (skipleft >> 5) << 2; + skipleft &= 31; + } + + (*infoRec->WriteBitmap)(pScrn, x1, y1, w, h, src, + glyphs->srcwidth, skipleft, fg, -1, rop, planemask); + } + } + +} diff --git a/xorg-server/hw/xfree86/xaa/xaaOffscreen.c b/xorg-server/hw/xfree86/xaa/xaaOffscreen.c new file mode 100644 index 000000000..7c9d53270 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaOffscreen.c @@ -0,0 +1,162 @@ + +/* + Copyright (c) 1999 - The XFree86 Project Inc. + + Written by Mark Vojkovich + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "mi.h" +#include "miline.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" +#include "xf86fbman.h" +#include "servermd.h" + +void +XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + PixmapLinkPtr pLink = infoRec->OffscreenPixmaps; + XAAPixmapPtr pPriv; + + while(pLink) { + pPriv = XAA_GET_PIXMAP_PRIVATE(pLink->pPix); + pLink->area = pPriv->offscreenArea; + XAAMoveOutOffscreenPixmap(pLink->pPix); + pLink = pLink->next; + } +} + + + +void +XAAMoveInOffscreenPixmaps(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + PixmapLinkPtr pLink = infoRec->OffscreenPixmaps; + PixmapPtr pPix, pScreenPix, tmpPix; + pointer data; + XAAPixmapPtr pPriv; + GCPtr pGC; + FBAreaPtr area; + + pScreenPix = (*pScreen->GetScreenPixmap)(pScreen); + + while(pLink) { + pPix = pLink->pPix; + pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + area = pLink->area; + + data = pPix->devPrivate.ptr; + tmpPix = GetScratchPixmapHeader(pScreen, + pPix->drawable.width, pPix->drawable.height, + pPix->drawable.depth, pPix->drawable.bitsPerPixel, + pPix->devKind, data); + + pPriv->freeData = FALSE; + + pPix->drawable.x = area->box.x1; + pPix->drawable.y = area->box.y1; + pPix->devKind = pScreenPix->devKind; + pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr; + pPix->drawable.bitsPerPixel = infoRec->pScrn->bitsPerPixel; + pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER; + + if(!tmpPix) { + pPriv->offscreenArea = area; + xfree(data); + pLink = pLink->next; + continue; + } + + pGC = GetScratchGC(pPix->drawable.depth, pScreen); + ValidateGC((DrawablePtr)pPix, pGC); + + (*pGC->ops->CopyArea)((DrawablePtr)tmpPix, (DrawablePtr)pPix, pGC, + 0, 0, pPix->drawable.width, pPix->drawable.height, 0, 0); + + xfree(data); + tmpPix->devPrivate.ptr = NULL; + + FreeScratchGC(pGC); + FreeScratchPixmapHeader(tmpPix); + + pPriv->offscreenArea = area; + pLink->area = NULL; + pLink = pLink->next; + } +} + + +void +XAARemoveAreaCallback(FBAreaPtr area) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(area->pScreen); + PixmapPtr pPix = (PixmapPtr)area->devPrivate.ptr; + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + + XAAMoveOutOffscreenPixmap(pPix); + + pPriv->flags &= ~OFFSCREEN; + + DELIST_OFFSCREEN_PIXMAP(pPix); +} + +void +XAAMoveOutOffscreenPixmap(PixmapPtr pPix) +{ + ScreenPtr pScreen = pPix->drawable.pScreen; + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + int width, height, devKind, bitsPerPixel; + PixmapPtr tmpPix; + unsigned char *data; + GCPtr pGC; + + width = pPix->drawable.width; + height = pPix->drawable.height; + bitsPerPixel = pPix->drawable.bitsPerPixel; + + devKind = BitmapBytePad(width * bitsPerPixel); + if(!(data = xalloc(devKind * height))) + FatalError("Out of memory\n"); + + tmpPix = GetScratchPixmapHeader(pScreen, width, height, + pPix->drawable.depth, bitsPerPixel, devKind, data); + if(!tmpPix) { + xfree(data); + FatalError("Out of memory\n"); + } + + pGC = GetScratchGC(pPix->drawable.depth, pScreen); + ValidateGC((DrawablePtr)tmpPix, pGC); + + (*pGC->ops->CopyArea)((DrawablePtr)pPix, (DrawablePtr)tmpPix, + pGC, 0, 0, width, height, 0, 0); + + FreeScratchGC(pGC); + FreeScratchPixmapHeader(tmpPix); + + pPix->drawable.x = 0; + pPix->drawable.y = 0; + pPix->devKind = devKind; + pPix->devPrivate.ptr = data; + pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER; + + pPriv->offscreenArea = NULL; + pPriv->freeData = TRUE; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlay.c b/xorg-server/hw/xfree86/xaa/xaaOverlay.c new file mode 100644 index 000000000..273183e10 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaOverlay.c @@ -0,0 +1,129 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "mioverlay.h" + +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif + +static void +XAACopyWindow8_32( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc +){ + DDXPointPtr pptSrc, ppt; + RegionRec rgnDst; + BoxPtr pbox; + int dx, dy, nbox; + WindowPtr pwinRoot; + ScreenPtr pScreen = pWin->drawable.pScreen; + XAAInfoRecPtr infoRec = + GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable)); + Bool doUnderlay = miOverlayCopyUnderlay(pScreen); + RegionPtr borderClip = &pWin->borderClip; + Bool freeReg = FALSE; + + if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt || + (infoRec->ScreenToScreenBitBltFlags & NO_PLANEMASK)) + { + XAA_SCREEN_PROLOGUE (pScreen, CopyWindow); + if(infoRec->pScrn->vtSema && infoRec->NeedToSync) { + (*infoRec->Sync)(infoRec->pScrn); + infoRec->NeedToSync = FALSE; + } + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); + XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAACopyWindow8_32); + return; + } + + pwinRoot = WindowTable[pScreen->myNum]; + + if(doUnderlay) + freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip); + + REGION_NULL(pScreen, &rgnDst); + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); + REGION_INTERSECT(pScreen, &rgnDst, borderClip, prgnSrc); + + pbox = REGION_RECTS(&rgnDst); + nbox = REGION_NUM_RECTS(&rgnDst); + if(!nbox || + !(pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec)))) { + REGION_UNINIT(pScreen, &rgnDst); + return; + } + ppt = pptSrc; + + while(nbox--) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + ppt++; pbox++; + } + + infoRec->ScratchGC.planemask = doUnderlay ? 0x00ffffff : 0xff000000; + infoRec->ScratchGC.alu = GXcopy; + + XAADoBitBlt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + &(infoRec->ScratchGC), &rgnDst, pptSrc); + + xfree(pptSrc); + REGION_UNINIT(pScreen, &rgnDst); + if(freeReg) + REGION_DESTROY(pScreen, borderClip); +} + +static void +XAASetColorKey8_32( + ScreenPtr pScreen, + int nbox, + BoxPtr pbox +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + ScrnInfoPtr pScrn = infoRec->pScrn; + + /* I'm counting on writes being clipped away while switched away. + If this isn't going to be true then I need to be wrapping instead. */ + if(!infoRec->pScrn->vtSema) return; + + (*infoRec->FillSolidRects)(pScrn, pScrn->colorKey << 24, GXcopy, + 0xff000000, nbox, pbox); + + SET_SYNC_FLAG(infoRec); +} + +void +XAASetupOverlay8_32Planar(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + int i; + + pScreen->CopyWindow = XAACopyWindow8_32; + + if(!(infoRec->FillSolidRectsFlags & NO_PLANEMASK)) + miOverlaySetTransFunction(pScreen, XAASetColorKey8_32); + + infoRec->FullPlanemask = ~0; + for(i = 0; i < 32; i++) /* haven't thought about this much */ + infoRec->FullPlanemasks[i] = ~0; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c new file mode 100644 index 000000000..64ca998ee --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c @@ -0,0 +1,1049 @@ +/* + Copyright (c) 1999 - The XFree86 Project Inc. + + Written by Mark Vojkovich +*/ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "mi.h" +#include "miline.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" +#include "servermd.h" + +/* Screen funcs */ + +static void XAAOverCopyWindow(WindowPtr, DDXPointRec, RegionPtr); +static void XAAOverWindowExposures(WindowPtr, RegionPtr, RegionPtr); + +static int XAAOverStippledFillChooser(GCPtr); +static int XAAOverOpaqueStippledFillChooser(GCPtr); +static int XAAOverTiledFillChooser(GCPtr); + +/* GC funcs */ + +static RegionPtr XAAOverCopyArea(DrawablePtr, DrawablePtr, GC *, + int, int, int, int, int, int); +static RegionPtr XAAOverCopyPlane(DrawablePtr, DrawablePtr, GCPtr, + int, int, int, int, int, int, unsigned long); +static void XAAOverPushPixelsSolid(GCPtr, PixmapPtr, DrawablePtr, int, + int, int, int); +static void XAAOverPolyFillRectSolid(DrawablePtr, GCPtr, int, xRectangle*); +static void XAAOverPolyFillRectStippled(DrawablePtr, GCPtr, int, xRectangle*); +static void XAAOverPolyFillRectOpaqueStippled(DrawablePtr, GCPtr, + int, xRectangle*); +static void XAAOverPolyFillRectTiled(DrawablePtr, GCPtr, int, xRectangle*); +static void XAAOverFillSpansSolid(DrawablePtr, GCPtr, int, DDXPointPtr, + int*, int); +static void XAAOverFillSpansStippled(DrawablePtr, GCPtr, int, DDXPointPtr, + int*, int); +static void XAAOverFillSpansOpaqueStippled(DrawablePtr, GCPtr, int, + DDXPointPtr, int*, int); +static void XAAOverFillSpansTiled(DrawablePtr, GCPtr, int, DDXPointPtr, + int*, int); +static int XAAOverPolyText8TE(DrawablePtr, GCPtr, int, int, int, char *); +static int XAAOverPolyText16TE(DrawablePtr, GCPtr, int, int, int, + unsigned short*); +static void XAAOverImageText8TE(DrawablePtr, GCPtr, int, int, int, char*); +static void XAAOverImageText16TE(DrawablePtr, GCPtr, int, int, int, + unsigned short*); +static void XAAOverImageGlyphBltTE(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr*, pointer); +static void XAAOverPolyGlyphBltTE(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr*, pointer); +static int XAAOverPolyText8NonTE(DrawablePtr, GCPtr, int, int, int, char*); +static int XAAOverPolyText16NonTE(DrawablePtr, GCPtr, int, int, int, + unsigned short*); +static void XAAOverImageText8NonTE(DrawablePtr, GCPtr, int, int, int, char*); +static void XAAOverImageText16NonTE(DrawablePtr, GCPtr, int, int, int, + unsigned short*); +static void XAAOverImageGlyphBltNonTE(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); +static void XAAOverPolyGlyphBltNonTE(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); +static void XAAOverPolyRectangleThinSolid(DrawablePtr, GCPtr, int, xRectangle*); +static void XAAOverPolylinesWideSolid(DrawablePtr, GCPtr, int, int, + DDXPointPtr); +static void XAAOverPolylinesThinSolid(DrawablePtr, GCPtr, int, int, + DDXPointPtr); +static void XAAOverPolySegmentThinSolid(DrawablePtr, GCPtr, int, xSegment*); +static void XAAOverPolylinesThinDashed(DrawablePtr, GCPtr, int, int, + DDXPointPtr); +static void XAAOverPolySegmentThinDashed(DrawablePtr, GCPtr, int, xSegment*); +static void XAAOverFillPolygonSolid(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void XAAOverFillPolygonStippled(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void XAAOverFillPolygonOpaqueStippled(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void XAAOverFillPolygonTiled(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void XAAOverPolyFillArcSolid(DrawablePtr, GCPtr, int, xArc*); +static void XAAOverPutImage(DrawablePtr, GCPtr, int, int, int, int, int, + int, int, char*); + + +typedef struct { + ScrnInfoPtr pScrn; + DepthChangeFuncPtr callback; + int currentDepth; +/* GC funcs */ + RegionPtr (*CopyArea)(DrawablePtr, DrawablePtr, GC *, + int, int, int, int, int, int); + RegionPtr (*CopyPlane)(DrawablePtr, DrawablePtr, GCPtr, + int, int, int, int, int, int, unsigned long); + void (*PushPixelsSolid)(GCPtr, PixmapPtr, DrawablePtr, int, int, int, int); + void (*PolyFillRectSolid)(DrawablePtr, GCPtr, int, xRectangle*); + void (*PolyFillRectStippled)(DrawablePtr, GCPtr, int, xRectangle*); + void (*PolyFillRectOpaqueStippled)(DrawablePtr, GCPtr, int, xRectangle*); + void (*PolyFillRectTiled)(DrawablePtr, GCPtr, int, xRectangle*); + void (*FillSpansSolid)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int); + void (*FillSpansStippled)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int); + void (*FillSpansOpaqueStippled)(DrawablePtr,GCPtr,int,DDXPointPtr,int*,int); + void (*FillSpansTiled)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int); + int (*PolyText8TE)(DrawablePtr, GCPtr, int, int, int, char *); + int (*PolyText16TE)(DrawablePtr, GCPtr, int, int, int, unsigned short*); + void (*ImageText8TE)(DrawablePtr, GCPtr, int, int, int, char*); + void (*ImageText16TE)(DrawablePtr, GCPtr, int, int, int, unsigned short*); + void (*ImageGlyphBltTE)(DrawablePtr, GCPtr, int, int, unsigned int, + CharInfoPtr*, pointer); + void (*PolyGlyphBltTE)(DrawablePtr, GCPtr, int, int, unsigned int, + CharInfoPtr*, pointer); + int (*PolyText8NonTE)(DrawablePtr, GCPtr, int, int, int, char*); + int (*PolyText16NonTE)(DrawablePtr, GCPtr, int, int, int, unsigned short*); + void (*ImageText8NonTE)(DrawablePtr, GCPtr, int, int, int, char*); + void (*ImageText16NonTE)(DrawablePtr, GCPtr, int, int, int, unsigned short*); + void (*ImageGlyphBltNonTE)(DrawablePtr, GCPtr, int, int, unsigned int, + CharInfoPtr *, pointer); + void (*PolyGlyphBltNonTE)(DrawablePtr, GCPtr, int, int, unsigned int, + CharInfoPtr *, pointer); + void (*PolyRectangleThinSolid)(DrawablePtr, GCPtr, int, xRectangle*); + void (*PolylinesWideSolid)(DrawablePtr, GCPtr, int, int, DDXPointPtr); + + void (*PolylinesThinSolid)(DrawablePtr, GCPtr, int, int, DDXPointPtr); + void (*PolySegmentThinSolid)(DrawablePtr, GCPtr, int, xSegment*); + void (*PolylinesThinDashed)(DrawablePtr, GCPtr, int, int, DDXPointPtr); + void (*PolySegmentThinDashed)(DrawablePtr, GCPtr, int, xSegment*); + void (*FillPolygonSolid)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr); + void (*FillPolygonStippled)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr); + void (*FillPolygonOpaqueStippled)(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); + void (*FillPolygonTiled)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr); + void (*PolyFillArcSolid)(DrawablePtr, GCPtr, int, xArc*); + void (*PutImage)(DrawablePtr, GCPtr, int, int, int, int, int, int, + int, char*); + int (*StippledFillChooser)(GCPtr); + int (*OpaqueStippledFillChooser)(GCPtr); + int (*TiledFillChooser)(GCPtr); +} XAAOverlayRec, *XAAOverlayPtr; + +static DevPrivateKey XAAOverlayKey = &XAAOverlayKey; + +#define GET_OVERLAY_PRIV(pScreen) \ + (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey) + +#define SWITCH_DEPTH(d) \ + if(pOverPriv->currentDepth != d) { \ + (*pOverPriv->callback)(pOverPriv->pScrn, d); \ + pOverPriv->currentDepth = d; \ + } + + +Bool +XAAInitDualFramebufferOverlay( + ScreenPtr pScreen, + DepthChangeFuncPtr callback +){ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAAOverlayPtr pOverPriv; + + if(!(pOverPriv = xalloc(sizeof(XAAOverlayRec)))) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv); + + pOverPriv->pScrn = pScrn; + pOverPriv->callback = callback; + pOverPriv->currentDepth = -1; + + /* Overwrite key screen functions. The XAA core will clean up */ + + pScreen->CopyWindow = XAAOverCopyWindow; + pScreen->WindowExposures = XAAOverWindowExposures; + + pOverPriv->StippledFillChooser = infoRec->StippledFillChooser; + pOverPriv->OpaqueStippledFillChooser = infoRec->OpaqueStippledFillChooser; + pOverPriv->TiledFillChooser = infoRec->TiledFillChooser; + + infoRec->StippledFillChooser = XAAOverStippledFillChooser; + infoRec->OpaqueStippledFillChooser = XAAOverOpaqueStippledFillChooser; + infoRec->TiledFillChooser = XAAOverTiledFillChooser; + + /* wrap all XAA GC rendering */ + + pOverPriv->CopyArea = infoRec->CopyArea; + pOverPriv->CopyPlane = infoRec->CopyPlane; + pOverPriv->PushPixelsSolid = infoRec->PushPixelsSolid; + pOverPriv->PolyFillRectSolid = infoRec->PolyFillRectSolid; + pOverPriv->PolyFillRectStippled = infoRec->PolyFillRectStippled; + pOverPriv->PolyFillRectOpaqueStippled = infoRec->PolyFillRectOpaqueStippled; + pOverPriv->PolyFillRectTiled = infoRec->PolyFillRectTiled; + pOverPriv->FillSpansSolid = infoRec->FillSpansSolid; + pOverPriv->FillSpansStippled = infoRec->FillSpansStippled; + pOverPriv->FillSpansOpaqueStippled = infoRec->FillSpansOpaqueStippled; + pOverPriv->FillSpansTiled = infoRec->FillSpansTiled; + pOverPriv->PolyText8TE = infoRec->PolyText8TE; + pOverPriv->PolyText16TE = infoRec->PolyText16TE; + pOverPriv->ImageText8TE = infoRec->ImageText8TE; + pOverPriv->ImageText16TE = infoRec->ImageText16TE; + pOverPriv->ImageGlyphBltTE = infoRec->ImageGlyphBltTE; + pOverPriv->PolyGlyphBltTE = infoRec->PolyGlyphBltTE; + pOverPriv->PolyText8NonTE = infoRec->PolyText8NonTE; + pOverPriv->PolyText16NonTE = infoRec->PolyText16NonTE; + pOverPriv->ImageText8NonTE = infoRec->ImageText8NonTE; + pOverPriv->ImageText16NonTE = infoRec->ImageText16NonTE; + pOverPriv->ImageGlyphBltNonTE = infoRec->ImageGlyphBltNonTE; + pOverPriv->PolyGlyphBltNonTE = infoRec->PolyGlyphBltNonTE; + pOverPriv->PolyRectangleThinSolid = infoRec->PolyRectangleThinSolid; + pOverPriv->PolylinesWideSolid = infoRec->PolylinesWideSolid; + pOverPriv->PolylinesThinSolid = infoRec->PolylinesThinSolid; + pOverPriv->PolySegmentThinSolid = infoRec->PolySegmentThinSolid; + pOverPriv->PolylinesThinDashed = infoRec->PolylinesThinDashed; + pOverPriv->PolySegmentThinDashed = infoRec->PolySegmentThinDashed; + pOverPriv->FillPolygonSolid = infoRec->FillPolygonSolid; + pOverPriv->FillPolygonStippled = infoRec->FillPolygonStippled; + pOverPriv->FillPolygonOpaqueStippled = infoRec->FillPolygonOpaqueStippled; + pOverPriv->FillPolygonTiled = infoRec->FillPolygonTiled; + pOverPriv->PolyFillArcSolid = infoRec->PolyFillArcSolid; + pOverPriv->PutImage = infoRec->PutImage; + + + if(infoRec->CopyArea) + infoRec->CopyArea = XAAOverCopyArea; + if(infoRec->CopyPlane) + infoRec->CopyPlane = XAAOverCopyPlane; + if(infoRec->PushPixelsSolid) + infoRec->PushPixelsSolid = XAAOverPushPixelsSolid; + if(infoRec->PolyFillRectSolid) + infoRec->PolyFillRectSolid = XAAOverPolyFillRectSolid; + if(infoRec->PolyFillRectStippled) + infoRec->PolyFillRectStippled = XAAOverPolyFillRectStippled; + if(infoRec->PolyFillRectOpaqueStippled) + infoRec->PolyFillRectOpaqueStippled = XAAOverPolyFillRectOpaqueStippled; + if(infoRec->PolyFillRectTiled) + infoRec->PolyFillRectTiled = XAAOverPolyFillRectTiled; + if(infoRec->FillSpansSolid) + infoRec->FillSpansSolid = XAAOverFillSpansSolid; + if(infoRec->FillSpansStippled) + infoRec->FillSpansStippled = XAAOverFillSpansStippled; + if(infoRec->FillSpansOpaqueStippled) + infoRec->FillSpansOpaqueStippled = XAAOverFillSpansOpaqueStippled; + if(infoRec->FillSpansTiled) + infoRec->FillSpansTiled = XAAOverFillSpansTiled; + if(infoRec->PolyText8TE) + infoRec->PolyText8TE = XAAOverPolyText8TE; + if(infoRec->PolyText16TE) + infoRec->PolyText16TE = XAAOverPolyText16TE; + if(infoRec->ImageText8TE) + infoRec->ImageText8TE = XAAOverImageText8TE; + if(infoRec->ImageText16TE) + infoRec->ImageText16TE = XAAOverImageText16TE; + if(infoRec->ImageGlyphBltTE) + infoRec->ImageGlyphBltTE = XAAOverImageGlyphBltTE; + if(infoRec->PolyGlyphBltTE) + infoRec->PolyGlyphBltTE = XAAOverPolyGlyphBltTE; + if(infoRec->PolyText8NonTE) + infoRec->PolyText8NonTE = XAAOverPolyText8NonTE; + if(infoRec->PolyText16NonTE) + infoRec->PolyText16NonTE = XAAOverPolyText16NonTE; + if(infoRec->ImageText8NonTE) + infoRec->ImageText8NonTE = XAAOverImageText8NonTE; + if(infoRec->ImageText16NonTE) + infoRec->ImageText16NonTE = XAAOverImageText16NonTE; + if(infoRec->ImageGlyphBltNonTE) + infoRec->ImageGlyphBltNonTE = XAAOverImageGlyphBltNonTE; + if(infoRec->PolyGlyphBltNonTE) + infoRec->PolyGlyphBltNonTE = XAAOverPolyGlyphBltNonTE; + if(infoRec->PolyRectangleThinSolid) + infoRec->PolyRectangleThinSolid = XAAOverPolyRectangleThinSolid; + if(infoRec->PolylinesWideSolid) + infoRec->PolylinesWideSolid = XAAOverPolylinesWideSolid; + if(infoRec->PolylinesThinSolid) + infoRec->PolylinesThinSolid = XAAOverPolylinesThinSolid; + if(infoRec->PolySegmentThinSolid) + infoRec->PolySegmentThinSolid = XAAOverPolySegmentThinSolid; + if(infoRec->PolylinesThinDashed) + infoRec->PolylinesThinDashed = XAAOverPolylinesThinDashed; + if(infoRec->PolySegmentThinDashed) + infoRec->PolySegmentThinDashed = XAAOverPolySegmentThinDashed; + if(infoRec->FillPolygonSolid) + infoRec->FillPolygonSolid = XAAOverFillPolygonSolid; + if(infoRec->FillPolygonStippled) + infoRec->FillPolygonStippled = XAAOverFillPolygonStippled; + if(infoRec->FillPolygonOpaqueStippled) + infoRec->FillPolygonOpaqueStippled = XAAOverFillPolygonOpaqueStippled; + if(infoRec->FillPolygonTiled) + infoRec->FillPolygonTiled = XAAOverFillPolygonTiled; + if(infoRec->PolyFillArcSolid) + infoRec->PolyFillArcSolid = XAAOverPolyFillArcSolid; + if(infoRec->PutImage) + infoRec->PutImage = XAAOverPutImage; + + return TRUE; +} + +/*********************** Screen functions ************************/ + +void +XAAOverCopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc +){ + ScreenPtr pScreen = pWin->drawable.pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen); + ScrnInfoPtr pScrn = infoRec->pScrn; + DDXPointPtr ppt, pptSrc; + RegionRec rgnDst; + BoxPtr pbox; + int i, nbox, dx, dy; + WindowPtr pRoot = WindowTable[pScreen->myNum]; + + + if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) { + XAA_SCREEN_PROLOGUE (pScreen, CopyWindow); + if(pScrn->vtSema && infoRec->NeedToSync) { + (*infoRec->Sync)(pScrn); + infoRec->NeedToSync = FALSE; + } + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); + XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAAOverCopyWindow); + return; + } + + infoRec->ScratchGC.alu = GXcopy; + infoRec->ScratchGC.planemask = ~0; + + REGION_NULL(pScreen, &rgnDst); + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); + REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc); + + nbox = REGION_NUM_RECTS(&rgnDst); + if(nbox && + (pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec)))) { + + pbox = REGION_RECTS(&rgnDst); + for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + SWITCH_DEPTH(8); + XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot, + &(infoRec->ScratchGC), &rgnDst, pptSrc); + + if(pWin->drawable.bitsPerPixel != 8) { + SWITCH_DEPTH(pScrn->depth); + XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot, + &(infoRec->ScratchGC), &rgnDst, pptSrc); + } + + xfree(pptSrc); + } + + REGION_UNINIT(pScreen, &rgnDst); + + if(pWin->drawable.depth == 8) { + REGION_NULL(pScreen, &rgnDst); + miSegregateChildren(pWin, &rgnDst, pScrn->depth); + if(REGION_NOTEMPTY(pScreen, &rgnDst)) { + REGION_INTERSECT(pScreen, &rgnDst, &rgnDst, prgnSrc); + nbox = REGION_NUM_RECTS(&rgnDst); + if(nbox && + (pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec)))){ + + pbox = REGION_RECTS(&rgnDst); + for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + SWITCH_DEPTH(pScrn->depth); + XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot, + &(infoRec->ScratchGC), &rgnDst, pptSrc); + xfree(pptSrc); + } + } + REGION_UNINIT(pScreen, &rgnDst); + } +} + + +void +XAAOverWindowExposures( + WindowPtr pWin, + RegionPtr pReg, + RegionPtr pOtherReg +){ + ScreenPtr pScreen = pWin->drawable.pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + + if((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) { + if(REGION_NUM_RECTS(pReg) && infoRec->FillSolidRects) { + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen); + + SWITCH_DEPTH(8); + (*infoRec->FillSolidRects)(infoRec->pScrn, + infoRec->pScrn->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(pReg), REGION_RECTS(pReg)); + miWindowExposures(pWin, pReg, pOtherReg); + return; + } else if(infoRec->NeedToSync) { + (*infoRec->Sync)(infoRec->pScrn); + infoRec->NeedToSync = FALSE; + } + } + + XAA_SCREEN_PROLOGUE (pScreen, WindowExposures); + (*pScreen->WindowExposures) (pWin, pReg, pOtherReg); + XAA_SCREEN_EPILOGUE(pScreen, WindowExposures, XAAOverWindowExposures); +} + +/********************* Choosers *************************/ + +static int +XAAOverStippledFillChooser(GCPtr pGC) +{ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + int ret; + + ret = (*pOverPriv->StippledFillChooser)(pGC); + + if((pGC->depth == 8) && + ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) { + ret = 0; + } + + return ret; +} + +static int +XAAOverOpaqueStippledFillChooser(GCPtr pGC) +{ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + int ret; + + ret = (*pOverPriv->OpaqueStippledFillChooser)(pGC); + + if((pGC->depth == 8) && + ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) { + ret = 0; + } + + return ret; +} + +static int +XAAOverTiledFillChooser(GCPtr pGC) +{ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + int ret; + + ret = (*pOverPriv->TiledFillChooser)(pGC); + + if((pGC->depth == 8) && + ((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) { + ret = 0; + } + + return ret; +} + + +/**************************** GC Functions **************************/ + +static RegionPtr +XAAOverCopyArea( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + return (*pOverPriv->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); +} + +static RegionPtr +XAAOverCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + return (*pOverPriv->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + +} + +static void +XAAOverPushPixelsSolid( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, + int xOrg, int yOrg +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PushPixelsSolid)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); +} + + + +static void +XAAOverPolyFillRectSolid( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyFillRectSolid)(pDraw, pGC, nrectFill, prectInit); +} + +static void +XAAOverPolyFillRectStippled( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyFillRectStippled)(pDraw, pGC, nrectFill, prectInit); +} + + +static void +XAAOverPolyFillRectOpaqueStippled( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyFillRectOpaqueStippled)(pDraw, pGC, nrectFill, prectInit); +} + +static void +XAAOverPolyFillRectTiled( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyFillRectTiled)(pDraw, pGC, nrectFill, prectInit); +} + + +static void +XAAOverFillSpansSolid( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillSpansSolid)( + pDraw, pGC, nInit, ppt, pwidth, fSorted); +} + + +static void +XAAOverFillSpansStippled( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillSpansStippled)(pDraw, pGC, nInit, ppt, pwidth, fSorted); +} + +static void +XAAOverFillSpansOpaqueStippled( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillSpansOpaqueStippled)( + pDraw, pGC, nInit, ppt, pwidth, fSorted); +} + + +static void +XAAOverFillSpansTiled( + DrawablePtr pDraw, + GCPtr pGC, + int nInit, + DDXPointPtr ppt, + int *pwidth, + int fSorted +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillSpansTiled)(pDraw, pGC, nInit, ppt, pwidth, fSorted); +} + +static int +XAAOverPolyText8TE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + return (*pOverPriv->PolyText8TE)(pDraw, pGC, x, y, count, chars); +} + + +static int +XAAOverPolyText16TE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + return (*pOverPriv->PolyText16TE)(pDraw, pGC, x, y, count, chars); +} + + +static void +XAAOverImageText8TE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->ImageText8TE)(pDraw, pGC, x, y, count, chars); +} + + +static void +XAAOverImageText16TE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->ImageText16TE)(pDraw, pGC, x, y, count, chars); +} + +static void +XAAOverImageGlyphBltTE( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->ImageGlyphBltTE)( + pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase); +} + +static void +XAAOverPolyGlyphBltTE( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyGlyphBltTE)( + pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase); +} + +static int +XAAOverPolyText8NonTE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + return (*pOverPriv->PolyText8NonTE)(pDraw, pGC, x, y, count, chars); +} + + +static int +XAAOverPolyText16NonTE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + return (*pOverPriv->PolyText16NonTE)(pDraw, pGC, x, y, count, chars); +} + +static void +XAAOverImageText8NonTE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->ImageText8NonTE)(pDraw, pGC, x, y, count, chars); +} + +static void +XAAOverImageText16NonTE( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->ImageText16NonTE)(pDraw, pGC, x, y, count, chars); +} + + +static void +XAAOverImageGlyphBltNonTE( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->ImageGlyphBltNonTE)( + pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase); +} + +static void +XAAOverPolyGlyphBltNonTE( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyGlyphBltNonTE)( + pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase); +} + +static void +XAAOverPolyRectangleThinSolid( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyRectangleThinSolid)(pDraw, pGC, nRectsInit, pRectsInit); +} + + + +static void +XAAOverPolylinesWideSolid( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolylinesWideSolid)(pDraw, pGC, mode, npt, pPts); +} + + +static void +XAAOverPolylinesThinSolid( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolylinesThinSolid)(pDraw, pGC, mode, npt, pPts); +} + +static void +XAAOverPolySegmentThinSolid( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolySegmentThinSolid)(pDraw, pGC, nseg, pSeg); +} + +static void +XAAOverPolylinesThinDashed( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolylinesThinDashed)(pDraw, pGC, mode, npt, pPts); +} + +static void +XAAOverPolySegmentThinDashed( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolySegmentThinDashed)(pDraw, pGC, nseg, pSeg); +} + + +static void +XAAOverFillPolygonSolid( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillPolygonSolid)(pDraw, pGC, shape, mode, count, ptsIn); +} + +static void +XAAOverFillPolygonStippled( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillPolygonStippled)(pDraw, pGC, shape, mode, count, ptsIn); +} + + +static void +XAAOverFillPolygonOpaqueStippled( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillPolygonOpaqueStippled)( + pDraw, pGC, shape, mode, count, ptsIn); +} + +static void +XAAOverFillPolygonTiled( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->FillPolygonTiled)(pDraw, pGC, shape, mode, count, ptsIn); +} + + +static void +XAAOverPolyFillArcSolid( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PolyFillArcSolid)(pDraw, pGC, narcs, parcs); +} + + +static void +XAAOverPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, + int y, + int w, + int h, + int leftPad, + int format, + char *pImage +){ + XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen); + + SWITCH_DEPTH(pGC->depth); + + (*pOverPriv->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaPCache.c b/xorg-server/hw/xfree86/xaa/xaaPCache.c new file mode 100644 index 000000000..d05aaf22c --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaPCache.c @@ -0,0 +1,2377 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "gc.h" +#include "mi.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "regionstr.h" +#include "servermd.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaacexp.h" +#include "xaalocal.h" +#include "xaawrap.h" + +#define MAX_COLOR 32 +#define MAX_MONO 32 +#define MAX_8 32 +#define MAX_128 32 +#define MAX_256 32 +#define MAX_512 16 + +static int CacheInitIndex = -1; +#define CACHEINIT(p) ((p)->privates[CacheInitIndex].val) + + +typedef struct _CacheLink { + int x; + int y; + int w; + int h; + struct _CacheLink *next; +} CacheLink, *CacheLinkPtr; + + +static void +TransferList(CacheLinkPtr list, XAACacheInfoPtr array, int num) +{ + while(num--) { + array->x = list->x; + array->y = list->y; + array->w = list->w; + array->h = list->h; + array->serialNumber = 0; + array->fg = array->bg = -1; + list = list->next; + array++; + } +} + + + +static CacheLinkPtr +Enlist(CacheLinkPtr link, int x, int y, int w, int h) +{ + CacheLinkPtr newLink; + + newLink = xalloc(sizeof(CacheLink)); + newLink->next = link; + newLink->x = x; newLink->y = y; + newLink->w = w; newLink->h = h; + return newLink; +} + + + +static CacheLinkPtr +Delist(CacheLinkPtr link) { + CacheLinkPtr ret = NULL; + + if(link) { + ret = link->next; + xfree(link); + } + return ret; +} + + + +static void +FreeList(CacheLinkPtr link) { + CacheLinkPtr tmp; + + while(link) { + tmp = link; + link = link->next; + xfree(tmp); + } +} + + + +static CacheLinkPtr +QuadLinks(CacheLinkPtr big, CacheLinkPtr little) +{ + /* CAUTION: This doesn't free big */ + int w1, w2, h1, h2; + + while(big) { + w1 = big->w >> 1; + w2 = big->w - w1; + h1 = big->h >> 1; + h2 = big->h - h1; + + little = Enlist(little, big->x, big->y, w1, h1); + little = Enlist(little, big->x + w1, big->y, w2, h1); + little = Enlist(little, big->x, big->y + h1, w1, h2); + little = Enlist(little, big->x + w1, big->y + h1, w2, h2); + + big = big->next; + } + return little; +} + + +static void +SubdivideList(CacheLinkPtr *large, CacheLinkPtr *small) +{ + CacheLinkPtr big = *large; + CacheLinkPtr little = *small; + int size = big->w >> 1; + + little = Enlist(little, big->x, big->y, size, size); + little = Enlist(little, big->x + size, big->y, size, size); + little = Enlist(little, big->x, big->y + size, size, size); + little = Enlist(little, big->x + size, big->y + size, size, size); + *small = little; + big = Delist(big); + *large = big; +} + +static void +FreePixmapCachePrivate(XAAPixmapCachePrivatePtr pPriv) +{ + if(!pPriv) return; + + if(pPriv->Info512) + xfree(pPriv->Info512); + if(pPriv->Info256) + xfree(pPriv->Info256); + if(pPriv->Info128) + xfree(pPriv->Info128); + if(pPriv->InfoColor) + xfree(pPriv->InfoColor); + if(pPriv->InfoMono) + xfree(pPriv->InfoMono); + if(pPriv->InfoPartial) + xfree(pPriv->InfoPartial); + + xfree(pPriv); +} + +void +XAAClosePixmapCache(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + + if(infoRec->PixmapCachePrivate) + FreePixmapCachePrivate( + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate); + + infoRec->PixmapCachePrivate = NULL; +} + + + +static CacheLinkPtr +ThinOutPartials( + CacheLinkPtr ListPartial, + int *num, int *maxw, int *maxh +) { +/* This guy's job is to get at least 4 big slots out of a list of fragments */ + + CacheLinkPtr List64, List32, List16, List8, pCur, next, ListKeepers; + int Num64, Num32, Num16, Num8, NumKeepers; + int w, h; + + List64 = List32 = List16 = List8 = ListKeepers = NULL; + Num64 = Num32 = Num16 = Num8 = NumKeepers = 0; + w = h = 0; + + /* We sort partials by how large a square tile they can cache. + If a partial can't store a 64x64, 32x32, 16x16 or 8x8 tile, + we free it. */ + + pCur = ListPartial; + while(pCur) { + next = pCur->next; + if((pCur->w >= 64) && (pCur->h >= 64)) { + pCur->next = List64; List64 = pCur; + Num64++; + } else + if((pCur->w >= 32) && (pCur->h >= 32)) { + pCur->next = List32; List32 = pCur; + Num32++; + } else + if((pCur->w >= 16) && (pCur->h >= 16)) { + pCur->next = List16; List16 = pCur; + Num16++; + } else + if((pCur->w >= 8) && (pCur->h >= 8)) { + pCur->next = List8; List8 = pCur; + Num8++; + } else { + xfree(pCur); + } + + pCur = next; + } + + /* We save all the tiles from the largest bin that we can get + at least 4 of. If there are too few of a bigger slot, we + cut it in fourths to make smaller slots. */ + + if(Num64 >= 4) { + ListKeepers = List64; List64 = NULL; + NumKeepers = Num64; + goto GOT_EM; + } else if(Num64) { + List32 = QuadLinks(List64, List32); + Num32 += Num64 * 4; + Num64 = 0; + } + + if(Num32 >= 4) { + ListKeepers = List32; List32 = NULL; + NumKeepers = Num32; + goto GOT_EM; + } else if(Num32) { + List16 = QuadLinks(List32, List16); + Num16 += Num32 * 4; + Num32 = 0; + } + + if(Num16 >= 4) { + ListKeepers = List16; List16 = NULL; + NumKeepers = Num16; + goto GOT_EM; + } else if(Num16) { + List8 = QuadLinks(List16, List8); + Num8 += Num16 * 4; + Num16 = 0; + } + + if(Num8 >= 4) { + ListKeepers = List8; List8 = NULL; + NumKeepers = Num8; + goto GOT_EM; + } + +GOT_EM: + + /* Free the ones we aren't using */ + + if(List64) FreeList(List64); + if(List32) FreeList(List32); + if(List16) FreeList(List16); + if(List8) FreeList(List8); + + + /* Enlarge the slots if we can */ + + if(ListKeepers) { + CacheLinkPtr pLink = ListKeepers; + w = h = 128; + + while(pLink) { + if(pLink->w < w) w = pLink->w; + if(pLink->h < h) h = pLink->h; + pLink = pLink->next; + } + } + + *maxw = w; + *maxh = h; + *num = NumKeepers; + return ListKeepers; +} + +static void +ConvertColorToMono( + CacheLinkPtr *ColorList, + int ColorW, int ColorH, + CacheLinkPtr *MonoList, + int MonoW, int MonoH +){ + int x, y, w; + + x = (*ColorList)->x; y = (*ColorList)->y; + *ColorList = Delist(*ColorList); + + while(ColorH) { + ColorH -= MonoH; + for(w = 0; w <= (ColorW - MonoW); w += MonoW) + *MonoList = Enlist(*MonoList, x + w, y + ColorH, MonoW, MonoH); + } +} + +static void +ConvertAllPartialsTo8x8( + int *NumMono, int *NumColor, + CacheLinkPtr ListPartial, + CacheLinkPtr *ListMono, + CacheLinkPtr *ListColor, + XAAInfoRecPtr infoRec +){ +/* This guy extracts as many 8x8 slots as it can out of fragments */ + + int ColorH = infoRec->CacheHeightColor8x8Pattern; + int ColorW = infoRec->CacheWidthColor8x8Pattern; + int MonoH = infoRec->CacheHeightMono8x8Pattern; + int MonoW = infoRec->CacheWidthMono8x8Pattern; + int x, y, w, Height, Width; + Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8); + Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8); + CacheLinkPtr pLink = ListPartial; + CacheLinkPtr MonoList = *ListMono, ColorList = *ListColor; + + if(DoColor && DoMono) { + /* we assume color patterns take more space than color ones */ + if(MonoH > ColorH) ColorH = MonoH; + if(MonoW > ColorW) ColorW = MonoW; + } + + /* Break up the area into as many Color and Mono slots as we can */ + + while(pLink) { + Height = pLink->h; + Width = pLink->w; + x = pLink->x; + y = pLink->y; + + if(DoColor) { + while(Height >= ColorH) { + Height -= ColorH; + for(w = 0; w <= (Width - ColorW); w += ColorW) { + ColorList = Enlist( + ColorList, x + w, y + Height, ColorW, ColorH); + (*NumColor)++; + } + } + } + + if(DoMono && (Height >= MonoH)) { + while(Height >= MonoH) { + Height -= MonoH; + for(w = 0; w <= (Width - MonoW); w += MonoW) { + MonoList = Enlist( + MonoList, x + w, y + Height, MonoW, MonoH); + (*NumMono)++; + } + } + } + + pLink = pLink->next; + } + + + *ListMono = MonoList; + *ListColor = ColorList; + FreeList(ListPartial); +} + + +static CacheLinkPtr +ExtractOneThatFits(CacheLinkPtr *initList, int w, int h) +{ + CacheLinkPtr list = *initList; + CacheLinkPtr prev = NULL; + + while(list) { + if((list->w >= w) && (list->h >= h)) + break; + prev = list; + list = list->next; + } + + if(list) { + if(prev) + prev->next = list->next; + else + *initList = list->next; + + list->next = NULL; + } + + return list; +} + + +static CacheLinkPtr +ConvertSomePartialsTo8x8( + int *NumMono, int *NumColor, int *NumPartial, + CacheLinkPtr ListPartial, + CacheLinkPtr *ListMono, + CacheLinkPtr *ListColor, + int *maxw, int *maxh, + XAAInfoRecPtr infoRec +){ +/* This guy tries to get 4 of each type of 8x8 slot requested out of + a list of fragments all while trying to retain some big fragments + for the cache blits */ + + int ColorH = infoRec->CacheHeightColor8x8Pattern; + int ColorW = infoRec->CacheWidthColor8x8Pattern; + int MonoH = infoRec->CacheHeightMono8x8Pattern; + int MonoW = infoRec->CacheWidthMono8x8Pattern; + Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8); + Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8); + CacheLinkPtr List64, List32, List16, List8, pCur, next, ListKeepers; + CacheLinkPtr MonoList = *ListMono, ColorList = *ListColor; + int Num64, Num32, Num16, Num8, NumKeepers; + int w, h, Width, Height; + int MonosPerColor = 1; + + if(DoColor && DoMono) { + /* we assume color patterns take more space than color ones */ + if(MonoH > ColorH) ColorH = MonoH; + if(MonoW > ColorW) ColorW = MonoW; + MonosPerColor = (ColorH/MonoH) * (ColorW/MonoW); + } + + List64 = List32 = List16 = List8 = ListKeepers = MonoList = ColorList = NULL; + Num64 = Num32 = Num16 = Num8 = NumKeepers = 0; + Width = Height = 0; + + /* We sort partials by how large a square tile they can cache. + We make 8x8 patterns from the leftovers if we can. */ + + pCur = ListPartial; + while(pCur) { + next = pCur->next; + if((pCur->w >= 64) && (pCur->h >= 64)) { + pCur->next = List64; List64 = pCur; + Num64++; + } else + if((pCur->w >= 32) && (pCur->h >= 32)) { + pCur->next = List32; List32 = pCur; + Num32++; + } else + if((pCur->w >= 16) && (pCur->h >= 16)) { + pCur->next = List16; List16 = pCur; + Num16++; + } else + if((pCur->w >= 8) && (pCur->h >= 8)) { + pCur->next = List8; List8 = pCur; + Num8++; + } else { + h = pCur->h; + if(DoColor && (pCur->w >= ColorW) && (h >= ColorH)) { + while(h >= ColorH) { + h -= ColorH; + for(w = 0; w <= (pCur->w - ColorW); w += ColorW) { + ColorList = Enlist( ColorList, + pCur->x + w, pCur->y + h, ColorW, ColorH); + (*NumColor)++; + } + } + } + if(DoMono && (pCur->w >= MonoW) && (h >= MonoH)) { + while(h >= MonoH) { + h -= MonoH; + for(w = 0; w <= (pCur->w - MonoW); w += MonoW) { + MonoList = Enlist( MonoList, + pCur->x + w, pCur->y + h, MonoW, MonoH); + (*NumMono)++; + } + } + } + xfree(pCur); + } + + pCur = next; + } + + /* Try to extract at least 4 of each type of 8x8 slot that we need */ + + if(DoColor) { + CacheLinkPtr theOne; + while(*NumColor < 4) { + theOne = NULL; + if(Num8) { + if((theOne = ExtractOneThatFits(&List8, ColorW, ColorH))) + Num8--; + } + if(Num16 && !theOne) { + if((theOne = ExtractOneThatFits(&List16, ColorW, ColorH))) + Num16--; + } + if(Num32 && !theOne) { + if((theOne = ExtractOneThatFits(&List32, ColorW, ColorH))) + Num32--; + } + if(Num64 && !theOne) { + if((theOne = ExtractOneThatFits(&List64, ColorW, ColorH))) + Num64--; + } + + if(!theOne) break; + + + ConvertAllPartialsTo8x8(NumMono, NumColor, theOne, + &MonoList, &ColorList, infoRec); + + if(DoMono) { + while(*NumColor && (*NumMono < 4)) { + ConvertColorToMono(&ColorList, ColorW, ColorH, + &MonoList, MonoW, MonoH); + (*NumColor)--; *NumMono += MonosPerColor; + } + } + } + } + + if(DoMono) { + CacheLinkPtr theOne; + while(*NumMono < 4) { + theOne = NULL; + if(Num8) { + if((theOne = ExtractOneThatFits(&List8, MonoW, MonoH))) + Num8--; + } + if(Num16 && !theOne) { + if((theOne = ExtractOneThatFits(&List16, MonoW, MonoH))) + Num16--; + } + if(Num32 && !theOne) { + if((theOne = ExtractOneThatFits(&List32, MonoW, MonoH))) + Num32--; + } + if(Num64 && !theOne) { + if((theOne = ExtractOneThatFits(&List64, MonoW, MonoH))) + Num64--; + } + + if(!theOne) break; + + ConvertAllPartialsTo8x8(NumMono, NumColor, theOne, + &MonoList, &ColorList, infoRec); + } + } + + /* We save all the tiles from the largest bin that we can get + at least 4 of. If there are too few of a bigger slot, we + cut it in fourths to make smaller slots. */ + + if(Num64 >= 4) { + ListKeepers = List64; List64 = NULL; + NumKeepers = Num64; + goto GOT_EM; + } else if(Num64) { + List32 = QuadLinks(List64, List32); + Num32 += Num64 * 4; + Num64 = 0; + } + + if(Num32 >= 4) { + ListKeepers = List32; List32 = NULL; + NumKeepers = Num32; + goto GOT_EM; + } else if(Num32) { + List16 = QuadLinks(List32, List16); + Num16 += Num32 * 4; + Num32 = 0; + } + + if(Num16 >= 4) { + ListKeepers = List16; List16 = NULL; + NumKeepers = Num16; + goto GOT_EM; + } else if(Num16) { + List8 = QuadLinks(List16, List8); + Num8 += Num16 * 4; + Num16 = 0; + } + + if(Num8 >= 4) { + ListKeepers = List8; List8 = NULL; + NumKeepers = Num8; + goto GOT_EM; + } + +GOT_EM: + + /* Free the ones we aren't using */ + + if(List64) + ConvertAllPartialsTo8x8(NumMono, NumColor, List64, + &MonoList, &ColorList, infoRec); + if(List32) + ConvertAllPartialsTo8x8(NumMono, NumColor, List32, + &MonoList, &ColorList, infoRec); + if(List16) + ConvertAllPartialsTo8x8(NumMono, NumColor, List16, + &MonoList, &ColorList, infoRec); + if(List8) + ConvertAllPartialsTo8x8(NumMono, NumColor, List8, + &MonoList, &ColorList, infoRec); + + + /* Enlarge the slots if we can */ + + if(ListKeepers) { + CacheLinkPtr pLink = ListKeepers; + Width = Height = 128; + + while(pLink) { + if(pLink->w < Width) Width = pLink->w; + if(pLink->h < Height) Height = pLink->h; + pLink = pLink->next; + } + } + + *ListMono = MonoList; + *ListColor = ColorList; + *maxw = Width; + *maxh = Height; + *NumPartial = NumKeepers; + return ListKeepers; +} + + +void +XAAInitPixmapCache( + ScreenPtr pScreen, + RegionPtr areas, + pointer data +) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XAAInfoRecPtr infoRec = (XAAInfoRecPtr)data; + XAAPixmapCachePrivatePtr pCachePriv; + BoxPtr pBox = REGION_RECTS(areas); + int nBox = REGION_NUM_RECTS(areas); + int Num512, Num256, Num128, NumPartial, NumColor, NumMono; + int Target512, Target256; + CacheLinkPtr List512, List256, List128, ListPartial, ListColor, ListMono; + int x, y, w, h, ntotal, granularity, width, height, i; + int MaxPartialWidth, MaxPartialHeight; + + infoRec->MaxCacheableTileWidth = 0; + infoRec->MaxCacheableTileHeight = 0; + infoRec->MaxCacheableStippleHeight = 0; + infoRec->MaxCacheableStippleWidth = 0; + infoRec->UsingPixmapCache = FALSE; + + + if(!nBox || !pBox || !(infoRec->Flags & PIXMAP_CACHE)) + return; + + /* Allocate a persistent per-screen init flag to control messages */ + if (CacheInitIndex < 0) + CacheInitIndex = xf86AllocateScrnInfoPrivateIndex(); + + /* free the old private data if it exists */ + if(infoRec->PixmapCachePrivate) { + FreePixmapCachePrivate( + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate); + infoRec->PixmapCachePrivate = NULL; + } + + Num512 = Num256 = Num128 = NumPartial = NumMono = NumColor = 0; + List512 = List256 = List128 = ListPartial = ListMono = ListColor = NULL; + granularity = infoRec->CachePixelGranularity; + if(granularity <= 1) granularity = 0; + + /* go through the boxes and break it into as many pieces as we can fit */ + + while(nBox--) { + x = pBox->x1; + if(granularity) { + int tmp = x % granularity; + if(tmp) x += (granularity - tmp); + } + width = pBox->x2 - x; + if(width <= 0) {pBox++; continue;} + + y = pBox->y1; + height = pBox->y2 - y; + + for(h = 0; h <= (height - 512); h += 512) { + for(w = 0; w <= (width - 512); w += 512) { + List512 = Enlist(List512, x + w, y + h, 512, 512); + Num512++; + } + for(; w <= (width - 256); w += 256) { + List256 = Enlist(List256, x + w, y + h, 256, 256); + List256 = Enlist(List256, x + w, y + h + 256, 256, 256); + Num256 += 2; + } + for(; w <= (width - 128); w += 128) { + List128 = Enlist(List128, x + w, y + h, 128, 128); + List128 = Enlist(List128, x + w, y + h + 128, 128, 128); + List128 = Enlist(List128, x + w, y + h + 256, 128, 128); + List128 = Enlist(List128, x + w, y + h + 384, 128, 128); + Num128 += 4; + } + if(w < width) { + int d = width - w; + ListPartial = Enlist(ListPartial, x + w, y + h, d, 128); + ListPartial = Enlist(ListPartial, x + w, y + h + 128, d, 128); + ListPartial = Enlist(ListPartial, x + w, y + h + 256, d, 128); + ListPartial = Enlist(ListPartial, x + w, y + h + 384, d, 128); + NumPartial += 4; + } + } + for(; h <= (height - 256); h += 256) { + for(w = 0; w <= (width - 256); w += 256) { + List256 = Enlist(List256, x + w, y + h, 256, 256); + Num256++; + } + for(; w <= (width - 128); w += 128) { + List128 = Enlist(List128, x + w, y + h, 128, 128); + List128 = Enlist(List128, x + w, y + h + 128, 128, 128); + Num128 += 2; + } + if(w < width) { + int d = width - w; + ListPartial = Enlist(ListPartial, x + w, y + h, d, 128); + ListPartial = Enlist(ListPartial, x + w, y + h + 128, d, 128); + NumPartial += 2; + } + } + for(; h <= (height - 128); h += 128) { + for(w = 0; w <= (width - 128); w += 128) { + List128 = Enlist(List128, x + w, y + h, 128, 128); + Num128++; + } + if(w < width) { + ListPartial = Enlist( + ListPartial, x + w, y + h, width - w, 128); + NumPartial++; + } + } + if(h < height) { + int d = height - h; + for(w = 0; w <= (width - 128); w += 128) { + ListPartial = Enlist(ListPartial, x + w, y + h, 128, d); + NumPartial++; + } + if(w < width) { + ListPartial = Enlist(ListPartial, x + w, y + h, width - w, d); + NumPartial++; + } + } + pBox++; + } + + +/* + by this point we've carved the space into as many 512x512, 256x256 + and 128x128 blocks as we could fit. We will then break larger + blocks into smaller ones if we need to. The rules are as follows: + + 512x512 - + 1) Don't take up more than half the memory. + 2) Don't bother if you can't get at least four. + 3) Don't make more than MAX_512. + 4) Don't have any of there are no 256x256s. + + 256x256 - + 1) Don't take up more than a quarter of the memory enless there + aren't any 512x512s. Then we can take up to half. + 2) Don't bother if you can't get at least four. + 3) Don't make more than MAX_256. + + 128x128 - + 1) Don't make more than MAX_128. + + We don't bother with the partial blocks unless we can use them + for 8x8 pattern fills or we are short on larger blocks. + +*/ + + ntotal = Num128 + (Num256<<2) + (Num512<<4); + + Target512 = ntotal >> 5; + if(Target512 < 4) Target512 = 0; + if(!Target512) Target256 = ntotal >> 3; + else Target256 = ntotal >> 4; + if(Target256 < 4) Target256 = 0; + + if(Num512 && Num256 < 4) { + while(Num512 && Num256 < Target256) { + SubdivideList(&List512, &List256); + Num256 += 4; Num512--; + } + } + + if(!Num512) { /* no room */ + } else if((Num512 < 4) || (!Target512)) { + while(Num512) { + SubdivideList(&List512, &List256); + Num256 += 4; Num512--; + } + } else if((Num512 > MAX_512) || (Num512 > Target512)){ + while(Num512 > MAX_512) { + SubdivideList(&List512, &List256); + Num256 += 4; Num512--; + } + while(Num512 > Target512) { + if(Num256 < MAX_256) { + SubdivideList(&List512, &List256); + Num256 += 4; Num512--; + } else break; + } + } + + if(!Num256) { /* no room */ + } else if((Num256 < 4) || (!Target256)) { + while(Num256) { + SubdivideList(&List256, &List128); + Num128 += 4; Num256--; + } + } else if((Num256 > MAX_256) || (Num256 > Target256)) { + while(Num256 > MAX_256) { + SubdivideList(&List256, &List128); + Num128 += 4; Num256--; + } + while(Num256 > Target256) { + if(Num128 < MAX_128) { + SubdivideList(&List256, &List128); + Num128 += 4; Num256--; + } else break; + } + } + + if(Num128 && ((Num128 < 4) || (Num128 > MAX_128))) { + CacheLinkPtr next; + int max = (Num128 > MAX_128) ? MAX_128 : 0; + + /* + * Note: next is set in this way to work around a code generation + * bug in gcc 2.7.2.3. + */ + next = List128->next; + while(Num128 > max) { + List128->next = ListPartial; + ListPartial = List128; + if((List128 = next)) + next = List128->next; + NumPartial++; Num128--; + } + } + + MaxPartialHeight = MaxPartialWidth = 0; + + /* at this point we have as many 512x512 and 256x256 slots as we + want but may have an excess of 128x128 slots. We still need + to find out if we need 8x8 slots. We take these from the + partials if we have them. Otherwise, we break some 128x128's */ + + if(!(infoRec->PixmapCacheFlags & (CACHE_MONO_8x8 | CACHE_COLOR_8x8))) { + if(NumPartial) { + if(Num128) { /* don't bother with partials */ + FreeList(ListPartial); + NumPartial = 0; ListPartial = NULL; + } else { + /* We have no big slots. Weed out the unusable partials */ + ListPartial = ThinOutPartials(ListPartial, &NumPartial, + &MaxPartialWidth, &MaxPartialHeight); + } + } + } else { + int MonosPerColor = 1; + int ColorH = infoRec->CacheHeightColor8x8Pattern; + int ColorW = infoRec->CacheWidthColor8x8Pattern; + int MonoH = infoRec->CacheHeightMono8x8Pattern; + int MonoW = infoRec->CacheWidthMono8x8Pattern; + Bool DoColor = (infoRec->PixmapCacheFlags & CACHE_COLOR_8x8); + Bool DoMono = (infoRec->PixmapCacheFlags & CACHE_MONO_8x8); + + if(DoColor) infoRec->CanDoColor8x8 = FALSE; + if(DoMono) infoRec->CanDoMono8x8 = FALSE; + + if(DoColor && DoMono) { + /* we assume color patterns take more space than color ones */ + if(MonoH > ColorH) ColorH = MonoH; + if(MonoW > ColorW) ColorW = MonoW; + MonosPerColor = (ColorH/MonoH) * (ColorW/MonoW); + } + + if(Num128) { + if(NumPartial) { /* use all for 8x8 slots */ + ConvertAllPartialsTo8x8(&NumMono, &NumColor, + ListPartial, &ListMono, &ListColor, infoRec); + NumPartial = 0; ListPartial = NULL; + } + + /* Get some 8x8 slots from the 128 slots */ + while((Num128 > 4) && + ((NumMono < MAX_MONO) && (NumColor < MAX_COLOR))) { + CacheLinkPtr tmp = NULL; + + tmp = Enlist(tmp, List128->x, List128->y, + List128->w, List128->h); + List128 = Delist(List128); + Num128--; + + ConvertAllPartialsTo8x8(&NumMono, &NumColor, + tmp, &ListMono, &ListColor, infoRec); + } + } else if(NumPartial) { + /* We have share partials between 8x8 slots and tiles. */ + ListPartial = ConvertSomePartialsTo8x8(&NumMono, &NumColor, + &NumPartial, ListPartial, &ListMono, &ListColor, + &MaxPartialWidth, &MaxPartialHeight, infoRec); + } + + + if(DoMono && DoColor) { + if(NumColor && ((NumColor > MAX_COLOR) || (NumColor < 4))) { + int max = (NumColor > MAX_COLOR) ? MAX_COLOR : 0; + + while(NumColor > max) { + ConvertColorToMono(&ListColor, ColorW, ColorH, + &ListMono, MonoW, MonoH); + NumColor--; NumMono += MonosPerColor; + } + } + + /* favor Mono slots over Color ones */ + while((NumColor > 4) && (NumMono < MAX_MONO)) { + ConvertColorToMono(&ListColor, ColorW, ColorH, + &ListMono, MonoW, MonoH); + NumColor--; NumMono += MonosPerColor; + } + } + + if(NumMono && ((NumMono > MAX_MONO) || (NumMono < 4))) { + int max = (NumMono > MAX_MONO) ? MAX_MONO : 0; + + while(NumMono > max) { + ListMono = Delist(ListMono); + NumMono--; + } + } + if(NumColor && ((NumColor > MAX_COLOR) || (NumColor < 4))) { + int max = (NumColor > MAX_COLOR) ? MAX_COLOR : 0; + + while(NumColor > max) { + ListColor = Delist(ListColor); + NumColor--; + } + } + } + + + pCachePriv = xcalloc(1,sizeof(XAAPixmapCachePrivate)); + if(!pCachePriv) { + if(Num512) FreeList(List512); + if(Num256) FreeList(List256); + if(Num128) FreeList(List128); + if(NumPartial) FreeList(ListPartial); + if(NumColor) FreeList(ListColor); + if(NumMono) FreeList(ListMono); + return; + } + + infoRec->PixmapCachePrivate = (char*)pCachePriv; + + if(Num512) { + pCachePriv->Info512 = xcalloc(Num512,sizeof(XAACacheInfoRec)); + if(!pCachePriv->Info512) Num512 = 0; + if(Num512) TransferList(List512, pCachePriv->Info512, Num512); + FreeList(List512); + pCachePriv->Num512x512 = Num512; + } + if(Num256) { + pCachePriv->Info256 = xcalloc(Num256, sizeof(XAACacheInfoRec)); + if(!pCachePriv->Info256) Num256 = 0; + if(Num256) TransferList(List256, pCachePriv->Info256, Num256); + FreeList(List256); + pCachePriv->Num256x256 = Num256; + } + if(Num128) { + pCachePriv->Info128 = xcalloc(Num128, sizeof(XAACacheInfoRec)); + if(!pCachePriv->Info128) Num128 = 0; + if(Num128) TransferList(List128, pCachePriv->Info128, Num128); + FreeList(List128); + pCachePriv->Num128x128 = Num128; + } + + if(NumPartial) { + pCachePriv->InfoPartial = xcalloc(NumPartial, sizeof(XAACacheInfoRec)); + if(!pCachePriv->InfoPartial) NumPartial = 0; + if(NumPartial) + TransferList(ListPartial, pCachePriv->InfoPartial, NumPartial); + FreeList(ListPartial); + pCachePriv->NumPartial = NumPartial; + } + + if(NumColor) { + pCachePriv->InfoColor = xcalloc(NumColor, sizeof(XAACacheInfoRec)); + if(!pCachePriv->InfoColor) NumColor = 0; + if(NumColor) TransferList(ListColor, pCachePriv->InfoColor, NumColor); + FreeList(ListColor); + pCachePriv->NumColor = NumColor; + } + + if(NumMono) { + pCachePriv->InfoMono = xcalloc(NumMono, sizeof(XAACacheInfoRec)); + if(!pCachePriv->InfoMono) NumMono = 0; + if(NumMono) TransferList(ListMono, pCachePriv->InfoMono, NumMono); + FreeList(ListMono); + pCachePriv->NumMono = NumMono; + } + + + if(NumPartial) { + infoRec->MaxCacheableTileWidth = MaxPartialWidth; + infoRec->MaxCacheableTileHeight = MaxPartialHeight; + } + if(Num128) + infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 128; + if(Num256) + infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 256; + if(Num512) + infoRec->MaxCacheableTileWidth = infoRec->MaxCacheableTileHeight = 512; + + + infoRec->MaxCacheableStippleHeight = infoRec->MaxCacheableTileHeight; + infoRec->MaxCacheableStippleWidth = + infoRec->MaxCacheableTileWidth * pScrn->bitsPerPixel; + if(infoRec->ScreenToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) + infoRec->MaxCacheableStippleWidth /= 3; + + if(NumMono) { + if(!(infoRec->Mono8x8PatternFillFlags & + (HARDWARE_PATTERN_PROGRAMMED_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_BITS))) { + int numPerLine = + infoRec->CacheWidthMono8x8Pattern/infoRec->MonoPatternPitch; + + for(i = 0; i < 64; i++) { + pCachePriv->MonoOffsets[i].y = i/numPerLine; + pCachePriv->MonoOffsets[i].x = (i % numPerLine) * + infoRec->MonoPatternPitch; + } + } + infoRec->CanDoMono8x8 = TRUE; + } + if(NumColor) { + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { + + for(i = 0; i < 64; i++) { + pCachePriv->ColorOffsets[i].y = i & 0x07; + pCachePriv->ColorOffsets[i].x = i & ~0x07; + } + } + infoRec->CanDoColor8x8 = TRUE; + } + + if(!CACHEINIT(pScrn)) { + xf86ErrorF("\tSetting up tile and stipple cache:\n"); + if(NumPartial) + xf86ErrorF("\t\t%i %ix%i slots\n", + NumPartial, MaxPartialWidth, MaxPartialHeight); + if(Num128) xf86ErrorF("\t\t%i 128x128 slots\n", Num128); + if(Num256) xf86ErrorF("\t\t%i 256x256 slots\n", Num256); + if(Num512) xf86ErrorF("\t\t%i 512x512 slots\n", Num512); + if(NumColor) xf86ErrorF("\t\t%i 8x8 color pattern slots\n", NumColor); + if(NumMono) xf86ErrorF("\t\t%i 8x8 color expansion slots\n", NumMono); + } + + if(!(NumPartial | Num128 | Num256 | Num512 | NumColor | NumMono)) { + if(!CACHEINIT(pScrn)) + xf86ErrorF("\t\tNot enough video memory for pixmap cache\n"); + } else infoRec->UsingPixmapCache = TRUE; + + CACHEINIT(pScrn) = 1; +} + +#if X_BYTE_ORDER == X_BIG_ENDIAN +static CARD32 StippleMasks[4] = { + 0x80808080, + 0xC0C0C0C0, + 0x00000000, + 0xF0F0F0F0 +}; +#else +static CARD32 StippleMasks[4] = { + 0x01010101, + 0x03030303, + 0x00000000, + 0x0F0F0F0F +}; +#endif + +Bool +XAACheckStippleReducibility(PixmapPtr pPixmap) +{ + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap); + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE(&pPixmap->drawable); + CARD32 *IntPtr = (CARD32*)pPixmap->devPrivate.ptr; + int w = pPixmap->drawable.width; + int h = pPixmap->drawable.height; + int i; + CARD32 bits[8]; + CARD32 mask = SHIFT_R(0xFFFFFFFF,24); + + pPriv->flags |= REDUCIBILITY_CHECKED | REDUCIBLE_TO_2_COLOR; + pPriv->flags &= ~REDUCIBLE_TO_8x8; + + if((w > 32) || (h > 32) || (w & (w - 1)) || (h & (h - 1))) + return FALSE; + + i = (h > 8) ? 8 : h; + + switch(w) { + case 32: + while(i--) { + bits[i] = IntPtr[i] & mask; + if( (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask, 8)), 8)) || + (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask,16)),16)) || + (bits[i] != SHIFT_R((IntPtr[i] & SHIFT_L(mask,24)),24))) + return FALSE; + } + break; + case 16: + while(i--) { + bits[i] = IntPtr[i] & mask; + if(bits[i] != ((IntPtr[i] & SHIFT_R(SHIFT_L(mask,8),8)))) + return FALSE; + } + break; + default: + while(i--) + bits[i] = IntPtr[i] & mask; + break; + } + + switch(h) { + case 32: + if( (IntPtr[8] != IntPtr[16]) || (IntPtr[9] != IntPtr[17]) || + (IntPtr[10] != IntPtr[18]) || (IntPtr[11] != IntPtr[19]) || + (IntPtr[12] != IntPtr[20]) || (IntPtr[13] != IntPtr[21]) || + (IntPtr[14] != IntPtr[22]) || (IntPtr[15] != IntPtr[23]) || + (IntPtr[16] != IntPtr[24]) || (IntPtr[17] != IntPtr[25]) || + (IntPtr[18] != IntPtr[26]) || (IntPtr[19] != IntPtr[27]) || + (IntPtr[20] != IntPtr[28]) || (IntPtr[21] != IntPtr[29]) || + (IntPtr[22] != IntPtr[30]) || (IntPtr[23] != IntPtr[31])) + return FALSE; + /* fall through */ + case 16: + if( (IntPtr[0] != IntPtr[8]) || (IntPtr[1] != IntPtr[9]) || + (IntPtr[2] != IntPtr[10]) || (IntPtr[3] != IntPtr[11]) || + (IntPtr[4] != IntPtr[12]) || (IntPtr[5] != IntPtr[13]) || + (IntPtr[6] != IntPtr[14]) || (IntPtr[7] != IntPtr[15])) + return FALSE; + case 8: break; + case 1: bits[1] = bits[0]; + case 2: bits[2] = bits[0]; bits[3] = bits[1]; + case 4: bits[4] = bits[0]; bits[5] = bits[1]; + bits[6] = bits[2]; bits[7] = bits[3]; + break; + } + + pPriv->flags |= REDUCIBLE_TO_8x8; + + pPriv->pattern0 = bits[0] | SHIFT_L(bits[1],8) | SHIFT_L(bits[2],16) | SHIFT_L(bits[3],24); + pPriv->pattern1 = bits[4] | SHIFT_L(bits[5],8) | SHIFT_L(bits[6],16) | SHIFT_L(bits[7],24); + + if(w < 8) { + pPriv->pattern0 &= StippleMasks[w - 1]; + pPriv->pattern1 &= StippleMasks[w - 1]; + + switch(w) { + case 1: pPriv->pattern0 |= SHIFT_L(pPriv->pattern0,1); + pPriv->pattern1 |= SHIFT_L(pPriv->pattern1,1); + case 2: pPriv->pattern0 |= SHIFT_L(pPriv->pattern0,2); + pPriv->pattern1 |= SHIFT_L(pPriv->pattern1,2); + case 4: pPriv->pattern0 |= SHIFT_L(pPriv->pattern0,4); + pPriv->pattern1 |= SHIFT_L(pPriv->pattern1,4); + } + } + + if(infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) { + pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0); + pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1); + } + + + return TRUE; +} + + +Bool +XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono) +{ + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap); + CARD32 *IntPtr; + int w = pPixmap->drawable.width; + int h = pPixmap->drawable.height; + int pitch = pPixmap->devKind >> 2; + int dwords, i, j; + + pPriv->flags |= REDUCIBILITY_CHECKED; + pPriv->flags &= ~(REDUCIBILITY_CHECKED | REDUCIBLE_TO_2_COLOR); + + if((w > 32) || (h > 32) || (w & (w - 1)) || (h & (h - 1))) + return FALSE; + + dwords = ((w * pPixmap->drawable.bitsPerPixel) + 31) >> 5; + i = (h > 8) ? 8 : h; + + + if(w > 8) { + IntPtr = (CARD32*)pPixmap->devPrivate.ptr; + switch(pPixmap->drawable.bitsPerPixel) { + case 8: + while(i--) { + for(j = 2; j < dwords; j++) + if(IntPtr[j] != IntPtr[j & 0x01]) + return FALSE; + IntPtr += pitch; + } + break; + case 16: + while(i--) { + for(j = 4; j < dwords; j++) + if(IntPtr[j] != IntPtr[j & 0x03]) + return FALSE; + IntPtr += pitch; + } + break; + case 24: + while(i--) { + for(j = 6; j < dwords; j++) + if(IntPtr[j] != IntPtr[j % 6]) + return FALSE; + IntPtr += pitch; + } + break; + case 32: + while(i--) { + for(j = 8; j < dwords; j++) + if(IntPtr[j] != IntPtr[j & 0x07]) + return FALSE; + IntPtr += pitch; + } + break; + default: return FALSE; + } + + } + + + if(h == 32) { + CARD32 *IntPtr2, *IntPtr3, *IntPtr4; + i = 8; + IntPtr = (CARD32*)pPixmap->devPrivate.ptr; + IntPtr2 = IntPtr + (pitch << 3); + IntPtr3 = IntPtr2 + (pitch << 3); + IntPtr4 = IntPtr3 + (pitch << 3); + while(i--) { + for(j = 0; j < dwords; j++) + if((IntPtr[j] != IntPtr2[j]) || (IntPtr[j] != IntPtr3[j]) || + (IntPtr[j] != IntPtr4[j])) + return FALSE; + IntPtr += pitch; + IntPtr2 += pitch; + IntPtr3 += pitch; + IntPtr4 += pitch; + } + } else if (h == 16) { + CARD32 *IntPtr2; + i = 8; + IntPtr = (CARD32*)pPixmap->devPrivate.ptr; + IntPtr2 = IntPtr + (pitch << 3); + while(i--) { + for(j = 0; j < dwords; j++) + if(IntPtr[j] != IntPtr2[j]) + return FALSE; + IntPtr += pitch; + IntPtr2 += pitch; + } + } + + pPriv->flags |= REDUCIBLE_TO_8x8; + + if(checkMono) { + XAAInfoRecPtr infoRec = + GET_XAAINFORECPTR_FROM_DRAWABLE(&pPixmap->drawable); + unsigned char bits[8]; + int fg, bg = -1, x, y; + + i = (h > 8) ? 8 : h; + j = (w > 8) ? 8 : w; + + if(pPixmap->drawable.bitsPerPixel == 8) { + unsigned char *srcp = pPixmap->devPrivate.ptr; + fg = srcp[0]; + pitch = pPixmap->devKind; + for(y = 0; y < i; y++) { + bits[y] = 0; + for(x = 0; x < j; x++) { + if(srcp[x] != fg) { + if(bg == -1) bg = srcp[x]; + else if(bg != srcp[x]) return TRUE; + } else bits[y] |= 1 << x; + } + srcp += pitch; + } + } else if(pPixmap->drawable.bitsPerPixel == 16) { + unsigned short *srcp = (unsigned short*)pPixmap->devPrivate.ptr; + fg = srcp[0]; + pitch = pPixmap->devKind >> 1; + for(y = 0; y < i; y++) { + bits[y] = 0; + for(x = 0; x < j; x++) { + if(srcp[x] != fg) { + if(bg == -1) bg = srcp[x]; + else if(bg != srcp[x]) return TRUE; + } else bits[y] |= 1 << x; + } + srcp += pitch; + } + } else if(pPixmap->drawable.bitsPerPixel == 24) { + CARD32 val; + unsigned char *srcp = pPixmap->devPrivate.ptr; + fg = *((CARD32*)srcp) & 0x00FFFFFF; + pitch = pPixmap->devKind; + j *= 3; + for(y = 0; y < i; y++) { + bits[y] = 0; + for(x = 0; x < j; x+=3) { + val = *((CARD32*)(srcp+x)) & 0x00FFFFFF; + if(val != fg) { + if(bg == -1) bg = val; + else if(bg != val) + return TRUE; + } else bits[y] |= 1 << (x/3); + } + srcp += pitch; + } + } else if(pPixmap->drawable.bitsPerPixel == 32) { + IntPtr = (CARD32*)pPixmap->devPrivate.ptr; + fg = IntPtr[0]; + for(y = 0; y < i; y++) { + bits[y] = 0; + for(x = 0; x < j; x++) { + if(IntPtr[x] != fg) { + if(bg == -1) bg = IntPtr[x]; + else if(bg != IntPtr[x]) return TRUE; + } else bits[y] |= 1 << x; + } + IntPtr += pitch; + } + } else return TRUE; + + pPriv->fg = fg; + if(bg == -1) pPriv->bg = fg; + else pPriv->bg = bg; + + if(h < 8) { + switch(h) { + case 1: bits[1] = bits[0]; + case 2: bits[2] = bits[0]; bits[3] = bits[1]; + case 4: bits[4] = bits[0]; bits[5] = bits[1]; + bits[6] = bits[2]; bits[7] = bits[3]; + break; + } + } + + pPriv->pattern0 = + bits[0] | (bits[1]<<8) | (bits[2]<<16) | (bits[3]<<24); + pPriv->pattern1 = + bits[4] | (bits[5]<<8) | (bits[6]<<16) | (bits[7]<<24); + + if(w < 8) { + switch(w) { + case 1: pPriv->pattern0 |= (pPriv->pattern0 << 1); + pPriv->pattern1 |= (pPriv->pattern1 << 1); + case 2: pPriv->pattern0 |= (pPriv->pattern0 << 2); + pPriv->pattern1 |= (pPriv->pattern1 << 2); + case 4: pPriv->pattern0 |= (pPriv->pattern0 << 4); + pPriv->pattern1 |= (pPriv->pattern1 << 4); + } + } + pPriv->flags |= REDUCIBLE_TO_2_COLOR; + + if(infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) { + pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0); + pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1); + } + + } + + return TRUE; +} + + +void XAATileCache( + ScrnInfoPtr pScrn, + XAACacheInfoPtr pCache, + int w, int h +) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, ~0, -1); + + while((w << 1) <= pCache->w) { + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y, + pCache->x + w, pCache->y, w, h); + w <<= 1; + } + if(w != pCache->w) { + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y, + pCache->x + w, pCache->y, pCache->w - w, h); + w = pCache->w; + } + + while((h << 1) <= pCache->h) { + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y, + pCache->x, pCache->y + h, w, h); + h <<= 1; + } + if(h != pCache->h) { + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pCache->x, pCache->y, + pCache->x, pCache->y + h, w, pCache->h - h); + } + SET_SYNC_FLAG(infoRec); +} + +XAACacheInfoPtr +XAACacheTile(ScrnInfoPtr pScrn, PixmapPtr pPix) +{ + int w = pPix->drawable.width; + int h = pPix->drawable.height; + int size = max(w, h); + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + XAACacheInfoPtr pCache, cacheRoot = NULL; + int i, max = 0; + int *current; + + if(size <= 128) { + if(pCachePriv->Info128) { + cacheRoot = pCachePriv->Info128; + max = pCachePriv->Num128x128; + current = &pCachePriv->Current128; + } else { + cacheRoot = pCachePriv->InfoPartial; + max = pCachePriv->NumPartial; + current = &pCachePriv->CurrentPartial; + } + } else if(size <= 256) { + cacheRoot = pCachePriv->Info256; + max = pCachePriv->Num256x256; + current = &pCachePriv->Current256; + } else if(size <= 512) { + cacheRoot = pCachePriv->Info512; + max = pCachePriv->Num512x512; + current = &pCachePriv->Current512; + } else { /* something's wrong */ + ErrorF("Something's wrong in XAACacheTile()\n"); + return pCachePriv->Info128; + } + + pCache = cacheRoot; + + /* lets look for it */ + for(i = 0; i < max; i++, pCache++) { + if(pCache->serialNumber == pPix->drawable.serialNumber) { + pCache->trans_color = -1; + return pCache; + } + } + + pCache = &cacheRoot[(*current)++]; + if(*current >= max) *current = 0; + + pCache->serialNumber = pPix->drawable.serialNumber; + pCache->trans_color = pCache->bg = pCache->fg = -1; + pCache->orig_w = w; pCache->orig_h = h; + (*infoRec->WritePixmapToCache)( + pScrn, pCache->x, pCache->y, w, h, pPix->devPrivate.ptr, + pPix->devKind, pPix->drawable.bitsPerPixel, pPix->drawable.depth); + if(!(infoRec->PixmapCacheFlags & DO_NOT_TILE_COLOR_DATA) && + ((w != pCache->w) || (h != pCache->h))) + XAATileCache(pScrn, pCache, w, h); + + return pCache; +} + +XAACacheInfoPtr +XAACacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix) +{ + int w = pPix->drawable.width; + int h = pPix->drawable.height; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + XAACacheInfoPtr pCache, cacheRoot = NULL; + int i, max = 0, funcNo, pad, dwords, bpp = pScrn->bitsPerPixel; + int *current; + StippleScanlineProcPtr StippleFunc; + unsigned char *data, *srcPtr, *dstPtr; + + if((h <= 128) && (w <= 128 * bpp)) { + if(pCachePriv->Info128) { + cacheRoot = pCachePriv->Info128; + max = pCachePriv->Num128x128; + current = &pCachePriv->Current128; + } else { + cacheRoot = pCachePriv->InfoPartial; + max = pCachePriv->NumPartial; + current = &pCachePriv->CurrentPartial; + } + } else if((h <= 256) && (w <= 256 * bpp)){ + cacheRoot = pCachePriv->Info256; + max = pCachePriv->Num256x256; + current = &pCachePriv->Current256; + } else if((h <= 512) && (w <= 526 * bpp)){ + cacheRoot = pCachePriv->Info512; + max = pCachePriv->Num512x512; + current = &pCachePriv->Current512; + } else { /* something's wrong */ + ErrorF("Something's wrong in XAACacheMonoStipple()\n"); + return pCachePriv->Info128; + } + + pCache = cacheRoot; + + /* lets look for it */ + for(i = 0; i < max; i++, pCache++) { + if((pCache->serialNumber == pPix->drawable.serialNumber) && + (pCache->fg == -1) && (pCache->bg == -1)) { + pCache->trans_color = -1; + return pCache; + } + } + + pCache = &cacheRoot[(*current)++]; + if(*current >= max) *current = 0; + + pCache->serialNumber = pPix->drawable.serialNumber; + pCache->trans_color = pCache->bg = pCache->fg = -1; + pCache->orig_w = w; pCache->orig_h = h; + + if(w <= 32) { + if(w & (w - 1)) funcNo = 1; + else funcNo = 0; + } else funcNo = 2; + + pad = BitmapBytePad(pCache->w * bpp); + dwords = pad >> 2; + dstPtr = data = (unsigned char*)xalloc(pad * pCache->h); + srcPtr = (unsigned char*)pPix->devPrivate.ptr; + + if(infoRec->ScreenToScreenColorExpandFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) + StippleFunc = XAAStippleScanlineFuncMSBFirst[funcNo]; + else + StippleFunc = XAAStippleScanlineFuncLSBFirst[funcNo]; + + /* don't bother generating more than we'll ever use */ + max = ((pScrn->displayWidth + w - 1) + 31) >> 5; + if(dwords > max) + dwords = max; + + for(i = 0; i < h; i++) { + (*StippleFunc)((CARD32*)dstPtr, (CARD32*)srcPtr, 0, w, dwords); + srcPtr += pPix->devKind; + dstPtr += pad; + } + + while((h<<1) <= pCache->h) { + memcpy(data + (pad * h), data, pad * h); + h <<= 1; + } + + if(h < pCache->h) + memcpy(data + (pad * h), data, pad * (pCache->h - h)); + + (*infoRec->WritePixmapToCache)( + pScrn, pCache->x, pCache->y, pCache->w, pCache->h, data, + pad, bpp, pScrn->depth); + + xfree(data); + + return pCache; +} + +XAACacheInfoPtr +XAACachePlanarMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix) +{ + int w = pPix->drawable.width; + int h = pPix->drawable.height; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + XAACacheInfoPtr pCache, cacheRoot = NULL; + int i, max = 0; + int *current; + + if((h <= 128) && (w <= 128)) { + if(pCachePriv->Info128) { + cacheRoot = pCachePriv->Info128; + max = pCachePriv->Num128x128; + current = &pCachePriv->Current128; + } else { + cacheRoot = pCachePriv->InfoPartial; + max = pCachePriv->NumPartial; + current = &pCachePriv->CurrentPartial; + } + } else if((h <= 256) && (w <= 256)){ + cacheRoot = pCachePriv->Info256; + max = pCachePriv->Num256x256; + current = &pCachePriv->Current256; + } else if((h <= 512) && (w <= 526)){ + cacheRoot = pCachePriv->Info512; + max = pCachePriv->Num512x512; + current = &pCachePriv->Current512; + } else { /* something's wrong */ + ErrorF("Something's wrong in XAACachePlanarMonoStipple()\n"); + return pCachePriv->Info128; + } + + pCache = cacheRoot; + + /* lets look for it */ + for(i = 0; i < max; i++, pCache++) { + if((pCache->serialNumber == pPix->drawable.serialNumber) && + (pCache->fg == -1) && (pCache->bg == -1)) { + pCache->trans_color = -1; + return pCache; + } + } + + pCache = &cacheRoot[(*current)++]; + if(*current >= max) *current = 0; + + pCache->serialNumber = pPix->drawable.serialNumber; + pCache->trans_color = pCache->bg = pCache->fg = -1; + pCache->orig_w = w; pCache->orig_h = h; + + /* Plane 0 holds the stipple. Plane 1 holds the inverted stipple */ + (*infoRec->WriteBitmapToCache)(pScrn, pCache->x, pCache->y, + pPix->drawable.width, pPix->drawable.height, pPix->devPrivate.ptr, + pPix->devKind, 1, 2); + if(!(infoRec->PixmapCacheFlags & DO_NOT_TILE_MONO_DATA) && + ((w != pCache->w) || (h != pCache->h))) + XAATileCache(pScrn, pCache, w, h); + + return pCache; +} + +XAACachePlanarMonoStippleProc +XAAGetCachePlanarMonoStipple(void) { return XAACachePlanarMonoStipple; } + +XAACacheInfoPtr +XAACacheStipple(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg) +{ + int w = pPix->drawable.width; + int h = pPix->drawable.height; + int size = max(w, h); + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + XAACacheInfoPtr pCache, cacheRoot = NULL; + int i, max = 0; + int *current; + + if(size <= 128) { + if(pCachePriv->Info128) { + cacheRoot = pCachePriv->Info128; + max = pCachePriv->Num128x128; + current = &pCachePriv->Current128; + } else { + cacheRoot = pCachePriv->InfoPartial; + max = pCachePriv->NumPartial; + current = &pCachePriv->CurrentPartial; + } + } else if(size <= 256) { + cacheRoot = pCachePriv->Info256; + max = pCachePriv->Num256x256; + current = &pCachePriv->Current256; + } else if(size <= 512) { + cacheRoot = pCachePriv->Info512; + max = pCachePriv->Num512x512; + current = &pCachePriv->Current512; + } else { /* something's wrong */ + ErrorF("Something's wrong in XAACacheStipple()\n"); + return pCachePriv->Info128; + } + + pCache = cacheRoot; + /* lets look for it */ + if(bg == -1) + for(i = 0; i < max; i++, pCache++) { + if((pCache->serialNumber == pPix->drawable.serialNumber) && + (fg == pCache->fg) && (pCache->fg != pCache->bg)) { + pCache->trans_color = pCache->bg; + return pCache; + } + } + else + for(i = 0; i < max; i++, pCache++) { + if((pCache->serialNumber == pPix->drawable.serialNumber) && + (fg == pCache->fg) && (bg == pCache->bg)) { + pCache->trans_color = -1; + return pCache; + } + } + + pCache = &cacheRoot[(*current)++]; + if(*current >= max) *current = 0; + + pCache->serialNumber = pPix->drawable.serialNumber; + pCache->fg = fg; + if(bg == -1) + pCache->trans_color = bg = fg ^ 1; + else + pCache->trans_color = -1; + pCache->bg = bg; + + pCache->orig_w = w; pCache->orig_h = h; + (*infoRec->WriteBitmapToCache)(pScrn, pCache->x, pCache->y, + pPix->drawable.width, pPix->drawable.height, pPix->devPrivate.ptr, + pPix->devKind, fg, bg); + if(!(infoRec->PixmapCacheFlags & DO_NOT_TILE_COLOR_DATA) && + ((w != pCache->w) || (h != pCache->h))) + XAATileCache(pScrn, pCache, w, h); + + return pCache; +} + + + +XAACacheInfoPtr +XAACacheMono8x8Pattern(ScrnInfoPtr pScrn, int pat0, int pat1) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + XAACacheInfoPtr pCache = pCachePriv->InfoMono; + int i; + + for(i = 0; i < pCachePriv->NumMono; i++, pCache++) { + if(pCache->serialNumber && + (pCache->pat0 == pat0) && (pCache->pat1 == pat1)) + return pCache; + } + + /* OK, let's cache it */ + pCache = &pCachePriv->InfoMono[pCachePriv->CurrentMono++]; + if(pCachePriv->CurrentMono >= pCachePriv->NumMono) + pCachePriv->CurrentMono = 0; + + pCache->serialNumber = 1; /* we don't care since we do lookups by pattern */ + pCache->pat0 = pat0; + pCache->pat1 = pat1; + + (*infoRec->WriteMono8x8PatternToCache)(pScrn, pCache); + + return pCache; +} + + + +XAACacheInfoPtr +XAACacheColor8x8Pattern(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + XAACacheInfoPtr pCache = pCachePriv->InfoColor; + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + int i; + + if(!(pixPriv->flags & REDUCIBLE_TO_2_COLOR)) { + for(i = 0; i < pCachePriv->NumColor; i++, pCache++) { + if(pCache->serialNumber == pPix->drawable.serialNumber) { + pCache->trans_color = -1; + return pCache; + } + } + pCache = &pCachePriv->InfoColor[pCachePriv->CurrentColor++]; + if(pCachePriv->CurrentColor >= pCachePriv->NumColor) + pCachePriv->CurrentColor = 0; + + pCache->serialNumber = pPix->drawable.serialNumber; + pCache->trans_color = pCache->fg = pCache->bg = -1; + } else { + int pat0 = pixPriv->pattern0; + int pat1 = pixPriv->pattern1; + + if(fg == -1) { /* it's a tile */ + fg = pixPriv->fg; bg = pixPriv->bg; + } + + if(bg == -1) { /* stipple */ + for(i = 0; i < pCachePriv->NumColor; i++, pCache++) { + if(pCache->serialNumber && + (pCache->pat0 == pat0) && (pCache->pat1 == pat1) && + (pCache->fg == fg) && (pCache->bg != fg)) { + pCache->trans_color = pCache->bg; + return pCache; + } + } + } else { /* opaque stipple */ + for(i = 0; i < pCachePriv->NumColor; i++, pCache++) { + if(pCache->serialNumber && + (pCache->pat0 == pat0) && (pCache->pat1 == pat1) && + (pCache->fg == fg) && (pCache->bg == bg)) { + pCache->trans_color = -1; + return pCache; + } + } + } + pCache = &pCachePriv->InfoColor[pCachePriv->CurrentColor++]; + if(pCachePriv->CurrentColor >= pCachePriv->NumColor) + pCachePriv->CurrentColor = 0; + + if(bg == -1) + pCache->trans_color = bg = fg ^ 1; + else + pCache->trans_color = -1; + + pCache->pat0 = pat0; pCache->pat1 = pat1; + pCache->fg = fg; pCache->bg = bg; + pCache->serialNumber = 1; + } + + (*infoRec->WriteColor8x8PatternToCache)(pScrn, pPix, pCache); + + return pCache; +} + + +void +XAAWriteBitmapToCache( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int fg, int bg +) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->WriteBitmap)(pScrn, x, y, w, h, src, srcwidth, + 0, fg, bg, GXcopy, ~0); +} + +void +XAAWriteBitmapToCacheLinear( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int fg, int bg +){ + ScreenPtr pScreen = pScrn->pScreen; + PixmapPtr pScreenPix, pDstPix; + XID gcvals[2]; + GCPtr pGC; + + pScreenPix = (*pScreen->GetScreenPixmap)(pScreen); + + pDstPix = GetScratchPixmapHeader(pScreen, pScreenPix->drawable.width, + y + h, pScreenPix->drawable.depth, + pScreenPix->drawable.bitsPerPixel, + pScreenPix->devKind, + pScreenPix->devPrivate.ptr); + + pGC = GetScratchGC(pScreenPix->drawable.depth, pScreen); + gcvals[0] = fg; + gcvals[1] = bg; + DoChangeGC(pGC, GCForeground | GCBackground, gcvals, 0); + ValidateGC((DrawablePtr)pDstPix, pGC); + + /* We've unwrapped already so these ops miss a sync */ + SYNC_CHECK(pScrn); + + (*pGC->ops->PutImage)((DrawablePtr)pDstPix, pGC, 1, x, y, w, h, 0, + XYBitmap, (pointer)src); + + FreeScratchGC(pGC); + FreeScratchPixmapHeader(pDstPix); +} + + +void +XAAWritePixmapToCache( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int bpp, int depth +) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->WritePixmap)(pScrn, x, y, w, h, src, srcwidth, + GXcopy, ~0, -1, bpp, depth); +} + + + +void +XAAWritePixmapToCacheLinear( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int bpp, int depth +){ + ScreenPtr pScreen = pScrn->pScreen; + PixmapPtr pScreenPix, pDstPix; + GCPtr pGC; + + pScreenPix = (*pScreen->GetScreenPixmap)(pScreen); + + pDstPix = GetScratchPixmapHeader(pScreen, x + w, y + h, + depth, bpp, pScreenPix->devKind, + pScreenPix->devPrivate.ptr); + + pGC = GetScratchGC(depth, pScreen); + ValidateGC((DrawablePtr)pDstPix, pGC); + + /* We've unwrapped already so these ops miss a sync */ + SYNC_CHECK(pScrn); + + if(bpp == BitsPerPixel(depth)) + (*pGC->ops->PutImage)((DrawablePtr)pDstPix, pGC, depth, x, y, w, + h, 0, ZPixmap, (pointer)src); + else { + PixmapPtr pSrcPix; + + pSrcPix = GetScratchPixmapHeader(pScreen, w, h, depth, bpp, + srcwidth, (pointer)src); + + (*pGC->ops->CopyArea)((DrawablePtr)pSrcPix, (DrawablePtr)pDstPix, + pGC, 0, 0, w, h, x, y); + + FreeScratchPixmapHeader(pSrcPix); + } + + FreeScratchGC(pGC); + FreeScratchPixmapHeader(pDstPix); +} + + +void +XAAWriteMono8x8PatternToCache( + ScrnInfoPtr pScrn, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + unsigned char *data; + int pad, Bpp = (pScrn->bitsPerPixel >> 3); + + pCache->offsets = pCachePriv->MonoOffsets; + + pad = BitmapBytePad(pCache->w * pScrn->bitsPerPixel); + + data = (unsigned char*)xalloc(pad * pCache->h); + if(!data) return; + + if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_ORIGIN) { + CARD32* ptr = (CARD32*)data; + ptr[0] = pCache->pat0; ptr[1] = pCache->pat1; + } else { + CARD32 *ptr; + DDXPointPtr pPoint = pCache->offsets; + int patx, paty, i; + + for(i = 0; i < 64; i++, pPoint++) { + patx = pCache->pat0; paty = pCache->pat1; + XAARotateMonoPattern(&patx, &paty, i & 0x07, i >> 3, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + ptr = (CARD32*)(data + (pad * pPoint->y) + (Bpp * pPoint->x)); + ptr[0] = patx; ptr[1] = paty; + } + } + + (*infoRec->WritePixmapToCache)(pScrn, pCache->x, pCache->y, + pCache->w, pCache->h, data, pad, pScrn->bitsPerPixel, pScrn->depth); + + xfree(data); +} + +void +XAAWriteColor8x8PatternToCache( + ScrnInfoPtr pScrn, + PixmapPtr pPix, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + int pad, i, w, h, nw, nh, Bpp; + unsigned char *data, *srcPtr, *dstPtr; + + pCache->offsets = pCachePriv->ColorOffsets; + + if(pixPriv->flags & REDUCIBLE_TO_2_COLOR) { + CARD32* ptr; + pad = BitmapBytePad(pCache->w); + data = (unsigned char*)xalloc(pad * pCache->h); + if(!data) return; + + if(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN) { + ptr = (CARD32*)data; + ptr[0] = pCache->pat0; ptr[1] = pCache->pat1; + } else { + int patx, paty; + + ptr = (CARD32*)data; + ptr[0] = ptr[2] = pCache->pat0; ptr[1] = ptr[3] = pCache->pat1; + for(i = 1; i < 8; i++) { + patx = pCache->pat0; paty = pCache->pat1; + XAARotateMonoPattern(&patx, &paty, i, 0, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + ptr = (CARD32*)(data + (pad * i)); + ptr[0] = ptr[2] = patx; ptr[1] = ptr[3] = paty; + } + } + + (*infoRec->WriteBitmapToCache)(pScrn, pCache->x, pCache->y, + pCache->w, pCache->h, data, pad, pCache->fg, pCache->bg); + + xfree(data); + return; + } + + Bpp = pScrn->bitsPerPixel >> 3; + h = min(8,pPix->drawable.height); + w = min(8,pPix->drawable.width); + pad = BitmapBytePad(pCache->w * pScrn->bitsPerPixel); + + data = (unsigned char*)xalloc(pad * pCache->h); + if(!data) return; + + /* Write and expand horizontally. */ + for (i = h, dstPtr = data, srcPtr = pPix->devPrivate.ptr; i--; + srcPtr += pPix->devKind, dstPtr += pScrn->bitsPerPixel) { + nw = w; + memcpy(dstPtr, srcPtr, w * Bpp); + while (nw != 8) { + memcpy(dstPtr + (nw * Bpp), dstPtr, nw * Bpp); + nw <<= 1; + } + } + nh = h; + /* Expand vertically. */ + while (nh != 8) { + memcpy(data + (nh*pScrn->bitsPerPixel), data, nh*pScrn->bitsPerPixel); + nh <<= 1; + } + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int j; + unsigned char *ptr = data + (128 * Bpp); + + memcpy(data + (64 * Bpp), data, 64 * Bpp); + for(i = 1; i < 8; i++, ptr += (128 * Bpp)) { + for(j = 0; j < 8; j++) { + memcpy(ptr + (j * 8) * Bpp, data + (j * 8 + i) * Bpp, + (8 - i) * Bpp); + memcpy(ptr + (j * 8 + 8 - i) * Bpp, data + j * 8 * Bpp, i*Bpp); + } + memcpy(ptr + (64 * Bpp), ptr, 64 * Bpp); + } + } + + (*infoRec->WritePixmapToCache)(pScrn, pCache->x, pCache->y, + pCache->w, pCache->h, data, pad, pScrn->bitsPerPixel, pScrn->depth); + + xfree(data); +} + + + +int +XAAStippledFillChooser(GCPtr pGC) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + PixmapPtr pPixmap = pGC->stipple; + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap); + + if(!(pPriv->flags & REDUCIBILITY_CHECKED) && + (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) { + XAACheckStippleReducibility(pPixmap); + } + + + if(pPriv->flags & REDUCIBLE_TO_8x8) { + if(infoRec->CanDoMono8x8 && + !(infoRec->FillMono8x8PatternSpansFlags & NO_TRANSPARENCY) && + ((pGC->alu == GXcopy) || !(infoRec->FillMono8x8PatternSpansFlags & + TRANSPARENCY_GXCOPY_ONLY)) && + CHECK_ROP(pGC,infoRec->FillMono8x8PatternSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillMono8x8PatternSpansFlags) && + CHECK_FG(pGC,infoRec->FillMono8x8PatternSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillMono8x8PatternSpansFlags)) { + + return DO_MONO_8x8; + } + + if(infoRec->CanDoColor8x8 && + !(infoRec->FillColor8x8PatternSpansFlags & NO_TRANSPARENCY) && + ((pGC->alu == GXcopy) || !(infoRec->FillColor8x8PatternSpansFlags & + TRANSPARENCY_GXCOPY_ONLY)) && + CHECK_ROP(pGC,infoRec->FillColor8x8PatternSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillColor8x8PatternSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillColor8x8PatternSpansFlags)) { + + return DO_COLOR_8x8; + } + } + + if(infoRec->UsingPixmapCache && infoRec->FillCacheExpandSpans && + (pPixmap->drawable.height <= infoRec->MaxCacheableStippleHeight) && + (pPixmap->drawable.width <= infoRec->MaxCacheableStippleWidth / + infoRec->CacheColorExpandDensity) && + !(infoRec->FillCacheExpandSpansFlags & NO_TRANSPARENCY) && + ((pGC->alu == GXcopy) || !(infoRec->FillCacheExpandSpansFlags & + TRANSPARENCY_GXCOPY_ONLY)) && + CHECK_ROP(pGC,infoRec->FillCacheExpandSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillCacheExpandSpansFlags) && + CHECK_FG(pGC,infoRec->FillCacheExpandSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillCacheExpandSpansFlags)) { + + return DO_CACHE_EXPAND; + } + + + if(infoRec->UsingPixmapCache && + !(infoRec->PixmapCacheFlags & DO_NOT_BLIT_STIPPLES) && + infoRec->FillCacheBltSpans && + (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) && + (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) && + !(infoRec->FillCacheBltSpansFlags & NO_TRANSPARENCY) && + ((pGC->alu == GXcopy) || !(infoRec->FillCacheBltSpansFlags & + TRANSPARENCY_GXCOPY_ONLY)) && + CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) { + + return DO_CACHE_BLT; + } + + if(infoRec->FillColorExpandSpans && + !(infoRec->FillColorExpandSpansFlags & NO_TRANSPARENCY) && + ((pGC->alu == GXcopy) || !(infoRec->FillColorExpandSpansFlags & + TRANSPARENCY_GXCOPY_ONLY)) && + CHECK_ROP(pGC,infoRec->FillColorExpandSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillColorExpandSpansFlags) && + CHECK_FG(pGC,infoRec->FillColorExpandSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillColorExpandSpansFlags)) { + + return DO_COLOR_EXPAND; + } + + return 0; +} + + +int +XAAOpaqueStippledFillChooser(GCPtr pGC) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + PixmapPtr pPixmap = pGC->stipple; + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap); + + if(XAA_DEPTH_BUG(pGC)) + return 0; + + if(!(pPriv->flags & REDUCIBILITY_CHECKED) && + (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) { + XAACheckStippleReducibility(pPixmap); + } + + if(pPriv->flags & REDUCIBLE_TO_8x8) { + if(infoRec->CanDoMono8x8 && + !(infoRec->FillMono8x8PatternSpansFlags & TRANSPARENCY_ONLY) && + CHECK_ROP(pGC,infoRec->FillMono8x8PatternSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillMono8x8PatternSpansFlags) && + CHECK_COLORS(pGC,infoRec->FillMono8x8PatternSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillMono8x8PatternSpansFlags)) { + + return DO_MONO_8x8; + } + + if(infoRec->CanDoColor8x8 && + CHECK_ROP(pGC,infoRec->FillColor8x8PatternSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillColor8x8PatternSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillColor8x8PatternSpansFlags)) { + + return DO_COLOR_8x8; + } + } + + if(infoRec->UsingPixmapCache && infoRec->FillCacheExpandSpans && + (pPixmap->drawable.height <= infoRec->MaxCacheableStippleHeight) && + (pPixmap->drawable.width <= infoRec->MaxCacheableStippleWidth / + infoRec->CacheColorExpandDensity) && + !(infoRec->FillCacheExpandSpansFlags & TRANSPARENCY_ONLY) && + CHECK_ROP(pGC,infoRec->FillCacheExpandSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillCacheExpandSpansFlags) && + CHECK_COLORS(pGC,infoRec->FillCacheExpandSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillCacheExpandSpansFlags)) { + + return DO_CACHE_EXPAND; + } + + if(infoRec->UsingPixmapCache && + !(infoRec->PixmapCacheFlags & DO_NOT_BLIT_STIPPLES) && + infoRec->FillCacheBltSpans && + (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) && + (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) && + CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) { + + return DO_CACHE_BLT; + } + + if(infoRec->FillColorExpandSpans && + !(infoRec->FillColorExpandSpansFlags & TRANSPARENCY_ONLY) && + CHECK_ROP(pGC,infoRec->FillColorExpandSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillColorExpandSpansFlags) && + CHECK_COLORS(pGC,infoRec->FillColorExpandSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillColorExpandSpansFlags)) { + + return DO_COLOR_EXPAND; + } + + return 0; +} + + + +int +XAATiledFillChooser(GCPtr pGC) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + PixmapPtr pPixmap = pGC->tile.pixmap; + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap); + + if(IS_OFFSCREEN_PIXMAP(pPixmap) && infoRec->FillCacheBltSpans && + CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) { + + return DO_PIXMAP_COPY; + } + + if(!(pPriv->flags & REDUCIBILITY_CHECKED) && + (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) { + XAACheckTileReducibility(pPixmap,infoRec->CanDoMono8x8); + } + + if(pPriv->flags & REDUCIBLE_TO_8x8) { + if((pPriv->flags & REDUCIBLE_TO_2_COLOR) && infoRec->CanDoMono8x8 && + !(infoRec->FillMono8x8PatternSpansFlags & TRANSPARENCY_ONLY) && + CHECK_ROP(pGC,infoRec->FillMono8x8PatternSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillMono8x8PatternSpansFlags) && + (!(infoRec->FillMono8x8PatternSpansFlags & RGB_EQUAL) || + (CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg))) && + CHECK_PLANEMASK(pGC,infoRec->FillMono8x8PatternSpansFlags)) { + + return DO_MONO_8x8; + } + + if(infoRec->CanDoColor8x8 && + CHECK_ROP(pGC,infoRec->FillColor8x8PatternSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillColor8x8PatternSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillColor8x8PatternSpansFlags)) { + + return DO_COLOR_8x8; + } + } + + if(infoRec->UsingPixmapCache && infoRec->FillCacheBltSpans && + (pPixmap->drawable.height <= infoRec->MaxCacheableTileHeight) && + (pPixmap->drawable.width <= infoRec->MaxCacheableTileWidth) && + CHECK_ROP(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_ROPSRC(pGC,infoRec->FillCacheBltSpansFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillCacheBltSpansFlags)) { + + return DO_CACHE_BLT; + } + + if(infoRec->FillImageWriteRects && + CHECK_NO_GXCOPY(pGC,infoRec->FillImageWriteRectsFlags) && + CHECK_ROP(pGC,infoRec->FillImageWriteRectsFlags) && + CHECK_ROPSRC(pGC,infoRec->FillImageWriteRectsFlags) && + CHECK_PLANEMASK(pGC,infoRec->FillImageWriteRectsFlags)) { + + return DO_IMAGE_WRITE; + } + + return 0; +} + + +static int RotateMasksX[8] = { + 0xFFFFFFFF, 0x7F7F7F7F, 0x3F3F3F3F, 0x1F1F1F1F, + 0x0F0F0F0F, 0x07070707, 0x03030303, 0x01010101 +}; + +static int RotateMasksY[4] = { + 0xFFFFFFFF, 0x00FFFFFF, 0x0000FFFF, 0x000000FF +}; + +void +XAARotateMonoPattern( + int *pat0, int *pat1, + int xorg, int yorg, + Bool msbfirst +){ + int tmp, mask; + + if(xorg) { + if(msbfirst) xorg = 8 - xorg; + mask = RotateMasksX[xorg]; + *pat0 = ((*pat0 >> xorg) & mask) | ((*pat0 << (8 - xorg)) & ~mask); + *pat1 = ((*pat1 >> xorg) & mask) | ((*pat1 << (8 - xorg)) & ~mask); + } + if(yorg >= 4) { + tmp = *pat0; *pat0 = *pat1; *pat1 = tmp; + yorg -= 4; + } + if(yorg) { + mask = RotateMasksY[yorg]; + yorg <<= 3; + tmp = *pat0; + *pat0 = ((*pat0 >> yorg) & mask) | ((*pat1 << (32 - yorg)) & ~mask); + *pat1 = ((*pat1 >> yorg) & mask) | ((tmp << (32 - yorg)) & ~mask); + } +} + + + +void +XAAInvalidatePixmapCache(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAAPixmapCachePrivatePtr pCachePriv = + (XAAPixmapCachePrivatePtr)infoRec->PixmapCachePrivate; + int i; + + if(!pCachePriv) return; + + for(i = 0; i < pCachePriv->Num512x512; i++) + (pCachePriv->Info512)[i].serialNumber = 0; + for(i = 0; i < pCachePriv->Num256x256; i++) + (pCachePriv->Info256)[i].serialNumber = 0; + for(i = 0; i < pCachePriv->Num128x128; i++) + (pCachePriv->Info128)[i].serialNumber = 0; + for(i = 0; i < pCachePriv->NumPartial; i++) + (pCachePriv->InfoPartial)[i].serialNumber = 0; + for(i = 0; i < pCachePriv->NumMono; i++) + (pCachePriv->InfoMono)[i].serialNumber = 0; + for(i = 0; i < pCachePriv->NumColor; i++) + (pCachePriv->InfoColor)[i].serialNumber = 0; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaPict.c b/xorg-server/hw/xfree86/xaa/xaaPict.c new file mode 100644 index 000000000..784c649a4 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaPict.c @@ -0,0 +1,643 @@ +/* + * + * Copyright © 2000 Keith Packard, member of The XFree86 Project, 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 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_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "mi.h" +#include "picturestr.h" +#include "glyphstr.h" +#include "picture.h" +#include "mipict.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" +#include "xaacexp.h" +#include "xf86fbman.h" +#include "servermd.h" + +Bool +XAAGetPixelFromRGBA ( + CARD32 *pixel, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 format +){ + int rbits, bbits, gbits, abits; + int rshift, bshift, gshift, ashift; + + *pixel = 0; + + if(!PICT_FORMAT_COLOR(format)) + return FALSE; + + rbits = PICT_FORMAT_R(format); + gbits = PICT_FORMAT_G(format); + bbits = PICT_FORMAT_B(format); + abits = PICT_FORMAT_A(format); + + if(PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) { + bshift = 0; + gshift = bbits; + rshift = gshift + gbits; + ashift = rshift + rbits; + } else { /* PICT_TYPE_ABGR */ + rshift = 0; + gshift = rbits; + bshift = gshift + gbits; + ashift = bshift + bbits; + } + + *pixel |= ( blue >> (16 - bbits)) << bshift; + *pixel |= ( red >> (16 - rbits)) << rshift; + *pixel |= (green >> (16 - gbits)) << gshift; + *pixel |= (alpha >> (16 - abits)) << ashift; + + return TRUE; +} + + +Bool +XAAGetRGBAFromPixel( + CARD32 pixel, + CARD16 *red, + CARD16 *green, + CARD16 *blue, + CARD16 *alpha, + CARD32 format +){ + int rbits, bbits, gbits, abits; + int rshift, bshift, gshift, ashift; + + if(!PICT_FORMAT_COLOR(format)) + return FALSE; + + rbits = PICT_FORMAT_R(format); + gbits = PICT_FORMAT_G(format); + bbits = PICT_FORMAT_B(format); + abits = PICT_FORMAT_A(format); + + if(PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) { + bshift = 0; + gshift = bbits; + rshift = gshift + gbits; + ashift = rshift + rbits; + } else { /* PICT_TYPE_ABGR */ + rshift = 0; + gshift = rbits; + bshift = gshift + gbits; + ashift = bshift + bbits; + } + + *red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits); + while(rbits < 16) { + *red |= *red >> rbits; + rbits <<= 1; + } + + *green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits); + while(gbits < 16) { + *green |= *green >> gbits; + gbits <<= 1; + } + + *blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits); + while(bbits < 16) { + *blue |= *blue >> bbits; + bbits <<= 1; + } + + if(abits) { + *alpha = ((pixel >> ashift ) & ((1 << abits) - 1)) << (16 - abits); + while(abits < 16) { + *alpha |= *alpha >> abits; + abits <<= 1; + } + } else *alpha = 0xffff; + + return TRUE; +} + +/* 8:8:8 + PICT_a8 -> 8:8:8:8 texture */ + +void +XAA_888_plus_PICT_a8_to_8888 ( + CARD32 color, + CARD8 *alphaPtr, /* in bytes */ + int alphaPitch, + CARD32 *dstPtr, + int dstPitch, /* in dwords */ + int width, + int height +){ + int x; + + color &= 0x00ffffff; + + while(height--) { + for(x = 0; x < width; x++) + dstPtr[x] = color | (alphaPtr[x] << 24); + dstPtr += dstPitch; + alphaPtr += alphaPitch; + } +} + +#define DRAWABLE_IS_ON_CARD(pDraw) \ + (pDraw->type == DRAWABLE_WINDOW || \ + (pDraw->type == DRAWABLE_PIXMAP && IS_OFFSCREEN_PIXMAP(pDraw))) + +Bool +XAADoComposite ( + CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height +){ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + RegionRec region; + CARD32 *formats, *dstformats; + int flags = 0; + BoxPtr pbox; + int nbox, w, h; + + if(!REGION_NUM_RECTS(pDst->pCompositeClip)) + return TRUE; + + if(!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable)) + return FALSE; + + if(DRAWABLE_IS_ON_CARD(pSrc->pDrawable)) + return FALSE; + + if (pSrc->transform || (pMask && pMask->transform)) + return FALSE; + + if (pDst->alphaMap || pSrc->alphaMap || (pMask && pMask->alphaMap)) + return FALSE; + + if ((pSrc->repeat && pSrc->repeatType != RepeatNormal) || + (pMask && pMask->repeat && pMask->repeatType != RepeatNormal)) + { + return FALSE; + } + + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + + if(pMask) { + if(pMask->componentAlpha) + return FALSE; + + /* for now we only do it if there is a 1x1 (solid) source */ + + if((pSrc->pDrawable->width == 1) && (pSrc->pDrawable->height == 1)) { + CARD16 red, green, blue, alpha; + CARD32 pixel = + *((CARD32*)(((PixmapPtr)(pSrc->pDrawable))->devPrivate.ptr)); + + if(!XAAGetRGBAFromPixel(pixel,&red,&green,&blue,&alpha,pSrc->format)) + return FALSE; + + xMask += pMask->pDrawable->x; + yMask += pMask->pDrawable->y; + + /* pull out color expandable operations here */ + if((pMask->format == PICT_a1) && (alpha == 0xffff) && + (op == PictOpOver) && infoRec->WriteBitmap && !pMask->repeat && + !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY) && + (!(infoRec->WriteBitmapFlags & RGB_EQUAL) || + ((red == green) && (green == blue)))) + { + PixmapPtr pPix = (PixmapPtr)(pMask->pDrawable); + int skipleft; + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height)) + return TRUE; + + nbox = REGION_NUM_RECTS(®ion); + pbox = REGION_RECTS(®ion); + + if(!nbox) + return TRUE; + + XAAGetPixelFromRGBA(&pixel, red, green, blue, 0, pDst->format); + + xMask -= xDst; + yMask -= yDst; + + while(nbox--) { + skipleft = pbox->x1 + xMask; + + (*infoRec->WriteBitmap)(infoRec->pScrn, + pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, + (unsigned char*)(pPix->devPrivate.ptr) + + (pPix->devKind * (pbox->y1 + yMask)) + + ((skipleft >> 3) & ~3), pPix->devKind, + skipleft & 31, pixel, -1, GXcopy, ~0); + pbox++; + } + + /* WriteBitmap sets the Sync flag */ + REGION_UNINIT(pScreen, ®ion); + return TRUE; + } + + formats = infoRec->CPUToScreenAlphaTextureFormats; + dstformats = infoRec->CPUToScreenAlphaTextureDstFormats; + if(!formats || !dstformats) + return FALSE; + + w = pMask->pDrawable->width; + h = pMask->pDrawable->height; + + if(pMask->repeat) { + if((infoRec->CPUToScreenAlphaTextureFlags & XAA_RENDER_NO_TILE) || + ((infoRec->CPUToScreenAlphaTextureFlags & + XAA_RENDER_POWER_OF_2_TILE_ONLY) && + ((h & (h - 1)) || (w & (w - 1))))) + { + return FALSE; + } + flags |= XAA_RENDER_REPEAT; + } + + if((alpha != 0xffff) && + (infoRec->CPUToScreenAlphaTextureFlags & XAA_RENDER_NO_SRC_ALPHA)) + return FALSE; + + while(*formats != pMask->format) { + if(!(*formats)) return FALSE; + formats++; + } + while(*dstformats != pDst->format) { + if(!(*dstformats)) + return FALSE; + dstformats++; + } + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height)) + return TRUE; + + nbox = REGION_NUM_RECTS(®ion); + pbox = REGION_RECTS(®ion); + + if(!nbox) { + REGION_UNINIT(pScreen, ®ion); + return TRUE; + } + + if(!(infoRec->SetupForCPUToScreenAlphaTexture2)(infoRec->pScrn, + op, red, green, blue, alpha, pMask->format, + pDst->format, + ((PixmapPtr)(pMask->pDrawable))->devPrivate.ptr, + ((PixmapPtr)(pMask->pDrawable))->devKind, + w, h, flags)) + { + REGION_UNINIT(pScreen, ®ion); + return FALSE; + } + + xMask -= xDst; + yMask -= yDst; + + while(nbox--) { + (*infoRec->SubsequentCPUToScreenAlphaTexture)(infoRec->pScrn, + pbox->x1, pbox->y1, + pbox->x1 + xMask, pbox->y1 + yMask, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + pbox++; + } + + SET_SYNC_FLAG(infoRec); + REGION_UNINIT(pScreen, ®ion); + return TRUE; + } + } else { + formats = infoRec->CPUToScreenTextureFormats; + dstformats = infoRec->CPUToScreenTextureDstFormats; + if(!formats || !dstformats) + return FALSE; + + w = pSrc->pDrawable->width; + h = pSrc->pDrawable->height; + + if(pSrc->repeat) { + if((infoRec->CPUToScreenTextureFlags & XAA_RENDER_NO_TILE) || + ((infoRec->CPUToScreenTextureFlags & + XAA_RENDER_POWER_OF_2_TILE_ONLY) && + ((h & (h - 1)) || (w & (w - 1))))) + { + return FALSE; + } + flags |= XAA_RENDER_REPEAT; + } + + while(*formats != pSrc->format) { + if(!(*formats)) return FALSE; + formats++; + } + while(*dstformats != pDst->format) { + if(!(*dstformats)) + return FALSE; + dstformats++; + } + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height)) + return TRUE; + + nbox = REGION_NUM_RECTS(®ion); + pbox = REGION_RECTS(®ion); + + if(!nbox) { + REGION_UNINIT(pScreen, ®ion); + return TRUE; + } + + if(!(infoRec->SetupForCPUToScreenTexture2)(infoRec->pScrn, + op, pSrc->format, pDst->format, + ((PixmapPtr)(pSrc->pDrawable))->devPrivate.ptr, + ((PixmapPtr)(pSrc->pDrawable))->devKind, + w, h, flags)) + { + REGION_UNINIT(pScreen, ®ion); + return FALSE; + } + + + xSrc -= xDst; + ySrc -= yDst; + + while(nbox--) { + (*infoRec->SubsequentCPUToScreenTexture)(infoRec->pScrn, + pbox->x1, pbox->y1, + pbox->x1 + xSrc, pbox->y1 + ySrc, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + pbox++; + } + + SET_SYNC_FLAG(infoRec); + REGION_UNINIT(pScreen, ®ion); + return TRUE; + } + + + return FALSE; +} + +static void +XAACompositeSrcCopy (PicturePtr pSrc, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + int i, nbox; + int xoff, yoff; + BoxPtr pbox; + DDXPointPtr pptSrc; + RegionRec region; + + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + + if (!miComputeCompositeRegion (®ion, pSrc, NULL, pDst, + xSrc, ySrc, 0, 0, xDst, yDst, + width, height)) + return; + + nbox = REGION_NUM_RECTS(®ion); + pbox = REGION_RECTS(®ion); + + if(!nbox) { + REGION_UNINIT(pScreen, ®ion); + return; + } + pptSrc = xalloc(sizeof(DDXPointRec) * nbox); + if (!pptSrc) { + REGION_UNINIT(pScreen, ®ion); + return; + } + xoff = xSrc - xDst; + yoff = ySrc - yDst; + for (i = 0; i < nbox; i++) { + pptSrc[i].x = pbox[i].x1 + xoff; + pptSrc[i].y = pbox[i].y1 + yoff; + } + + infoRec->ScratchGC.planemask = ~0L; + infoRec->ScratchGC.alu = GXcopy; + + XAADoBitBlt(pSrc->pDrawable, pDst->pDrawable, &infoRec->ScratchGC, ®ion, + pptSrc); + + xfree(pptSrc); + REGION_UNINIT(pScreen, ®ion); + return; +} + +void +XAAComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAA_RENDER_PROLOGUE(pScreen, Composite); + + if(!pMask && infoRec->pScrn->vtSema && + infoRec->ScreenToScreenBitBlt && + pSrc->pDrawable && + DRAWABLE_IS_ON_CARD(pSrc->pDrawable) && + DRAWABLE_IS_ON_CARD(pDst->pDrawable) && + !pSrc->transform && + (!pSrc->repeat || (xSrc >= 0 && ySrc >= 0 && + xSrc+width<=pSrc->pDrawable->width && + ySrc+height<=pSrc->pDrawable->height)) && + ((op == PictOpSrc && + ((pSrc->format==pDst->format) || + (pSrc->format==PICT_a8r8g8b8 && pDst->format==PICT_x8r8g8b8) || + (pSrc->format==PICT_a8b8g8r8 && pDst->format==PICT_x8b8g8r8))) || + (op == PictOpOver && !pSrc->alphaMap && !pDst->alphaMap && + pSrc->format==pDst->format && + (pSrc->format==PICT_x8r8g8b8 || pSrc->format==PICT_x8b8g8r8)))) + { + XAACompositeSrcCopy(pSrc, pDst, xSrc, ySrc, xDst, yDst, width, height); + } else if(!pSrc->pDrawable || (pMask && !pMask->pDrawable) || + !infoRec->Composite || + !(*infoRec->Composite)(op, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height)) + { + if(infoRec->pScrn->vtSema && + ((pSrc->pDrawable && + (pSrc->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))) || + pDst->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) { + SYNC_CHECK(pDst->pDrawable); + } + (*GetPictureScreen(pScreen)->Composite) (op, + pSrc, + pMask, + pDst, + xSrc, + ySrc, + xMask, + yMask, + xDst, + yDst, + width, + height); + } + + if(pDst->pDrawable->type == DRAWABLE_PIXMAP) + (XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst->pDrawable)))->flags |= DIRTY; + + XAA_RENDER_EPILOGUE(pScreen, Composite, XAAComposite); +} + +Bool +XAADoGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + + if(!REGION_NUM_RECTS(pDst->pCompositeClip)) + return TRUE; + + if(!infoRec->pScrn->vtSema || + ((pDst->pDrawable->type != DRAWABLE_WINDOW) && + !IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) + return FALSE; + + if((pSrc->pDrawable->type != DRAWABLE_PIXMAP) || + IS_OFFSCREEN_PIXMAP(pSrc->pDrawable)) + return FALSE; + + /* + * If it looks like we have a chance of being able to draw these + * glyphs with an accelerated Composite, do that now to avoid + * unneeded and costly syncs. + */ + if(maskFormat) { + if(!infoRec->CPUToScreenAlphaTextureFormats) + return FALSE; + } else { + if(!infoRec->CPUToScreenTextureFormats) + return FALSE; + } + + miGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); + + return TRUE; +} + + +void +XAAGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAA_RENDER_PROLOGUE(pScreen, Glyphs); + + if(!pSrc->pDrawable || !infoRec->Glyphs || + !(*infoRec->Glyphs)(op, pSrc, pDst, maskFormat, + xSrc, ySrc, nlist, list, glyphs)) + { + if(infoRec->pScrn->vtSema && + ((pSrc->pDrawable && + (pSrc->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pSrc->pDrawable))) || + pDst->pDrawable->type == DRAWABLE_WINDOW || IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) { + SYNC_CHECK(pDst->pDrawable); + } + (*GetPictureScreen(pScreen)->Glyphs) (op, pSrc, pDst, maskFormat, + xSrc, ySrc, nlist, list, glyphs); + } + + if(pDst->pDrawable->type == DRAWABLE_PIXMAP) + (XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst->pDrawable)))->flags |= DIRTY; + + XAA_RENDER_EPILOGUE(pScreen, Glyphs, XAAGlyphs); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaROP.c b/xorg-server/hw/xfree86/xaa/xaaROP.c new file mode 100644 index 000000000..155daa4ee --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaROP.c @@ -0,0 +1,184 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "scrnintstr.h" +#include "xf86str.h" +#include "xaarop.h" +#include "xaa.h" +#include "xaalocal.h" + + +int XAACopyROP[16] = +{ + ROP_0, /* GXclear */ + ROP_DSa, /* GXand */ + ROP_SDna, /* GXandReverse */ + ROP_S, /* GXcopy */ + ROP_DSna, /* GXandInverted */ + ROP_D, /* GXnoop */ + ROP_DSx, /* GXxor */ + ROP_DSo, /* GXor */ + ROP_DSon, /* GXnor */ + ROP_DSxn, /* GXequiv */ + ROP_Dn, /* GXinvert*/ + ROP_SDno, /* GXorReverse */ + ROP_Sn, /* GXcopyInverted */ + ROP_DSno, /* GXorInverted */ + ROP_DSan, /* GXnand */ + ROP_1 /* GXset */ +}; + +int XAACopyROP_PM[16] = +{ + ROP_0, /* not used */ + ROP_DSPnoa, + ROP_DPSnaon, + ROP_DPSDxax, + ROP_DPSana, + ROP_D, /* not used */ + ROP_DPSax, + ROP_DPSao, + ROP_DPSaon, + ROP_DPSaxn, + ROP_Dn, /* not used */ + ROP_DPSanan, + ROP_PSDPxox, /* is that correct ? */ + ROP_DPSnao, + ROP_DSPnoan, + ROP_1 /* not used */ +}; + + +int XAAPatternROP[16]= +{ + ROP_0, + ROP_DPa, + ROP_PDna, + ROP_P, + ROP_DPna, + ROP_D, + ROP_DPx, + ROP_DPo, + ROP_DPon, + ROP_PDxn, + ROP_Dn, + ROP_PDno, + ROP_Pn, + ROP_DPno, + ROP_DPan, + ROP_1 +}; + +int XAAPatternROP_PM[16] = +{ + ROP_DPna, + ROP_DPSnoa, + ROP_DSPnaon, + ROP_DSPDxax, + ROP_DPSana, + ROP_D, + ROP_DPSax, + ROP_DPSao, + ROP_DPSaon, + ROP_DPSaxn, + ROP_DPx, + ROP_DPSanan, + ROP_SPDSxox, /* is that correct ? */ + ROP_DSPnao, + ROP_DPSnoan, + ROP_DPo +}; + +int XAAGetCopyROP(int i) +{ + return XAACopyROP[i]; +} + +int XAAGetCopyROP_PM(int i) +{ + return XAACopyROP_PM[i]; +} + +int XAAGetPatternROP(int i) +{ + return XAAPatternROP[i]; +} + +int XAAGetPatternROP_PM(int i) +{ + return XAAPatternROP_PM[i]; +} + +int +XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int ret = 0; + + pm &= infoRec->FullPlanemasks[pScrn->depth - 1]; + + if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) { + if(!NO_SRC_ROP(*rop)) + ret |= ROP_PAT; + *rop = XAAPatternROP[*rop]; + } else { + switch(*rop) { + case GXnoop: + break; + case GXset: + case GXclear: + case GXinvert: + ret |= ROP_PAT; + *fg = pm; + if(*bg != -1) + *bg = pm; + break; + default: + ret |= ROP_PAT | ROP_SRC; + break; + } + *rop = XAAPatternROP_PM[*rop]; + } + + return ret; +} + + +int +XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int ret = 0; + + pm &= infoRec->FullPlanemasks[pScrn->depth - 1]; + + if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) { + if(!NO_SRC_ROP(*rop)) + ret |= ROP_PAT; + *rop = XAAPatternROP[*rop]; + } else { + switch(*rop) { + case GXnoop: + break; + case GXset: + case GXclear: + case GXinvert: + ret |= ROP_PAT; + *fg = pm; + break; + default: + ret |= ROP_PAT | ROP_SRC; + break; + } + *rop = XAAPatternROP_PM[*rop]; + } + + return ret; +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaRect.c b/xorg-server/hw/xfree86/xaa/xaaRect.c new file mode 100644 index 000000000..0a7e174b7 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaRect.c @@ -0,0 +1,136 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + +/* + Much of this file based on code by + Harm Hanemaayer (H.Hanemaayer@inter.nl.net). +*/ + + +void +XAAPolyRectangleThinSolid( + DrawablePtr pDrawable, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int nClipRects; /* number of clip rectangles */ + BoxPtr pClipRects; /* points to the list of clip rects */ + int xOrigin; /* Drawables x origin */ + int yOrigin; /* Drawables x origin */ + xRectangle *pRect; /* list of rects */ + int nRects; /* running count of number of rects */ + int origX1, origY1; /* original rectangle's U/L corner */ + int origX2, origY2; /* original rectangle's L/R corner */ + int clippedX1; /* clipped rectangle's left x */ + int clippedY1; /* clipped rectangle's top y */ + int clippedX2; /* clipped rectangle's right x */ + int clippedY2; /* clipped rectangle's bottom y */ + int clipXMin; /* upper left corner of clip rect */ + int clipYMin; /* upper left corner of clip rect */ + int clipXMax; /* lower right corner of clip rect */ + int clipYMax; /* lower right corner of clip rect */ + int width, height; /* width and height of rect */ + + nClipRects = REGION_NUM_RECTS(pGC->pCompositeClip); + pClipRects = REGION_RECTS(pGC->pCompositeClip); + + if(!nClipRects) return; + + xOrigin = pDrawable->x; + yOrigin = pDrawable->y; + + + (*infoRec->SetupForSolidLine)(infoRec->pScrn, + pGC->fgPixel, pGC->alu, pGC->planemask); + + + for ( ; nClipRects > 0; + nClipRects--, pClipRects++ ) + { + clipYMin = pClipRects->y1; + clipYMax = pClipRects->y2 - 1; + clipXMin = pClipRects->x1; + clipXMax = pClipRects->x2 - 1; + + for (pRect = pRectsInit, nRects = nRectsInit; + nRects > 0; + nRects--, pRect++ ) + { + /* translate rectangle data over to the drawable */ + origX1 = pRect->x + xOrigin; + origY1 = pRect->y + yOrigin; + origX2 = origX1 + pRect->width; + origY2 = origY1 + pRect->height; + + /* reject entire rectangle if completely outside clip rect */ + if ((origX1 > clipXMax) || (origX2 < clipXMin) || + (origY1 > clipYMax) || (origY2 < clipYMin)) + continue; + + /* clip the rectangle */ + clippedX1 = max (origX1, clipXMin); + clippedX2 = min (origX2, clipXMax); + clippedY1 = max (origY1, clipYMin); + clippedY2 = min (origY2, clipYMax); + + width = clippedX2 - clippedX1 + 1; + + if (origY1 >= clipYMin) { + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX1, clippedY1, width, DEGREES_0); + + /* don't overwrite corner */ + clippedY1++; + } + + if ((origY2 <= clipYMax) && (origY1 != origY2)) { + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX1, clippedY2, width, DEGREES_0); + + /* don't overwrite corner */ + clippedY2--; + } + + if (clippedY2 < clippedY1) continue; + + height = clippedY2 - clippedY1 + 1; + + /* draw vertical edges using lines if not clipped out */ + if (origX1 >= clipXMin) + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX1, clippedY1, height, DEGREES_270); + + if ((origX2 <= clipXMax) && (origX2 != origX1)) + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX2, clippedY1, height, DEGREES_270); + } + } + + SET_SYNC_FLAG(infoRec); +} + + + + + + + + + + + diff --git a/xorg-server/hw/xfree86/xaa/xaaSpans.c b/xorg-server/hw/xfree86/xaa/xaaSpans.c new file mode 100644 index 000000000..7d0943d72 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaSpans.c @@ -0,0 +1,882 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "mi.h" +#include "mispans.h" +#include "xaa.h" +#include "xaalocal.h" + + +static void XAARenderSolidSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderColor8x8Spans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderMono8x8Spans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderCacheBltSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderColorExpandSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderCacheExpandSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderPixmapCopySpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); + +void +XAAFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, /* number of spans to fill */ + DDXPointPtr pptInit, /* pointer to list of start points */ + int *pwidthInit, /* pointer to list of n widths */ + int fSorted +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int type = 0; + ClipAndRenderSpansFunc function; + Bool fastClip = FALSE; + + if((nInit <= 0) || !pGC->planemask) + return; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + switch(pGC->fillStyle) { + case FillSolid: + type = DO_SOLID; + break; + case FillStippled: + type = (*infoRec->StippledFillChooser)(pGC); + break; + case FillOpaqueStippled: + if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid && + CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) && + CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) && + CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) && + CHECK_FG(pGC,infoRec->FillSpansSolidFlags)) + type = DO_SOLID; + else + type = (*infoRec->OpaqueStippledFillChooser)(pGC); + break; + case FillTiled: + type = (*infoRec->TiledFillChooser)(pGC); + break; + } + + switch(type) { + case DO_SOLID: + function = XAARenderSolidSpans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) + fastClip = TRUE; + break; + case DO_COLOR_8x8: + function = XAARenderColor8x8Spans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL) + fastClip = TRUE; + break; + case DO_MONO_8x8: + function = XAARenderMono8x8Spans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL) + fastClip = TRUE; + break; + case DO_CACHE_BLT: + function = XAARenderCacheBltSpans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) + fastClip = TRUE; + break; + case DO_COLOR_EXPAND: + function = XAARenderColorExpandSpans; + break; + case DO_CACHE_EXPAND: + function = XAARenderCacheExpandSpans; + if(infoRec->ClippingFlags & + HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND) + fastClip = TRUE; + break; + case DO_PIXMAP_COPY: + function = XAARenderPixmapCopySpans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) + fastClip = TRUE; + break; + case DO_IMAGE_WRITE: + default: + (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit, + pwidthInit, fSorted); + return; + } + + + if((nInit < 10) || (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)) + fastClip = FALSE; + + if(fastClip) { + infoRec->ClipBox = &pGC->pCompositeClip->extents; + (*function)(pGC, nInit, pptInit, pwidthInit, fSorted, + pDraw->x, pDraw->y); + infoRec->ClipBox = NULL; + } else + XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted, + function, pDraw->x, pDraw->y); +} + + + /*********************\ + | Solid Spans | + \*********************/ + + +static void +XAARenderSolidSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted); +} + + + /************************\ + | Mono 8x8 Spans | + \************************/ + + +static void +XAARenderMono8x8Spans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + fg = pPriv->fg; bg = pPriv->bg; + break; + default: /* Muffle compiler */ + pPriv = NULL; /* Kaboom */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn, + fg, bg, pGC->alu, pGC->planemask, + n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); +} + + + /*************************\ + | Color 8x8 Spans | + \*************************/ + + +static void +XAARenderColor8x8Spans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + PixmapPtr pPix; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPix = pGC->tile.pixmap; + fg = -1; bg = -1; + break; + default: /* Muffle compiler */ + pPix = NULL; + fg = -1; bg = -1; + break; + } + + pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); + + (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, + (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y)); +} + + + /****************************\ + | Color Expand Spans | + \****************************/ + + +static void +XAARenderColorExpandSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); + +} + + + /*************************\ + | Cache Blt Spans | + \*************************/ + + +static void +XAARenderCacheBltSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + + switch(pGC->fillStyle) { + case FillStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, -1); + break; + case FillOpaqueStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, pGC->bgPixel); + break; + case FillTiled: + pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); + break; + default: /* Muffle compiler */ + pCache = NULL; + break; + } + + (*infoRec->FillCacheBltSpans) (infoRec->pScrn, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); + +} + + + /****************************\ + | Cache Expand Spans | + \****************************/ + + +static void +XAARenderCacheExpandSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); +} + + + /***************************\ + | Pixmap Copy Spans | + \***************************/ + + +static void +XAARenderPixmapCopySpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + + pCache->x = pPriv->offscreenArea->box.x1; + pCache->y = pPriv->offscreenArea->box.y1; + pCache->w = pCache->orig_w = + pPriv->offscreenArea->box.x2 - pCache->x; + pCache->h = pCache->orig_h = + pPriv->offscreenArea->box.y2 - pCache->y; + pCache->trans_color = -1; + + (*infoRec->FillCacheBltSpans) (infoRec->pScrn, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); +} + + + + + + /****************\ + | Solid | + \****************/ + + +void +XAAFillSolidSpans( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + if (*pwidth > 0) + (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y, + *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + /***************\ + | Mono 8x8 | + \***************/ + + +void +XAAFillMono8x8PatternSpansScreenOrigin( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + int pattern0, int pattern1, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + + if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = + (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + +void +XAAFillMono8x8PatternSpans( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + int pattern0, int pattern1, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg, yorg, slot; + XAACacheInfoPtr pCache = NULL; + + + if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + } + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + xorg = (ppt->x - xorigin) & 0x07; + yorg = (ppt->y - yorigin) & 0x07; + + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + patx = pattern0; paty = pattern1; + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } else { + slot = (yorg << 3) + xorg; + xorg = patx + pCache->offsets[slot].x; + yorg = paty + pCache->offsets[slot].y; + } + } + + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + + + /****************\ + | Color 8x8 | + \****************/ + + +void +XAAFillColor8x8PatternSpansScreenOrigin( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + XAACacheInfoPtr pCache, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pCache->x, paty = pCache->y; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + paty += pCache->offsets[slot].y; + patx += pCache->offsets[slot].x; + xorg = patx; yorg = paty; + } + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, + rop, planemask, pCache->trans_color); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + +void +XAAFillColor8x8PatternSpans( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + XAACacheInfoPtr pCache, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int xorg, yorg, slot; + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, + rop, planemask, pCache->trans_color); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + xorg = (ppt->x - xorigin) & 0x07; + yorg = (ppt->y - yorigin) & 0x07; + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + slot = (yorg << 3) + xorg; + yorg = pCache->y + pCache->offsets[slot].y; + xorg = pCache->x + pCache->offsets[slot].x; + } + + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + /*****************\ + | Cache Blit | + \*****************/ + + +void +XAAFillCacheBltSpans( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + XAACacheInfoPtr pCache, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, w, phaseX, phaseY, blit_w; + + (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, + pCache->trans_color); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + x = ppt->x; + w = *pwidth; + phaseX = (x - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + phaseY = (ppt->y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + + while(1) { + blit_w = pCache->w - phaseX; + if(blit_w > w) blit_w = w; + + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + phaseX, pCache->y + phaseY, + x, ppt->y, blit_w, 1); + + w -= blit_w; + if(!w) break; + x += blit_w; + phaseX = (phaseX + blit_w) % pCache->orig_w; + } + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + + /****************\ + | Cache Expand | + \****************/ + + +void +XAAFillCacheExpandSpans( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, w, phaseX, phaseY, blit_w, cacheWidth; + XAACacheInfoPtr pCache; + + pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); + + cacheWidth = (pCache->w * pScrn->bitsPerPixel) / + infoRec->CacheColorExpandDensity; + + (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, + planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + x = ppt->x; + w = *pwidth; + phaseX = (x - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + phaseY = (ppt->y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + + while(1) { + blit_w = cacheWidth - phaseX; + if(blit_w > w) blit_w = w; + + (*infoRec->SubsequentScreenToScreenColorExpandFill)( + pScrn, x, ppt->y, blit_w, 1, + pCache->x, pCache->y + phaseY, phaseX); + + w -= blit_w; + if(!w) break; + x += blit_w; + phaseX = (phaseX + blit_w) % pCache->orig_w; + } + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + + +void +XAAClipAndRenderSpans( + GCPtr pGC, + DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted, + ClipAndRenderSpansFunc func, + int xorg, + int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + DDXPointPtr pptNew, pptBase; + int *pwidthBase, *pwidthNew; + int Right, numRects, MaxBoxes; + + MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int)); + pptBase = (DDXPointRec*)infoRec->PreAllocMem; + pwidthBase = (int*)(&pptBase[MaxBoxes]); + + pptNew = pptBase; + pwidthNew = pwidthBase; + + numRects = REGION_NUM_RECTS(pGC->pCompositeClip); + + if(numRects == 1) { + BoxPtr pextent = REGION_RECTS(pGC->pCompositeClip); + + while(nspans--) { + if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) { + pptNew->x = max(pextent->x1, ppt->x); + Right = ppt->x + *pwidth; + *pwidthNew = min(pextent->x2, Right) - pptNew->x; + + if (*pwidthNew > 0) { + pptNew->y = ppt->y; + pptNew++; + pwidthNew++; + + if(pptNew >= (pptBase + MaxBoxes)) { + (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted, + xorg, yorg); + pptNew = pptBase; + pwidthNew = pwidthBase; + } + } + } + ppt++; + pwidth++; + } + } else if (numRects) { + BoxPtr pbox; + int nbox; + + while(nspans--) { + nbox = numRects; + pbox = REGION_RECTS(pGC->pCompositeClip); + + /* find the first band */ + while(nbox && (pbox->y2 <= ppt->y)) { + pbox++; + nbox--; + } + + if(nbox && (pbox->y1 <= ppt->y)) { + int orig_y = pbox->y1; + Right = ppt->x + *pwidth; + while(nbox && (orig_y == pbox->y1)) { + if(pbox->x2 <= ppt->x) { + nbox--; + pbox++; + continue; + } + + if(pbox->x1 >= Right) { + nbox = 0; + break; + } + + pptNew->x = max(pbox->x1, ppt->x); + *pwidthNew = min(pbox->x2, Right) - pptNew->x; + if(*pwidthNew > 0) { + pptNew->y = ppt->y; + pptNew++; + pwidthNew++; + + if(pptNew >= (pptBase + MaxBoxes)) { + (*func)(pGC, MaxBoxes, pptBase, pwidthBase, + fSorted, xorg, yorg); + pptNew = pptBase; + pwidthNew = pwidthBase; + } + } + pbox++; + nbox--; + } + } + ppt++; + pwidth++; + } + } + + if(pptNew != pptBase) + (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted, + xorg, yorg); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaStateChange.c b/xorg-server/hw/xfree86/xaa/xaaStateChange.c new file mode 100644 index 000000000..443bda628 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaStateChange.c @@ -0,0 +1,1631 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "mi.h" +#include "miline.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" +#include "servermd.h" + +#define XAA_STATE_WRAP(func) do {\ +if(infoRec->func) { \ + pStatePriv->func = infoRec->func;\ + infoRec->func = XAAStateWrap##func;\ +}} while(0) + +/* Wrap all XAA functions and allocate our private structure. + */ + +typedef struct _XAAStateWrapRec { + ScrnInfoPtr pScrn; + void (*RestoreAccelState)(ScrnInfoPtr pScrn); + void (*Sync)(ScrnInfoPtr pScrn); + void (*SetupForScreenToScreenCopy)(ScrnInfoPtr pScrn, int xdir, int ydir, + int rop, unsigned int planemask, + int trans_color); + void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color, int rop, + unsigned int planemask); + void (*SetupForSolidLine)(ScrnInfoPtr pScrn,int color,int rop, + unsigned int planemask); + void (*SetupForDashedLine)(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int length, + unsigned char *pattern); + void (*SetClippingRectangle) (ScrnInfoPtr pScrn, int left, int top, + int right, int bottom); + void (*DisableClipping)(ScrnInfoPtr pScrn); + void (*SetupForMono8x8PatternFill)(ScrnInfoPtr pScrn, int patx, int paty, + int fg, int bg, int rop, + unsigned int planemask); + void (*SetupForColor8x8PatternFill)(ScrnInfoPtr pScrn, int patx, int paty, + int rop, unsigned int planemask, + int transparency_color); + void (*SetupForCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn, int fg, + int bg, int rop, + unsigned int planemask); + void (*SetupForScanlineCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask); + void (*SetupForScreenToScreenColorExpandFill) (ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask); + void (*SetupForImageWrite)(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int transparency_color, + int bpp, int depth); + void (*SetupForScanlineImageWrite)(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth); + void (*SetupForImageRead) (ScrnInfoPtr pScrn, int bpp, int depth); + void (*ScreenToScreenBitBlt)(ScrnInfoPtr pScrn, int nbox, + DDXPointPtr pptSrc, BoxPtr pbox, int xdir, + int ydir, int alu, unsigned int planmask); + void (*WriteBitmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int skipleft, + int fg, int bg, int rop, unsigned int planemask); + void (*FillSolidRects)(ScrnInfoPtr pScrn, int fg, int rop, + unsigned int planemask, int nBox, BoxPtr pBox); + void (*FillMono8x8PatternRects)(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int nBox, + BoxPtr pBox, int pat0, int pat1, + int xorg, int yorg); + void (*FillColor8x8PatternRects)(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int nBox, + BoxPtr pBox, int xorg, int yorg, + XAACacheInfoPtr pCache); + void (*FillCacheBltRects)(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int nBox, BoxPtr pBox, + int xorg, int yorg, XAACacheInfoPtr pCache); + void (*FillColorExpandRects)(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int nBox, + BoxPtr pBox, int xorg, int yorg, + PixmapPtr pPix); + void (*FillCacheExpandRects)(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int nBox, BoxPtr pBox, + int xorg, int yorg, PixmapPtr pPix); + void (*FillImageWriteRects)(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int nBox, BoxPtr pBox, + int xorg, int yorg, PixmapPtr pPix); + void (*FillSolidSpans)(ScrnInfoPtr pScrn, int fg, int rop, + unsigned int planemask, int n, DDXPointPtr points, + int *widths, int fSorted); + void (*FillMono8x8PatternSpans)(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int n, + DDXPointPtr points, int *widths, + int fSorted, int pat0, int pat1, + int xorg, int yorg); + void (*FillColor8x8PatternSpans)(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int n, + DDXPointPtr points, int *widths, + int fSorted, XAACacheInfoPtr pCache, + int xorg, int yorg); + void (*FillCacheBltSpans)(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int n, DDXPointPtr points, + int *widths, int fSorted, XAACacheInfoPtr pCache, + int xorg, int yorg); + void (*FillColorExpandSpans)(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int n, + DDXPointPtr points, int *widths, int fSorted, + int xorg, int yorg, PixmapPtr pPix); + void (*FillCacheExpandSpans)(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int n, DDXPointPtr ppt, + int *pwidth, int fSorted, int xorg, int yorg, + PixmapPtr pPix); + void (*TEGlyphRenderer)(ScrnInfoPtr pScrn, int x, int y, int w, int h, + int skipleft, int startline, unsigned int **glyphs, + int glyphWidth, int fg, int bg, int rop, + unsigned planemask); + void (*NonTEGlyphRenderer)(ScrnInfoPtr pScrn, int x, int y, int n, + NonTEGlyphPtr glyphs, BoxPtr pbox, + int fg, int rop, unsigned int planemask); + void (*WritePixmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int rop, + unsigned int planemask, int transparency_color, + int bpp, int depth); + void (*ReadPixmap) (ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *dst, int dstwidth, int bpp, int depth); + RegionPtr (*CopyArea)(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, + GC *pGC, int srcx, int srcy, int width, int height, + int dstx, int dsty); + RegionPtr (*CopyPlane)(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int width, int height, int dstx, + int dsty, unsigned long bitPlane); + void (*PushPixelsSolid) (GCPtr pGC, PixmapPtr pBitMap, + DrawablePtr pDrawable, int dx, int dy, int xOrg, + int yOrg); + void (*PolyFillRectSolid)(DrawablePtr pDraw, GCPtr pGC, int nrectFill, + xRectangle *prectInit); + void (*PolyFillRectStippled)(DrawablePtr pDraw, GCPtr pGC, int nrectFill, + xRectangle *prectInit); + void (*PolyFillRectOpaqueStippled)(DrawablePtr pDraw, GCPtr pGC, + int nrectFill, xRectangle *prectInit); + void (*PolyFillRectTiled)(DrawablePtr pDraw, GCPtr pGC, int nrectFill, + xRectangle *prectInit); + void (*FillSpansSolid)(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted); + void (*FillSpansStippled)(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted); + void (*FillSpansOpaqueStippled)(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted); + void (*FillSpansTiled)(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted); + int (*PolyText8TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, + char *chars); + int (*PolyText16TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, + unsigned short *chars); + void (*ImageText8TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, + char *chars); + void (*ImageText16TE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars); + void (*ImageGlyphBltTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase); + void (*PolyGlyphBltTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase); + int (*PolyText8NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, char *chars); + int (*PolyText16NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars); + void (*ImageText8NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, char *chars); + void (*ImageText16NonTE) (DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars); + void (*ImageGlyphBltNonTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase); + void (*PolyGlyphBltNonTE) (DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase); + void (*PolyRectangleThinSolid)(DrawablePtr pDrawable,GCPtr pGC, + int nRectsInit, xRectangle *pRectsInit); + void (*PolylinesWideSolid)(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pPts); + void (*PolylinesThinSolid)(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pPts); + void (*PolySegmentThinSolid)(DrawablePtr pDrawable, GCPtr pGC, int nseg, + xSegment *pSeg); + void (*PolylinesThinDashed)(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pPts); + void (*PolySegmentThinDashed)(DrawablePtr pDrawable, GCPtr pGC, int nseg, + xSegment *pSeg); + void (*FillPolygonSolid)(DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr ptsIn); + void (*FillPolygonStippled)(DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr ptsIn); + void (*FillPolygonOpaqueStippled)(DrawablePtr pDrawable, GCPtr pGC, + int shape, int mode, int count, + DDXPointPtr ptsIn); + void (*FillPolygonTiled)(DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr ptsIn); + void (*PolyFillArcSolid)(DrawablePtr pDraw, GCPtr pGC, int narcs, + xArc *parcs); + void (*PutImage)(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pImage); + ValidateGCProcPtr ValidateFillSpans; + ValidateGCProcPtr ValidateSetSpans; + ValidateGCProcPtr ValidatePutImage; + ValidateGCProcPtr ValidateCopyArea; + ValidateGCProcPtr ValidateCopyPlane; + ValidateGCProcPtr ValidatePolyPoint; + ValidateGCProcPtr ValidatePolylines; + ValidateGCProcPtr ValidatePolySegment; + ValidateGCProcPtr ValidatePolyRectangle; + ValidateGCProcPtr ValidatePolyArc; + ValidateGCProcPtr ValidateFillPolygon; + ValidateGCProcPtr ValidatePolyFillRect; + ValidateGCProcPtr ValidatePolyFillArc; + ValidateGCProcPtr ValidatePolyText8; + ValidateGCProcPtr ValidatePolyText16; + ValidateGCProcPtr ValidateImageText8; + ValidateGCProcPtr ValidateImageText16; + ValidateGCProcPtr ValidatePolyGlyphBlt; + ValidateGCProcPtr ValidateImageGlyphBlt; + ValidateGCProcPtr ValidatePushPixels; + void (*ComputeDash)(GCPtr pGC); + void (*InitPixmapCache)(ScreenPtr pScreen, RegionPtr areas, pointer data); + void (*ClosePixmapCache)(ScreenPtr pScreen); + int (*StippledFillChooser)(GCPtr pGC); + int (*OpaqueStippledFillChooser)(GCPtr pGC); + int (*TiledFillChooser)(GCPtr pGC); + XAACacheInfoPtr (*CacheTile)(ScrnInfoPtr Scrn, PixmapPtr pPix); + XAACacheInfoPtr (*CacheStipple)(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, + int bg); + XAACacheInfoPtr (*CacheMonoStipple)(ScrnInfoPtr Scrn, PixmapPtr pPix); + XAACacheInfoPtr (*CacheMono8x8Pattern)(ScrnInfoPtr Scrn, int pat0, + int pat1); + XAACacheInfoPtr (*CacheColor8x8Pattern)(ScrnInfoPtr Scrn, PixmapPtr pPix, + int fg, int bg); + void (*WriteBitmapToCache) (ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int fg, + int bg); + void (*WritePixmapToCache) (ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int bpp, + int depth); + void (*WriteMono8x8PatternToCache)(ScrnInfoPtr pScrn, + XAACacheInfoPtr pCache); + void (*WriteColor8x8PatternToCache)(ScrnInfoPtr pScrn, PixmapPtr pPix, + XAACacheInfoPtr pCache); + GetImageProcPtr GetImage; + GetSpansProcPtr GetSpans; + CopyWindowProcPtr CopyWindow; +#ifdef RENDER + Bool (*SetupForCPUToScreenAlphaTexture2)(ScrnInfoPtr pScrn, int op, + CARD16 red, CARD16 green, + CARD16 blue, CARD16 alpha, + CARD32 maskFormat, CARD32 dstFormat, + CARD8 *alphaPtr, int alphaPitch, + int width, int height, int flags); + Bool (*SetupForCPUToScreenTexture2)(ScrnInfoPtr pScrn, int op, + CARD32 srcFormat, CARD32 dstFormat, + CARD8 *texPtr, int texPitch, + int width, int height, int flags); +#endif +} XAAStateWrapRec, *XAAStateWrapPtr; + +static DevPrivateKey XAAStateKey = &XAAStateKey; + +/* Wrap functions start here */ +#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\ +(XAAStateWrapPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAStateKey) + +#define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\ +(XAAStateWrapPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAStateKey) + +#define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\ +(XAAStateWrapPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAStateKey) + +#define STATE_CHECK_SP(pStatePriv) {\ + ScrnInfoPtr pScrn = pStatePriv->pScrn;\ + int i = 0;\ + int need_change = 0;\ + while(i < pScrn->numEntities) {\ + if(xf86IsEntityShared(pScrn->entityList[i]) &&\ + xf86GetLastScrnFlag(pScrn->entityList[i]) != pScrn->scrnIndex) {\ + need_change = 1;\ + xf86SetLastScrnFlag(pScrn->entityList[i],\ + pScrn->scrnIndex);\ + }\ + i++;\ + }\ + if(need_change == 1) (*pStatePriv->RestoreAccelState)(pScrn);\ +} + +#define STATE_CHECK_PSCRN(pScrn) {\ + int i = 0;\ + int need_change = 0;\ + while(i < pScrn->numEntities) {\ + if(xf86IsEntityShared(pScrn->entityList[i]) &&\ + xf86GetLastScrnFlag(pScrn->entityList[i]) != pScrn->scrnIndex) {\ + need_change = 1;\ + xf86SetLastScrnFlag(pScrn->entityList[i],\ + pScrn->scrnIndex);\ + }\ + i++;\ + }\ + if(need_change == 1) (*pStatePriv->RestoreAccelState)(pScrn);\ +} + +static void XAAStateWrapSync(ScrnInfoPtr pScrn) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->Sync)(pScrn); +} + +static void XAAStateWrapSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, + int rop, unsigned int planemask, + int trans_color) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForScreenToScreenCopy)(pScrn, xdir, ydir, rop, planemask, + trans_color); +} + +static void XAAStateWrapSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, + unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForSolidFill)(pScrn, color, rop, planemask); +} + +static void XAAStateWrapSetupForSolidLine(ScrnInfoPtr pScrn,int color,int rop, + unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForSolidLine)(pScrn, color, rop, planemask); +} + +static void XAAStateWrapSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int length, + unsigned char *pattern) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForDashedLine)(pScrn, fg, bg, rop, planemask, length, pattern); +} + +static void XAAStateWrapSetClippingRectangle(ScrnInfoPtr pScrn, int left, int top, + int right, int bottom) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetClippingRectangle)(pScrn, left, top, right, bottom); +} + +static void XAAStateWrapDisableClipping(ScrnInfoPtr pScrn) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->DisableClipping)(pScrn); +} + +static void XAAStateWrapSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, + int fg, int bg, int rop, + unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForMono8x8PatternFill)(pScrn, patx, paty, fg, bg, rop, planemask); +} + +static void XAAStateWrapSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, + int rop, unsigned int planemask, + int transparency_color) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForColor8x8PatternFill)(pScrn, patx, paty, rop, planemask, + transparency_color); +} + +static void XAAStateWrapSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, + int bg, int rop, + unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask); +} + +static void XAAStateWrapSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, + planemask); +} + +static void XAAStateWrapSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask); +} + +static void XAAStateWrapSetupForImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int transparency_color, + int bpp, int depth) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForImageWrite)(pScrn, rop, planemask, transparency_color, bpp, + depth); +} + +static void XAAStateWrapSetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForScanlineImageWrite)(pScrn, rop, planemask, transparency_color, + bpp, depth); +} + +static void XAAStateWrapSetupForImageRead(ScrnInfoPtr pScrn, int bpp, int depth) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->SetupForImageRead)(pScrn, bpp, depth); +} + +static void XAAStateWrapScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox, + DDXPointPtr pptSrc, BoxPtr pbox, int xdir, + int ydir, int alu, unsigned int planmask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->ScreenToScreenBitBlt)(pScrn, nbox, + pptSrc, pbox, xdir, + ydir, alu, planmask); +} + +static void XAAStateWrapWriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int skipleft, + int fg, int bg, int rop, unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->WriteBitmap)(pScrn, x, y, w, h, + src, srcwidth, skipleft, + fg, bg, rop, planemask); +} + +static void XAAStateWrapFillSolidRects(ScrnInfoPtr pScrn, int fg, int rop, + unsigned int planemask, int nBox, BoxPtr pBox) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillSolidRects)(pScrn, fg, rop, + planemask, nBox, pBox); +} + +static void XAAStateWrapFillMono8x8PatternRects(ScrnInfoPtr pScrn, int fg, int bg, + int rop, unsigned int planemask, int nBox, + BoxPtr pBox, int pat0, int pat1, + int xorg, int yorg) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillMono8x8PatternRects)(pScrn, fg, bg, + rop, planemask, nBox, + pBox, pat0, pat1, + xorg, yorg); +} + +static void XAAStateWrapFillColor8x8PatternRects(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int nBox, + BoxPtr pBox, int xorg, int yorg, + XAACacheInfoPtr pCache) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillColor8x8PatternRects)(pScrn, rop, + planemask, nBox, + pBox, xorg, yorg, + pCache); +} + +static void XAAStateWrapFillCacheBltRects(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int nBox, BoxPtr pBox, + int xorg, int yorg, XAACacheInfoPtr pCache) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillCacheBltRects)(pScrn, rop, + planemask, nBox, pBox, + xorg, yorg, pCache); +} + +static void XAAStateWrapFillColorExpandRects(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int nBox, + BoxPtr pBox, int xorg, int yorg, + PixmapPtr pPix) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillColorExpandRects)(pScrn, fg, bg, rop, + planemask, nBox, + pBox, xorg, yorg, + pPix); +} + +static void XAAStateWrapFillCacheExpandRects(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int nBox, + BoxPtr pBox, int xorg, int yorg, + PixmapPtr pPix) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillCacheExpandRects)(pScrn, fg, bg, rop, + planemask, nBox, + pBox, xorg, yorg, + pPix); +} + +static void XAAStateWrapFillImageWriteRects(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int nBox, BoxPtr pBox, + int xorg, int yorg, PixmapPtr pPix) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillImageWriteRects)(pScrn, rop, + planemask, nBox, pBox, + xorg, yorg, pPix); +} + +static void XAAStateWrapFillSolidSpans(ScrnInfoPtr pScrn, int fg, int rop, + unsigned int planemask, int n, DDXPointPtr points, + int *widths, int fSorted) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillSolidSpans)(pScrn, fg, rop, + planemask, n, points, + widths, fSorted); +} + +static void XAAStateWrapFillMono8x8PatternSpans(ScrnInfoPtr pScrn, int fg, int bg, + int rop, unsigned int planemask, int n, + DDXPointPtr points, int *widths, + int fSorted, int pat0, int pat1, + int xorg, int yorg) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillMono8x8PatternSpans)(pScrn, fg, bg, + rop, planemask, n, + points, widths, + fSorted, pat0, pat1, + xorg, yorg); +} + +static void XAAStateWrapFillColor8x8PatternSpans(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int n, + DDXPointPtr points, int *widths, + int fSorted, XAACacheInfoPtr pCache, + int xorg, int yorg) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillColor8x8PatternSpans)(pScrn, rop, + planemask, n, + points, widths, + fSorted, pCache, + xorg, yorg); +} + +static void XAAStateWrapFillCacheBltSpans(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int n, + DDXPointPtr points, int *widths, + int fSorted, XAACacheInfoPtr pCache, + int xorg, int yorg) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillCacheBltSpans)(pScrn, rop, + planemask, n, + points, widths, + fSorted, pCache, + xorg, yorg); +} + +static void XAAStateWrapFillColorExpandSpans(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int n, + DDXPointPtr points, int *widths, int fSorted, + int xorg, int yorg, PixmapPtr pPix) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillColorExpandSpans)(pScrn, fg, bg, rop, + planemask, n, + points, widths, fSorted, + xorg, yorg, pPix); +} + +static void XAAStateWrapFillCacheExpandSpans(ScrnInfoPtr pScrn, int fg, int bg, int rop, + unsigned int planemask, int n, + DDXPointPtr ppt, int *pwidth, int fSorted, + int xorg, int yorg, PixmapPtr pPix) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->FillCacheExpandSpans)(pScrn, fg, bg, rop, + planemask, n, + ppt, pwidth, fSorted, + xorg, yorg, pPix); +} + +static void XAAStateWrapTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int w, int h, + int skipleft, int startline, + unsigned int **glyphs, + int glyphWidth, int fg, int bg, int rop, + unsigned planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->TEGlyphRenderer)(pScrn, x, y, w, h, + skipleft, startline, + glyphs, + glyphWidth, fg, bg, rop, + planemask); +} + +static void XAAStateWrapNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n, + NonTEGlyphPtr glyphs, BoxPtr pbox, + int fg, int rop, unsigned int planemask) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->NonTEGlyphRenderer)(pScrn, x, y, n, + glyphs, pbox, + fg, rop, planemask); +} + +static void XAAStateWrapWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int rop, + unsigned int planemask, int transparency_color, + int bpp, int depth) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->WritePixmap)(pScrn, x, y, w, h, + src, srcwidth, rop, + planemask, transparency_color, + bpp, depth); +} + +static void XAAStateWrapReadPixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *dst, int dstwidth, int bpp, int depth) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->ReadPixmap)(pScrn, x, y, w, h, + dst, dstwidth, bpp, depth); +} + +static RegionPtr XAAStateWrapCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, + GC *pGC, int srcx, int srcy, int width, int height, + int dstx, int dsty) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->CopyArea)(pSrcDrawable, pDstDrawable, + pGC, srcx, srcy, width, height, + dstx, dsty); +} + +static RegionPtr XAAStateWrapCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long bitPlane) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->CopyPlane)(pSrc, pDst, pGC, + srcx, srcy, width, height, + dstx, dsty, bitPlane); +} + +static void XAAStateWrapPushPixelsSolid(GCPtr pGC, PixmapPtr pBitMap, + DrawablePtr pDrawable, int dx, int dy, int xOrg, + int yOrg) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PushPixelsSolid)(pGC, pBitMap, + pDrawable, dx, dy, xOrg, + yOrg); +} + +static void XAAStateWrapPolyFillRectSolid(DrawablePtr pDraw, GCPtr pGC, int nrectFill, + xRectangle *prectInit) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyFillRectSolid)(pDraw, pGC, nrectFill, + prectInit); +} + +static void XAAStateWrapPolyFillRectStippled(DrawablePtr pDraw, GCPtr pGC, int nrectFill, + xRectangle *prectInit) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyFillRectStippled)(pDraw, pGC, nrectFill, + prectInit); +} + +static void XAAStateWrapPolyFillRectOpaqueStippled(DrawablePtr pDraw, GCPtr pGC, + int nrectFill, xRectangle *prectInit) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyFillRectOpaqueStippled)(pDraw, pGC, + nrectFill, prectInit); +} + +static void XAAStateWrapPolyFillRectTiled(DrawablePtr pDraw, GCPtr pGC, int nrectFill, + xRectangle *prectInit) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyFillRectTiled)(pDraw, pGC, nrectFill, + prectInit); +} + +static void XAAStateWrapFillSpansSolid(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillSpansSolid)(pDraw, pGC, nInit, + ppt, pwidth, fSorted); +} + +static void XAAStateWrapFillSpansStippled(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillSpansStippled)(pDraw, pGC, nInit, + ppt, pwidth, fSorted); +} + +static void XAAStateWrapFillSpansOpaqueStippled(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillSpansOpaqueStippled)(pDraw, pGC, nInit, + ppt, pwidth, fSorted); +} + +static void XAAStateWrapFillSpansTiled(DrawablePtr pDraw, GCPtr pGC, int nInit, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillSpansTiled)(pDraw, pGC, nInit, + ppt, pwidth, fSorted); +} + +static int XAAStateWrapPolyText8TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, + char *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->PolyText8TE)(pDraw, pGC, x, y, count, + chars); +} + +static int XAAStateWrapPolyText16TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count, + unsigned short *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->PolyText16TE)(pDraw, pGC, x, y, count, + chars); +} + +static void XAAStateWrapImageText8TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, char *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ImageText8TE)(pDraw, pGC, x, y, + count, chars); +} + +static void XAAStateWrapImageText16TE(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ImageText16TE)(pDraw, pGC, x, y, + count, chars); +} + +static void XAAStateWrapImageGlyphBltTE(DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ImageGlyphBltTE)(pDrawable, pGC, xInit, + yInit, nglyph, ppci, + pglyphBase); +} + +static void XAAStateWrapPolyGlyphBltTE(DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyGlyphBltTE)(pDrawable, pGC, xInit, + yInit, nglyph, ppci, + pglyphBase); +} + +static int XAAStateWrapPolyText8NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, char *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->PolyText8NonTE)(pDraw, pGC, x, y, + count, chars); +} + +static int XAAStateWrapPolyText16NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->PolyText16NonTE)(pDraw, pGC, x, y, + count, chars); +} + +static void XAAStateWrapImageText8NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, char *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ImageText8NonTE)(pDraw, pGC, x, y, + count, chars); +} + +static void XAAStateWrapImageText16NonTE(DrawablePtr pDraw, GCPtr pGC, int x, int y, + int count, unsigned short *chars) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ImageText16NonTE)(pDraw, pGC, x, y, + count, chars); +} + +static void XAAStateWrapImageGlyphBltNonTE(DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ImageGlyphBltNonTE)(pDrawable, pGC, xInit, + yInit, nglyph, + ppci, pglyphBase); +} + +static void XAAStateWrapPolyGlyphBltNonTE(DrawablePtr pDrawable, GCPtr pGC, int xInit, + int yInit, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyGlyphBltNonTE)(pDrawable, pGC, xInit, + yInit, nglyph, + ppci, pglyphBase); +} + +static void XAAStateWrapPolyRectangleThinSolid(DrawablePtr pDrawable,GCPtr pGC, + int nRectsInit, xRectangle *pRectsInit) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyRectangleThinSolid)(pDrawable, pGC, + nRectsInit, pRectsInit); +} + +static void XAAStateWrapPolylinesWideSolid(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pPts) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolylinesWideSolid)(pDrawable, pGC, mode, + npt, pPts); +} + +static void XAAStateWrapPolylinesThinSolid(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pPts) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolylinesThinSolid)(pDrawable, pGC, mode, + npt, pPts); +} + +static void XAAStateWrapPolySegmentThinSolid(DrawablePtr pDrawable, GCPtr pGC, int nseg, + xSegment *pSeg) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolySegmentThinSolid)(pDrawable, pGC, nseg, + pSeg); +} + +static void XAAStateWrapPolylinesThinDashed(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pPts) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolylinesThinDashed)(pDrawable, pGC, mode, + npt, pPts); +} + +static void XAAStateWrapPolySegmentThinDashed(DrawablePtr pDrawable, GCPtr pGC, int nseg, + xSegment *pSeg) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolySegmentThinDashed)(pDrawable, pGC, nseg, + pSeg); +} + +static void XAAStateWrapFillPolygonSolid(DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr ptsIn) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillPolygonSolid)(pDrawable, pGC, shape, + mode, count, ptsIn); +} + +static void XAAStateWrapFillPolygonStippled(DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr ptsIn) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillPolygonStippled)(pDrawable, pGC, shape, + mode, count, ptsIn); +} + +static void XAAStateWrapFillPolygonOpaqueStippled(DrawablePtr pDrawable, GCPtr pGC, + int shape, int mode, int count, + DDXPointPtr ptsIn) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillPolygonOpaqueStippled)(pDrawable, pGC, + shape, mode, count, + ptsIn); +} + +static void XAAStateWrapFillPolygonTiled(DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr ptsIn) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->FillPolygonTiled)(pDrawable, pGC, shape, + mode, count, ptsIn); +} + +static void XAAStateWrapPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, + xArc *parcs) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PolyFillArcSolid)(pDraw, pGC, narcs, + parcs); +} + +static void XAAStateWrapPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pImage) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->PutImage)(pDraw, pGC, depth, x, y, + w, h, leftPad, format, pImage); +} + +static void XAAStateWrapValidateFillSpans(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidateFillSpans)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidateSetSpans(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidateSetSpans)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePutImage(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePutImage)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidateCopyArea(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidateCopyArea)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidateCopyPlane(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidateCopyPlane)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyPoint(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyPoint)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolylines(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolylines)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolySegment(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolySegment)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyRectangle(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyRectangle)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyArc(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyArc)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidateFillPolygon(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidateFillPolygon)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyFillRect(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyFillRect)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyFillArc(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyFillArc)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyText8(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyText8)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyText16(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyText16)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidateImageText8(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidateImageText8)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidateImageText16(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidateImageText16)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePolyGlyphBlt(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePolyGlyphBlt)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidateImageGlyphBlt(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + (*pStatePriv->ValidateImageGlyphBlt)(pGC, changes, + pDraw); +} + +static void XAAStateWrapValidatePushPixels(GCPtr pGC, unsigned long changes, + DrawablePtr pDraw) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ValidatePushPixels)(pGC, changes, + pDraw); +} + +static void XAAStateWrapComputeDash(GCPtr pGC) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ComputeDash)(pGC); +} + +static void XAAStateWrapInitPixmapCache(ScreenPtr pScreen, RegionPtr areas, + pointer data) +{ + GET_STATEPRIV_SCREEN(pScreen); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->InitPixmapCache)(pScreen, areas, + data); +} + +static void XAAStateWrapClosePixmapCache(ScreenPtr pScreen) +{ + GET_STATEPRIV_SCREEN(pScreen); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->ClosePixmapCache)(pScreen); +} + +static int XAAStateWrapStippledFillChooser(GCPtr pGC) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->StippledFillChooser)(pGC); +} + +static int XAAStateWrapOpaqueStippledFillChooser(GCPtr pGC) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->OpaqueStippledFillChooser)(pGC); +} + +static int XAAStateWrapTiledFillChooser(GCPtr pGC) +{ + GET_STATEPRIV_GC(pGC); + STATE_CHECK_SP(pStatePriv); + + return (*pStatePriv->TiledFillChooser)(pGC); +} + +static XAACacheInfoPtr XAAStateWrapCacheTile(ScrnInfoPtr pScrn, PixmapPtr pPix) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + return (*pStatePriv->CacheTile)(pScrn, pPix); +} + +static XAACacheInfoPtr XAAStateWrapCacheStipple(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, + int bg) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + return (*pStatePriv->CacheStipple)(pScrn, pPix, fg, + bg); +} + +static XAACacheInfoPtr XAAStateWrapCacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + return (*pStatePriv->CacheMonoStipple)(pScrn, pPix); +} + +static XAACacheInfoPtr XAAStateWrapCacheMono8x8Pattern(ScrnInfoPtr pScrn, int pat0, + int pat1) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + return (*pStatePriv->CacheMono8x8Pattern)(pScrn, pat0, + pat1); +} + +static XAACacheInfoPtr XAAStateWrapCacheColor8x8Pattern(ScrnInfoPtr pScrn, PixmapPtr pPix, + int fg, int bg) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + return (*pStatePriv->CacheColor8x8Pattern)(pScrn, pPix, + fg, bg); +} + +static void XAAStateWrapWriteBitmapToCache(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int fg, + int bg) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->WriteBitmapToCache)(pScrn, x, y, w, h, + src, srcwidth, fg, + bg); +} + +static void XAAStateWrapWritePixmapToCache(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int bpp, + int depth) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->WritePixmapToCache)(pScrn, x, y, w, h, + src, srcwidth, bpp, + depth); +} + +static void XAAStateWrapWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, + XAACacheInfoPtr pCache) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->WriteMono8x8PatternToCache)(pScrn, + pCache); +} + +static void XAAStateWrapWriteColor8x8PatternToCache(ScrnInfoPtr pScrn, PixmapPtr pPix, + XAACacheInfoPtr pCache) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + (*pStatePriv->WriteColor8x8PatternToCache)(pScrn, pPix, + pCache); +} + +static void XAAStateWrapGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, + unsigned int format,unsigned long planeMask, + char *pdstLine) +{ + GET_STATEPRIV_SCREEN(pDrawable->pScreen); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->GetImage)(pDrawable, sx, sy, w, h, + format, planeMask, + pdstLine); +} + +static void XAAStateWrapGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, + int *pwidth, int nspans, char *pdstStart) +{ + GET_STATEPRIV_SCREEN(pDrawable->pScreen); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->GetSpans)(pDrawable, wMax, ppt, + pwidth, nspans, pdstStart); +} + +static void XAAStateWrapCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, + RegionPtr prgnSrc) +{ + GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen); + STATE_CHECK_SP(pStatePriv); + + (*pStatePriv->CopyWindow)(pWindow, ptOldOrg, + prgnSrc); +} + +#ifdef RENDER +static Bool XAAStateWrapSetupForCPUToScreenAlphaTexture2(ScrnInfoPtr pScrn, + int op, CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 srcFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, + int alphaPitch, + int width, int height, + int flags) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + return (*pStatePriv->SetupForCPUToScreenAlphaTexture2)(pScrn, op, red, green, + blue, alpha, srcFormat, + dstFormat, alphaPtr, + alphaPitch, width, + height, flags); +} + +static Bool XAAStateWrapSetupForCPUToScreenTexture2(ScrnInfoPtr pScrn, int op, + CARD32 srcFormat, + CARD32 dstFormat, + CARD8 *texPtr, int texPitch, + int width, int height, + int flags) +{ + GET_STATEPRIV_PSCRN(pScrn); + STATE_CHECK_PSCRN(pScrn); + + return (*pStatePriv->SetupForCPUToScreenTexture2)(pScrn, op, srcFormat, + dstFormat, texPtr, texPitch, + width, height, flags); +} +#endif + +/* Setup Function */ +Bool +XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XAAStateWrapPtr pStatePriv; + int i = 0; + + if(!(pStatePriv = xalloc(sizeof(XAAStateWrapRec)))) return FALSE; + dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv); + pStatePriv->RestoreAccelState = infoRec->RestoreAccelState; + pStatePriv->pScrn = pScrn; + + /* Initialize the last screen to -1 so whenever an accel function + * is called the proper state is setup + */ + while(i < pScrn->numEntities) { + xf86SetLastScrnFlag(pScrn->entityList[i], -1); + i++; + } +/* Do the wrapping */ + XAA_STATE_WRAP(Sync); + XAA_STATE_WRAP(SetupForScreenToScreenCopy); + XAA_STATE_WRAP(SetupForSolidFill); + XAA_STATE_WRAP(SetupForSolidLine); + XAA_STATE_WRAP(SetupForDashedLine); + XAA_STATE_WRAP(SetClippingRectangle); + XAA_STATE_WRAP(DisableClipping); + XAA_STATE_WRAP(SetupForMono8x8PatternFill); + XAA_STATE_WRAP(SetupForColor8x8PatternFill); + XAA_STATE_WRAP(SetupForCPUToScreenColorExpandFill); + XAA_STATE_WRAP(SetupForScanlineCPUToScreenColorExpandFill); + XAA_STATE_WRAP(SetupForScreenToScreenColorExpandFill); + XAA_STATE_WRAP(SetupForImageWrite); + XAA_STATE_WRAP(SetupForScanlineImageWrite); + XAA_STATE_WRAP(SetupForImageRead); + XAA_STATE_WRAP(ScreenToScreenBitBlt); + XAA_STATE_WRAP(WriteBitmap); + XAA_STATE_WRAP(FillSolidRects); + XAA_STATE_WRAP(FillMono8x8PatternRects); + XAA_STATE_WRAP(FillColor8x8PatternRects); + XAA_STATE_WRAP(FillCacheBltRects); + XAA_STATE_WRAP(FillColorExpandRects); + XAA_STATE_WRAP(FillCacheExpandRects); + XAA_STATE_WRAP(FillImageWriteRects); + XAA_STATE_WRAP(FillSolidSpans); + XAA_STATE_WRAP(FillMono8x8PatternSpans); + XAA_STATE_WRAP(FillColor8x8PatternSpans); + XAA_STATE_WRAP(FillCacheBltSpans); + XAA_STATE_WRAP(FillColorExpandSpans); + XAA_STATE_WRAP(FillCacheExpandSpans); + XAA_STATE_WRAP(TEGlyphRenderer); + XAA_STATE_WRAP(NonTEGlyphRenderer); + XAA_STATE_WRAP(WritePixmap); + XAA_STATE_WRAP(ReadPixmap); + XAA_STATE_WRAP(CopyArea); + XAA_STATE_WRAP(CopyPlane); + XAA_STATE_WRAP(PushPixelsSolid); + XAA_STATE_WRAP(PolyFillRectSolid); + XAA_STATE_WRAP(PolyFillRectStippled); + XAA_STATE_WRAP(PolyFillRectOpaqueStippled); + XAA_STATE_WRAP(PolyFillRectTiled); + XAA_STATE_WRAP(FillSpansSolid); + XAA_STATE_WRAP(FillSpansStippled); + XAA_STATE_WRAP(FillSpansOpaqueStippled); + XAA_STATE_WRAP(FillSpansTiled); + XAA_STATE_WRAP(PolyText8TE); + XAA_STATE_WRAP(PolyText16TE); + XAA_STATE_WRAP(ImageText8TE); + XAA_STATE_WRAP(ImageText16TE); + XAA_STATE_WRAP(ImageGlyphBltTE); + XAA_STATE_WRAP(PolyGlyphBltTE); + XAA_STATE_WRAP(PolyText8NonTE); + XAA_STATE_WRAP(PolyText16NonTE); + XAA_STATE_WRAP(ImageText8NonTE); + XAA_STATE_WRAP(ImageText16NonTE); + XAA_STATE_WRAP(ImageGlyphBltNonTE); + XAA_STATE_WRAP(PolyGlyphBltNonTE); + XAA_STATE_WRAP(PolyRectangleThinSolid); + XAA_STATE_WRAP(PolylinesWideSolid); + XAA_STATE_WRAP(PolylinesThinSolid); + XAA_STATE_WRAP(PolySegmentThinSolid); + XAA_STATE_WRAP(PolylinesThinDashed); + XAA_STATE_WRAP(PolySegmentThinDashed); + XAA_STATE_WRAP(FillPolygonSolid); + XAA_STATE_WRAP(FillPolygonStippled); + XAA_STATE_WRAP(FillPolygonOpaqueStippled); + XAA_STATE_WRAP(FillPolygonTiled); + XAA_STATE_WRAP(PolyFillArcSolid); + XAA_STATE_WRAP(PutImage); + XAA_STATE_WRAP(ValidateFillSpans); + XAA_STATE_WRAP(ValidateSetSpans); + XAA_STATE_WRAP(ValidatePutImage); + XAA_STATE_WRAP(ValidateCopyArea); + XAA_STATE_WRAP(ValidateCopyPlane); + XAA_STATE_WRAP(ValidatePolyPoint); + XAA_STATE_WRAP(ValidatePolylines); + XAA_STATE_WRAP(ValidatePolySegment); + XAA_STATE_WRAP(ValidatePolyRectangle); + XAA_STATE_WRAP(ValidatePolyArc); + XAA_STATE_WRAP(ValidateFillPolygon); + XAA_STATE_WRAP(ValidatePolyFillRect); + XAA_STATE_WRAP(ValidatePolyFillArc); + XAA_STATE_WRAP(ValidatePolyText8); + XAA_STATE_WRAP(ValidatePolyText16); + XAA_STATE_WRAP(ValidateImageText8); + XAA_STATE_WRAP(ValidateImageText16); + XAA_STATE_WRAP(ValidatePolyGlyphBlt); + XAA_STATE_WRAP(ValidateImageGlyphBlt); + XAA_STATE_WRAP(ValidatePushPixels); + XAA_STATE_WRAP(ComputeDash); + XAA_STATE_WRAP(InitPixmapCache); + XAA_STATE_WRAP(ClosePixmapCache); + XAA_STATE_WRAP(StippledFillChooser); + XAA_STATE_WRAP(OpaqueStippledFillChooser); + XAA_STATE_WRAP(TiledFillChooser); + XAA_STATE_WRAP(CacheTile); + XAA_STATE_WRAP(CacheStipple); + XAA_STATE_WRAP(CacheMonoStipple); + XAA_STATE_WRAP(CacheMono8x8Pattern); + XAA_STATE_WRAP(CacheColor8x8Pattern); + XAA_STATE_WRAP(WriteBitmapToCache); + XAA_STATE_WRAP(WritePixmapToCache); + XAA_STATE_WRAP(WriteMono8x8PatternToCache); + XAA_STATE_WRAP(WriteColor8x8PatternToCache); + XAA_STATE_WRAP(GetImage); + XAA_STATE_WRAP(GetSpans); + XAA_STATE_WRAP(CopyWindow); +#ifdef RENDER + XAA_STATE_WRAP(SetupForCPUToScreenAlphaTexture2); + XAA_STATE_WRAP(SetupForCPUToScreenTexture2); +#endif + return TRUE; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaStipple.c b/xorg-server/hw/xfree86/xaa/xaaStipple.c new file mode 100644 index 000000000..0dd8e9fcf --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaStipple.c @@ -0,0 +1,866 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xaa.h" +#include "xaalocal.h" +#include "xaacexp.h" +#include "xf86.h" + +static CARD32* StipplePowerOfTwo(CARD32*, CARD32*, int, int, int); +static CARD32* StipplePowerOfTwo_Inverted(CARD32*, CARD32*, int, int, int); +static CARD32* StippleUpTo32(CARD32*, CARD32*, int, int, int); +static CARD32* StippleUpTo32_Inverted(CARD32*, CARD32*, int, int, int); +static CARD32* StippleOver32(CARD32*, CARD32*, int, int, int); +static CARD32* StippleOver32_Inverted(CARD32*, CARD32*, int, int, int); + +#ifdef TRIPLE_BITS +#define stipple_scanline_func EXPNAME(XAAStippleScanlineFunc3) +#define stipple_get_scanline_func EXPNAME(XAAGetStippleScanlineFunc3) +#else +#define stipple_scanline_func EXPNAME(XAAStippleScanlineFunc) +#define stipple_get_scanline_func EXPNAME(XAAGetStippleScanlineFunc) +#endif + +StippleScanlineProcPtr stipple_scanline_func[6] = { + StipplePowerOfTwo, + StippleUpTo32, + StippleOver32, + StipplePowerOfTwo_Inverted, + StippleUpTo32_Inverted, + StippleOver32_Inverted +}; + +StippleScanlineProcPtr *stipple_get_scanline_func(void) { + return stipple_scanline_func; +} + +#ifdef FIXEDBASE +# define DEST(i) *dest +# define RETURN(i) return(dest) +#else +# define DEST(i) dest[i] +# define RETURN(i) return(dest + i) +#endif + + +/* TRIPLE_BITS pattern expansion */ +#ifdef TRIPLE_BITS +#define EXPAND_PAT \ + CARD32 pat1 = byte_expand3[pat & 0xFF], \ + pat2 = byte_expand3[(pat & 0xFF00) >> 8], \ + pat3 = byte_expand3[(pat & 0xFF0000) >> 16], \ + pat4 = byte_expand3[(pat & 0xFF000000) >> 24], \ + patA = pat1 | (pat2 << 24), \ + patB = (pat2 >> 8) | (pat3 << 16), \ + patC = (pat3 >> 16) | (pat4 << 8) +#ifdef FIXED_BASE +#define WRITE_PAT1 { \ + *dest = patA; } +#define WRITE_PAT2 { \ + *dest = patA; \ + *dest = patB; } +#define WRITE_PAT3 { \ + *dest = patA; \ + *dest = patB; \ + *dest = patC; } +#else +#define WRITE_PAT1 { \ + *(dest++) = patA; } +#define WRITE_PAT2 { \ + *(dest) = patA; \ + *(dest + 1) = patB; \ + dest += 2; } +#define WRITE_PAT3 { \ + *(dest) = patA; \ + *(dest + 1) = patB; \ + *(dest + 2) = patC; \ + dest += 3; } +#endif +#endif + + +#if !defined(FIXEDBASE) && !defined(MSBFIRST) && !defined(TRIPLE_BITS) + +unsigned int XAAShiftMasks[32] = { + /* gcc is rather pedantic about SHIFT_R(0xFFFFFFFF,32) */ + 0x00000000 , SHIFT_R(0xFFFFFFFF,31), + SHIFT_R(0xFFFFFFFF,30), SHIFT_R(0xFFFFFFFF,29), + SHIFT_R(0xFFFFFFFF,28), SHIFT_R(0xFFFFFFFF,27), + SHIFT_R(0xFFFFFFFF,26), SHIFT_R(0xFFFFFFFF,25), + SHIFT_R(0xFFFFFFFF,24), SHIFT_R(0xFFFFFFFF,23), + SHIFT_R(0xFFFFFFFF,22), SHIFT_R(0xFFFFFFFF,21), + SHIFT_R(0xFFFFFFFF,20), SHIFT_R(0xFFFFFFFF,19), + SHIFT_R(0xFFFFFFFF,18), SHIFT_R(0xFFFFFFFF,17), + SHIFT_R(0xFFFFFFFF,16), SHIFT_R(0xFFFFFFFF,15), + SHIFT_R(0xFFFFFFFF,14), SHIFT_R(0xFFFFFFFF,13), + SHIFT_R(0xFFFFFFFF,12), SHIFT_R(0xFFFFFFFF,11), + SHIFT_R(0xFFFFFFFF,10), SHIFT_R(0xFFFFFFFF,9), + SHIFT_R(0xFFFFFFFF,8), SHIFT_R(0xFFFFFFFF,7), + SHIFT_R(0xFFFFFFFF,6), SHIFT_R(0xFFFFFFFF,5), + SHIFT_R(0xFFFFFFFF,4), SHIFT_R(0xFFFFFFFF,3), + SHIFT_R(0xFFFFFFFF,2), SHIFT_R(0xFFFFFFFF,1) +}; + +#endif + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAFillColorExpandRects3)( +#else +EXPNAME(XAAFillColorExpandRects)( +#endif + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32 *base; + Bool TwoPass = FALSE, FirstPass = TRUE; + StippleScanlineProcPtr StippleFunc, FirstFunc, SecondFunc; + int stipplewidth = pPix->drawable.width; + int stippleheight = pPix->drawable.height; + int srcwidth = pPix->devKind; + int dwords, srcy, srcx, funcNo = 2, h; + unsigned char *src = (unsigned char*)pPix->devPrivate.ptr; + unsigned char *srcp; + int flag; + + if(stipplewidth <= 32) { + if(stipplewidth & (stipplewidth - 1)) + funcNo = 1; + else + funcNo = 0; + } + StippleFunc = stipple_scanline_func[funcNo]; + SecondFunc = stipple_scanline_func[funcNo]; + FirstFunc = stipple_scanline_func[funcNo + 3]; + +#ifdef TRIPLE_BITS + if((bg == -1) || + (!(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) && + (!(infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) || + (CHECK_RGB_EQUAL(bg))))) { +#else + if((bg == -1) || + !(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) { +#endif + /* one pass */ + } else if((rop == GXcopy) && infoRec->FillSolidRects) { + /* one pass but we fill background rects first */ + (*infoRec->FillSolidRects)(pScrn, bg, rop, planemask, nBox, pBox); + bg = -1; + } else { + /* gotta do two passes */ + TwoPass = TRUE; + } + + if(!TwoPass) + (*infoRec->SetupForCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + while(nBox--) { +#ifdef TRIPLE_BITS + dwords = (3 * (pBox->x2 - pBox->x1) + 31) >> 5; +#else + dwords = (pBox->x2 - pBox->x1 + 31) >> 5; +#endif + +SECOND_PASS: + if(TwoPass) { + (*infoRec->SetupForCPUToScreenColorExpandFill)(pScrn, + (FirstPass) ? bg : fg, -1, rop, planemask); + StippleFunc = (FirstPass) ? FirstFunc : SecondFunc; + } + + h = pBox->y2 - pBox->y1; + flag = (infoRec->CPUToScreenColorExpandFillFlags + & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01); + + (*infoRec->SubsequentCPUToScreenColorExpandFill)( + pScrn, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, h, 0); + + base = (CARD32*)infoRec->ColorExpandBase; + + srcy = (pBox->y1 - yorg) % stippleheight; + if(srcy < 0) srcy += stippleheight; + srcx = (pBox->x1 - xorg) % stipplewidth; + if(srcx < 0) srcx += stipplewidth; + + srcp = (srcwidth * srcy) + src; + +#ifndef FIXEDBASE + if((dwords * h) <= infoRec->ColorExpandRange) { + while(h--) { + base = (*StippleFunc)( + base, (CARD32*)srcp, srcx, stipplewidth, dwords); + srcy++; + srcp += srcwidth; + if (srcy >= stippleheight) { + srcy = 0; + srcp = src; + } + } + } else +#endif + while(h--) { + (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords); + srcy++; + srcp += srcwidth; + if (srcy >= stippleheight) { + srcy = 0; + srcp = src; + } + } + + if (flag) { + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + + if(TwoPass) { + if(FirstPass) { + FirstPass = FALSE; + goto SECOND_PASS; + } else FirstPass = TRUE; + } + + pBox++; + } + + if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + + + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAFillColorExpandSpans3)( +#else +EXPNAME(XAAFillColorExpandSpans)( +#endif + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32 *base; + Bool TwoPass = FALSE, FirstPass = TRUE; + StippleScanlineProcPtr StippleFunc, FirstFunc, SecondFunc; + int stipplewidth = pPix->drawable.width; + int stippleheight = pPix->drawable.height; + int dwords, srcy, srcx, funcNo = 2; + unsigned char *srcp; + + if(stipplewidth <= 32) { + if(stipplewidth & (stipplewidth - 1)) + funcNo = 1; + else + funcNo = 0; + } + StippleFunc = stipple_scanline_func[funcNo]; + SecondFunc = stipple_scanline_func[funcNo]; + FirstFunc = stipple_scanline_func[funcNo + 3]; + +#ifdef TRIPLE_BITS + if((bg == -1) || + (!(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) && + (!(infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) || + (CHECK_RGB_EQUAL(bg))))) { +#else + if((bg == -1) || + !(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) { +#endif + /* one pass */ + } else if((rop == GXcopy) && infoRec->FillSolidSpans) { + /* one pass but we fill background rects first */ + (*infoRec->FillSolidSpans)( + pScrn, bg, rop, planemask, n, ppt, pwidth, fSorted); + bg = -1; + } else { + /* gotta do two passes */ + TwoPass = TRUE; + } + + if(!TwoPass) + (*infoRec->SetupForCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + while(n--) { +#ifdef TRIPLE_BITS + dwords = (3 * *pwidth + 31) >> 5; +#else + dwords = (*pwidth + 31) >> 5; +#endif + + srcy = (ppt->y - yorg) % stippleheight; + if(srcy < 0) srcy += stippleheight; + srcx = (ppt->x - xorg) % stipplewidth; + if(srcx < 0) srcx += stipplewidth; + + srcp = (pPix->devKind * srcy) + (unsigned char*)pPix->devPrivate.ptr; + +SECOND_PASS: + if(TwoPass) { + (*infoRec->SetupForCPUToScreenColorExpandFill)(pScrn, + (FirstPass) ? bg : fg, -1, rop, planemask); + StippleFunc = (FirstPass) ? FirstFunc : SecondFunc; + } + + (*infoRec->SubsequentCPUToScreenColorExpandFill)(pScrn, ppt->x, ppt->y, + *pwidth, 1, 0); + + base = (CARD32*)infoRec->ColorExpandBase; + + (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords); + + if((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD) + && (dwords & 0x01)) { + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + + if(TwoPass) { + if(FirstPass) { + FirstPass = FALSE; + goto SECOND_PASS; + } else FirstPass = TRUE; + } + + ppt++; pwidth++; + } + + if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + + +#ifndef FIXEDBASE + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAFillScanlineColorExpandRects3)( +#else +EXPNAME(XAAFillScanlineColorExpandRects)( +#endif + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32 *base; + Bool TwoPass = FALSE, FirstPass = TRUE; + StippleScanlineProcPtr StippleFunc, FirstFunc, SecondFunc; + int stipplewidth = pPix->drawable.width; + int stippleheight = pPix->drawable.height; + int srcwidth = pPix->devKind; + int dwords, srcy, srcx, funcNo = 2, bufferNo, h; + unsigned char *src = pPix->devPrivate.ptr; + unsigned char *srcp; + + if(stipplewidth <= 32) { + if(stipplewidth & (stipplewidth - 1)) + funcNo = 1; + else + funcNo = 0; + } + StippleFunc = stipple_scanline_func[funcNo]; + SecondFunc = stipple_scanline_func[funcNo]; + FirstFunc = stipple_scanline_func[funcNo + 3]; + +#ifdef TRIPLE_BITS + if((bg == -1) || + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) && + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) || + (CHECK_RGB_EQUAL(bg))))) { +#else + if((bg == -1) || + !(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) { +#endif + /* one pass */ + } else if((rop == GXcopy) && infoRec->FillSolidRects) { + /* one pass but we fill background rects first */ + (*infoRec->FillSolidRects)(pScrn, bg, rop, planemask, nBox, pBox); + bg = -1; + } else { + /* gotta do two passes */ + TwoPass = TRUE; + } + + if(!TwoPass) + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + while(nBox--) { +#ifdef TRIPLE_BITS + dwords = (3 * (pBox->x2 - pBox->x1) + 31) >> 5; +#else + dwords = (pBox->x2 - pBox->x1 + 31) >> 5; +#endif + +SECOND_PASS: + if(TwoPass) { + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, + (FirstPass) ? bg : fg, -1, rop, planemask); + StippleFunc = (FirstPass) ? FirstFunc : SecondFunc; + } + + h = pBox->y2 - pBox->y1; + + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, pBox->x1, pBox->y1, pBox->x2 - pBox->x1, h, 0); + + bufferNo = 0; + + srcy = (pBox->y1 - yorg) % stippleheight; + if(srcy < 0) srcy += stippleheight; + srcx = (pBox->x1 - xorg) % stipplewidth; + if(srcx < 0) srcx += stipplewidth; + + srcp = (srcwidth * srcy) + src; + + while(h--) { + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords); + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + srcy++; + srcp += srcwidth; + if (srcy >= stippleheight) { + srcy = 0; + srcp = src; + } + } + + if(TwoPass) { + if(FirstPass) { + FirstPass = FALSE; + goto SECOND_PASS; + } else FirstPass = TRUE; + } + + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + +void +#ifdef TRIPLE_BITS +EXPNAME(XAAFillScanlineColorExpandSpans3)( +#else +EXPNAME(XAAFillScanlineColorExpandSpans)( +#endif + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32 *base; + Bool TwoPass = FALSE, FirstPass = TRUE; + StippleScanlineProcPtr StippleFunc, FirstFunc, SecondFunc; + int stipplewidth = pPix->drawable.width; + int stippleheight = pPix->drawable.height; + int dwords, srcy, srcx, funcNo = 2; + unsigned char *srcp; + + if(stipplewidth <= 32) { + if(stipplewidth & (stipplewidth - 1)) + funcNo = 1; + else + funcNo = 0; + } + StippleFunc = stipple_scanline_func[funcNo]; + SecondFunc = stipple_scanline_func[funcNo]; + FirstFunc = stipple_scanline_func[funcNo + 3]; + +#ifdef TRIPLE_BITS + if((bg == -1) || + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) && + (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) || + (CHECK_RGB_EQUAL(bg))))) { +#else + if((bg == -1) || + !(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) { +#endif + /* one pass */ + } else if((rop == GXcopy) && infoRec->FillSolidSpans) { + /* one pass but we fill background rects first */ + (*infoRec->FillSolidSpans)( + pScrn, bg, rop, planemask, n, ppt, pwidth, fSorted); + bg = -1; + } else { + /* gotta do two passes */ + TwoPass = TRUE; + } + + if(!TwoPass) + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + + while(n--) { +#ifdef TRIPLE_BITS + dwords = (3 * *pwidth + 31) >> 5; +#else + dwords = (*pwidth + 31) >> 5; +#endif + + srcy = (ppt->y - yorg) % stippleheight; + if(srcy < 0) srcy += stippleheight; + srcx = (ppt->x - xorg) % stipplewidth; + if(srcx < 0) srcx += stipplewidth; + + srcp = (pPix->devKind * srcy) + (unsigned char*)pPix->devPrivate.ptr; + +SECOND_PASS: + if(TwoPass) { + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, + (FirstPass) ? bg : fg, -1, rop, planemask); + StippleFunc = (FirstPass) ? FirstFunc : SecondFunc; + } + + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, ppt->x, ppt->y, *pwidth, 1, 0); + + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[0]; + + (*StippleFunc)(base, (CARD32*)srcp, srcx, stipplewidth, dwords); + (*infoRec->SubsequentColorExpandScanline)(pScrn, 0); + + if(TwoPass) { + if(FirstPass) { + FirstPass = FALSE; + goto SECOND_PASS; + } else FirstPass = TRUE; + } + + ppt++; pwidth++; + } + + SET_SYNC_FLAG(infoRec); +} + +#endif + +static CARD32 * +StipplePowerOfTwo( + CARD32* dest, CARD32* src, + int shift, int width, int dwords +){ + CARD32 pat = *src; + if(width < 32) { + pat &= XAAShiftMasks[width]; + while(width < 32) { + pat |= SHIFT_L(pat,width); + width <<= 1; + } + } + + if(shift) + pat = SHIFT_R(pat,shift) | SHIFT_L(pat,32 - shift); + +#ifdef MSBFIRST + pat = SWAP_BITS_IN_BYTES(pat); +#endif + +#ifdef TRIPLE_BITS + { + EXPAND_PAT; + + while(dwords >= 3) { + WRITE_PAT3; + dwords -= 3; + } + if (dwords == 2) { + WRITE_PAT2; + } else if (dwords == 1) { + WRITE_PAT1; + } + + return dest; + } +#else /* TRIPLE_BITS */ + while(dwords >= 4) { + DEST(0) = pat; + DEST(1) = pat; + DEST(2) = pat; + DEST(3) = pat; + dwords -= 4; +#ifndef FIXEDBASE + dest += 4; +#endif + } + + if(!dwords) return dest; + DEST(0) = pat; + if(dwords == 1) RETURN(1); + DEST(1) = pat; + if(dwords == 2) RETURN(2); + DEST(2) = pat; + RETURN(3); +#endif /* TRIPLE_BITS */ +} + +static CARD32 * +StipplePowerOfTwo_Inverted( + CARD32* dest, CARD32* src, + int shift, int width, int dwords +){ + CARD32 pat = *src; + if(width < 32) { + pat &= XAAShiftMasks[width]; + while(width < 32) { + pat |= SHIFT_L(pat,width); + width <<= 1; + } + } + + if(shift) + pat = SHIFT_R(pat,shift) | SHIFT_L(pat,32 - shift); + +#ifdef MSBFIRST + pat = SWAP_BITS_IN_BYTES(pat); +#endif + + pat = ~pat; + +#ifdef TRIPLE_BITS + { + EXPAND_PAT; + + while(dwords >= 3) { + WRITE_PAT3; + dwords -= 3; + } + if (dwords == 2) { + WRITE_PAT2; + } else if (dwords == 1) { + WRITE_PAT1; + } + + return dest; + } +#else /* TRIPLE_BITS */ + while(dwords >= 4) { + DEST(0) = pat; + DEST(1) = pat; + DEST(2) = pat; + DEST(3) = pat; + dwords -= 4; +#ifndef FIXEDBASE + dest += 4; +#endif + } + + if(!dwords) return dest; + DEST(0) = pat; + if(dwords == 1) RETURN(1); + DEST(1) = pat; + if(dwords == 2) RETURN(2); + DEST(2) = pat; + RETURN(3); +#endif /* TRIPLE_BITS */ +} + + +static CARD32 * +StippleUpTo32( + CARD32* base, CARD32* src, + int shift, int width, int dwords +){ + CARD32 pat = *src & XAAShiftMasks[width]; + + while(width <= 15) { + pat |= SHIFT_L(pat,width); + width <<= 1; + } + pat |= SHIFT_L(pat,width); + + while(dwords--) { + CARD32 bits = SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift); +#ifdef TRIPLE_BITS + if(dwords >= 2) { + WRITE_BITS3(bits); + dwords -= 2; + } else if(dwords > 0) { + WRITE_BITS2(bits); + dwords--; + } else { + WRITE_BITS1(bits); + } +#else + WRITE_BITS(bits); +#endif + + shift += 32; + shift %= width; + } + return base; +} + + +static CARD32 * +StippleUpTo32_Inverted( + CARD32* base, CARD32* src, + int shift, int width, int dwords +){ + CARD32 pat = *src & XAAShiftMasks[width]; + + while(width <= 15) { + pat |= SHIFT_L(pat,width); + width <<= 1; + } + pat |= SHIFT_L(pat,width); + + while(dwords--) { + CARD32 bits = ~(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift)); +#ifdef TRIPLE_BITS + if(dwords >= 2) { + WRITE_BITS3(bits); + dwords -= 2; + } else if(dwords > 0) { + WRITE_BITS2(bits); + dwords--; + } else { + WRITE_BITS1(bits); + } +#else + WRITE_BITS(bits); +#endif + + shift += 32; + shift %= width; + } + return base; +} + + +static CARD32 * +StippleOver32( + CARD32* base, CARD32* src, + int offset, int width, int dwords +){ + CARD32* srcp; + CARD32 bits; + int bitsleft, shift, usable; + + while(dwords--) { + bitsleft = width - offset; + srcp = src + (offset >> 5); + shift = offset & 31; + usable = 32 - shift; + + if(bitsleft < 32) { + if(bitsleft <= usable) { + bits = SHIFT_L(*src,bitsleft) | + (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft]); + } else { + bits = SHIFT_L(*src,bitsleft) | + (SHIFT_L(srcp[1],usable) & XAAShiftMasks[bitsleft]) | + (SHIFT_R(*srcp,shift) & XAAShiftMasks[usable]); + } + } + else if(shift) + bits = SHIFT_R(*srcp,shift) | SHIFT_L(srcp[1],usable); + else + bits = *srcp; + +#ifdef TRIPLE_BITS + if(dwords >= 2) { + WRITE_BITS3(bits); + dwords -= 2; + } else if(dwords > 0) { + WRITE_BITS2(bits); + dwords--; + } else { + WRITE_BITS1(bits); + } +#else + WRITE_BITS(bits); +#endif + + offset += 32; + offset %= width; + } + return base; +} + + +static CARD32 * +StippleOver32_Inverted( + CARD32* base, CARD32* src, + int offset, int width, int dwords +){ + CARD32* srcp; + CARD32 bits; + int bitsleft, shift, usable; + + while(dwords--) { + bitsleft = width - offset; + srcp = src + (offset >> 5); + shift = offset & 31; + usable = 32 - shift; + + if(bitsleft < 32) { + if(bitsleft <= usable) { + bits = SHIFT_L(*src,bitsleft) | + (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft]); + } else { + bits = SHIFT_L(*src,bitsleft) | + (SHIFT_L(srcp[1],usable) & XAAShiftMasks[bitsleft]) | + (SHIFT_R(*srcp,shift) & XAAShiftMasks[usable]); + } + } + else if(shift) + bits = SHIFT_R(*srcp,shift) | SHIFT_L(srcp[1],usable); + else + bits = *srcp; + + bits = ~bits; + +#ifdef TRIPLE_BITS + if(dwords >= 2) { + WRITE_BITS3(bits); + dwords -= 2; + } else if(dwords > 0) { + WRITE_BITS2(bits); + dwords--; + } else { + WRITE_BITS1(bits); + } +#else + WRITE_BITS(bits); +#endif + + offset += 32; + offset %= width; + } + return base; +} diff --git a/xorg-server/hw/xfree86/xaa/xaaTEGlyph.c b/xorg-server/hw/xfree86/xaa/xaaTEGlyph.c new file mode 100644 index 000000000..cb60266ea --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaTEGlyph.c @@ -0,0 +1,1077 @@ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xaa.h" +#include "xaalocal.h" +#include "xaacexp.h" +#include "xf86.h" + +/* scanline function for TRIPLE_BITS_24BPP */ +static CARD32 *DrawTextScanline3(CARD32 *base, CARD32 *mem, int width); + +/* Loop unrolled functions for common font widths */ +static CARD32 *DrawTETextScanlineGeneric(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth7(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth10(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth12(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth14(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth16(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth18(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth24(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); + + +#ifdef USEASSEMBLER +# ifdef FIXEDBASE +# ifdef MSBFIRST +CARD32 *DrawTETextScanlineWidth6PMSBFirstFixedBase(CARD32 *base, + unsigned int **glyphp, int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth8PMSBFirstFixedBase(CARD32 *base, + unsigned int **glyphp, int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth9PMSBFirstFixedBase(CARD32 *base, + unsigned int **glyphp, int line, int width, int glyphwidth); +# else +CARD32 *DrawTETextScanlineWidth6PLSBFirstFixedBase(CARD32 *base, + unsigned int **glyphp, int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth8PLSBFirstFixedBase(CARD32 *base, + unsigned int **glyphp, int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth9PLSBFirstFixedBase(CARD32 *base, + unsigned int **glyphp, int line, int width, int glyphwidth); +# endif +# else +# ifdef MSBFIRST +CARD32 *DrawTETextScanlineWidth6PMSBFirst(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth8PMSBFirst(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth9PMSBFirst(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +# else +CARD32 *DrawTETextScanlineWidth6PLSBFirst(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth8PLSBFirst(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +CARD32 *DrawTETextScanlineWidth9PLSBFirst(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +# endif +# endif +#else +static CARD32 *DrawTETextScanlineWidth6(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth8(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +static CARD32 *DrawTETextScanlineWidth9(CARD32 *base, unsigned int **glyphp, + int line, int width, int glyphwidth); +#endif + +#define glyph_scanline_func EXPNAME(XAAGlyphScanlineFunc) +#define glyph_get_scanline_func EXPNAME(XAAGetGlyphScanlineFunc) + + +GlyphScanlineFuncPtr glyph_scanline_func[32] = { + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric, + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric, + DrawTETextScanlineGeneric, +#ifdef USEASSEMBLER +# ifdef FIXEDBASE +# ifdef MSBFIRST + DrawTETextScanlineWidth6PMSBFirstFixedBase, + DrawTETextScanlineWidth7, + DrawTETextScanlineWidth8PMSBFirstFixedBase, + DrawTETextScanlineWidth9PMSBFirstFixedBase, +# else + DrawTETextScanlineWidth6PLSBFirstFixedBase, + DrawTETextScanlineWidth7, + DrawTETextScanlineWidth8PLSBFirstFixedBase, + DrawTETextScanlineWidth9PLSBFirstFixedBase, +# endif +# else +# ifdef MSBFIRST + DrawTETextScanlineWidth6PMSBFirst, + DrawTETextScanlineWidth7, + DrawTETextScanlineWidth8PMSBFirst, + DrawTETextScanlineWidth9PMSBFirst, +# else + DrawTETextScanlineWidth6PLSBFirst, + DrawTETextScanlineWidth7, + DrawTETextScanlineWidth8PLSBFirst, + DrawTETextScanlineWidth9PLSBFirst, +# endif +# endif +#else + DrawTETextScanlineWidth6, DrawTETextScanlineWidth7, + DrawTETextScanlineWidth8, DrawTETextScanlineWidth9, +#endif + DrawTETextScanlineWidth10, + DrawTETextScanlineGeneric, DrawTETextScanlineWidth12, + DrawTETextScanlineGeneric, DrawTETextScanlineWidth14, + DrawTETextScanlineGeneric, DrawTETextScanlineWidth16, + DrawTETextScanlineGeneric, DrawTETextScanlineWidth18, + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric, + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric, + DrawTETextScanlineGeneric, DrawTETextScanlineWidth24, + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric, + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric, + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric, + DrawTETextScanlineGeneric, DrawTETextScanlineGeneric +}; + +GlyphScanlineFuncPtr *glyph_get_scanline_func(void) { + return glyph_scanline_func; +} + + +/******************************************************************** + + Here we have TEGlyphRenders for a bunch of different color + expansion types. The driver may provide its own renderer, but + this is the default one which renders using lower-level primitives + exported by the chipset driver. + +********************************************************************/ + +/* This gets built for MSBFIRST or LSBFIRST with FIXEDBASE or not. + A total of 4 versions */ + +void +EXPNAME(XAATEGlyphRenderer)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32* base; + GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1]; + int dwords = 0; + + if((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + bg = -1; + } + + (*infoRec->SetupForCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + if(skipleft && + (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) || + (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) && + (skipleft > x)))) { + /* draw the first character only */ + + int count = h, line = startline; + int width = glyphWidth - skipleft; + + if(width > w) width = w; + + (*infoRec->SubsequentCPUToScreenColorExpandFill)( + pScrn, x, y, width, h, 0); + + base = (CARD32*)infoRec->ColorExpandBase; + + while(count--) { + register CARD32 tmp = SHIFT_R(glyphs[0][line++],skipleft); + WRITE_BITS(tmp); + } + + w -= width; + if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) && + ((((width + 31) >> 5) * h) & 1)) { + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + if(!w) goto THE_END; + glyphs++; + x += width; + skipleft = 0; /* nicely aligned again */ + } + + w += skipleft; + x -= skipleft; + dwords = ((w + 31) >> 5) * h; + + (*infoRec->SubsequentCPUToScreenColorExpandFill)( + pScrn, x, y, w, h, skipleft); + + base = (CARD32*)infoRec->ColorExpandBase; + +#ifndef FIXEDBASE + if((((w + 31) >> 5) * h) <= infoRec->ColorExpandRange) + while(h--) { + base = (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth); + } + else +#endif + while(h--) { + (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth); + } + + if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) && + (dwords & 1)) { + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + +THE_END: + + if(infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + +/******************************************************************** + + This is the GlyphRenderer for TRIPLE_BITS_24BPP. It renders to a buffer + with the non FIXEDBASE LSB_FIRST code before tripling, and possibly + reversing the bits and sending them to the screen + +********************************************************************/ + +void +EXPNAME(XAATEGlyphRenderer3)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + CARD32 *base, *mem; + GlyphScanlineFuncPtr GlyphFunc = XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1]; + int dwords = 0; + + if((bg != -1) && + ((infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY) || + ((infoRec->TEGlyphRendererFlags & RGB_EQUAL) && + (!CHECK_RGB_EQUAL(bg))))) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + bg = -1; + } + + (*infoRec->SetupForCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + if(skipleft) { + /* draw the first character only */ + + int count = h, line = startline; + int width = glyphWidth - skipleft; + CARD32 bits; + + if(width > w) width = w; + (*infoRec->SubsequentCPUToScreenColorExpandFill)( + pScrn, x, y, width, h, 0); + + base = (CARD32*)infoRec->ColorExpandBase; + + while(count--) { + bits = SHIFT_R(glyphs[0][line++],skipleft); + if (width >= 22) { + WRITE_BITS3(bits); + } else if (width >= 11) { + WRITE_BITS2(bits); + } else { + WRITE_BITS1(bits); + } + } + + w -= width; + if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) && + ((((3 * width + 31) >> 5) * h) & 1)) { + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + if(!w) goto THE_END; + glyphs++; + x += width; + skipleft = 0; /* nicely aligned again */ + } + + dwords = ((3 * w + 31) >> 5) * h; + mem = (CARD32*)xalloc(((w + 31) >> 3) * sizeof(char)); + if (!mem) return; + + (*infoRec->SubsequentCPUToScreenColorExpandFill)(pScrn, x, y, w, h, 0); + + base = (CARD32*)infoRec->ColorExpandBase; + +# ifndef FIXEDBASE + if((((3 * w + 31) >> 5) * h) <= infoRec->ColorExpandRange) + while(h--) { + (*GlyphFunc)(mem, glyphs, startline++, w, glyphWidth); + base = DrawTextScanline3(base, mem, w); + } + else +# endif + while(h--) { + (*GlyphFunc)(mem, glyphs, startline++, w, glyphWidth); + DrawTextScanline3(base, mem, w); + } + + xfree(mem); + + if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) && + (dwords & 1)) { + base = (CARD32*)infoRec->ColorExpandBase; + base[0] = 0x00000000; + } + +THE_END: + + if(infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + + +#ifndef FIXEDBASE +/* Scanline version of above gets built for LSBFIRST and MSBFIRST */ + +void +EXPNAME(XAATEGlyphRendererScanline)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int bufferNo; + CARD32* base; + GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1]; + + if((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + bg = -1; + } + + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + if(skipleft && + (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) || + (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) && + (skipleft > x)))) { + /* draw the first character only */ + + int count = h, line = startline; + int width = glyphWidth - skipleft; + + if(width > w) width = w; + + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, x, y, width, h, 0); + + bufferNo = 0; + + while(count--) { + register CARD32 tmp = SHIFT_R(glyphs[0][line++],skipleft); + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + WRITE_BITS(tmp); + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + } + + w -= width; + if(!w) goto THE_END; + glyphs++; + x += width; + skipleft = 0; /* nicely aligned again */ + } + + w += skipleft; + x -= skipleft; + + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, x, y, w, h, skipleft); + + bufferNo = 0; + + while(h--) { + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth); + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + } + +THE_END: + + SET_SYNC_FLAG(infoRec); +} + +void +EXPNAME(XAATEGlyphRendererScanline3)( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int bufferNo; + CARD32 *base, *mem; + GlyphScanlineFuncPtr GlyphFunc = XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1]; + + if((bg != -1) && + ((infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY) || + ((infoRec->TEGlyphRendererFlags & RGB_EQUAL) && + (!CHECK_RGB_EQUAL(bg))))) { + (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask); + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + bg = -1; + } + + (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)( + pScrn, fg, bg, rop, planemask); + + if(skipleft) { + /* draw the first character only */ + + int count = h, line = startline; + int width = glyphWidth - skipleft; + CARD32 bits; + + if(width > w) width = w; + + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, x, y, width, h, 0); + + bufferNo = 0; + + while(count--) { + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + bits = SHIFT_R(glyphs[0][line++],skipleft); + if (width >= 22) { + WRITE_BITS3(bits); + } else if (width >= 11) { + WRITE_BITS2(bits); + } else { + WRITE_BITS1(bits); + } + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + } + + w -= width; + if(!w) goto THE_END; + glyphs++; + x += width; + skipleft = 0; /* nicely aligned again */ + } + + w += skipleft; + x -= skipleft; + mem = (CARD32*)xalloc(((w + 31) >> 3) * sizeof(char)); + if (!mem) return; + + (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( + pScrn, x, y, w, h, skipleft); + + bufferNo = 0; + + while(h--) { + base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; + (*GlyphFunc)(mem, glyphs, startline++, w, glyphWidth); + DrawTextScanline3(base, mem, w); + (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); + if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) + bufferNo = 0; + } + + xfree(mem); + +THE_END: + + SET_SYNC_FLAG(infoRec); +} + +#endif + + + +/******************************************************************** + + TRIPLE_BITS_24BPP scanline rendering code. + +********************************************************************/ + + + +static CARD32* +DrawTextScanline3( + CARD32 *base, + CARD32 *mem, + int width ) +{ + + while(width > 32) { + WRITE_BITS3(*mem); + mem++; + width -= 32; + } + if(width) { + if (width >= 22) { + WRITE_BITS3(*mem); + } else if (width >= 11) { + WRITE_BITS2(*mem); + } else { + WRITE_BITS1(*mem); + } + } + + return base; +} + + +/******************************************************************** + + Generic TE scanline rendering code. + +********************************************************************/ + + + +static CARD32* +DrawTETextScanlineGeneric( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + CARD32 bits = (*glyphp)[line]; + int shift = glyphwidth; + + while(width > 32) { + while(shift < 32) { + glyphp++; + bits |= SHIFT_L((*glyphp)[line], shift); + shift += glyphwidth; + } + WRITE_BITS(bits); + shift &= 31; + if(shift) + bits = SHIFT_R((*glyphp)[line],(glyphwidth - shift)); + else bits = 0; + width -= 32; + } + + if(width) { + width -= shift; + while(width > 0) { + glyphp++; + bits |= SHIFT_L((*glyphp)[line],shift); + shift += glyphwidth; + width -= glyphwidth; + } + WRITE_BITS(bits); + } + + return base; +} + + +/******************************************************************** + + Loop unrolled TE font scanline rendering code + +********************************************************************/ + + +#ifndef USEASSEMBLER +static CARD32* +DrawTETextScanlineWidth6( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],6); + bits |= SHIFT_L(glyphp[2][line],12); + bits |= SHIFT_L(glyphp[3][line],18); + bits |= SHIFT_L(glyphp[4][line],24); + bits |= SHIFT_L(glyphp[5][line],30); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[5][line],2); + bits |= SHIFT_L(glyphp[6][line],4); + bits |= SHIFT_L(glyphp[7][line],10); + bits |= SHIFT_L(glyphp[8][line],16); + bits |= SHIFT_L(glyphp[9][line],22); + bits |= SHIFT_L(glyphp[10][line],28); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[10][line],4); + bits |= SHIFT_L(glyphp[11][line],2); + bits |= SHIFT_L(glyphp[12][line],8); + bits |= SHIFT_L(glyphp[13][line],14); + bits |= SHIFT_L(glyphp[14][line],20); + bits |= SHIFT_L(glyphp[15][line],26); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); +#ifndef FIXEDBASE + base += 3; +#endif + width -= 96; + glyphp += 16; + } + return base; +} +#endif + +static CARD32* +DrawTETextScanlineWidth7( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],7); + bits |= SHIFT_L(glyphp[2][line],14); + bits |= SHIFT_L(glyphp[3][line],21); + bits |= SHIFT_L(glyphp[4][line],28); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[4][line],4); + bits |= SHIFT_L(glyphp[5][line],3); + bits |= SHIFT_L(glyphp[6][line],10); + bits |= SHIFT_L(glyphp[7][line],17); + bits |= SHIFT_L(glyphp[8][line],24); + bits |= SHIFT_L(glyphp[9][line],31); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[9][line],1); + bits |= SHIFT_L(glyphp[10][line],6); + bits |= SHIFT_L(glyphp[11][line],13); + bits |= SHIFT_L(glyphp[12][line],20); + bits |= SHIFT_L(glyphp[13][line],27); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); + bits = SHIFT_R(glyphp[13][line],5); + bits |= SHIFT_L(glyphp[14][line],2); + bits |= SHIFT_L(glyphp[15][line],9); + bits |= SHIFT_L(glyphp[16][line],16); + bits |= SHIFT_L(glyphp[17][line],23); + bits |= SHIFT_L(glyphp[18][line],30); + WRITE_IN_BITORDER(base, 3, bits); + CHECKRETURN(4); + bits = SHIFT_R(glyphp[18][line],2); + bits |= SHIFT_L(glyphp[19][line],5); + bits |= SHIFT_L(glyphp[20][line],12); + bits |= SHIFT_L(glyphp[21][line],19); + bits |= SHIFT_L(glyphp[22][line],26); + WRITE_IN_BITORDER(base, 4, bits); + CHECKRETURN(5); + bits = SHIFT_R(glyphp[22][line],6); + bits |= SHIFT_L(glyphp[23][line],1); + bits |= SHIFT_L(glyphp[24][line],8); + bits |= SHIFT_L(glyphp[25][line],15); + bits |= SHIFT_L(glyphp[26][line],22); + bits |= SHIFT_L(glyphp[27][line],29); + WRITE_IN_BITORDER(base, 5, bits); + CHECKRETURN(6); + bits = SHIFT_R(glyphp[27][line],3); + bits |= SHIFT_L(glyphp[28][line],4); + bits |= SHIFT_L(glyphp[29][line],11); + bits |= SHIFT_L(glyphp[30][line],18); + bits |= SHIFT_L(glyphp[31][line],25); + WRITE_IN_BITORDER(base, 6, bits); + CHECKRETURN(7); +#ifndef FIXEDBASE + base += 7; +#endif + width -= 224; + glyphp += 32; + } + return base; +} + + +#ifndef USEASSEMBLER +static CARD32* +DrawTETextScanlineWidth8( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],8); + bits |= SHIFT_L(glyphp[2][line],16); + bits |= SHIFT_L(glyphp[3][line],24); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = glyphp[4][line]; + bits |= SHIFT_L(glyphp[5][line],8); + bits |= SHIFT_L(glyphp[6][line],16); + bits |= SHIFT_L(glyphp[7][line],24); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); +#ifndef FIXEDBASE + base += 2; +#endif + width -= 64; + glyphp += 8; + } + return base; +} +#endif + +#ifndef USEASSEMBLER +static CARD32* +DrawTETextScanlineWidth9( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],9); + bits |= SHIFT_L(glyphp[2][line],18); + bits |= SHIFT_L(glyphp[3][line],27); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[3][line],5); + bits |= SHIFT_L(glyphp[4][line],4); + bits |= SHIFT_L(glyphp[5][line],13); + bits |= SHIFT_L(glyphp[6][line],22); + bits |= SHIFT_L(glyphp[7][line],31); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[7][line],1); + bits |= SHIFT_L(glyphp[8][line],8); + bits |= SHIFT_L(glyphp[9][line],17); + bits |= SHIFT_L(glyphp[10][line],26); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); + bits = SHIFT_R(glyphp[10][line],6); + bits |= SHIFT_L(glyphp[11][line],3); + bits |= SHIFT_L(glyphp[12][line],12); + bits |= SHIFT_L(glyphp[13][line],21); + bits |= SHIFT_L(glyphp[14][line],30); + WRITE_IN_BITORDER(base, 3, bits); + CHECKRETURN(4); + bits = SHIFT_R(glyphp[14][line],2); + bits |= SHIFT_L(glyphp[15][line],7); + bits |= SHIFT_L(glyphp[16][line],16); + bits |= SHIFT_L(glyphp[17][line],25); + WRITE_IN_BITORDER(base, 4, bits); + CHECKRETURN(5); + bits = SHIFT_R(glyphp[17][line],7); + bits |= SHIFT_L(glyphp[18][line],2); + bits |= SHIFT_L(glyphp[19][line],11); + bits |= SHIFT_L(glyphp[20][line],20); + bits |= SHIFT_L(glyphp[21][line],29); + WRITE_IN_BITORDER(base, 5, bits); + CHECKRETURN(6); + bits = SHIFT_R(glyphp[21][line],3); + bits |= SHIFT_L(glyphp[22][line],6); + bits |= SHIFT_L(glyphp[23][line],15); + bits |= SHIFT_L(glyphp[24][line],24); + WRITE_IN_BITORDER(base, 6, bits); + CHECKRETURN(7); + bits = SHIFT_R(glyphp[24][line],8); + bits |= SHIFT_L(glyphp[25][line],1); + bits |= SHIFT_L(glyphp[26][line],10); + bits |= SHIFT_L(glyphp[27][line],19); + bits |= SHIFT_L(glyphp[28][line],28); + WRITE_IN_BITORDER(base, 7, bits); + CHECKRETURN(8); + bits = SHIFT_R(glyphp[28][line],4); + bits |= SHIFT_L(glyphp[29][line],5); + bits |= SHIFT_L(glyphp[30][line],14); + bits |= SHIFT_L(glyphp[31][line],23); + WRITE_IN_BITORDER(base, 8, bits); + CHECKRETURN(9); +#ifndef FIXEDBASE + base += 9; +#endif + width -= 288; + glyphp += 32; + } + return base; +} +#endif + +static CARD32* +DrawTETextScanlineWidth10( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],10); + bits |= SHIFT_L(glyphp[2][line],20); + bits |= SHIFT_L(glyphp[3][line],30); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[3][line],2); + bits |= SHIFT_L(glyphp[4][line],8); + bits |= SHIFT_L(glyphp[5][line],18); + bits |= SHIFT_L(glyphp[6][line],28); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[6][line],4); + bits |= SHIFT_L(glyphp[7][line],6); + bits |= SHIFT_L(glyphp[8][line],16); + bits |= SHIFT_L(glyphp[9][line],26); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); + bits = SHIFT_R(glyphp[9][line],6); + bits |= SHIFT_L(glyphp[10][line],4); + bits |= SHIFT_L(glyphp[11][line],14); + bits |= SHIFT_L(glyphp[12][line],24); + WRITE_IN_BITORDER(base, 3, bits); + CHECKRETURN(4); + bits = SHIFT_R(glyphp[12][line],8); + bits |= SHIFT_L(glyphp[13][line],2); + bits |= SHIFT_L(glyphp[14][line],12); + bits |= SHIFT_L(glyphp[15][line],22); + WRITE_IN_BITORDER(base, 4, bits); + CHECKRETURN(5); +#ifndef FIXEDBASE + base += 5; +#endif + width -= 160; + glyphp += 16; + } + return base; +} + +static CARD32* +DrawTETextScanlineWidth12( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],12); + bits |= SHIFT_L(glyphp[2][line],24); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[2][line],8); + bits |= SHIFT_L(glyphp[3][line],4); + bits |= SHIFT_L(glyphp[4][line],16); + bits |= SHIFT_L(glyphp[5][line],28); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[5][line],4); + bits |= SHIFT_L(glyphp[6][line],8); + bits |= SHIFT_L(glyphp[7][line],20); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); +#ifndef FIXEDBASE + base += 3; +#endif + width -= 96; + glyphp += 8; + } + return base; +} + + + +static CARD32* +DrawTETextScanlineWidth14( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],14); + bits |= SHIFT_L(glyphp[2][line],28); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[2][line],4); + bits |= SHIFT_L(glyphp[3][line],10); + bits |= SHIFT_L(glyphp[4][line],24); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[4][line],8); + bits |= SHIFT_L(glyphp[5][line],6); + bits |= SHIFT_L(glyphp[6][line],20); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); + bits = SHIFT_R(glyphp[6][line],12); + bits |= SHIFT_L(glyphp[7][line],2); + bits |= SHIFT_L(glyphp[8][line],16); + bits |= SHIFT_L(glyphp[9][line],30); + WRITE_IN_BITORDER(base, 3, bits); + CHECKRETURN(4); + bits = SHIFT_R(glyphp[9][line],2); + bits |= SHIFT_L(glyphp[10][line],12); + bits |= SHIFT_L(glyphp[11][line],26); + WRITE_IN_BITORDER(base, 4, bits); + CHECKRETURN(5); + bits = SHIFT_R(glyphp[11][line],6); + bits |= SHIFT_L(glyphp[12][line],8); + bits |= SHIFT_L(glyphp[13][line],22); + WRITE_IN_BITORDER(base, 5, bits); + CHECKRETURN(6); + bits = SHIFT_R(glyphp[13][line],10); + bits |= SHIFT_L(glyphp[14][line],4); + bits |= SHIFT_L(glyphp[15][line],18); + WRITE_IN_BITORDER(base, 6, bits); + CHECKRETURN(7); +#ifndef FIXEDBASE + base += 7; +#endif + width -= 224; + glyphp += 16; + } + return base; +} + + +static CARD32* +DrawTETextScanlineWidth16( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],16); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = glyphp[2][line]; + bits |= SHIFT_L(glyphp[3][line],16); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = glyphp[4][line]; + bits |= SHIFT_L(glyphp[5][line],16); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); + bits = glyphp[6][line]; + bits |= SHIFT_L(glyphp[7][line],16); + WRITE_IN_BITORDER(base, 3, bits); + CHECKRETURN(4); +#ifndef FIXEDBASE + base += 4; +#endif + width -= 128; + glyphp += 8; + } + return base; +} + + + +static CARD32* +DrawTETextScanlineWidth18( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],18); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[1][line],14); + bits |= SHIFT_L(glyphp[2][line],4); + bits |= SHIFT_L(glyphp[3][line],22); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[3][line],10); + bits |= SHIFT_L(glyphp[4][line],8); + bits |= SHIFT_L(glyphp[5][line],26); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); + bits = SHIFT_R(glyphp[5][line],6); + bits |= SHIFT_L(glyphp[6][line],12); + bits |= SHIFT_L(glyphp[7][line],30); + WRITE_IN_BITORDER(base, 3, bits); + CHECKRETURN(4); + bits = SHIFT_R(glyphp[7][line],2); + bits |= SHIFT_L(glyphp[8][line],16); + WRITE_IN_BITORDER(base, 4, bits); + CHECKRETURN(5); + bits = SHIFT_R(glyphp[8][line],16); + bits |= SHIFT_L(glyphp[9][line],2); + bits |= SHIFT_L(glyphp[10][line],20); + WRITE_IN_BITORDER(base, 5, bits); + CHECKRETURN(6); + bits = SHIFT_R(glyphp[10][line],12); + bits |= SHIFT_L(glyphp[11][line],6); + bits |= SHIFT_L(glyphp[12][line],24); + WRITE_IN_BITORDER(base, 6, bits); + CHECKRETURN(7); + bits = SHIFT_R(glyphp[12][line],8); + bits |= SHIFT_L(glyphp[13][line],10); + bits |= SHIFT_L(glyphp[14][line],28); + WRITE_IN_BITORDER(base, 7, bits); + CHECKRETURN(8); + bits = SHIFT_R(glyphp[14][line],4); + bits |= SHIFT_L(glyphp[15][line],14); + WRITE_IN_BITORDER(base, 8, bits); + CHECKRETURN(9); +#ifndef FIXEDBASE + base += 9; +#endif + width -= 288; + glyphp += 16; + } + return base; +} + + +static CARD32* +DrawTETextScanlineWidth24( + CARD32 *base, + unsigned int **glyphp, + int line, int width, int glyphwidth ) +{ + while (1) { + unsigned int bits; + bits = glyphp[0][line]; + bits |= SHIFT_L(glyphp[1][line],24); + WRITE_IN_BITORDER(base, 0, bits); + CHECKRETURN(1); + bits = SHIFT_R(glyphp[1][line],8); + bits |= SHIFT_L(glyphp[2][line],16); + WRITE_IN_BITORDER(base, 1, bits); + CHECKRETURN(2); + bits = SHIFT_R(glyphp[2][line],16); + bits |= SHIFT_L(glyphp[3][line],8); + WRITE_IN_BITORDER(base, 2, bits); + CHECKRETURN(3); +#ifndef FIXEDBASE + base += 3; +#endif + width -= 96; + glyphp += 4; + } + return base; +} + + diff --git a/xorg-server/hw/xfree86/xaa/xaaTEGlyphBlt.S b/xorg-server/hw/xfree86/xaa/xaaTEGlyphBlt.S new file mode 100644 index 000000000..5f3137f45 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaTEGlyphBlt.S @@ -0,0 +1,964 @@ +/* + * Copyright 1996 The XFree86 Project + * + * 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 + * HARM HANEMAAYER 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. + * + * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net). + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyphBlt.S,v 1.1 1999/07/10 07:24:54 dawes Exp $ */ + + +/* + * Intel Pentium-optimized versions of "terminal emulator font" text + * bitmap transfer routines. + * + * SCANLINE_PAD_DWORD. + * + * Only for glyphs with a fixed width of 6 pixels or 8 pixels. + */ + +#include "assyntax.h" + +#ifndef QNX4 + FILE("xaaTEGlyphBlt.s") +#else + FILE( __FILE__ ) +#endif + + AS_BEGIN + +/* + * Definition of stack frame function arguments. + * All functions have the same arguments (some don't have glyphwidth, + * but that's OK, since it comes last and doesn't affect the offset + * of the other arguments). + */ + +#define base_arg REGOFF(20,ESP) +#define glyphp_arg REGOFF(24,ESP) +#define line_arg REGOFF(28,ESP) +#define width_arg REGOFF(32,ESP) +#define glyphwidth_arg REGOFF(36,ESP) + +#define BYTE_REVERSED GLNAME(byte_reversed) + +/* I assume %eax and %edx can be trashed. */ + + SEG_TEXT + + ALIGNTEXT4 + +#ifdef FIXEDBASE +# ifdef MSBFIRST + GLOBL GLNAME(DrawTETextScanlineWidth6PMSBFirstFixedBase) +GLNAME(DrawTETextScanlineWidth6PMSBFirstFixedBase): +# else + GLOBL GLNAME(DrawTETextScanlineWidth6PLSBFirstFixedBase) +GLNAME(DrawTETextScanlineWidth6PLSBFirstFixedBase): +# endif +#else +# ifdef MSBFIRST + GLOBL GLNAME(DrawTETextScanlineWidth6PMSBFirst) +GLNAME(DrawTETextScanlineWidth6PMSBFirst): +# else + GLOBL GLNAME(DrawTETextScanlineWidth6PLSBFirst) +GLNAME(DrawTETextScanlineWidth6PLSBFirst): +# endif +#endif + +/* Definition of stack frame function arguments. */ + +#define base_arg REGOFF(20,ESP) +#define glyphp_arg REGOFF(24,ESP) +#define line_arg REGOFF(28,ESP) +#define width_arg REGOFF(32,ESP) + + SUB_L (CONST(16),ESP) + MOV_L (EBP,REGOFF(12,ESP)) /* PUSH EBP */ + MOV_L (EBX,REGOFF(8,ESP)) /* PUSH EBX */ + MOV_L (ESI,REGOFF(4,ESP)) /* PUSH ESI */ + MOV_L (EDI,REGOFF(0,ESP)) /* PUSH EDI */ + + MOV_L (line_arg,EBP) + MOV_L (base_arg,EDI) + MOV_L (glyphp_arg,ESI) + + ALIGNTEXT4 + +.L6_1: + /* Pentium-optimized instruction pairing. */ + /* EBX = bits = glyph[0][line] */ + MOV_L (REGOFF(4,ESI),EDX) /* glyphp[1] */ + MOV_L (REGIND(ESI),EBX) /* glyphp[0] */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[1][line] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[0][line] */ + SAL_L (CONST(6),EDX) /* glyphp[1][line] << 6 */ + MOV_L (REGOFF(8,ESI),ECX) /* glyphp[2] */ + MOV_L (REGOFF(12,ESI),EAX) /* glyphp[3] */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[2][line] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[3][line] */ + SAL_L (CONST(12),ECX) /* glyphp[2][line] << 12 */ + OR_L (EDX,EBX) /* bits |= ..[1].. << 6 */ + SAL_L (CONST(18),EAX) /* glyphp[3][line] << 18 */ + OR_L (ECX,EBX) /* bits |= ..[2].. << 12 */ + + MOV_L (REGOFF(16,ESI),EDX) /* glyphp[4] */ + MOV_L (REGOFF(20,ESI),ECX) /* glyphp[5] */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[4][line] */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[5][line] */ + SAL_L (CONST(24),EDX) /* glyphp[4][line] << 24 */ + OR_L (EAX,EBX) /* bits |= ..[3].. << 18 */ + SAL_L (CONST(30),ECX) /* glyphp[5][line] << 30 */ + OR_L (EDX,EBX) /* bits |= ..[4].. << 24 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(20,ESI),EAX) /* glyphp[5] */ + OR_L (ECX,EBX) /* bits |= ..[5].. << 30 */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[5][line] */ + MOV_L (EBX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (CONST(0),EAX) + OR_L (ECX,EBX) /* bits |= ..[5].. << 30 */ + MOV_L (CONST(0),EDX) + MOV_B (BL,AL) + MOV_B (BH,DL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),BH) + ROL_L (CONST(16),EBX) + MOV_B (BL,AL) + MOV_B (BH,DL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),BH) + ROL_L (CONST(16),EBX) + MOV_L (REGOFF(20,ESI),EAX) /* glyphp[5] */ + MOV_L (EBX,REGIND(EDI)) + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[5][line] */ +#endif + + CMP_L (CONST(32),width_arg) + JG (.L6_2) +#ifndef FIXEDBASE + ADD_L (CONST(4),EDI) /* base++ */ +#endif + JMP (.L6_4) +.L6_2: + /* Note that glyphp[5][line] is already read again. */ + /* EAX = bits = glyphp[5][line] >> 2 */ + MOV_L (REGOFF(24,ESI),EDX) /* glyphp[6] */ + MOV_L (REGOFF(28,ESI),EBX) /* glyphp[7] */ + SHR_L (CONST(2),EAX) /* glyphp[5][line] >> 2 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[6][line] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[7][line] */ + MOV_L (REGOFF(32,ESI),ECX) /* glyphp[8] */ + SAL_L (CONST(4),EDX) /* glyphp[6][line] << 4 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[8][line] */ + SAL_L (CONST(10),EBX) /* glyphp[7][line] << 10 */ + OR_L (EDX,EAX) /* bits |= ..[6].. << 4 */ + SAL_L (CONST(16),ECX) /* glyphp[8][line] << 16 */ + MOV_L (REGOFF(36,ESI),EDX) /* glyphp[9] */ + OR_L (EBX,EAX) /* bits |= ..[7].. << 10 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[9][line] */ + OR_L (ECX,EAX) /* bits |= ..[8].. << 16 */ + MOV_L (REGOFF(40,ESI),EBX) /* glyphp[10] */ + SAL_L (CONST(22),EDX) /* glyphp[9][line] << 22 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[10][line] */ + OR_L (EDX,EAX) /* bits |= ..[9].. << 22 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(40,ESI),ECX) /* glyphp[10] */ + SAL_L (CONST(28),EBX) /* glyphp[10][line] << 28 */ + MOV_L (REGOFF(44,ESI),EDX) /* glyphp[11] */ + OR_L (EBX,EAX) /* bits |= ..[10].. << 28 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[10][line] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(4,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[11][line] */ +#else + MOV_L (CONST(0),ECX) + SAL_L (CONST(28),EBX) /* glyphp[10][line] << 28 */ + MOV_L (CONST(0),EDX) + OR_L (EBX,EAX) /* bits |= ..[10].. << 28 */ + MOV_B (AL,CL) + MOV_B (AH,DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),AH) + ROL_L (CONST(16),EAX) + MOV_B (AL,CL) + MOV_B (AH,DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),AH) + MOV_L (REGOFF(40,ESI),ECX) /* glyphp[10] */ + ROL_L (CONST(16),EAX) + MOV_L (REGOFF(44,ESI),EDX) /* glyphp[11] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(4,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[10][line] */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[11][line] */ +#endif + + CMP_L (CONST(64),width_arg) + JG (.L6_3) +#ifndef FIXEDBASE + ADD_L (CONST(8),EDI) /* base+=2 */ +#endif + JMP (.L6_4) +.L6_3: + /* Note that glyphp[10][line] is read again. */ + /* EAX = bits = glyphp[10][line] >> 4 */ + SHR_L (CONST(4),ECX) /* glyphp[10][line] >> 4 */ + MOV_L (REGOFF(48,ESI),EBX) /* glyphp[12] */ + SAL_L (CONST(2),EDX) /* glyphp[11][line] << 2 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[12][line] */ + OR_L (EDX,ECX) /* bits |= ..[11].. << 2 */ + MOV_L (REGOFF(52,ESI),EAX) /* glyphp[13] */ + SAL_L (CONST(8),EBX) /* glyphp[12][line] << 8 */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[13][line] */ + OR_L (EBX,ECX) /* bits |= ..[12].. << 8 */ + MOV_L (REGOFF(56,ESI),EDX) /* glyphp[14] */ + SAL_L (CONST(14),EAX) /* glyphp[13][line] << 14 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[14][line] */ + OR_L (EAX,ECX) /* bits |= ..[13].. << 14 */ + MOV_L (REGOFF(60,ESI),EBX) /* glyphp[15] */ + SAL_L (CONST(20),EDX) /* glyphp[14][line] << 20 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[15][line] */ + OR_L (EDX,ECX) /* bits |= ..[14].. << 20 */ + +#ifndef MSBFIRST + SAL_L (CONST(26),EBX) /* glyphp[15][line] << 26 */ + OR_L (EBX,ECX) /* bits |= ..[15].. << 26 */ +#ifndef FIXEDBASE + MOV_L (ECX,REGOFF(8,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (ECX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),EAX) + SAL_L (CONST(26),EBX) /* glyphp[15][line] << 26 */ + MOV_L (CONST(0),EDX) + OR_L (EBX,ECX) /* bits |= ..[15].. << 26 */ + MOV_B (CL,AL) + MOV_B (CH,DL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),CL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),CH) + ROL_L (CONST(16),ECX) + MOV_B (CL,AL) + MOV_B (CH,DL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),CL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),CH) + ROL_L (CONST(16),ECX) +#ifndef FIXEDBASE + MOV_L (ECX,REGOFF(8,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (ECX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#endif + +#ifndef FIXEDBASE + ADD_L (CONST(12),EDI) /* base += 3*/ +#endif + CMP_L (CONST(96),width_arg) + JLE (.L6_4) + ADD_L (CONST(64),ESI) /* glyphp += 16 */ + SUB_L (CONST(96),width_arg) + JMP (.L6_1) + +.L6_4: + +#ifndef FIXEDBASE + MOV_L (EDI,EAX) /* return base */ +#else + MOV_L (base_arg,EAX) /* return base */ +#endif + MOV_L (REGOFF(0,ESP),EDI) /* POPL EDI */ + MOV_L (REGOFF(4,ESP),ESI) /* POPL ESI */ + MOV_L (REGOFF(8,ESP),EBX) /* POPL EBX */ + MOV_L (REGOFF(12,ESP),EBP) /* POPL EBP */ + ADD_L (CONST(16),ESP) + RET + + + ALIGNTEXT4 + +#ifdef FIXEDBASE +# ifdef MSBFIRST + GLOBL GLNAME(DrawTETextScanlineWidth8PMSBFirstFixedBase) +GLNAME(DrawTETextScanlineWidth8PMSBFirstFixedBase): +# else + GLOBL GLNAME(DrawTETextScanlineWidth8PLSBFirstFixedBase) +GLNAME(DrawTETextScanlineWidth8PLSBFirstFixedBase): +# endif +#else +# ifdef MSBFIRST + GLOBL GLNAME(DrawTETextScanlineWidth8PMSBFirst) +GLNAME(DrawTETextScanlineWidth8PMSBFirst): +# else + GLOBL GLNAME(DrawTETextScanlineWidth8PLSBFirst) +GLNAME(DrawTETextScanlineWidth8PLSBFirst): +# endif +#endif + + SUB_L (CONST(16),ESP) + MOV_L (EBP,REGOFF(12,ESP)) /* PUSH EBP */ + MOV_L (EBX,REGOFF(8,ESP)) /* PUSH EBX */ + MOV_L (ESI,REGOFF(4,ESP)) /* PUSH ESI */ + MOV_L (EDI,REGOFF(0,ESP)) /* PUSH EDI */ + + MOV_L (line_arg,EBP) + MOV_L (base_arg,EDI) + MOV_L (glyphp_arg,ESI) + + ALIGNTEXT4 + +.L8_1: + /* Pentium-optimized instruction pairing. */ + /* EBX = bits */ + MOV_L (REGIND(ESI),EAX) /* glyphp[0] */ + MOV_L (REGOFF(4,ESI),EDX) /* glyphp[1] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[0][line] */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[1][line] */ +#ifdef MSBFIRST + MOV_B (REGOFF(BYTE_REVERSED,EAX),BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),BH) +#else + MOV_L (EAX,EBX) /* bits = glyph[0][line] */ + MOV_B (DL,BH) /* bits |= ..[1].. << 8 */ +#endif + + ROL_L (CONST(16),EBX) + MOV_L (REGOFF(8,ESI),EAX) /* glyphp[2] */ + MOV_L (REGOFF(12,ESI),ECX) /* glyphp[3] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[2][line] */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[3][line] */ +#ifdef MSBFIRST + MOV_B (REGOFF(BYTE_REVERSED,EAX),BL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),BH) +#else + MOV_B (AL,BL) /* bits |= ..[2].. << 16 */ + MOV_B (CL,BH) /* bits |= ..[3].. << 24 */ +#endif + ROL_L (CONST(16),EBX) + MOV_L (EBX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ + CMP_L (CONST(32),width_arg) +#ifndef FIXEDBASE + JLE (.L8_2) +#else + JLE (.L8_3) +#endif + + MOV_L (REGOFF(16,ESI),EAX) /* glyphp[4] */ + MOV_L (REGOFF(20,ESI),EDX) /* glyphp[5] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[4][line] */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[5][line] */ +#ifdef MSBFIRST + MOV_B (REGOFF(BYTE_REVERSED,EAX),BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),BH) +#else + MOV_L (EAX,EBX) /* bits = glyph[4][line] */ + MOV_B (DL,BH) /* nits |= ..[5].. << 8 */ +#endif + + ROL_L (CONST(16),EBX) + MOV_L (REGOFF(24,ESI),EAX) /* glyphp[6] */ + MOV_L (REGOFF(28,ESI),ECX) /* glyphp[7] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[6][line] */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[7][line] */ +#ifdef MSBFIRST + MOV_B (REGOFF(BYTE_REVERSED,EAX),BL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),BH) +#else + MOV_B (AL,BL) /* bits |= ..[6].. << 16 */ + MOV_B (CL,BH) /* bits |= ..[7].. << 24 */ +#endif + ROL_L (CONST(16),EBX) +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(4,EDI)) /* WRITE_IN_BIT_ORDER(base+1, bits) */ + ADD_L (CONST(8),EDI) /* base += 2 */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif + CMP_L (CONST(64),width_arg) + JLE (.L8_3) + ADD_L (CONST(32),ESI) /* glyphp += 8 */ + SUB_L (CONST(64),width_arg) + JMP (.L8_1) + +#ifndef FIXEDBASE +.L8_2: + ADD_L (CONST(4),EDI) /* base++ */ +.L8_3: + MOV_L (EDI,EAX) /* return base */ +#else +.L8_3: + MOV_L (base_arg,EAX) /* return base */ +#endif + MOV_L (REGOFF(0,ESP),EDI) /* POPL EDI */ + MOV_L (REGOFF(4,ESP),ESI) /* POPL ESI */ + MOV_L (REGOFF(8,ESP),EBX) /* POPL EBX */ + MOV_L (REGOFF(12,ESP),EBP) /* POPL EBP */ + ADD_L (CONST(16),ESP) + RET + + ALIGNTEXT4 + +#ifdef FIXEDBASE +# ifdef MSBFIRST + GLOBL GLNAME(DrawTETextScanlineWidth9PMSBFirstFixedBase) +GLNAME(DrawTETextScanlineWidth9PMSBFirstFixedBase): +# else + GLOBL GLNAME(DrawTETextScanlineWidth9PLSBFirstFixedBase) +GLNAME(DrawTETextScanlineWidth9PLSBFirstFixedBase): +# endif +#else +# ifdef MSBFIRST + GLOBL GLNAME(DrawTETextScanlineWidth9PMSBFirst) +GLNAME(DrawTETextScanlineWidth9PMSBFirst): +# else + GLOBL GLNAME(DrawTETextScanlineWidth9PLSBFirst) +GLNAME(DrawTETextScanlineWidth9PLSBFirst): +# endif +#endif + + SUB_L (CONST(16),ESP) + MOV_L (EBP,REGOFF(12,ESP)) /* PUSH EBP */ + MOV_L (EBX,REGOFF(8,ESP)) /* PUSH EBX */ + MOV_L (ESI,REGOFF(4,ESP)) /* PUSH ESI */ + MOV_L (EDI,REGOFF(0,ESP)) /* PUSH EDI */ + + MOV_L (line_arg,EBP) + MOV_L (base_arg,EDI) + MOV_L (glyphp_arg,ESI) + + ALIGNTEXT4 + +.L9_1: + /* Pentium-optimized instruction pairing. */ + /* EAX = bits */ + MOV_L (REGOFF(4,ESI),EBX) /* glyphp[1] */ + MOV_L (REGIND(ESI),EAX) /* glyphp[0] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[1][line] */ + MOV_L (REGOFF(8,ESI),ECX) /* glyphp[2] */ + SAL_L (CONST(9),EBX) /* glyphp[1][line] << 9 */ + MOV_L (REGOFF(12,ESI),EDX) /* glyphp[3] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[0][line] */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[3][line] */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[2][line] */ + OR_L (EBX,EAX) /* bits |= ..[1].. << 9 */ + SAL_L (CONST(18),ECX) /* glyphp[2][line] << 18 */ + OR_L (ECX,EAX) /* bits |= ..[2].. << 18 */ + SAL_L (CONST(27),EDX) /* glyphp[3][line << 27 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(12,ESI),EBX) /* glyphp[3] */ + OR_L (EDX,EAX) /* bits |= ..[3].. << 27 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[3][line] */ + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (CONST(0),EBX) + OR_L (EDX,EAX) /* bits |= ..[3].. << 27 */ + MOV_L (CONST(0),ECX) + MOV_B (AL,BL) + MOV_B (AH,CL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),AL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AH) + ROL_L (CONST(16),EAX) + MOV_B (AL,BL) + MOV_B (AH,CL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),AL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AH) + MOV_L (REGOFF(12,ESI),EBX) /* glyphp[3] */ + ROL_L (CONST(16),EAX) + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[3][line] */ + MOV_L (EAX,REGIND(EDI)) +#endif + + CMP_L (CONST(32),width_arg) + JG (.L9_2) +#ifndef FIXEDBASE + ADD_L (CONST(4),EDI) /* base++ */ +#endif + JMP (.L9_11) +.L9_2: + /* Note that glyphp[3][line] is read again. */ + /* EAX = bits, EBX = glyphp[3][line] >> 5 */ + SHR_L (CONST(5),EBX) /* glyphp[3][line] >> 5 */ + MOV_L (REGOFF(16,ESI),EAX) /* glyphp[4] */ + MOV_L (REGOFF(20,ESI),ECX) /* glyphp[5] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[4][line] */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[5][line] */ + MOV_L (REGOFF(24,ESI),EDX) /* glyphp[6] */ + SAL_L (CONST(4),EAX) /* glyphp[4][line] << 4 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[6][line] */ + SAL_L (CONST(13),ECX) /* glyphp[5][line] << 13 */ + OR_L (EBX,EAX) /* bits |= ..[4].. << 4 */ + SAL_L (CONST(22),EDX) /* glyphp[6][line] << 22 */ + MOV_L (REGOFF(28,ESI),EBX) /* glyphp[7] */ + OR_L (ECX,EAX) /* bits |= ..[5].. << 13 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[7][line] */ + OR_L (EDX,EAX) /* bits |= ..[6].. << 22 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(28,ESI),ECX) /* glyphp[7] */ + SAL_L (CONST(31),EBX) /* glyphp[7][line] << 31 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[7][line] */ + OR_L (EBX,EAX) /* bits |= ..[7].. << 31 */ + MOV_L (REGOFF(32,ESI),EDX) /* glyphp[8] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(4,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),ECX) + SAL_L (CONST(31),EBX) /* glyphp[7][line] << 31 */ + MOV_L (CONST(0),EDX) + OR_L (EBX,EAX) /* bits |= ..[7].. << 31 */ + MOV_B (AL,CL) + MOV_B (AH,DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),AH) + ROL_L (CONST(16),EAX) + MOV_B (AL,CL) + MOV_B (AH,DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),AH) + MOV_L (REGOFF(28,ESI),ECX) /* glyphp[7] */ + ROL_L (CONST(16),EAX) + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[7][line] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(4,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif + MOV_L (REGOFF(32,ESI),EDX) /* glyphp[8] */ +#endif + + CMP_L (CONST(64),width_arg) + JG (.L9_3) +#ifndef FIXEDBASE + ADD_L (CONST(8),EDI) /* base+=2 */ +#endif + JMP (.L9_11) +.L9_3: + + /* Note that glyphp[7][line] is read again. */ + /* ECX = bits = glyphp[7][line] >> 1 */ + SHR_L (CONST(1),ECX) /* glyphp[7][line] >> 1 */ + MOV_L (REGOFF(36,ESI),EBX) /* glyphp[9] */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[8][line] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[9][line] */ + SAL_L (CONST(8),EDX) /* glyphp[8][line] << 8 */ + MOV_L (REGOFF(40,ESI),EAX) /* glyphp[10] */ + SAL_L (CONST(17),EBX) /* glyphp[9][line] << 17 */ + OR_L (EDX,ECX) /* bits |= ..[8].. << 8 */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[10][line] */ + OR_L (EBX,ECX) /* bits |= ..[9].. << 17 */ + SAL_L (CONST(26),EAX) /* glyphp[10][line] << 26 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(40,ESI),EDX) /* glyphp[10] */ + OR_L (EAX,ECX) /* bits |= ..[10].. << 26 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[10][line] */ +#ifndef FIXEDBASE + MOV_L (ECX,REGOFF(8,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (ECX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),EDX) + OR_L (EAX,ECX) /* bits |= ..[10].. << 26 */ + MOV_L (CONST(0),EBX) + MOV_B (CL,DL) + MOV_B (CH,BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),CL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),CH) + ROL_L (CONST(16),ECX) + MOV_B (CL,DL) + MOV_B (CH,BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),CL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),CH) + MOV_L (REGOFF(40,ESI),EDX) /* glyphp[10] */ + ROL_L (CONST(16),ECX) + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[10][line] */ +#ifndef FIXEDBASE + MOV_L (ECX,REGOFF(8,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (ECX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#endif + + CMP_L (CONST(96),width_arg) + JG (.L9_4) +#ifndef FIXEDBASE + ADD_L (CONST(12),EDI) /* base+=3 */ +#endif + JMP (.L9_11) +.L9_4: + /* Note that glyphp[10][line] is read again. */ + /* EDX = bits = glyphp[10][line] >> 6 */ + SHR_L (CONST(6),EDX) /* glyphp[10][line] >> 6 */ + MOV_L (REGOFF(44,ESI),EBX) /* glyphp[11] */ + MOV_L (REGOFF(48,ESI),EAX) /* glyphp[12] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[11][line] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[12][line] */ + MOV_L (REGOFF(52,ESI),ECX) /* glyphp[13] */ + SAL_L (CONST(3),EBX) /* glyphp[11][line] << 3 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[13][line] */ + SAL_L (CONST(12),EAX) /* glyphp[12][line] << 12 */ + OR_L (EBX,EDX) /* bits |= ..[11].. << 3 */ + SAL_L (CONST(21),ECX) /* glyphp[13][line] << 21 */ + MOV_L (REGOFF(56,ESI),EBX) /* glyphp[14] */ + OR_L (EAX,EDX) /* bits |= ..[12].. << 17 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[14][line] */ + SAL_L (CONST(30),EBX) /* glyphp[14][line] << 30 */ + OR_L (ECX,EDX) /* bits |= ..[13].. << 21 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(56,ESI),EAX) /* glyphp[14] */ + OR_L (EBX,EDX) /* bits |= ..[14].. << 30 */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[14][line] */ +#ifndef FIXEDBASE + MOV_L (EDX,REGOFF(12,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EDX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),EAX) + OR_L (EBX,EDX) /* bits |= ..[14].. << 30 */ + MOV_L (CONST(0),ECX) + MOV_B (DL,AL) + MOV_B (DH,CL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),DH) + ROL_L (CONST(16),EDX) + MOV_B (DL,AL) + MOV_B (DH,CL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),DH) + MOV_L (REGOFF(56,ESI),EAX) /* glyphp[14] */ + ROL_L (CONST(16),EDX) + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[14][line] */ +#ifndef FIXEDBASE + MOV_L (EDX,REGOFF(12,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EDX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#endif + + CMP_L (CONST(128),width_arg) + JG (.L9_5) +#ifndef FIXEDBASE + ADD_L (CONST(16),EDI) /* base+=4 */ +#endif + JMP (.L9_11) +.L9_5: + /* Note that glyphp[14][line] is read again. */ + /* EAX = bits = glyphp[14][line] >> 2 */ + SHR_L (CONST(2),EAX) /* glyphp[14][line] >> 2 */ + MOV_L (REGOFF(60,ESI),ECX) /* glyphp[15] */ + MOV_L (REGOFF(64,ESI),EBX) /* glyphp[16] */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[15][line] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[16][line] */ + MOV_L (REGOFF(68,ESI),EDX) /* glyphp[17] */ + SAL_L (CONST(7),ECX) /* glyphp[15][line] << 7 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[17][line] */ + SAL_L (CONST(16),EBX) /* glyphp[16][line] << 16 */ + OR_L (ECX,EAX) /* bits |= ..[15].. << 7 */ + SAL_L (CONST(25),EDX) /* glyphp[17][line] << 25 */ + OR_L (EBX,EAX) /* bits |= ..[16].. << 16 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(68,ESI),ECX) /* glyphp[17] */ + OR_L (EDX,EAX) /* bits |= ..[17].. << 25 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[17][line] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(16,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),ECX) + OR_L (EDX,EAX) /* bits |= ..[17].. << 25 */ + MOV_L (CONST(0),EBX) + MOV_B (AL,CL) + MOV_B (AH,BL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),AH) + ROL_L (CONST(16),EAX) + MOV_B (AL,CL) + MOV_B (AH,BL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),AH) + MOV_L (REGOFF(68,ESI),ECX) /* glyphp[17] */ + ROL_L (CONST(16),EAX) + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[17][line] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(16,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#endif + + CMP_L (CONST(160),width_arg) + JG (.L9_6) +#ifndef FIXEDBASE + ADD_L (CONST(20),EDI) /* base+=5 */ +#endif + JMP (.L9_11) +.L9_6: + /* Note that glyphp[17][line] is read again. */ + /* ECX = bits = glyphp[17][line] >> 7 */ + SHR_L (CONST(7),ECX) /* glyphp[17][line] >> 7 */ + MOV_L (REGOFF(72,ESI),EBX) /* glyphp[18] */ + MOV_L (REGOFF(76,ESI),EAX) /* glyphp[19] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[18][line] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[19][line] */ + MOV_L (REGOFF(80,ESI),EDX) /* glyphp[20] */ + SAL_L (CONST(2),EBX) /* glyphp[18][line] << 2 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[20][line] */ + SAL_L (CONST(11),EAX) /* glyphp[19][line] << 11 */ + OR_L (EBX,ECX) /* bits |= ..[18].. << 2 */ + SAL_L (CONST(20),EDX) /* glyphp[20][line] << 20 */ + MOV_L (REGOFF(84,ESI),EBX) /* glyphp[21] */ + OR_L (EAX,ECX) /* bits |= ..[19].. << 11 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[21][line] */ + OR_L (EDX,ECX) /* bits |= ..[20].. << 20 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(84,ESI),EAX) /* glyphp[21] */ + SAL_L (CONST(29),EBX) /* glyphp[21][line] << 29 */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[21][line] */ + OR_L (EBX,ECX) /* bits |= ..[14].. << 30 */ + MOV_L (REGOFF(88,ESI),EDX) /* glyphp[22] */ +#ifndef FIXEDBASE + MOV_L (ECX,REGOFF(20,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (ECX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),EAX) + SAL_L (CONST(29),EBX) /* glyphp[21][line] << 29 */ + MOV_L (CONST(0),EDX) + OR_L (EBX,ECX) /* bits |= ..[14].. << 30 */ + MOV_B (CL,AL) + MOV_B (CH,DL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),CL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),CH) + ROL_L (CONST(16),ECX) + MOV_B (CL,AL) + MOV_B (CH,DL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),CL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),CH) + MOV_L (REGOFF(84,ESI),EAX) /* glyphp[21] */ + ROL_L (CONST(16),ECX) + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[21][line] */ +#ifndef FIXEDBASE + MOV_L (ECX,REGOFF(20,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (ECX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif + MOV_L (REGOFF(88,ESI),EDX) /* glyphp[22] */ +#endif + + CMP_L (CONST(192),width_arg) + JG (.L9_7) +#ifndef FIXEDBASE + ADD_L (CONST(24),EDI) /* base+=6 */ +#endif + JMP (.L9_11) +.L9_7: + /* Note that glyphp[21][line] is read again. */ + /* EAX = bits = glyphp[21][line] >> 3 */ + SHR_L (CONST(3),EAX) /* glyphp[21][line] >> 3 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[22][line] */ + MOV_L (REGOFF(92,ESI),EBX) /* glyphp[23] */ + MOV_L (REGOFF(96,ESI),ECX) /* glyphp[24] */ + SAL_L (CONST(6),EDX) /* glyphp[22][line] << 6 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[23][line] */ + OR_L (EDX,EAX) /* bits |= ..[22].. << 6 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[24][line] */ + SAL_L (CONST(15),EBX) /* glyphp[23][line] << 15 */ + OR_L (EBX,EAX) /* bits |= ..[23].. << 15 */ + SAL_L (CONST(24),ECX) /* glyphp[24][line] << 24 */ + +#ifndef MSBFIRST + MOV_L (REGOFF(96,ESI),EDX) /* glyphp[24] */ + OR_L (ECX,EAX) /* bits |= ..[24].. << 24 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[24][line] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(24,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),EDX) + OR_L (ECX,EAX) /* bits |= ..[24].. << 24 */ + MOV_L (CONST(0),EBX) + MOV_B (AL,DL) + MOV_B (AH,BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),AH) + ROL_L (CONST(16),EAX) + MOV_B (AL,DL) + MOV_B (AH,BL) + MOV_B (REGOFF(BYTE_REVERSED,EDX),AL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),AH) + MOV_L (REGOFF(96,ESI),EDX) /* glyphp[24] */ + ROL_L (CONST(16),EAX) + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[24][line] */ +#ifndef FIXEDBASE + MOV_L (EAX,REGOFF(24,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EAX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#endif + + CMP_L (CONST(224),width_arg) + JG (.L9_8) +#ifndef FIXEDBASE + ADD_L (CONST(28),EDI) /* base+=7 */ +#endif + JMP (.L9_11) +.L9_8: + /* Note that glyphp[24][line] is read again. */ + /* EDX = bits = glyphp[24][line] >> 8 */ + + SHR_L (CONST(8),EDX) /* glyphp[24][line] >> 8 */ + MOV_L (REGOFF(100,ESI),EAX) /* glyphp[25] */ + MOV_L (REGOFF(104,ESI),EBX) /* glyphp[26] */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[25][line] */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[26][line] */ + MOV_L (REGOFF(108,ESI),ECX) /* glyphp[27] */ + SAL_L (CONST(1),EAX) /* glyphp[25][line] << 1 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[27][line] */ + SAL_L (CONST(10),EBX) /* glyphp[26][line] << 10 */ + OR_L (EAX,EDX) /* bits |= ..[25].. << 1 */ + SAL_L (CONST(19),ECX) /* glyphp[27][line] << 19 */ + OR_L (EBX,EDX) /* bits |= ..[26].. << 10 */ + MOV_L (REGOFF(112,ESI),EAX) /* glyphp[28] */ + OR_L (ECX,EDX) /* bits |= ..[27].. << 19 */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[28][line] */ + +#ifndef MSBFIRST + MOV_L (REGOFF(112,ESI),EBX) /* glyphp[28] */ + SAL_L (CONST(28),EAX) /* glyphp[28][line] << 28 */ + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[28][line] */ + OR_L (EAX,EDX) /* bits |= ..[28].. << 28 */ + MOV_L (REGOFF(116,ESI),ECX) /* glyphp[29] */ +#ifndef FIXEDBASE + MOV_L (EDX,REGOFF(28,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EDX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),EBX) + SAL_L (CONST(28),EAX) /* glyphp[28][line] << 28 */ + MOV_L (CONST(0),ECX) + OR_L (EAX,EDX) /* bits |= ..[28].. << 28 */ + MOV_B (DL,BL) + MOV_B (DH,CL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),DH) + ROL_L (CONST(16),EDX) + MOV_B (DL,BL) + MOV_B (DH,CL) + MOV_B (REGOFF(BYTE_REVERSED,EBX),DL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),DH) + MOV_L (REGOFF(112,ESI),EBX) /* glyphp[28] */ + ROL_L (CONST(16),EDX) + MOV_L (REGOFF(116,ESI),ECX) /* glyphp[29] */ +#ifndef FIXEDBASE + MOV_L (EDX,REGOFF(28,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EDX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif + MOV_L (REGBISD(EBX,EBP,4,0),EBX) /* glyphp[28][line] */ +#endif + + CMP_L (CONST(256),width_arg) + JG (.L9_9) +#ifndef FIXEDBASE + ADD_L (CONST(32),EDI) /* base+=8 */ +#endif + JMP (.L9_11) +.L9_9: + /* Note that glyphp[28][line] is read again. */ + /* EBX = bits = glyphp[28][line] >> 4 */ + SHR_L (CONST(4),EBX) /* glyphp[28][line] >> 4 */ + MOV_L (REGBISD(ECX,EBP,4,0),ECX) /* glyphp[29][line] */ + MOV_L (REGOFF(120,ESI),EAX) /* glyphp[30] */ + MOV_L (REGOFF(124,ESI),EDX) /* glyphp[31] */ + SAL_L (CONST(5),ECX) /* glyphp[29][line] << 5 */ + MOV_L (REGBISD(EAX,EBP,4,0),EAX) /* glyphp[30][line] */ + OR_L (ECX,EBX) /* bits |= ..[29].. << 5 */ + MOV_L (REGBISD(EDX,EBP,4,0),EDX) /* glyphp[31][line] */ + SAL_L (CONST(14),EAX) /* glyphp[30][line] << 14 */ + ADD_L (CONST(128),ESI) /* glyphp+=32 */ + SAL_L (CONST(23),EDX) /* glyphp[31][line] << 23 */ + OR_L (EAX,EBX) /* bits |= ..[30].. << 14 */ + SUB_L (CONST(288),width_arg) /* width-=288 */ + OR_L (EDX,EBX) /* bits |= ..[31].. << 23 */ + +#ifndef MSBFIRST +#ifndef FIXEDBASE + MOV_L (EBX,REGOFF(32,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EBX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#else + MOV_L (CONST(0),ECX) + MOV_L (CONST(0),EAX) + MOV_B (BL,CL) + MOV_B (BH,AL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),BL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),BH) + ROL_L (CONST(16),EBX) + MOV_B (BL,CL) + MOV_B (BH,AL) + MOV_B (REGOFF(BYTE_REVERSED,ECX),BL) + MOV_B (REGOFF(BYTE_REVERSED,EAX),BH) + ROL_L (CONST(16),EBX) +#ifndef FIXEDBASE + MOV_L (EBX,REGOFF(32,EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#else + MOV_L (EBX,REGIND(EDI)) /* WRITE_IN_BIT_ORDER(base, bits) */ +#endif +#endif + + ADD_L (CONST(36),EDI) /* base+=9 */ + CMP_L (CONST(0),width_arg) + JG (.L9_1) + +.L9_11: +#ifndef FIXEDBASE + MOV_L (EDI,EAX) /* return base */ +#else + MOV_L (base_arg,EAX) /* return base */ +#endif + MOV_L (REGOFF(0,ESP),EDI) /* POPL EDI */ + MOV_L (REGOFF(4,ESP),ESI) /* POPL ESI */ + MOV_L (REGOFF(8,ESP),EBX) /* POPL EBX */ + MOV_L (REGOFF(12,ESP),EBP) /* POPL EBP */ + ADD_L (CONST(16),ESP) + RET diff --git a/xorg-server/hw/xfree86/xaa/xaaTEText.c b/xorg-server/hw/xfree86/xaa/xaaTEText.c new file mode 100644 index 000000000..fc445726f --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaTEText.c @@ -0,0 +1,312 @@ + +/******************************************************************** + + In this file we have GC level replacements for PolyText8/16, + ImageText8/16, ImageGlyphBlt and PolyGlyphBlt for TE (fixed) fonts. + The idea is that everything in this file is device independent. + The mentioned GCOps are merely wrappers for XAAGlyphBltTEColorExpansion + which calculates the boxes containing arbitrarily clipped text + and passes them to the TEGlyphRenderer which will usually be a lower + level XAA function which renders these clipped glyphs using + the basic color expansion functions exported by the chipset driver. + The TEGlyphRenderer itself may optionally be driver supplied to + facilitate work-arounds/optimizations at a higher level than usual. + + v1.0 - Mark Vojkovich (mvojkovi@ucsd.edu) + + +********************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include <X11/fonts/font.h> +#include "scrnintstr.h" +#include "dixfontstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "gcstruct.h" +#include "pixmapstr.h" + + +static void XAAGlyphBltTEColorExpansion(ScrnInfoPtr pScrn, int xInit, + int yInit, FontPtr font, int fg, int bg, int rop, + unsigned int planemask, RegionPtr cclip, int nglyph, + unsigned char* gBase, CharInfoPtr *ppci); + + +/******************************************************************** + + GC level replacements for PolyText8/16 and ImageText8/16 + for TE fonts when using color expansion. + +********************************************************************/ + + +int +XAAPolyText8TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + + (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, + (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo); + + /* we have divorced XAAGlyphBltTEColorExpansion from the drawable */ + if(n) XAAGlyphBltTEColorExpansion( + infoRec->pScrn, x + pDraw->x, y + pDraw->y, + pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo); + + return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth))); +} + + +int +XAAPolyText16TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + + (*pGC->font->get_glyphs)( + pGC->font, (unsigned long)count, (unsigned char *)chars, + (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, + &n, infoRec->CharInfo); + + if(n) XAAGlyphBltTEColorExpansion( + infoRec->pScrn, x + pDraw->x, y + pDraw->y, + pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo); + + return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth))); +} + + +void +XAAImageText8TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, + (unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo); + + if(n) XAAGlyphBltTEColorExpansion( + infoRec->pScrn, x + pDraw->x, y + pDraw->y, + pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo); +} + + +void +XAAImageText16TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + unsigned long n; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + (*pGC->font->get_glyphs)( + pGC->font, (unsigned long)count, (unsigned char *)chars, + (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, + &n, infoRec->CharInfo); + + if(n) XAAGlyphBltTEColorExpansion( + infoRec->pScrn, x + pDraw->x, y + pDraw->y, + pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask, + pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo); +} + + + +/******************************************************************** + + GC level replacements for ImageGlyphBlt and PolyGlyphBlt for + TE fonts when using color expansion. + +********************************************************************/ + + +void +XAAImageGlyphBltTEColorExpansion( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + XAAGlyphBltTEColorExpansion( + infoRec->pScrn, xInit + pDrawable->x, yInit + pDrawable->y, + pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask, + pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci); +} + +void +XAAPolyGlyphBltTEColorExpansion( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + XAAGlyphBltTEColorExpansion( + infoRec->pScrn, xInit + pDrawable->x, yInit + pDrawable->y, + pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask, + pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci); +} + + + + +/******************************************************************** + + XAAGlyphBltTEColorExpansion - + + This guy computes the clipped pieces of text and sends it to + the lower-level function which will handle acceleration of + arbitrarily clipped text. + +********************************************************************/ + + +static void +XAAGlyphBltTEColorExpansion( + ScrnInfoPtr pScrn, + int xInit, int yInit, + FontPtr font, + int fg, int bg, + int rop, + unsigned int planemask, + RegionPtr cclip, + int nglyph, + unsigned char* gBase, + CharInfoPtr *ppci ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int skippix, skipglyphs; + int Left, Right, Top, Bottom; + int LeftEdge, RightEdge, ytop, ybot; + int nbox = REGION_NUM_RECTS(cclip); + BoxPtr pbox = REGION_RECTS(cclip); + unsigned int **glyphs = NULL; + int glyphWidth = FONTMAXBOUNDS(font, characterWidth); + + /* find the size of the box */ + Left = xInit; + Right = Left + (glyphWidth * nglyph); + Top = yInit - FONTASCENT(font); + Bottom = yInit + FONTDESCENT(font); + + /* get into the first band that may contain part of our string */ + while(nbox && (Top >= pbox->y2)) { + pbox++; nbox--; + } + + /* stop when the lower edge of the box is beyond our string */ + while(nbox && (Bottom > pbox->y1)) { + LeftEdge = max(Left, pbox->x1); + RightEdge = min(Right, pbox->x2); + + if(RightEdge > LeftEdge) { /* we have something to draw */ + unsigned int *fallbackBits = NULL; + ytop = max(Top, pbox->y1); + ybot = min(Bottom, pbox->y2); + + if((skippix = LeftEdge - Left)) { + skipglyphs = skippix/glyphWidth; + skippix %= glyphWidth; + } else skipglyphs = 0; + + if(!glyphs) { + int count; + glyphs = (unsigned int**)(infoRec->PreAllocMem); + + for(count = 0; count < nglyph; count++) { + glyphs[count] = (unsigned int*) + FONTGLYPHBITS(gBase,*ppci++); + if (!glyphs[count]) { + /* Glyphs with NULL bits do exist in the wild. + Replace with blank bits in that case */ + + if (!fallbackBits) { + int fontHeight = Bottom - Top + 1; + fallbackBits = xcalloc (glyphWidth * fontHeight, 1); + if (!fallbackBits) + return; + } + glyphs[count] = fallbackBits; + } + } + + /* our new unrolled TE code only writes DWORDS at a time + so it can read up to 6 characters past the last one + we're displaying */ + glyphs[count + 0] = glyphs[0]; + glyphs[count + 1] = glyphs[0]; + glyphs[count + 2] = glyphs[0]; + glyphs[count + 3] = glyphs[0]; + glyphs[count + 4] = glyphs[0]; + glyphs[count + 5] = glyphs[0]; + } + + /* x, y, w, h, skipleft, skiptop, glyphp, glyphWidth, fg, bg, rop, pm */ + + (*infoRec->TEGlyphRenderer)( pScrn, + LeftEdge, ytop, RightEdge - LeftEdge, ybot - ytop, + skippix, ytop - Top, glyphs + skipglyphs, glyphWidth, + fg, bg, rop, planemask); + + if (fallbackBits) + xfree (fallbackBits); + } + + nbox--; pbox++; + } +} + + + + diff --git a/xorg-server/hw/xfree86/xaa/xaaTables.c b/xorg-server/hw/xfree86/xaa/xaaTables.c new file mode 100644 index 000000000..829527dd6 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaTables.c @@ -0,0 +1,87 @@ + +/* + * This is a table of 24-bit values, indexed with an 8-bit byte value, then + * expands each bit to three consecutive bits. This is required for color + * expansion in 24bpp mode with the coprocessor in 8bpp mode, with LSB-first + * bit order within a byte. + */ + +unsigned int byte_expand3[256] = +{ + 0x000000, 0x000007, 0x000038, 0x00003F, 0x0001C0, 0x0001C7, 0x0001F8, 0x0001FF, + 0x000E00, 0x000E07, 0x000E38, 0x000E3F, 0x000FC0, 0x000FC7, 0x000FF8, 0x000FFF, + 0x007000, 0x007007, 0x007038, 0x00703F, 0x0071C0, 0x0071C7, 0x0071F8, 0x0071FF, + 0x007E00, 0x007E07, 0x007E38, 0x007E3F, 0x007FC0, 0x007FC7, 0x007FF8, 0x007FFF, + 0x038000, 0x038007, 0x038038, 0x03803F, 0x0381C0, 0x0381C7, 0x0381F8, 0x0381FF, + 0x038E00, 0x038E07, 0x038E38, 0x038E3F, 0x038FC0, 0x038FC7, 0x038FF8, 0x038FFF, + 0x03F000, 0x03F007, 0x03F038, 0x03F03F, 0x03F1C0, 0x03F1C7, 0x03F1F8, 0x03F1FF, + 0x03FE00, 0x03FE07, 0x03FE38, 0x03FE3F, 0x03FFC0, 0x03FFC7, 0x03FFF8, 0x03FFFF, + 0x1C0000, 0x1C0007, 0x1C0038, 0x1C003F, 0x1C01C0, 0x1C01C7, 0x1C01F8, 0x1C01FF, + 0x1C0E00, 0x1C0E07, 0x1C0E38, 0x1C0E3F, 0x1C0FC0, 0x1C0FC7, 0x1C0FF8, 0x1C0FFF, + 0x1C7000, 0x1C7007, 0x1C7038, 0x1C703F, 0x1C71C0, 0x1C71C7, 0x1C71F8, 0x1C71FF, + 0x1C7E00, 0x1C7E07, 0x1C7E38, 0x1C7E3F, 0x1C7FC0, 0x1C7FC7, 0x1C7FF8, 0x1C7FFF, + 0x1F8000, 0x1F8007, 0x1F8038, 0x1F803F, 0x1F81C0, 0x1F81C7, 0x1F81F8, 0x1F81FF, + 0x1F8E00, 0x1F8E07, 0x1F8E38, 0x1F8E3F, 0x1F8FC0, 0x1F8FC7, 0x1F8FF8, 0x1F8FFF, + 0x1FF000, 0x1FF007, 0x1FF038, 0x1FF03F, 0x1FF1C0, 0x1FF1C7, 0x1FF1F8, 0x1FF1FF, + 0x1FFE00, 0x1FFE07, 0x1FFE38, 0x1FFE3F, 0x1FFFC0, 0x1FFFC7, 0x1FFFF8, 0x1FFFFF, + 0xE00000, 0xE00007, 0xE00038, 0xE0003F, 0xE001C0, 0xE001C7, 0xE001F8, 0xE001FF, + 0xE00E00, 0xE00E07, 0xE00E38, 0xE00E3F, 0xE00FC0, 0xE00FC7, 0xE00FF8, 0xE00FFF, + 0xE07000, 0xE07007, 0xE07038, 0xE0703F, 0xE071C0, 0xE071C7, 0xE071F8, 0xE071FF, + 0xE07E00, 0xE07E07, 0xE07E38, 0xE07E3F, 0xE07FC0, 0xE07FC7, 0xE07FF8, 0xE07FFF, + 0xE38000, 0xE38007, 0xE38038, 0xE3803F, 0xE381C0, 0xE381C7, 0xE381F8, 0xE381FF, + 0xE38E00, 0xE38E07, 0xE38E38, 0xE38E3F, 0xE38FC0, 0xE38FC7, 0xE38FF8, 0xE38FFF, + 0xE3F000, 0xE3F007, 0xE3F038, 0xE3F03F, 0xE3F1C0, 0xE3F1C7, 0xE3F1F8, 0xE3F1FF, + 0xE3FE00, 0xE3FE07, 0xE3FE38, 0xE3FE3F, 0xE3FFC0, 0xE3FFC7, 0xE3FFF8, 0xE3FFFF, + 0xFC0000, 0xFC0007, 0xFC0038, 0xFC003F, 0xFC01C0, 0xFC01C7, 0xFC01F8, 0xFC01FF, + 0xFC0E00, 0xFC0E07, 0xFC0E38, 0xFC0E3F, 0xFC0FC0, 0xFC0FC7, 0xFC0FF8, 0xFC0FFF, + 0xFC7000, 0xFC7007, 0xFC7038, 0xFC703F, 0xFC71C0, 0xFC71C7, 0xFC71F8, 0xFC71FF, + 0xFC7E00, 0xFC7E07, 0xFC7E38, 0xFC7E3F, 0xFC7FC0, 0xFC7FC7, 0xFC7FF8, 0xFC7FFF, + 0xFF8000, 0xFF8007, 0xFF8038, 0xFF803F, 0xFF81C0, 0xFF81C7, 0xFF81F8, 0xFF81FF, + 0xFF8E00, 0xFF8E07, 0xFF8E38, 0xFF8E3F, 0xFF8FC0, 0xFF8FC7, 0xFF8FF8, 0xFF8FFF, + 0xFFF000, 0xFFF007, 0xFFF038, 0xFFF03F, 0xFFF1C0, 0xFFF1C7, 0xFFF1F8, 0xFFF1FF, + 0xFFFE00, 0xFFFE07, 0xFFFE38, 0xFFFE3F, 0xFFFFC0, 0xFFFFC7, 0xFFFFF8, 0xFFFFFF +}; + +/* + * This is a table of 24-bit values, indexed with an 8-bit byte value, + * that reverses the bit order of a byte and then expands each bit to three + * consecutive bits. This is required for color expansion in 24bpp mode + * with the coprocessor in 8bpp mode, with MSB-first bit order within a + * byte. + */ + +unsigned int byte_reversed_expand3[256] = +{ + 0x000000, 0x0000E0, 0x00001C, 0x0000FC, 0x008003, 0x0080E3, 0x00801F, 0x0080FF, + 0x007000, 0x0070E0, 0x00701C, 0x0070FC, 0x00F003, 0x00F0E3, 0x00F01F, 0x00F0FF, + 0x000E00, 0x000EE0, 0x000E1C, 0x000EFC, 0x008E03, 0x008EE3, 0x008E1F, 0x008EFF, + 0x007E00, 0x007EE0, 0x007E1C, 0x007EFC, 0x00FE03, 0x00FEE3, 0x00FE1F, 0x00FEFF, + 0xC00100, 0xC001E0, 0xC0011C, 0xC001FC, 0xC08103, 0xC081E3, 0xC0811F, 0xC081FF, + 0xC07100, 0xC071E0, 0xC0711C, 0xC071FC, 0xC0F103, 0xC0F1E3, 0xC0F11F, 0xC0F1FF, + 0xC00F00, 0xC00FE0, 0xC00F1C, 0xC00FFC, 0xC08F03, 0xC08FE3, 0xC08F1F, 0xC08FFF, + 0xC07F00, 0xC07FE0, 0xC07F1C, 0xC07FFC, 0xC0FF03, 0xC0FFE3, 0xC0FF1F, 0xC0FFFF, + 0x380000, 0x3800E0, 0x38001C, 0x3800FC, 0x388003, 0x3880E3, 0x38801F, 0x3880FF, + 0x387000, 0x3870E0, 0x38701C, 0x3870FC, 0x38F003, 0x38F0E3, 0x38F01F, 0x38F0FF, + 0x380E00, 0x380EE0, 0x380E1C, 0x380EFC, 0x388E03, 0x388EE3, 0x388E1F, 0x388EFF, + 0x387E00, 0x387EE0, 0x387E1C, 0x387EFC, 0x38FE03, 0x38FEE3, 0x38FE1F, 0x38FEFF, + 0xF80100, 0xF801E0, 0xF8011C, 0xF801FC, 0xF88103, 0xF881E3, 0xF8811F, 0xF881FF, + 0xF87100, 0xF871E0, 0xF8711C, 0xF871FC, 0xF8F103, 0xF8F1E3, 0xF8F11F, 0xF8F1FF, + 0xF80F00, 0xF80FE0, 0xF80F1C, 0xF80FFC, 0xF88F03, 0xF88FE3, 0xF88F1F, 0xF88FFF, + 0xF87F00, 0xF87FE0, 0xF87F1C, 0xF87FFC, 0xF8FF03, 0xF8FFE3, 0xF8FF1F, 0xF8FFFF, + 0x070000, 0x0700E0, 0x07001C, 0x0700FC, 0x078003, 0x0780E3, 0x07801F, 0x0780FF, + 0x077000, 0x0770E0, 0x07701C, 0x0770FC, 0x07F003, 0x07F0E3, 0x07F01F, 0x07F0FF, + 0x070E00, 0x070EE0, 0x070E1C, 0x070EFC, 0x078E03, 0x078EE3, 0x078E1F, 0x078EFF, + 0x077E00, 0x077EE0, 0x077E1C, 0x077EFC, 0x07FE03, 0x07FEE3, 0x07FE1F, 0x07FEFF, + 0xC70100, 0xC701E0, 0xC7011C, 0xC701FC, 0xC78103, 0xC781E3, 0xC7811F, 0xC781FF, + 0xC77100, 0xC771E0, 0xC7711C, 0xC771FC, 0xC7F103, 0xC7F1E3, 0xC7F11F, 0xC7F1FF, + 0xC70F00, 0xC70FE0, 0xC70F1C, 0xC70FFC, 0xC78F03, 0xC78FE3, 0xC78F1F, 0xC78FFF, + 0xC77F00, 0xC77FE0, 0xC77F1C, 0xC77FFC, 0xC7FF03, 0xC7FFE3, 0xC7FF1F, 0xC7FFFF, + 0x3F0000, 0x3F00E0, 0x3F001C, 0x3F00FC, 0x3F8003, 0x3F80E3, 0x3F801F, 0x3F80FF, + 0x3F7000, 0x3F70E0, 0x3F701C, 0x3F70FC, 0x3FF003, 0x3FF0E3, 0x3FF01F, 0x3FF0FF, + 0x3F0E00, 0x3F0EE0, 0x3F0E1C, 0x3F0EFC, 0x3F8E03, 0x3F8EE3, 0x3F8E1F, 0x3F8EFF, + 0x3F7E00, 0x3F7EE0, 0x3F7E1C, 0x3F7EFC, 0x3FFE03, 0x3FFEE3, 0x3FFE1F, 0x3FFEFF, + 0xFF0100, 0xFF01E0, 0xFF011C, 0xFF01FC, 0xFF8103, 0xFF81E3, 0xFF811F, 0xFF81FF, + 0xFF7100, 0xFF71E0, 0xFF711C, 0xFF71FC, 0xFFF103, 0xFFF1E3, 0xFFF11F, 0xFFF1FF, + 0xFF0F00, 0xFF0FE0, 0xFF0F1C, 0xFF0FFC, 0xFF8F03, 0xFF8FE3, 0xFF8F1F, 0xFF8FFF, + 0xFF7F00, 0xFF7FE0, 0xFF7F1C, 0xFF7FFC, 0xFFFF03, 0xFFFFE3, 0xFFFF1F, 0xFFFFFF, +}; diff --git a/xorg-server/hw/xfree86/xaa/xaaWideLine.c b/xorg-server/hw/xfree86/xaa/xaaWideLine.c new file mode 100644 index 000000000..a684d6676 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaWideLine.c @@ -0,0 +1,921 @@ +/* + +XAAPolylinesWideSolid does not maintain a span list and subsequently does +not follow the "touch-each-pixel-once" rules for wide lines and arcs. +This means it can only be used in the case where we have +miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we +limited usage of this function to one rect situations. This +function is used only for solid lines. + + Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu) +Original mi code written by Keith Packard. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <math.h> + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "windowstr.h" +#include "gcstruct.h" +#include "regionstr.h" +#include "miwideline.h" +#include "mi.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + +#define DRAW_POINT(pScrn, x, y) \ + if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \ + else XAAPointHelper(pScrn, x, y) + +#define FILL_RECT(pScrn, x, y, w, h) \ + if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \ + else XAAFillRectHelper(pScrn, x, y, w, h) + +#define FILL_SPAN(pScrn, x, y, w) \ + if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \ + else XAASpanHelper(pScrn, x, y, w) + + +#define CLIPSTEPEDGE(edgey,edge,edgeleft) \ + if (ybase == edgey) { \ + if (edgeleft) { \ + if (edge->x > xcl) \ + xcl = edge->x; \ + } else { \ + if (edge->x < xcr) \ + xcr = edge->x; \ + } \ + edgey++; \ + edge->x += edge->stepx; \ + edge->e += edge->dx; \ + if (edge->e > 0) { \ + edge->x += edge->signdx; \ + edge->e -= edge->dy; \ + } \ + } + +static void +XAAPointHelper(ScrnInfoPtr pScrn, int x, int y) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + BoxPtr extents = infoRec->ClipBox; + + if((x >= extents->x1) && (x < extents->x2) && + (y >= extents->y1) && (y < extents->y2)) + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); +} + +static void +XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + BoxPtr extents = infoRec->ClipBox; + int x2 = x1 + dx; + int y2 = y1 + dy; + + if(x1 < extents->x1) x1 = extents->x1; + if(x2 >= extents->x2) x2 = extents->x2; + if((dx = x2 - x1)<1) return; + if(y1 < extents->y1) y1 = extents->y1; + if(y2 >= extents->y2) y2 = extents->y2; + if((dy = y2 - y1)<1) return; + + (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy); +} + + +static void +XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + BoxPtr extents = infoRec->ClipBox; + int x2; + + if((y < extents->y1) || (y >= extents->y2)) return; + + x2 = x1 + width; + if(x1 < extents->x1) x1 = extents->x1; + if(x2 > extents->x2) x2 = extents->x2; + width = x2 - x1; + + if(width > 0) + (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1); + +} + +#define FixError(x, dx, dy, e, sign, step, h) { \ + e += (h) * dx; \ + x += (h) * step; \ + if(e > 0) { \ + x += e * sign/dy; \ + e %= dy; \ + if(e) { \ + x += sign; \ + e -= dy; \ + } \ + } \ +} + + +static void +XAAFillPolyHelper ( + GCPtr pGC, + int y, /* start y coordinate */ + int overall_height, /* height of entire segment */ + PolyEdgePtr left, PolyEdgePtr right, + int left_count, int right_count ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + BoxPtr extents = infoRec->ClipBox; + int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx; + int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx; + int height, left_height, right_height; + int xorg; + Bool hardClip; + + if((y >= extents->y2) || ((y + overall_height) <= extents->y1)) + return; + + /* Muffle compiler */ + left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0; + right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0; + + left_height = right_height = 0; + xorg = 0; + + hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + while ((left_count || left_height) && (right_count || right_height)) { + if (!left_height && left_count) { + left_height = left->height; + left_x = left->x + xorg; + left_stepx = left->stepx; + left_signdx = left->signdx; + left_e = left->e; + left_dy = left->dy; + left_dx = left->dx; + left_count--; + left++; + } + if (!right_height && right_count) { + right_height = right->height; + right_x = right->x + xorg + 1; + right_stepx = right->stepx; + right_signdx = right->signdx; + right_e = right->e; + right_dy = right->dy; + right_dx = right->dx; + right_count--; + right++; + } + + height = (left_height > right_height) ? right_height : left_height; + + left_height -= height; + right_height -= height; + + if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) { + int right_DX, left_DX; + + right_DX = (right_dx * right_signdx) + (right_stepx * right_dy); + left_DX = (left_dx * left_signdx) + (left_stepx * left_dy); + + (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height, + left_x, left_DX, left_dy, left_e, + right_x - 1, right_DX, right_dy, right_e); + + FixError(left_x, left_dx, left_dy, left_e, left_signdx, + left_stepx, height); + FixError(right_x, right_dx, right_dy, right_e, right_signdx, + right_stepx, height); + y += height; + continue; + } + + while (height--) { + if(right_x > left_x) { + FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x); + } + y++; + + left_x += left_stepx; + left_e += left_dx; + if (left_e > 0) { + left_x += left_signdx; + left_e -= left_dy; + } + right_x += right_stepx; + right_e += right_dx; + if (right_e > 0) { + right_x += right_signdx; + right_e -= right_dy; + } + + } + } +} + + + +static void +XAAWideSegment ( + GCPtr pGC, + int x1, int y1, int x2, int y2, + Bool projectLeft, Bool projectRight, + LineFacePtr leftFace, LineFacePtr rightFace ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + double l, L, r; + double xa, ya; + double projectXoff, projectYoff; + double k; + double maxy; + int x, y; + int dx, dy; + int finaly; + PolyEdgePtr left, right; + PolyEdgePtr top, bottom; + int lefty, righty, topy, bottomy; + int signdx; + PolyEdgeRec lefts[2], rights[2]; + LineFacePtr tface; + int lw = pGC->lineWidth; + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + /* draw top-to-bottom always */ + if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) { + x = x1; + x1 = x2; + x2 = x; + + y = y1; + y1 = y2; + y2 = y; + + x = projectLeft; + projectLeft = projectRight; + projectRight = x; + + tface = leftFace; + leftFace = rightFace; + rightFace = tface; + } + + dy = y2 - y1; + signdx = 1; + dx = x2 - x1; + if (dx < 0) + signdx = -1; + + leftFace->x = x1; + leftFace->y = y1; + leftFace->dx = dx; + leftFace->dy = dy; + + rightFace->x = x2; + rightFace->y = y2; + rightFace->dx = -dx; + rightFace->dy = -dy; + + if (!dy) { + rightFace->xa = 0; + rightFace->ya = (double) lw / 2.0; + rightFace->k = -(double) (lw * dx) / 2.0; + leftFace->xa = 0; + leftFace->ya = -rightFace->ya; + leftFace->k = rightFace->k; + x = x1; + if (projectLeft) + x -= (lw >> 1); + y = y1 - (lw >> 1); + dx = x2 - x; + if (projectRight) + dx += ((lw + 1) >> 1); + dy = lw; + FILL_RECT(infoRec->pScrn, x, y, dx, dy); + } else if (!dx) { + leftFace->xa = (double) lw / 2.0; + leftFace->ya = 0; + leftFace->k = (double) (lw * dy) / 2.0; + rightFace->xa = -leftFace->xa; + rightFace->ya = 0; + rightFace->k = leftFace->k; + y = y1; + if (projectLeft) + y -= lw >> 1; + x = x1 - (lw >> 1); + dy = y2 - y; + if (projectRight) + dy += ((lw + 1) >> 1); + dx = lw; + FILL_RECT(infoRec->pScrn, x, y, dx, dy); + } else { + l = ((double) lw) / 2.0; + L = sqrt((double)(dx*dx + dy*dy)); + + if (dx < 0) { + right = &rights[1]; + left = &lefts[0]; + top = &rights[0]; + bottom = &lefts[1]; + } else { + right = &rights[0]; + left = &lefts[1]; + top = &lefts[0]; + bottom = &rights[1]; + } + r = l / L; + + /* coord of upper bound at integral y */ + ya = -r * dx; + xa = r * dy; + + projectXoff = -ya; + projectYoff = xa; + + /* xa * dy - ya * dx */ + k = l * L; + + leftFace->xa = xa; + leftFace->ya = ya; + leftFace->k = k; + rightFace->xa = -xa; + rightFace->ya = -ya; + rightFace->k = k; + + if (projectLeft) + righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, + k, dx, dy, x1, y1, 0, right); + else + righty = miPolyBuildEdge (xa, ya, + k, dx, dy, x1, y1, 0, right); + + /* coord of lower bound at integral y */ + ya = -ya; + xa = -xa; + + /* xa * dy - ya * dx */ + k = - k; + + if (projectLeft) + lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, + k, dx, dy, x1, y1, 1, left); + else + lefty = miPolyBuildEdge (xa, ya, + k, dx, dy, x1, y1, 1, left); + + /* coord of top face at integral y */ + + if (signdx > 0) { + ya = -ya; + xa = -xa; + } + + if (projectLeft) { + double xap = xa - projectXoff; + double yap = ya - projectYoff; + topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, + -dy, dx, x1, y1, dx > 0, top); + } + else + topy = miPolyBuildEdge(xa, ya, 0.0, + -dy, dx, x1, y1, dx > 0, top); + + /* coord of bottom face at integral y */ + + if (projectRight) { + double xap = xa + projectXoff; + double yap = ya + projectYoff; + bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, + -dy, dx, x2, y2, dx < 0, bottom); + maxy = -ya + projectYoff; + } else { + bottomy = miPolyBuildEdge (xa, ya, 0.0, + -dy, dx, x2, y2, dx < 0, bottom); + maxy = -ya; + } + + finaly = ICEIL (maxy) + y2; + + if (dx < 0) { + left->height = bottomy - lefty; + right->height = finaly - righty; + top->height = righty - topy; + } else { + right->height = bottomy - righty; + left->height = finaly - lefty; + top->height = lefty - topy; + } + bottom->height = finaly - bottomy; + XAAFillPolyHelper (pGC, topy, + bottom->height + bottomy - topy, lefts, rights, 2, 2); + } +} + + +static void +XAALineArcI (GCPtr pGC, int xorg, int yorg) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int x, y, e, ex; + int slw = pGC->lineWidth; + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + y = (slw >> 1) + 1; + if (slw & 1) + e = - ((y << 2) + 3); + else + e = - (y << 3); + ex = -4; + x = 0; + while (y) { + e += (y << 3) - 4; + while (e >= 0) { + x++; + e += (ex = -((x << 3) + 4)); + } + y--; + slw = (x << 1) + 1; + if ((e == ex) && (slw > 1)) + slw--; + + FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw); + + if ((y != 0) && ((slw > 1) || (e != ex))) { + FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw); + } + } +} + + +static void +XAALineArcD ( + GCPtr pGC, + double xorg, + double yorg, + PolyEdgePtr edge1, + int edgey1, + Bool edgeleft1, + PolyEdgePtr edge2, + int edgey2, + Bool edgeleft2 ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + double radius, x0, y0, el, er, yk, xlk, xrk, k; + int xbase, ybase, y, boty, xl, xr, xcl, xcr; + int ymin, ymax; + Bool edge1IsMin, edge2IsMin; + int ymin1, ymin2; + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + + xbase = floor(xorg); + x0 = xorg - xbase; + ybase = ICEIL (yorg); + y0 = yorg - ybase; + + xlk = x0 + x0 + 1.0; + xrk = x0 + x0 - 1.0; + yk = y0 + y0 - 1.0; + radius = ((double)pGC->lineWidth) / 2.0; + y = floor(radius - y0 + 1.0); + ybase -= y; + ymin = ybase; + ymax = 65536; + edge1IsMin = FALSE; + ymin1 = edgey1; + if (edge1->dy >= 0) { + if (!edge1->dy) { + if (edgeleft1) + edge1IsMin = TRUE; + else + ymax = edgey1; + edgey1 = 65536; + } else if ((edge1->signdx < 0) == edgeleft1) + edge1IsMin = TRUE; + } + edge2IsMin = FALSE; + ymin2 = edgey2; + if (edge2->dy >= 0) { + if (!edge2->dy) { + if (edgeleft2) + edge2IsMin = TRUE; + else + ymax = edgey2; + edgey2 = 65536; + } else if ((edge2->signdx < 0) == edgeleft2) + edge2IsMin = TRUE; + } + if (edge1IsMin) { + ymin = ymin1; + if (edge2IsMin && (ymin1 > ymin2)) + ymin = ymin2; + } else if (edge2IsMin) + ymin = ymin2; + el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0); + er = el + xrk; + xl = 1; + xr = 0; + if (x0 < 0.5) { + xl = 0; + el -= xlk; + } + boty = (y0 < -0.5) ? 1 : 0; + if (ybase + y - boty > ymax) + boty = ymax - ybase - y; + while (y > boty) { + k = (y << 1) + yk; + er += k; + while (er > 0.0) { + xr++; + er += xrk - (xr << 1); + } + el += k; + while (el >= 0.0) { + xl--; + el += (xl << 1) - xlk; + } + y--; + ybase++; + if (ybase < ymin) + continue; + xcl = xl + xbase; + xcr = xr + xbase; + CLIPSTEPEDGE(edgey1, edge1, edgeleft1); + CLIPSTEPEDGE(edgey2, edge2, edgeleft2); + if(xcr >= xcl) { + FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); + } + } + er = xrk - (xr << 1) - er; + el = (xl << 1) - xlk - el; + boty = floor(-y0 - radius + 1.0); + if (ybase + y - boty > ymax) + boty = ymax - ybase - y; + while (y > boty) { + k = (y << 1) + yk; + er -= k; + while ((er >= 0.0) && (xr >= 0)) { + xr--; + er += xrk - (xr << 1); + } + el -= k; + while ((el > 0.0) && (xl <= 0)) { + xl++; + el += (xl << 1) - xlk; + } + y--; + ybase++; + if (ybase < ymin) + continue; + xcl = xl + xbase; + xcr = xr + xbase; + CLIPSTEPEDGE(edgey1, edge1, edgeleft1); + CLIPSTEPEDGE(edgey2, edge2, edgeleft2); + if(xcr >= xcl) { + FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); + } + } +} + + +static void +XAALineArc ( + GCPtr pGC, + LineFacePtr leftFace, + LineFacePtr rightFace, + double xorg, + double yorg, + Bool isInt ) +{ + int xorgi, yorgi; + PolyEdgeRec edge1, edge2; + int edgey1, edgey2; + Bool edgeleft1, edgeleft2; + + if (isInt) { + xorgi = leftFace ? leftFace->x : rightFace->x; + yorgi = leftFace ? leftFace->y : rightFace->y; + } else { /* Muffle compiler */ + xorgi = yorgi = 0; + } + edgey1 = 65536; + edgey2 = 65536; + edge1.x = 0; /* not used, keep memory checkers happy */ + edge1.dy = -1; + edge2.x = 0; /* not used, keep memory checkers happy */ + edge2.dy = -1; + edgeleft1 = FALSE; + edgeleft2 = FALSE; + + if ((pGC->lineWidth > 2) && + ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) || + (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) { + if (isInt) { + xorg = (double) xorgi; + yorg = (double) yorgi; + } + + if (leftFace && rightFace) + miRoundJoinClip (leftFace, rightFace, &edge1, &edge2, + &edgey1, &edgey2, &edgeleft1, &edgeleft2); + else if (leftFace) + edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1); + else if (rightFace) + edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2); + + isInt = FALSE; + } + + if (isInt) { + if(pGC->lineWidth == 1) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + DRAW_POINT(infoRec->pScrn, xorgi, yorgi); + } else + XAALineArcI(pGC, xorgi, yorgi); + } else + XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1, + &edge2, edgey2, edgeleft2); + +} + + +static void +XAALineJoin ( + GCPtr pGC, + LineFacePtr pLeft, + LineFacePtr pRight ) +{ + double mx = 0, my = 0; + double denom = 0; + PolyVertexRec vertices[4]; + PolySlopeRec slopes[4]; + int edgecount; + PolyEdgeRec left[4], right[4]; + int nleft, nright; + int y, height; + int swapslopes; + int joinStyle = pGC->joinStyle; + int lw = pGC->lineWidth; + + if (lw == 1) { + /* Lines going in the same direction have no join */ + if ((pLeft->dx >= 0) == (pRight->dx <= 0)) + return; + if (joinStyle != JoinRound) { + denom = - pLeft->dx * (double)pRight->dy + pRight->dx * + (double)pLeft->dy; + if (denom == 0.0) + return; /* no join to draw */ + } + if (joinStyle != JoinMiter) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y); + return; + } + } else { + if (joinStyle == JoinRound) { + XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE); + return; + } + denom = - pLeft->dx * (double)pRight->dy + pRight->dx * + (double)pLeft->dy; + if (denom == 0.0) + return; /* no join to draw */ + } + + swapslopes = 0; + if (denom > 0) { + pLeft->xa = -pLeft->xa; + pLeft->ya = -pLeft->ya; + pLeft->dx = -pLeft->dx; + pLeft->dy = -pLeft->dy; + } else { + swapslopes = 1; + pRight->xa = -pRight->xa; + pRight->ya = -pRight->ya; + pRight->dx = -pRight->dx; + pRight->dy = -pRight->dy; + } + + vertices[0].x = pRight->xa; + vertices[0].y = pRight->ya; + slopes[0].dx = -pRight->dy; + slopes[0].dy = pRight->dx; + slopes[0].k = 0; + + vertices[1].x = 0; + vertices[1].y = 0; + slopes[1].dx = pLeft->dy; + slopes[1].dy = -pLeft->dx; + slopes[1].k = 0; + + vertices[2].x = pLeft->xa; + vertices[2].y = pLeft->ya; + + if (joinStyle == JoinMiter) { + my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) - + pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/ + denom; + if (pLeft->dy != 0) + mx = pLeft->xa + (my - pLeft->ya) * + (double) pLeft->dx / (double) pLeft->dy; + else + mx = pRight->xa + (my - pRight->ya) * + (double) pRight->dx / (double) pRight->dy; + + /* check miter limit */ + if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw) + joinStyle = JoinBevel; + } + + if (joinStyle == JoinMiter) { + slopes[2].dx = pLeft->dx; + slopes[2].dy = pLeft->dy; + slopes[2].k = pLeft->k; + if (swapslopes) { + slopes[2].dx = -slopes[2].dx; + slopes[2].dy = -slopes[2].dy; + slopes[2].k = -slopes[2].k; + } + vertices[3].x = mx; + vertices[3].y = my; + slopes[3].dx = pRight->dx; + slopes[3].dy = pRight->dy; + slopes[3].k = pRight->k; + if (swapslopes) { + slopes[3].dx = -slopes[3].dx; + slopes[3].dy = -slopes[3].dy; + slopes[3].k = -slopes[3].k; + } + edgecount = 4; + } else { + double scale, dx, dy, adx, ady; + + adx = dx = pRight->xa - pLeft->xa; + ady = dy = pRight->ya - pLeft->ya; + if (adx < 0) + adx = -adx; + if (ady < 0) + ady = -ady; + scale = ady; + if (adx > ady) + scale = adx; + slopes[2].dx = (dx * 65536) / scale; + slopes[2].dy = (dy * 65536) / scale; + slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy - + (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0; + edgecount = 3; + } + + y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y, + left, right, &nleft, &nright, &height); + XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright); +} + + +void +XAAPolylinesWideSolid ( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int x1, y1, x2, y2; + Bool projectLeft, projectRight; + LineFaceRec leftFace, rightFace, prevRightFace, firstFace; + int first = TRUE; + Bool somethingDrawn = FALSE; + Bool selfJoin = FALSE; + int xorg = pDrawable->x; + int yorg = pDrawable->y; + Bool hardClip = FALSE; + + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + return; + + if(REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { + miWideLine(pDrawable, pGC, mode, npt, pPts); + return; + } + + x2 = pPts->x; + y2 = pPts->y; + if (npt > 1) { + if (mode == CoordModePrevious) { + int nptTmp; + register DDXPointPtr pPtsTmp; + + x1 = x2; + y1 = y2; + nptTmp = npt; + pPtsTmp = pPts + 1; + while (--nptTmp) { + x1 += pPtsTmp->x; + y1 += pPtsTmp->y; + ++pPtsTmp; + } + if ((x2 == x1) && (y2 == y1)) + selfJoin = TRUE; + } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y)) + selfJoin = TRUE; + } + + projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin); + projectRight = FALSE; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + infoRec->ClipBox = &pGC->pCompositeClip->extents; + + if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) { + hardClip = TRUE; + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + } + + x2 += xorg; + y2 += yorg; + while (--npt) { + x1 = x2; + y1 = y2; + ++pPts; + x2 = pPts->x; + y2 = pPts->y; + if (mode == CoordModePrevious) { + x2 += x1; + y2 += y1; + } else { + x2 += xorg; + y2 += yorg; + } + if ((x1 != x2) || (y1 != y2)) { + somethingDrawn = TRUE; + if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin) + projectRight = TRUE; + XAAWideSegment(pGC, x1, y1, x2, y2, + projectLeft, projectRight, &leftFace, &rightFace); + if (first) { + if (selfJoin) + firstFace = leftFace; + else if (pGC->capStyle == CapRound) { + if (pGC->lineWidth == 1) { + DRAW_POINT(infoRec->pScrn, x1, y1); + } else + XAALineArc(pGC,&leftFace, (LineFacePtr) NULL, + (double)0.0, (double)0.0,TRUE); + } + } else + XAALineJoin (pGC, &leftFace, &prevRightFace); + + prevRightFace = rightFace; + first = FALSE; + projectLeft = FALSE; + } + if (npt == 1 && somethingDrawn) { + if (selfJoin) + XAALineJoin (pGC, &firstFace, &rightFace); + else if (pGC->capStyle == CapRound) { + if (pGC->lineWidth == 1) { + DRAW_POINT(infoRec->pScrn, x2, y2); + } else + XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, + (double)0.0, (double)0.0,TRUE); + } + } + } + /* handle crock where all points are coincedent */ + if (!somethingDrawn) { + projectLeft = (pGC->capStyle == CapProjecting); + XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft, + &leftFace, &rightFace); + if (pGC->capStyle == CapRound) { + XAALineArc (pGC, &leftFace, (LineFacePtr) NULL, + (double)0.0, (double)0.0, TRUE); + rightFace.dx = -1; /* sleezy hack to make it work */ + XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, + (double)0.0, (double)0.0, TRUE); + } + } + + infoRec->ClipBox = NULL; + if(hardClip) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaWrapper.c b/xorg-server/hw/xfree86/xaa/xaaWrapper.c new file mode 100644 index 000000000..5d6ea05cf --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaWrapper.c @@ -0,0 +1,484 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "scrnintstr.h" +#include "gcstruct.h" +#include "glyphstr.h" +#include "window.h" +#include "windowstr.h" +#include "picture.h" +#include "picturestr.h" +#include "colormapst.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaaWrapper.h" + +void XAASync(ScreenPtr pScreen); + +/* #include "render.h" */ + +#if 1 +#define COND(pDraw) \ + ((pDraw)->depth \ + != (xaaWrapperGetScrPriv(((DrawablePtr)(pDraw))->pScreen))->depth) +#else +#define COND(pDraw) 1 +#endif + +static Bool xaaWrapperCreateGC(GCPtr pGC); +static void xaaWrapperValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw); +static void xaaWrapperDestroyGC(GCPtr pGC); +static void xaaWrapperChangeGC (GCPtr pGC, unsigned long mask); +static void xaaWrapperCopyGC (GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); +static void xaaWrapperChangeClip (GCPtr pGC, int type, pointer pvalue, int nrects); + +static void xaaWrapperCopyClip(GCPtr pgcDst, GCPtr pgcSrc); +static void xaaWrapperDestroyClip(GCPtr pGC); + + +static void +xaaWrapperComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, + INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); +static void +xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, + GlyphListPtr list, GlyphPtr *glyphs); + + +typedef struct { + CloseScreenProcPtr CloseScreen; + CreateScreenResourcesProcPtr CreateScreenResources; + CreateWindowProcPtr CreateWindow; + CopyWindowProcPtr CopyWindow; + WindowExposuresProcPtr WindowExposures; + CreateGCProcPtr CreateGC; + CreateColormapProcPtr CreateColormap; + DestroyColormapProcPtr DestroyColormap; + InstallColormapProcPtr InstallColormap; + UninstallColormapProcPtr UninstallColormap; + ListInstalledColormapsProcPtr ListInstalledColormaps; + StoreColorsProcPtr StoreColors; +#ifdef RENDER + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; +#endif + + CloseScreenProcPtr wrapCloseScreen; + CreateScreenResourcesProcPtr wrapCreateScreenResources; + CreateWindowProcPtr wrapCreateWindow; + CopyWindowProcPtr wrapCopyWindow; + WindowExposuresProcPtr wrapWindowExposures; + CreateGCProcPtr wrapCreateGC; + CreateColormapProcPtr wrapCreateColormap; + DestroyColormapProcPtr wrapDestroyColormap; + InstallColormapProcPtr wrapInstallColormap; + UninstallColormapProcPtr wrapUninstallColormap; + ListInstalledColormapsProcPtr wrapListInstalledColormaps; + StoreColorsProcPtr wrapStoreColors; +#ifdef RENDER + CompositeProcPtr wrapComposite; + GlyphsProcPtr wrapGlyphs; +#endif + int depth; +} xaaWrapperScrPrivRec, *xaaWrapperScrPrivPtr; + +#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr) \ + dixLookupPrivate(&(s)->devPrivates, xaaWrapperScrPrivateKey)) +#define xaaWrapperScrPriv(s) xaaWrapperScrPrivPtr pScrPriv = xaaWrapperGetScrPriv(s) + +#define wrap(priv,real,mem,func) {\ + priv->mem = real->mem; \ + real->mem = func; \ +} + +#define unwrap(priv,real,mem) {\ + real->mem = priv->mem; \ +} + +#define cond_wrap(priv,cond,real,mem,wrapmem,func) {\ + if (COND(cond)) \ + priv->wrapmem = real->mem; \ + else \ + priv->mem = real->mem; \ + real->mem = func; \ +} + +#define cond_unwrap(priv,cond,real,mem,wrapmem) {\ + if (COND(cond)) \ + real->mem = priv->wrapmem; \ + else \ + real->mem = priv->mem; \ +} + +#define get(priv,real,func,wrap) \ + priv->wrap = real->func; + +typedef struct _xaaWrapperGCPriv { + GCOps *ops; + Bool wrap; + GCFuncs *funcs; + GCOps *wrapops; +} xaaWrapperGCPrivRec, *xaaWrapperGCPrivPtr; + +#define xaaWrapperGetGCPriv(pGC) ((xaaWrapperGCPrivPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, xaaWrapperGCPrivateKey)) +#define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC) + + +static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKey; +static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKey; + +static Bool +xaaWrapperCreateScreenResources(ScreenPtr pScreen) +{ + xaaWrapperScrPriv(pScreen); + Bool ret; + + unwrap (pScrPriv,pScreen, CreateScreenResources); + ret = pScreen->CreateScreenResources(pScreen); + wrap(pScrPriv,pScreen,CreateScreenResources,xaaWrapperCreateScreenResources); + return ret; +} + +static Bool +xaaWrapperCloseScreen (int iScreen, ScreenPtr pScreen) +{ + xaaWrapperScrPriv(pScreen); + Bool ret; + + unwrap (pScrPriv,pScreen, CloseScreen); + ret = pScreen->CloseScreen(iScreen,pScreen); + return TRUE; +} + +static Bool +xaaWrapperCreateWindow(WindowPtr pWin) +{ + xaaWrapperScrPriv(pWin->drawable.pScreen); + Bool ret; + + cond_unwrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen, + CreateWindow, wrapCreateWindow); + ret = pWin->drawable.pScreen->CreateWindow(pWin); + cond_wrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen, CreateWindow, + wrapCreateWindow, xaaWrapperCreateWindow); + + return ret; +} + +static void +xaaWrapperCopyWindow(WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + xaaWrapperScrPriv(pScreen); + + unwrap (pScrPriv, pScreen, CopyWindow); +#if 0 + if (COND(&pWin->drawable)) + pWin->drawable.pScreen->CopyWindow = pScrPriv->wrapCopyWindow; +#endif + pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc); + wrap(pScrPriv, pScreen, CopyWindow, xaaWrapperCopyWindow); +} + +static void +xaaWrapperWindowExposures (WindowPtr pWin, + RegionPtr prgn, + RegionPtr other_exposed) +{ + xaaWrapperScrPriv(pWin->drawable.pScreen); + + cond_unwrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen, + WindowExposures, wrapWindowExposures); + pWin->drawable.pScreen->WindowExposures(pWin, prgn, other_exposed); + cond_wrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen, + WindowExposures, wrapWindowExposures, xaaWrapperWindowExposures); +} + +static Bool +xaaWrapperCreateColormap(ColormapPtr pmap) +{ + xaaWrapperScrPriv(pmap->pScreen); + Bool ret; + unwrap(pScrPriv,pmap->pScreen, CreateColormap); + ret = pmap->pScreen->CreateColormap(pmap); + wrap(pScrPriv,pmap->pScreen,CreateColormap,xaaWrapperCreateColormap); + + return ret; +} + +static void +xaaWrapperDestroyColormap(ColormapPtr pmap) +{ + xaaWrapperScrPriv(pmap->pScreen); + unwrap(pScrPriv,pmap->pScreen, DestroyColormap); + pmap->pScreen->DestroyColormap(pmap); + wrap(pScrPriv,pmap->pScreen,DestroyColormap,xaaWrapperDestroyColormap); +} + +static void +xaaWrapperStoreColors(ColormapPtr pmap, int nColors, xColorItem *pColors) +{ + xaaWrapperScrPriv(pmap->pScreen); + unwrap(pScrPriv,pmap->pScreen, StoreColors); + pmap->pScreen->StoreColors(pmap,nColors,pColors); + wrap(pScrPriv,pmap->pScreen,StoreColors,xaaWrapperStoreColors); +} + +static void +xaaWrapperInstallColormap(ColormapPtr pmap) +{ + xaaWrapperScrPriv(pmap->pScreen); + + unwrap(pScrPriv,pmap->pScreen, InstallColormap); + pmap->pScreen->InstallColormap(pmap); + wrap(pScrPriv,pmap->pScreen,InstallColormap,xaaWrapperInstallColormap); +} + +static void +xaaWrapperUninstallColormap(ColormapPtr pmap) +{ + xaaWrapperScrPriv(pmap->pScreen); + + unwrap(pScrPriv,pmap->pScreen, UninstallColormap); + pmap->pScreen->UninstallColormap(pmap); + wrap(pScrPriv,pmap->pScreen,UninstallColormap,xaaWrapperUninstallColormap); +} + +static int +xaaWrapperListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds) +{ + int n; + xaaWrapperScrPriv(pScreen); + + unwrap(pScrPriv,pScreen, ListInstalledColormaps); + n = pScreen->ListInstalledColormaps(pScreen, pCmapIds); + wrap (pScrPriv,pScreen,ListInstalledColormaps,xaaWrapperListInstalledColormaps); + return n; +} + +Bool +xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *func) +{ + Bool ret; + xaaWrapperScrPrivPtr pScrPriv; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec))) + return FALSE; + + pScrPriv = (xaaWrapperScrPrivPtr) xalloc (sizeof (xaaWrapperScrPrivRec)); + if (!pScrPriv) + return FALSE; + + get (pScrPriv, pScreen, CloseScreen, wrapCloseScreen); + get (pScrPriv, pScreen, CreateScreenResources, wrapCreateScreenResources); + get (pScrPriv, pScreen, CreateWindow, wrapCreateWindow); + get (pScrPriv, pScreen, CopyWindow, wrapCopyWindow); + get (pScrPriv, pScreen, WindowExposures, wrapWindowExposures); + get (pScrPriv, pScreen, CreateGC, wrapCreateGC); + get (pScrPriv, pScreen, CreateColormap, wrapCreateColormap); + get (pScrPriv, pScreen, DestroyColormap, wrapDestroyColormap); + get (pScrPriv, pScreen, InstallColormap, wrapInstallColormap); + get (pScrPriv, pScreen, UninstallColormap, wrapUninstallColormap); + get (pScrPriv, pScreen, ListInstalledColormaps, wrapListInstalledColormaps); + get (pScrPriv, pScreen, StoreColors, wrapStoreColors); +#ifdef RENDER + if (ps) { + get (pScrPriv, ps, Glyphs, wrapGlyphs); + get (pScrPriv, ps, Composite, wrapComposite); + } +#endif + if (!(ret = XAAInit(pScreen,infoPtr))) + return FALSE; + + wrap (pScrPriv, pScreen, CloseScreen, xaaWrapperCloseScreen); + wrap (pScrPriv, pScreen, CreateScreenResources, + xaaWrapperCreateScreenResources); + wrap (pScrPriv, pScreen, CreateWindow, xaaWrapperCreateWindow); + wrap (pScrPriv, pScreen, CopyWindow, xaaWrapperCopyWindow); + wrap (pScrPriv, pScreen, WindowExposures, xaaWrapperWindowExposures); + wrap (pScrPriv, pScreen, CreateGC, xaaWrapperCreateGC); + wrap (pScrPriv, pScreen, CreateColormap, xaaWrapperCreateColormap); + wrap (pScrPriv, pScreen, DestroyColormap, xaaWrapperDestroyColormap); + wrap (pScrPriv, pScreen, InstallColormap, xaaWrapperInstallColormap); + wrap (pScrPriv, pScreen, UninstallColormap, xaaWrapperUninstallColormap); + wrap (pScrPriv, pScreen, ListInstalledColormaps, + xaaWrapperListInstalledColormaps); + wrap (pScrPriv, pScreen, StoreColors, xaaWrapperStoreColors); + +#ifdef RENDER + if (ps) { + wrap (pScrPriv, ps, Glyphs, xaaWrapperGlyphs); + wrap (pScrPriv, ps, Composite, xaaWrapperComposite); + } +#endif + pScrPriv->depth = depth; + dixSetPrivate(&pScreen->devPrivates, xaaWrapperScrPrivateKey, pScrPriv); + + *func = XAASync; + + return ret; +} + +GCFuncs xaaWrapperGCFuncs = { + xaaWrapperValidateGC, xaaWrapperChangeGC, xaaWrapperCopyGC, + xaaWrapperDestroyGC, xaaWrapperChangeClip, xaaWrapperDestroyClip, + xaaWrapperCopyClip +}; + +#define XAAWRAPPER_GC_FUNC_PROLOGUE(pGC) \ + xaaWrapperGCPriv(pGC); \ + unwrap(pGCPriv, pGC, funcs); \ + if (pGCPriv->wrap) unwrap(pGCPriv, pGC, ops) + +#define XAAWRAPPER_GC_FUNC_EPILOGUE(pGC) \ + wrap(pGCPriv, pGC, funcs, &xaaWrapperGCFuncs); \ + if (pGCPriv->wrap) wrap(pGCPriv, pGC, ops, pGCPriv->wrapops) + +static Bool +xaaWrapperCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + xaaWrapperScrPriv(pScreen); + xaaWrapperGCPriv(pGC); + Bool ret; + + unwrap (pScrPriv, pScreen, CreateGC); + if((ret = (*pScreen->CreateGC) (pGC))) { + pGCPriv->wrap = FALSE; + pGCPriv->funcs = pGC->funcs; + pGCPriv->wrapops = pGC->ops; + pGC->funcs = &xaaWrapperGCFuncs; + } + wrap (pScrPriv, pScreen, CreateGC, xaaWrapperCreateGC); + + return ret; +} + +static void +xaaWrapperValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + XAAWRAPPER_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + + if(COND(pDraw)) + pGCPriv->wrap = TRUE; + + XAAWRAPPER_GC_FUNC_EPILOGUE (pGC); +} + +static void +xaaWrapperDestroyGC(GCPtr pGC) +{ + XAAWRAPPER_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->DestroyGC)(pGC); + XAAWRAPPER_GC_FUNC_EPILOGUE (pGC); +} + +static void +xaaWrapperChangeGC ( + GCPtr pGC, + unsigned long mask +){ + XAAWRAPPER_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + XAAWRAPPER_GC_FUNC_EPILOGUE (pGC); +} + +static void +xaaWrapperCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst +){ + XAAWRAPPER_GC_FUNC_PROLOGUE (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + XAAWRAPPER_GC_FUNC_EPILOGUE (pGCDst); +} + +static void +xaaWrapperChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects +){ + XAAWRAPPER_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + XAAWRAPPER_GC_FUNC_EPILOGUE (pGC); +} + +static void +xaaWrapperCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + XAAWRAPPER_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + XAAWRAPPER_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +xaaWrapperDestroyClip(GCPtr pGC) +{ + XAAWRAPPER_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + XAAWRAPPER_GC_FUNC_EPILOGUE (pGC); +} + +#ifdef RENDER +static void +xaaWrapperComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, + INT16 xDst, INT16 yDst, CARD16 width, CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xaaWrapperScrPriv(pScreen); + + unwrap (pScrPriv, ps, Composite); + (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); + wrap (pScrPriv, ps, Composite, xaaWrapperComposite); +} + + +static void +xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, + GlyphListPtr list, GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xaaWrapperScrPriv(pScreen); + + unwrap (pScrPriv, ps, Glyphs); + (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlist, list, glyphs); + wrap (pScrPriv, ps, Glyphs, xaaWrapperGlyphs); + +} +#endif + +void +XAASync(ScreenPtr pScreen) +{ + XAAScreenPtr pScreenPriv = (XAAScreenPtr) + dixLookupPrivate(&pScreen->devPrivates, XAAGetScreenKey()); + XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec; + + if(infoRec->NeedToSync) { + (*infoRec->Sync)(infoRec->pScrn); + infoRec->NeedToSync = FALSE; + } +} diff --git a/xorg-server/hw/xfree86/xaa/xaaWrapper.h b/xorg-server/hw/xfree86/xaa/xaaWrapper.h new file mode 100644 index 000000000..a141d8421 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaaWrapper.h @@ -0,0 +1,10 @@ + +#ifndef _XAA_WRAPPER_H +# define _XAA_WRAPPER_H + +typedef void (*SyncFunc)(ScreenPtr); + +Bool xaaSetupWrapper(ScreenPtr pScreen, + XAAInfoRecPtr infoPtr, int depth, SyncFunc *func); + +#endif diff --git a/xorg-server/hw/xfree86/xaa/xaacexp.h b/xorg-server/hw/xfree86/xaa/xaacexp.h new file mode 100644 index 000000000..56bcda69a --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaacexp.h @@ -0,0 +1,127 @@ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/Xarch.h> + +#ifndef FIXEDBASE +#define CHECKRETURN(b) if(width <= ((b) * 32)) return(base + (b)) +#else +#define CHECKRETURN(b) if(width <= ((b) * 32)) return(base) +#endif + +#if X_BYTE_ORDER == X_BIG_ENDIAN +# define SHIFT_L(value, shift) ((value) >> (shift)) +# define SHIFT_R(value, shift) ((value) << (shift)) +#else +# define SHIFT_L(value, shift) ((value) << (shift)) +# define SHIFT_R(value, shift) ((value) >> (shift)) +#endif + +#ifndef MSBFIRST +# ifdef FIXEDBASE +# define WRITE_IN_BITORDER(dest, offset, data) *(dest) = data; +# else +# define WRITE_IN_BITORDER(dest, offset, data) *(dest + offset) = data; +# endif +#else +# ifdef FIXEDBASE +# define WRITE_IN_BITORDER(dest, offset, data) *(dest) = SWAP_BITS_IN_BYTES(data); +# else +# define WRITE_IN_BITORDER(dest, offset, data) *(dest + offset) = SWAP_BITS_IN_BYTES(data) +# endif +#endif + +#ifdef FIXEDBASE +# ifdef MSBFIRST +# define WRITE_BITS(b) *base = SWAP_BITS_IN_BYTES(b) +# define WRITE_BITS1(b) { \ + *base = byte_reversed_expand3[(b) & 0xFF] | \ + byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; } +# define WRITE_BITS2(b) { \ + *base = byte_reversed_expand3[(b) & 0xFF] | \ + byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ + *base = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; } +# define WRITE_BITS3(b) { \ + *base = byte_reversed_expand3[(b) & 0xFF] | \ + byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ + *base = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \ + *base = byte_reversed_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ + byte_reversed_expand3[((b) & 0xFF000000) >> 24] << 8; } +# else +# define WRITE_BITS(b) *base = (b) +# define WRITE_BITS1(b) { \ + *base = byte_expand3[(b) & 0xFF] | \ + byte_expand3[((b) & 0xFF00) >> 8] << 24; } +# define WRITE_BITS2(b) { \ + *base = byte_expand3[(b) & 0xFF] | \ + byte_expand3[((b) & 0xFF00) >> 8] << 24; \ + *base = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_expand3[((b) & 0xFF0000) >> 16] << 16; } +# define WRITE_BITS3(b) { \ + *base = byte_expand3[(b) & 0xFF] | \ + byte_expand3[((b) & 0xFF00) >> 8] << 24; \ + *base = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_expand3[((b) & 0xFF0000) >> 16] << 16; \ + *base = byte_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ + byte_expand3[((b) & 0xFF000000) >> 24] << 8; } +# endif +#else +# ifdef MSBFIRST +# define WRITE_BITS(b) *(base++) = SWAP_BITS_IN_BYTES(b) +# define WRITE_BITS1(b) { \ + *(base++) = byte_reversed_expand3[(b) & 0xFF] | \ + byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; } +# define WRITE_BITS2(b) { \ + *(base) = byte_reversed_expand3[(b) & 0xFF] | \ + byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ + *(base + 1) = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \ + base += 2; } +# define WRITE_BITS3(b) { \ + *(base) = byte_reversed_expand3[(b) & 0xFF] | \ + byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ + *(base + 1) = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \ + *(base + 2) = byte_reversed_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ + byte_reversed_expand3[((b) & 0xFF000000) >> 24] << 8; \ + base += 3; } +# else +# define WRITE_BITS(b) *(base++) = (b) +# define WRITE_BITS1(b) { \ + *(base++) = byte_expand3[(b) & 0xFF] | \ + byte_expand3[((b) & 0xFF00) >> 8] << 24; } +# define WRITE_BITS2(b) { \ + *(base) = byte_expand3[(b) & 0xFF] | \ + byte_expand3[((b) & 0xFF00) >> 8] << 24; \ + *(base + 1) = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_expand3[((b) & 0xFF0000) >> 16] << 16; \ + base += 2; } +# define WRITE_BITS3(b) { \ + *(base) = byte_expand3[(b) & 0xFF] | \ + byte_expand3[((b) & 0xFF00) >> 8] << 24; \ + *(base + 1) = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ + byte_expand3[((b) & 0xFF0000) >> 16] << 16; \ + *(base + 2) = byte_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ + byte_expand3[((b) & 0xFF000000) >> 24] << 8; \ + base += 3; } +# endif +#endif + +#ifdef FIXEDBASE +# ifdef MSBFIRST +# define EXPNAME(x) x##MSBFirstFixedBase +# else +# define EXPNAME(x) x##LSBFirstFixedBase +# endif +#else +# ifdef MSBFIRST +# define EXPNAME(x) x##MSBFirst +# else +# define EXPNAME(x) x##LSBFirst +# endif +#endif diff --git a/xorg-server/hw/xfree86/xaa/xaalocal.h b/xorg-server/hw/xfree86/xaa/xaalocal.h new file mode 100644 index 000000000..e25b9df52 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaalocal.h @@ -0,0 +1,1758 @@ + +#ifndef _XAALOCAL_H +#define _XAALOCAL_H + +/* This file is very unorganized ! */ + + +#include "gcstruct.h" +#include "regionstr.h" +#include "xf86fbman.h" +#include "xaa.h" +#include "mi.h" +#ifdef RENDER +#include "picturestr.h" +#endif + +#define GCWhenForced (GCArcMode << 1) + +#define DO_COLOR_8x8 0x00000001 +#define DO_MONO_8x8 0x00000002 +#define DO_CACHE_BLT 0x00000003 +#define DO_COLOR_EXPAND 0x00000004 +#define DO_CACHE_EXPAND 0x00000005 +#define DO_IMAGE_WRITE 0x00000006 +#define DO_PIXMAP_COPY 0x00000007 +#define DO_SOLID 0x00000008 + + +typedef CARD32 * (*GlyphScanlineFuncPtr)( + CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width +); + +typedef CARD32 *(*StippleScanlineProcPtr)(CARD32*, CARD32*, int, int, int); + +typedef void (*RectFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int, + XAACacheInfoPtr); +typedef void (*TrapFuncPtr) (ScrnInfoPtr, int, int, int, int, int, int, + int, int, int, int, int, int, + XAACacheInfoPtr); + + + +typedef struct _XAAScreen { + CreateGCProcPtr CreateGC; + CloseScreenProcPtr CloseScreen; + GetImageProcPtr GetImage; + GetSpansProcPtr GetSpans; + CopyWindowProcPtr CopyWindow; + WindowExposuresProcPtr WindowExposures; + CreatePixmapProcPtr CreatePixmap; + DestroyPixmapProcPtr DestroyPixmap; + ChangeWindowAttributesProcPtr ChangeWindowAttributes; + XAAInfoRecPtr AccelInfoRec; + Bool (*EnterVT)(int, int); + void (*LeaveVT)(int, int); + int (*SetDGAMode)(int, int, DGADevicePtr); + void (*EnableDisableFBAccess)(int, Bool); +#ifdef RENDER + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; +#endif +} XAAScreenRec, *XAAScreenPtr; + +#define OPS_ARE_PIXMAP 0x00000001 +#define OPS_ARE_ACCEL 0x00000002 + +typedef struct _XAAGC { + GCOps *wrapOps; + GCFuncs *wrapFuncs; + GCOps *XAAOps; + int DashLength; + unsigned char* DashPattern; + unsigned long changes; + unsigned long flags; +} XAAGCRec, *XAAGCPtr; + +#define REDUCIBILITY_CHECKED 0x00000001 +#define REDUCIBLE_TO_8x8 0x00000002 +#define REDUCIBLE_TO_2_COLOR 0x00000004 +#define DIRTY 0x00010000 +#define OFFSCREEN 0x00020000 +#define DGA_PIXMAP 0x00040000 +#define SHARED_PIXMAP 0x00080000 +#define LOCKED_PIXMAP 0x00100000 + +#define REDUCIBILITY_MASK \ + (REDUCIBILITY_CHECKED | REDUCIBLE_TO_8x8 | REDUCIBLE_TO_2_COLOR) + +typedef struct _XAAPixmap { + unsigned long flags; + CARD32 pattern0; + CARD32 pattern1; + int fg; + int bg; + FBAreaPtr offscreenArea; + Bool freeData; +} XAAPixmapRec, *XAAPixmapPtr; + + +Bool +XAACreateGC( + GCPtr pGC +); + +Bool +XAAInitAccel( + ScreenPtr pScreen, + XAAInfoRecPtr infoRec +); + +RegionPtr +XAABitBlt( + DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GC *pGC, + int srcx, + int srcy, + int width, + int height, + int dstx, + int dsty, + void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr), + unsigned long bitPlane +); + +void +XAAScreenToScreenBitBlt( + ScrnInfoPtr pScrn, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, + int ydir, + int alu, + unsigned int planemask +); + +void +XAADoBitBlt( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + RegionPtr prgnDst, + DDXPointPtr pptSrc +); + +void +XAADoImageWrite( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + RegionPtr prgnDst, + DDXPointPtr pptSrc +); + +void +XAADoImageRead( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + RegionPtr prgnDst, + DDXPointPtr pptSrc +); + +void +XAACopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc +); + + +RegionPtr +XAACopyArea( + DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GC *pGC, + int srcx, + int srcy, + int width, + int height, + int dstx, + int dsty +); + +void +XAAValidateCopyArea( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +void +XAAValidatePutImage( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +void +XAAValidateCopyPlane( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +void +XAAValidatePushPixels( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +void +XAAValidateFillSpans( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +void +XAAValidatePolyGlyphBlt( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +void +XAAValidateImageGlyphBlt( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + +void +XAAValidatePolylines( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +); + + +RegionPtr +XAACopyPlaneColorExpansion( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, + int srcy, + int width, + int height, + int dstx, + int dsty, + unsigned long bitPlane +); + + +void +XAAPushPixelsSolidColorExpansion( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDrawable, + int dx, + int dy, + int xOrg, + int yOrg +); + +void +XAAWriteBitmapColorExpandMSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapColorExpand3MSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapColorExpandMSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapColorExpand3MSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapColorExpandLSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapColorExpand3LSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapColorExpandLSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapColorExpand3LSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + + +void +XAAWriteBitmapScanlineColorExpandMSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapScanlineColorExpand3MSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapScanlineColorExpandMSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapScanlineColorExpand3MSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapScanlineColorExpandLSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapScanlineColorExpand3LSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapScanlineColorExpandLSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWriteBitmapScanlineColorExpand3LSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + +void +XAAWritePixmap ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth +); + +void +XAAWritePixmapScanline ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth +); + +typedef void (*ClipAndRenderRectsFunc)(GCPtr, int, BoxPtr, int, int); + + +void +XAAClipAndRenderRects( + GCPtr pGC, + ClipAndRenderRectsFunc func, + int nrectFill, + xRectangle *prectInit, + int xorg, int yorg +); + + +typedef void (*ClipAndRenderSpansFunc)(GCPtr, int, DDXPointPtr, int*, + int, int, int); + +void +XAAClipAndRenderSpans( + GCPtr pGC, + DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted, + ClipAndRenderSpansFunc func, + int xorg, + int yorg +); + + +void +XAAFillSolidRects( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox +); + +void +XAAFillMono8x8PatternRects( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int pat0, int pat1, + int xorg, int yorg +); + +void +XAAFillMono8x8PatternRectsScreenOrigin( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int pat0, int pat1, + int xorg, int yorg +); + + +void +XAAFillColor8x8PatternRectsScreenOrigin( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorigin, int yorigin, + XAACacheInfoPtr pCache +); + +void +XAAFillColor8x8PatternRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorigin, int yorigin, + XAACacheInfoPtr pCache +); + +void +XAAFillCacheBltRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + XAACacheInfoPtr pCache +); + +void +XAAFillCacheExpandRects( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillImageWriteRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +); + + +void +XAATEGlyphRendererMSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRenderer3MSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRendererMSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRenderer3MSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRendererLSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + + +void +XAATEGlyphRenderer3LSBFirstFixedBase ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRendererLSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRenderer3LSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + + +void +XAATEGlyphRendererScanlineMSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRendererScanline3MSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRendererScanlineLSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + +void +XAATEGlyphRendererScanline3LSBFirst ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft, int startline, + unsigned int **glyphs, int glyphWidth, + int fg, int bg, int rop, unsigned planemask +); + + +extern CARD32 *(*XAAGlyphScanlineFuncMSBFirstFixedBase[32])( + CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width +); + +extern CARD32 *(*XAAGlyphScanlineFuncMSBFirst[32])( + CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width +); + +extern CARD32 *(*XAAGlyphScanlineFuncLSBFirstFixedBase[32])( + CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width +); + +extern CARD32 *(*XAAGlyphScanlineFuncLSBFirst[32])( + CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width +); + +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirstFixedBase(void); +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirst(void); +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirstFixedBase(void); +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirst(void); + +void +XAAFillColorExpandRectsLSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandRects3LSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandRectsLSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandRects3LSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandRectsMSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandRects3MSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandRectsMSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandRects3MSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillScanlineColorExpandRectsLSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillScanlineColorExpandRects3LSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillScanlineColorExpandRectsMSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillScanlineColorExpandRects3MSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpansLSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpans3LSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpansLSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpans3LSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpansMSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpans3MSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpansMSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillColorExpandSpans3MSBFirstFixedBase( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillScanlineColorExpandSpansLSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillScanlineColorExpandSpans3LSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, + int y, + int w, + int h, + int leftPad, + int format, + char *pImage +); + +void +XAAFillScanlineColorExpandSpansMSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillScanlineColorExpandSpans3MSBFirst( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + + +extern CARD32 *(*XAAStippleScanlineFuncMSBFirstFixedBase[6])( + CARD32* base, CARD32* src, int offset, int width, int dwords +); + +extern CARD32 *(*XAAStippleScanlineFuncMSBFirst[6])( + CARD32* base, CARD32* src, int offset, int width, int dwords +); + +extern CARD32 *(*XAAStippleScanlineFuncLSBFirstFixedBase[6])( + CARD32* base, CARD32* src, int offset, int width, int dwords +); + +extern CARD32 *(*XAAStippleScanlineFuncLSBFirst[6])( + CARD32* base, CARD32* src, int offset, int width, int dwords +); + +StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirstFixedBase(void); +StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirst(void); +StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirstFixedBase(void); +StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirst(void); + +int +XAAPolyText8TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +); + +int +XAAPolyText16TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +); + +void +XAAImageText8TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +); + +void +XAAImageText16TEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +); + +void +XAAImageGlyphBltTEColorExpansion( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +); + +void +XAAPolyGlyphBltTEColorExpansion( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +); + + +int +XAAPolyText8NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +); + +int +XAAPolyText16NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +); + +void +XAAImageText8NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + char *chars +); + +void +XAAImageText16NonTEColorExpansion( + DrawablePtr pDraw, + GCPtr pGC, + int x, int y, + int count, + unsigned short *chars +); + +void +XAAImageGlyphBltNonTEColorExpansion( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +); + +void +XAAPolyGlyphBltNonTEColorExpansion( + DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +); + + +void XAANonTEGlyphRenderer( + ScrnInfoPtr pScrn, + int x, int y, int n, + NonTEGlyphPtr glyphs, + BoxPtr pbox, + int fg, int rop, + unsigned int planemask +); + +void +XAAFillSolidSpans( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted +); + +void +XAAFillMono8x8PatternSpans( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + int patx, int paty, + int xorg, int yorg +); + +void +XAAFillMono8x8PatternSpansScreenOrigin( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + int patx, int paty, + int xorg, int yorg +); + +void +XAAFillColor8x8PatternSpansScreenOrigin( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + XAACacheInfoPtr, + int xorigin, int yorigin +); + +void +XAAFillColor8x8PatternSpans( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + XAACacheInfoPtr, + int xorigin, int yorigin +); + +void +XAAFillCacheBltSpans( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr points, + int *widths, + int fSorted, + XAACacheInfoPtr pCache, + int xorg, int yorg +); + +void +XAAFillCacheExpandSpans( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +); + +void +XAAFillSpans( + DrawablePtr pDrawable, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidth, + int fSorted +); + + +void +XAAInitPixmapCache( + ScreenPtr pScreen, + RegionPtr areas, + pointer data +); + +void +XAAWriteBitmapToCache( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int fg, int bg +); + +void +XAAWriteBitmapToCacheLinear( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int fg, int bg +); + +void +XAAWritePixmapToCache( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int bpp, int depth +); + +void +XAAWritePixmapToCacheLinear( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int bpp, int depth +); + +void +XAASolidHorVertLineAsRects( + ScrnInfoPtr pScrn, + int x, int y, int len, int dir +); + +void +XAASolidHorVertLineAsTwoPoint( + ScrnInfoPtr pScrn, + int x, int y, int len, int dir +); + +void +XAASolidHorVertLineAsBresenham( + ScrnInfoPtr pScrn, + int x, int y, int len, int dir +); + + +void +XAAPolyRectangleThinSolid( + DrawablePtr pDrawable, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +); + + +void +XAAPolylinesWideSolid ( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts +); + +void +XAAFillPolygonSolid( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +); + +void +XAAFillPolygonStippled( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +); + + +void +XAAFillPolygonTiled( + DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +); + + +int +XAAIsEasyPolygon( + DDXPointPtr ptsIn, + int count, + BoxPtr extents, + int origin, + DDXPointPtr *topPoint, + int *topY, int *bottomY, + int shape +); + +void +XAAFillPolygonHelper( + ScrnInfoPtr pScrn, + DDXPointPtr ptsIn, + int count, + DDXPointPtr topPoint, + int y, + int maxy, + int origin, + RectFuncPtr RectFunc, + TrapFuncPtr TrapFunc, + int xorg, + int yorg, + XAACacheInfoPtr pCache +); + +void +XAAPolySegment( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg +); + +void +XAAPolyLines( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +); + +void +XAAPolySegmentDashed( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg +); + +void +XAAPolyLinesDashed( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +); + + +void +XAAWriteMono8x8PatternToCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache); + +void +XAAWriteColor8x8PatternToCache( + ScrnInfoPtr pScrn, + PixmapPtr pPix, + XAACacheInfoPtr pCache +); + +void +XAARotateMonoPattern( + int *pat0, int *pat1, + int xoffset, int yoffset, + Bool msbfirst +); + +void XAAComputeDash(GCPtr pGC); + +void XAAMoveDWORDS_FixedBase( + register CARD32* dest, + register CARD32* src, + register int dwords +); + +void XAAMoveDWORDS_FixedSrc( + register CARD32* dest, + register CARD32* src, + register int dwords +); + +void XAAMoveDWORDS( + register CARD32* dest, + register CARD32* src, + register int dwords +); + +int +XAAGetRectClipBoxes( + GCPtr pGC, + BoxPtr pboxClippedBase, + int nrectFill, + xRectangle *prectInit +); + +void +XAASetupOverlay8_32Planar(ScreenPtr); + +void +XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs); + +XAACacheInfoPtr +XAACacheTile(ScrnInfoPtr Scrn, PixmapPtr pPix); + +XAACacheInfoPtr +XAACacheMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix); + +XAACacheInfoPtr +XAACachePlanarMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix); + +typedef XAACacheInfoPtr (*XAACachePlanarMonoStippleProc)(ScrnInfoPtr, PixmapPtr); +XAACachePlanarMonoStippleProc XAAGetCachePlanarMonoStipple(void); + +XAACacheInfoPtr +XAACacheStipple(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg); + +XAACacheInfoPtr +XAACacheMono8x8Pattern(ScrnInfoPtr Scrn, int pat0, int pat1); + +XAACacheInfoPtr +XAACacheColor8x8Pattern(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg); + +void +XAATileCache(ScrnInfoPtr pScrn, XAACacheInfoPtr pCache, int w, int h); + +void XAAClosePixmapCache(ScreenPtr pScreen); +void XAAInvalidatePixmapCache(ScreenPtr pScreen); + +Bool XAACheckStippleReducibility(PixmapPtr pPixmap); +Bool XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono); + +int XAAStippledFillChooser(GCPtr pGC); +int XAAOpaqueStippledFillChooser(GCPtr pGC); +int XAATiledFillChooser(GCPtr pGC); + +void XAAMoveInOffscreenPixmaps(ScreenPtr pScreen); +void XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen); +void XAARemoveAreaCallback(FBAreaPtr area); +void XAAMoveOutOffscreenPixmap(PixmapPtr pPix); +Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec); + +#ifdef RENDER +void +XAAComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + + +Bool +XAADoComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + + +void +XAAGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs); + +Bool +XAADoGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs); + + + +/* helpers */ +void +XAA_888_plus_PICT_a8_to_8888 ( + CARD32 color, + CARD8 *alphaPtr, /* in bytes */ + int alphaPitch, + CARD32 *dstPtr, + int dstPitch, /* in dwords */ + int width, + int height +); + +Bool +XAAGetRGBAFromPixel( + CARD32 pixel, + CARD16 *red, + CARD16 *green, + CARD16 *blue, + CARD16 *alpha, + CARD32 format +); + + +Bool +XAAGetPixelFromRGBA ( + CARD32 *pixel, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 format +); + +#endif + +/* XXX should be static */ +extern GCOps XAAFallbackOps; +extern GCOps *XAAGetFallbackOps(void); +extern GCFuncs XAAGCFuncs; +extern DevPrivateKey XAAGetScreenKey(void); +extern DevPrivateKey XAAGetGCKey(void); +extern DevPrivateKey XAAGetPixmapKey(void); + +extern unsigned int XAAShiftMasks[32]; + +extern unsigned int byte_expand3[256], byte_reversed_expand3[256]; + +CARD32 XAAReverseBitOrder(CARD32 data); + +#define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\ + dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()) + +#define GET_XAASCREENPTR_FROM_GC(pGC)\ + dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()) + +#define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\ + dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()) + +#define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\ +((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->AccelInfoRec + +#define GET_XAAINFORECPTR_FROM_GC(pGC)\ +((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec + +#define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\ +((XAAScreenPtr)dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec + +#define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\ +((XAAScreenPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec + +#define XAA_GET_PIXMAP_PRIVATE(pix)\ + (XAAPixmapPtr)dixLookupPrivate(&(pix)->devPrivates, XAAGetPixmapKey()) + +#define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) + +#define CHECK_FG(pGC, flags) \ + (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->fgPixel)) + +#define CHECK_BG(pGC, flags) \ + (!(flags & RGB_EQUAL) || CHECK_RGB_EQUAL(pGC->bgPixel)) + +#define CHECK_ROP(pGC, flags) \ + (!(flags & GXCOPY_ONLY) || (pGC->alu == GXcopy)) + +#define CHECK_ROPSRC(pGC, flags) \ + (!(flags & ROP_NEEDS_SOURCE) || ((pGC->alu != GXclear) && \ + (pGC->alu != GXnoop) && (pGC->alu != GXinvert) && \ + (pGC->alu != GXset))) + +#define CHECK_PLANEMASK(pGC, flags) \ + (!(flags & NO_PLANEMASK) || \ + ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == \ + infoRec->FullPlanemasks[pGC->depth - 1])) + +#define CHECK_COLORS(pGC, flags) \ + (!(flags & RGB_EQUAL) || \ + (CHECK_RGB_EQUAL(pGC->fgPixel) && CHECK_RGB_EQUAL(pGC->bgPixel))) + +#define CHECK_NO_GXCOPY(pGC, flags) \ + ((pGC->alu != GXcopy) || !(flags & NO_GXCOPY) || \ + ((pGC->planemask & infoRec->FullPlanemask) != infoRec->FullPlanemask)) + +#define IS_OFFSCREEN_PIXMAP(pPix)\ + ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->offscreenArea) + +#define PIXMAP_IS_SHARED(pPix)\ + ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & SHARED_PIXMAP) + +#define OFFSCREEN_PIXMAP_LOCKED(pPix)\ + ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & LOCKED_PIXMAP) + +#define XAA_DEPTH_BUG(pGC) \ + ((pGC->depth == 32) && (pGC->bgPixel == 0xffffffff)) + +#define DELIST_OFFSCREEN_PIXMAP(pPix) { \ + PixmapLinkPtr _pLink, _prev; \ + _pLink = infoRec->OffscreenPixmaps; \ + _prev = NULL; \ + while(_pLink) { \ + if(_pLink->pPix == pPix) { \ + if(_prev) _prev->next = _pLink->next; \ + else infoRec->OffscreenPixmaps = _pLink->next; \ + xfree(_pLink); \ + break; \ + } \ + _prev = _pLink; \ + _pLink = _pLink->next; \ + }} + + +#define SWAP_BITS_IN_BYTES(v) \ + (((0x01010101 & (v)) << 7) | ((0x02020202 & (v)) << 5) | \ + ((0x04040404 & (v)) << 3) | ((0x08080808 & (v)) << 1) | \ + ((0x10101010 & (v)) >> 1) | ((0x20202020 & (v)) >> 3) | \ + ((0x40404040 & (v)) >> 5) | ((0x80808080 & (v)) >> 7)) + +/* + * Moved XAAPixmapCachePrivate here from xaaPCache.c, since driver + * replacements for CacheMonoStipple need access to it + */ + +typedef struct { + int Num512x512; + int Current512; + XAACacheInfoPtr Info512; + int Num256x256; + int Current256; + XAACacheInfoPtr Info256; + int Num128x128; + int Current128; + XAACacheInfoPtr Info128; + int NumMono; + int CurrentMono; + XAACacheInfoPtr InfoMono; + int NumColor; + int CurrentColor; + XAACacheInfoPtr InfoColor; + int NumPartial; + int CurrentPartial; + XAACacheInfoPtr InfoPartial; + DDXPointRec MonoOffsets[64]; + DDXPointRec ColorOffsets[64]; +} XAAPixmapCachePrivate, *XAAPixmapCachePrivatePtr; + + +#endif /* _XAALOCAL_H */ diff --git a/xorg-server/hw/xfree86/xaa/xaarop.h b/xorg-server/hw/xfree86/xaa/xaarop.h new file mode 100644 index 000000000..548993c49 --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaarop.h @@ -0,0 +1,311 @@ +/* + + int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop) + + For use with solid fills emulated by solid 8x8 patterns. You + give it the foreground, planemask and X rop and it will replace + the foreground with a new one and the rop with the appropriate + MS triadic raster op. The function will return which components + (S-P) need to be enabled. + + + int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop) + + For use with 8x8 opaque pattern fills. You give it the foreground, + and background, planemask and X rop and it will replace the + foreground and background with new ones and the rop with the + appropriate MS triadic raster op. The function will return which + components (S-P) need to be enabled. + + + ROP_PAT - Means to enable 8x8 mono patterns (all bits + set for solid patterns). Set the foreground and + background as returned by the function. + + ROP_SRC - Means a source of color == planemask should be used. + + +*/ + +#ifndef _XAAROP_H +#define _XAAROP_H + +#define ROP_DST 0x00000001 +#define ROP_SRC 0x00000002 +#define ROP_PAT 0x00000004 + +#define ROP_0 0x00 +#define ROP_DPSoon 0x01 +#define ROP_DPSona 0x02 +#define ROP_PSon 0x03 +#define ROP_SDPona 0x04 +#define ROP_DPon 0x05 +#define ROP_PDSxnon 0x06 +#define ROP_PDSaon 0x07 +#define ROP_SDPnaa 0x08 +#define ROP_PDSxon 0x09 +#define ROP_DPna 0x0A +#define ROP_PSDnaon 0x0B +#define ROP_SPna 0x0C +#define ROP_PDSnaon 0x0D +#define ROP_PDSonon 0x0E +#define ROP_Pn 0x0F +#define ROP_PDSona 0x10 +#define ROP_DSon 0x11 +#define ROP_SDPxnon 0x12 +#define ROP_SDPaon 0x13 +#define ROP_DPSxnon 0x14 +#define ROP_DPSaon 0x15 +#define ROP_PSDPSanaxx 0x16 +#define ROP_SSPxDSxaxn 0x17 +#define ROP_SPxPDxa 0x18 +#define ROP_SDPSanaxn 0x19 +#define ROP_PDSPaox 0x1A +#define ROP_SDPSxaxn 0x1B +#define ROP_PSDPaox 0x1C +#define ROP_DSPDxaxn 0x1D +#define ROP_PDSox 0x1E +#define ROP_PDSoan 0x1F +#define ROP_DPSnaa 0x20 +#define ROP_SDPxon 0x21 +#define ROP_DSna 0x22 +#define ROP_SPDnaon 0x23 +#define ROP_SPxDSxa 0x24 +#define ROP_PDSPanaxn 0x25 +#define ROP_SDPSaox 0x26 +#define ROP_SDPSxnox 0x27 +#define ROP_DPSxa 0x28 +#define ROP_PSDPSaoxxn 0x29 +#define ROP_DPSana 0x2A +#define ROP_SSPxPDxaxn 0x2B +#define ROP_SPDSoax 0x2C +#define ROP_PSDnox 0x2D +#define ROP_PSDPxox 0x2E +#define ROP_PSDnoan 0x2F +#define ROP_PSna 0x30 +#define ROP_SDPnaon 0x31 +#define ROP_SDPSoox 0x32 +#define ROP_Sn 0x33 +#define ROP_SPDSaox 0x34 +#define ROP_SPDSxnox 0x35 +#define ROP_SDPox 0x36 +#define ROP_SDPoan 0x37 +#define ROP_PSDPoax 0x38 +#define ROP_SPDnox 0x39 +#define ROP_SPDSxox 0x3A +#define ROP_SPDnoan 0x3B +#define ROP_PSx 0x3C +#define ROP_SPDSonox 0x3D +#define ROP_SPDSnaox 0x3E +#define ROP_PSan 0x3F +#define ROP_PSDnaa 0x40 +#define ROP_DPSxon 0x41 +#define ROP_SDxPDxa 0x42 +#define ROP_SPDSanaxn 0x43 +#define ROP_SDna 0x44 +#define ROP_DPSnaon 0x45 +#define ROP_DSPDaox 0x46 +#define ROP_PSDPxaxn 0x47 +#define ROP_SDPxa 0x48 +#define ROP_PDSPDaoxxn 0x49 +#define ROP_DPSDoax 0x4A +#define ROP_PDSnox 0x4B +#define ROP_SDPana 0x4C +#define ROP_SSPxDSxoxn 0x4D +#define ROP_PDSPxox 0x4E +#define ROP_PDSnoan 0x4F +#define ROP_PDna 0x50 +#define ROP_DSPnaon 0x51 +#define ROP_DPSDaox 0x52 +#define ROP_SPDSxaxn 0x53 +#define ROP_DPSonon 0x54 +#define ROP_Dn 0x55 +#define ROP_DPSox 0x56 +#define ROP_DPSoan 0x57 +#define ROP_PDSPoax 0x58 +#define ROP_DPSnox 0x59 +#define ROP_DPx 0x5A +#define ROP_DPSDonox 0x5B +#define ROP_DPSDxox 0x5C +#define ROP_DPSnoan 0x5D +#define ROP_DPSDnaox 0x5E +#define ROP_DPan 0x5F +#define ROP_PDSxa 0x60 +#define ROP_DSPDSaoxxn 0x61 +#define ROP_DSPDoax 0x62 +#define ROP_SDPnox 0x63 +#define ROP_SDPSoax 0x64 +#define ROP_DSPnox 0x65 +#define ROP_DSx 0x66 +#define ROP_SDPSonox 0x67 +#define ROP_DSPDSonoxxn 0x68 +#define ROP_PDSxxn 0x69 +#define ROP_DPSax 0x6A +#define ROP_PSDPSoaxxn 0x6B +#define ROP_SDPax 0x6C +#define ROP_PDSPDoaxxn 0x6D +#define ROP_SDPSnoax 0x6E +#define ROP_PDSxnan 0x6F +#define ROP_PDSana 0x70 +#define ROP_SSDxPDxaxn 0x71 +#define ROP_SDPSxox 0x72 +#define ROP_SDPnoan 0x73 +#define ROP_DSPDxox 0x74 +#define ROP_DSPnoan 0x75 +#define ROP_SDPSnaox 0x76 +#define ROP_DSan 0x77 +#define ROP_PDSax 0x78 +#define ROP_DSPDSoaxxn 0x79 +#define ROP_DPSDnoax 0x7A +#define ROP_SDPxnan 0x7B +#define ROP_SPDSnoax 0x7C +#define ROP_DPSxnan 0x7D +#define ROP_SPxDSxo 0x7E +#define ROP_DPSaan 0x7F +#define ROP_DPSaa 0x80 +#define ROP_SPxDSxon 0x81 +#define ROP_DPSxna 0x82 +#define ROP_SPDSnoaxn 0x83 +#define ROP_SDPxna 0x84 +#define ROP_PDSPnoaxn 0x85 +#define ROP_DSPDSoaxx 0x86 +#define ROP_PDSaxn 0x87 +#define ROP_DSa 0x88 +#define ROP_SDPSnaoxn 0x89 +#define ROP_DSPnoa 0x8A +#define ROP_DSPDxoxn 0x8B +#define ROP_SDPnoa 0x8C +#define ROP_SDPSxoxn 0x8D +#define ROP_SSDxPDxax 0x8E +#define ROP_PDSanan 0x8F +#define ROP_PDSxna 0x90 +#define ROP_SDPSnoaxn 0x91 +#define ROP_DPSDPoaxx 0x92 +#define ROP_SPDaxn 0x93 +#define ROP_PSDPSoaxx 0x94 +#define ROP_DPSaxn 0x95 +#define ROP_DPSxx 0x96 +#define ROP_PSDPSonoxx 0x97 +#define ROP_SDPSonoxn 0x98 +#define ROP_DSxn 0x99 +#define ROP_DPSnax 0x9A +#define ROP_SDPSoaxn 0x9B +#define ROP_SPDnax 0x9C +#define ROP_DSPDoaxn 0x9D +#define ROP_DSPDSaoxx 0x9E +#define ROP_PDSxan 0x9F +#define ROP_DPa 0xA0 +#define ROP_PDSPnaoxn 0xA1 +#define ROP_DPSnoa 0xA2 +#define ROP_DPSDxoxn 0xA3 +#define ROP_PDSPonoxn 0xA4 +#define ROP_PDxn 0xA5 +#define ROP_DSPnax 0xA6 +#define ROP_PDSPoaxn 0xA7 +#define ROP_DPSoa 0xA8 +#define ROP_DPSoxn 0xA9 +#define ROP_D 0xAA +#define ROP_DPSono 0xAB +#define ROP_SPDSxax 0xAC +#define ROP_DPSDaoxn 0xAD +#define ROP_DSPnao 0xAE +#define ROP_DPno 0xAF +#define ROP_PDSnoa 0xB0 +#define ROP_PDSPxoxn 0xB1 +#define ROP_SSPxDSxox 0xB2 +#define ROP_SDPanan 0xB3 +#define ROP_PSDnax 0xB4 +#define ROP_DPSDoaxn 0xB5 +#define ROP_DPSDPaoxx 0xB6 +#define ROP_SDPxan 0xB7 +#define ROP_PSDPxax 0xB8 +#define ROP_DSPDaoxn 0xB9 +#define ROP_DPSnao 0xBA +#define ROP_DSno 0xBB +#define ROP_SPDSanax 0xBC +#define ROP_SDxPDxan 0xBD +#define ROP_DPSxo 0xBE +#define ROP_DPSano 0xBF +#define ROP_Psa 0xC0 +#define ROP_SPDSnaoxn 0xC1 +#define ROP_SPDSonoxn 0xC2 +#define ROP_PSxn 0xC3 +#define ROP_SPDnoa 0xC4 +#define ROP_SPDSxoxn 0xC5 +#define ROP_SDPnax 0xC6 +#define ROP_PSDPoaxn 0xC7 +#define ROP_SDPoa 0xC8 +#define ROP_SPDoxn 0xC9 +#define ROP_DPSDxax 0xCA +#define ROP_SPDSaoxn 0xCB +#define ROP_S 0xCC +#define ROP_SDPono 0xCD +#define ROP_SDPnao 0xCE +#define ROP_SPno 0xCF +#define ROP_PSDnoa 0xD0 +#define ROP_PSDPxoxn 0xD1 +#define ROP_PDSnax 0xD2 +#define ROP_SPDSoaxn 0xD3 +#define ROP_SSPxPDxax 0xD4 +#define ROP_DPSanan 0xD5 +#define ROP_PSDPSaoxx 0xD6 +#define ROP_DPSxan 0xD7 +#define ROP_PDSPxax 0xD8 +#define ROP_SDPSaoxn 0xD9 +#define ROP_DPSDanax 0xDA +#define ROP_SPxDSxan 0xDB +#define ROP_SPDnao 0xDC +#define ROP_SDno 0xDD +#define ROP_SDPxo 0xDE +#define ROP_SDPano 0xDF +#define ROP_PDSoa 0xE0 +#define ROP_PDSoxn 0xE1 +#define ROP_DSPDxax 0xE2 +#define ROP_PSDPaoxn 0xE3 +#define ROP_SDPSxax 0xE4 +#define ROP_PDSPaoxn 0xE5 +#define ROP_SDPSanax 0xE6 +#define ROP_SPxPDxan 0xE7 +#define ROP_SSPxDSxax 0xE8 +#define ROP_DSPDSanaxxn 0xE9 +#define ROP_DPSao 0xEA +#define ROP_DPSxno 0xEB +#define ROP_SDPao 0xEC +#define ROP_SDPxno 0xED +#define ROP_DSo 0xEE +#define ROP_SDPnoo 0xEF +#define ROP_P 0xF0 +#define ROP_PDSono 0xF1 +#define ROP_PDSnao 0xF2 +#define ROP_PSno 0xF3 +#define ROP_PSDnao 0xF4 +#define ROP_PDno 0xF5 +#define ROP_PDSxo 0xF6 +#define ROP_PDSano 0xF7 +#define ROP_PDSao 0xF8 +#define ROP_PDSxno 0xF9 +#define ROP_DPo 0xFA +#define ROP_DPSnoo 0xFB +#define ROP_PSo 0xFC +#define ROP_PSDnoo 0xFD +#define ROP_DPSoo 0xFE +#define ROP_1 0xFF + +#define NO_SRC_ROP(rop) \ + ((rop == GXnoop) || (rop == GXset) || (rop == GXclear) || (rop == GXinvert)) + +int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop); +int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop); + +/* XXX These four should be static, but it breaks the 6.7.0 ABI. */ +extern int XAACopyROP[16]; +extern int XAACopyROP_PM[16]; +extern int XAAPatternROP[16]; +extern int XAAPatternROP_PM[16]; + +extern int XAAGetCopyROP(int i); +extern int XAAGetCopyROP_PM(int i); +extern int XAAGetPatternROP(int i); +extern int XAAGetPatternROP_PM(int i); + +#endif /* _XAAROP_H */ diff --git a/xorg-server/hw/xfree86/xaa/xaawrap.h b/xorg-server/hw/xfree86/xaa/xaawrap.h new file mode 100644 index 000000000..38c97d70b --- /dev/null +++ b/xorg-server/hw/xfree86/xaa/xaawrap.h @@ -0,0 +1,81 @@ + +#define XAA_SCREEN_PROLOGUE(pScreen, field)\ + ((pScreen)->field = \ + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) + +#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\ + ((pScreen)->field = wrapper) + + +#define XAA_GC_FUNC_PROLOGUE(pGC)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + (pGC)->funcs = pGCPriv->wrapFuncs;\ + if(pGCPriv->flags)\ + (pGC)->ops = pGCPriv->wrapOps + +#define XAA_GC_FUNC_EPILOGUE(pGC)\ + pGCPriv->wrapFuncs = (pGC)->funcs;\ + (pGC)->funcs = &XAAGCFuncs;\ + if(pGCPriv->flags) {\ + pGCPriv->wrapOps = (pGC)->ops;\ + (pGC)->ops = (pGCPriv->flags & OPS_ARE_ACCEL) ? pGCPriv->XAAOps :\ + &XAAPixmapOps;\ + } + + +#define XAA_GC_OP_PROLOGUE(pGC)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + GCFuncs *oldFuncs = pGC->funcs;\ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps + +#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + GCFuncs *oldFuncs = pGC->funcs;\ + if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps + + +#define XAA_GC_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = pGC->ops;\ + pGC->funcs = oldFuncs;\ + pGC->ops = pGCPriv->XAAOps + + +#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\ + GCFuncs *oldFuncs = pGC->funcs;\ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps + + +#define XAA_PIXMAP_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = pGC->ops;\ + pGC->funcs = oldFuncs;\ + pGC->ops = &XAAPixmapOps;\ + pixPriv->flags |= DIRTY + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifdef RENDER +#define XAA_RENDER_PROLOGUE(pScreen,field)\ + (GetPictureScreen(pScreen)->field = \ + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) + +#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ + (GetPictureScreen(pScreen)->field = wrapper) +#endif + +/* This also works fine for drawables */ + +#define SYNC_CHECK(pGC) {\ + XAAInfoRecPtr infoRec =\ +((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \ + if(infoRec->NeedToSync) {\ + (*infoRec->Sync)(infoRec->pScrn);\ + infoRec->NeedToSync = FALSE;\ + }} diff --git a/xorg-server/hw/xfree86/xf1bpp/Makefile.am b/xorg-server/hw/xfree86/xf1bpp/Makefile.am new file mode 100644 index 000000000..c724f760f --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/Makefile.am @@ -0,0 +1,178 @@ +module_LTLIBRARIES = libxf1bpp.la + +sdk_HEADERS = xf1bpp.h mfbmap.h mfbunmap.h + +libxf1bpp_la_LDFLAGS = -avoid-version + +libxf1bppgen_a_SOURCES = \ + mfbseg.c \ + mfbpgbwht.c \ + mfbpgbblak.c \ + mfbpgbinv.c \ + mfbigbwht.c \ + mfbigbblak.c \ + mfbpawhite.c \ + mfbpablack.c \ + mfbpainv.c \ + mfbtewhite.c \ + mfbteblack.c \ + mfbplywhite.c \ + mfbplyblack.c \ + mfbplyinv.c \ + mfbbltC.c \ + mfbbltX.c \ + mfbbltCI.c \ + mfbbltO.c \ + mfbbltG.c \ + mfbtileC.c \ + mfbtileG.c + +libxf1bppmfb_a_SOURCES = \ + maskbits.c \ + mfbbitblt.c \ + mfbbres.c \ + mfbbresd.c \ + mfbclip.c \ + mfbcmap.c \ + mfbfillarc.c \ + mfbfillrct.c \ + mfbfillsp.c \ + mfbfont.c \ + mfbgc.c \ + mfbgetsp.c \ + mfbhrzvert.c \ + mfbimage.c \ + mfbline.c \ + mfbmisc.c \ + mfbpixmap.c \ + mfbpolypnt.c \ + mfbpushpxl.c \ + mfbscrclse.c \ + mfbscrinit.c \ + mfbsetsp.c \ + mfbwindow.c \ + mfbzerarc.c + +BUILT_SOURCES = $(libxf1bppmfb_a_SOURCES) $(libxf1bppgen_a_SOURCES) + +libxf1bpp_la_SOURCES = $(libxf1bppmfb_a_SOURCES) $(libxf1bppgen_a_SOURCES) \ + mfbmodule.c + +AM_CFLAGS = -DXF86MONO $(DIX_CFLAGS) $(XORG_CFLAGS) +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/mfb + +mfbseg.c: + echo "#define POLYSEGMENT" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbline.c\"" >> $@ +mfbpgbwht.c: + echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltWhite" > $@ + echo "#define OPEQ |=" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ +mfbpgbblak.c: + echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltBlack" > $@ + echo "#define OPEQ &=~" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ +mfbpgbinv.c: + echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltInvert" > $@ + echo "#define OPEQ ^=" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ +mfbigbwht.c: + echo "#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltWhite" > $@ + echo "#define OPEQ |=" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbimggblt.c\"" >> $@ +mfbigbblak.c: + echo "#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltBlack" > $@ + echo "#define OPEQ &=~" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbimggblt.c\"" >> $@ +mfbpawhite.c: + echo "#define MFBSOLIDFILLAREA xf1bppSolidWhiteArea" > $@ + echo "#define MFBSTIPPLEFILLAREA xf1bppStippleWhiteArea" >> $@ + echo "#define OPEQ |=" >> $@ + echo "#define EQWHOLEWORD =~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ +mfbpablack.c: + echo "#define MFBSOLIDFILLAREA xf1bppSolidBlackArea" > $@ + echo "#define MFBSTIPPLEFILLAREA xf1bppStippleBlackArea" >> $@ + echo "#define OPEQ &=~" >> $@ + echo "#define EQWHOLEWORD =0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ +mfbpainv.c: + echo "#define MFBSOLIDFILLAREA xf1bppSolidInvertArea" > $@ + echo "#define MFBSTIPPLEFILLAREA xf1bppStippleInvertArea" >> $@ + echo "#define OPEQ ^=" >> $@ + echo "#define EQWHOLEWORD ^=~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ +mfbtewhite.c: + echo "#define OP" > $@ + echo "#define CLIPTETEXT xf1bppImageGlyphBltWhite" >> $@ + echo "#define MFBTEGLYPHBLT xf1bppTEGlyphBltWhite" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtegblt.c\"" >> $@ +mfbteblack.c: + echo "#define OP ~" > $@ + echo "#define CLIPTETEXT xf1bppImageGlyphBltBlack" >> $@ + echo "#define MFBTEGLYPHBLT xf1bppTEGlyphBltBlack" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtegblt.c\"" >> $@ +mfbplywhite.c: + echo "#define MFBFILLPOLY1RECT xf1bppFillPolyWhite" > $@ + echo "#define OPEQ |=" >> $@ + echo "#define EQWHOLEWORD =~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ +mfbplyblack.c: + echo "#define MFBFILLPOLY1RECT xf1bppFillPolyBlack" > $@ + echo "#define OPEQ &=~" >> $@ + echo "#define EQWHOLEWORD =0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ +mfbplyinv.c: + echo "#define MFBFILLPOLY1RECT xf1bppFillPolyInvert" > $@ + echo "#define OPEQ ^=" >> $@ + echo "#define EQWHOLEWORD ^=~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ +mfbbltC.c: + echo "#define MROP Mcopy" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltX.c: + echo "#define MROP Mxor" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltCI.c: + echo "#define MROP McopyInverted" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltO.c: + echo "#define MROP Mor" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltG.c: + echo "#define MROP M0" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbtileC.c: + echo "#define MROP Mcopy" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtile.c\"" >> $@ +mfbtileG.c: + echo "#define MRop M0" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtile.c\"" >> $@ + +$(libxf1bppmfb_a_SOURCES): + echo "#include \"mfbmap.h\"" > $@ + echo "#include \"$(top_srcdir)/mfb/$@\"" >> $@ + +EXTRA_DIST = mfbmap.sh mfbunmap.sh +DISTCLEANFILES = $(BUILT_SOURCES) diff --git a/xorg-server/hw/xfree86/xf1bpp/Makefile.in b/xorg-server/hw/xfree86/xf1bpp/Makefile.in new file mode 100644 index 000000000..d57f4e994 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/Makefile.in @@ -0,0 +1,929 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/xf1bpp +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libxf1bpp_la_LIBADD = +am__objects_1 = maskbits.lo mfbbitblt.lo mfbbres.lo mfbbresd.lo \ + mfbclip.lo mfbcmap.lo mfbfillarc.lo mfbfillrct.lo mfbfillsp.lo \ + mfbfont.lo mfbgc.lo mfbgetsp.lo mfbhrzvert.lo mfbimage.lo \ + mfbline.lo mfbmisc.lo mfbpixmap.lo mfbpolypnt.lo mfbpushpxl.lo \ + mfbscrclse.lo mfbscrinit.lo mfbsetsp.lo mfbwindow.lo \ + mfbzerarc.lo +am__objects_2 = mfbseg.lo mfbpgbwht.lo mfbpgbblak.lo mfbpgbinv.lo \ + mfbigbwht.lo mfbigbblak.lo mfbpawhite.lo mfbpablack.lo \ + mfbpainv.lo mfbtewhite.lo mfbteblack.lo mfbplywhite.lo \ + mfbplyblack.lo mfbplyinv.lo mfbbltC.lo mfbbltX.lo mfbbltCI.lo \ + mfbbltO.lo mfbbltG.lo mfbtileC.lo mfbtileG.lo +am_libxf1bpp_la_OBJECTS = $(am__objects_1) $(am__objects_2) \ + mfbmodule.lo +libxf1bpp_la_OBJECTS = $(am_libxf1bpp_la_OBJECTS) +libxf1bpp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libxf1bpp_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxf1bpp_la_SOURCES) +DIST_SOURCES = $(libxf1bpp_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libxf1bpp.la +sdk_HEADERS = xf1bpp.h mfbmap.h mfbunmap.h +libxf1bpp_la_LDFLAGS = -avoid-version +libxf1bppgen_a_SOURCES = \ + mfbseg.c \ + mfbpgbwht.c \ + mfbpgbblak.c \ + mfbpgbinv.c \ + mfbigbwht.c \ + mfbigbblak.c \ + mfbpawhite.c \ + mfbpablack.c \ + mfbpainv.c \ + mfbtewhite.c \ + mfbteblack.c \ + mfbplywhite.c \ + mfbplyblack.c \ + mfbplyinv.c \ + mfbbltC.c \ + mfbbltX.c \ + mfbbltCI.c \ + mfbbltO.c \ + mfbbltG.c \ + mfbtileC.c \ + mfbtileG.c + +libxf1bppmfb_a_SOURCES = \ + maskbits.c \ + mfbbitblt.c \ + mfbbres.c \ + mfbbresd.c \ + mfbclip.c \ + mfbcmap.c \ + mfbfillarc.c \ + mfbfillrct.c \ + mfbfillsp.c \ + mfbfont.c \ + mfbgc.c \ + mfbgetsp.c \ + mfbhrzvert.c \ + mfbimage.c \ + mfbline.c \ + mfbmisc.c \ + mfbpixmap.c \ + mfbpolypnt.c \ + mfbpushpxl.c \ + mfbscrclse.c \ + mfbscrinit.c \ + mfbsetsp.c \ + mfbwindow.c \ + mfbzerarc.c + +BUILT_SOURCES = $(libxf1bppmfb_a_SOURCES) $(libxf1bppgen_a_SOURCES) +libxf1bpp_la_SOURCES = $(libxf1bppmfb_a_SOURCES) $(libxf1bppgen_a_SOURCES) \ + mfbmodule.c + +AM_CFLAGS = -DXF86MONO $(DIX_CFLAGS) $(XORG_CFLAGS) +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/mfb +EXTRA_DIST = mfbmap.sh mfbunmap.sh +DISTCLEANFILES = $(BUILT_SOURCES) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/xf1bpp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/xf1bpp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libxf1bpp.la: $(libxf1bpp_la_OBJECTS) $(libxf1bpp_la_DEPENDENCIES) + $(libxf1bpp_la_LINK) -rpath $(moduledir) $(libxf1bpp_la_OBJECTS) $(libxf1bpp_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maskbits.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbitblt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbltC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbltCI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbltG.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbltO.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbltX.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbres.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbresd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbclip.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbcmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbfillarc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbfillrct.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbfillsp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbfont.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbgc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbgetsp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbhrzvert.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbigbblak.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbigbwht.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbimage.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbline.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbmisc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbmodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpablack.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpainv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpawhite.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpgbblak.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpgbinv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpgbwht.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpixmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbplyblack.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbplyinv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbplywhite.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpolypnt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbpushpxl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbscrclse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbscrinit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbseg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbsetsp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbteblack.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbtewhite.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbtileC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbtileG.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbwindow.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbzerarc.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + + +mfbseg.c: + echo "#define POLYSEGMENT" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbline.c\"" >> $@ +mfbpgbwht.c: + echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltWhite" > $@ + echo "#define OPEQ |=" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ +mfbpgbblak.c: + echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltBlack" > $@ + echo "#define OPEQ &=~" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ +mfbpgbinv.c: + echo "#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltInvert" > $@ + echo "#define OPEQ ^=" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbplygblt.c\"" >> $@ +mfbigbwht.c: + echo "#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltWhite" > $@ + echo "#define OPEQ |=" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbimggblt.c\"" >> $@ +mfbigbblak.c: + echo "#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltBlack" > $@ + echo "#define OPEQ &=~" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbimggblt.c\"" >> $@ +mfbpawhite.c: + echo "#define MFBSOLIDFILLAREA xf1bppSolidWhiteArea" > $@ + echo "#define MFBSTIPPLEFILLAREA xf1bppStippleWhiteArea" >> $@ + echo "#define OPEQ |=" >> $@ + echo "#define EQWHOLEWORD =~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ +mfbpablack.c: + echo "#define MFBSOLIDFILLAREA xf1bppSolidBlackArea" > $@ + echo "#define MFBSTIPPLEFILLAREA xf1bppStippleBlackArea" >> $@ + echo "#define OPEQ &=~" >> $@ + echo "#define EQWHOLEWORD =0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ +mfbpainv.c: + echo "#define MFBSOLIDFILLAREA xf1bppSolidInvertArea" > $@ + echo "#define MFBSTIPPLEFILLAREA xf1bppStippleInvertArea" >> $@ + echo "#define OPEQ ^=" >> $@ + echo "#define EQWHOLEWORD ^=~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbpntarea.c\"" >> $@ +mfbtewhite.c: + echo "#define OP" > $@ + echo "#define CLIPTETEXT xf1bppImageGlyphBltWhite" >> $@ + echo "#define MFBTEGLYPHBLT xf1bppTEGlyphBltWhite" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtegblt.c\"" >> $@ +mfbteblack.c: + echo "#define OP ~" > $@ + echo "#define CLIPTETEXT xf1bppImageGlyphBltBlack" >> $@ + echo "#define MFBTEGLYPHBLT xf1bppTEGlyphBltBlack" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtegblt.c\"" >> $@ +mfbplywhite.c: + echo "#define MFBFILLPOLY1RECT xf1bppFillPolyWhite" > $@ + echo "#define OPEQ |=" >> $@ + echo "#define EQWHOLEWORD =~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ +mfbplyblack.c: + echo "#define MFBFILLPOLY1RECT xf1bppFillPolyBlack" > $@ + echo "#define OPEQ &=~" >> $@ + echo "#define EQWHOLEWORD =0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ +mfbplyinv.c: + echo "#define MFBFILLPOLY1RECT xf1bppFillPolyInvert" > $@ + echo "#define OPEQ ^=" >> $@ + echo "#define EQWHOLEWORD ^=~0" >> $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbply1rct.c\"" >> $@ +mfbbltC.c: + echo "#define MROP Mcopy" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltX.c: + echo "#define MROP Mxor" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltCI.c: + echo "#define MROP McopyInverted" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltO.c: + echo "#define MROP Mor" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbbltG.c: + echo "#define MROP M0" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbblt.c\"" >> $@ +mfbtileC.c: + echo "#define MROP Mcopy" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtile.c\"" >> $@ +mfbtileG.c: + echo "#define MRop M0" > $@ + echo "#include \"mfbmap.h\"" >> $@ + echo "#include \"$(top_srcdir)/mfb/mfbtile.c\"" >> $@ + +$(libxf1bppmfb_a_SOURCES): + echo "#include \"mfbmap.h\"" > $@ + echo "#include \"$(top_srcdir)/mfb/$@\"" >> $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/xf1bpp/maskbits.c b/xorg-server/hw/xfree86/xf1bpp/maskbits.c new file mode 100644 index 000000000..a8869b2fd --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/maskbits.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/maskbits.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbitblt.c b/xorg-server/hw/xfree86/xf1bpp/mfbbitblt.c new file mode 100644 index 000000000..dd41a79f4 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbitblt.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbbitblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbltC.c b/xorg-server/hw/xfree86/xf1bpp/mfbbltC.c new file mode 100644 index 000000000..83c9066c6 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbltC.c @@ -0,0 +1,3 @@ +#define MROP Mcopy +#include "mfbmap.h" +#include "../../../mfb/mfbblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbltCI.c b/xorg-server/hw/xfree86/xf1bpp/mfbbltCI.c new file mode 100644 index 000000000..c436d1533 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbltCI.c @@ -0,0 +1,3 @@ +#define MROP McopyInverted +#include "mfbmap.h" +#include "../../../mfb/mfbblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbltG.c b/xorg-server/hw/xfree86/xf1bpp/mfbbltG.c new file mode 100644 index 000000000..8ecd93835 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbltG.c @@ -0,0 +1,3 @@ +#define MROP M0 +#include "mfbmap.h" +#include "../../../mfb/mfbblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbltO.c b/xorg-server/hw/xfree86/xf1bpp/mfbbltO.c new file mode 100644 index 000000000..2e463a993 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbltO.c @@ -0,0 +1,3 @@ +#define MROP Mor +#include "mfbmap.h" +#include "../../../mfb/mfbblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbltX.c b/xorg-server/hw/xfree86/xf1bpp/mfbbltX.c new file mode 100644 index 000000000..2c26467c0 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbltX.c @@ -0,0 +1,3 @@ +#define MROP Mxor +#include "mfbmap.h" +#include "../../../mfb/mfbblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbres.c b/xorg-server/hw/xfree86/xf1bpp/mfbbres.c new file mode 100644 index 000000000..3ff1187b2 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbres.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbbres.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbbresd.c b/xorg-server/hw/xfree86/xf1bpp/mfbbresd.c new file mode 100644 index 000000000..b745fb6bc --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbbresd.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbbresd.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbclip.c b/xorg-server/hw/xfree86/xf1bpp/mfbclip.c new file mode 100644 index 000000000..2fadd7682 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbclip.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbclip.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbcmap.c b/xorg-server/hw/xfree86/xf1bpp/mfbcmap.c new file mode 100644 index 000000000..5255927a2 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbcmap.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbcmap.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbfillarc.c b/xorg-server/hw/xfree86/xf1bpp/mfbfillarc.c new file mode 100644 index 000000000..8d7cca2ba --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbfillarc.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbfillarc.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbfillrct.c b/xorg-server/hw/xfree86/xf1bpp/mfbfillrct.c new file mode 100644 index 000000000..2ec87f4b2 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbfillrct.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbfillrct.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbfillsp.c b/xorg-server/hw/xfree86/xf1bpp/mfbfillsp.c new file mode 100644 index 000000000..9c89144e8 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbfillsp.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbfillsp.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbfont.c b/xorg-server/hw/xfree86/xf1bpp/mfbfont.c new file mode 100644 index 000000000..d3201a145 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbfont.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbfont.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbgc.c b/xorg-server/hw/xfree86/xf1bpp/mfbgc.c new file mode 100644 index 000000000..f17eec900 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbgc.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbgc.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbgetsp.c b/xorg-server/hw/xfree86/xf1bpp/mfbgetsp.c new file mode 100644 index 000000000..3638cb85a --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbgetsp.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbgetsp.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbhrzvert.c b/xorg-server/hw/xfree86/xf1bpp/mfbhrzvert.c new file mode 100644 index 000000000..0b76abfee --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbhrzvert.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbhrzvert.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbigbblak.c b/xorg-server/hw/xfree86/xf1bpp/mfbigbblak.c new file mode 100644 index 000000000..628631d53 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbigbblak.c @@ -0,0 +1,4 @@ +#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltBlack +#define OPEQ &=~ +#include "mfbmap.h" +#include "../../../mfb/mfbimggblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbigbwht.c b/xorg-server/hw/xfree86/xf1bpp/mfbigbwht.c new file mode 100644 index 000000000..c35f241bc --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbigbwht.c @@ -0,0 +1,4 @@ +#define MFBIMAGEGLYPHBLT xf1bppImageGlyphBltWhite +#define OPEQ |= +#include "mfbmap.h" +#include "../../../mfb/mfbimggblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbimage.c b/xorg-server/hw/xfree86/xf1bpp/mfbimage.c new file mode 100644 index 000000000..cd43fe076 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbimage.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbimage.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbline.c b/xorg-server/hw/xfree86/xf1bpp/mfbline.c new file mode 100644 index 000000000..dccff150f --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbline.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbline.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbmap.h b/xorg-server/hw/xfree86/xf1bpp/mfbmap.h new file mode 100644 index 000000000..e330ebd5b --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbmap.h @@ -0,0 +1,122 @@ + +#ifndef _MFBMAP_H +#define _MFBMAP_H + +#define InverseAlu xf1bppInverseAlu +#define endtab xf1bppendtab +#define mask xf1bppmask +#define mergeRopBits xf1bppmergeRopBits +#define mergeGetRopBits xf1bppmergeGetRopBits +#define mfbAllocatePrivates xf1bppAllocatePrivates +#define mfbBSFuncRec xf1bppBSFuncRec +#define mfbBlackSolidFS xf1bppBlackSolidFS +#define mfbBlackStippleFS xf1bppBlackStippleFS +#define mfbBresD xf1bppBresD +#define mfbBresS xf1bppBresS +#define mfbChangeWindowAttributes xf1bppChangeWindowAttributes +#define mfbCloseScreen xf1bppCloseScreen +#define mfbCopyArea xf1bppCopyArea +#define mfbCopyPixmap xf1bppCopyPixmap +#define mfbCopyPlane xf1bppCopyPlane +#define mfbCopyRotatePixmap xf1bppCopyRotatePixmap +#define mfbCopyWindow xf1bppCopyWindow +#define mfbCreateColormap xf1bppCreateColormap +#define mfbCreateDefColormap xf1bppCreateDefColormap +#define mfbCreateGC xf1bppCreateGC +#define mfbCreatePixmap xf1bppCreatePixmap +#define mfbCreateWindow xf1bppCreateWindow +#define mfbDestroyColormap xf1bppDestroyColormap +#define mfbDestroyPixmap xf1bppDestroyPixmap +#define mfbDestroyWindow xf1bppDestroyWindow +#define mfbDoBitblt xf1bppDoBitblt +#define mfbDoBitbltCopy xf1bppDoBitbltCopy +#define mfbDoBitbltCopyInverted xf1bppDoBitbltCopyInverted +#define mfbDoBitbltGeneral xf1bppDoBitbltGeneral +#define mfbDoBitbltOr xf1bppDoBitbltOr +#define mfbDoBitbltXor xf1bppDoBitbltXor +#define mfbFillInScreen xf1bppFillInScreen +#define mfbFillPolyBlack xf1bppFillPolyBlack +#define mfbFillPolyInvert xf1bppFillPolyInvert +#define mfbFillPolyWhite xf1bppFillPolyWhite +#define mfbGCPrivateIndex xf1bppGCPrivateIndex +#define mfbGetGCPrivateIndex xf1bppGetGCPrivateIndex +#define mfbGetImage xf1bppGetImage +#define mfbGetInverseAlu xf1bppGetInverseAlu +#define mfbGetSpans xf1bppGetSpans +#define mfbGetWindowPixmap xf1bppGetWindowPixmap +#define mfbGetWindowPrivateIndex xf1bppGetWindowPrivateIndex +#define mfbGetmask xf1bppGetmask +#define mfbGetpartmasks xf1bppGetpartmasks +#define mfbGetrmask xf1bppGetrmask +#define mfbGetstarttab xf1bppGetstarttab +#define mfbGetendtab xf1bppGetendtab +#define mfbHorzS xf1bppHorzS +#define mfbImageGlyphBltBlack xf1bppImageGlyphBltBlack +#define mfbImageGlyphBltWhite xf1bppImageGlyphBltWhite +#define mfbInstallColormap xf1bppInstallColormap +#define mfbInvertSolidFS xf1bppInvertSolidFS +#define mfbInvertStippleFS xf1bppInvertStippleFS +#define mfbLineSD xf1bppLineSD +#define mfbLineSS xf1bppLineSS +#define mfbListInstalledColormaps xf1bppListInstalledColormaps +#define mfbMapWindow xf1bppMapWindow +#define mfbPadPixmap xf1bppPadPixmap +#define mfbPixmapToRegion xf1bppPixmapToRegion +#define mfbPixmapToRegionWeak xf1bppPixmapToRegionWeak +#define mfbPolyFillArcSolid xf1bppPolyFillArcSolid +#define mfbPolyFillRect xf1bppPolyFillRect +#define mfbPolyGlyphBltBlack xf1bppPolyGlyphBltBlack +#define mfbPolyGlyphBltInvert xf1bppPolyGlyphBltInvert +#define mfbPolyGlyphBltWhite xf1bppPolyGlyphBltWhite +#define mfbPolyPoint xf1bppPolyPoint +#define mfbPositionWindow xf1bppPositionWindow +#define mfbPushPixels xf1bppPushPixels +#define mfbPushPixelsWeak xf1bppPushPixelsWeak +#define mfbPutImage xf1bppPutImage +#define mfbQueryBestSize xf1bppQueryBestSize +#define mfbQueryBestSizeWeak xf1bppQueryBestSizeWeak +#define mfbRealizeFont xf1bppRealizeFont +#define mfbRealizeFontWeak xf1bppRealizeFontWeak +#define mfbReduceRop xf1bppReduceRop +#define mfbRegisterCopyPlaneProc xf1bppRegisterCopyPlaneProc +#define mfbResolveColor xf1bppResolveColor +#define mfbRestoreAreas xf1bppRestoreAreas +#define mfbSaveAreas xf1bppSaveAreas +#define mfbScreenInit xf1bppScreenInit +#define mfbSegmentSD xf1bppSegmentSD +#define mfbSegmentSS xf1bppSegmentSS +#define mfbSetScanline xf1bppSetScanline +#define mfbSetSpans xf1bppSetSpans +#define mfbSetWindowPixmap xf1bppSetWindowPixmap +#define mfbSolidBlackArea xf1bppSolidBlackArea +#define mfbSolidInvertArea xf1bppSolidInvertArea +#define mfbSolidPP xf1bppSolidPP +#define mfbSolidWhiteArea xf1bppSolidWhiteArea +#define mfbStippleBlackArea xf1bppStippleBlackArea +#define mfbStippleInvertArea xf1bppStippleInvertArea +#define mfbStippleWhiteArea xf1bppStippleWhiteArea +#define mfbTEGlyphBltBlack xf1bppTEGlyphBltBlack +#define mfbTEGlyphBltWhite xf1bppTEGlyphBltWhite +#define mfbTileAreaPPW xf1bppTileAreaPPW +#define mfbTileAreaPPWCopy xf1bppTileAreaPPWCopy +#define mfbTileAreaPPWGeneral xf1bppTileAreaPPWGeneral +#define mfbTileFS xf1bppTileFS +#define mfbUninstallColormap xf1bppUninstallColormap +#define mfbUnmapWindow xf1bppUnmapWindow +#define mfbUnnaturalStippleFS xf1bppUnnaturalStippleFS +#define mfbUnnaturalTileFS xf1bppUnnaturalTileFS +#define mfbUnrealizeFont xf1bppUnrealizeFont +#define mfbUnrealizeFontWeak xf1bppUnrealizeFontWeak +#define mfbValidateGC xf1bppValidateGC +#define mfbVertS xf1bppVertS +#define mfbWhiteSolidFS xf1bppWhiteSolidFS +#define mfbWhiteStippleFS xf1bppWhiteStippleFS +#define mfbWindowPrivateIndex xf1bppWindowPrivateIndex +#define mfbXRotatePixmap xf1bppXRotatePixmap +#define mfbYRotatePixmap xf1bppYRotatePixmap +#define mfbZeroPolyArcSS xf1bppZeroPolyArcSS +#define partmasks xf1bpppartmasks +#define rmask xf1bpprmask +#define starttab xf1bppstarttab + +#endif diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbmap.sh b/xorg-server/hw/xfree86/xf1bpp/mfbmap.sh new file mode 100644 index 000000000..514040776 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbmap.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# $XFree86: xc/programs/Xserver/hw/xfree86/xf1bpp/mfbmap.sh,v 1.1.2.3 1998/06/27 14:48:23 dawes Exp $ +# +# This script recreates the mapping list that maps the mfb external +# symbols * to xf1bpp* (without "mfb") +# This should only be rerun if there have been changes in the mfb code +# that affect the external symbols. +# It assumes that Xserver/mfb has been compiled. +# The output goes to stdout. +echo "" +echo "#ifndef _MFBMAP_H" +echo "#define _MFBMAP_H" +echo "" + +nm ../../../mfb/*.o | \ +awk "{ if ((\$2 == \"D\") || (\$2 == \"T\") || (\$2 == \"C\")) print \$3 }" | \ +sed s/^_// | \ +grep -v "ModuleInit$" | \ +sort | \ +awk "{ print \"#define \" \$1 \" xf1bpp\"\$1 }" | \ +sed s/xf1bppmfb/xf1bpp/ + +echo "" +echo "#endif" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbmisc.c b/xorg-server/hw/xfree86/xf1bpp/mfbmisc.c new file mode 100644 index 000000000..0c0ddb851 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbmisc.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbmisc.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbmodule.c b/xorg-server/hw/xfree86/xf1bpp/mfbmodule.c new file mode 100644 index 000000000..ccd3572e5 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbmodule.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 1997 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static XF86ModuleVersionInfo VersRec = +{ + "xf1bpp", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData xf1bppModuleData = { &VersRec, NULL, NULL }; diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpablack.c b/xorg-server/hw/xfree86/xf1bpp/mfbpablack.c new file mode 100644 index 000000000..90aa7faf1 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpablack.c @@ -0,0 +1,6 @@ +#define MFBSOLIDFILLAREA xf1bppSolidBlackArea +#define MFBSTIPPLEFILLAREA xf1bppStippleBlackArea +#define OPEQ &=~ +#define EQWHOLEWORD =0 +#include "mfbmap.h" +#include "../../../mfb/mfbpntarea.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpainv.c b/xorg-server/hw/xfree86/xf1bpp/mfbpainv.c new file mode 100644 index 000000000..fdbe7978a --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpainv.c @@ -0,0 +1,6 @@ +#define MFBSOLIDFILLAREA xf1bppSolidInvertArea +#define MFBSTIPPLEFILLAREA xf1bppStippleInvertArea +#define OPEQ ^= +#define EQWHOLEWORD ^=~0 +#include "mfbmap.h" +#include "../../../mfb/mfbpntarea.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpawhite.c b/xorg-server/hw/xfree86/xf1bpp/mfbpawhite.c new file mode 100644 index 000000000..5b5ccc93b --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpawhite.c @@ -0,0 +1,6 @@ +#define MFBSOLIDFILLAREA xf1bppSolidWhiteArea +#define MFBSTIPPLEFILLAREA xf1bppStippleWhiteArea +#define OPEQ |= +#define EQWHOLEWORD =~0 +#include "mfbmap.h" +#include "../../../mfb/mfbpntarea.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpgbblak.c b/xorg-server/hw/xfree86/xf1bpp/mfbpgbblak.c new file mode 100644 index 000000000..d6451a962 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpgbblak.c @@ -0,0 +1,4 @@ +#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltBlack +#define OPEQ &=~ +#include "mfbmap.h" +#include "../../../mfb/mfbplygblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpgbinv.c b/xorg-server/hw/xfree86/xf1bpp/mfbpgbinv.c new file mode 100644 index 000000000..52b35a507 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpgbinv.c @@ -0,0 +1,4 @@ +#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltInvert +#define OPEQ ^= +#include "mfbmap.h" +#include "../../../mfb/mfbplygblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpgbwht.c b/xorg-server/hw/xfree86/xf1bpp/mfbpgbwht.c new file mode 100644 index 000000000..bd4d2f7c1 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpgbwht.c @@ -0,0 +1,4 @@ +#define MFBPOLYGLYPHBLT xf1bppPolyGlyphBltWhite +#define OPEQ |= +#include "mfbmap.h" +#include "../../../mfb/mfbplygblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpixmap.c b/xorg-server/hw/xfree86/xf1bpp/mfbpixmap.c new file mode 100644 index 000000000..11c51c623 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpixmap.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbpixmap.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbplyblack.c b/xorg-server/hw/xfree86/xf1bpp/mfbplyblack.c new file mode 100644 index 000000000..f06f0dcf3 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbplyblack.c @@ -0,0 +1,5 @@ +#define MFBFILLPOLY1RECT xf1bppFillPolyBlack +#define OPEQ &=~ +#define EQWHOLEWORD =0 +#include "mfbmap.h" +#include "../../../mfb/mfbply1rct.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbplyinv.c b/xorg-server/hw/xfree86/xf1bpp/mfbplyinv.c new file mode 100644 index 000000000..9937d076d --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbplyinv.c @@ -0,0 +1,5 @@ +#define MFBFILLPOLY1RECT xf1bppFillPolyInvert +#define OPEQ ^= +#define EQWHOLEWORD ^=~0 +#include "mfbmap.h" +#include "../../../mfb/mfbply1rct.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbplywhite.c b/xorg-server/hw/xfree86/xf1bpp/mfbplywhite.c new file mode 100644 index 000000000..13560dfaa --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbplywhite.c @@ -0,0 +1,5 @@ +#define MFBFILLPOLY1RECT xf1bppFillPolyWhite +#define OPEQ |= +#define EQWHOLEWORD =~0 +#include "mfbmap.h" +#include "../../../mfb/mfbply1rct.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpolypnt.c b/xorg-server/hw/xfree86/xf1bpp/mfbpolypnt.c new file mode 100644 index 000000000..0e45a3db6 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpolypnt.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbpolypnt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbpushpxl.c b/xorg-server/hw/xfree86/xf1bpp/mfbpushpxl.c new file mode 100644 index 000000000..c03505454 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbpushpxl.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbpushpxl.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbscrclse.c b/xorg-server/hw/xfree86/xf1bpp/mfbscrclse.c new file mode 100644 index 000000000..d4aee1bfc --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbscrclse.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbscrclse.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbscrinit.c b/xorg-server/hw/xfree86/xf1bpp/mfbscrinit.c new file mode 100644 index 000000000..50b3889ce --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbscrinit.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbscrinit.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbseg.c b/xorg-server/hw/xfree86/xf1bpp/mfbseg.c new file mode 100644 index 000000000..b0bfd735f --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbseg.c @@ -0,0 +1,3 @@ +#define POLYSEGMENT +#include "mfbmap.h" +#include "../../../mfb/mfbline.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbsetsp.c b/xorg-server/hw/xfree86/xf1bpp/mfbsetsp.c new file mode 100644 index 000000000..4a16db9f3 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbsetsp.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbsetsp.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbteblack.c b/xorg-server/hw/xfree86/xf1bpp/mfbteblack.c new file mode 100644 index 000000000..32568b2ed --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbteblack.c @@ -0,0 +1,5 @@ +#define OP ~ +#define CLIPTETEXT xf1bppImageGlyphBltBlack +#define MFBTEGLYPHBLT xf1bppTEGlyphBltBlack +#include "mfbmap.h" +#include "../../../mfb/mfbtegblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbtewhite.c b/xorg-server/hw/xfree86/xf1bpp/mfbtewhite.c new file mode 100644 index 000000000..16c83f779 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbtewhite.c @@ -0,0 +1,5 @@ +#define OP +#define CLIPTETEXT xf1bppImageGlyphBltWhite +#define MFBTEGLYPHBLT xf1bppTEGlyphBltWhite +#include "mfbmap.h" +#include "../../../mfb/mfbtegblt.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbtileC.c b/xorg-server/hw/xfree86/xf1bpp/mfbtileC.c new file mode 100644 index 000000000..60c0e4069 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbtileC.c @@ -0,0 +1,3 @@ +#define MROP Mcopy +#include "mfbmap.h" +#include "../../../mfb/mfbtile.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbtileG.c b/xorg-server/hw/xfree86/xf1bpp/mfbtileG.c new file mode 100644 index 000000000..20764136d --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbtileG.c @@ -0,0 +1,3 @@ +#define MRop M0 +#include "mfbmap.h" +#include "../../../mfb/mfbtile.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbunmap.h b/xorg-server/hw/xfree86/xf1bpp/mfbunmap.h new file mode 100644 index 000000000..56b734bcd --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbunmap.h @@ -0,0 +1,114 @@ + +#ifdef _MFBMAP_H +#undef _MFBMAP_H + +#undef InverseAlu +#undef endtab +#undef mask +#undef mergeRopBits +#undef mergeGetRopBits +#undef mfbAllocatePrivates +#undef mfbBSFuncRec +#undef mfbBlackSolidFS +#undef mfbBlackStippleFS +#undef mfbBresD +#undef mfbBresS +#undef mfbChangeWindowAttributes +#undef mfbCloseScreen +#undef mfbCopyArea +#undef mfbCopyPixmap +#undef mfbCopyPlane +#undef mfbCopyRotatePixmap +#undef mfbCopyWindow +#undef mfbCreateColormap +#undef mfbCreateDefColormap +#undef mfbCreateGC +#undef mfbCreatePixmap +#undef mfbCreateWindow +#undef mfbDestroyColormap +#undef mfbDestroyPixmap +#undef mfbDestroyWindow +#undef mfbDoBitblt +#undef mfbDoBitbltCopy +#undef mfbDoBitbltCopyInverted +#undef mfbDoBitbltGeneral +#undef mfbDoBitbltOr +#undef mfbDoBitbltXor +#undef mfbFillPolyBlack +#undef mfbFillPolyInvert +#undef mfbFillPolyWhite +#undef mfbGCPrivateIndex +#undef mfbGetImage +#undef mfbGetInverseAlu +#undef mfbGetSpans +#undef mfbGetWindowPixmap +#undef mfbHorzS +#undef mfbImageGlyphBltBlack +#undef mfbImageGlyphBltWhite +#undef mfbInstallColormap +#undef mfbInvertSolidFS +#undef mfbInvertStippleFS +#undef mfbLineSD +#undef mfbLineSS +#undef mfbListInstalledColormaps +#undef mfbMapWindow +#undef mfbPadPixmap +#undef mfbPixmapToRegion +#undef mfbPixmapToRegionWeak +#undef mfbPolyFillArcSolid +#undef mfbPolyFillRect +#undef mfbPolyGlyphBltBlack +#undef mfbPolyGlyphBltInvert +#undef mfbPolyGlyphBltWhite +#undef mfbPolyPoint +#undef mfbPositionWindow +#undef mfbPushPixels +#undef mfbPushPixelsWeak +#undef mfbPutImage +#undef mfbQueryBestSize +#undef mfbQueryBestSizeWeak +#undef mfbRealizeFont +#undef mfbRealizeFontWeak +#undef mfbReduceRop +#undef mfbRegisterCopyPlaneProc +#undef mfbResolveColor +#undef mfbRestoreAreas +#undef mfbSaveAreas +#undef mfbScreenInit +#undef mfbSegmentSD +#undef mfbSegmentSS +#undef mfbSetScanline +#undef mfbSetSpans +#undef mfbSetWindowPixmap +#undef mfbSolidBlackArea +#undef mfbSolidInvertArea +#undef mfbSolidPP +#undef mfbSolidWhiteArea +#undef mfbStippleBlackArea +#undef mfbStippleInvertArea +#undef mfbStippleWhiteArea +#undef mfbTEGlyphBltBlack +#undef mfbTEGlyphBltWhite +#undef mfbTileAreaPPW +#undef mfbTileAreaPPWCopy +#undef mfbTileAreaPPWGeneral +#undef mfbTileFS +#undef mfbUninstallColormap +#undef mfbUnmapWindow +#undef mfbUnnaturalStippleFS +#undef mfbUnnaturalTileFS +#undef mfbUnrealizeFont +#undef mfbUnrealizeFontWeak +#undef mfbValidateGC +#undef mfbVertS +#undef mfbWhiteSolidFS +#undef mfbWhiteStippleFS +#undef mfbWindowPrivateIndex +#undef mfbXRotatePixmap +#undef mfbYRotatePixmap +#undef mfbZeroPolyArcSS +#undef partmasks +#undef rmask +#undef starttab + +#endif diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbunmap.sh b/xorg-server/hw/xfree86/xf1bpp/mfbunmap.sh new file mode 100644 index 000000000..44dc781fc --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbunmap.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# $XFree86: xc/programs/Xserver/hw/xfree86/xf1bpp/mfbunmap.sh,v 1.1.2.1 1998/06/27 14:48:24 dawes Exp $ +# +# This script recreates a header that undoes the effect of mfbmap.h +# This should only be rerun if there have been changes in the mfb code +# that affect the external symbols. +# It assumes that Xserver/mfb has been compiled. +# The output goes to stdout. +echo "" +echo "#ifdef _MFBMAP_H" +echo "#undef _MFBMAP_H" +echo "" + +nm ../../../mfb/*.o | \ +awk "{ if ((\$2 == \"D\") || (\$2 == \"T\") || (\$2 == \"C\")) print \$3 }" | \ +sed s/^_// | \ +grep -v "ModuleInit$" | \ +sort | \ +awk "{ print \"#undef \" \$1 }" + +echo "" +echo "#endif" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbwindow.c b/xorg-server/hw/xfree86/xf1bpp/mfbwindow.c new file mode 100644 index 000000000..e16082559 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbwindow.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbwindow.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/mfbzerarc.c b/xorg-server/hw/xfree86/xf1bpp/mfbzerarc.c new file mode 100644 index 000000000..01f2a5446 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/mfbzerarc.c @@ -0,0 +1,2 @@ +#include "mfbmap.h" +#include "../../../mfb/mfbzerarc.c" diff --git a/xorg-server/hw/xfree86/xf1bpp/xf1bpp.h b/xorg-server/hw/xfree86/xf1bpp/xf1bpp.h new file mode 100644 index 000000000..33e5818c3 --- /dev/null +++ b/xorg-server/hw/xfree86/xf1bpp/xf1bpp.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 1994-1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifndef __XF1BPP_H__ +#define __XF1BPP_H__ + +#define MFB_PROTOTYPES_ONLY +#include "mfbmap.h" +#include "mfb.h" +#include "mfbunmap.h" +#undef MFB_PROTOTYPES_ONLY + +#endif diff --git a/xorg-server/hw/xfree86/xf4bpp/Makefile.am b/xorg-server/hw/xfree86/xf4bpp/Makefile.am new file mode 100644 index 000000000..1414a0d0f --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/Makefile.am @@ -0,0 +1,57 @@ +module_LTLIBRARIES = libxf4bpp.la + +sdk_HEADERS = xf4bpp.h + +libxf4bpp_la_LDFLAGS = -avoid-version + +libxf4bpp_la_SOURCES = \ + ppcArea.c \ + ppcClip.c \ + ppcCpArea.c \ + ppcCReduce.c \ + ppcDepth.c \ + ppcFillRct.c \ + ppcWinFS.c \ + ppcPixFS.c \ + ppcGC.c \ + ppcGetSp.c \ + ppcImg.c \ + ppcPixmap.c \ + ppcPolyPnt.c \ + ppcQuery.c \ + ppcRslvC.c \ + ppcSetSp.c \ + ppcWindow.c \ + ppcIO.c \ + emulOpStip.c \ + emulRepAre.c \ + emulTile.c \ + vgaGC.c \ + vgaBitBlt.c \ + vgaImages.c \ + vgaStipple.c \ + vgaSolid.c \ + offscreen.c \ + wm3.c \ + mfbimggblt.c \ + mfbline.c \ + mfbseg.c \ + mfbhrzvert.c \ + mfbbres.c \ + mfbbresd.c \ + mfbfillarc.c \ + mfbzerarc.c \ + vgamodule.c + +EXTRA_DIST = OScompiler.h ibmTrace.h ppcGCstr.h ppcSpMcro.h vgaReg.h \ + vgaVideo.h wm3.h NOTES + +DISTCLEANFILES = mfbseg.c + +mfbseg.c: + echo "#define POLYSEGMENT" > $@ + echo "#include \"$(srcdir)/mfbline.c\"" >> $@ + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../xf1bpp -I$(top_srcdir)/mfb + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xfree86/xf4bpp/Makefile.in b/xorg-server/hw/xfree86/xf4bpp/Makefile.in new file mode 100644 index 000000000..0a242da14 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/Makefile.in @@ -0,0 +1,791 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/xf4bpp +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libxf4bpp_la_LIBADD = +am_libxf4bpp_la_OBJECTS = ppcArea.lo ppcClip.lo ppcCpArea.lo \ + ppcCReduce.lo ppcDepth.lo ppcFillRct.lo ppcWinFS.lo \ + ppcPixFS.lo ppcGC.lo ppcGetSp.lo ppcImg.lo ppcPixmap.lo \ + ppcPolyPnt.lo ppcQuery.lo ppcRslvC.lo ppcSetSp.lo ppcWindow.lo \ + ppcIO.lo emulOpStip.lo emulRepAre.lo emulTile.lo vgaGC.lo \ + vgaBitBlt.lo vgaImages.lo vgaStipple.lo vgaSolid.lo \ + offscreen.lo wm3.lo mfbimggblt.lo mfbline.lo mfbseg.lo \ + mfbhrzvert.lo mfbbres.lo mfbbresd.lo mfbfillarc.lo \ + mfbzerarc.lo vgamodule.lo +libxf4bpp_la_OBJECTS = $(am_libxf4bpp_la_OBJECTS) +libxf4bpp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libxf4bpp_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxf4bpp_la_SOURCES) +DIST_SOURCES = $(libxf4bpp_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libxf4bpp.la +sdk_HEADERS = xf4bpp.h +libxf4bpp_la_LDFLAGS = -avoid-version +libxf4bpp_la_SOURCES = \ + ppcArea.c \ + ppcClip.c \ + ppcCpArea.c \ + ppcCReduce.c \ + ppcDepth.c \ + ppcFillRct.c \ + ppcWinFS.c \ + ppcPixFS.c \ + ppcGC.c \ + ppcGetSp.c \ + ppcImg.c \ + ppcPixmap.c \ + ppcPolyPnt.c \ + ppcQuery.c \ + ppcRslvC.c \ + ppcSetSp.c \ + ppcWindow.c \ + ppcIO.c \ + emulOpStip.c \ + emulRepAre.c \ + emulTile.c \ + vgaGC.c \ + vgaBitBlt.c \ + vgaImages.c \ + vgaStipple.c \ + vgaSolid.c \ + offscreen.c \ + wm3.c \ + mfbimggblt.c \ + mfbline.c \ + mfbseg.c \ + mfbhrzvert.c \ + mfbbres.c \ + mfbbresd.c \ + mfbfillarc.c \ + mfbzerarc.c \ + vgamodule.c + +EXTRA_DIST = OScompiler.h ibmTrace.h ppcGCstr.h ppcSpMcro.h vgaReg.h \ + vgaVideo.h wm3.h NOTES + +DISTCLEANFILES = mfbseg.c +INCLUDES = $(XORG_INCS) -I$(srcdir)/../xf1bpp -I$(top_srcdir)/mfb +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/xf4bpp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/xf4bpp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libxf4bpp.la: $(libxf4bpp_la_OBJECTS) $(libxf4bpp_la_DEPENDENCIES) + $(libxf4bpp_la_LINK) -rpath $(moduledir) $(libxf4bpp_la_OBJECTS) $(libxf4bpp_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emulOpStip.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emulRepAre.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emulTile.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbres.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbbresd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbfillarc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbhrzvert.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbimggblt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbline.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbseg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfbzerarc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/offscreen.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcArea.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcCReduce.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcClip.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcCpArea.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcDepth.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcFillRct.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcGC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcGetSp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcIO.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcImg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcPixFS.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcPixmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcPolyPnt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcQuery.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcRslvC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcSetSp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcWinFS.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcWindow.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgaBitBlt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgaGC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgaImages.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgaSolid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgaStipple.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vgamodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wm3.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + + +mfbseg.c: + echo "#define POLYSEGMENT" > $@ + echo "#include \"$(srcdir)/mfbline.c\"" >> $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/xf4bpp/NOTES b/xorg-server/hw/xfree86/xf4bpp/NOTES new file mode 100644 index 000000000..e3b77dcfd --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/NOTES @@ -0,0 +1,194 @@ +This code originally hails from IBM. It was ported to an early XFree86 by +Gertjan Akkerman, whose BUGS file I append here. + +In turn, this is a port of Gertjan's work to the new server design. Among the +changes are: + +- The removal of almost all unreferenced code. +- The removal of this code's own copy of mfb (xf1bpp is used instead). +- The removal of banking support (mibank is used instead). +- External symbols were made static where this was sufficient. +- The remaining external names were renamed to xf4bpp*. +- Several minor cleanups too many to mention here. + +To understate the matter, this code is >UGLY<. This seems inherent in IBM's +corporate culture. Be that as it may, it *does* survive X11R4's xtest +(whatever that means these days...). For now, this is sufficient for 4bpp +support in the new design, but at some point, I'll have to sit down and +rewrite this from scratch. A more technical justification for a rewrite is +that the pixmap format is 8bpp, instead of 4bpp, which is causing me to +pepper the rest of the server with unclean accomodations. + +Marc. + +=============================================================================== +Section 1: From IBM's X11R4 contribution towards XFree86. + +This section describes what I did to obtain a 16 colour vga server. + +I started with the SYSV, ppc, vga and common directories from IBM's X11R4 +contribution. Those directories have the following function: +1. SYSV implements the mouse and keyboard. +2. ppc is a generic layer implementing ddx in terms of drawing operations + through rectangles. (With spans as a boundary case: height = 1.) +3. vga implements a layer of operations drawing through rectangles. +4. common implements ddx initialization and quitting, and screen saving. + +I eliminated SYSV and common since the functionality provided therein is +already provided in XFree86. Since XFree86 is actively being ported to +new operating systems, while X11R4 is out of date, I preferred the XFree86 +code here above the SYSV and common code. +Whatever functionality was still needed from common (default colormap +initialization -- not much code) was moved into ppc. + +Since XFree86 uses the mi-provided software cursor code, IBM's software +cursor code was deleted from ppc and vga. This is a pity, since it is +expected that it is more efficient than mi's code, but the XFree86 mouse and +keyboard code directly call mi, and I do not want to maintain the XFree86 +mouse and keyboard code. + +Since we cannot support a monolithic multi-screen server using all of the +x11r4 contributed code yet, all multi screen code was deleted. This includes +one header file containing a nasty copyright statement. + +Since glyph handling has changed between X11R4 and X11R5, the code handling +glyphs was replaced by appropriate calls to mi. +I hope it can be modified and put back one day. + +Provisionally, some code was added (viz. file vga/offscreen.c) to intercept +calls to the rectangle drawing code when we are switched out of the VT. +I hope this can be replaced by some window tree invalidation and GC validation +scheme. + + +Section 2: BUGS + +This section describes fixed and still unfixed bugs in this code. +All bugs not labeled otherwise also occur in IBM's X11R4 code, and may be of +interest to anybody using that code. + +1. (Fixed.) +I found (and provisionally fixed) a bug in the IBM bitblit code: +In file ddx/ibm/vga/vgaImages.c a function vgaReadColorImage is defined. +When this function is used to read less than 8 pixels starting on a byte +boundary it will always read precisely 8 pixels. +Thus, when space is allocated for 4 or less pixels, it will write beyond +the allocated space. +Since the code is rather convoluted, this may not be apparent at first sight, +but going through the code with an example shows the error. + +2. (Fixed.) +In ppcPixmapFS.c, function ppcStipplePixmapFS there was a bug +regarding the stipple origin: The horizontal origin is added while +the vertical one is subtracted. The horizontal origin should be subtracted +instead of added here. +This bug gets visible when backing-store is enabled and one uses twm: +the submenu icons get truncated on their left hand side. +(In case you wonder why this bug appears: under those circumstances +twm prepares its menus by drawing into an unmapped window. +The miCopyPlane function uses the ppcStipplePixmap (and many others) +to get the plane copied.) +I also fixed this bug in the other routines (ppcOpStipplePixmapFS, +ppcTilePixmapFS) in this file, although I had no visible clues for this. +I hope this is appropriate. + +3. (Fixed.) +I find it suspect that ppcSetSpans gives different output when one +claims that an actually sorted list of spans is unsorted. +The unsorted code is wrong, and should be made to look more like the sorted +code. I.e., use ( xStart - ppt->x ) instead of ( xStart - pbox->x1 ) + +4. (Fixed.) +There used to be another bug that became visible when using twm and backing +store: popping up a submenu, and moving the cursor upwards til it leaves the +submenu, the submenu would disappears, as it should. +But the submenu icon would not get restored, while it should be. +10b. By replacing the clip-computing code in ppcValidateGC by that in +cfbValidateGC, I *finally* fixed the disappearing twm menu icon problem. + +5. Added mfbRegisterCopyplaneProc call. [Its omission was an error on my + part.] + Fixing a server core dump in XTest. + +6. Fixed not-very-high tile bug in function ppcTileRect, file emulTile.c + (I.e., if the tile was higher than the area to be tiled, far too much + was drawn, causing server core dumps in XTest.) + Actually, "savey" ought to be used to determine the height of the tiles in + the top line to be tiled, instead of "pTile->drawable.height". +7. A use of height where width was intended was fixed in ppcTileRect: + "savehcount = w / pTile->drawable.height;" should use "... .width" and + "savehcount = ( x + w - htarget ) / pTile->drawable.height;" too. + +8. Deleted overly clever code in ppcCReduce.c + (All code that tried to pre-compute how alu's could be replaced by + other alu's with inverted colors, etc. was deleted. I think it is + at least wrong for FillSolid.) + +9. Looked at suspicious code in ppcSetSp.c + "tmpx = *pdst;" was never updated during the loop. We took it out of the + initialization position of the for and moved it into the loop. + +10. Add xSrc := GC->patOrg.x + pDrawable.x and ySrc := ... in ppcPixmapFS.c, + functions ppcStipplePixmapFS, ppcOpStipplePixmapFS, and ppcTilePixmapFS. + This because stipple and tile origins are taken relative to the drawable. + Also use a "modulo" function that gets the cases of a negative stipple + or tile offset right. (When the stipple origin is to the right of or + below the origin of the drawable.) + +11. File vgaSolid.c, function vgaFillSolid: + Inverting is XORing with all ones. Not with the color we want to AND/OR + later. So we'll have to set the color to VGA_ALLPLANES + whenever we want to invert existing data, and reset it before the + AND/OR is done. + Also we replaced an outb( 0x3CF, tmp2 ) by the SetVideoGraphicsData( tmp2 ) + it is representing. (Just a cosmetic replacement.) + +12. File vgaImages, function vgaDrawColorImage. + Moved a line "invert_existing_data = TRUE;" two lines down, past a case + label. Now it is also part of the code executed for GXorReverse, as it + should be. + +13. The pixmap FillSpans routines (file ppcPixmapFS.c) got somewhat better + after importing some code from ddx/ibm/vga. (A getbits function that does + wrapping.) + They were wrong for the FillStippled and FillOpaqueStippled modes. + I don't understand the old code. How could it handle stipples of a size not + an exact multiple of 32? (or 8, for that matter.) + +14. In function vgaBitBlt file vgaBitBlt.c, in the shortcuts for + GXSet, GXClear and GXInvert, the source (x0,y0) is accidentally operated + upon by vgaFillSolid, instead of the destination (x1,y1). + +15. Notice that in DoMonoSingle and DoMonoMany in file vgaStipple.c, the left + edge of the square to be stippled is treated wrong. + Correct would be to get the bits with getbits using offset xshift, and + to shift them right (x & 07) places. + [One might wish to use the variable tmp1 at this place, since it had been + set to (x & 07) at this place; but that is already re-used at this point.] + Also note that NeedValX is set wrong: The implicit assumption was that + stipples are more than 8 wide. + This only fixes the problem when miPushPixel is used instead of ppcPushPixel. + I think I should look some more into this. + +16. I took out some code of the CopyArea function, in which a no-op function + was called while a real one was needed. My fix does not completely work, + although it improved the behaviour of GetImage somewhat. + +17. After finding three kinds of errors in this single function, + -- the new kinds being the right side not being always written due to + an incorrect if scope, and the lower end not always being written due + to variables being updated at the wrong place -- + (requiring modifications to be made at at least 10 places, + I decided to REWRITE the body of the ppcTileRect function from scratch. + This version simply computes all relevant margins in advance, and does + not try to reuse temporary variables. I leave that to the compiler. + (This was a maintenance and robustness nightmare anyway.) + +MORE NOTES: + It is funny that there are two files in mi that require compilation + with the proper #defines ( -DXF86VGA16 in my case ): + Besides the obvious mibitblt.c, there is also mipushpxl.c. + + + +$XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/NOTES,v 1.1.2.2 1998/06/27 15:15:45 dawes Exp $ diff --git a/xorg-server/hw/xfree86/xf4bpp/OScompiler.h b/xorg-server/hw/xfree86/xf4bpp/OScompiler.h new file mode 100644 index 000000000..8a8bbb59c --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/OScompiler.h @@ -0,0 +1,58 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef __COMPILER_DEPENDANCIES__ +#define __COMPILER_DEPENDANCIES__ + +#define MOVE( src, dst, length ) memcpy( dst, src, length) +#define MAX(a,b) (((a)>(b))?(a):(b)) +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define ABS(x) (((x)>0)?(x):-(x)) + +#include "misc.h" +#include "compiler.h" + +#ifdef lint +/* So that lint doesn't complain about constructs it doesn't understand */ +#ifdef volatile +#undef volatile +#endif +#define volatile +#ifdef const +#undef const +#endif +#define const +#ifdef signed +#undef signed +#endif +#define signed +#ifdef _ANSI_DECLS_ +#undef _ANSI_DECLS_ +#endif +#endif + +#endif /* !__COMPILER_DEPENDANCIES__ */ diff --git a/xorg-server/hw/xfree86/xf4bpp/emulOpStip.c b/xorg-server/hw/xfree86/xf4bpp/emulOpStip.c new file mode 100644 index 000000000..542e9d394 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/emulOpStip.c @@ -0,0 +1,102 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* ppc OpaqueStipple + * + * Based on the private stipple; does a foreground, and then an inverted + * on the background + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" + +void +xf4bppOpaqueStipple( pWin, pStipple, fg, bg, alu, planes, x, y, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr pStipple ; +unsigned long int fg ; +unsigned long int bg ; +int alu ; +unsigned long int planes ; +register int x, y, w, h ; +int xSrc, ySrc ; +{ + /* DO BACKGROUND */ + switch ( alu ) { + /* Easy Cases -- i.e. Final Result Doesn't Depend On Initial Dest. */ + case GXclear: /* 0x0 Zero 0 */ + case GXset: /* 0xf 1 */ + /* Foreground And Background Are Both The Same !! */ + xf4bppFillSolid( pWin, bg, alu, planes, x, y, w, h ) ; + case GXnoop: /* 0x5 dst */ + break ; + case GXcopy: /* 0x3 src */ + case GXcopyInverted: /* 0xc NOT src */ + { /* Special Case Code */ + register int vtarget, htarget ; + + /* We Can Draw Just One Copy Then Blit The Rest !! */ + /* Draw The One Copy */ + htarget = MIN( w, pStipple->drawable.width ) ; + vtarget = MIN( h, pStipple->drawable.height ) ; + + /* First The Background */ + xf4bppFillSolid( pWin, bg, alu, planes, x, y, + htarget, vtarget ) ; + /* Then The Foreground */ + xf4bppFillStipple( pWin, pStipple, fg, alu, planes, + x, y, htarget, vtarget, + xSrc, ySrc ) ; + + /* Here We Double The Size Of The BLIT Each Iteration */ + xf4bppReplicateArea(pWin, x, y, planes, w, h, htarget, vtarget); + } + break ; + default: + /* Hard Cases -- i.e. Final Result DOES Depend On Initial Dest. */ + { /* Do The Background */ + register int i, j; + register PixmapPtr pInvPixmap = xf4bppCopyPixmap( pStipple ) ; + register unsigned char *data = pInvPixmap->devPrivate.ptr ; + + /* INVERT PIXMAP OK, jeff, this is for you */ + for ( i = pInvPixmap->drawable.height ; i-- ; ) + for ( j = pInvPixmap->devKind ; j-- ; data++ ) + *data = ~ ( *data ) ; + + xf4bppFillStipple( pWin, pInvPixmap, bg, alu, planes, x, y, w, h, xSrc, ySrc ); + mfbDestroyPixmap( pInvPixmap ) ; + /* DO FOREGROUND */ + xf4bppFillStipple( pWin, pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc ); + } + break ; + } + return; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/emulRepAre.c b/xorg-server/hw/xfree86/xf4bpp/emulRepAre.c new file mode 100644 index 000000000..20fff1e0c --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/emulRepAre.c @@ -0,0 +1,69 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* ppc Replicate Area -- A Divide & Conquer Algorithm + * a "ppc" Helper Function For Stipples And Tiling + * P. Shupak 1/88 + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" + +void xf4bppReplicateArea( pWin, x, y, planeMask, goalWidth, goalHeight, + currentHoriz, currentVert) +WindowPtr pWin; /* GJA */ +register int x, y, planeMask ; +int goalWidth, goalHeight ; +int currentHoriz, currentVert ; +{ + for ( ; + currentHoriz <= ( goalWidth >> 1 ) ; + currentHoriz <<= 1 ) { + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x + currentHoriz, y, + currentHoriz, currentVert ) ; + } + if ( goalWidth - currentHoriz ) + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x + currentHoriz, y, + goalWidth - currentHoriz, currentVert ) ; + for ( ; + currentVert <= ( goalHeight >> 1 ) ; + currentVert <<= 1 ) { + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x, y + currentVert, + goalWidth, currentVert ) ; + } + if ( goalHeight - currentVert ) + xf4bppBitBlt( pWin, GXcopy, planeMask, + x, y, + x, y + currentVert, + goalWidth, goalHeight - currentVert ) ; +return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/emulTile.c b/xorg-server/hw/xfree86/xf4bpp/emulTile.c new file mode 100644 index 000000000..2f2a758f2 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/emulTile.c @@ -0,0 +1,352 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* ppc Tile + * P. Shupak 11/87 + * Modified From original ppc Tile + * T. Paquin 9/87 + * Uses private imageFill a bunch of times + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "ibmTrace.h" + +static void +DrawFirstTile +( + WindowPtr pWin, /* GJA */ + register PixmapPtr pTile, + register int x, + register int y, + int w, + int h, + int alu, + unsigned long int planes, + int xOffset, + int yOffset +) +{ +register int htarget ; +register int vtarget ; + + if ( xOffset ) { /* Not X-Aligned */ + if ( yOffset ) { /* Nor Y-Aligned */ + htarget = MIN( pTile->drawable.width - xOffset, w ), + vtarget = MIN( pTile->drawable.height - yOffset, h ), + yOffset *= pTile->devKind ; + xf4bppDrawColorImage( pWin,x, y, + htarget, + vtarget, + (unsigned char *)pTile->devPrivate.ptr + yOffset + xOffset, + pTile->devKind, + alu, planes ) ; + if ( w > htarget ) { + w = MIN( w, pTile->drawable.width ) ; + if ( h > vtarget ) { + h = MIN( h, pTile->drawable.height ) ; + xf4bppDrawColorImage( pWin, x, y + vtarget, + htarget, + h - vtarget, + (unsigned char *)pTile->devPrivate.ptr + xOffset, + pTile->devKind, + alu, planes ) ; + xf4bppDrawColorImage( pWin, x + htarget, y, + w - htarget, + vtarget, + (unsigned char *)pTile->devPrivate.ptr + yOffset, + pTile->devKind, + alu, planes ) ; + xf4bppDrawColorImage( pWin, x + htarget, + y + vtarget, + w - htarget, + h - vtarget, + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + else { /* h <= vtarget */ + xf4bppDrawColorImage( pWin, x + htarget, y, + w - htarget, + vtarget, + (unsigned char *)pTile->devPrivate.ptr + yOffset, + pTile->devKind, + alu, planes ) ; + } + } + else if ( h > vtarget ) { + xf4bppDrawColorImage( pWin, x, y + vtarget, + htarget, + MIN( h, pTile->drawable.height ) - vtarget, + (unsigned char *)pTile->devPrivate.ptr + xOffset, + pTile->devKind, + alu, planes ) ; + vtarget = pTile->drawable.height ; + } + } + else { /* No Y Offset */ + xf4bppDrawColorImage( pWin, x, y, + htarget = MIN( pTile->drawable.width - xOffset, w ), + vtarget = MIN( pTile->drawable.height, h ), + (unsigned char *)pTile->devPrivate.ptr + xOffset, + pTile->devKind, + alu, planes ) ; + if ( w > htarget ) { + xf4bppDrawColorImage( pWin, x + htarget, y, + MIN( pTile->drawable.width, w ) - htarget, + vtarget, + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + } + } + else if ( yOffset ) { + xf4bppDrawColorImage( pWin, x, y, + htarget = MIN( pTile->drawable.width, w ), + vtarget = MIN( pTile->drawable.height - yOffset, h ), + (unsigned char *)pTile->devPrivate.ptr + ( yOffset * pTile->devKind ), + pTile->devKind, + alu, planes ) ; + if ( h > vtarget ) { + xf4bppDrawColorImage( pWin, x, y + vtarget, + htarget, + MIN( pTile->drawable.height, h ) - vtarget, + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + } + else { /* NO Offset */ + xf4bppDrawColorImage( pWin, x, y, + htarget = MIN( pTile->drawable.width, w ), + vtarget = MIN( pTile->drawable.height, h ), + pTile->devPrivate.ptr, + pTile->devKind, + alu, planes ) ; + } + + return ; +} + +/* GJA -- + * After finding three kinds of errors in this single function, + * (requiring modifications to be made at at least 10 places, + * I decided to REWRITE the body of the xf4bppTileRect function from scratch. + * This version simply computes all relevant margins in advance, and does + * not try to reuse temporary variables. I leave that to the compiler. + * (This was a maintenance and robustness nightmare anyway.) + * The code is pretty obvious: all margins, coordinates, and numbers of tiles + * are computed before drawing starts. + * Notice that the margins consist of incompletely drawn tiles. Therefore + * we need offsets in the data for the left and upper margins. + * The right and lower margins are also incomplete, but start at offset 0 + * in the data. They just end at awkward offsets. + * The center block, by definition, consists of fully drawn tiles. + * Perhaps we could leave out some if's. But why bother? It would decrease + * robustness. + */ +void +xf4bppTileRect( pWin, pTile, alu, planes, x0, y0, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr pTile ; +const int alu ; +const unsigned long int planes ; +register int x0, y0, w, h ; +int xSrc ; +int ySrc ; +{ +int xOffset ; +int yOffset ; +int width, height; + +TRACE( ( "xf4bppTileRect(pTile=x%x,alu=x%x,planes=x%02x,x0=%d,y0=%d,w=%d,h=%d,xSrc=%d,ySrc=%d\n", + pTile, alu, planes, x0, y0, w, h, xSrc, ySrc ) ) ; + + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppFillSolid + ( pWin, 0xFF, alu, planes, x0, y0, w, h ) ; + case GXnoop: /* 0x5 dst */ + return ; + default: + break ; +} + + width = pTile->drawable.width; + if ( ( xOffset = ( x0 - xSrc ) ) > 0 ) + xOffset %= width ; + else + xOffset = width - (( - xOffset ) % width ) ; + if ( xOffset == width ) xOffset = 0; /* For else case */ + + height = pTile->drawable.height; + if ( ( yOffset = ( y0 - ySrc ) ) > 0 ) + yOffset %= height ; + else + yOffset = height - (( - yOffset ) % height ) ; + if ( yOffset == height ) yOffset = 0; /* For else case */ + + switch ( alu ) { + case GXcopyInverted: /* 0xc NOT src */ + case GXcopy: /* 0x3 src */ + /* Special Case Code */ + DrawFirstTile( pWin, pTile, x0, y0, w, h, + alu, planes, xOffset, yOffset ) ; + /* Here We Double The Size Of The BLIT Each Iteration */ + xf4bppReplicateArea( pWin, x0, y0, planes, w, h, + MIN( w, pTile->drawable.width ), + MIN( h, pTile->drawable.height ) ) ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + case GXandReverse: /* 0x2 src AND NOT dst */ + case GXorReverse: /* 0xb src OR NOT dst */ + case GXnand: /* 0xe NOT src OR NOT dst */ + case GXandInverted: /* 0x4 NOT src AND dst */ + case GXand: /* 0x1 src AND dst */ + case GXequiv: /* 0x9 NOT src XOR dst */ + case GXxor: /* 0x6 src XOR dst */ + case GXorInverted: /* 0xd NOT src OR dst */ + case GXor: /* 0x7 src OR dst */ + default: + { + register unsigned char *data ; + register int hcount, vcount ; /* Number of tiles in center */ + int xcount, ycount; /* Temporaries */ + int x1, y1; /* Left upper corner of center */ + int x2, y2; /* Left upper corner of lower right margin */ + int leftmgn, rightmgn, topmgn, botmgn; /* Margins */ + + int htarget, vtarget ; + + data = pTile->devPrivate.ptr; + + /* Compute the various sizes and coordinates. */ + leftmgn = MIN( w, width - xOffset ) ; + x1 = x0 + leftmgn; + topmgn = MIN( h, height - yOffset ) ; + y1 = y0 + topmgn; + + rightmgn = (w - leftmgn) % width; + hcount = (w - leftmgn) / width; + x2 = x0 + w - rightmgn; + botmgn = (h - topmgn) % height; + vcount = (h - topmgn) / height; + y2 = y0 + h - botmgn; + + /* We'll use yOffset as offset in data. + * This requires yOffset != height (ditto xOffset). + */ + yOffset *= pTile->devKind; + + /* Draw top margin, including corners */ + if ( topmgn ) { + if ( leftmgn ) { + xf4bppDrawColorImage( pWin, x0, y0, leftmgn, topmgn, + data + yOffset + xOffset, + pTile->devKind, alu, planes ) ; + } + for ( xcount = hcount, htarget = x1; + xcount ; + xcount--, htarget += width ) + { + xf4bppDrawColorImage( pWin, htarget, y0, width, topmgn, + data + yOffset, + pTile->devKind, alu, planes ) ; + } + if ( rightmgn ) { + xf4bppDrawColorImage( pWin, x2, y0, rightmgn, topmgn, + data + yOffset, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw bottom margin, including corners */ + if ( botmgn ) { + if ( leftmgn ) { + xf4bppDrawColorImage( pWin, x0, y2, leftmgn, botmgn, + data + xOffset, + pTile->devKind, alu, planes ) ; + } + for ( xcount = hcount, htarget = x1; + xcount ; + xcount--, htarget += width ) + { + xf4bppDrawColorImage( pWin, htarget, y2, width, botmgn, + data, + pTile->devKind, alu, planes ) ; + } + if ( rightmgn ) { + xf4bppDrawColorImage( pWin, x2, y2, rightmgn, botmgn, + data, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw left margin, excluding corners */ + if ( leftmgn ) { + for ( ycount = vcount, vtarget = y1 ; + ycount ; + ycount--, vtarget += height ) + { + xf4bppDrawColorImage( pWin, x0, vtarget, leftmgn, height, + data + xOffset, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw right margin, excluding corners */ + if ( rightmgn ) { + for ( ycount = vcount, vtarget = y1 ; + ycount ; + ycount--, vtarget += height ) + { + xf4bppDrawColorImage( pWin, x2, vtarget, rightmgn, height, + data, + pTile->devKind, alu, planes ) ; + } + } + + /* Draw center consisting of full tiles */ + for ( ycount = vcount, vtarget = y1 ; + ycount ; + ycount--, vtarget += height ) + { + for ( xcount = hcount, htarget = x1 ; + xcount ; + xcount--, htarget += width ) + { + xf4bppDrawColorImage( pWin, htarget, vtarget, width, height, + data, + pTile->devKind, alu, planes ) ; + + } + } + } } /* Block + switch */ +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ibmTrace.h b/xorg-server/hw/xfree86/xf4bpp/ibmTrace.h new file mode 100644 index 000000000..f1d88406d --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ibmTrace.h @@ -0,0 +1 @@ +#define TRACE(x) /* empty */ diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbbres.c b/xorg-server/hw/xfree86/xf4bpp/mfbbres.c new file mode 100644 index 000000000..09d7ee288 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbbres.c @@ -0,0 +1,164 @@ +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "miline.h" +#include "wm3.h" + +/* Solid bresenham line */ +/* NOTES + e2 is used less often than e1, so it's not in a register +*/ + +void +xf4bppBresS(addrlbase, nlwidth, signdx, signdy, axis, x1, y1, e, e1, e2, len) +PixelType *addrlbase; /* pointer to base of bitmap */ +int nlwidth; /* width in longwords of bitmap */ +int signdx, signdy; /* signs of directions */ +int axis; /* major axis (Y_AXIS or X_AXIS) */ +int x1, y1; /* initial point */ +register int e; /* error accumulator */ +register int e1; /* bresenham increments */ +int e2; +int len; /* length of line */ +{ + register int yinc; /* increment to next scanline, in bytes */ + register PixelType *addrl; /* bitmask long pointer + *dont* * cast to char pointer */ + register PixelType bit; /* current bit being set/cleared/etc. */ + PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */ + PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */ + + register int e3 = e2-e1; + + /* point to longword containing first point */ + addrl = mfbScanline(addrlbase, x1, y1, nlwidth); + yinc = signdy * nlwidth; + e = e-e1; /* to make looping easier */ + bit = mfbGetmask(x1 & PIM); + + if (!len) + return; + + if (axis == X_AXIS) + { + if (signdx > 0) + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + } + } + else + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + } + } + } /* if X_AXIS */ + else + { + if (signdx > 0) + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + e += e3; + } + addrl += yinc; + } + } + else + { + while(len--) + { + UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + e += e3; + } + addrl += yinc; + } + } + } /* else Y_AXIS */ +} diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbbresd.c b/xorg-server/hw/xfree86/xf4bpp/mfbbresd.c new file mode 100644 index 000000000..318d4f5da --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbbresd.c @@ -0,0 +1,205 @@ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "miline.h" +#include "wm3.h" +#include "xf86.h" + +/* Dashed bresenham line */ + +#define NO_INK (-1) /* GJA -- means: dash is off */ + +#define StepDash\ + if (!--dashRemaining) { \ + if (++ dashIndex == numInDashList) \ + dashIndex = 0; \ + dashRemaining = pDash[dashIndex]; \ + ink = fgink; \ + if (dashIndex & 1) \ + ink = bgink; \ + if (isDoubleDash) \ + WM3_SET_INK(ink); \ + } + +void +xf4bppBresD(pDrawable, fgink, bgink, + pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash, + addrlbase, nlwidth, + signdx, signdy, axis, x1, y1, e, e1, e2, len) +DrawablePtr pDrawable; +int fgink, bgink; +int *pdashIndex; /* current dash */ +unsigned char *pDash; /* dash list */ +int numInDashList; /* total length of dash list */ +int *pdashOffset; /* offset into current dash */ +int isDoubleDash; +PixelType *addrlbase; /* pointer to base of bitmap */ +int nlwidth; /* width in longwords of bitmap */ +int signdx, signdy; /* signs of directions */ +int axis; /* major axis (Y_AXIS or X_AXIS) */ +int x1, y1; /* initial point */ +register int e; /* error accumulator */ +register int e1; /* bresenham increments */ +int e2; +int len; /* length of line */ +{ + IOADDRESS REGBASE = + xf86Screens[pDrawable->pScreen->myNum]->domainIOBase + 0x300; + register int yinc; /* increment to next scanline, in bytes */ + register PixelType *addrl; + register int e3 = e2-e1; + register unsigned long bit; + PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */ + PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */ + int dashIndex; + int dashOffset; + int dashRemaining; + int ink; + + fgink &= 0x0F; bgink &= 0x0F; /* GJA -- so they're != NO_INK */ + + dashOffset = *pdashOffset; + dashIndex = *pdashIndex; + dashRemaining = pDash[dashIndex] - dashOffset; + ink = fgink; + if (!isDoubleDash) + bgink = NO_INK; + if (dashIndex & 1) + ink = bgink; + if ( ink != NO_INK ) WM3_SET_INK(ink); + + /* point to longword containing first point */ + addrl = mfbScanline(addrlbase, x1, y1, nlwidth); + yinc = signdy * nlwidth; + e = e-e1; /* to make looping easier */ + bit = mfbGetmask(x1 & PIM); + if (axis == X_AXIS) + { + if (signdx > 0) + { + while(len--) + { + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + StepDash + } + } + else + { + while(len--) + { + + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + addrl += yinc; + e += e3; + } + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + StepDash + } + } + } /* if X_AXIS */ + else + { + if (signdx > 0) + { + while(len--) + { + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRRIGHT(bit,1); + if (!bit) { bit = leftbit; addrl++; } + e += e3; + } + addrl += yinc; + StepDash + } + } + else + { + while(len--) + { + + if ( ink != NO_INK ) UPDRW(addrl,bit); + e += e1; + if (e >= 0) + { + bit = SCRLEFT(bit,1); + if (!bit) { bit = rightbit; addrl--; } + e += e3; + } + addrl += yinc; + StepDash + } + } + } /* else Y_AXIS */ + *pdashIndex = dashIndex; + *pdashOffset = pDash[dashIndex] - dashRemaining; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbfillarc.c b/xorg-server/hw/xfree86/xf4bpp/mfbfillarc.c new file mode 100644 index 000000000..89aeadd2b --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbfillarc.c @@ -0,0 +1,301 @@ +/************************************************************ + +Copyright (c) 1989 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + +********************************************************/ + +/* GJA -- Took mfb code and modified it. */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "mifillarc.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +static void +v16FillEllipseSolid +( + DrawablePtr pDraw, + xArc *arc +) +{ + int x, y, e; + int yk, xk, ym, xm, dx, dy, xorg, yorg; + register int slw; + miFillArcRec info; + int *addrlt, *addrlb; + register int *addrl; + register int n; + int nlwidth; + register int xpos; + int startmask, endmask, nlmiddle; + + if (pDraw->type == DRAWABLE_WINDOW) + { + addrlt = (int *) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr); + nlwidth = (int) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2; + } + else + { + addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr); + nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2; + } + + miFillArcSetup(arc, &info); + MIFILLARCSETUP(); + xorg += pDraw->x; + yorg += pDraw->y; + addrlb = addrlt; + addrlt += nlwidth * (yorg - y); + addrlb += nlwidth * (yorg + y + dy); + while (y) + { + addrlt += nlwidth; + addrlb -= nlwidth; + MIFILLARCSTEP(slw); + if (!slw) + continue; + xpos = xorg - x; + addrl = addrlt + (xpos >> PWSH); + if (((xpos & PIM) + slw) < PPW) + { + maskpartialbits(xpos, slw, startmask); + UPDRW(addrl,startmask); + if (miFillArcLower(slw)) + { + addrl = addrlb + (xpos >> PWSH); + UPDRW(addrl,startmask); + } + continue; + } + maskbits(xpos, slw, startmask, endmask, nlmiddle); + if (startmask) + { + UPDRW(addrl,startmask); addrl++; + } + n = nlmiddle; + while (n--) { + UPDRW(addrl,~0); addrl++; + } + if (endmask) + { + UPDRW(addrl,endmask); + } + if (!miFillArcLower(slw)) + continue; + addrl = addrlb + (xpos >> PWSH); + if (startmask) + { + UPDRW(addrl,startmask); addrl++; + } + n = nlmiddle; + while (n--) { + UPDRW(addrl,~0); addrl++; + } + if (endmask) + { + UPDRW(addrl,endmask); + } + } +} + +#define FILLSPAN(xl,xr,addr) \ + if (xr >= xl) \ + { \ + width = xr - xl + 1; \ + addrl = addr + (xl >> PWSH); \ + if (((xl & PIM) + width) < PPW) \ + { \ + maskpartialbits(xl, width, startmask); \ + UPDRW(addrl,startmask); \ + } \ + else \ + { \ + maskbits(xl, width, startmask, endmask, nlmiddle); \ + if (startmask) \ + { \ + UPDRW(addrl,startmask); addrl++; \ + } \ + n = nlmiddle; \ + while (n--) { \ + UPDRW(addrl,~0); addrl++; \ + } \ + if (endmask) \ + { \ + UPDRW(addrl,endmask); \ + } \ + } \ + } + +#define FILLSLICESPANS(flip,addr) \ + if (!flip) \ + { \ + FILLSPAN(xl, xr, addr); \ + } \ + else \ + { \ + xc = xorg - x; \ + FILLSPAN(xc, xr, addr); \ + xc += slw - 1; \ + FILLSPAN(xl, xc, addr); \ + } + +static void +v16FillArcSliceSolidCopy +( + DrawablePtr pDraw, + GCPtr pGC, + xArc *arc +) +{ + register int *addrl; + register int n; + int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; + register int x, y, e; + miFillArcRec info; + miArcSliceRec slice; + int xl, xr, xc; + int *addrlt, *addrlb; + int nlwidth; + int width; + int startmask, endmask, nlmiddle; + + if (pDraw->type == DRAWABLE_WINDOW) + { + addrlt = (int *) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr); + nlwidth = (int) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2; + } + else + { + addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr); + nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2; + } + + miFillArcSetup(arc, &info); + miFillArcSliceSetup(arc, &slice, pGC); + MIFILLARCSETUP(); + xorg += pDraw->x; + yorg += pDraw->y; + addrlb = addrlt; + addrlt += nlwidth * (yorg - y); + addrlb += nlwidth * (yorg + y + dy); + slice.edge1.x += pDraw->x; + slice.edge2.x += pDraw->x; + while (y > 0) + { + addrlt += nlwidth; + addrlb -= nlwidth; + MIFILLARCSTEP(slw); + MIARCSLICESTEP(slice.edge1); + MIARCSLICESTEP(slice.edge2); + if (miFillSliceUpper(slice)) + { + MIARCSLICEUPPER(xl, xr, slice, slw); + FILLSLICESPANS(slice.flip_top, addrlt); + } + if (miFillSliceLower(slice)) + { + MIARCSLICELOWER(xl, xr, slice, slw); + FILLSLICESPANS(slice.flip_bot, addrlb); + } + } +} + +static void +xf4bppPolyFillArcSolid +( + register DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +) +{ + register xArc *arc; + register int i; + BoxRec box; + RegionPtr cclip; +#if 0 + mfbPrivGC *priv; + int rop; + + priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); + rop = priv->rop; + if ((rop == RROP_NOP) || !(pGC->planemask & 1)) +#else + if ( !(pGC->planemask & 0x0F)) +#endif + return; + cclip = pGC->pCompositeClip; + for (arc = parcs, i = narcs; --i >= 0; arc++) + { + if (miFillArcEmpty(arc)) + continue; + if (miCanFillArc(arc)) + { + box.x1 = arc->x + pDraw->x; + box.y1 = arc->y + pDraw->y; + box.x2 = box.x1 + (int)arc->width + 1; + box.y2 = box.y1 + (int)arc->height + 1; + if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) + { + if ((arc->angle2 >= FULLCIRCLE) || + (arc->angle2 <= -FULLCIRCLE)) + DO_WM3(pGC,v16FillEllipseSolid(pDraw, arc)) + else + DO_WM3(pGC,v16FillArcSliceSolidCopy(pDraw, pGC, arc)) + continue; + } + } + miPolyFillArc(pDraw, pGC, 1, arc); + } +} + +void +xf4bppPolyFillArc(pDraw, pGC, narcs, parcs) + register DrawablePtr pDraw; + GCPtr pGC; + int narcs; + xArc *parcs; +{ + if ( !xf86Screens[pDraw->pScreen->myNum]->vtSema || (pGC->fillStyle != FillSolid) ) { + miPolyFillArc(pDraw, pGC, narcs, parcs); + } else { + xf4bppPolyFillArcSolid(pDraw, pGC, narcs, parcs); + } +} diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbhrzvert.c b/xorg-server/hw/xfree86/xf4bpp/mfbhrzvert.c new file mode 100644 index 000000000..3444f48f5 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbhrzvert.c @@ -0,0 +1,135 @@ +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "wm3.h" + +/* horizontal solid line + abs(len) > 1 +*/ + +void +xf4bppHorzS(addrl, nlwidth, x1, y1, len) +register PixelType *addrl; /* pointer to base of bitmap */ +register int nlwidth; /* width in longwords of bitmap */ +int x1; /* initial point */ +int y1; +int len; /* length of line */ +{ + register PixelType startmask; + register PixelType endmask; + register int nlmiddle; + + + /* force the line to go left to right + but don't draw the last point + */ + if (len < 0) + { + x1 += len; + x1 += 1; + len = -len; + } + + addrl = mfbScanline(addrl, x1, y1, nlwidth); + + /* all bits inside same longword */ + if ( ((x1 & PIM) + len) < PPW) + { + maskpartialbits(x1, len, startmask); + UPDRW(addrl,startmask); + } + else + { + maskbits(x1, len, startmask, endmask, nlmiddle); + if (startmask) { + UPDRW(addrl,startmask); addrl++; + } + Duff (nlmiddle, UPDRW(addrl,~0); addrl++); + if (endmask) { + UPDRW(addrl,endmask); + } + } +} + +/* vertical solid line + this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates + better code. sigh. we know that len will never be 0 or 1, so + it's OK to use it. +*/ + +void +xf4bppVertS(addrl, nlwidth, x1, y1, len) +register PixelType *addrl; /* pointer to base of bitmap */ +register int nlwidth; /* width in longwords of bitmap */ +int x1, y1; /* initial point */ +register int len; /* length of line */ +{ + register PixelType bitmask; + + addrl = mfbScanline(addrl, x1, y1, nlwidth); + + if (len < 0) + { + nlwidth = -nlwidth; + len = -len; + } + + bitmask = mfbGetmask(x1 & PIM); + Duff(len, UPDRW(addrl,bitmask); addrl += nlwidth); +} diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbimggblt.c b/xorg-server/hw/xfree86/xf4bpp/mfbimggblt.c new file mode 100644 index 000000000..4f9561161 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbimggblt.c @@ -0,0 +1,505 @@ +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "dixfontstr.h" +#include "ppcGCstr.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +/* + we should eventually special-case fixed-width fonts for ImageText. + + this works for fonts with glyphs <= 32 bits wide. + + the clipping calculations are done for worst-case fonts. +we make no assumptions about the heights, widths, or bearings +of the glyphs. if we knew that the glyphs are all the same height, +we could clip the tops and bottoms per clipping box, rather +than per character per clipping box. if we knew that the glyphs' +left and right bearings were wlle-behaved, we could clip a single +character at the start, output until the last unclipped +character, and then clip the last one. this is all straightforward +to determine based on max-bounds and min-bounds from the font. + there is some inefficiency introduced in the per-character +clipping to make what's going on clearer. + + (it is possible, for example, for a font to be defined in which the +next-to-last character in a font would be clipped out, but the last +one wouldn't. the code below deals with this.) + + Image text looks at the bits in the glyph and the fg and bg in the +GC. it paints a rectangle, as defined in the protocol dcoument, +and the paints the characters. + + to avoid source proliferation, this file is compiled +three times: + MFBIMAGEGLYPHBLT OPEQ + mfbImageGlyphBltWhite |= + mfbImageGlyphBltBlack &=~ + + the register allocations for startmask and endmask may not +be the right thing. are there two other deserving candidates? +xoff, pdst, pglyph, and tmpSrc seem like the right things, though. +*/ + +/* Forward declarations -- GJA */ +static void doImageGlyphBlt( + DrawablePtr, + GC *, + int, + int, + unsigned int, + CharInfoPtr *, + unsigned char *, + ExtentInfoRec * +); + +void +xf4bppImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) + DrawablePtr pDrawable; + GC *pGC; + int x, y; + unsigned int nglyph; + CharInfoPtr *ppci; /* array of character info */ + pointer pglyphBase; /* start of array of glyphs */ +{ + ExtentInfoRec info; /* used by QueryGlyphExtents() */ + xRectangle backrect;/* backing rectangle to paint. + in the general case, NOT necessarily + the same as the string's bounding box + */ + /* GJA -- I agree, this ALL should be moved to GC validation. */ + if ( (pDrawable->type != DRAWABLE_WINDOW) || (pGC->alu != GXcopy) || + !xf86Screens[pDrawable->pScreen->myNum]->vtSema || + ((pGC->font) && + (FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 || + FONTMINBOUNDS(pGC->font,characterWidth) < 0)) ) { + miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + } else { + ppcPrivGC *pPrivGC; + int oldfillStyle, oldfg, oldalu; + + if (!(pGC->planemask & 0x0F)) + return; + + QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info); + + backrect.x = x; + backrect.y = y - FONTASCENT(pGC->font); + backrect.width = info.overallWidth; + backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + + + pPrivGC = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); + oldfillStyle = pPrivGC->colorRrop.fillStyle; /* GJA */ + oldfg = pPrivGC->colorRrop.fgPixel; /* GJA */ + oldalu = pPrivGC->colorRrop.alu; /* GJA */ + + pPrivGC->colorRrop.fillStyle = FillSolid; /* GJA */ + pPrivGC->colorRrop.fgPixel = pGC->bgPixel; /* GJA */ + pGC->fgPixel = pGC->bgPixel; + pPrivGC->colorRrop.alu = GXcopy; /* GJA */ + pGC->alu = GXcopy; + + /* Required fields: + * colorRrop.alu, colorRrop.planemask, colorRrop.fgPixel + */ + xf4bppPolyFillRect(pDrawable, pGC, 1, &backrect); + + pPrivGC->colorRrop.fgPixel = oldfg; /* GJA */ + pGC->fgPixel = oldfg; + + /* the faint-hearted can open their eyes now */ + + DO_WM3(pGC,doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, + pglyphBase,&info)) + + pPrivGC->colorRrop.fillStyle = oldfillStyle; /* GJA */ + pPrivGC->colorRrop.alu = oldalu; /* GJA */ + pGC->alu = oldalu; + } + +} + +static void +doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,infop) + DrawablePtr pDrawable; + GC *pGC; + int x, y; + unsigned int nglyph; + CharInfoPtr *ppci; /* array of character info */ + unsigned char *pglyphBase; /* start of array of glyphs */ + ExtentInfoRec* infop; /* used by QueryGlyphExtents() */ +{ + BoxRec bbox; /* string's bounding box */ + + CharInfoPtr pci; + int xorg, yorg; /* origin of drawable in bitmap */ + int widthDst; /* width of dst in longwords */ + + /* these keep track of the character origin */ + CARD32 *pdstBase; + /* points to longword with character origin */ + int xchar; /* xorigin of char (mod 32) */ + + /* these are used for placing the glyph */ + register int xoff; /* x offset of left edge of glyph (mod 32) */ + register CARD32 *pdst; + /* pointer to current longword in dst */ + + int w; /* width of glyph in bits */ + int h; /* height of glyph */ + int widthGlyph; /* width of glyph, in bytes */ + register unsigned char *pglyph; + /* pointer to current row of glyph */ + + /* used for putting down glyph */ + register unsigned int tmpSrc; + /* for getting bits from glyph */ + register int startmask; + register int endmask; + + register int nFirst;/* bits of glyph in current longword */ + + xorg = pDrawable->x; + yorg = pDrawable->y; + if (pDrawable->type == DRAWABLE_WINDOW) + { + pdstBase = (CARD32 *) + (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate.ptr); + widthDst = (int) + (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind) >> 2; + } + else + { + pdstBase = (CARD32 *)(((PixmapPtr)pDrawable)->devPrivate.ptr); + widthDst = (int)(((PixmapPtr)pDrawable)->devKind) >> 2; + } + + x += xorg; + y += yorg; + bbox.x1 = x + infop->overallLeft; + bbox.x2 = x + infop->overallRight; + bbox.y1 = y - infop->overallAscent; + bbox.y2 = y + infop->overallDescent; + + /* UNCLEAN CODE + we know the mfbPolyFillRect uses only three fields in + devPrivate[mfbGetGCPrivateIndex()].ptr, two of which (the rotated + tile/stipple and the ropFillArea) are + irrelevant for solid filling, so we just poke the FillArea + field. the GC is now in an inconsistent state, but we'll fix + it as soon as PolyFillRect returns. fortunately, the server + is single threaded. + + NOTE: + if you are not using the standard mfbFillRectangle code, you + need to poke any fields in the GC the rectangle stuff need + (probably alu, fgPixel, and fillStyle) and in devPrivate[mfbGetGCPrivateIndex()].ptr + (probably rop or ropFillArea.) You could just call ValidateGC, + but that is usually not a cheap thing to do. + */ + + switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) + { + case rgnOUT: + break; + case rgnIN: + pdstBase = pdstBase + (widthDst * y) + (x >> PWSH); + xchar = x & PIM; + + while(nglyph--) + { + pci = *ppci; + pglyph = FONTGLYPHBITS(pglyphBase, pci); + w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + h = pci->metrics.ascent + pci->metrics.descent; + widthGlyph = GLYPHWIDTHBYTESPADDED(pci); + + /* start at top scanline of glyph */ + pdst = pdstBase - (pci->metrics.ascent * widthDst); + + /* find correct word in scanline and x offset within it + for left edge of glyph + */ + xoff = xchar + pci->metrics.leftSideBearing; + if (xoff > PIM) + { + pdst++; + xoff &= PIM; + } + else if (xoff < 0) + { + xoff += PPW; + pdst--; + } + + if ((xoff + w) <= PPW) + { + /* glyph all in one longword */ + maskpartialbits(xoff, w, startmask); + + while (h--) + { + getleftbits(pglyph, w, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } + else + { + /* glyph crosses longword boundary */ + maskPPWbits(xoff, w, startmask, endmask); + nFirst = PPW - xoff; + while (h--) + { + getleftbits(pglyph, w, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + UPDRW(&(pdst[1]),(SCRLEFT(tmpSrc, nFirst) & endmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } /* glyph crosses longwords boundary */ + + /* update character origin */ + x += pci->metrics.characterWidth; + xchar += pci->metrics.characterWidth; + if (xchar > PLST) + { + xchar -= PPW; + pdstBase++; + } + else if (xchar < 0) + { + xchar += PPW; + pdstBase--; + } + ppci++; + } /* while nglyph-- */ + break; + case rgnPART: + { + TEXTPOS *ppos; + int nbox; + BoxPtr pbox; + RegionPtr cclip; + int xpos; /* x position of char origin */ + unsigned int i; + BoxRec clip; + int leftEdge, rightEdge; + int topEdge, bottomEdge; + int glyphRow; /* first row of glyph not wholly + clipped out */ + int glyphCol; /* leftmost visible column of glyph */ +#if GETLEFTBITS_ALIGNMENT > 1 + int getWidth; /* bits to get from glyph */ +#endif + + if(!(ppos = (TEXTPOS *)xalloc(nglyph * sizeof(TEXTPOS)))) + return; + + pdstBase = pdstBase + (widthDst * y) + (x >> PWSH); + xpos = x; + xchar = xpos & PIM; + + for (i=0; i<nglyph; i++) + { + pci = ppci[i]; + + ppos[i].xpos = xpos; + ppos[i].xchar = xchar; + ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing; + ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing; + ppos[i].topEdge = y - pci->metrics.ascent; + ppos[i].bottomEdge = y + pci->metrics.descent; + ppos[i].pdstBase = pdstBase; + ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci); + + xpos += pci->metrics.characterWidth; + xchar += pci->metrics.characterWidth; + if (xchar > PLST) + { + xchar &= PIM; + pdstBase++; + } + else if (xchar < 0) + { + xchar += PPW; + pdstBase--; + } + } + + cclip = pGC->pCompositeClip; + pbox = REGION_RECTS(cclip); + nbox = REGION_NUM_RECTS(cclip); + + /* HACK ALERT + since we continue out of the loop below so often, it + is easier to increment pbox at the top than at the end. + don't try this at home. + */ + pbox--; + while(nbox--) + { + pbox++; + clip.x1 = max(bbox.x1, pbox->x1); + clip.y1 = max(bbox.y1, pbox->y1); + clip.x2 = min(bbox.x2, pbox->x2); + clip.y2 = min(bbox.y2, pbox->y2); + if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1)) + continue; + + for(i=0; i<nglyph; i++) + { + pci = ppci[i]; + xchar = ppos[i].xchar; + + /* clip the left and right edges */ + if (ppos[i].leftEdge < clip.x1) + leftEdge = clip.x1; + else + leftEdge = ppos[i].leftEdge; + + if (ppos[i].rightEdge > clip.x2) + rightEdge = clip.x2; + else + rightEdge = ppos[i].rightEdge; + + w = rightEdge - leftEdge; + if (w <= 0) + continue; + + /* clip the top and bottom edges */ + if (ppos[i].topEdge < clip.y1) + topEdge = clip.y1; + else + topEdge = ppos[i].topEdge; + + if (ppos[i].bottomEdge > clip.y2) + bottomEdge = clip.y2; + else + bottomEdge = ppos[i].bottomEdge; + + h = bottomEdge - topEdge; + if (h <= 0) + continue; + + glyphRow = (topEdge - y) + pci->metrics.ascent; + widthGlyph = ppos[i].widthGlyph; + pglyph = FONTGLYPHBITS(pglyphBase, pci); + pglyph += (glyphRow * widthGlyph); + + pdst = ppos[i].pdstBase - ((y-topEdge) * widthDst); + + glyphCol = (leftEdge - ppos[i].xpos) - + (pci->metrics.leftSideBearing); +#if GETLEFTBITS_ALIGNMENT > 1 + getWidth = w + glyphCol; +#endif + xoff = xchar + (leftEdge - ppos[i].xpos); + if (xoff > PLST) + { + xoff &= PIM; + pdst++; + } + else if (xoff < 0) + { + xoff += PPW; + pdst--; + } + + if ((xoff + w) <= PPW) + { + maskpartialbits(xoff, w, startmask); + while (h--) + { + getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } + else + { + maskPPWbits(xoff, w, startmask, endmask); + nFirst = PPW - xoff; + while (h--) + { + getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc); + UPDRW(pdst,(SCRRIGHT(tmpSrc, xoff) & startmask)); + UPDRW(&(pdst[1]),(SCRLEFT(tmpSrc, nFirst) & endmask)); + pglyph += widthGlyph; + pdst += widthDst; + } + } + } /* for each glyph */ + } /* while nbox-- */ + xfree(ppos); + break; + } + default: + break; + } +} + diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbline.c b/xorg-server/hw/xfree86/xf4bpp/mfbline.c new file mode 100644 index 000000000..d2d4e0b0e --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbline.c @@ -0,0 +1,976 @@ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +/* GJA -- modified this file for vga16 */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "miline.h" +#include "vgaVideo.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +/* single-pixel lines on a color frame buffer + + NON-SLOPED LINES + horizontal lines are always drawn left to right; we have to +move the endpoints right by one after they're swapped. + horizontal lines will be confined to a single band of a +region. the code finds that band (giving up if the lower +bound of the band is above the line we're drawing); then it +finds the first box in that band that contains part of the +line. we clip the line to subsequent boxes in that band. + vertical lines are always drawn top to bottom (y-increasing.) +this requires adding one to the y-coordinate of each endpoint +after swapping. + + SLOPED LINES + when clipping a sloped line, we bring the second point inside +the clipping box, rather than one beyond it, and then add 1 to +the length of the line before drawing it. this lets us use +the same box for finding the outcodes for both endpoints. since +the equation for clipping the second endpoint to an edge gives us +1 beyond the edge, we then have to move the point towards the +first point by one step on the major axis. + eventually, there will be a diagram here to explain what's going +on. the method uses Cohen-Sutherland outcodes to determine +outsideness, and a method similar to Pike's layers for doing the +actual clipping. + +*/ +#ifdef POLYSEGMENT +static void DoV16SegmentSS( + DrawablePtr, GCPtr, int, xSegment* +); + +void +xf4bppSegmentSS (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + GCPtr pGC; + int nseg; + register xSegment *pSeg; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miPolySegment(pDrawable, pGC, nseg, pSeg); + } else { + DO_WM3(pGC,DoV16SegmentSS (pDrawable, pGC, nseg, pSeg)); + } +} + +#else +static void DoV16LineSS( + DrawablePtr, GCPtr, int, int, DDXPointPtr +); + +void +xf4bppLineSS (pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miZeroLine(pDrawable, pGC, mode, npt, pptInit); + } else { + DO_WM3(pGC,DoV16LineSS (pDrawable, pGC, mode, npt, pptInit)); + } +} +#endif + +static void +#ifdef POLYSEGMENT +DoV16SegmentSS (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + GCPtr pGC; + int nseg; + register xSegment *pSeg; +#else +DoV16LineSS (pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +#endif +{ + int nboxInit; + register int nbox; + BoxPtr pboxInit; + register BoxPtr pbox; +#ifndef POLYSEGMENT + register DDXPointPtr ppt; /* pointer to list of translated points */ +#endif + + unsigned int oc1; /* outcode of point 1 */ + unsigned int oc2; /* outcode of point 2 */ + + PixelType *addrlBase; /* pointer to start of drawable */ +#ifndef POLYSEGMENT + PixelType *addrl; /* address of destination pixmap */ +#endif + int nlwidth; /* width in longwords of destination pixmap */ + int xorg, yorg; /* origin of window */ + + int adx; /* abs values of dx and dy */ + int ady; + int signdx; /* sign of dx and dy */ + int signdy; + int e, e1, e2; /* bresenham error and increments */ + int len; /* length of segment */ + int axis; /* major axis */ + int octant; + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + + /* a bunch of temporaries */ + register int y1, y2; + register int x1, x2; + RegionPtr cclip; +#ifndef POLYSEGMENT + int alu = pGC->alu; /* GJA */ +#endif + + if (!(pGC->planemask & 0x0F)) + return; + + cclip = pGC->pCompositeClip; + pboxInit = REGION_RECTS(cclip); + nboxInit = REGION_NUM_RECTS(cclip); + + nlwidth = BYTES_PER_LINE(pDrawable) >> 2; /* GJA */ + addrlBase = (PixelType *)VIDBASE(pDrawable); /* GJA */ + + xorg = pDrawable->x; + yorg = pDrawable->y; +#ifdef POLYSEGMENT + while (nseg--) +#else + ppt = pptInit; + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; + while(--npt) +#endif + { + nbox = nboxInit; + pbox = pboxInit; + +#ifdef POLYSEGMENT + x1 = pSeg->x1 + xorg; + y1 = pSeg->y1 + yorg; + x2 = pSeg->x2 + xorg; + y2 = pSeg->y2 + yorg; + pSeg++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) + { + xorg = x1; + yorg = y1; + } + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; +#endif + + if (x1 == x2) /* vertical line */ + { + /* make the line go top to bottom of screen, keeping + endpoint semantics + */ + if (y1 > y2) + { + register int tmp; + + tmp = y2; + y2 = y1 + 1; + y1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + y1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) + y2++; +#endif + /* get to first band that might contain part of line */ + while ((nbox) && (pbox->y2 <= y1)) + { + pbox++; + nbox--; + } + + if (nbox) + { + /* stop when lower edge of box is beyond end of line */ + while((nbox) && (y2 >= pbox->y1)) + { + if ((x1 >= pbox->x1) && (x1 < pbox->x2)) + { + int y1t, y2t; + /* this box has part of the line in it */ + y1t = max(y1, pbox->y1); + y2t = min(y2, pbox->y2); + if (y1t != y2t) + { + xf4bppVertS (addrlBase, nlwidth, + x1, y1t, y2t-y1t); + } + } + nbox--; + pbox++; + } + } +#ifndef POLYSEGMENT + y2 = ppt->y + yorg; +#endif + } + else if (y1 == y2) /* horizontal line */ + { + /* force line from left to right, keeping + endpoint semantics + */ + if (x1 > x2) + { + register int tmp; + + tmp = x2; + x2 = x1 + 1; + x1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + x1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) + x2++; +#endif + + /* find the correct band */ + while( (nbox) && (pbox->y2 <= y1)) + { + pbox++; + nbox--; + } + + /* try to draw the line, if we haven't gone beyond it */ + if ((nbox) && (pbox->y1 <= y1)) + { + int tmp; + + /* when we leave this band, we're done */ + tmp = pbox->y1; + while((nbox) && (pbox->y1 == tmp)) + { + int x1t, x2t; + + if (pbox->x2 <= x1) + { + /* skip boxes until one might contain start point */ + nbox--; + pbox++; + continue; + } + + /* stop if left of box is beyond right of line */ + if (pbox->x1 >= x2) + { + nbox = 0; + break; + } + + x1t = max(x1, pbox->x1); + x2t = min(x2, pbox->x2); + if (x1t != x2t) + { + xf4bppHorzS (addrlBase, nlwidth, + x1t, y1, x2t-x1t); + } + nbox--; + pbox++; + } + } +#ifndef POLYSEGMENT + x2 = ppt->x + xorg; +#endif + } + else /* sloped line */ + { + CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, + 1, 1, octant); + + if (adx > ady) + { + axis = X_AXIS; + e1 = ady << 1; + e2 = e1 - (adx << 1); + e = e1 - adx; + } + else + { + axis = Y_AXIS; + e1 = adx << 1; + e2 = e1 - (ady << 1); + e = e1 - ady; + SetYMajorOctant(octant); + } + + FIXUP_ERROR(e, octant, bias); + + /* we have bresenham parameters and two points. + all we have to do now is clip and draw. + */ + + while(nbox--) + { + oc1 = 0; + oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if ((oc1 | oc2) == 0) + { + if (axis == X_AXIS) + len = adx; + else + len = ady; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + len++; +#endif + xf4bppBresS (addrlBase, nlwidth, + signdx, signdy, axis, x1, y1, + e, e1, e2, len); + break; + } + else if (oc1 & oc2) + { + pbox++; + } + else + { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int clipdx, clipdy; + int err; + + if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, + pbox->y2-1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + + if (axis == X_AXIS) + len = abs(new_x2 - new_x1); + else + len = abs(new_y2 - new_y1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) + { + /* unwind bresenham error term to first point */ + if (clip1) + { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + if (axis == X_AXIS) + err = e+((clipdy*e2) + ((clipdx-clipdy)*e1)); + else + err = e+((clipdx*e2) + ((clipdy-clipdx)*e1)); + } + else + err = e; + xf4bppBresS (addrlBase, nlwidth, + signdx, signdy, axis, new_x1, new_y1, + err, e1, e2, len); + } + pbox++; + } + } /* while (nbox--) */ + } /* sloped line */ + } /* while (nline--) */ + +#ifndef POLYSEGMENT + + /* paint the last point if the end style isn't CapNotLast. + (Assume that a projecting, butt, or round cap that is one + pixel wide is the same as the single pixel of the endpoint.) + */ + + if ((pGC->capStyle != CapNotLast) && + ((ppt->x + xorg != pptInit->x + pDrawable->x) || + (ppt->y + yorg != pptInit->y + pDrawable->y) || + (ppt == pptInit + 1))) + { + PixelType _mask; + + if (alu == RROP_BLACK) + _mask = mfbGetrmask(x2 & PIM); + else + _mask = mfbGetmask(x2 & PIM); + + nbox = nboxInit; + pbox = pboxInit; + while (nbox--) + { + if ((x2 >= pbox->x1) && + (y2 >= pbox->y1) && + (x2 < pbox->x2) && + (y2 < pbox->y2)) + { + addrl = mfbScanline(addrlBase, x2, y2, nlwidth); + UPDRW(addrl,_mask); + break; + } + else + pbox++; + } + } +#endif +} + +/* + * Draw dashed 1-pixel lines. + */ + +#ifdef POLYSEGMENT +static void DoV16SegmentSD( + DrawablePtr, GCPtr, int, xSegment* +); + +void +xf4bppSegmentSD (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + GCPtr pGC; + int nseg; + register xSegment *pSeg; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miPolySegment(pDrawable, pGC, nseg, pSeg); + } else { + DO_WM3(pGC,DoV16SegmentSD (pDrawable, pGC, nseg, pSeg)); + } +} + +#else +static void DoV16LineSD( + DrawablePtr, GCPtr, int, int, DDXPointPtr +); + +void +xf4bppLineSD (pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +{ + if ( ! xf86Screens[pDrawable->pScreen->myNum]->vtSema ) { + miZeroDashLine(pDrawable, pGC, mode, npt, pptInit); + } else { + DO_WM3(pGC,DoV16LineSD (pDrawable, pGC, mode, npt, pptInit)); + } +} +#endif + +static void +#ifdef POLYSEGMENT +DoV16SegmentSD (pDrawable, pGC, nseg, pSeg) + DrawablePtr pDrawable; + register GCPtr pGC; + int nseg; + register xSegment *pSeg; +#else +DoV16LineSD( pDrawable, pGC, mode, npt, pptInit) + DrawablePtr pDrawable; + register GCPtr pGC; + int mode; /* Origin or Previous */ + int npt; /* number of points */ + DDXPointPtr pptInit; +#endif +{ + int nboxInit; + register int nbox; + BoxPtr pboxInit; + register BoxPtr pbox; +#ifndef POLYSEGMENT + register DDXPointPtr ppt; /* pointer to list of translated points */ +#endif + + register unsigned int oc1; /* outcode of point 1 */ + register unsigned int oc2; /* outcode of point 2 */ + + PixelType *addrl; /* address of destination pixmap */ + int nlwidth; /* width in longwords of destination pixmap */ + int xorg, yorg; /* origin of window */ + + int adx; /* abs values of dx and dy */ + int ady; + int signdx; /* sign of dx and dy */ + int signdy; + int e, e1, e2; /* bresenham error and increments */ + int len; /* length of segment */ + int axis; /* major axis */ + int octant; + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + int x1, x2, y1, y2; + RegionPtr cclip; + int fgink, bgink; /* GJA */ + unsigned char *pDash; + int dashOffset; + int numInDashList; + int dashIndex; + int isDoubleDash; + int dashIndexTmp, dashOffsetTmp; + int unclippedlen; + + if (!(pGC->planemask & 0x0F)) + return; + + cclip = pGC->pCompositeClip; + fgink = bgink = pGC->fgPixel; /* GJA */ + pboxInit = REGION_RECTS(cclip); + nboxInit = REGION_NUM_RECTS(cclip); + + nlwidth = BYTES_PER_LINE(pDrawable) >> 2; /* GJA */ + addrl = (PixelType *)VIDBASE(pDrawable); /* GJA */ + + /* compute initial dash values */ + + pDash = (unsigned char *) pGC->dash; + numInDashList = pGC->numInDashList; + isDoubleDash = (pGC->lineStyle == LineDoubleDash); + dashIndex = 0; + dashOffset = 0; + miStepDash ((int)pGC->dashOffset, &dashIndex, pDash, + numInDashList, &dashOffset); + + if (isDoubleDash) + bgink = pGC->bgPixel; /* GJA */ + + xorg = pDrawable->x; + yorg = pDrawable->y; +#ifdef POLYSEGMENT + while (nseg--) +#else + ppt = pptInit; + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; + while(--npt) +#endif + { + nbox = nboxInit; + pbox = pboxInit; + +#ifdef POLYSEGMENT + x1 = pSeg->x1 + xorg; + y1 = pSeg->y1 + yorg; + x2 = pSeg->x2 + xorg; + y2 = pSeg->y2 + yorg; + pSeg++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) + { + xorg = x1; + yorg = y1; + } + x2 = ppt->x + xorg; + y2 = ppt->y + yorg; +#endif + + CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant); + + if (adx > ady) + { + axis = X_AXIS; + e1 = ady << 1; + e2 = e1 - (adx << 1); + e = e1 - adx; + unclippedlen = adx; + } + else + { + axis = Y_AXIS; + e1 = adx << 1; + e2 = e1 - (ady << 1); + e = e1 - ady; + unclippedlen = ady; + SetYMajorOctant(octant); + } + + FIXUP_ERROR(e, octant, bias); + + /* we have bresenham parameters and two points. + all we have to do now is clip and draw. + */ + + while(nbox--) + { + oc1 = 0; + oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if ((oc1 | oc2) == 0) + { +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) + unclippedlen++; + dashIndexTmp = dashIndex; + dashOffsetTmp = dashOffset; + xf4bppBresD (pDrawable, fgink, bgink, + &dashIndexTmp, pDash, numInDashList, + &dashOffsetTmp, isDoubleDash, + addrl, nlwidth, + signdx, signdy, axis, x1, y1, + e, e1, e2, unclippedlen); + break; +#else + xf4bppBresD (pDrawable, fgink, bgink, + &dashIndex, pDash, numInDashList, + &dashOffset, isDoubleDash, + addrl, nlwidth, + signdx, signdy, axis, x1, y1, + e, e1, e2, unclippedlen); + goto dontStep; +#endif + } + else if (oc1 & oc2) + { + pbox++; + } + else /* have to clip */ + { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int clipdx, clipdy; + int err; + + if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, pbox->y2-1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + dashIndexTmp = dashIndex; + dashOffsetTmp = dashOffset; + if (clip1) + { + int dlen; + + if (axis == X_AXIS) + dlen = abs(new_x1 - x1); + else + dlen = abs(new_y1 - y1); + miStepDash (dlen, &dashIndexTmp, pDash, + numInDashList, &dashOffsetTmp); + } + if (axis == X_AXIS) + len = abs(new_x2 - new_x1); + else + len = abs(new_y2 - new_y1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) + { + /* unwind bresenham error term to first point */ + if (clip1) + { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + if (axis == X_AXIS) + err = e+((clipdy*e2) + ((clipdx-clipdy)*e1)); + else + err = e+((clipdx*e2) + ((clipdy-clipdx)*e1)); + } + else + err = e; + xf4bppBresD (pDrawable, fgink, bgink, + &dashIndexTmp, pDash, numInDashList, + &dashOffsetTmp, isDoubleDash, + addrl, nlwidth, + signdx, signdy, axis, new_x1, new_y1, + err, e1, e2, len); + } + pbox++; + } + } /* while (nbox--) */ +#ifndef POLYSEGMENT + /* + * walk the dash list around to the next line + */ + miStepDash (unclippedlen, &dashIndex, pDash, + numInDashList, &dashOffset); +dontStep: ; +#endif + } /* while (nline--) */ + +#ifndef POLYSEGMENT + /* paint the last point if the end style isn't CapNotLast. + (Assume that a projecting, butt, or round cap that is one + pixel wide is the same as the single pixel of the endpoint.) + */ + + if ((pGC->capStyle != CapNotLast) && + ((dashIndex & 1) == 0 || isDoubleDash) && + ((ppt->x + xorg != pptInit->x + pDrawable->x) || + (ppt->y + yorg != pptInit->y + pDrawable->y) || + (ppt == pptInit + 1))) + { + nbox = nboxInit; + pbox = pboxInit; + while (nbox--) + { + if ((x2 >= pbox->x1) && + (y2 >= pbox->y1) && + (x2 < pbox->x2) && + (y2 < pbox->y2)) + { + unsigned long _mask; + + _mask = mfbGetmask(x2 & PIM); + addrl = mfbScanline(addrl, x2, y2, nlwidth); + UPDRW(addrl,_mask); + break; + } + else + pbox++; + } + } +#endif +} + + +#if 0 +#ifndef POLYSEGMENT +/* + the clipping code could be cleaned up some; most of its +mess derives from originally being inline in the line code, +then pulled out to make clipping dashes easier. +*/ + +int +mfbClipLine(pbox, box, + ppt1Orig, ppt1, ppt2, + adx, ady, signdx, signdy, axis, + pclip1, pclip2) +BoxPtr pbox; /* box to clip to */ +BoxRec box; /* box to do calculations with */ +DDXPointPtr ppt1Orig, ppt1, ppt2; +int adx, ady; +int signdx, signdy; +register int axis; +int *pclip1, *pclip2; +{ + DDXPointRec pt1Orig, pt1, pt2; + register int swapped = 0; + int clipDone = 0; + register unsigned int utmp; + register int oc1, oc2; + int clip1, clip2; + + pt1Orig = *ppt1Orig; + pt1 = *ppt1; + pt2 = *ppt2; + clip1 = 0; + clip2 = 0; + + do + { + oc1 = 0; + oc2 = 0; + OUTCODES(oc1, pt1.x, pt1.y, pbox); + OUTCODES(oc2, pt2.x, pt2.y, pbox); + + if (oc1 & oc2) + clipDone = -1; + else if ((oc1 | oc2) == 0) + { + clipDone = 1; + if (swapped) + { + SWAPPT(pt1, pt2); + SWAPINT(oc1, oc2); + SWAPINT(clip1, clip2); + } + } + else /* have to clip */ + { + /* only clip one point at a time */ + if (!oc1) + { + SWAPPT(pt1, pt2); + SWAPINT(oc1, oc2); + SWAPINT(clip1, clip2); + swapped = !swapped; + } + + clip1 |= oc1; + if (oc1 & OUT_LEFT) + { + pt1.x = box.x1; + utmp = abs(box.x1 - pt1Orig.x); + utmp *= ady; + if(axis==X_AXIS) + { + pt1.y = pt1Orig.y + SignTimes(signdy, round(utmp, adx)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += ady; + else + utmp -= ady; + pt1.y = pt1Orig.y + SignTimes(signdy, ceiling(utmp, 2*adx)); + if (swapped) + pt1.y -= signdy; + } + } + else if (oc1 & OUT_ABOVE) + { + pt1.y = box.y1; + utmp = abs(box.y1 - pt1Orig.y); + utmp *= adx; + if (axis == Y_AXIS) + { + pt1.x = pt1Orig.x + SignTimes(signdx, round(utmp, ady)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += adx; + else + utmp -= adx; + pt1.x = pt1Orig.x + SignTimes(signdx, ceiling(utmp, 2*ady)); + if (swapped) + pt1.x -= signdx; + } + } + else if (oc1 & OUT_RIGHT) + { + pt1.x = box.x2; + utmp = abs(pt1Orig.x - box.x2); + utmp *= ady; + if (axis == X_AXIS) + { + pt1.y = pt1Orig.y + SignTimes(signdy, round(utmp, adx)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += ady; + else + utmp -= ady; + pt1.y = pt1Orig.y + SignTimes(signdy, ceiling(utmp, 2*adx)); + if (swapped) + pt1.y -= signdy; + } + } + else if (oc1 & OUT_BELOW) + { + pt1.y = box.y2; + utmp = abs(pt1Orig.y - box.y2); + utmp *= adx; + if (axis == Y_AXIS) + { + pt1.x = pt1Orig.x + SignTimes(signdx, round(utmp, ady)); + } + else + { + utmp <<= 1; + if (swapped) + utmp += adx; + else + utmp -= adx; + pt1.x = pt1Orig.x + SignTimes(signdx, ceiling(utmp, 2*ady)); + if (swapped) + pt1.x -= signdx; + } + } + } /* else have to clip */ + } while(!clipDone); + *ppt1 = pt1; + *ppt2 = pt2; + *pclip1 = clip1; + *pclip2 = clip2; + + return clipDone; +} +#endif +#endif diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbseg.c b/xorg-server/hw/xfree86/xf4bpp/mfbseg.c new file mode 100644 index 000000000..3af37d817 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbseg.c @@ -0,0 +1,2 @@ +#define POLYSEGMENT +#include "./mfbline.c" diff --git a/xorg-server/hw/xfree86/xf4bpp/mfbzerarc.c b/xorg-server/hw/xfree86/xf4bpp/mfbzerarc.c new file mode 100644 index 000000000..61fc7b184 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/mfbzerarc.c @@ -0,0 +1,267 @@ +/************************************************************ + +Copyright (c) 1989 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + +********************************************************/ +/* GJA -- Took mfb code and modified it. */ + +/* Derived from: + * "Algorithm for drawing ellipses or hyperbolae with a digital plotter" + * by M. L. V. Pitteway + * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289 + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "mizerarc.h" +#include "wm3.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +/* + * Note, LEFTMOST must be the bit leftmost in the actual screen + * representation. This depends on both BITMAP_BIT_ORDER and + * IMAGE_BYTE_ORDER + * DHD 10/92 + */ + +#if (BITMAP_BIT_ORDER == MSBFirst) +#if (IMAGE_BYTE_ORDER == MSBFirst) +#define LEFTMOST ((unsigned int) 0x80000000) +#else +#define LEFTMOST ((unsigned int) 0x80) +#endif +#else +#if (IMAGE_BYTE_ORDER == LSBFirst) +#define LEFTMOST ((unsigned int) 1) +#else +#define LEFTMOST ((unsigned int) 0x1000000) +#endif +#endif + +#define PixelateWhite(addr,off) \ +{ \ + register int *tmpaddr = &((addr)[(off)>>PWSH]); \ + UPDRW(tmpaddr,SCRRIGHT (LEFTMOST, ((off) & PIM))); \ +} +#define PixelateBlack(addr,off) \ +{ \ + register int *tmpaddr = &((addr)[(off)>>PWSH]); \ + UPDRW(tmpaddr,~(SCRRIGHT (LEFTMOST, ((off) & PIM)))); \ +} + +#define Pixelate(base,off) \ +{ \ + paddr = base + ((off)>>PWSH); \ + pmask = SCRRIGHT(LEFTMOST, (off) & PIM); \ + UPDRW(paddr,(pixel & pmask)); \ +} + +#define DoPix(bit,base,off) if (msk & bit) Pixelate(base,off); + +static void +v16ZeroArcSS +( + DrawablePtr pDraw, + GCPtr pGC, + xArc *arc +) +{ + miZeroArcRec info; + Bool do360; + register int x, y, a, b, d, msk; + register int k1, k3, dx, dy; + int *addrl; + int *yorgl, *yorgol; + unsigned long pixel; + int nlwidth, yoffset, dyoffset; + int pmask; + register int *paddr; + + if (((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()))->rop == + RROP_BLACK) + pixel = 0; + else + pixel = ~0UL; + + if (pDraw->type == DRAWABLE_WINDOW) + { + addrl = (int *) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr); + nlwidth = (int) + (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2; + } + else + { + addrl = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr); + nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2; + } + + do360 = miZeroArcSetup(arc, &info, TRUE); + yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth); + yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth); + info.xorg += pDraw->x; + info.xorgo += pDraw->x; + MIARCSETUP(); + yoffset = y ? nlwidth : 0; + dyoffset = 0; + msk = info.initialMask; + if (!(arc->width & 1)) + { + DoPix(2, yorgl, info.xorgo); + DoPix(8, yorgol, info.xorgo); + } + if (!info.end.x || !info.end.y) + { + msk = info.end.mask; + info.end = info.altend; + } + if (do360 && (arc->width == arc->height) && !(arc->width & 1)) + { + int xoffset = nlwidth; + int *yorghl = yorgl + (info.h * nlwidth); + int xorghp = info.xorg + info.h; + int xorghn = info.xorg - info.h; + + while (1) + { + PixelateWhite(yorgl + yoffset, info.xorg + x); + PixelateWhite(yorgl + yoffset, info.xorg - x); + PixelateWhite(yorgol- yoffset, info.xorg - x); + PixelateWhite(yorgol - yoffset, info.xorg + x); + if (a < 0) + break; + PixelateWhite(yorghl - xoffset, xorghp - y); + PixelateWhite(yorghl - xoffset, xorghn + y); + PixelateWhite(yorghl + xoffset, xorghn + y); + PixelateWhite(yorghl + xoffset, xorghp - y); + xoffset += nlwidth; + MIARCCIRCLESTEP(yoffset += nlwidth;); + } + x = info.w; + yoffset = info.h * nlwidth; + } + else if (do360) + { + while (y < info.h || x < info.w) + { + MIARCOCTANTSHIFT(dyoffset = nlwidth;); + Pixelate(yorgl + yoffset, info.xorg + x); + Pixelate(yorgl + yoffset, info.xorgo - x); + Pixelate(yorgol - yoffset, info.xorgo - x); + Pixelate(yorgol - yoffset, info.xorg + x); + MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;); + } + } + else + { + while (y < info.h || x < info.w) + { + MIARCOCTANTSHIFT(dyoffset = nlwidth;); + if ((x == info.start.x) || (y == info.start.y)) + { + msk = info.start.mask; + info.start = info.altstart; + } + DoPix(1, yorgl + yoffset, info.xorg + x); + DoPix(2, yorgl + yoffset, info.xorgo - x); + DoPix(4, yorgol - yoffset, info.xorgo - x); + DoPix(8, yorgol - yoffset, info.xorg + x); + if ((x == info.end.x) || (y == info.end.y)) + { + msk = info.end.mask; + info.end = info.altend; + } + MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;); + } + } + if ((x == info.start.x) || (y == info.start.y)) + msk = info.start.mask; + DoPix(1, yorgl + yoffset, info.xorg + x); + DoPix(4, yorgol - yoffset, info.xorgo - x); + if (arc->height & 1) + { + DoPix(2, yorgl + yoffset, info.xorgo - x); + DoPix(8, yorgol - yoffset, info.xorg + x); + } +} + +static void +xf4bppZeroPolyArcSS +( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +) +{ + register xArc *arc; + register int i; + BoxRec box; + RegionPtr cclip; + + if (!pGC->planemask & 0x0F) + return; + cclip = pGC->pCompositeClip; + for (arc = parcs, i = narcs; --i >= 0; arc++) + { + if (miCanZeroArc(arc)) + { + box.x1 = arc->x + pDraw->x; + box.y1 = arc->y + pDraw->y; + box.x2 = box.x1 + (int)arc->width + 1; + box.y2 = box.y1 + (int)arc->height + 1; + if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) + v16ZeroArcSS(pDraw, pGC, arc); + else + miZeroPolyArc(pDraw, pGC, 1, arc); + } + else + miPolyArc(pDraw, pGC, 1, arc); + } +} + +void +xf4bppZeroPolyArc(pDraw, pGC, narcs, parcs) + DrawablePtr pDraw; + GCPtr pGC; + int narcs; + xArc *parcs; +{ + if ( !xf86Screens[pDraw->pScreen->myNum]->vtSema ) { + miZeroPolyArc(pDraw, pGC, narcs, parcs); + } else { + DO_WM3(pGC,xf4bppZeroPolyArcSS(pDraw, pGC, narcs, parcs)); + } +} diff --git a/xorg-server/hw/xfree86/xf4bpp/offscreen.c b/xorg-server/hw/xfree86/xf4bpp/offscreen.c new file mode 100644 index 000000000..3160e7ef8 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/offscreen.c @@ -0,0 +1,342 @@ +/* + * Copyright 1993 Gerrit Jan Akkerman + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of Gerrit Jan Akkerman not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * GERRIT JAN AKKERMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL GERRIT JAN AKKERMAN BE LIABLE FOR ANY SPECIAL, INDIRECT + * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * +*/ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "vgaVideo.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "windowstr.h" + +#define saved_screen(pWin) \ + ((unsigned char *)(((PixmapPtr)((pWin)->drawable.pScreen->devPrivate))->devPrivate.ptr)) + +#define SAVEDSCREEN(pWin, x, y) \ + (*(saved_screen(pWin) + (y) * (BYTES_PER_LINE(pWin)) + (x))) + +#define DO_ROP(src,dst,alu,planes) \ + ((dst) = do_rop((src),(dst),(alu),(planes))) + +/* NOTE: + * The following to functions don't do anything. They're just there to + * provide a stable interface to the rest of the system. + */ + +static int +do_rop +( + int src, + int dst, + int alu, + const unsigned long planes +) +{ + int _dst; /* New dst */ + + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + _dst = 0; break ; + case GXinvert: /* 0xa NOT dst */ + _dst = ~dst; break ; + case GXset: /* 0xf 1 */ + _dst = src; break ; + default: + case GXnoop: /* 0x5 dst */ + return dst; + case GXnor: /* 0x8 NOT src AND NOT dst */ + _dst = ~src & ~dst; break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + _dst = ~src & dst; break ; + case GXand: /* 0x1 src AND dst */ + _dst = src & dst; break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + _dst = ~src ^ dst; break ; + case GXxor: /* 0x6 src XOR dst */ + _dst = src ^ dst; break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + _dst = src & ~dst; break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + _dst = ~src | ~dst; break ; + case GXorReverse: /* 0xb src OR NOT dst */ + _dst = src | ~dst; break ; + case GXorInverted: /* 0xd NOT src OR dst */ + _dst = ~src | dst; break ; + case GXor: /* 0x7 src OR dst */ + _dst = src | dst; break ; + case GXcopyInverted: /* 0xc NOT src */ + _dst = ~src; break ; + case GXcopy: /* 0x3 src */ + _dst = src; break ; + } + return (dst & ~planes) | (_dst & planes); +} + +/* File vgaBitBlt.c */ +void +xf4bppOffBitBlt( pWin, alu, writeplanes, x0, y0, x1, y1, w, h ) +WindowPtr pWin; /* GJA */ +const int alu, writeplanes ; +register int x0 ; +int y0 ; +register int x1 ; +int y1 ; +register int w, h ; +{ + int x,y; + + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppOffFillSolid( pWin, VGA_ALLPLANES, alu, writeplanes, + x0, y0, w, h ) ; + case GXnoop: /* 0x5 dst */ + return ; + default: + break ; + } + + if ( (w <= 0) || (h <= 0) ) return; + + for ( y = 0 ; y < h ; y++ ) { + for ( x = 0 ; x < w ; x++ ) { + DO_ROP(SAVEDSCREEN(pWin,x0+x,y0+y),SAVEDSCREEN(pWin,x1+x,y1+y), + alu,writeplanes); + } + } +} + +/* for file vgaImages.c */ + +void +xf4bppOffDrawColorImage( pWin, x, y, w, h, data, RowIncrement, alu, planes ) +WindowPtr pWin; /* GJA */ +int x, y ; +register int w, h ; +unsigned char *data ; +register int RowIncrement ; +const int alu ; +const unsigned long int planes ; +{ + int dx,dy; + + for ( dy = 0 ; dy < h ; dy++ ) { + for ( dx = 0 ; dx < w ; dx++ ) { + DO_ROP( data[dy * RowIncrement + dx], + SAVEDSCREEN(pWin,x+dx,y+dy), alu, planes); + } + } +} + +void +xf4bppOffReadColorImage( pWin, x, y, lx, ly, data, RowIncrement ) +WindowPtr pWin; /* GJA */ +int x, y ; +int lx, ly ; +unsigned char *data ; +int RowIncrement ; +{ + int dx, dy; + + if ( ( lx <= 0 ) || ( ly <= 0 ) ) + return ; + + for ( dy = 0 ; dy < ly ; dy++ ) { + for ( dx = 0 ; dx < lx ; dx++ ) { + data[dy*RowIncrement+dx] = SAVEDSCREEN(pWin,x+dx,y+dy); + } + } +} + +/* For file vgaSolid.c */ + +void xf4bppOffFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ) +WindowPtr pWin; /* GJA */ +unsigned long int color ; +const int alu ; +unsigned long int planes ; +register int x0 ; +register const int y0 ; +register int lx ; +register const int ly ; /* MUST BE > 0 !! */ +{ + int dx, dy; + + if ( ( lx == 0 ) || ( ly == 0 ) ) + return; + + for ( dy = 0 ; dy < ly ; dy++ ) { + for ( dx = 0 ; dx < lx ; dx++ ) { + DO_ROP(color,SAVEDSCREEN(pWin, x0+dx,y0+dy),alu,planes); + } + } +} + +/* For file vgaStipple.c */ + +/* GJA -- modified this to take both Width and Height, and to + * reduce x and y to Width and Height by taking remainders. + */ +static unsigned char +xygetbits +( + register int x, + register int y, + register const unsigned int Width, + register const unsigned int paddedByteWidth, + register const unsigned int Height, + register const unsigned char * const data +) +{ + register unsigned char bits ; + unsigned const char *lineptr, *cptr ; + register int shift ; + register int wrap ; + + x = x % Width; + y = y % Height; + + lineptr = data + (y * paddedByteWidth); + cptr = lineptr + (x >> 3) ; + bits = *cptr ; + if ((shift = x & 7)) + bits = SCRLEFT8( bits, shift ) | + SCRRIGHT8( cptr[1], ( 8 - shift ) ) ; + if ( ( wrap = x + 8 - Width ) > 0 ) { + bits &= SCRLEFT8( 0xFF, wrap ) ; + bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ; + } + + return bits ; +} + +static void +DoMono +( + WindowPtr pWin, /* GJA */ + int w, + int x, + int y, + register const unsigned char *mastersrc, + int h, + unsigned int width, + register unsigned int paddedByteWidth, + unsigned int height, + int xshift, + int yshift, + int alu, + int planes, + int fg +) +{ + int dy, dx, i; + int byte; + + for ( dy = 0 ; dy < h ; dy++ ) { + for ( dx = 0; dx <= w - 8 ; dx += 8 ) { + /* get next byte */ + byte = xygetbits(dx+xshift,dy+yshift,width, + paddedByteWidth, height, mastersrc); + for ( i = 0 ; i < 8 ; i++ ) { + if ( byte & (128 >> i) ) { + DO_ROP(fg,SAVEDSCREEN(pWin,x+dx+i,y+dy), + alu,planes); + } + } + } + /* get last bits */ + byte = xygetbits(dx+xshift,dy+yshift,width, + paddedByteWidth, height, mastersrc); + for ( i = 0 ; i < (w - dx) ; i++ ) { + if ( byte & (128 >> i) ) { + DO_ROP(fg,SAVEDSCREEN(pWin,x+dx+i,y+dy), + alu,planes); + } + } + } +} + +void +xf4bppOffFillStipple( pWin, pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr const pStipple ; +unsigned long int fg ; +const int alu ; +unsigned long int planes ; +int x, y, w, h ; +const int xSrc, ySrc ; +{ + unsigned int width ; + unsigned int height ; + int xshift ; + int yshift ; + + if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) ) + return ; + + /* Figure Bit Offsets & Source Address */ + width = pStipple->drawable.width ; + if ( ( xshift = ( x - xSrc ) ) < 0 ) + xshift = width - ( ( - xshift ) % width ) ; + else + xshift %= width ; + + height = pStipple->drawable.height ; + if ( ( yshift = ( y - ySrc ) ) < 0 ) + yshift = height - ( ( - yshift ) % height ) ; + else + yshift %= height ; + + DoMono( pWin, w, x, y, + (const unsigned char *) pStipple->devPrivate.ptr, + h, + width, + ( ( width + 31 ) & (unsigned)(~31) ) >> 3, + height, + xshift, yshift, + alu, (int)planes, (int)fg ) ; + return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcArea.c b/xorg-server/hw/xfree86/xf4bpp/ppcArea.c new file mode 100644 index 000000000..df7856a35 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcArea.c @@ -0,0 +1,97 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* + * ppc solid area fill + * + * Tom Paquin 8/87 + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "ppcGCstr.h" +#include "ibmTrace.h" + +void +xf4bppFillArea( pWin, nboxes, pBox, pGC ) + register WindowPtr pWin ; + register int nboxes ; + register BoxPtr pBox ; + GCPtr pGC ; +{ +register int x, y, w, h ; +int alu ; +unsigned long int fg, bg, pm ; +int xSrc, ySrc ; +PixmapPtr pPixmap ; +ppcPrivGC *pPrivGC = dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); + +TRACE( ( "xf4bppFillArea(0x%x,%d,0x%x,0x%x)\n", pWin, nboxes, pBox, pGC ) ) ; + +if ( ( alu = pPrivGC->colorRrop.alu ) == GXnoop || !nboxes ) + return ; + +xSrc = pGC->patOrg.x + pWin->drawable.x ; +ySrc = pGC->patOrg.y + pWin->drawable.y ; + +pm = pPrivGC->colorRrop.planemask ; +fg = pPrivGC->colorRrop.fgPixel ; +bg = pPrivGC->colorRrop.bgPixel ; + +nboxes++ ; +switch ( pPrivGC->colorRrop.fillStyle ) { + case FillTiled: + for ( pPixmap = pGC->tile.pixmap ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppTileRect( pWin, pPixmap, alu, pm, + x, y, w, h, xSrc, ySrc ) ; + break ; + case FillOpaqueStippled: + for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppOpaqueStipple( pWin, pPixmap, fg, bg, alu, pm, + x, y, w, h, xSrc, ySrc ) ; + break ; + case FillStippled: + for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppFillStipple( pWin, pPixmap, fg, alu, pm, + x, y, w, h, xSrc, ySrc ) ; + break ; + case FillSolid: + for ( ; --nboxes ; pBox++ ) + if ( ( w = pBox->x2 - ( x = pBox->x1 ) ) + && ( h = pBox->y2 - ( y = pBox->y1 ) ) ) + xf4bppFillSolid( pWin, fg, alu, pm, x, y, w, h ) ; + break ; +} + +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcCReduce.c b/xorg-server/hw/xfree86/xf4bpp/ppcCReduce.c new file mode 100644 index 000000000..c567e6fd1 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcCReduce.c @@ -0,0 +1,237 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "ppcGCstr.h" + +/* xf4bppGetReducedColorRrop( pGC, drawableDepth, returnLoc ) + * An attempt to do "strength reduction" on color raster-ops + * P. Shupak 1/88 + */ + +static void +ppcReduceGeneral +( + register int alu, + register unsigned long pm, + register unsigned long fg, + register unsigned long bg, + register int fillStyle, + int drawableDepth, + ppcReducedRrop *returnLoc +) +{ + +if ( ( alu == GXnoop ) + || !( pm &= ( ( 1 << drawableDepth ) - 1 ) ) ) { + returnLoc->alu = GXnoop ; + return ; +} + +#ifdef DELETE_THIS +switch ( fillStyle ) { + case FillTiled: + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + fillStyle = FillSolid ; + default: /* We Can't Do Much Here */ + break ; + } + break ; + case FillOpaqueStippled: + if ( ( fg & pm ) != ( bg & pm ) ) { /* else FillSolid */ + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXset: /* 0xf 1 */ + case GXinvert: /* 0xa NOT dst */ + fillStyle = FillSolid ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + case GXnand: /* 0xe NOT src OR NOT dst */ + case GXcopy: /* 0x3 src */ + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXnor ; + break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXand ; /* Fall Through */ + case GXand: /* 0x1 src AND dst */ + pm &= ~( fg & bg ) ; + if ( ( bg & pm ) == pm ) { + fillStyle = FillStippled ; + alu = GXclear ; + } + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXxor ; /* Fall Through */ + case GXxor: /* 0x6 src XOR dst */ + pm &= ( fg | bg ) ; + if ( !( bg & pm ) ) { + fillStyle = FillStippled ; + alu = GXinvert ; + } + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXnand ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + fg = ~fg ; + bg = ~bg ; + alu = GXcopy ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + fg = ~fg ; + bg = ~bg ; + alu = GXor ; /* Fall Through */ + case GXor: /* 0x7 src OR dst */ + pm &= ( fg | bg ) ; + if ( !( bg & pm ) ) { + fillStyle = FillStippled ; + alu = GXset ; + } + break ; + default: + ErrorF( + "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ; + break ; + } + break ; /* Don't Fall Through */ + } + else + fillStyle = FillSolid ; + /* Fall Through */ + case FillStippled: + case FillSolid: + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXset: /* 0xf 1 */ + case GXinvert: /* 0xa NOT dst */ + break ; + case GXand: /* 0x1 src AND dst */ + pm &= ~fg ; + alu = GXclear ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + fg = ~fg ; + alu = GXnor ; /* Fall Through */ + case GXnor: /* 0x8 NOT src AND NOT dst */ + if ( !( fg & pm ) ) + alu = GXclear ; + else if ( ( fg & pm ) == pm ) + alu = GXinvert ; + break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + pm &= fg ; + alu = GXclear ; + break ; + case GXxor: /* 0x6 src XOR dst */ + pm &= fg ; + alu = GXinvert ; + break ; + case GXor: /* 0x7 src OR dst */ + pm &= fg ; + alu = GXset ; + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + pm &= ~fg ; + alu = GXinvert ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + fg = ~fg ; + alu = GXnand ; /* Fall Through */ + case GXnand: /* 0xe NOT src OR NOT dst */ + if ( !( fg & pm ) ) + alu = GXset ; + else if ( ( fg & pm ) == pm ) + alu = GXinvert ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + fg = ~fg ; + alu = GXcopy ; /* Fall Through */ + case GXcopy: /* 0x3 src */ + if ( !( fg & pm ) ) + alu = GXclear ; + else if ( ( fg & pm ) == pm ) + alu = GXset ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + pm &= ~fg ; + alu = GXset ; + break ; + default: + ErrorF( + "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ; + break ; + } + break; + default: + ErrorF("xf4bppGetReducedColorRrop: Bad Fillstyle\n"); + break; +} +#endif + +/* Final Test On Restricted Plane Mask */ +if ( !pm ) + alu = GXnoop ; + +/* Set Actual Returned Values */ +returnLoc->planemask = pm ; +returnLoc->fgPixel = fg ; +returnLoc->bgPixel = bg ; +returnLoc->alu = alu ; +returnLoc->fillStyle = fillStyle ; + +return ; +} + +void +xf4bppGetReducedColorRrop( pGC, drawableDepth, returnLoc ) +GC *pGC ; +int drawableDepth ; +ppcReducedRrop *returnLoc ; +{ + +ppcReduceGeneral( pGC->alu, + pGC->planemask, + pGC->fgPixel, + pGC->bgPixel, + pGC->fillStyle, + drawableDepth, + returnLoc ) ; + +return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcClip.c b/xorg-server/hw/xfree86/xf4bpp/ppcClip.c new file mode 100644 index 000000000..899dba683 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcClip.c @@ -0,0 +1,157 @@ +/* + +Copyright (c) 1987 X Consortium + +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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "scrnintstr.h" + +void +xf4bppDestroyClip(pGC) + GCPtr pGC; +{ + if(pGC->clientClipType == CT_NONE) + return; + else if (pGC->clientClipType == CT_PIXMAP) + { + mfbDestroyPixmap((PixmapPtr)(pGC->clientClip)); + } + else + { + /* we know we'll never have a list of rectangles, since + ChangeClip immediately turns them into a region + */ + REGION_DESTROY(pGC->pScreen, pGC->clientClip); + } + pGC->clientClip = NULL; + pGC->clientClipType = CT_NONE; +} + +void +xf4bppChangeClip(pGC, type, pvalue, nrects) + GCPtr pGC; + int type; + pointer pvalue; + int nrects; +{ + xf4bppDestroyClip(pGC); + if(type == CT_PIXMAP) + { + /* convert the pixmap to a region */ + pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pvalue); + /* you wouldn't do this if you were leaving the pixmap in + rather than converting it. + */ + (*pGC->pScreen->DestroyPixmap)(pvalue); + } + else if (type == CT_REGION) + { + /* stuff the region in the GC */ + pGC->clientClip = pvalue; + } + else if (type != CT_NONE) + { + pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nrects, + (xRectangle *)pvalue, + type); + xfree(pvalue); + } + pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION : + CT_NONE; + pGC->stateChanges |= GCClipMask; +} + +void +xf4bppCopyClip (pgcDst, pgcSrc) + GCPtr pgcDst, pgcSrc; +{ + RegionPtr prgnNew; + + switch(pgcSrc->clientClipType) + { + case CT_PIXMAP: + ((PixmapPtr) pgcSrc->clientClip)->refcnt++; + /* Fall through !! */ + case CT_NONE: + xf4bppChangeClip(pgcDst, pgcSrc->clientClipType, pgcSrc->clientClip, 0); + break; + case CT_REGION: + prgnNew = REGION_CREATE(pgcSrc->pScreen, NULL, 1); + REGION_COPY(pgcSrc->pScreen, prgnNew, (RegionPtr)(pgcSrc->clientClip)); + xf4bppChangeClip(pgcDst, CT_REGION, (pointer)prgnNew, 0); + break; + } +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcCpArea.c b/xorg-server/hw/xfree86/xf4bpp/ppcCpArea.c new file mode 100644 index 000000000..9bdaf89e3 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcCpArea.c @@ -0,0 +1,470 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +/*********************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "mfbmap.h" +#define PSZ 8 +#include "mfb.h" +#include "mergerop.h" +#include "mi.h" +#include "pixmapstr.h" +#include "scrnintstr.h" + +/* + * Graft in the DoBitblt from cfb. It does everything correctly. + */ +static void +vga16DoBitblt +( + DrawablePtr pSrc, + DrawablePtr pDst, + int alu, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long planemask +) +{ + int widthSrc, widthDst; /* add to get to same position in next line */ + BoxPtr pbox; + int nbox; + BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2; + /* temporaries for shuffling rectangles */ + DDXPointPtr pptTmp, pptNew1, pptNew2; + /* shuffling boxes entails shuffling the + source points too */ + int w, h; + int careful; + + widthSrc = mfbGetPixelWidth(pSrc); + widthDst = mfbGetPixelWidth(pDst); + + /* XXX we have to err on the side of safety when both are windows, + * because we don't know if IncludeInferiors is being used. + */ + careful = ((pSrc == pDst) || + ((pSrc->type == DRAWABLE_WINDOW) && + (pDst->type == DRAWABLE_WINDOW))); + + pbox = REGION_RECTS(prgnDst); + nbox = REGION_NUM_RECTS(prgnDst); + + pboxNew1 = NULL; + pptNew1 = NULL; + pboxNew2 = NULL; + pptNew2 = NULL; + if (careful && (pptSrc->y < pbox->y1)) + { + /* walk source botttom to top */ + widthSrc = -widthSrc; + widthDst = -widthDst; + + if (nbox > 1) + { + /* keep ordering in each band, reverse order of bands */ + pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox); + if(!pboxNew1) + return; + pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox); + if(!pptNew1) + { + xfree(pboxNew1); + return; + } + pboxBase = pboxNext = pbox+nbox-1; + while (pboxBase >= pbox) + { + while ((pboxNext >= pbox) && + (pboxBase->y1 == pboxNext->y1)) + pboxNext--; + pboxTmp = pboxNext+1; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp <= pboxBase) + { + *pboxNew1++ = *pboxTmp++; + *pptNew1++ = *pptTmp++; + } + pboxBase = pboxNext; + } + pboxNew1 -= nbox; + pbox = pboxNew1; + pptNew1 -= nbox; + pptSrc = pptNew1; + } + } + + if (careful && (pptSrc->x < pbox->x1)) + { + if (nbox > 1) + { + /* reverse order of rects in each band */ + pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox); + pptNew2 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox); + if(!pboxNew2 || !pptNew2) + { + if (pptNew2) xfree(pptNew2); + if (pboxNew2) xfree(pboxNew2); + if (pboxNew1) + { + xfree(pptNew1); + xfree(pboxNew1); + } + return; + } + pboxBase = pboxNext = pbox; + while (pboxBase < pbox+nbox) + { + while ((pboxNext < pbox+nbox) && + (pboxNext->y1 == pboxBase->y1)) + pboxNext++; + pboxTmp = pboxNext; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp != pboxBase) + { + *pboxNew2++ = *--pboxTmp; + *pptNew2++ = *--pptTmp; + } + pboxBase = pboxNext; + } + pboxNew2 -= nbox; + pbox = pboxNew2; + pptNew2 -= nbox; + pptSrc = pptNew2; + } + } + + while(nbox--) + { + w = pbox->x2 - pbox->x1; + h = pbox->y2 - pbox->y1; + + if( pSrc->type == DRAWABLE_WINDOW ) + xf4bppBitBlt( (WindowPtr)pDst, alu, planemask, + pptSrc->x, /* x0 */ + pptSrc->y, /* y0 */ + pbox->x1, /* x1 */ + pbox->y1, /* y1 */ + w, h ); /* w, h */ + else /* DRAWABLE_PIXMAP */ + xf4bppDrawColorImage( (WindowPtr)pDst, + pbox->x1, pbox->y1, + w, + h, + ((unsigned char *)((PixmapPtr)pSrc)->devPrivate.ptr + + pptSrc->x + (pptSrc->y*((PixmapPtr)pSrc)->devKind)), + ((PixmapPtr)pSrc)->devKind, + alu, planemask ) ; + pbox++; + pptSrc++; + } + if (pboxNew2) + { + xfree(pptNew2); + xfree(pboxNew2); + } + if (pboxNew1) + { + xfree(pptNew1); + xfree(pboxNew1); + } +} + + +/* + * Graft in the CopyArea from mfb/cfb. It does everything correctly. + */ + +RegionPtr +xf4bppCopyArea(pSrcDrawable, pDstDrawable, + pGC, srcx, srcy, width, height, dstx, dsty) +register DrawablePtr pSrcDrawable; +register DrawablePtr pDstDrawable; +register GC *pGC; +int srcx, srcy; +int width, height; +int dstx, dsty; +{ + RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */ + Bool freeSrcClip = FALSE; + + RegionPtr prgnExposed; + RegionRec rgnDst; + DDXPointPtr pptSrc; + register DDXPointPtr ppt; + register BoxPtr pbox; + int i; + register int dx; + register int dy; + xRectangle origSource; + DDXPointRec origDest; + int numRects; + BoxRec fastBox; + int fastClip = 0; /* for fast clipping with pixmap source */ + int fastExpose = 0; /* for fast exposures with pixmap source */ + + if ( pDstDrawable->type != DRAWABLE_WINDOW ) + return miCopyArea( pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, dstx, dsty ) ; + + /* Begin code from mfb/cfbCopyArea */ + + origSource.x = srcx; + origSource.y = srcy; + origSource.width = width; + origSource.height = height; + origDest.x = dstx; + origDest.y = dsty; + + if ((pSrcDrawable != pDstDrawable) && + pSrcDrawable->pScreen->SourceValidate) + { + (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height); + } + + srcx += pSrcDrawable->x; + srcy += pSrcDrawable->y; + + /* clip the source */ + + if (pSrcDrawable->type == DRAWABLE_PIXMAP) + { + if ((pSrcDrawable == pDstDrawable) && + (pGC->clientClipType == CT_NONE)) + { + prgnSrcClip = pGC->pCompositeClip; + } + else + { + fastClip = 1; + } + } + else + { + if (pGC->subWindowMode == IncludeInferiors) + { + if (!((WindowPtr) pSrcDrawable)->parent) + { + /* + * special case bitblt from root window in + * IncludeInferiors mode; just like from a pixmap + */ + fastClip = 1; + } + else if ((pSrcDrawable == pDstDrawable) && + (pGC->clientClipType == CT_NONE)) + { + prgnSrcClip = pGC->pCompositeClip; + } + else + { + prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable); + freeSrcClip = TRUE; + } + } + else + { + prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList; + } + } + + fastBox.x1 = srcx; + fastBox.y1 = srcy; + fastBox.x2 = srcx + width; + fastBox.y2 = srcy + height; + + /* Don't create a source region if we are doing a fast clip */ + if (fastClip) + { + fastExpose = 1; + /* + * clip the source; if regions extend beyond the source size, + * make sure exposure events get sent + */ + if (fastBox.x1 < pSrcDrawable->x) + { + fastBox.x1 = pSrcDrawable->x; + fastExpose = 0; + } + if (fastBox.y1 < pSrcDrawable->y) + { + fastBox.y1 = pSrcDrawable->y; + fastExpose = 0; + } + if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width) + { + fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width; + fastExpose = 0; + } + if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height) + { + fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height; + fastExpose = 0; + } + } + else + { + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip); + } + + dstx += pDstDrawable->x; + dsty += pDstDrawable->y; + + if (pDstDrawable->type == DRAWABLE_WINDOW) + { + if (!((WindowPtr)pDstDrawable)->realized) + { + if (!fastClip) + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return NULL; + } + } + + dx = srcx - dstx; + dy = srcy - dsty; + + /* Translate and clip the dst to the destination composite clip */ + if (fastClip) + { + RegionPtr cclip; + + /* Translate the region directly */ + fastBox.x1 -= dx; + fastBox.x2 -= dx; + fastBox.y1 -= dy; + fastBox.y2 -= dy; + + /* If the destination composite clip is one rectangle we can + do the clip directly. Otherwise we have to create a full + blown region and call intersect */ + cclip = pGC->pCompositeClip; + if (REGION_NUM_RECTS(cclip) == 1) + { + BoxPtr pBox = REGION_RECTS(cclip); + + if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1; + if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2; + if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1; + if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2; + + /* Check to see if the region is empty */ + if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) + { + REGION_NULL(pGC->pScreen, &rgnDst); + } + else + { + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + } + } + else + { + /* We must turn off fastClip now, since we must create + a full blown region. It is intersected with the + composite clip below. */ + fastClip = 0; + REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + } + } + else + { + REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy); + } + + if (!fastClip) + { + REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, pGC->pCompositeClip); + } + + /* Do bit blitting */ + numRects = REGION_NUM_RECTS(&rgnDst); + if (numRects && width && height) + { + if(!(pptSrc = (DDXPointPtr)xalloc(numRects * + sizeof(DDXPointRec)))) + { + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return NULL; + } + pbox = REGION_RECTS(&rgnDst); + ppt = pptSrc; + for (i = numRects; --i >= 0; pbox++, ppt++) + { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + vga16DoBitblt(pSrcDrawable, pDstDrawable, pGC->alu, + &rgnDst, pptSrc, pGC->planemask ); + xfree(pptSrc); + } + + prgnExposed = NULL; + if (pGC->fExpose) + { + /* Pixmap sources generate a NoExposed (we return NULL to do this) */ + if (!fastExpose) + prgnExposed = + miHandleExposures(pSrcDrawable, pDstDrawable, pGC, + origSource.x, origSource.y, + (int)origSource.width, + (int)origSource.height, + origDest.x, origDest.y, (unsigned long)0); + } + REGION_UNINIT(pGC->pScreen, &rgnDst); + if (freeSrcClip) + REGION_DESTROY(pGC->pScreen, prgnSrcClip); + return prgnExposed; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcDepth.c b/xorg-server/hw/xfree86/xf4bpp/ppcDepth.c new file mode 100644 index 000000000..2fa19ff80 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcDepth.c @@ -0,0 +1,53 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* Check to see if the alleged depth is acceptable for the Screen + * + * T. Paquin 9/87 + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "scrnintstr.h" + +Bool +xf4bppDepthOK(pDraw,depth) +register DrawablePtr pDraw; +register int depth; +{ +register ScreenPtr pScreen= pDraw->pScreen; +register int i = pScreen->numDepths; + + if ( ( pDraw->type == DRAWABLE_PIXMAP ) && ( depth == 1 ) ) + return TRUE ; + + while ( i-- ) + if ( depth == pScreen->allowedDepths[i].depth ) + return TRUE ; + + return FALSE ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcFillRct.c b/xorg-server/hw/xfree86/xf4bpp/ppcFillRct.c new file mode 100644 index 000000000..3422c8092 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcFillRct.c @@ -0,0 +1,215 @@ +/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */ +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "scrnintstr.h" + +#define MODEQ(a, b) ((a) %= (b)) + +/* + filled rectangles. + translate the rectangles, clip them, and call the +helper function in the GC. +*/ + +#define NUM_STACK_RECTS 1024 + +void +xf4bppPolyFillRect(pDrawable, pGC, nrectFill, prectInit) + DrawablePtr pDrawable; + GCPtr pGC; + int nrectFill; /* number of rectangles to fill */ + xRectangle *prectInit; /* Pointer to first rectangle to fill */ +{ + xRectangle *prect; + RegionPtr prgnClip; + register BoxPtr pbox; + register BoxPtr pboxClipped; + BoxPtr pboxClippedBase; + BoxPtr pextent; + BoxRec stackRects[NUM_STACK_RECTS]; + int numRects; + int n; + int xorg, yorg; + + if (!(pGC->planemask & 0x0F)) /* GJA */ + return; + + prgnClip = pGC->pCompositeClip; + + prect = prectInit; + xorg = pDrawable->x; + yorg = pDrawable->y; + if (xorg || yorg) + { + prect = prectInit; + n = nrectFill; + Duff (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) + xf4bppFillArea((WindowPtr)pDrawable, pboxClipped-pboxClippedBase, + pboxClippedBase, pGC); + if (pboxClippedBase != stackRects) + xfree(pboxClippedBase); +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcGC.c b/xorg-server/hw/xfree86/xf4bpp/ppcGC.c new file mode 100644 index 000000000..7ef312d39 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcGC.c @@ -0,0 +1,446 @@ +/* + +Copyright (c) 1987 X Consortium + +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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "scrnintstr.h" +#include "ppcGCstr.h" +#include "vgaVideo.h" +#include "ibmTrace.h" + +#define ppcGCInterestValidateMask \ +( GCLineStyle | GCLineWidth | GCJoinStyle | GCBackground | GCForeground \ +| GCFunction | GCPlaneMask | GCFillStyle | GC_CALL_VALIDATE_BIT \ +| GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode ) + +static void xf4bppValidateGC(GCPtr, unsigned long, DrawablePtr); +static void xf4bppDestroyGC(GC *); + +static GCFuncs vgaGCFuncs = { + xf4bppValidateGC, + (void (*)(GCPtr, unsigned long))NoopDDA, + (void (*)(GCPtr, unsigned long, GCPtr))NoopDDA, + xf4bppDestroyGC, + xf4bppChangeClip, + xf4bppDestroyClip, + xf4bppCopyClip, + { NULL } +}; + + +static ppcPrivGC vgaPrototypeGCPriv = { + GXcopy, /* unsigned char rop */ + 0, /* unsigned char ropOpStip */ + 0, /* unsigned char ropFillArea */ + {0, }, /* unsigned char unused[sizeof(long) - 3] */ + NULL, /* mfbFillAreaProcPtr FillArea */ + { + VGA_ALLPLANES, /* unsigned long planemask */ + 1, /* unsigned long fgPixel */ + 0, /* unsigned long bgPixel */ + GXcopy, /* int alu */ + FillSolid, /* int fillStyle */ + }, /* ppcReducedRrop colorRrop */ + -1, /* short lastDrawableType */ + -1, /* short lastDrawableDepth */ + 0 /* pointer devPriv */ +} ; + +static GCOps vgaGCOps = { + xf4bppSolidWindowFS, /* void (* FillSpans)() */ + xf4bppSetSpans, /* void (* SetSpans)() */ + miPutImage, /* void (* PutImage)() */ + xf4bppCopyArea, /* RegionPtr (* CopyArea)() */ + miCopyPlane, /* void (* CopyPlane)() */ + xf4bppPolyPoint, /* void (* PolyPoint)() */ + miZeroLine, /* void (* Polylines)() */ + miPolySegment, /* void (* PolySegment)() */ + miPolyRectangle, /* void (* PolyRectangle)() */ + xf4bppZeroPolyArc, /* void (* PolyArc)() */ + miFillPolygon, /* void (* FillPolygon)() */ + miPolyFillRect, /* void (* PolyFillRect)() */ + xf4bppPolyFillArc, /* void (* PolyFillArc)() */ + miPolyText8, /* int (* PolyText8)() */ + miPolyText16, /* int (* PolyText16)() */ + miImageText8, /* void (* ImageText8)() */ + miImageText16, /* void (* ImageText16)() */ + xf4bppImageGlyphBlt, /* GJA -- void (* ImageGlyphBlt)() */ + miPolyGlyphBlt, /* GJA -- void (* PolyGlyphBlt)() */ + miPushPixels, /* void (* PushPixels)() */ + {NULL} /* devPrivate */ +}; + +Bool +xf4bppCreateGC( pGC ) +register GCPtr pGC ; +{ + ppcPrivGC *pPriv ; + GCOps *pOps ; + + if ( pGC->depth == 1 ) + { + return (mfbCreateGC(pGC)); + } + + if ( !( pPriv = xalloc( sizeof( ppcPrivGC ) ) ) ) + return FALSE ; + + if ( !( pOps = xalloc( sizeof( GCOps ) ) ) ) { + xfree(pPriv); + return FALSE; + } + + /* Now we initialize the GC fields */ + pGC->miTranslate = 1; + pGC->unused = 0; + pGC->planemask = VGA_ALLPLANES; + pGC->fgPixel = VGA_BLACK_PIXEL; + pGC->bgPixel = VGA_WHITE_PIXEL; + pGC->funcs = &vgaGCFuncs; + /* ops, -- see below */ + + pGC->fExpose = TRUE; + pGC->freeCompClip = FALSE; + + /* GJA: I don't like this code: + * they allocated a mfbPrivGC, ignore the allocated data and place + * a pointer to a ppcPrivGC in its slot. + */ + *pPriv = vgaPrototypeGCPriv; + dixSetPrivate(&pGC->devPrivates, mfbGetGCPrivateKey(), pPriv); + + /* Set the vgaGCOps */ + *pOps = vgaGCOps; + pOps->devPrivate.val = 1; + pGC->ops = pOps; + + return TRUE ; +} + +static void +xf4bppDestroyGC( pGC ) + register GC *pGC ; + +{ + TRACE( ( "xf4bppDestroyGC(pGC=0x%x)\n", pGC ) ) ; + + if ( pGC->freeCompClip && pGC->pCompositeClip ) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + if(pGC->ops->devPrivate.val) xfree( pGC->ops ); + xfree(dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey())); + return ; +} + +static Mask +ppcChangePixmapGC +( + register GC *pGC, + register Mask changes +) +{ +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); +register unsigned long int idx ; /* used for stepping through bitfields */ + +#define LOWBIT( x ) ( x & - x ) /* Two's complement */ +while ((idx = LOWBIT(changes))) { + switch ( idx ) { + + case GCLineStyle: + case GCLineWidth: + pGC->ops->Polylines = ( ! pGC->lineWidth ) + ? miZeroLine + : ( ( pGC->lineStyle == LineSolid ) + ? miWideLine : miWideDash ) ; + changes &= ~( GCLineStyle | GCLineWidth ) ; + break ; + + case GCJoinStyle: + changes &= ~ idx ; /* i.e. changes &= ~ GCJoinStyle */ + break ; + + case GCBackground: + if ( pGC->fillStyle != FillOpaqueStippled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCBackground */ + break ; + } /* else Fall Through */ + case GCForeground: + if ( pGC->fillStyle == FillTiled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCForeground */ + break ; + } /* else Fall Through */ + case GCFunction: + case GCPlaneMask: + case GCFillStyle: + { /* new_fill */ + int fillStyle = devPriv->colorRrop.fillStyle ; + /* install a suitable fillspans */ + if ( fillStyle == FillSolid ) + pGC->ops->FillSpans = xf4bppSolidPixmapFS ; + else if ( fillStyle == FillStippled ) + pGC->ops->FillSpans = xf4bppStipplePixmapFS ; + else if ( fillStyle == FillOpaqueStippled ) + pGC->ops->FillSpans = xf4bppOpStipplePixmapFS ; + else /* fillStyle == FillTiled */ + pGC->ops->FillSpans = xf4bppTilePixmapFS ; + changes &= ~( GCBackground | GCForeground + | GCFunction | GCPlaneMask | GCFillStyle ) ; + break ; + } /* end of new_fill */ + + default: + ErrorF( "ppcChangePixmapGC: Unexpected GC Change\n" ) ; + changes &= ~ idx ; /* Remove it anyway */ + break ; + } +} + +return 0 ; +} + +/* Clipping conventions + if the drawable is a window + CT_REGION ==> pCompositeClip really is the composite + CT_other ==> pCompositeClip is the window clip region + if the drawable is a pixmap + CT_REGION ==> pCompositeClip is the translated client region + clipped to the pixmap boundary + CT_other ==> pCompositeClip is the pixmap bounding box +*/ + +static void +xf4bppValidateGC( pGC, changes, pDrawable ) + GCPtr pGC; + unsigned long changes; + DrawablePtr pDrawable; +{ + register ppcPrivGCPtr devPriv ; + WindowPtr pWin ; + + devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); + if ( pDrawable->type != devPriv->lastDrawableType ) { + devPriv->lastDrawableType = pDrawable->type ; + xf4bppChangeGCtype( pGC, devPriv ) ; + changes = (unsigned)~0 ; + } + + if ( pDrawable->depth == 1 ) { +/* ibmAbort(); */ + xf4bppNeverCalled(); + } + + if ( pDrawable->type == DRAWABLE_WINDOW ) { + pWin = (WindowPtr) pDrawable ; + pGC->lastWinOrg.x = pWin->drawable.x ; + pGC->lastWinOrg.y = pWin->drawable.y ; + } + else { + pWin = (WindowPtr) NULL ; + pGC->lastWinOrg.x = 0 ; + pGC->lastWinOrg.y = 0 ; + } + + changes &= ppcGCInterestValidateMask ; + /* If Nothing REALLY Changed, Just Return */ + if ( pDrawable->serialNumber == (pGC->serialNumber & DRAWABLE_SERIAL_BITS) ) + if ( !( changes &= ~ GC_CALL_VALIDATE_BIT ) ) + return ; + + /* GJA -- start of cfb code */ + /* + * if the client clip is different or moved OR the subwindowMode has + * changed OR the window's clip has changed since the last validation + * we need to recompute the composite clip + */ + + if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || + (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) + ) + { + if (pWin) { + RegionPtr pregWin; + Bool freeTmpClip, freeCompClip; + + if (pGC->subWindowMode == IncludeInferiors) { + pregWin = NotClippedByChildren(pWin); + freeTmpClip = TRUE; + } + else { + pregWin = &pWin->clipList; + freeTmpClip = FALSE; + } + freeCompClip = pGC->freeCompClip; + + /* + * if there is no client clip, we can get by with just keeping + * the pointer we got, and remembering whether or not should + * destroy (or maybe re-use) it later. this way, we avoid + * unnecessary copying of regions. (this wins especially if + * many clients clip by children and have no client clip.) + */ + if (pGC->clientClipType == CT_NONE) { + if (freeCompClip) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + pGC->pCompositeClip = pregWin; + pGC->freeCompClip = freeTmpClip; + } + else { + /* + * we need one 'real' region to put into the composite + * clip. if pregWin the current composite clip are real, + * we can get rid of one. if pregWin is real and the + * current composite clip isn't, use pregWin for the + * composite clip. if the current composite clip is real + * and pregWin isn't, use the current composite clip. if + * neither is real, create a new region. + */ + + REGION_TRANSLATE(pGC->pScreen, pGC->clientClip, + pDrawable->x + pGC->clipOrg.x, + pDrawable->y + pGC->clipOrg.y); + + if (freeCompClip) + { + REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, + pregWin, pGC->clientClip); + if (freeTmpClip) + REGION_DESTROY(pGC->pScreen, pregWin); + } + else if (freeTmpClip) + { + REGION_INTERSECT(pGC->pScreen, pregWin, pregWin, + pGC->clientClip); + pGC->pCompositeClip = pregWin; + } + else + { + pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0); + REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, + pregWin, pGC->clientClip); + } + pGC->freeCompClip = TRUE; + REGION_TRANSLATE(pGC->pScreen, pGC->clientClip, + -(pDrawable->x + pGC->clipOrg.x), + -(pDrawable->y + pGC->clipOrg.y)); + + } + } /* end of composite clip for a window */ + else { + BoxRec pixbounds; + + /* XXX should we translate by drawable.x/y here ? */ + pixbounds.x1 = 0; + pixbounds.y1 = 0; + pixbounds.x2 = pDrawable->width; + pixbounds.y2 = pDrawable->height; + + if (pGC->freeCompClip) { + REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds); + } else { + pGC->freeCompClip = TRUE; + pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1); + } + + if (pGC->clientClipType == CT_REGION) + { + REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, + -pGC->clipOrg.x, -pGC->clipOrg.y); + REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, + pGC->pCompositeClip, pGC->clientClip); + REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, + pGC->clipOrg.x, pGC->clipOrg.y); + } + } /* end of composute clip for pixmap */ + } + /* GJA -- End of cfb code */ + + changes &= ~ ( GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode + | GC_CALL_VALIDATE_BIT ) ; + + /* If needed, Calculate the Color Reduced Raster-Op */ + if ( changes & ( GCFillStyle | GCBackground | GCForeground + | GCPlaneMask | GCFunction ) ) + xf4bppGetReducedColorRrop( pGC, pDrawable->depth, + &devPriv->colorRrop ) ; + + (* ( ( pDrawable->type == DRAWABLE_WINDOW ) + ? xf4bppChangeWindowGC + : ppcChangePixmapGC ) )( pGC, changes ) ; + + return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcGCstr.h b/xorg-server/hw/xfree86/xf4bpp/ppcGCstr.h new file mode 100644 index 000000000..82d1f2df4 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcGCstr.h @@ -0,0 +1,71 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "gc.h" +#include "mfb.h" + +typedef struct { + unsigned long planemask ; + unsigned long fgPixel ; + unsigned long bgPixel ; + int alu ; + int fillStyle ; + } ppcReducedRrop ; + +/* ************************************************************************ */ + +/* private field of GC */ +typedef struct { +/* The next five (5) fields MUST CORRESPOND to + * the fields of a "mfbPrivGC" struct + * ----- BEGINNING OF "DO-NOT-CHANGE" REGION ----- + */ + unsigned char rop ; /* reduction of rasterop to 1 of 3 */ + unsigned char ropOpStip ; /* rop for opaque stipple */ + unsigned char ropFillArea ; /* == alu, rop, or ropOpStip */ + unsigned char unused[sizeof(long) - 3]; + mfbFillAreaProcPtr FillArea; /* fills regions; look at the code */ +/* ----- END OF "DO-NOT-CHANGE" REGION ----- */ + ppcReducedRrop colorRrop ; + short lastDrawableType ; /* was last drawable a window or a pixmap? */ + short lastDrawableDepth ; /* was last drawable 1 or 8 planes? */ + pointer devPriv ; /* Private area for device specific stuff */ + } ppcPrivGC ; +typedef ppcPrivGC *ppcPrivGCPtr ; + +/* ppcCReduce.c */ +void xf4bppGetReducedColorRrop( + GCPtr, + int, + ppcReducedRrop * +); + +/* vgaGC.c */ +void xf4bppChangeGCtype( + GCPtr, + ppcPrivGCPtr +); diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcGetSp.c b/xorg-server/hw/xfree86/xf4bpp/ppcGetSp.c new file mode 100644 index 000000000..d88abe02b --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcGetSp.c @@ -0,0 +1,141 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "servermd.h" +#include "ibmTrace.h" + +/* GetSpans -- for each span, gets bits from drawable starting at ppt[i] + * and continuing for pwidth[i] bits + * Each scanline returned will be server scanline padded, i.e., it will come + * out to an integral number of words. + */ +void +xf4bppGetSpans( pDrawable, wMax, ppt, pwidth, nspans, pdstStart ) + DrawablePtr pDrawable ; /* drawable from which to get bits */ + int wMax ; /* largest value of all *pwidths */ + DDXPointPtr ppt ; /* points to start copying from */ + int *pwidth ; /* list of number of bits to copy */ + int nspans ; /* number of scanlines to copy */ + char *pdstStart ; +{ + register int j ; + register unsigned char *pdst ; /* where to put the bits */ + register unsigned char *psrc ; /* where to get the bits */ + register int pixmapStride ; + + + TRACE( ( "xf4bppGetSpans(pDrawable=0x%x,wMax=%d,ppt=0x%x,pwidth=0x%x,nspans=%d)\n", + pDrawable, wMax, ppt, pwidth, nspans ) ) ; + + if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) + { + mfbGetSpans( pDrawable, wMax, ppt, pwidth, nspans, pdstStart ) ; + return; + } + + pixmapStride = PixmapBytePad( wMax, pDrawable->depth ) ; + pdst = (unsigned char *) /* GJA */ pdstStart ; + + if ( pDrawable->type == DRAWABLE_WINDOW ) { + for ( ; nspans-- ; ppt++, pwidth++ ) { + xf4bppReadColorImage( (WindowPtr)pDrawable, + ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride ) ; + pdst += j ; /* width is in 32 bit words */ + j = ( -j ) & 3 ; + while ( j-- ) /* Pad out to 32-bit boundary */ + *pdst++ = 0 ; + } + } + else { /* OK, if we are here, we had better be a DRAWABLE PIXMAP */ + register int widthSrc = /* width of pixmap in bytes */ + (int) ( (PixmapPtr) pDrawable )->devKind ; + + psrc = (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ; + for ( ; nspans-- ; ppt++, pwidth++ ) { + MOVE( psrc + ( ppt->y * widthSrc ) + ppt->x, + pdst, j = *pwidth ) ; + pdst += j ; + j = ( -j ) & 3 ; + while ( j-- ) /* Pad out to 32-bit boundary */ + *pdst++ = 0 ; + } + } + return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcIO.c b/xorg-server/hw/xfree86/xf4bpp/ppcIO.c new file mode 100644 index 000000000..83952d12d --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcIO.c @@ -0,0 +1,233 @@ +/* + +Copyright (c) 1990 X Consortium + +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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "micmap.h" +#include "scrnintstr.h" +#include "vgaVideo.h" + +#if 0 +/* XXX This remains to remind of the PC98 difference */ +static VisualRec vgaVisuals[] = { +/* StaticColor needs to be first so is can be used as the default */ +/* vid class bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */ +#ifdef PC98 +{ 0, StaticColor, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, StaticGray, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, GrayScale, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, PseudoColor, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +#else +{ 0, StaticColor, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, StaticGray, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, GrayScale, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +{ 0, PseudoColor, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 }, +#endif +} ; +#endif + +void +xf4bppNeverCalled() +{ + FatalError("xf4bppNeverCalled was nevertheless called\n"); +} + +/*ARGSUSED*/ +static Bool +vgaScreenClose +( + int idx, + ScreenPtr pScreen +) +{ + pScreen->defColormap = 0 ; + return TRUE; +} + + +static GCPtr sampleGCperDepth[MAXFORMATS+1] = { 0 }; +static PixmapPtr samplePixmapPerDepth[1] = { 0 }; + +/* GJA -- Took this from miscrinit.c. + * We want that devKind contains the distance in bytes between two scanlines. + * The computation that mi does is not appropriate for planar VGA. + * Therefore we provide here our own routine. + */ + +/* GJA -- WARNING: this is an internal structure declaration, taken from + * miscrinit.c + */ +typedef struct +{ + pointer pbits; /* pointer to framebuffer */ + int width; /* delta to add to a framebuffer addr to move one row down */ +} miScreenInitParmsRec, *miScreenInitParmsPtr; + +/* With the introduction of pixmap privates, the "screen pixmap" can no + * longer be created in miScreenInit, since all the modules that could + * possibly ask for pixmap private space have not been initialized at + * that time. pScreen->CreateScreenResources is called after all + * possible private-requesting modules have been inited; we create the + * screen pixmap here. + */ +static Bool +v16CreateScreenResources +( + ScreenPtr pScreen +) +{ + miScreenInitParmsPtr pScrInitParms; + pointer value; + + pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate; + + /* if width is non-zero, pScreen->devPrivate will be a pixmap + * else it will just take the value pbits + */ + if (pScrInitParms->width) + { + PixmapPtr pPixmap; + + /* create a pixmap with no data, then redirect it to point to + * the screen + */ + pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth, 0); + if (!pPixmap) + return FALSE; + + if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width, + pScreen->height, pScreen->rootDepth, 8 /* bits per pixel */, +/* GJA: was PixmapBytePad(pScrInitParms->width, pScreen->rootDepth), */ +#define BITS_PER_BYTE_SHIFT 3 + pScrInitParms->width >> BITS_PER_BYTE_SHIFT, + pScrInitParms->pbits)) + return FALSE; + value = (pointer)pPixmap; + } + else + { + value = pScrInitParms->pbits; + } + xfree(pScreen->devPrivate); /* freeing miScreenInitParmsRec */ + pScreen->devPrivate = value; /* pPixmap or pbits */ + return TRUE; +} + + +Bool +xf4bppScreenInit( pScreen, pbits, virtx, virty, dpix, dpiy, width ) + ScreenPtr pScreen; + pointer pbits; + int virtx, virty; + int dpix, dpiy; + int width; +{ + Bool ret; + VisualPtr visuals; + DepthPtr depths; + int nvisuals; + int ndepths; + int rootdepth; + VisualID defaultVisual; + + rootdepth = 0; + ret = miInitVisuals(&visuals, &depths, &nvisuals, &ndepths, &rootdepth, + &defaultVisual, (unsigned long)1 << 8, 6, -1); + if (!ret) + return FALSE; + + pScreen-> id = 0; + pScreen->defColormap = FakeClientID(0); + pScreen-> whitePixel = VGA_WHITE_PIXEL; + pScreen-> blackPixel = VGA_BLACK_PIXEL; + pScreen-> rgf = 0; + *(pScreen-> GCperDepth) = *(sampleGCperDepth); + *(pScreen-> PixmapPerDepth) = *(samplePixmapPerDepth); + pScreen-> CloseScreen = vgaScreenClose; + pScreen-> QueryBestSize = xf4bppQueryBestSize; + pScreen-> GetImage = xf4bppGetImage; + pScreen-> GetSpans = xf4bppGetSpans; + pScreen-> CreateWindow = xf4bppCreateWindowForXYhardware; + pScreen-> DestroyWindow = xf4bppDestroyWindow; + pScreen-> PositionWindow = xf4bppPositionWindow; + pScreen-> CopyWindow = xf4bppCopyWindow; + pScreen-> CreatePixmap = xf4bppCreatePixmap; + pScreen-> CreateGC = xf4bppCreateGC; + pScreen-> CreateColormap = xf4bppInitializeColormap; + pScreen-> DestroyColormap = (DestroyColormapProcPtr)NoopDDA; + pScreen-> InstallColormap = miInstallColormap; + pScreen-> UninstallColormap = miUninstallColormap; + pScreen-> ListInstalledColormaps = miListInstalledColormaps; + pScreen-> StoreColors = (StoreColorsProcPtr)NoopDDA; + pScreen-> ResolveColor = xf4bppResolveColor; + mfbFillInScreen(pScreen); + + if (!mfbAllocatePrivates(pScreen, NULL)) + return FALSE; + + if (!miScreenInit(pScreen, pbits, virtx, virty, dpix, dpiy, width, + rootdepth, ndepths, depths, defaultVisual /* See above */, + nvisuals, visuals)) + return FALSE; + + /* GJA -- Now we override the supplied default: */ + pScreen -> CreateScreenResources = v16CreateScreenResources; + + mfbRegisterCopyPlaneProc(pScreen,miCopyPlane); /* GJA -- R4->R5 */ + return TRUE; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcImg.c b/xorg-server/hw/xfree86/xf4bpp/ppcImg.c new file mode 100644 index 000000000..33c6b89c5 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcImg.c @@ -0,0 +1,122 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mi.h" +#include "scrnintstr.h" +#include "servermd.h" + +/* Was MIGETIMAGE -- public entry for the GetImage Request + * We're getting the image into a memory buffer. While we have to use GetSpans + * to read a line from the device ( since we don't know what that looks like ) , + * we can just write into the destination buffer + * + * two different strategies are used, depending on whether we're getting the + * image in Z format or XY format + * Z format: + * Line at a time, GetSpans a line and bcopy it to the destination + * buffer, except that if the planemask is not all ones, we create a + * temporary pixmap and do a SetSpans into it ( to get bits turned off ) + * and then another GetSpans to get stuff back ( because pixmaps are + * opaque, and we are passed in the memory to write into ) . This is + * completely ugly and slow but works, but the interfaces just aren't + * designed for this case. Life is hard. + * XY format: + * get the single plane specified in planemask + */ +void +xf4bppGetImage( pDraw, sx, sy, w, h, format, planeMask, pdstLine ) + DrawablePtr pDraw ; + int sx, sy, w, h ; + unsigned int format ; + unsigned long planeMask ; + char * pdstLine ; +{ +#if 1 + int depth, i, linelength, width ; + DDXPointRec pt ; + char *pbits ; + XID gcv[2] ; + PixmapPtr pPixmap = (PixmapPtr) NULL ; + GCPtr pGC ; + char *pDst = pdstLine ; + + depth = pDraw->depth ; + if ( format == ZPixmap ) { + linelength = PixmapBytePad( w, depth ) ; +/* if ( pDraw->type == DRAWABLE_WINDOW ) { */ + sx += pDraw->x ; + sy += pDraw->y ; +/* } */ + if ( ( ( ( 1 << pDraw->depth ) - 1 ) & planeMask ) + != (unsigned)( 1 << pDraw->depth ) - 1 ) { + pGC = GetScratchGC( depth, pDraw->pScreen ) ; + pPixmap = (PixmapPtr) + (* pDraw->pScreen->CreatePixmap)( pDraw->pScreen, w, h, depth, + CREATE_PIXMAP_USAGE_SCRATCH) ; + gcv[0] = GXcopy ; + gcv[1] = planeMask ; + DoChangeGC( pGC, GCPlaneMask | GCFunction, gcv, 0 ) ; + ValidateGC( (DrawablePtr)pPixmap, pGC ) ; + + pbits = (char *)xalloc(w); + + for ( i = 0 ; i < h ; i++ ) { + pt.x = sx ; + pt.y = sy + i ; + width = w ; + (* pDraw->pScreen->GetSpans)( pDraw, w, &pt, &width, 1, pbits ) ; + pt.x = 0 ; + pt.y = i ; + width = w ; + if ( planeMask & ((1 << depth) - 1) ) /* GJA -- mfb bug */ + (* pGC->ops->SetSpans)( (DrawablePtr)pPixmap, pGC, pbits, &pt, &width, 1, TRUE ) ; + (* pDraw->pScreen->GetSpans)( (DrawablePtr)pPixmap, w, &pt, &width, 1, pDst ) ; + pDst += linelength ; + } + + xfree(pbits) ; + (* pGC->pScreen->DestroyPixmap)( pPixmap ) ; + FreeScratchGC( pGC ) ; + return ; + } + + for ( i = 0 ; i < h ; i++ ) { + pt.x = sx ; + pt.y = sy + i ; + width = w ; + (* pDraw->pScreen->GetSpans)( pDraw, w, &pt, &width, 1, pDst ) ; + pDst += linelength ; + } + } + else +#endif + miGetImage( pDraw, sx, sy, w, h, format, planeMask, pdstLine ) ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcPixFS.c b/xorg-server/hw/xfree86/xf4bpp/ppcPixFS.c new file mode 100644 index 000000000..9fd29efce --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcPixFS.c @@ -0,0 +1,502 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +/****************************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "maskbits.h" +#include "mi.h" +#include "mispans.h" +#include "ppcGCstr.h" +#include "ppcSpMcro.h" +#include "vgaVideo.h" +#include "ibmTrace.h" + +#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 ) + +/* GJA -- copied this from VGA */ +#define SCRLEFT8(lw, n) ( (unsigned char) (((unsigned char) lw) << (n)) ) +#define SCRRIGHT8(lw, n) ( (unsigned char) (((unsigned char)lw) >> (n)) ) +/* +********** ********** ********** ********** ********** ********** ********** + these routines all clip. they assume that anything that has called +them has already translated the points (i.e. pGC->miTranslate is +non-zero, which is howit gets set in mfbCreateGC().) + + the number of new scnalines created by clipping == +MaxRectsPerBand * nSpans. +********** ********** ********** ********** ********** ********** ********** +*/ +/* A mod definition that goes smoothly into the negative. + */ +static int +modulo +( + int n1, + int n2 +) +{ + int tmp; + if ( n1 < 0 ) { + tmp = (-n1) % n2; + if ( tmp == 0 ) { + return 0; + } else { + return n2 - tmp; + } + } else { + return n1 % n2; + } +} + +void +xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) + DrawablePtr pDrawable ; + GCPtr pGC ; + int nInit ; /* number of spans to fill */ + DDXPointPtr pptInit ; /* pointer to list of start points */ + int *pwidthInit ; /* pointer to list of n widths */ + int fSorted ; +{ + register unsigned long int pm, npm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + register unsigned char *addrl ; /* pointer to current longword in bitmap */ + int i ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE(("xf4bppSolidPixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ; + + if ( pDrawable->type != DRAWABLE_PIXMAP ) { + ErrorF("xf4bppSolidPixmapFS: drawable is not a pixmap\n") ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()))->colorRrop.alu ) == GXnoop ) + return ; + + n = nInit * miFindMaxBand(pGC->pCompositeClip) ; + if ( !( pwidthFree = (int *) xalloc( n * sizeof( int ) ) ) ) + return ; + pwidth = pwidthFree ; + + if ( !( pptFree = (DDXPointRec *) + xalloc( n * sizeof( DDXPointRec ) ) ) ) { + xfree( pwidth ) ; + return ; + } + ppt = pptFree ; + + n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, + ppt, pwidth, fSorted ) ; + + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + + for ( ; n-- ; ppt++, pwidth++ ) { + addrl = ( (unsigned char *) ( ( (PixmapPtr) pDrawable )->devPrivate.ptr ) ) + + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) ) + + ppt->x ; + for ( i = *pwidth ; i-- ; addrl++ ) + { + unsigned _p; + DoRop( _p, alu, fg, *addrl ); + *addrl = ( *addrl & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *addrl = ( *addrl & npm ) | ( pm & DoRop( alu, fg, *addrl ) ) ; +#endif /* PURDUE */ + } + xfree( pptFree ) ; + xfree( pwidthFree ) ; + return ; +} + +/* GJA -- copied from vgaStipple.c */ +static unsigned char +vgagetbits +( + register const int x, + register const unsigned int patternWidth, + register const unsigned char * const lineptr +) +{ +register unsigned char bits ; +register const unsigned char *cptr ; +register int shift ; +register int wrap ; + +cptr = lineptr + ( x >> 3 ) ; +bits = *cptr ; +if ((shift = x & 7)) + bits = SCRLEFT8( bits, shift ) | SCRRIGHT8( cptr[1], ( 8 - shift ) ) ; +if ( ( wrap = x + 8 - patternWidth ) > 0 ) { + bits &= SCRLEFT8( 0xFF, wrap ) ; + bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ; +} + +/* GJA -- Handle extraction of 8 bits from < 8 bits wide stipple. + * I duplicated case 4,5,6,7 to give the compiler a chance to optimize. + */ +switch (patternWidth) { +case 1: /* Not really useful. */ + bits &= ~SCRRIGHT8(0xFF,1); + bits |= SCRRIGHT8(bits,1); + bits |= SCRRIGHT8(bits,2); + bits |= SCRRIGHT8(bits,4); + break; +case 2: + bits &= ~SCRRIGHT8(0xFF,2); + bits |= SCRRIGHT8(bits,2); bits |= SCRRIGHT8(bits,4); break; +case 3: + bits &= ~SCRRIGHT8(0xFF,3); + bits |= (SCRRIGHT8(bits,3) | SCRRIGHT8(bits,6)); break; +case 4: + bits = (bits & ~SCRRIGHT8(0xFF,4)) | SCRRIGHT8(bits,4); break; +case 5: + bits = (bits & ~SCRRIGHT8(0xFF,5)) | SCRRIGHT8(bits,5); break; +case 6: + bits = (bits & ~SCRRIGHT8(0xFF,6)) | SCRRIGHT8(bits,6); break; +case 7: + bits = (bits & ~SCRRIGHT8(0xFF,7)) | SCRRIGHT8(bits,7); break; +default: + ; + /* Do nothing, of course */ +} + +return bits ; +} + +void +xf4bppStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +register DrawablePtr pDrawable ; +GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register unsigned char *pdst ; /* pointer to current word in bitmap */ + register unsigned long int pm, npm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int width, x, xSrc, ySrc ; + int tlwidth, tileWidth ; + unsigned char *psrcT ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + int xoff, count, stip, i ; + + TRACE(("xf4bppStipplePixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ; + + if ( pDrawable->type != DRAWABLE_PIXMAP ) { + ErrorF( "xf4bppStippleWindowFS: drawable is not a pixmap\n") ; + return ; + } + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF( "ppcStippleFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, + pptFree, pwidth, ppt, fSorted ) ; + + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + + pTile = pGC->stipple ; + tlwidth = pTile->devKind ; + + tileWidth = pTile->drawable.width ; + + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + + /* this replaces rotating the stipple. Instead, we just adjust the offset + * at which we start grabbing bits from the stipple */ + xSrc = pGC->patOrg.x + pDrawable->x; + ySrc = pGC->patOrg.y + pDrawable->y; + + while ( n-- ) { + pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ) + + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) ) + + ppt->x ; + psrcT = (unsigned char *)pTile->devPrivate.ptr + + ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ; + x = ppt->x ; + + xoff = modulo( x - xSrc, tileWidth) ; + for ( width = *pwidth ; width ; width -= count, xoff+=count ) { + + if ( xoff >= tileWidth ) xoff -= tileWidth; + + if ( width < 8 ) + count = width; + else + count = 8; + + stip = vgagetbits( xoff, tileWidth, psrcT ) ; + + for ( i = count ; i-- ; ) { + if ( stip & 128 ) + { + unsigned _p; + DoRop( _p, alu, fg, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ; +#endif /* PURDUE */ + pdst++ ; + stip = SCRLEFT( stip, 1 ) ; + } + } + ppt++ ; + pwidth++ ; + } + xfree( pptFree ) ; + xfree( pwidthFree ) ; + return ; +} + +void +xf4bppOpStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register unsigned char *pdst ; /* pointer to current word in bitmap */ + register unsigned long int pm, npm ; + register unsigned long int fg, bg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int width ; + int xSrc, ySrc ; + int tlwidth, tileWidth ; + unsigned char *psrcT ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + int xoff, count, stip, i ; + + TRACE( ( "xf4bppOpStipplePixmapFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF( "xf4bppOpStipplePixmapFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, + pptFree, pwidth, ppt, fSorted ) ; + + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + + pTile = pGC->stipple ; + tlwidth = pTile->devKind ; + tileWidth = pTile->drawable.width ; + + xSrc = pGC->patOrg.x + pDrawable->x; + ySrc = pGC->patOrg.y + pDrawable->y; + + /* this replaces rotating the stipple. Instead, we just adjust the offset + * at which we start grabbing bits from the stipple */ + for ( ; n-- ; ppt++, pwidth++ ) { + pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ) + + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) ) + + ppt->x ; + psrcT = (unsigned char *)pTile->devPrivate.ptr + + ( modulo( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ; + + xoff = modulo( ppt->x - xSrc, tileWidth) ; + + for ( width = *pwidth ; width ; width -= count, xoff+=count ) { + + if ( xoff >= tileWidth ) xoff -= tileWidth; + + if ( width < 8 ) + count = width; + else + count = 8; + + stip = vgagetbits( xoff, tileWidth, psrcT ) ; + for ( i = count ; i-- ; pdst++, stip = SCRLEFT( stip, 1 ) ) + if ( stip & 128 ) + { + unsigned _p; + DoRop( _p, alu, fg, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ; +#endif /* PURDUE */ + else + { + unsigned _p; + DoRop( _p, alu, bg, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, bg, *pdst ) ) ; +#endif /* PURDUE */ + } + } + xfree( pptFree ) ; + xfree( pwidthFree ) ; + return ; +} + +void +xf4bppTilePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +register DrawablePtr pDrawable ; +GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + register unsigned char *pdst ; /* pointer to current word in bitmap */ + register unsigned char *psrc ; /* pointer to current word in tile */ + register PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int i ; + int alu ; + unsigned char pm, npm ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + int tileWidth ; + int xSrc, ySrc; + unsigned char *psrcT ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "ppcTileFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) { + mfbTileFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ; + return ; + } + if ( !xf4bppDepthOK( pDrawable, pGC->tile.pixmap->drawable.depth ) ) { + ErrorF( "ppcTileFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pDrawable->depth) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, + pptFree, pwidth, ppt, fSorted ) ; + + /* the following code is for 8 bits per pixel addressable memory only */ + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; + pTile = pGC->tile.pixmap ; + tileWidth = pTile->drawable.width ; + + xSrc = pGC->patOrg.x + pDrawable->x; + ySrc = pGC->patOrg.y + pDrawable->y; + /* this replaces rotating the tile. Instead we just adjust the offset + * at which we start grabbing bits from the tile */ + for ( ; n-- ; ppt++, pwidth++ ) { + pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ) + + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) ) + + ppt->x ; + psrcT = (unsigned char *) pTile->devPrivate.ptr + + ( modulo( ppt->y - ySrc, pTile->drawable.height) * pTile->devKind ) ; + + psrc = psrcT + modulo( ppt->x - xSrc, tileWidth ) ; + for ( i = *pwidth ; i-- ; pdst++, psrc++ ) { + if ( psrc >= ( psrcT + tileWidth ) ) + psrc = psrcT ; + { + unsigned _p; + DoRop( _p, alu, *psrc, *pdst ) ; + *pdst = ( *pdst & npm ) | ( pm & _p ) ; + } +#ifdef notdef /* PURDUE */ + *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, *psrc, *pdst ) ) ; +#endif /* PURDUE */ + } + } + xfree( pptFree ) ; + xfree( pwidthFree ) ; + return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcPixmap.c b/xorg-server/hw/xfree86/xf4bpp/ppcPixmap.c new file mode 100644 index 000000000..d04aacf82 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcPixmap.c @@ -0,0 +1,151 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <string.h> + +#include "xf4bpp.h" +#include "servermd.h" +#include "OScompiler.h" +#include "ibmTrace.h" +#include "scrnintstr.h" + +PixmapPtr +xf4bppCreatePixmap( pScreen, width, height, depth, usage_hint ) + ScreenPtr pScreen ; + int width ; + int height ; + int depth ; + unsigned usage_hint ; +{ + register PixmapPtr pPixmap = (PixmapPtr)NULL; + size_t size ; + + TRACE(("xf4bppCreatePixmap(pScreen=0x%x, width=%d, height=%d, depth=%d, usage_hint=%d)\n", pScreen, width, height, depth, usage_hint)) ; + + if ( depth > 8 ) + return (PixmapPtr) NULL ; + + size = PixmapBytePad(width, depth); + + if (size / 4 > 32767 || height > 32767) + return (PixmapPtr) NULL ; + + pPixmap = AllocatePixmap (pScreen, (height * size)); + + if ( !pPixmap ) + return (PixmapPtr) NULL ; + pPixmap->drawable.type = DRAWABLE_PIXMAP ; + pPixmap->drawable.class = 0 ; + pPixmap->drawable.pScreen = pScreen ; + pPixmap->drawable.depth = depth ; + pPixmap->drawable.id = 0 ; + pPixmap->drawable.bitsPerPixel = ( depth == 1 ) ? 1 : 8 ; + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER ; + pPixmap->drawable.x = 0 ; + pPixmap->drawable.y = 0 ; + pPixmap->drawable.width = width ; + pPixmap->drawable.height = height ; + pPixmap->devKind = size; + pPixmap->refcnt = 1 ; + size = height * pPixmap->devKind ; + pPixmap->devPrivate.ptr = (pointer) (((CARD8*)pPixmap) + + pScreen->totalPixmapSize); + bzero( (char *) pPixmap->devPrivate.ptr, size ) ; + pPixmap->usage_hint = usage_hint; + return pPixmap ; +} + +PixmapPtr +xf4bppCopyPixmap(pSrc) + register PixmapPtr pSrc; +{ + register PixmapPtr pDst; + int size; + + TRACE(("xf4bppCopyPixmap(pSrc=0x%x)\n", pSrc)) ; + size = pSrc->drawable.height * pSrc->devKind; + pDst = xalloc(sizeof(PixmapRec) + size); + if (!pDst) + return NullPixmap; + pDst->devPrivates = NULL; + pDst->drawable = pSrc->drawable; + pDst->drawable.id = 0; + pDst->drawable.serialNumber = NEXT_SERIAL_NUMBER; + pDst->devKind = pSrc->devKind; + pDst->refcnt = 1; + pDst->devPrivate.ptr = (pointer)(pDst + 1); + MOVE( (char *)pSrc->devPrivate.ptr, (char *)pDst->devPrivate.ptr, size ) ; + return pDst; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcPolyPnt.c b/xorg-server/hw/xfree86/xf4bpp/ppcPolyPnt.c new file mode 100644 index 000000000..c61fd6d26 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcPolyPnt.c @@ -0,0 +1,143 @@ +/* + +Copyright (c) 1987 X Consortium + +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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "scrnintstr.h" +#include "ppcGCstr.h" +#include "ibmTrace.h" + +void +xf4bppPolyPoint( pDrawable, pGC, mode, npt, pptInit ) +DrawablePtr pDrawable ; +GCPtr pGC ; +int mode ; /* Origin or Previous */ +int npt ; +xPoint *pptInit ; +{ +register xPoint *ppt ; +ppcPrivGC *devPriv ; +int alu ; +int nptTmp ; + +TRACE( ("xf4bppPolyPoint(0x%x,0x%x,%d,%d,0x%x)\n", + pDrawable, pGC, mode, npt, pptInit ) ) ; + +if ( pDrawable->type == DRAWABLE_PIXMAP ) { + if ( pGC->alu != GXnoop ) + miPolyPoint( pDrawable, pGC, mode, npt, pptInit ) ; + return ; +} + +devPriv = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); +if ( ( alu = devPriv->colorRrop.alu ) == GXnoop ) + return ; + +/* make pointlist origin relative */ +if ( mode == CoordModePrevious ) + for ( ppt = pptInit, nptTmp = npt ; --nptTmp ; ) { + ppt++ ; + ppt->x += (ppt-1)->x ; + ppt->y += (ppt-1)->y ; + } + +if ( pGC->miTranslate ) { + register int xorg = pDrawable->x ; + register int yorg = pDrawable->y ; + for ( ppt = pptInit, nptTmp = npt ; nptTmp-- ; ppt++ ) { + ppt->x += xorg ; + ppt->y += yorg ; + } +} + +{ + register RegionPtr pRegion = pGC->pCompositeClip ; + register unsigned long int fg = devPriv->colorRrop.fgPixel ; + register unsigned long int pm = devPriv->colorRrop.planemask ; + BoxRec box ; /* Scratch Space */ + + if ( ! REGION_NUM_RECTS(pRegion)) + return ; + + for ( ppt = pptInit ; npt-- ; ppt++ ) + if (POINT_IN_REGION(pDrawable->pScreen, pRegion, + ppt->x, ppt->y, &box)) + xf4bppFillSolid( (WindowPtr)pDrawable, + fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ; +} + +return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcQuery.c b/xorg-server/hw/xfree86/xf4bpp/ppcQuery.c new file mode 100644 index 000000000..d42360da5 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcQuery.c @@ -0,0 +1,46 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" + +void +xf4bppQueryBestSize +( + register int class, + register unsigned short *pwidth, + register unsigned short *pheight, + ScreenPtr pScreen +) +{ +if ( class == CursorShape ) + *pwidth = *pheight = 32 ; /* ppc's cursor max out at 32 by 32 */ +else /* either TileShape or StippleShape */ + /* Round Up To Nearest Multiple Of 8 -- We don't care what height they use */ + *pwidth = ( *pwidth + 0x7 ) & ~ 0x7 ; + +return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcRslvC.c b/xorg-server/hw/xfree86/xf4bpp/ppcRslvC.c new file mode 100644 index 000000000..0337feb62 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcRslvC.c @@ -0,0 +1,177 @@ +/************************************************************ +Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright no- +tice appear in all copies and that both that copyright no- +tice and this permission notice appear in supporting docu- +mentation, and that the names of Sun or X Consortium +not be used in advertising or publicity pertaining to +distribution of the software without specific prior +written permission. Sun and X Consortium make no +representations about the suitability of this software for +any purpose. It is provided "as is" without any express or +implied warranty. + +SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- +NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- +ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* Generic Color Resolution Scheme + * P. Shupak 12/31/87 + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "scrnintstr.h" + +/* + * New colormap routines that can support multiple Visual types. + */ + +static unsigned short defstaticpalette[16][3] = { + /* R G B */ + { 0x0000, 0x0000, 0x0000 }, /* black */ + { 0xFFFF, 0xFFFF, 0xFFFF }, /* white */ + { 0xAAAA, 0xAAAA, 0xAAAA }, /* grey */ + { 0x0000, 0x0000, 0xAAAA }, /* dark blue */ + { 0x0000, 0x0000, 0xFFFF }, /* medium blue */ + { 0x0000, 0xAAAA, 0xFFFF }, /* light blue */ + { 0x0000, 0xFFFF, 0xFFFF }, /* cyan */ + { 0x0000, 0xAAAA, 0x0000 }, /* dark green */ + { 0x0000, 0xFFFF, 0x0000 }, /* green */ + { 0xAAAA, 0xFFFF, 0x5555 }, /* pale green */ + { 0xAAAA, 0x5555, 0x0000 }, /* brown */ + { 0xFFFF, 0xAAAA, 0x0000 }, /* light brown */ + { 0xFFFF, 0xFFFF, 0x0000 }, /* yellow */ + { 0xAAAA, 0x0000, 0xAAAA }, /* purple */ + { 0xFFFF, 0x0000, 0xFFFF }, /* magenta */ + { 0xFFFF, 0x0000, 0x0000 }, /* red */ + }; + +Bool +xf4bppInitializeColormap(pmap) + register ColormapPtr pmap; +{ + register unsigned i; + register VisualPtr pVisual; + unsigned lim, maxent, shift; + + pVisual = pmap->pVisual; + lim = (1 << pVisual->bitsPerRGBValue) - 1; + shift = 16 - pVisual->bitsPerRGBValue; + maxent = pVisual->ColormapEntries - 1; + + switch( pVisual->class ) + { + case StaticGray: + for ( i = 0 ; i < maxent ; i++ ) { + pmap->red[i].co.local.red = + pmap->red[i].co.local.green = + pmap->red[i].co.local.blue = + ((((i * 65535) / maxent) >> shift) * 65535) / lim; + } + break; + case StaticColor: + for ( i = 0 ; i < 16 ; i++ ) { + pmap->red[i].co.local.red = (defstaticpalette[i][0]); + pmap->red[i].co.local.green = (defstaticpalette[i][1]); + pmap->red[i].co.local.blue = (defstaticpalette[i][2]); + } + break; + case GrayScale: + case PseudoColor: + for(i=0;i<=maxent;i++) { + int a,b,c; + a = i << 10; + b = i << 12; + c = i << 14; + pmap->red[i].co.local.red = a; + pmap->red[i].co.local.green = b; + pmap->red[i].co.local.blue = c; + } + break; + case TrueColor: + case DirectColor: + default: + ErrorF( "Unsupported Visual class %d\b", pVisual->class ); + return FALSE; + } + return TRUE; +} + +void +xf4bppResolveColor( pred, pgreen, pblue, pVisual ) +register unsigned short* pred ; +register unsigned short* pgreen ; +register unsigned short* pblue ; +register VisualPtr pVisual ; +{ + unsigned lim, maxent, shift; + + lim = (1 << pVisual->bitsPerRGBValue) - 1; + shift = 16 - pVisual->bitsPerRGBValue; + maxent = pVisual->ColormapEntries - 1; + + switch( pVisual->class ) + { + case StaticGray: + *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100; + *pred = (((*pred * (maxent + 1)) >> 16) * 65535) / maxent; + *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim; + break; + case StaticColor: + break; + case GrayScale: + *pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100; + *pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim; + break; + case PseudoColor: + /* rescale to rgb bits */ + *pred = ((*pred >> shift) * 65535) / lim; + *pgreen = ((*pgreen >> shift) * 65535) / lim; + *pblue = ((*pblue >> shift) * 65535) / lim; + break; + case TrueColor: + case DirectColor: + default: + ErrorF( "Unsupported Visual class %d\b", pVisual->class ); + } +} + diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcSetSp.c b/xorg-server/hw/xfree86/xf4bpp/ppcSetSp.c new file mode 100644 index 000000000..7659384e7 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcSetSp.c @@ -0,0 +1,319 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +/*********************************************************** + +Copyright (c) 1987 X Consortium + +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 +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "mfbmap.h" +#include "mfb.h" +#include "servermd.h" + +/* SetScanline -- copies the bits from psrc to the drawable starting at + * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc + * starts on the scanline. (I.e., if this scanline passes through multiple + * boxes, we may not want to start grabbing bits at psrc but at some offset + * further on.) + */ +static void +ppcSetScanline +( + register int pixCount, /* width of scanline in bits */ + register char *psrc, + register unsigned char *pdst, /* where to put the bits */ + register int pm, /* plane mask */ + const int alu /* raster op */ +) +{ +register int npm = ~pm ; /* inverted plane mask */ +register char tmpx ; + +pm &= 0x0F; npm &= 0x0F; /* GJA */ + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + while ( pixCount-- ) + *pdst++ &= npm ; + break ; + case GXand: /* 0x1 src AND dst */ + while ( pixCount-- ) + *pdst++ &= *psrc++ | npm ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & *psrc & ~tmpx ) ; + } + break ; + case GXcopy: /* 0x3 src */ + for ( ; pixCount-- ; pdst++, psrc++ ) + *pdst = ( *pdst & npm ) | ( pm & *psrc ) ; + break ; + case GXandInverted: /* 0x4 NOT src AND dst */ + while ( pixCount-- ) + *pdst++ &= npm | ~*psrc++ ; + break ; + case GXnoop: /* 0x5 dst */ + break ; + case GXxor: /* 0x6 src XOR dst */ + while ( pixCount-- ) + *pdst++ ^= pm & *psrc++ ; + break ; + case GXor: /* 0x7 src OR dst */ + while ( pixCount-- ) + *pdst++ |= *psrc++ & pm ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & ~( tmpx | *psrc ) ) ; + } + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + while ( pixCount-- ) + *pdst++ ^= pm & ~ *psrc++ ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & ( *psrc | ~tmpx ) ) ; + } + break ; + case GXinvert: /* 0xa NOT dst */ + while ( pixCount-- ) + *pdst++ ^= pm ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + for ( ; pixCount-- ; pdst++, psrc++ ) + *pdst = ( *pdst & npm ) | ( pm & ~ *psrc ) ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + while ( pixCount-- ) + *pdst++ |= pm & ~ *psrc++ ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + for ( ; pixCount-- ; pdst++, psrc++ ) { + tmpx = *pdst; + *pdst = ( tmpx & npm ) | ( pm & ~( tmpx & *psrc ) ) ; + } + break ; + case GXset: /* 0xf 1 */ + while ( pixCount-- ) + *pdst++ |= pm ; + break ; + default: + ErrorF( "ppcSetScanLine: bad alu value == 0x%02X\n", alu ) ; + break ; +} + +return ; +} + +/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at + * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines + * are in increasing Y order. + * Source bit lines are server scanline padded so that they always begin + * on a word boundary. + */ +void +xf4bppSetSpans( pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted ) + register DrawablePtr pDrawable ; + GCPtr pGC ; + char *psrc ; + register DDXPointPtr ppt ; + int *pwidth ; + int nspans ; + int fSorted ; +{ + unsigned char *pdstBase = NULL; /* start of dst bitmap */ + int widthDst = 0; /* width of bitmap in words */ + register BoxPtr pbox, pboxLast, pboxTest ; + register DDXPointPtr pptLast ; + RegionPtr prgnDst ; + register int width ; + int xStart, xEnd ; + int yMax ; + int alu ; + int pm ; + + /* allow for 1-deep windows on nfb machines (eg apa8, aed) */ + if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) { + mfbSetSpans( pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted ) ; + return ; + } + + if ( !( pm = pGC->planemask & ~( (~0) << pDrawable->depth ) ) + || ( ( alu = pGC->alu ) == GXnoop ) ) + return ; + + prgnDst = pGC->pCompositeClip ; + + if ( ! REGION_NUM_RECTS(prgnDst)) + return ; + + pboxLast = ( pbox = REGION_RECTS(prgnDst) ) + REGION_NUM_RECTS(prgnDst); + pptLast = ppt + nspans ; + + if ( pDrawable->type == DRAWABLE_WINDOW ) { + yMax = (int) pDrawable->height + pDrawable->y ; + } + else { + pdstBase = (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr ; + widthDst = (int) ( (PixmapPtr) pDrawable )->devKind ; + yMax = pDrawable->height ; + } + + if ( fSorted ) { + /* scan lines sorted in ascending order. Because they are sorted, we + * don't have to check each scanline against each clip box. We can be + * sure that this scanline only has to be clipped to boxes at or after the + * beginning of this y-band + */ + for ( pboxTest = pbox ; + ( ppt < pptLast ) && ( ppt->y < yMax ) ; + ppt++, pwidth++, + psrc += PixmapBytePad( width, pDrawable->depth ) ) { + width = *pwidth ; + for ( pbox = pboxTest ; + pbox < pboxLast ; + pbox++ ) { + if ( pbox->y2 <= ppt->y ) { + /* clip box is before scanline */ + pboxTest = pbox + 1 ; + } + else if ( ( pbox->y1 > ppt->y ) + || ( pbox->x1 > ppt->x + width ) ) + break ; /* scanline before clip box or left of clip box */ + else if ( pbox->x2 > ppt->x ) { + /* some of the scanline is in the current clip box */ + xStart = MAX( pbox->x1, ppt->x ) ; + xEnd = MIN( ppt->x + width, pbox->x2 ) ; + if ( pDrawable->type == DRAWABLE_PIXMAP ) + ppcSetScanline( xEnd - xStart, + psrc + ( xStart - ppt->x ), + pdstBase + xStart + + ( ppt->y * widthDst ), + pm, alu ) ; + else + xf4bppDrawColorImage( (WindowPtr)pDrawable, + xStart, ppt->y, xEnd - xStart, 1, + (unsigned char *)psrc + ( xStart - ppt->x ), + xEnd - xStart, alu, pm ) ; + if ( ppt->x + width <= pbox->x2 ) + break ; /* End of the line, as it were */ + } + } + /* We've tried this line against every box ; it must be outside them + * all. move on to the next point */ + } + } + else { + /* scan lines not sorted. We must clip each line against all the boxes */ + for ( ; + ppt < pptLast ; + ppt++, pwidth++, + psrc += PixmapBytePad( width, pDrawable->depth ) ) { + width = *pwidth ; + if ( ppt->y >= 0 && ppt->y < yMax ) { + for ( pbox = REGION_RECTS(prgnDst) ; pbox < pboxLast ; pbox++ ) { + if ( pbox->y1 > ppt->y ) + break ; /* rest of clip region is above this scanline */ + else if ( ( pbox->y2 > ppt->y ) + && ( pbox->x1 <= ppt->x + width ) + && ( pbox->x2 > ppt->x ) ) { + xStart = MAX( pbox->x1, ppt->x ) ; + xEnd = MIN( pbox->x2, ppt->x + width ) ; + if ( pDrawable->type == DRAWABLE_PIXMAP ) + ppcSetScanline( xEnd - xStart, + psrc + ( xStart - ppt->x ), + /* ^ GJA */ + ( ( pdstBase + + ( ppt->y * widthDst ) ) + + xStart ), + pm, alu ) ; + else /* pDrawable->type == DRAWABLE_WINDOW */ + xf4bppDrawColorImage( (WindowPtr)pDrawable, + xStart, ppt->y, xEnd - xStart, 1, + (unsigned char *)psrc + ( xStart - ppt->x ), + /* GJA ^ */ + xEnd - xStart, alu, pm ) ; + } + + } + } + } + } + return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcSpMcro.h b/xorg-server/hw/xfree86/xf4bpp/ppcSpMcro.h new file mode 100644 index 000000000..655a883e5 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcSpMcro.h @@ -0,0 +1,43 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +/* This screwy macro is used in all the spans routines and you find + it all over the place, so it is a macro just to tidy things up. +*/ + +#define SETSPANPTRS(IN,N,IPW,PW,IPPT,PPT,FPW,FPPT,FSORT) \ + { \ + N = IN * miFindMaxBand(pGC->pCompositeClip); \ + if(!(PW = (int *)xalloc(N * sizeof(int)))) \ + return; \ + if(!(PPT = (DDXPointRec *)xalloc(N * sizeof(DDXPointRec)))) \ + { \ + free(PW); \ + return; \ + } \ + FPW = PW; \ + FPPT = PPT; \ + N = miClipSpans(pGC->pCompositeClip, IPPT, IPW, IN, \ + PPT, PW, FSORT); \ + } + diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcWinFS.c b/xorg-server/hw/xfree86/xf4bpp/ppcWinFS.c new file mode 100644 index 000000000..1522afd9e --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcWinFS.c @@ -0,0 +1,280 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +/****************************************************************** +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "mispans.h" +#include "ppcGCstr.h" +#include "ppcSpMcro.h" +#include "ibmTrace.h" + +#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 ) +/* +********** ********** ********** ********** ********** ********** ********** + these routines all clip. they assume that anything that has called +them has already translated the points (i.e. pGC->miTranslate is +non-zero, which is howit gets set in mfbCreateGC().) + + the number of new scanlines created by clipping == +MaxRectsPerBand * nSpans. +********** ********** ********** ********** ********** ********** ********** +*/ + +void +xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) + DrawablePtr pDrawable ; + GCPtr pGC ; + int nInit ; /* number of spans to fill */ + DDXPointPtr pptInit ; /* pointer to list of start points */ + int *pwidthInit ; /* pointer to list of n widths */ + int fSorted ; +{ + register unsigned long int pm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppSolidWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pDrawable->type != DRAWABLE_WINDOW ) { + ErrorF( "xf4bppSolidWindowFS: drawable is not a window\n") ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) + return ; + + n = nInit * miFindMaxBand( pGC->pCompositeClip ) ; + if ( !( pwidthFree = (int *) xalloc( n * sizeof( int ) ) ) ) + return ; + pwidth = pwidthFree ; + + if ( !( pptFree = (DDXPointRec *) + xalloc( n * sizeof( DDXPointRec ) ) ) ) { + xfree( pwidth ) ; + return ; + } + ppt = pptFree ; + + n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, + ppt, pwidth, fSorted ) ; + + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + + for ( ; n-- ; ppt++, pwidth++ ) + if ( *pwidth ) + xf4bppFillSolid( (WindowPtr)pDrawable, + fg, alu, pm, ppt->x, ppt->y, *pwidth, 1 ) ; + + xfree( pptFree ) ; + xfree( pwidthFree ) ; + return ; +} + +void +xf4bppStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +register GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register unsigned long int pm ; + register unsigned long int fg ; + register int alu ; + /* next three parameters are post-clip */ + int n ; /* number of spans to fill */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + PixmapPtr pTile ; /* pointer to tile we want to fill with */ + int xSrc ; + int ySrc ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pDrawable->type != DRAWABLE_WINDOW ) { + ErrorF( "xf4bppStippleWindowFS: drawable is not a window\n" ) ; + return ; + } + + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF("ppcStippleFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, + pptFree, pwidth, ppt, fSorted ) ; + + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + + xSrc = pGC->patOrg.x + pDrawable->x ; + ySrc = pGC->patOrg.y + pDrawable->y ; + pTile = pGC->stipple ; + + for ( ; n-- ; ppt++, pwidth++ ) + xf4bppFillStipple( (WindowPtr)pDrawable, pTile, fg, alu, pm, + ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ; + + xfree( pptFree ) ; + xfree( pwidthFree ) ; + + return ; +} + +void +xf4bppOpStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +register GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + int n ; /* number of spans to fill */ + int xSrc ; + int ySrc ; + unsigned long int pm ; + unsigned long int fg, bg ; + int alu ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppOpStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( pGC->stipple->drawable.depth != 1 ) { + ErrorF( "xf4bppOpStippleWindowFS: bad depth\ntype = %d, depth = %d\n", + pDrawable->type, pGC->stipple->drawable.depth ) ; + return ; + } + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, + pptFree, pwidth, ppt, fSorted ) ; + + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ; + + xSrc = pGC->patOrg.x + pDrawable->x ; + ySrc = pGC->patOrg.y + pDrawable->y ; + + for ( ; n-- ; ppt++, pwidth++ ) + xf4bppOpaqueStipple( (WindowPtr)pDrawable, pGC->stipple, fg, bg, alu, pm, + ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ; + + xfree( pptFree ) ; + xfree( pwidthFree ) ; + return ; +} + +void +xf4bppTileWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) +DrawablePtr pDrawable ; +register GC *pGC ; +int nInit ; /* number of spans to fill */ +DDXPointPtr pptInit ; /* pointer to list of start points */ +int *pwidthInit ; /* pointer to list of n widths */ +int fSorted ; +{ + /* next three parameters are post-clip */ + register DDXPointPtr ppt ; /* pointer to list of start points */ + register int *pwidth ; /* pointer to list of n widths */ + int n ; /* number of spans to fill */ + unsigned char pm ; + int alu ; + int xSrc ; + int ySrc ; + int *pwidthFree ; /* copies of the pointers to free */ + DDXPointPtr pptFree ; + + TRACE( ( "xf4bppTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", + pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; + + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) + return ; + + SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, + pptFree, pwidth, ppt, fSorted ) ; + + xSrc = pGC->patOrg.x + pDrawable->x ; + ySrc = pGC->patOrg.y + pDrawable->y ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + + for ( ; n-- ; ppt++, pwidth++ ) + xf4bppTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm, + ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ; + + xfree( pptFree ) ; + xfree( pwidthFree ) ; + return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/ppcWindow.c b/xorg-server/hw/xfree86/xf4bpp/ppcWindow.c new file mode 100644 index 000000000..6165e04b6 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/ppcWindow.c @@ -0,0 +1,220 @@ +/* + +Copyright (c) 1987 X Consortium + +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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "scrnintstr.h" +#include "ibmTrace.h" + +/* + xf4bppCopyWindow copies only the parts of the destination that are +visible in the source. +*/ + +void +xf4bppCopyWindow(pWin, ptOldOrg, prgnSrc) + register WindowPtr pWin ; + DDXPointRec ptOldOrg ; + RegionPtr prgnSrc ; +{ + RegionPtr prgnDst ; + register BoxPtr pbox ; + register int dx, dy ; + register int nbox ; + register int pm ; + + BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew ; + /* temporaries for shuffling rectangles */ + + TRACE(("xf4bppCopyWindow(pWin= 0x%x, ptOldOrg= 0x%x, prgnSrc= 0x%x)\n", pWin, ptOldOrg, prgnSrc)) ; + + + dx = ptOldOrg.x - pWin->drawable.x ; + dy = ptOldOrg.y - pWin->drawable.y ; + REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); + + prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1); + REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, + &pWin->borderClip, prgnSrc); + + if ( !( nbox = REGION_NUM_RECTS(prgnDst) ) ) + return; + + pbox = REGION_RECTS(prgnDst); + + pboxNew = 0 ; + if ( nbox > 1 ) { + if ( dy < 0 ) { + if ( dx > 0 ) { + /* walk source bottom to top */ + /* keep ordering in each band, reverse order of bands */ + if ( !( pboxNew = + (BoxPtr) xalloc( sizeof( BoxRec ) * nbox ) ) ) + return ; + pboxBase = pboxNext = pbox+nbox - 1 ; + while ( pboxBase >= pbox ) { + while ( ( pboxNext >= pbox ) + && ( pboxBase->y1 == pboxNext->y1 ) ) + pboxNext-- ; + pboxTmp = pboxNext + 1 ; + while ( pboxTmp <= pboxBase ) + *pboxNew++ = *pboxTmp++ ; + pboxBase = pboxNext ; + } + pboxNew -= nbox ; + pbox = pboxNew ; + } + else { /* dx <= 0 */ + /* we can just reverse the entire list in place */ + /* Do three-position swaps */ + BoxRec tmpBox ; + + pboxBase = pbox ; + pboxNext = pbox + nbox - 1 ; + while ( pboxBase < pboxNext ) { + /* ****** Warning Structure Assignment !! ****** */ + tmpBox = *pboxBase ; + *pboxBase = *pboxNext ; + *pboxNext = tmpBox ; + pboxBase++ ; + pboxNext-- ; + } + } + } + else if ( dx < 0 ) { + /* walk source right to left */ + /* reverse order of rects in each band */ + if ( !( pboxNew = (BoxPtr)xalloc(sizeof(BoxRec) * nbox) ) ) + return ; + pboxBase = pboxNext = pbox ; + while (pboxBase < pbox+nbox) + { + while ((pboxNext < pbox+nbox) && + (pboxNext->y1 == pboxBase->y1)) + pboxNext++ ; + pboxTmp = pboxNext ; + while (pboxTmp != pboxBase) + *pboxNew++ = *--pboxTmp ; + pboxBase = pboxNext ; + } + pboxNew -= nbox ; + pbox = pboxNew ; + } + } /* END if nbox > 1 */ + + /* + * call blit several times, the parms are: + * blit( alu,rplanes, wplanes, srcx, srcy, destx, desty, width, height ) ; + */ + + pm = ( 1 << pWin->drawable.depth ) - 1 ; + for ( ; nbox-- ; pbox++ ) + xf4bppBitBlt( pWin, GXcopy, pm, + pbox->x1 + dx, pbox->y1 + dy, + pbox->x1, pbox->y1, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1) ; + + /* free up stuff */ + if ( pboxNew ) + xfree( pboxNew ) ; + + REGION_DESTROY(pWin->drawable.pScreen, prgnDst); +} + +Bool xf4bppPositionWindow(pWin, x, y) +register WindowPtr pWin ; +register int x, y ; +{ + return TRUE ; +} + +Bool +xf4bppDestroyWindow(pWin) +register WindowPtr pWin ; +{ +return pWin ? TRUE : FALSE ; +} + +/* As The Name Says -- Used For ega, vga and apa8c */ +Bool +xf4bppCreateWindowForXYhardware(pWin) +register WindowPtr pWin ; +{ + TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin)); + + return TRUE; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/vgaBitBlt.c b/xorg-server/hw/xfree86/xf4bpp/vgaBitBlt.c new file mode 100644 index 000000000..2e89f43b7 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgaBitBlt.c @@ -0,0 +1,749 @@ +/* GJA -- span move routines */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#ifndef PC98_EGC /* not PC98_EGC */ +/* NOTE: It seems that there is no way to program the VGA to copy just + * a part of a byte in the smarter modes. Therefore we copy the boundaries + * plane by plane. + */ +#define WORDSZ 8 + /* The fast blit code requires WORDSZ = 8 for its read-modify write cycle. + * Therefore, we do not fully implement the other options. + */ +#define HIGHPLANEMASK 0x08 +#define HIGHPLANEINDEX 3 + +/* Of course, we want the following anyway: + * (Yes, they're identical now.) + */ +#define SMEM(x,y) ( VIDBASE(pWin) + (y) * BYTES_PER_LINE(pWin) + (x) ) +#define DMEM(x,y) ( VIDBASE(pWin) + (y) * BYTES_PER_LINE(pWin) + (x) ) + +#define WORD8 unsigned char +#define LW8 BYTES_PER_LINE(pWin) /* Line width */ +#define WSHIFT8 0x3 +#define WMASK8 0x07 +/* NOTE: lmask[8] matters. It must be different from lmask[0] */ +static unsigned char lmasktab[] = { + 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF +} ; +static unsigned char rmasktab[] = { + 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00 +} ; + +#define LMASK8(n) lmasktab[n] +#define RMASK8(n) rmasktab[n] +#define SWAPB8(x) (x) + +#if (WORDSZ == 8) + +#define WORD WORD8 +#define LW LW8 +#define WSHIFT WSHIFT8 +#define WMASK WMASK8 + +#define LMASK(n) LMASK8(n) +#define RMASK(n) RMASK8(n) +#define SWAPB(x) SWAPB8(x) + +#endif /* WORDSZ == 8 */ + +#define DO_ALU(dst,src,mask,alu) {\ + int _ndst, _odst; _odst = dst; \ + switch ( alu ) { \ + case GXclear: \ + _ndst = 0; break; \ + case GXand: \ + _ndst = src & _odst; break; \ + case GXandReverse: \ + _ndst = src & ~ _odst; break; \ + case GXcopy: \ + _ndst = src; break; \ + case GXandInverted: \ + _ndst = ~ src & _odst; break; \ + default: \ + case GXnoop: \ + _ndst = _odst; break; \ + case GXxor: \ + _ndst = src ^ _odst; break; \ + case GXor: \ + _ndst = src | _odst; break; \ + case GXnor: \ + _ndst = ~ src & ~ _odst; break; \ + case GXequiv: \ + _ndst = ~ src ^ _odst; break; \ + case GXinvert: \ + _ndst = ~ _odst; break; \ + case GXorReverse: \ + _ndst = src | ~ _odst; break; \ + case GXcopyInverted: \ + _ndst = ~ src; break; \ + case GXorInverted: \ + _ndst = ~ src | _odst; break; \ + case GXnand: \ + _ndst = ~ src | ~ _odst; break; \ + case GXset: \ + _ndst = ~0; break; \ + } \ + dst = (_odst & ~(mask)) | (_ndst & (mask)); \ + } + +static void aligned_blit( + WindowPtr, int, int, int, int, int, int, int, int +); + +static void aligned_blit_center( + WindowPtr, int, int, int, int, int, int +); + +static void shift( + WindowPtr, int, int, int, int, int, int, int +); + +static void shift_thin_rect( + WindowPtr, int, int, int, int, int, int, int +); + +static void shift_center( + WindowPtr, int, int, int, int, int, int, int +); + +void xf4bppBitBlt(pWin,alu,writeplanes,x0,y0,x1,y1,w,h) +WindowPtr pWin; /* GJA */ +int alu; +int writeplanes; /* planes */ +int x0, y0, x1, y1, w, h; +{ + IOADDRESS REGBASE; + int plane, bit; + + if ( !w || !h ) return; + + if ( ! xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffBitBlt(pWin,alu,writeplanes,x0,y0,x1,y1,w,h); + return; + } + + REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; + + /* 0x7, not WMASK: it is hardware dependant */ + if ( ((x0 - x1) & 0x7) || (alu != GXcopy) ) { + /* Use slow copy */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX ; + plane ; plane >>= 1, bit-- ) + { + + if ( writeplanes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift(pWin,x0,x1,y0,y1,w,h,alu); + } + } + } else { + aligned_blit(pWin,x0,x1,y0,y1,w,h,alu,writeplanes); + } +} + +/* Copy a span a number of places to the right. + */ +static void +shift(pWin,x0,x1,y0,y1,w,h,alu) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +{ + if ( ((x1 & WMASK) + w) <= WORDSZ ) { + shift_thin_rect(pWin,x0,x1,y0,y1,w,h,alu); + } else if ( x1 > x0 ) { /* Shift right: start right */ + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( r1 ) /* right edge */ + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + shift_center(pWin,x0,x1,y0,y1,w,h,alu); + if ( l1 ) /* left edge */ + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + } else { + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( l1 ) /* left edge */ + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + shift_center(pWin,x0,x1,y0,y1,w,h,alu); + if ( r1 ) /* right edge */ + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + } +} + +/* The whole rectangle is so thin that it fits in one byte written */ +static void +shift_thin_rect(pWin,x0,x1,y0,y1,w,h,alu) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +{ + int l0 = x0 & WMASK; /* Left edge of source, as bit */ + int l1 = x1 & WMASK; /* Left edge of target, as bit */ + int L0 = x0 >> WSHIFT; /* Left edge of source, as byte */ + int L1 = x1 >> WSHIFT; /* Left edge of target, as byte */ + int pad; + int htmp; + int mask; + int tmp; + int bs; + + volatile unsigned char *sp, *dp; + + mask = RMASK(l1) & LMASK(l1+w); + bs = (x1 - x0) & WMASK; + + if ( y1 > y0 ) { /* Move down, start at the bottom */ + pad = - BYTES_PER_LINE(pWin); + sp = SMEM(L0,y0+h-1); + dp = DMEM(L1,y1+h-1); + } else { /* Move up, start at the top */ + pad = BYTES_PER_LINE(pWin); + sp = SMEM(L0,y0); + dp = DMEM(L1,y1); + } + + if ( l0+w > WORDSZ ) { + /* Need two bytes */ + for ( htmp = h ; htmp ; htmp-- ) { + tmp = (sp[0] << (WORDSZ - bs)); + sp++; + tmp |= (sp[0] >> bs); + sp--; + DO_ALU(dp[0],tmp,mask,alu); + dp += pad; + sp += pad; + } + } else if ( l0 <= l1 ) { + /* Need one byte, shifted right */ + for ( htmp = h ; htmp ; htmp-- ) { + tmp = (sp[0] >> bs); + DO_ALU(dp[0],tmp,mask,alu); + dp += pad; + sp += pad; + } + } else { + /* Need one byte, shifted left */ + for ( htmp = h ; htmp ; htmp-- ) { + tmp = (sp[0] << (WORDSZ - bs)); + DO_ALU(dp[0],tmp,mask,alu); + dp += pad; + sp += pad; + } + } +} + +static void +shift_center(pWin,x0,x1,y0,y1,w,h,alu) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +{ + int l1 = x1 & WMASK; /* Left edge of target, as bit */ + int r1 = (x1 + w) & WMASK; /* Right edge of target, as bit */ + int pad; + int htmp, wtmp; /* Temporaries for indices over height and width */ + volatile unsigned char tmp; /* Temporary result of the shifts */ + int bs; + int rem; /* Remaining bits; temporary in loop */ + int bytecnt; + + volatile unsigned char *sp, *dp; + + bs = (x1 - x0) & WMASK; + + if ( l1 ) { + bytecnt = (w - (WORDSZ - l1) - r1) >> WSHIFT; + sp = SMEM( ((x0 + (WORDSZ - l1)) >> WSHIFT), y0); + dp = DMEM( ((x1 + (WORDSZ - l1)) >> WSHIFT), y1); + } else { + bytecnt = (w - r1) >> WSHIFT; + sp = SMEM( (x0 >> WSHIFT), y0); + dp = DMEM( (x1 >> WSHIFT), y1); + } + + if ( y1 > y0 ) { /* Move down, start at the bottom */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = - BYTES_PER_LINE(pWin) + bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + dp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + } else { /* Move left, start left */ + pad = - BYTES_PER_LINE(pWin) - bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1); + dp += BYTES_PER_LINE(pWin) * (h - 1); + } + } else { /* Move up, start at the top */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = BYTES_PER_LINE(pWin) + bytecnt; + sp += bytecnt - 1; + dp += bytecnt - 1; + } else { /* Move left, start left */ + pad = BYTES_PER_LINE(pWin) - bytecnt; + sp += 0; + dp += 0; + } + } + + if ( x1 > x0 ) { /* Move right, start right */ + if ( bs == 0 ) { /* No shift. Need one byte only */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + DO_ALU(dp[0],tmp,~0,alu); + dp--; + sp--; + } + dp += pad; + sp += pad; + } + } else { + for ( htmp = h ; htmp ; htmp-- ) { + if ( bytecnt ) { + sp++; + rem = sp[0]; + sp--; + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = (rem >> bs); + rem = sp[0]; + tmp |= (rem << (WORDSZ - bs)) ; + DO_ALU(dp[0],tmp,~0,alu); + dp--; + sp--; + } + } + dp += pad; + sp += pad; + } + } + } else { /* x1 <= x0 */ /* Move left, start left */ + if ( bs == 0 ) { /* No shift. Need one byte only */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + DO_ALU(dp[0],tmp,~0,alu); + dp++; + sp++; + } + dp += pad; + sp += pad; + } + } else { + for ( htmp = h ; htmp ; htmp-- ) { + if ( bytecnt ) { + rem = sp[0]; + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = (rem << (WORDSZ - bs)); + sp++; + rem = sp[0]; + sp--; + tmp |= (rem >> bs); + DO_ALU(dp[0],tmp,~0,alu); + dp++; + sp++; + } + } + dp += pad; + sp += pad; + } + } + } +} + +/* Copy a rectangle. + */ +static void +aligned_blit(pWin,x0,x1,y0,y1,w,h,alu,planes) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +int alu; +int planes; +{ + IOADDRESS REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; + int plane, bit; + + if ( ((x1 & WMASK) + w) <= WORDSZ ) { + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0,x1,y0,y1,w,h,alu); + } + } + } else if ( x1 > x0 ) { /* Shift right: start right */ + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( r1 ) { /* right edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + } + } + } + + /* Center */ + SetVideoGraphics(Graphics_ModeIndex, 1); /* Write mode 1 */ + SetVideoSequencer(Mask_MapIndex, planes); + + aligned_blit_center(pWin,x0,x1,y0,y1,w,h); + + if ( l1 ) { /* left edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + } + } + } + } else { + int l1 = x1 & WMASK, r1 = (x1 + w) & WMASK; + + if ( l1 ) { /* left edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0,x1,y0,y1,(WORDSZ-l1),h,alu); + } + } + } + + /* Center */ + SetVideoGraphics(Graphics_ModeIndex, 1); /* Write mode 1 */ + SetVideoSequencer(Mask_MapIndex, planes); + + aligned_blit_center(pWin,x0,x1,y0,y1,w,h); + + if ( r1 ) { /* right edge */ + SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ + SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ + SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ + SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ + + for ( plane = HIGHPLANEMASK, bit = HIGHPLANEINDEX ; + plane ; plane >>= 1, bit-- ) + { + if ( planes & plane) { + SetVideoGraphics(Read_Map_SelectIndex, bit); + SetVideoSequencer(Mask_MapIndex, plane); + + shift_thin_rect(pWin,x0+w-r1,x1+w-r1,y0,y1,r1,h,alu); + } + } + } + } +} + +static void +aligned_blit_center(pWin,x0,x1,y0,y1,w,h) +WindowPtr pWin; /* GJA */ +int x0; /* left edge of source */ +int x1; /* left edge of target */ +int y0; +int y1; +int w; /* length of source, and of target */ +int h; +{ + int l1 = x1 & WMASK; /* Left edge of target, as bit */ + int r1 = (x1 + w) & WMASK; /* Right edge of target, as bit */ + int pad; + int htmp, wtmp; /* Temporaries for indices over height and width */ + volatile unsigned char tmp; /* Temporary result of the shifts */ + int bytecnt; + + volatile unsigned char *sp, *dp; + + if ( l1 ) { + bytecnt = (w - (WORDSZ - l1) - r1) >> WSHIFT; + sp = SMEM( ((x0 + (WORDSZ - l1)) >> WSHIFT), y0); + dp = DMEM( ((x1 + (WORDSZ - l1)) >> WSHIFT), y1); + } else { + bytecnt = (w - r1) >> WSHIFT; + sp = SMEM( (x0 >> WSHIFT), y0); + dp = DMEM( (x1 >> WSHIFT), y1); + } + + if ( y1 > y0 ) { /* Move down, start at the bottom */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = - BYTES_PER_LINE(pWin) + bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + dp += BYTES_PER_LINE(pWin) * (h - 1) + bytecnt - 1; + } else { /* Move left, start left */ + pad = - BYTES_PER_LINE(pWin) - bytecnt; + sp += BYTES_PER_LINE(pWin) * (h - 1); + dp += BYTES_PER_LINE(pWin) * (h - 1); + } + } else { /* Move up, start at the top */ + if ( x1 > x0 ) { /* Move right, start right */ + pad = BYTES_PER_LINE(pWin) + bytecnt; + sp += bytecnt - 1; + dp += bytecnt - 1; + } else { /* Move left, start left */ + pad = BYTES_PER_LINE(pWin) - bytecnt; + sp += 0; + dp += 0; + } + } + + if ( x1 > x0 ) { /* Move right, start right */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + dp[0] = tmp; + dp--; + sp--; + } + dp += pad; + sp += pad; + } + } else { /* x1 <= x0 */ /* Move left, start left */ + for ( htmp = h ; htmp ; htmp-- ) { + for ( wtmp = bytecnt ; wtmp ; wtmp-- ) { + tmp = sp[0]; + dp[0] = tmp; + dp++; + sp++; + } + dp += pad; + sp += pad; + } + } +} +#else /* PC98_EGC */ + +static void +egc_fast_blt (pWin, alu, writeplanes, x0, y0, x1, y1, w, h) +WindowPtr pWin; +const int alu, writeplanes ; +register int x0, x1 ; +int y0, y1 ; +register int w, h ; +{ +register volatile unsigned char *src ; +register volatile unsigned char *dst ; +unsigned short *src_x ; +unsigned short *dst_x ; +int x_direction, y_interval ; +int src_off, dst_off ; +register int k, i ; +unsigned short ROP_value; + +src = (unsigned char *)SCREENADDRESS( pWin, 0, y0); +dst = (unsigned char *)SCREENADDRESS( pWin, 0, y1); + +/* Set Map Mask */ +outw(EGC_PLANE, ~(writeplanes & VGA_ALLPLANES)); +switch(alu) { +case GXnor: /* ~(S|D) */ + ROP_value = 0x2903; + break; +case GXandInverted: /* ~S&D */ + ROP_value = 0x290c; + break; +case GXand: /* S&D */ + ROP_value = 0x29c0; + break; +case GXequiv: /* ~S ^ D */ + ROP_value = 0x29c3; + break; +case GXxor: /* S^D */ + ROP_value = 0x293c; + break; +case GXandReverse: /* S&~D */ + ROP_value = 0x2930; + break; +case GXorReverse: /* S|~D */ + ROP_value = 0x29f3; + break; +case GXnand: /* ~(S&D) */ + ROP_value = 0x293f; + break; +case GXorInverted: /* ~S|D */ + ROP_value = 0x29cf; + break; +case GXor: /* S|D */ + ROP_value = 0x29fa; + break; +case GXcopyInverted: /* ~S */ + ROP_value = 0x290f; + break; +case GXcopy: /* S */ +default: + ROP_value = 0x29f0; +} +outw(EGC_MODE, ROP_value); +if ( y1 > y0 ) { + y_interval = - BYTES_PER_LINE(pWin) * 8 ; + src += BYTES_PER_LINE(pWin) * ( h - 1 ) ; + dst += BYTES_PER_LINE(pWin) * ( h - 1 ) ; +} +else { + y_interval = BYTES_PER_LINE(pWin) * 8 ; +} + +src = (unsigned char *)((int)src << 3) ; +dst = (unsigned char *)((int)dst << 3) ; + +if ( y1 > y0) { + x_direction = 0x1000 ; + src += x0 + w - 1 ; + dst += x1 + w - 1 ; +} else if ( y1 < y0 ) { + x_direction = 0 ; + src += x0 ; + dst += x1 ; +} else { + if ( x1 < x0 ) { + x_direction = 0 ; + src += x0 ; + dst += x1 ; + } else { + x_direction = 0x1000 ; + src += x0 + w - 1 ; + dst += x1 + w - 1 ; + } +} + outw ( EGC_LENGTH , w - 1 ) ; + +for ( ; h-- ; ) { + if ( x_direction ) { + src_off = 15 - (int)src & 0xf ; + dst_off = 15 - (int)dst & 0xf ; + } else { + src_off = (int)src & 0xf ; + dst_off = (int)dst & 0xf ; + } +#if defined(__NetBSD__) || defined(__OpenBSD__) + src_x = (unsigned short *)(((unsigned int)src >> 4 ) << 1) ; + dst_x = (unsigned short *)(((unsigned int)dst >> 4 ) << 1) ; +#else + src_x = (unsigned short *)(((int)src >> 4 ) << 1) ; + dst_x = (unsigned short *)(((int)dst >> 4 ) << 1) ; +#endif + k = ( src_off + w + 15 ) >> 4 ; + if ( src_off < dst_off ) { + if ( ((src_off + w - 1 ) >> 4) < ((dst_off + w - 1) >> 4)) k++ ; + } + if ( src_off > dst_off ) { + if ( ((src_off + w - 1) >> 4 ) == ((dst_off + w - 1) >> 4) ) k++ ; + if ( x_direction ) dst_x ++ ; + else dst_x -- ; + } + outw ( EGC_ADD , x_direction | src_off | dst_off << 4 ); + if ( x_direction ) { + wcopyl ( src_x, dst_x, k, VIDBASE(pWin) ) ; + } else { + wcopyr ( src_x, dst_x, k, VIDBASE(pWin) ) ; + } +src += y_interval ; +dst += y_interval ; +} +outw ( EGC_ADD, 0 ) ; +outw ( EGC_LENGTH , 0xf ); +return; +} + +void +xf4bppBitBlt( pWin,alu, writeplanes, x0, y0, x1, y1, w, h ) +WindowPtr pWin; /* GJA */ +int alu; +int writeplanes; /* planes */ +int x0, y0, x1, y1, w, h; +{ + if ( ! xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffBitBlt( pWin, alu, writeplanes, + x0, y0, x1, y1, w, h ); + return; + } + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppFillSolid( pWin, VGA_ALLPLANES, alu, writeplanes, x1, y1, w, h ) ; + /* x1, y1, GJA */ + case GXnoop: /* 0x5 dst */ + return ; + default: + break ; +} + +egc_fast_blt ( pWin, alu, writeplanes, x0, y0, x1, y1, w, h); +return; +} +#endif diff --git a/xorg-server/hw/xfree86/xf4bpp/vgaGC.c b/xorg-server/hw/xfree86/xf4bpp/vgaGC.c new file mode 100644 index 000000000..6495e5638 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgaGC.c @@ -0,0 +1,213 @@ +/* + +Copyright (c) 1987 X Consortium + +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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + + +Copyright IBM Corporation 1987,1988,1989 +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of IBM not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "mfbmap.h" +#include "mfb.h" +#include "mi.h" +#include "ppcGCstr.h" + +void +xf4bppChangeGCtype( pGC, devPriv ) +register GC *pGC ; +register ppcPrivGCPtr devPriv ; +{ + if ( devPriv->lastDrawableType == DRAWABLE_PIXMAP ) { + pGC->ops->CopyArea = miCopyArea ; + pGC->ops->PolyFillRect = miPolyFillRect ; + pGC->ops->PushPixels = miPushPixels ; + pGC->ops->PolyArc = miPolyArc ; + pGC->ops->PolyFillArc = miPolyFillArc ; + pGC->ops->PolySegment = miPolySegment ; + } + else { + pGC->ops->CopyArea = xf4bppCopyArea ; + pGC->ops->PolyFillRect = xf4bppPolyFillRect ; + pGC->ops->PushPixels = miPushPixels ; /* GJA */ + pGC->ops->PolyArc = xf4bppZeroPolyArc ; + pGC->ops->PolyFillArc = xf4bppPolyFillArc ; + pGC->ops->PolySegment = xf4bppSegmentSS ; + } + return; +} + +Mask +xf4bppChangeWindowGC( pGC, changes ) +register GC *pGC ; +register Mask changes ; +{ +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); +register unsigned long int idx ; /* used for stepping through bitfields */ + +#define LOWBIT( x ) ( x & - x ) /* Two's complement */ + while ((idx = LOWBIT(changes))) { + switch ( idx ) { + + case GCLineStyle: + case GCLineWidth: + pGC->ops->PolyArc = ( ( pGC->lineStyle == LineSolid ) + ? ( ( pGC->lineWidth == 0 ) ? xf4bppZeroPolyArc + : miPolyArc ) + : miPolyArc ) ; + pGC->ops->PolySegment = ( ( pGC->lineStyle == LineSolid ) + ? ( ( pGC->lineWidth == 0 ) + ? ( ( pGC->fillStyle == FillSolid ) ? + xf4bppSegmentSS : miPolySegment ) + : miPolySegment ) + : ( ( pGC->lineWidth == 0 ) + ? ( ( pGC->fillStyle == FillSolid ) ? + xf4bppSegmentSD : miPolySegment ) + : miPolySegment ) ) ; + pGC->ops->Polylines = ( ( pGC->lineStyle == LineSolid ) + ? ( ( pGC->lineWidth == 0 ) + ? ( (pGC->fillStyle == FillSolid ) ? + xf4bppLineSS : miZeroLine ) + : miWideLine ) + : ( ( pGC->lineWidth == 0 ) + ? ( (pGC->fillStyle == FillSolid ) ? + xf4bppLineSD : miWideDash ) + : miWideDash ) ) ; + /* + * If these are just square boxes with no funny business + * going on we can call the fast routine that draws + * rectangles without floating point. + */ +/* too buggy */ +#if 0 + if ( ( pGC->lineStyle == LineSolid ) + && ( pGC->joinStyle == JoinMiter ) + && ( pGC->lineWidth != 0 ) ) + pGC->ops->PolyRectangle = xf4bppPolyRectangle; + else +#endif + pGC->ops->PolyRectangle = miPolyRectangle; + + changes &= ~( GCLineStyle | GCLineWidth ) ; + break ; + case GCJoinStyle: + /* + * If these are just square boxes with no funny business + * going on we can call the fast routine that draws + * rectangles without floating point. + */ +/* too buggy */ +#if 0 + if ( ( pGC->lineStyle == LineSolid ) + && ( pGC->joinStyle == JoinMiter ) + && ( pGC->lineWidth != 0 ) ) + pGC->ops->PolyRectangle = xf4bppPolyRectangle; + else +#endif + pGC->ops->PolyRectangle = miPolyRectangle; + changes &= ~ idx ; /* i.e. changes &= ~ GCJoinStyle */ + break ; + + case GCBackground: + if ( pGC->fillStyle != FillOpaqueStippled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCBackground */ + break ; + } /* else Fall Through */ + case GCForeground: + if ( pGC->fillStyle == FillTiled ) { + changes &= ~ idx ; /* i.e. changes &= ~GCForeground */ + break ; + } /* else Fall Through */ + case GCFunction: + case GCPlaneMask: + case GCFillStyle: + { /* new_fill */ + int fillStyle = devPriv->colorRrop.fillStyle ; + /* install a suitable fillspans */ + if ( fillStyle == FillSolid ) + pGC->ops->FillSpans = xf4bppSolidWindowFS ; + else if ( fillStyle == FillStippled ) + pGC->ops->FillSpans = xf4bppStippleWindowFS ; + else if ( fillStyle == FillOpaqueStippled ) + pGC->ops->FillSpans = xf4bppOpStippleWindowFS ; + else /* fillStyle == FillTiled */ + pGC->ops->FillSpans = xf4bppTileWindowFS ; + } /* end of new_fill */ + changes &= ~( GCBackground | GCForeground + | GCFunction + | GCPlaneMask | GCFillStyle ) ; + break ; + + default: + ErrorF("xf4bppChangeWindowGC: Unexpected GC Change\n") ; + changes &= ~ idx ; /* Remove it anyway */ + break ; + } + } + return changes; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/vgaImages.c b/xorg-server/hw/xfree86/xf4bpp/vgaImages.c new file mode 100644 index 000000000..bea2d0a17 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgaImages.c @@ -0,0 +1,460 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#undef TRUE +#undef FALSE +#define TRUE 1 +#define FALSE 0 + +void +xf4bppDrawColorImage( pWin, x, y, w, h, data, RowIncrement, alu, planes ) +WindowPtr pWin; /* GJA */ +int x, y ; +register int w, h ; +unsigned char *data ; +register int RowIncrement ; +const int alu ; +const unsigned long int planes ; +{ +IOADDRESS REGBASE; +register unsigned long int tmp ; +register const unsigned char *src ; +register volatile unsigned char *dst ; +register int Pixel_Count ; +register unsigned int currMask ; +register unsigned int InitialMask ; +register volatile unsigned char *StartByte ; +unsigned int invert_source_data = FALSE ; +#ifdef PC98_EGC /* new EGC test */ +register unsigned char tmp1; +#endif + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffDrawColorImage( pWin, x, y, w, h, data, RowIncrement, alu, planes ); + return; + } +} /* End GJA */ + +{ + unsigned int invert_existing_data = FALSE ; + unsigned int data_rotate_value = VGA_COPY_MODE ; +#ifdef PC98_EGC + unsigned short ROP_value; +#endif + + REGBASE = 0x300 + + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase; + + switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + case GXinvert: /* 0xa NOT dst */ + case GXset: /* 0xf 1 */ + xf4bppFillSolid( pWin, VGA_ALLPLANES, alu, planes, x, y, w, h ) ; + case GXnoop: /* 0x5 dst */ + return ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = TRUE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + invert_source_data = TRUE ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE ; + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + invert_source_data = TRUE ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_AND_MODE ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_source_data = TRUE ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = TRUE ; + /* GJA -- moved this here */ + data_rotate_value = VGA_OR_MODE ; + break ; + case GXorInverted: /* 0xd NOT src OR dst */ + invert_source_data = TRUE ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + invert_source_data = TRUE ; + case GXcopy: /* 0x3 src */ + default: + break ; + } + +#ifdef PC98_EGC + /* Setup EGC Registers */ + switch(data_rotate_value) { +/* EGC MODE.. Cmp Read: Flase, WriteSource=ROP, ReadSource=CPU */ + case VGA_AND_MODE: + if (invert_existing_data) + ROP_value = EGC_AND_INV_MODE; + else + ROP_value = EGC_AND_MODE; + break; + case VGA_OR_MODE: + if (invert_existing_data) + ROP_value = EGC_OR_INV_MODE; + else + ROP_value = EGC_OR_MODE; + break; + case VGA_XOR_MODE: + if (invert_existing_data) + ROP_value = EGC_XOR_INV_MODE; + else + ROP_value = EGC_XOR_MODE; + break; + case VGA_COPY_MODE: + default: + ROP_value = EGC_COPY_MODE; + break; + } + outw(EGC_PLANE, ~(planes & VGA_ALLPLANES)); + outw(EGC_MODE, ROP_value); + outw(EGC_FGC, 0x0000); + tmp1 = 0; +#else + if ( invert_existing_data ) + xf4bppFillSolid( pWin, VGA_ALLPLANES, GXinvert, planes, x, y, w, h ) ; + /* Setup VGA Registers */ + SetVideoSequencer( Mask_MapIndex, planes & VGA_ALLPLANES ) ; + /* Set Raster Op */ + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_2 ) ; +#endif +} + +StartByte = SCREENADDRESS(pWin, x, y); +InitialMask = SCRRIGHT8( LeftmostBit, BIT_OFFSET( x ) ) ; +if ( invert_source_data ) +#ifdef PC98_EGC +#if 0 /* New EGC version */ + egc_image_invert ( StartByte, data, InitialMask, w, h, + RowIncrement ) ; +#else /* new EGC c version */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + if (tmp1 != (~*src & VGA_ALLPLANES)) { + tmp1 = ~*src & VGA_ALLPLANES; + /* set FGC */ + outw(EGC_FGC, ~*src & VGA_ALLPLANES); + } + *((VgaMemoryPtr) dst) = currMask; + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif /* new EGC */ +#else /* original */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + /* Set The Bit Mask Reg */ + SetVideoGraphics( Bit_MaskIndex, currMask ) ; + /* Read To Load vga Data Latches */ + tmp = *( (VgaMemoryPtr) dst ) ; + (void) tmp; + *( (VgaMemoryPtr) dst ) = ~ *src ; + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif +else /* invert_source_data == FALSE */ +#ifdef PC98_EGC +#if 0 /* new EGC version */ + egc_image ( StartByte, data, InitialMask, w, h, + RowIncrement ); +#else /* new EGC c version */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + if (tmp1 != *src & VGA_ALLPLANES) { + tmp1 = *src & VGA_ALLPLANES; + outw(EGC_FGC, tmp1); /* set FGC */ + } + *((VgaMemoryPtr) dst) = currMask; /* write with mask */ + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif /* new EGC version */ +#else /* original */ + for ( ; + h-- ; + data += RowIncrement, StartByte += BYTES_PER_LINE(pWin) ) { + dst = StartByte; + for ( src = data, + Pixel_Count = w, currMask = InitialMask ; + Pixel_Count-- ; + src++ ) { + /* Set The Bit Mask Reg */ + SetVideoGraphics( Bit_MaskIndex, currMask ) ; /* GJA */ + /* Read To Load vga Data Latches */ + tmp = *( (VgaMemoryPtr) dst ) ; + (void) tmp; + *( (VgaMemoryPtr) dst ) = *src ; + if ( currMask & RightmostBit ) { + currMask = LeftmostBit ; + dst++; + } + else + currMask = SCRRIGHT8( currMask, 1 ) ; + } + } +#endif /* original */ + +return ; +} + +#ifndef PC98_EGC +static unsigned long int +read8Z +( + IOADDRESS REGBASE, + register volatile unsigned char *screen_ptr +) +{ +register unsigned long int i ; +register unsigned long int j ; + +/* Read One Byte At A Time to get + * i == [ Plane 3 ] [ Plane 2 ] [ Plane 1 ] [ Plane 0 ] + * into a single register + */ +SetVideoGraphicsData( 3 ) ; +i = *( (VgaMemoryPtr) screen_ptr ) << 8 ; +SetVideoGraphicsData( 2 ) ; +i |= *( (VgaMemoryPtr) screen_ptr ) ; +i <<= 8 ; +SetVideoGraphicsData( 1 ) ; +i |= *( (VgaMemoryPtr) screen_ptr ) ; +i <<= 8 ; +SetVideoGraphicsData( 0 ) ; +i |= *( (VgaMemoryPtr) screen_ptr ) ; + +/* Push Bits To Get + * j == [Pixel 7][Pixel 6][Pixel 5][Pixel 4][Pixel 3][Pixel 2][Pixel 1][Pixel 0] + * into one register + */ + +j = ( i & 0x1 ) << 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; +j <<= 4 ; +j |= ( i >>= 1 ) & 0x1 ; + +j |= ( i & 0x2 ) << 28 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 24 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 20 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 16 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 12 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 8 ; +j |= ( ( i >>= 1 ) & 0x2 ) << 4 ; +j |= ( i >>= 1 ) & 0x2 ; + +j |= ( i & 0x4 ) << 28 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 24 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 20 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 16 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 12 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 8 ; +j |= ( ( i >>= 1 ) & 0x4 ) << 4 ; +j |= ( i >>= 1 ) & 0x4 ; + +j |= ( i & 0x8 ) << 28 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 24 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 20 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 16 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 12 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 8 ; +j |= ( ( i >>= 1 ) & 0x8 ) << 4 ; +j |= ( i >>= 1 ) & 0x8 ; + +return j ; +} +#endif /* not PC98_EGC */ + +void +xf4bppReadColorImage( pWin, x, y, lx, ly, data, RowIncrement ) +WindowPtr pWin; /* GJA */ +int x, y ; +int lx, ly ; +register unsigned char *data ; +int RowIncrement ; +{ +IOADDRESS REGBASE; +register unsigned long int tmp ; +register volatile unsigned char *src ; +volatile unsigned char *masterSrc ; +int savCenterWidth ; +int dx ; +int skip ; +int center_width ; +int ignore ; +int pad ; +unsigned char tmpc; + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffReadColorImage( pWin, x, y, lx, ly, data, RowIncrement ); + return; + } +} /* End GJA */ + +if ( ( lx <= 0 ) || ( ly <= 0 ) ) + return ; + + REGBASE = 0x300 + + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase; + +/* Setup VGA Registers */ +#ifndef PC98_EGC +SetVideoGraphicsIndex( Graphics_ModeIndex ) ; +tmpc = inb( GraphicsDataRegister ); +SetVideoGraphicsData( tmpc & ~0x8 ) ; /* Clear the bit */ +SetVideoGraphicsIndex( Read_Map_SelectIndex ) ; +#else +outw(EGC_MODE, 0x0800); +#endif + +skip = BIT_OFFSET( x ) ; +pad = RowIncrement - lx ; +ignore = BIT_OFFSET( x + lx ) ; +masterSrc = SCREENADDRESS( pWin, x, y ) ; +center_width = ROW_OFFSET( x + lx ) - ROW_OFFSET( ( x + 0x7 ) & ~0x7 ) ; + +#define SINGLE_STEP *data++ = tmp & VGA_ALLPLANES ; tmp >>= 4 + + +if ( center_width < 0 ) { + src = masterSrc; + for ( ; ly-- ; ) { + tmp = read8Z( REGBASE, src ) >> ( skip << 2 ) ; + for ( dx = lx + 1 ; --dx ; ) { + SINGLE_STEP ; + } + data += pad ; + src += BYTES_PER_LINE(pWin); + } +} else + for ( savCenterWidth = center_width ; + ly-- ; + center_width = savCenterWidth, + masterSrc += BYTES_PER_LINE(pWin) ) { + src = masterSrc ; + tmp = read8Z( REGBASE, src ) ; src++; + if ((dx = skip)) + tmp >>= ( dx << 2 ) ; + else + if ( lx < 8 ) { /* kludge -- GJA */ + --center_width ; /* kludge -- GJA */ + dx = 8 - lx ; /* kludge -- GJA */ + } else /* kludge -- GJA */ + --center_width ; + BranchPoint: + switch ( dx ) { + LoopTop: + case 0x0: SINGLE_STEP ; + case 0x1: SINGLE_STEP ; + case 0x2: SINGLE_STEP ; + case 0x3: SINGLE_STEP ; + case 0x4: SINGLE_STEP ; + case 0x5: SINGLE_STEP ; + case 0x6: SINGLE_STEP ; + case 0x7: *data++ = tmp & VGA_ALLPLANES ; + + /* Fall Through To End Of Inner Loop */ + if ( center_width > 0 ) { + tmp = read8Z( REGBASE, src ) ; src++; + center_width-- ; + goto LoopTop ; + } + else if ( ( center_width == 0 ) + && ( dx = ( - ignore ) & 07 ) ) { + tmp = read8Z( REGBASE, src ) ; src++; + center_width-- ; + goto BranchPoint ; /* Do Mod 8 edge */ + } + else /* End of this line */ + data += pad ; + } + } + +return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/vgaReg.h b/xorg-server/hw/xfree86/xf4bpp/vgaReg.h new file mode 100644 index 000000000..32ec0daed --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgaReg.h @@ -0,0 +1,137 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM 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. + * +*/ + +#define SET_BYTE_REGISTER( ioport, value ) outb( ioport, value ) +#define SET_INDEX_REGISTER( ioport, value ) SET_BYTE_REGISTER( ioport, value ) +#define SET_DATA_REGISTER( ioport, value ) SET_BYTE_REGISTER( ioport, value ) +/* GJA -- deleted RTIO and ATRIO case here, so that a PCIO #define became + * superfluous. + */ +#define SET_INDEXED_REGISTER(RegGroup, Index, Value) \ + (SET_BYTE_REGISTER(RegGroup, Index), \ + SET_BYTE_REGISTER((RegGroup) + 1, Value)) + +/* There is a jumper on the ega to change this to 0x200 instead !! */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#if 0 /* This is now a stack variable, as needed */ +#define REGBASE 0x300 +#endif + +#define AttributeIndexRegister REGBASE + 0xC0 +#define AttributeDataWriteRegister REGBASE + 0xC0 +#define AttributeDataReadRegister REGBASE + 0xC1 +#define AttributeRegister AttributeIndexRegister +#define AttributeModeIndex 0x30 +#define OverScanColorIndex 0x31 +#define ColorPlaneEnableIndex 0x32 +#define HorizPelPanIndex 0x33 +#define ColorSelectIndex 0x34 +#ifndef PC98_EGC +#define SetVideoAttributeIndex( index ) \ + SET_INDEX_REGISTER( AttributeIndexRegister, index ) +#define SetVideoAttribute( index, value ) \ + SetVideoAttributeIndex( index ) ; \ + SET_BYTE_REGISTER( AttributeDataWriteRegister, value ) +#endif + + /* Graphics Registers 03CE & 03CF */ +#define GraphicsIndexRegister REGBASE + 0xCE +#define GraphicsDataRegister REGBASE + 0xCF +#define GraphicsRegister GraphicsIndexRegister +#define Set_ResetIndex 0x00 +#define Enb_Set_ResetIndex 0x01 +#define Color_CompareIndex 0x02 +#define Data_RotateIndex 0x03 +#define Read_Map_SelectIndex 0x04 +#define Graphics_ModeIndex 0x05 +#define MiscellaneousIndex 0x06 +#define Color_Dont_CareIndex 0x07 +#define Bit_MaskIndex 0x08 +#ifndef PC98_EGC +#define SetVideoGraphicsIndex( index ) \ + SET_INDEX_REGISTER( GraphicsIndexRegister, index ) +#define SetVideoGraphicsData( value ) \ + SET_INDEX_REGISTER( GraphicsDataRegister, value ) +#define SetVideoGraphics( index, value ) \ + SET_INDEXED_REGISTER( GraphicsRegister, index, value ) +#endif + +/* Sequencer Registers 03C4 & 03C5 */ +#define SequencerIndexRegister REGBASE + 0xC4 +#define SequencerDataRegister REGBASE + 0xC5 +#define SequencerRegister SequencerIndexRegister +#define Seq_ResetIndex 00 +#define Clock_ModeIndex 01 +#define Mask_MapIndex 02 +#define Char_Map_SelectIndex 03 +#define Memory_ModeIndex 04 +#ifndef PC98_EGC +#define SetVideoSequencerIndex( index ) \ + SET_INDEX_REGISTER( SequencerIndexRegister, index ) +#define SetVideoSequencer( index, value ) \ + SET_INDEXED_REGISTER( SequencerRegister, index, value ) +#endif + +/* BIT CONSTANTS FOR THE VGA/EGA HARDWARE */ +/* for the Graphics' Data_Rotate Register */ +#define VGA_ROTATE_FUNC_SHIFT 3 +#define VGA_COPY_MODE ( 0 << VGA_ROTATE_FUNC_SHIFT ) /* 0x00 */ +#define VGA_AND_MODE ( 1 << VGA_ROTATE_FUNC_SHIFT ) /* 0x08 */ +#define VGA_OR_MODE ( 2 << VGA_ROTATE_FUNC_SHIFT ) /* 0x10 */ +#define VGA_XOR_MODE ( 3 << VGA_ROTATE_FUNC_SHIFT ) /* 0x18 */ +/* for the Graphics' Graphics_Mode Register */ +#define VGA_READ_MODE_SHIFT 3 +#define VGA_WRITE_MODE_0 0 +#define VGA_WRITE_MODE_1 1 +#define VGA_WRITE_MODE_2 2 +#define VGA_WRITE_MODE_3 3 +#define VGA_READ_MODE_0 ( 0 << VGA_READ_MODE_SHIFT ) +#define VGA_READ_MODE_1 ( 1 << VGA_READ_MODE_SHIFT ) + +#ifdef PC98_EGC +/* I/O port address define for extended EGC */ +#define EGC_PLANE 0x4a0 /* EGC active plane select */ +#define EGC_READ 0x4a2 /* EGC FGC,EGC,Read Plane */ +#define EGC_MODE 0x4a4 /* EGC Mode register & ROP */ +#define EGC_FGC 0x4a6 /* EGC Forground color */ +#define EGC_MASK 0x4a8 /* EGC Mask register */ +#define EGC_BGC 0x4aa /* EGC Background color */ +#define EGC_ADD 0x4ac /* EGC Dest/Source address */ +#define EGC_LENGTH 0x4ae /* EGC Bit length */ + +#define PALETTE_ADD 0xa8 /* Palette address */ +#define PALETTE_GRE 0xaa /* Palette Green */ +#define PALETTE_RED 0xac /* Palette Red */ +#define PALETTE_BLU 0xae /* Palette Blue */ + +#define EGC_AND_MODE 0x2c8c /* (S&P&D)|(~S&D) */ +#define EGC_AND_INV_MODE 0x2c2c /* (S&P&~D)|(~S&D) */ +#define EGC_OR_MODE 0x2cec /* S&(P|D)|(~S&D) */ +#define EGC_OR_INV_MODE 0x2cbc /* S&(P|~D)|(~S&D) */ +#define EGC_XOR_MODE 0x2c6c /* (S&(P&~D|~P&D))|(~S&D) */ +#define EGC_XOR_INV_MODE 0x2c9c /* (S&(P&D)|(~P&~D))|(~S&D) */ +#define EGC_COPY_MODE 0x2cac /* (S&P)|(~S&D) */ +#endif diff --git a/xorg-server/hw/xfree86/xf4bpp/vgaSolid.c b/xorg-server/hw/xfree86/xf4bpp/vgaSolid.c new file mode 100644 index 000000000..0ef18cfeb --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgaSolid.c @@ -0,0 +1,574 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#undef TRUE +#undef FALSE +#define TRUE 1 +#define FALSE 0 + +#ifndef PC98_EGC +#ifdef USE_ASM +extern void fastFill(); +extern void fastFillRMW(); +#else + +static void fastFill +( + register volatile unsigned char *destination, + register const unsigned int bytes_per_line, + register const unsigned int bytewidth, /* MUST BE > 0 !! */ + register unsigned int height /* MUST BE > 0 !! */ +) +{ +int stop_count = bytewidth ; +register int row_jump = bytes_per_line - bytewidth ; +#if !defined(OLDHC) && defined(BSDrt) && !defined(__i386__) +register const unsigned int notZero = ((unsigned char)(~0x0)); +#else +#define notZero ((unsigned char)(~0)) +#endif + +#define SINGLE_STORE \ + ( *( (VgaMemoryPtr) destination ) = notZero ); \ + destination++; stop_count--; + +/* TOP OF FIRST LOOP */ +BranchPoint: + +switch ( bytewidth & 0xF ) { /* Jump into loop at mod 16 remainder */ + LoopTop : + case 0x0 : SINGLE_STORE ; + case 0xF : SINGLE_STORE ; + case 0xE : SINGLE_STORE ; + case 0xD : SINGLE_STORE ; + case 0xC : SINGLE_STORE ; + case 0xB : SINGLE_STORE ; + case 0xA : SINGLE_STORE ; + case 0x9 : SINGLE_STORE ; + case 0x8 : SINGLE_STORE ; + case 0x7 : SINGLE_STORE ; + case 0x6 : SINGLE_STORE ; + case 0x5 : SINGLE_STORE ; + case 0x4 : SINGLE_STORE ; + case 0x3 : SINGLE_STORE ; + case 0x2 : SINGLE_STORE ; + case 0x1 : SINGLE_STORE ; +/* FIRST LOOP */ + if ( stop_count ) + goto LoopTop ; +/* SECOND LOOP */ + if ( --height ) { + destination += row_jump ; + stop_count = bytewidth ; + goto BranchPoint ; + } + else + return ; +#undef SINGLE_STORE +} +/*NOTREACHED*/ +} + +/* For Read-Modify-Write Case */ +static void fastFillRMW +( + register volatile unsigned char *destination, + register const unsigned int bytes_per_line, + register const unsigned int bytewidth, /* MUST BE > 0 !! */ + register unsigned int height /* MUST BE > 0 !! */ +) +{ +int stop_count = bytewidth ; +register int row_jump = bytes_per_line - bytewidth ; +#if !defined(OLDHC) && defined(BSDrt) && !defined(__i386__) +register const unsigned int notZero = ((unsigned char)(~0x0)); +#endif +register int tmp ; + +#define SINGLE_STORE \ + tmp = *( (VgaMemoryPtr) destination ) ; (void)tmp; \ + ( *( (VgaMemoryPtr) destination ) = notZero ) ; \ + destination++; stop_count-- ; + +/* TOP OF FIRST LOOP */ +BranchPoint: + +switch ( bytewidth & 0xF ) { /* Jump into loop at mod 16 remainder */ + LoopTop : + case 0x0 : SINGLE_STORE ; + case 0xF : SINGLE_STORE ; + case 0xE : SINGLE_STORE ; + case 0xD : SINGLE_STORE ; + case 0xC : SINGLE_STORE ; + case 0xB : SINGLE_STORE ; + case 0xA : SINGLE_STORE ; + case 0x9 : SINGLE_STORE ; + case 0x8 : SINGLE_STORE ; + case 0x7 : SINGLE_STORE ; + case 0x6 : SINGLE_STORE ; + case 0x5 : SINGLE_STORE ; + case 0x4 : SINGLE_STORE ; + case 0x3 : SINGLE_STORE ; + case 0x2 : SINGLE_STORE ; + case 0x1 : SINGLE_STORE ; +/* FIRST LOOP */ + if ( stop_count ) + goto LoopTop ; +/* SECOND LOOP */ + if ( --height ) { + destination += row_jump ; + stop_count = bytewidth ; + goto BranchPoint ; + } + else + return ; +} +#undef SINGLE_STORE +/*NOTREACHED*/ +} +#endif + + +void xf4bppFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ) +WindowPtr pWin; /* GJA */ +unsigned long int color ; +const int alu ; +unsigned long int planes ; +register int x0 ; +register const int y0 ; +register int lx ; +register const int ly ; /* MUST BE > 0 !! */ +{ +IOADDRESS REGBASE; +register volatile unsigned char *dst ; +register int tmp ; +register int tmp2 ; +register int tmp3 ; +unsigned int data_rotate_value = VGA_COPY_MODE ; +unsigned int read_write_modify = FALSE ; +unsigned int invert_existing_data = FALSE ; + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ); + return; + } +} /* End GJA */ + +if ( ( lx == 0 ) || ( ly == 0 ) ) + return; + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + color = 0 ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = TRUE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + color = ~color ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + case GXcopy: /* 0x3 src */ + break ; + case GXnoop: /* 0x5 dst */ + return ; + case GXequiv: /* 0x9 NOT src XOR dst */ + color = ~color ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + planes &= color ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_existing_data = TRUE ; + case GXorInverted: /* 0xd NOT src OR dst */ + color = ~color ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + color = ~color ; + break ; + case GXinvert: /* 0xa NOT dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + case GXset: /* 0xf 1 */ + color = VGA_ALLPLANES ; + default: + break ; +} + +if ( !( planes &= VGA_ALLPLANES ) ) + return ; + +REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; + +/* + * Set The Plane-Enable + */ +SetVideoSequencer( Mask_MapIndex, planes ) ; +SetVideoGraphics( Enb_Set_ResetIndex, planes ) ; +/* + * Put Display Into SET/RESET Write Mode + */ +SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_3 ) ; +/* + * Set The Color in The Set/Reset Register + */ +SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; +/* + * Set The Function-Select In The Data Rotate Register + */ +SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + +/* Do Left Edge */ +if ((tmp = x0 & 07)) { + tmp2 = SCRRIGHT8( ( (unsigned) 0xFF ), tmp ) ; + /* Catch The Cases Where The Entire Region Is Within One Byte */ + if ( ( lx -= 8 - tmp ) < 0 ) { + tmp2 &= SCRLEFT8( 0xFF, -lx ) ; + lx = 0 ; + } + /* Set The Bit Mask Reg */ + SetVideoGraphics(Bit_MaskIndex, tmp2 ) ; + if ( invert_existing_data == TRUE ) { + SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ; + dst = SCREENADDRESS( pWin, x0, y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + (void)tmp3; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin); + } + SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + /* Un-Set XOR */ + } + dst = SCREENADDRESS( pWin, x0, y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + (void)tmp3; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin); + } + if ( !lx ) { /* All Handled In This Byte */ + return ; + } + x0 = ( x0 + 8 ) & ~07 ; +} + +/* Fill The Center Of The Box */ +if ( ROW_OFFSET( lx ) ) { + SetVideoGraphics(Bit_MaskIndex, 0xFF ) ; + if ( invert_existing_data == TRUE ) { + SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ; + fastFillRMW( SCREENADDRESS( pWin, x0, y0 ), + BYTES_PER_LINE(pWin), + ROW_OFFSET( lx ), ly ) ; + SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + /* Un-Set XOR */ + /* Point At The Bit Mask Reg */ + } + (* ( ( read_write_modify == FALSE ) ? fastFill : fastFillRMW ) ) + ( SCREENADDRESS( pWin, x0, y0 ), BYTES_PER_LINE(pWin), + ROW_OFFSET( lx ), ly ) ; +} + +/* Do Right Edge */ +if ((tmp = BIT_OFFSET(lx))) { /* x0 Now Is Byte Aligned */ + /* Set The Bit Mask */ + SetVideoGraphics( Bit_MaskIndex, + (tmp2 = SCRLEFT8( 0xFF, ( 8 - tmp ) ) ) ) ; + if ( invert_existing_data == TRUE ) { + SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ; + dst = SCREENADDRESS( pWin, ( x0 + lx ), y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + (void)tmp3; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin); + } + SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ; + SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ; + /* Un-Set XOR */ + } + dst = SCREENADDRESS( pWin, ( x0 + lx ), y0 ); + for ( tmp = ly; + tmp-- ; ) { + tmp3 = *( (VgaMemoryPtr) dst ) ; + (void)tmp3; + *( (VgaMemoryPtr) dst ) = tmp2 ; + dst += BYTES_PER_LINE(pWin) ; + } +} +/* Disable Set/Reset Register */ +SetVideoGraphics( Enb_Set_ResetIndex, 0 ) ; + + +return ; +} + +#else /* for PC98 EGC */ +static void WordfastFill( destination, bytes_per_line, wordwidth, height ) +register volatile unsigned char *destination ; +register const unsigned int bytes_per_line ; +register const unsigned int wordwidth ; /* MUST BE > 0 !! */ +register unsigned int height ; /* MUST BE > 0 !! */ +{ +int stop_count = wordwidth ; +register int row_jump = bytes_per_line - wordwidth*2 ; +#if !defined(OLDHC) && defined(BSDrt) && !defined(__i386__) && 0 +register const int notZero = ~0x0 ; +#else +#define notZero ( ~0 ) +#endif + +#define SINGLE_STORE \ + ( *( (unsigned short *) destination++ ) = notZero ); \ + destination++; stop_count--; + +/* TOP OF FIRST LOOP */ +BranchPoint: + +switch ( wordwidth & 0xF ) { /* Jump into loop at mod 16 remainder */ + LoopTop : + case 0x0 : SINGLE_STORE ; + case 0xF : SINGLE_STORE ; + case 0xE : SINGLE_STORE ; + case 0xD : SINGLE_STORE ; + case 0xC : SINGLE_STORE ; + case 0xB : SINGLE_STORE ; + case 0xA : SINGLE_STORE ; + case 0x9 : SINGLE_STORE ; + case 0x8 : SINGLE_STORE ; + case 0x7 : SINGLE_STORE ; + case 0x6 : SINGLE_STORE ; + case 0x5 : SINGLE_STORE ; + case 0x4 : SINGLE_STORE ; + case 0x3 : SINGLE_STORE ; + case 0x2 : SINGLE_STORE ; + case 0x1 : SINGLE_STORE ; +/* FIRST LOOP */ + if ( stop_count ) + goto LoopTop ; +/* SECOND LOOP */ + if ( --height ) { + destination += row_jump ; + stop_count = wordwidth ; + goto BranchPoint ; + } + else + return ; +#undef SINGLE_STORE +} +/*NOTREACHED*/ +} + +void xf4bppFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ) +WindowPtr pWin; /* GJA */ +unsigned long int color ; +const int alu ; +unsigned long int planes ; +register int x0 ; +register const int y0 ; +register int lx ; +register const int ly ; /* MUST BE > 0 !! */ +{ +register volatile unsigned char *dst ; +register tmp ; +register tmp2 ; +register unsigned short tmp3 ; +unsigned short ROP_value; +unsigned int data_rotate_value = VGA_COPY_MODE ; +unsigned int read_write_modify = FALSE ; +unsigned int invert_existing_data = FALSE ; + +{ /* Start GJA */ + if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffFillSolid( pWin, color, alu, planes, x0, y0, lx, ly ); + return; + } +} /* End GJA */ + +if ( ( lx == 0 ) || ( ly == 0 ) ) + return; + +switch ( alu ) { + case GXclear: /* 0x0 Zero 0 */ + color = 0 ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = TRUE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + color = ~color ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + case GXcopy: /* 0x3 src */ + break ; + case GXnoop: /* 0x5 dst */ + return ; + case GXequiv: /* 0x9 NOT src XOR dst */ + color = ~color ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + planes &= color ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_AND_MODE ; + read_write_modify = TRUE ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = TRUE ; + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_existing_data = TRUE ; + case GXorInverted: /* 0xd NOT src OR dst */ + color = ~color ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE ; + read_write_modify = TRUE ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + color = ~color ; + break ; + case GXinvert: /* 0xa NOT dst */ + data_rotate_value = VGA_XOR_MODE ; + read_write_modify = TRUE ; + case GXset: /* 0xf 1 */ + color = VGA_ALLPLANES ; + default: + break ; +} + +if ( !( planes &= VGA_ALLPLANES ) ) + return ; + +/* Set Access Planes */ +outw(EGC_PLANE, ~planes); +switch(data_rotate_value) { +/* EGC MODE.. Cmp Read: Flase, WriteSource=ROP, ReadSource=CPU */ + case VGA_AND_MODE: + if (invert_existing_data) + ROP_value = EGC_AND_INV_MODE; + else + ROP_value = EGC_AND_MODE; + break; + case VGA_OR_MODE: + if (invert_existing_data) + ROP_value = EGC_OR_INV_MODE; + else + ROP_value = EGC_OR_MODE; + break; + case VGA_XOR_MODE: + if (invert_existing_data) + ROP_value = EGC_XOR_INV_MODE; + else + ROP_value = EGC_XOR_MODE; + break; + case VGA_COPY_MODE: + default: + ROP_value = EGC_COPY_MODE; + break; +} +outw(EGC_MODE, ROP_value); +outw(EGC_FGC, color & VGA_ALLPLANES); +/* Do Left Edge */ +if ( tmp = x0 & 0x0f ) { + dst = (unsigned char *)((int)(SCREENADDRESS(pWin,x0,y0)) & ~0x01); + tmp3 = (unsigned)0xffff >>tmp; + /* Catch The Cases Where The Entire Region Is Within One Word */ + if ( ( lx -= 16 - tmp ) < 0 ) { + tmp3 &= (unsigned)0xffff << -lx; + lx = 0 ; + } + tmp3 = (unsigned short)(tmp3 >> 8 | tmp3 << 8); + for ( tmp = ly; + tmp-- ; ) { + *((unsigned short *) dst ) = tmp3 ; + dst += BYTES_PER_LINE(pWin); + } + if ( !lx ) { /* All Handled In This Word */ + return ; + } + x0 = ( x0 + 0x0f ) & ~0x0f ; +} + +/* Fill The Center Of The Box */ +if (lx >> 4) { + WordfastFill( SCREENADDRESS( pWin, x0, y0 ), BYTES_PER_LINE(pWin), + (lx >> 4), ly ) ; +} + +/* Do Right Edge */ +if ( tmp = lx & 0x0f ) { /* x0 Now Is Word Aligned */ + /* Set The Bit Mask */ + tmp3 = (unsigned)0xffff << ( 16 - tmp ); + dst = (unsigned char*)((int)SCREENADDRESS(pWin,(x0+lx),y0) & ~0x01); + tmp3 = (unsigned short)(tmp3 >> 8 | tmp3 << 8); + for ( tmp = ly; + tmp-- ; ) { + *( (unsigned short *) dst ) = tmp3 ; + dst += BYTES_PER_LINE(pWin); + } +} + +return ; +} +#endif diff --git a/xorg-server/hw/xfree86/xf4bpp/vgaStipple.c b/xorg-server/hw/xfree86/xf4bpp/vgaStipple.c new file mode 100644 index 000000000..5ad53028c --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgaStipple.c @@ -0,0 +1,720 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "vgaReg.h" +#include "vgaVideo.h" + +#include "xf86str.h" /* for pScrn->vtSema */ +extern ScrnInfoPtr *xf86Screens; + +#ifndef PC98_EGC +static unsigned char +getbits +( + register const int x, + register const unsigned int patternWidth, + register const unsigned char * const lineptr +) +{ +register unsigned char bits ; +register const unsigned char *cptr ; +register int shift ; +register int wrap ; + +cptr = lineptr + ( x >> 3 ) ; +bits = *cptr ; +if ((shift = x & 7)) + bits = SCRLEFT8( bits, shift ) | SCRRIGHT8( cptr[1], ( 8 - shift ) ) ; +if ( ( wrap = x + 8 - patternWidth ) > 0 ) { + bits &= SCRLEFT8( 0xFF, wrap ) ; + bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ; +} + +/* GJA -- Handle extraction of 8 bits from < 8 bits wide stipple. + * I duplicated case 4,5,6,7 to give the compiler a chance to optimize. + */ +switch (patternWidth) { +case 1: /* Not really useful. */ + bits &= ~SCRRIGHT8(0xFF,1); + bits |= SCRRIGHT8(bits,1); + bits |= SCRRIGHT8(bits,2); + bits |= SCRRIGHT8(bits,4); + break; +case 2: + bits &= ~SCRRIGHT8(0xFF,2); + bits |= SCRRIGHT8(bits,2); bits |= SCRRIGHT8(bits,4); break; +case 3: + bits &= ~SCRRIGHT8(0xFF,3); + bits |= (SCRRIGHT8(bits,3) | SCRRIGHT8(bits,6)); break; +case 4: + bits = (bits & ~SCRRIGHT8(0xFF,4)) | SCRRIGHT8(bits,4); break; +case 5: + bits = (bits & ~SCRRIGHT8(0xFF,5)) | SCRRIGHT8(bits,5); break; +case 6: + bits = (bits & ~SCRRIGHT8(0xFF,6)) | SCRRIGHT8(bits,6); break; +case 7: + bits = (bits & ~SCRRIGHT8(0xFF,7)) | SCRRIGHT8(bits,7); break; +default: + ; + /* Do nothing, of course */ +} +return bits ; +} +#endif + +/* GJA -- + * Basically, in the code below, we will draw a stipple in the usual + * three parts: left edge, center and right edge. + * For efficiency reasons, the center will be drawn byte aligned, so that + * we will have to shuffle the bits in the left and right edges. + * The hard cases will be stipples with width < 8: In order to get 8 + * bits from those, we will need a loop. One single 'if' will never do. + * This is taken care of above. + */ +static void +DoMonoSingle +( + WindowPtr pWin, /* GJA */ + int w, + int x, + int y, + register const unsigned char *mastersrc, + int h, + register unsigned int width, + register unsigned int paddedByteWidth, + unsigned int height, + int xshift, + int yshift +) +{ +IOADDRESS REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; +register volatile unsigned char *xDst ; +register VideoAdapterObject tmp2 ; +register int NeedValX ; +register int counter ; +register int tmp1 ; +unsigned int rowCounter ; +int byte_cnt ; +#ifdef PC98_EGC +unsigned char bitmask; +#endif + +/* Do Left Edge */ +if ((tmp1 = x & 07)) { + tmp2 = SCRRIGHT8( ( (unsigned) 0xFF ), tmp1 ) ; + /* Catch The Cases Where The Entire Region Is Within One Byte */ + if ( ( w -= 8 - tmp1 ) < 0 ) { + tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ; + w = 0 ; + } +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, tmp2 ) ; /* Set The Bit Mask */ +#else + bitmask = tmp2; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + xDst = SCREENADDRESS( pWin, x, y ); + for ( tmp1 = yshift, rowCounter = h; + rowCounter ; + rowCounter-- , tmp1++ ) { + + if ( tmp1 >= (int)height ) + tmp1 -= height ; +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = +#ifndef PC98_EGC + getbits( xshift /* GJA */, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) >> (x & 07) ; +#else +#if 0 + (getbits( xshift /* GJA */, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) >> (x & 07) + & bitmask); +#else + (getbits_x( xshift /* GJA */, width, + mastersrc + + ( tmp1 * paddedByteWidth ), (x & 07)) + & bitmask); +#endif +#endif + xDst += BYTES_PER_LINE(pWin); + } + NeedValX = (xshift + 8 - (x & 07)) % width; + x = ( x + 7 ) & ~07 ; +} +else { + NeedValX = xshift ; +} + +if ((byte_cnt = ROW_OFFSET(w))) { /* Fill The Center Of The Box */ + int SavNeedX = NeedValX ; + +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + xDst = SCREENADDRESS( pWin, x, y ); + for ( tmp1 = yshift, rowCounter = h; + rowCounter ; + rowCounter-- , tmp1++ ) { + register const unsigned char *l_ptr ; + if ( tmp1 >= (int)height ) + tmp1 -= height ; + l_ptr = mastersrc + ( tmp1 * paddedByteWidth ) ; + /* + * For Each Byte Across The Pattern In X + */ + for ( counter = byte_cnt, NeedValX = SavNeedX ; + counter-- ; ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = +#ifndef PC98_EGC + getbits( NeedValX, width, l_ptr ) ; +#else +#if 0 + getbits( NeedValX, width, l_ptr ) ; +#else + getbits_x ( NeedValX, width, l_ptr, 0 ) ; +#endif +#endif + /* GJA -- The '%' is there since width could be < 8 */ + NeedValX = (NeedValX + 8) % width; + xDst++; + } + xDst += BYTES_PER_LINE(pWin) - byte_cnt; + } +} + +/* Do Right Edge */ +if ((tmp1 = BIT_OFFSET(w))) { /* x Now Is Byte Aligned */ + /* Set The Bit Mask */ +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ; +#else + bitmask = SCRLEFT8( 0xFF, ( 8 - tmp1 )); +#endif + /* + * For Each Line In The Source Pixmap + */ + xDst = SCREENADDRESS( pWin, ( x + w ), y ); + for ( tmp1 = yshift, rowCounter = h; + rowCounter ; + rowCounter-- , tmp1++ ) { + if ( tmp1 >= (int)height ) + tmp1 -= height ; +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = +#ifndef PC98_EGC + getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else +#if 0 + (getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) & bitmask); +#else + (getbits_x( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ), 0 ) & bitmask); +#endif +#endif + xDst += BYTES_PER_LINE(pWin) ; + } +} + +return ; +} + +static void +DoMonoMany +( + WindowPtr pWin, /* GJA */ + int w, + int x, + int y, + register const unsigned char *mastersrc, + int h, + register unsigned int width, + register unsigned int paddedByteWidth, + unsigned int height, + int xshift, + int yshift +) +{ +IOADDRESS REGBASE = + xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->domainIOBase + 0x300; +register volatile unsigned char *xDst ; +register VideoAdapterObject tmp2 ; +register int NeedValX ; +register int byte_cnt ; +register int tmp1 ; +unsigned DestinationRow ; +unsigned int SourceRow ; +volatile unsigned char *dst ; +int scr_incr = ( height * BYTES_PER_LINE(pWin) ) ; +#ifdef PC98_EGC +unsigned char bitmask; +#endif + +/* Do Left Edge */ +if ((tmp1 = x & 07)) { + tmp2 = SCRRIGHT8( ( (unsigned) 0xFF ), tmp1 ) ; + /* Catch The Cases Where The Entire Region Is Within One Byte */ + if ( ( w -= 8 - tmp1 ) < 0 ) { + tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ; + w = 0 ; + } +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, tmp2 ) ; /* Set The Bit Mask */ +#else + bitmask = tmp2; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( pWin, x, y ) ; + SourceRow < height ; + tmp1++, SourceRow++, dst += BYTES_PER_LINE(pWin) ) { + register unsigned bitPattern ; + + if ( tmp1 >= (int)height ) + tmp1 -= height ; + /* + * For Each Time Pattern Repeats In The Y Dimension + */ + xDst = dst; + for ( DestinationRow = SourceRow, +#ifndef PC98_EGC + bitPattern = getbits( xshift, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else +#if 0 + bitPattern = getbits( xshift, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else + bitPattern = getbits_x( xshift, width, + mastersrc + + ( tmp1 * paddedByteWidth ), 0 ) ; +#endif +#endif + (int)DestinationRow < h ; + DestinationRow += height ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst ) ; +#endif + /* Write Pattern */ +#ifndef PC98_EGC + *( (VgaMemoryPtr) xDst ) = bitPattern >> (x & 07); +#else + *( (VgaMemoryPtr) xDst ) = (bitPattern >> (x & 07)) & bitmask; +#endif + xDst += scr_incr; + } + } + NeedValX = (xshift + 8 - (x & 07)) % width; + x = ( x + 7 ) & ~07 ; +} +else { + NeedValX = xshift ; +} + +if ((byte_cnt = ROW_OFFSET(w))) { /* Fill The Center Of The Box */ + int SavNeedX = NeedValX ; + +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* Set The Bit Mask */ +#endif + /* + * For Each Line In The Source Pixmap + */ + for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( pWin, x, y ) ; + SourceRow < height ; + tmp1++, SourceRow++, dst += BYTES_PER_LINE(pWin) - byte_cnt ) { + register const unsigned char *l_ptr ; + if ( tmp1 >= (int)height ) + tmp1 -= height ; + l_ptr = mastersrc + ( tmp1 * paddedByteWidth ) ; + /* + * For Each Byte Across The Pattern In X + */ + for ( tmp2 = byte_cnt, NeedValX = SavNeedX ; + tmp2-- ; + dst++ ) { + register unsigned bitPattern ; +#ifndef PC98_EGC + register VideoAdapterObject tmp3 ; +#endif + /* + * For Each Time Pattern Repeats In Y + */ + xDst = dst; + for ( DestinationRow = SourceRow, +#ifndef PC98_EGC + bitPattern = getbits( NeedValX, width, l_ptr ) ; +#else +#if 0 + bitPattern = getbits( NeedValX, width, l_ptr ) ; +#else + bitPattern = getbits_x( NeedValX, width, l_ptr, 0 ) ; +#endif +#endif + (int)DestinationRow < h ; + DestinationRow += height ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp3 = *( (VgaMemoryPtr) xDst) ; + (void)tmp3; +#endif + /* Write Pattern */ + *( (VgaMemoryPtr) xDst ) = bitPattern ; + xDst += scr_incr; + } + NeedValX = (NeedValX + 8) % width; + } + } +} + +/* Do Right Edge */ +if ((tmp1 = BIT_OFFSET(w))) { /* x Now Is Byte Aligned */ + /* Set The Bit Mask */ +#ifndef PC98_EGC + SetVideoGraphics( Bit_MaskIndex, SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ; +#else + bitmask = SCRLEFT8( 0xFF, ( 8 - tmp1 ) ); +#endif + /* + * For Each Line In The Source Pixmap + */ + for ( tmp1 = yshift, SourceRow = 0, + dst = SCREENADDRESS( pWin, ( x + w ), y ) ; + SourceRow < height ; + tmp1++, SourceRow++, dst += BYTES_PER_LINE(pWin) ) { + register unsigned bitPattern ; + if ( tmp1 >= (int)height ) + tmp1 -= height ; + /* + * For Each Time Pattern Repeats In The Y Dimension + */ + xDst = dst; + for ( DestinationRow = SourceRow, +#ifndef PC98_EGC + bitPattern = getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else +#if 0 + bitPattern = getbits( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ) ) ; +#else + bitPattern = getbits_x( NeedValX, width, + mastersrc + + ( tmp1 * paddedByteWidth ), 0 ) ; +#endif +#endif + (int)DestinationRow < h ; + DestinationRow += height ) { +#ifndef PC98_EGC + /* Read To Save */ + tmp2 = *( (VgaMemoryPtr) xDst) ; +#endif + /* Write Pattern */ +#ifndef PC98_EGC + *( (VgaMemoryPtr) xDst ) = bitPattern ; +#else + *( (VgaMemoryPtr) xDst ) = bitPattern & bitmask; +#endif + xDst += scr_incr; + } + } +} + +return ; +} + +#define DO_RECURSE 0x10000 + +static void +vgaSetMonoRegisters +( + DrawablePtr pDrawable, + register unsigned long int plane_mask, + register unsigned long int desiredState +) +{ +IOADDRESS REGBASE = + xf86Screens[pDrawable->pScreen->myNum]->domainIOBase + 0x300; +#ifndef PC98_EGC +/* Setup VGA Registers */ +/* + * Set The Plane-Enable + */ +SetVideoSequencer( Mask_MapIndex, plane_mask ) ; +SetVideoGraphics( Enb_Set_ResetIndex, plane_mask ) ; +/* + * Put Display Into SET-AND (i.e. Write Mode 3 ) + */ +SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_3 ) ; +/* + * Set The Color in The Set/Reset Register + */ +SetVideoGraphics( Set_ResetIndex, desiredState & VGA_ALLPLANES ) ; +/* + * Set The Vga's Alu Function + */ +SetVideoGraphics( Data_RotateIndex, desiredState >> 8 ) ; +#else /* PC98_EGC */ +unsigned short ROP_value; +/* Setup VGA Registers */ +/* + * Set The Plane-Enable + */ +outw(EGC_PLANE, ~plane_mask); +switch((desiredState >> 8)&0x18) { +/* EGC MODE.. Cmp Read: Flase, WriteSource=ROP, ReadSource=CPU */ + case VGA_AND_MODE: + if (desiredState & DO_RECURSE) + ROP_value = EGC_AND_INV_MODE; + else + ROP_value = EGC_AND_MODE; + break; + case VGA_OR_MODE: + if (desiredState & DO_RECURSE) + ROP_value = EGC_OR_INV_MODE; + else + ROP_value = EGC_OR_MODE; + break; + case VGA_XOR_MODE: + if (desiredState & DO_RECURSE) + ROP_value = EGC_XOR_INV_MODE; + else + ROP_value = EGC_XOR_MODE; + break; + case VGA_COPY_MODE: + default: + ROP_value = EGC_COPY_MODE; + break; +} +outw(EGC_MODE, ROP_value); +outw(EGC_FGC, desiredState & VGA_ALLPLANES); +#endif + +return ; +} + +static unsigned long +vgaCalcMonoMode +( + int rasterOp, + register unsigned long int color +) +{ +register unsigned int data_rotate_value = VGA_COPY_MODE << 8 ; +register unsigned int invert_existing_data = 0 ; + +/* Test The Raster-Op */ +switch ( rasterOp ) { + case GXclear: /* 0x0 Zero 0 */ + color = 0 ; + break ; + case GXinvert: /* 0xa NOT dst */ + data_rotate_value = VGA_XOR_MODE << 8 ; + case GXset: /* 0xf 1 */ + color = VGA_ALLPLANES ; + break ; + case GXnor: /* 0x8 NOT src AND NOT dst */ + invert_existing_data = DO_RECURSE ; + case GXandInverted: /* 0x4 NOT src AND dst */ + color = ~color ; + case GXand: /* 0x1 src AND dst */ + data_rotate_value = VGA_AND_MODE << 8 ; + case GXcopy: /* 0x3 src */ + break ; + case GXequiv: /* 0x9 NOT src XOR dst */ + color = ~color ; + case GXxor: /* 0x6 src XOR dst */ + data_rotate_value = VGA_XOR_MODE << 8 ; + break ; + case GXandReverse: /* 0x2 src AND NOT dst */ + invert_existing_data = DO_RECURSE ; + data_rotate_value = VGA_AND_MODE << 8 ; + break ; + case GXorReverse: /* 0xb src OR NOT dst */ + invert_existing_data = DO_RECURSE ; + data_rotate_value = VGA_OR_MODE << 8 ; + break ; + case GXnand: /* 0xe NOT src OR NOT dst */ + invert_existing_data = DO_RECURSE ; + case GXorInverted: /* 0xd NOT src OR dst */ + color = ~color ; + case GXor: /* 0x7 src OR dst */ + data_rotate_value = VGA_OR_MODE << 8 ; + break ; + case GXcopyInverted: /* 0xc NOT src */ + color = ~color ; + break ; + case GXnoop: /* 0x5 dst */ + ; /* Shouldn't Get Here !! */ +} + +return ( color & VGA_ALLPLANES ) | data_rotate_value | invert_existing_data ; +} + +static void +vgaDrawMonoImage +( + WindowPtr pWin, /* GJA */ + unsigned char *data, + int x, + int y, + int w, + int h, + unsigned long int fg, + int alu, + unsigned long int planes +) +{ +unsigned long regState ; + +if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffDrawMonoImage( pWin, data, x, y, w, h, fg, alu, planes ); + return; +} + +if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) ) + return ; + +#ifndef PC98_EGC +if ( ( regState = vgaCalcMonoMode( alu, fg ) ) & DO_RECURSE ) { + vgaDrawMonoImage( pWin, data, x, y, w, h, + VGA_ALLPLANES, GXinvert, planes ) ; + regState &= ~DO_RECURSE ; +} +#else +regState = vgaCalcMonoMode(alu, (char)fg); +#endif + + +vgaSetMonoRegisters( (DrawablePtr)pWin, planes, regState ) ; + +DoMonoSingle( pWin, w, x, y, (const unsigned char *) data, h, + w, ( ( w + 31 ) & ~31 ) >> 3, h, 0, 0 ) ; + + +return ; +} + +void +xf4bppFillStipple( pWin, pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc ) +WindowPtr pWin; /* GJA */ +register PixmapPtr const pStipple ; +unsigned long int fg ; +const int alu ; +unsigned long int planes ; +int x, y, w, h ; +const int xSrc, ySrc ; +{ +unsigned int width ; +unsigned int height ; +int xshift ; +int yshift ; +unsigned long regState ; + +if ( !xf86Screens[((DrawablePtr)pWin)->pScreen->myNum]->vtSema ) { + xf4bppOffFillStipple( pWin, pStipple, fg, alu, planes, + x, y, w, h, xSrc, ySrc ); + return; +} + +if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) ) + return ; + +#if 1 +if ( ( regState = vgaCalcMonoMode( alu, fg ) ) & DO_RECURSE ) { + xf4bppFillStipple( pWin, pStipple, VGA_ALLPLANES, GXinvert, planes, + x, y, w, h, xSrc, ySrc ) ; + regState &= ~DO_RECURSE ; +} +#else +regState = vgaCalcMonoMode(alu, (char)fg); +#endif + + +vgaSetMonoRegisters( (DrawablePtr)pWin, planes, regState ) ; + +/* Figure Bit Offsets & Source Address */ +width = pStipple->drawable.width ; +if ( ( xshift = ( x - xSrc ) ) < 0 ) + xshift = width - ( ( - xshift ) % width ) ; +else + xshift %= width ; +if ( xshift == (int)width ) xshift = 0; + +height = pStipple->drawable.height ; +if ( ( yshift = ( y - ySrc ) ) < 0 ) + yshift = height - ( ( - yshift ) % height ) ; +else + yshift %= height ; +if ( yshift == (int)height ) yshift = 0; + + (* ( (h > (int)height) ? DoMonoMany : DoMonoSingle ) ) ( + pWin, w, x, y, + (const unsigned char *) pStipple->devPrivate.ptr, + h, + width, + ( ( width + 31 ) & ((unsigned)(~31)) ) >> 3, + height, + xshift, yshift + ) ; + +return ; +} diff --git a/xorg-server/hw/xfree86/xf4bpp/vgaVideo.h b/xorg-server/hw/xfree86/xf4bpp/vgaVideo.h new file mode 100644 index 000000000..60afa5bb6 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgaVideo.h @@ -0,0 +1,93 @@ +/* + * Copyright IBM Corporation 1987,1988,1989 + * + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation, and that the name of IBM not be + * used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * + * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" /* GJA -- for pointer data type */ +#ifdef lint +#if defined(volatile) +#undef volatile +#endif +#define volatile /**/ +#if defined(const) +#undef const +#endif +#define const /**/ +#if defined(signed) +#undef signed +#endif +#define signed /**/ +#endif + +/* + * References to all pc ( i.e. '286 ) memory in the + * regions used by the [ev]ga server ( the 128K windows ) + * MUST be long-word ( i.e. 32-bit ) reads or writes. + * This definition will change for other memory architectures + * ( e.g. AIX-Rt ) + */ +typedef unsigned char VideoAdapterObject ; +typedef volatile VideoAdapterObject *VideoMemoryPtr ; +typedef volatile VideoAdapterObject *VgaMemoryPtr ; +#if !defined(BITMAP_BIT_ORDER) +#define BITMAP_BIT_ORDER MSBFirst +#endif + +#if !defined(IMAGE_BYTE_ORDER) +#define IMAGE_BYTE_ORDER LSBFirst +#endif + +/* Bit Ordering Macros */ +#if !defined(SCRLEFT8) +#define SCRLEFT8(lw, n) ( (unsigned char) (((unsigned char) lw) << (n)) ) +#endif +#if !defined(SCRRIGHT8) +#define SCRRIGHT8(lw, n) ( (unsigned char) (((unsigned char)lw) >> (n)) ) +#endif +/* These work ONLY on 8-bit wide Quantities !! */ +#define LeftmostBit ( SCRLEFT8( 0xFF, 7 ) & 0xFF ) +#define RightmostBit ( SCRRIGHT8( 0xFF, 7 ) & 0xFF ) + +/* + * [ev]ga video screen defines & macros + */ +#define VGA_BLACK_PIXEL 0 +#define VGA_WHITE_PIXEL 1 + +#define VGA_MAXPLANES 4 +#define VGA_ALLPLANES 0xFL + +#define VIDBASE(pDraw) ((volatile unsigned char *) \ + (((PixmapPtr)(((DrawablePtr)(pDraw))->pScreen->devPrivate))-> \ + devPrivate.ptr)) +#define BYTES_PER_LINE(pDraw) \ + ((int)((PixmapPtr)(((DrawablePtr)(pDraw))->pScreen->devPrivate))->devKind) + +#define ROW_OFFSET( x ) ( ( x ) >> 3 ) +#define BIT_OFFSET( x ) ( ( x ) & 0x7 ) +#define SCREENADDRESS( pWin, x, y ) \ + ( VIDBASE(pWin) + (y) * BYTES_PER_LINE(pWin) + ROW_OFFSET(x) ) + + diff --git a/xorg-server/hw/xfree86/xf4bpp/vgamodule.c b/xorg-server/hw/xfree86/xf4bpp/vgamodule.c new file mode 100644 index 000000000..e7324914b --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/vgamodule.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(xf4bppSetup); + +static XF86ModuleVersionInfo VersRec = +{ + "xf4bpp", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData xf4bppModuleData = { &VersRec, xf4bppSetup, NULL }; + +static pointer +xf4bppSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + /* This module requires xf1bpp for bitmap support */ + return LoadSubModule(module, "xf1bpp", NULL, NULL, NULL, NULL, + errmaj, errmin); +} diff --git a/xorg-server/hw/xfree86/xf4bpp/wm3.c b/xorg-server/hw/xfree86/xf4bpp/wm3.c new file mode 100644 index 000000000..3a57221f2 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/wm3.c @@ -0,0 +1,203 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf4bpp.h" +#include "OScompiler.h" +#include "wm3.h" +#include "vgaVideo.h" +#include "xf86.h" + +/* Ferraro is wrong. GJA */ +#define COPY (0 << 3) +#define AND (1 << 3) +#define OR (2 << 3) +#define XOR (3 << 3) + +int +wm3_set_regs(pGC) +GC *pGC; +{ +#ifndef PC98_EGC + IOADDRESS REGBASE = xf86Screens[pGC->pScreen->myNum]->domainIOBase + 0x300; + int post_invert = 0; + int ALU; + + switch(pGC->alu) { + case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */ + pGC->fgPixel = 0; + pGC->bgPixel = 0; + ALU = COPY; + break; + case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */ + ALU = AND; + break; + case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = OR; + post_invert = 1; + break; + case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */ + ALU = COPY; + break; + case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = AND; + break; + default: + case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */ + return 0; + case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */ + ALU = XOR; + break; + case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */ + ALU = OR; + break; + case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/ + ALU = OR; + post_invert = 1; + break; + case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = XOR; + break; + case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = XOR; + break; + case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = AND; + post_invert = 1; + break; + case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = COPY; + break; + case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = OR; + break; + case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */ + ALU = AND; + post_invert = 1; + break; + case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = COPY; + break; + } + + + SetVideoSequencer(Mask_MapIndex, (pGC->planemask & VGA_ALLPLANES)); + SetVideoGraphics(Enb_Set_ResetIndex, VGA_ALLPLANES); + SetVideoGraphics(Set_ResetIndex, pGC->fgPixel); + SetVideoGraphics(Bit_MaskIndex, 0xFF); + SetVideoGraphics(Graphics_ModeIndex, 3); /* Write Mode 3 */ + SetVideoGraphics(Data_RotateIndex, ALU); + + return post_invert; +#else + int ALU; + + switch(pGC->alu) { + case GXclear: /* rop0 = RROP_BLACK; rop1 = RROP_BLACK; */ + pGC->fgPixel = 0; + pGC->bgPixel = 0; + ALU = EGC_COPY_MODE; + break; + case GXand: /* rop0 = RROP_BLACK; rop1 = RROP_NOP; */ + ALU = EGC_AND_MODE; + break; + case GXandReverse: /* rop0 = RROP_BLACK; rop1 = RROP_INVERT; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_OR_INV_MODE; + break; + case GXcopy: /* rop0 = RROP_BLACK; rop1 = RROP_WHITE; */ + ALU = EGC_COPY_MODE; + break; + case GXandInverted: /* rop0 = RROP_NOP; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_AND_MODE; + break; + case GXnoop: /* rop0 = RROP_NOP; rop1 = RROP_NOP; */ + return 0; + case GXxor: /* rop0 = RROP_NOP; rop1 = RROP_INVERT; */ + ALU = EGC_XOR_MODE; + break; + case GXor: /* rop0 = RROP_NOP; rop1 = RROP_WHITE; */ + ALU = EGC_OR_MODE; + break; + case GXnor: /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/ + ALU = EGC_OR_INV_MODE; + break; + case GXequiv: /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_XOR_MODE; + break; + case GXinvert: /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = EGC_XOR_MODE; + break; + case GXorReverse: /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_AND_INV_MODE; + break; + case GXcopyInverted: /* rop0 = RROP_WHITE; rop1 = RROP_BLACK; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_COPY_MODE; + break; + case GXorInverted: /* rop0 = RROP_WHITE; rop1 = RROP_NOP; */ + pGC->fgPixel = ~pGC->fgPixel; + pGC->bgPixel = ~pGC->bgPixel; + ALU = EGC_OR_MODE; + break; + case GXnand: /* rop0 = RROP_WHITE; rop1 = RROP_INVERT; -- TRICKY */ + ALU = EGC_OR_INV_MODE; + break; + case GXset: /* rop0 = RROP_WHITE; rop1 = RROP_WHITE; */ + pGC->fgPixel = 0x0F; + pGC->bgPixel = 0x0F; + ALU = EGC_COPY_MODE; + break; + } + + outw(EGC_PLANE, ~(pGC->planemask & VGA_ALLPLANES)); + outw(EGC_MODE, ALU); + outw(EGC_FGC, pGC->fgPixel & VGA_ALLPLANES); /* set FGC */ + + return 0; +#endif +} + +/* + Now we will have to set the alu. + Problematic is: How do we handle IsDoubleDash, which draws with both fg + and bg colour? + The answer is: We take care to store the ink colour in one register only. + Then we need set only this register to change the ink. + */ + +/* -- MORE NOTES: + We might try to 'wrap' the mfb functions in a 16-colour wrapper that does + all operations once. However, this does not work: + Some operations (esp) CopyArea may for example cause expositions. + Such expositions will cause data to be copied in from backing store, + and this copying in may damage the contents of the VGA registers. + So we must take care to set the VGA registers at each place where they could + be modified. + */ diff --git a/xorg-server/hw/xfree86/xf4bpp/wm3.h b/xorg-server/hw/xfree86/xf4bpp/wm3.h new file mode 100644 index 000000000..113723283 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/wm3.h @@ -0,0 +1,73 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "vgaReg.h" + +#ifdef PC98_EGC +#define VGA_ALLPLANES 0xFL +#endif + +/* Do call in Write Mode 3. + * We take care of the possibility that two passes are needed. + */ +#ifndef PC98_EGC +#define DO_WM3(pgc,call) \ + { int _tp, _fg, _bg, _alu; \ + _fg = pgc->fgPixel; _bg = pgc->bgPixel; \ + _tp = wm3_set_regs(pgc); \ + (call); \ + if ( _tp ) { \ + _alu = pgc->alu; \ + pgc->alu = GXinvert; \ + _tp = wm3_set_regs(pgc); \ + (call); \ + pgc->alu = _alu; \ + } \ + pgc->fgPixel = _fg; pgc->bgPixel = _bg; \ + } +#else +#define DO_WM3(pgc,call) \ + { int _tp, _fg, _bg; \ + _fg = pgc->fgPixel; _bg = pgc->bgPixel; \ + _tp = wm3_set_regs(pgc); \ + (call); \ + pgc->fgPixel = _fg; pgc->bgPixel = _bg; \ + } +#endif + +#ifndef PC98_EGC +#define WM3_SET_INK(ink) \ + SetVideoGraphics(Set_ResetIndex, ink) +#else +#define WM3_SET_INK(ink) \ + outw(EGC_FGC, ink) +#endif + +/* GJA -- Move a long word to screen memory. + * The reads into 'dummy' are here to load the VGA latches. + * This is a RMW operation except for trivial cases. + * Notice that we ignore the operation. + */ +#ifdef PC98_EGC +#define UPDRW(destp,src) \ + { volatile unsigned short *_dtmp = \ + (volatile unsigned short *)(destp); \ + unsigned int _stmp = (src); \ + *_dtmp = _stmp; _dtmp++; _stmp >>= 16; \ + *_dtmp = _stmp; } +#else +#define UPDRW(destp,src) \ + { volatile char *_dtmp = (volatile char *)(destp); \ + unsigned int _stmp = (src); \ + volatile int dummy; /* Bit bucket. */ \ + _stmp = ldl_u(&_stmp); \ + dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \ + dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \ + dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \ + dummy = *_dtmp; *_dtmp = _stmp; } +#endif + +#define UPDRWB(destp,src) \ + { volatile int dummy; /* Bit bucket. */ \ + dummy = *(destp); *(destp) = (src); } diff --git a/xorg-server/hw/xfree86/xf4bpp/xf4bpp.h b/xorg-server/hw/xfree86/xf4bpp/xf4bpp.h new file mode 100644 index 000000000..cf0822444 --- /dev/null +++ b/xorg-server/hw/xfree86/xf4bpp/xf4bpp.h @@ -0,0 +1,622 @@ + +#ifndef __XF4BPP_H__ +#define __XF4BPP_H__ + + +#include "windowstr.h" +#include "gcstruct.h" +#include "colormapst.h" +#include <X11/fonts/fontstruct.h> +#ifndef PixelType +#define PixelType CARD32 +#endif + +/* ppcArea.c */ +void xf4bppFillArea( + WindowPtr, + int, + BoxPtr, + GCPtr +); + +/* ppcClip.c */ +void xf4bppDestroyClip( + GCPtr +); +void xf4bppChangeClip( + GCPtr, + int, + pointer, + int +); +void xf4bppCopyClip( + GCPtr, + GCPtr +); + +/* ppcCpArea.c */ +RegionPtr xf4bppCopyArea( + DrawablePtr, + DrawablePtr, + GCPtr, + int, + int, + int, + int, + int, + int +); + +/* ppcDepth.c */ +Bool xf4bppDepthOK( + DrawablePtr, + int +); + +/* ppcFillRct.c */ +void xf4bppPolyFillRect( + DrawablePtr, + GCPtr, + int, + xRectangle * +); + +/* ppcWindowFS.c */ +void xf4bppSolidWindowFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); +void xf4bppStippleWindowFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); +void xf4bppOpStippleWindowFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); +void xf4bppTileWindowFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); + +/* xf4bppPixmapFS.c */ +void xf4bppSolidPixmapFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); +void xf4bppStipplePixmapFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); +void xf4bppOpStipplePixmapFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); +void xf4bppTilePixmapFS( + DrawablePtr, + GCPtr, + int, + DDXPointPtr, + int *, + int +); + +/* ppcGC.c */ +Bool xf4bppCreateGC( + GCPtr +); + +/* ppcGetSp.c */ +void xf4bppGetSpans( + DrawablePtr, + int, + DDXPointPtr, + int *, + int, + char * +); + +/* ppcImg.c */ +void xf4bppGetImage( + DrawablePtr, + int, + int, + int, + int, + unsigned int, + unsigned long, + char * +); + +/* ppcLine.c */ +void xf4bppScrnZeroLine( + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +); +void xf4bppScrnZeroDash( + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +); +void xf4bppScrnZeroSegs( + DrawablePtr, + GCPtr, + int, + xSegment * +); + +/* ppcPixmap.c */ +PixmapPtr xf4bppCreatePixmap( + ScreenPtr, + int, + int, + int, + unsigned +); +PixmapPtr xf4bppCopyPixmap( + PixmapPtr +); + +/* ppcPolyPnt.c */ +void xf4bppPolyPoint( + DrawablePtr, + GCPtr, + int, + int, + xPoint * +); + +/* ppcPolyRec.c */ +void xf4bppPolyRectangle( + DrawablePtr, + GCPtr, + int, + xRectangle * +); + +/* ppcQuery.c */ +void xf4bppQueryBestSize( + int, + unsigned short *, + unsigned short *, + ScreenPtr +); + +/* ppcRslvC.c */ +void xf4bppResolveColor( + unsigned short *, + unsigned short *, + unsigned short *, + VisualPtr +); +Bool xf4bppInitializeColormap( + ColormapPtr +); + +/* ppcSetSp.c */ +void xf4bppSetSpans( + DrawablePtr, + GCPtr, + char *, + DDXPointPtr, + int *, + int, + int +); + +/* ppcWindow.c */ +void xf4bppCopyWindow( + WindowPtr, + DDXPointRec, + RegionPtr +); +Bool xf4bppPositionWindow( + WindowPtr, + int, + int +); +Bool xf4bppUnrealizeWindow( + WindowPtr, + int, + int +); +Bool xf4bppDestroyWindow( + WindowPtr +); +Bool xf4bppCreateWindowForXYhardware( + WindowPtr +); + +/* emulOpStip.c */ +void xf4bppOpaqueStipple( + WindowPtr, + PixmapPtr, + unsigned long int, + unsigned long int, + int, + unsigned long int, + int, + int, + int, + int, + int, + int +); + +/* emulRepAre.c */ +void xf4bppReplicateArea( + WindowPtr, + int, + int, + int, + int, + int, + int, + int +); + +/* emulTile.c */ +void xf4bppTileRect( + WindowPtr, + PixmapPtr, + const int, + const unsigned long int, + int, + int, + int, + int, + int, + int +); + +/* vgaGC.c */ +Mask xf4bppChangeWindowGC( + GCPtr, + Mask +); + +/* vgaBitBlt.c */ +void xf4bppBitBlt( + WindowPtr, + int, + int, + int, + int, + int, + int, + int, + int +); + +/* vgaImages.c */ +void xf4bppDrawColorImage( + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int, + const int, + const unsigned long int +); +void xf4bppReadColorImage( + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int +); + +/* vgaLine.c */ +void xf4bppHorzLine( + WindowPtr, + unsigned long int, + int, + unsigned long int, + int, + int, + int +); +void xf4bppVertLine( + WindowPtr, + unsigned long int, + int, + unsigned long int, + int, + int, + int +); +void xf4bppBresLine( + WindowPtr, + unsigned long int, + int, + unsigned long int, + int, + int, + int, + int, + int, + int, + int, + int, + unsigned long int +); + +/* vgaStipple.c */ +void xf4bppFillStipple( + WindowPtr, + const PixmapPtr, + unsigned long int, + const int, + unsigned long int, + int, + int, + int, + int, + const int, + const int +); + +/* vgaSolid.c */ +void xf4bppFillSolid( + WindowPtr, + unsigned long int, + const int, + unsigned long int, + int, + const int, + int, + const int +); + +/* offscreen.c */ +void xf4bppOffBitBlt( + WindowPtr, + const int, + const int, + int, + int, + int, + int, + int, + int +); +void xf4bppOffDrawColorImage( + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int, + const int, + const unsigned long int +); +void xf4bppOffReadColorImage( + WindowPtr, + int, + int, + int, + int, + unsigned char *, + int +); +void xf4bppOffFillSolid( + WindowPtr, + unsigned long int, + const int, + unsigned long int, + int, + const int, + int, + const int +); +void xf4bppOffDrawMonoImage( + WindowPtr, + unsigned char *, + int, + int, + int, + int, + unsigned long int, + int, + unsigned long int +); +void xf4bppOffFillStipple( + WindowPtr, + const PixmapPtr, + unsigned long int, + const int, + unsigned long int, + int, + int, + int, + int, + const int, + const int +); + +/* mfbimggblt.c */ +void xf4bppImageGlyphBlt( + DrawablePtr, + GCPtr, + int, + int, + unsigned int, + CharInfoPtr *, + pointer +); + +/* wm3.c */ +int wm3_set_regs( + GC * +); + +/* ppcIO.c */ +void xf4bppNeverCalled( + void +); +Bool xf4bppScreenInit( + ScreenPtr, + pointer, + int, + int, + int, + int, + int +); + +/* mfbfillarc.c */ +void xf4bppPolyFillArc( + DrawablePtr, + GCPtr, + int, + xArc * +); + +/* mfbzerarc.c */ +void xf4bppZeroPolyArc( + DrawablePtr, + GCPtr, + int, + xArc * +); + +/* mfbline.c */ +void xf4bppSegmentSS ( + DrawablePtr, + GCPtr, + int, + xSegment * +); +void xf4bppLineSS ( + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +); +void xf4bppSegmentSD ( + DrawablePtr, + GCPtr, + int, + xSegment * +); +void xf4bppLineSD ( + DrawablePtr, + GCPtr, + int, + int, + DDXPointPtr +); + +/* mfbbres.c */ +void xf4bppBresS( + PixelType *, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int +); + +/* mfbbresd.c */ +void xf4bppBresD( + DrawablePtr, + int, int, + int *, + unsigned char *, + int, + int *, + int, + PixelType *, + int, int, int, int, int, int, + int, int, + int, int +); + +/* mfbhrzvert.c */ +void xf4bppHorzS( + PixelType *, + int, + int, + int, + int +); +void xf4bppVertS( + PixelType *, + int, + int, + int, + int +); + +#ifdef PC98_EGC + +/* egc_asm.s */ +unsigned char getbits_x( + int, + unsigned int, + pointer, + unsigned int +); +void wcopyr( + pointer, + pointer, + int, + pointer +); +void wcopyl( + pointer, + pointer, + int, + pointer +); +unsigned long int read8Z( + pointer +); + +#endif /* PC98_EGC */ + +#endif /* __XF4BPP_H__ */ diff --git a/xorg-server/hw/xfree86/xf8_16bpp/Makefile.am b/xorg-server/hw/xfree86/xf8_16bpp/Makefile.am new file mode 100644 index 000000000..3c5b8c93d --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_16bpp/Makefile.am @@ -0,0 +1,11 @@ +module_LTLIBRARIES = libxf8_16bpp.la + +sdk_HEADERS = cfb8_16.h + +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/fb + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +libxf8_16bpp_la_LDFLAGS = -avoid-version + +libxf8_16bpp_la_SOURCES = xf8_16module.c diff --git a/xorg-server/hw/xfree86/xf8_16bpp/Makefile.in b/xorg-server/hw/xfree86/xf8_16bpp/Makefile.in new file mode 100644 index 000000000..d930ddce1 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_16bpp/Makefile.in @@ -0,0 +1,700 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/xf8_16bpp +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libxf8_16bpp_la_LIBADD = +am_libxf8_16bpp_la_OBJECTS = xf8_16module.lo +libxf8_16bpp_la_OBJECTS = $(am_libxf8_16bpp_la_OBJECTS) +libxf8_16bpp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libxf8_16bpp_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxf8_16bpp_la_SOURCES) +DIST_SOURCES = $(libxf8_16bpp_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libxf8_16bpp.la +sdk_HEADERS = cfb8_16.h +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/fb +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +libxf8_16bpp_la_LDFLAGS = -avoid-version +libxf8_16bpp_la_SOURCES = xf8_16module.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/xf8_16bpp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/xf8_16bpp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libxf8_16bpp.la: $(libxf8_16bpp_la_OBJECTS) $(libxf8_16bpp_la_DEPENDENCIES) + $(libxf8_16bpp_la_LINK) -rpath $(moduledir) $(libxf8_16bpp_la_OBJECTS) $(libxf8_16bpp_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf8_16module.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/xf8_16bpp/cfb8_16.h b/xorg-server/hw/xfree86/xf8_16bpp/cfb8_16.h new file mode 100644 index 000000000..3a3a68da7 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_16bpp/cfb8_16.h @@ -0,0 +1,36 @@ +/* + * Copyright 2006 Adam Jackson. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _CFB8_16_H +#define _CFB8_16_H + +#include "regionstr.h" +#include "windowstr.h" + +/* this has to stay misnamed for ABI reasons */ + +_X_EXPORT Bool +cfb8_16ScreenInit(ScreenPtr pScreen, pointer pbits16, pointer pbits8, + int xsize, int ysize, int dpix, int dpiy, + int width16, int width8); + +#endif /* _CFB8_16_H */ diff --git a/xorg-server/hw/xfree86/xf8_16bpp/xf8_16module.c b/xorg-server/hw/xfree86/xf8_16bpp/xf8_16module.c new file mode 100644 index 000000000..1a739b040 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_16bpp/xf8_16module.c @@ -0,0 +1,77 @@ +/* + * Copyright 2006 Adam Jackson. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include "misc.h" +#include "servermd.h" +#include "scrnintstr.h" +#include "resource.h" +#include "fb.h" +#include "fboverlay.h" +#include "cfb8_16.h" + +_X_EXPORT Bool +cfb8_16ScreenInit(ScreenPtr pScreen, pointer pbits16, pointer pbits8, + int xsize, int ysize, int dpix, int dpiy, + int width16, int width8) +{ + return + (fbOverlaySetupScreen(pScreen, pbits16, pbits8, xsize, ysize, + dpix, dpiy, width16, width8, 16, 8) && + fbOverlayFinishScreenInit(pScreen, pbits16, pbits8, xsize, ysize, + dpix, dpiy, width16, width8, 16, 8, 16, 8)); +} + +#include "xf86Module.h" + +static MODULESETUPPROTO(xf8_16bppSetup); + +static XF86ModuleVersionInfo VersRec = { + "xf8_16bpp", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 2, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + NULL, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData xf8_16bppModuleData = { + &VersRec, + xf8_16bppSetup, + NULL +}; + +static pointer +xf8_16bppSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + return (pointer)LoadSubModule(module, "fb", NULL, NULL, NULL, NULL, + errmaj, errmin); +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/Makefile.am b/xorg-server/hw/xfree86/xf8_32bpp/Makefile.am new file mode 100644 index 000000000..6f51a628e --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/Makefile.am @@ -0,0 +1,37 @@ +module_LTLIBRARIES = libxf8_32bpp.la + +sdk_HEADERS = cfb8_32.h + +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/mfb -I$(top_srcdir)/cfb + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +libxf8_32bpp_la_LDFLAGS = -avoid-version + +libxf8_32bpp_la_SOURCES = \ + cfbcpyarea.c \ + cfbcpyplane.c \ + cfbgcmisc.c \ + cfbimage.c \ + cfbpntwin.c \ + cfbscrinit.c \ + cfbwindow.c \ + xf86overlay.c \ + cfb8_32module.c \ + cfbgc8.c \ + cfbgc32.c \ + cfbgcunder.c + +libxf8_32bpp_la_LIBADD = $(top_builddir)/cfb32/libcfb32.la + +EXTRA_DIST = cfbgc.c + +cfbgc8.c: $(srcdir)/cfbgc.c + echo '#define PSZ 8' > $@ + echo '#include "$(srcdir)/cfbgc.c"' >> $@ + +cfbgc32.c: $(srcdir)/cfbgc.c + echo '#define PSZ 32' > $@ + echo '#include "$(srcdir)/cfbgc.c"' >> $@ + +DISTCLEANFILES = cfbgc8.c cfbgc32.c diff --git a/xorg-server/hw/xfree86/xf8_32bpp/Makefile.in b/xorg-server/hw/xfree86/xf8_32bpp/Makefile.in new file mode 100644 index 000000000..5bea22162 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/Makefile.in @@ -0,0 +1,739 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/xf8_32bpp +DIST_COMMON = $(sdk_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)" +moduleLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(module_LTLIBRARIES) +libxf8_32bpp_la_DEPENDENCIES = $(top_builddir)/cfb32/libcfb32.la +am_libxf8_32bpp_la_OBJECTS = cfbcpyarea.lo cfbcpyplane.lo cfbgcmisc.lo \ + cfbimage.lo cfbpntwin.lo cfbscrinit.lo cfbwindow.lo \ + xf86overlay.lo cfb8_32module.lo cfbgc8.lo cfbgc32.lo \ + cfbgcunder.lo +libxf8_32bpp_la_OBJECTS = $(am_libxf8_32bpp_la_OBJECTS) +libxf8_32bpp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libxf8_32bpp_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libxf8_32bpp_la_SOURCES) +DIST_SOURCES = $(libxf8_32bpp_la_SOURCES) +sdkHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(sdk_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +module_LTLIBRARIES = libxf8_32bpp.la +sdk_HEADERS = cfb8_32.h +INCLUDES = $(XORG_INCS) -I$(top_srcdir)/mfb -I$(top_srcdir)/cfb +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) +libxf8_32bpp_la_LDFLAGS = -avoid-version +libxf8_32bpp_la_SOURCES = \ + cfbcpyarea.c \ + cfbcpyplane.c \ + cfbgcmisc.c \ + cfbimage.c \ + cfbpntwin.c \ + cfbscrinit.c \ + cfbwindow.c \ + xf86overlay.c \ + cfb8_32module.c \ + cfbgc8.c \ + cfbgc32.c \ + cfbgcunder.c + +libxf8_32bpp_la_LIBADD = $(top_builddir)/cfb32/libcfb32.la +EXTRA_DIST = cfbgc.c +DISTCLEANFILES = cfbgc8.c cfbgc32.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/xf8_32bpp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/xf8_32bpp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-moduleLTLIBRARIES: $(module_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)" + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moduledir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moduledir)/$$f"; \ + else :; fi; \ + done + +uninstall-moduleLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moduledir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moduledir)/$$p"; \ + done + +clean-moduleLTLIBRARIES: + -test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES) + @list='$(module_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libxf8_32bpp.la: $(libxf8_32bpp_la_OBJECTS) $(libxf8_32bpp_la_DEPENDENCIES) + $(libxf8_32bpp_la_LINK) -rpath $(moduledir) $(libxf8_32bpp_la_OBJECTS) $(libxf8_32bpp_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfb8_32module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbcpyarea.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbcpyplane.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbgc32.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbgc8.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbgcmisc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbgcunder.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbimage.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbpntwin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbscrinit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfbwindow.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86overlay.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-sdkHEADERS: $(sdk_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(sdkdir)" || $(MKDIR_P) "$(DESTDIR)$(sdkdir)" + @list='$(sdk_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sdkHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(sdkdir)/$$f'"; \ + $(sdkHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +uninstall-sdkHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(sdk_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sdkdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sdkdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moduledir)" "$(DESTDIR)$(sdkdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-moduleLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-moduleLTLIBRARIES install-sdkHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-moduleLTLIBRARIES uninstall-sdkHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-moduleLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-moduleLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-sdkHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-moduleLTLIBRARIES \ + uninstall-sdkHEADERS + + +cfbgc8.c: $(srcdir)/cfbgc.c + echo '#define PSZ 8' > $@ + echo '#include "$(srcdir)/cfbgc.c"' >> $@ + +cfbgc32.c: $(srcdir)/cfbgc.c + echo '#define PSZ 32' > $@ + echo '#include "$(srcdir)/cfbgc.c"' >> $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfb8_32.h b/xorg-server/hw/xfree86/xf8_32bpp/cfb8_32.h new file mode 100644 index 000000000..6e985da20 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfb8_32.h @@ -0,0 +1,191 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _CFB8_32_H +#define _CFB8_32_H + +#include "gcstruct.h" + +typedef struct { + GCOps *Ops8bpp; + GCOps *Ops32bpp; + unsigned long changes; + Bool OpsAre8bpp; +} cfb8_32GCRec, *cfb8_32GCPtr; + +typedef struct { + unsigned char key; + void (*EnableDisableFBAccess)(int scrnIndex, Bool enable); + pointer visualData; +} cfb8_32ScreenRec, *cfb8_32ScreenPtr; + + +extern DevPrivateKey cfb8_32GetGCPrivateKey(void); +extern DevPrivateKey cfb8_32GetScreenPrivateKey(void); + +RegionPtr +cfb8_32CopyArea( + DrawablePtr pSrcDraw, + DrawablePtr pDstDraw, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +); + +void +cfbDoBitblt8To32( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long planemask +); + +void +cfbDoBitblt32To8( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long planemask +); + + +void +cfb8_32ValidateGC8( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +); + +void +cfb8_32ValidateGC32( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +); + +void +cfb32ValidateGC_Underlay( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +); + +Bool cfb8_32CreateGC(GCPtr pGC); + +void +cfb8_32GetSpans( + DrawablePtr pDraw, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pchardstStart +); + +void +cfb8_32PutImage ( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +); + +void +cfb8_32GetImage ( + DrawablePtr pDraw, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planeMask, + char *pdstLine +); + +Bool +cfb8_32ScreenInit ( + ScreenPtr pScreen, + pointer pbits, + int xsize, int ysize, + int dpix, int dpiy, + int width +); + +void +cfb8_32FillBoxSolid8 ( + DrawablePtr pDraw, + int nbox, + BoxPtr pBox, + unsigned long color +); + +RegionPtr +cfb8_32CopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +); + +void +cfbDoBitblt8To8GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm +); + +void +cfbDoBitblt24To24GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm +); + +Bool cfb8_32CreateWindow(WindowPtr pWin); +Bool cfb8_32DestroyWindow(WindowPtr pWin); + +Bool +cfb8_32PositionWindow( + WindowPtr pWin, + int x, int y +); + +void +cfb8_32CopyWindow( + WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc +); + +Bool +cfb8_32ChangeWindowAttributes( + WindowPtr pWin, + unsigned long mask +); + + +#define CFB8_32_GET_GC_PRIVATE(pGC) ((cfb8_32GCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, cfb8_32GetGCPrivateKey())) + +#define CFB8_32_GET_SCREEN_PRIVATE(pScreen) ((cfb8_32ScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, cfb8_32GetScreenPrivateKey())) + +Bool xf86Overlay8Plus32Init (ScreenPtr pScreen); + +#endif /* _CFB8_32_H */ diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfb8_32module.c b/xorg-server/hw/xfree86/xf8_32bpp/cfb8_32module.c new file mode 100644 index 000000000..5afabe52d --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfb8_32module.c @@ -0,0 +1,39 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86Module.h" + +static MODULESETUPPROTO(xf8_32bppSetup); + +static XF86ModuleVersionInfo VersRec = +{ + "xf8_32bpp", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_ANSIC, /* Only need the ansic layer */ + ABI_ANSIC_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} /* signature, to be patched into the file by a tool */ +}; + +_X_EXPORT XF86ModuleData xf8_32bppModuleData = { + &VersRec, + xf8_32bppSetup, + NULL +}; + +static pointer +xf8_32bppSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + if (!LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL, + errmaj, errmin)) + return NULL; + if (!LoadSubModule(module, "cfb32", NULL, NULL, NULL, NULL, + errmaj, errmin)) + return NULL; + return (pointer)1; /* non-NULL required to indicate success */ +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbcpyarea.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbcpyarea.c new file mode 100644 index 000000000..d8f0c6d76 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbcpyarea.c @@ -0,0 +1,549 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include <X11/X.h> +#include <X11/Xmd.h> +#include "servermd.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "resource.h" +#include "colormap.h" +#include "colormapst.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" +#include "mistruct.h" +#include "dix.h" +#include "mibstore.h" + + +RegionPtr +cfb8_32CopyArea( + DrawablePtr pSrcDraw, + DrawablePtr pDstDraw, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + + if(pSrcDraw->bitsPerPixel == 32) { + if(pDstDraw->bitsPerPixel == 32) { + if((pGC->alu == GXcopy) && (pGC->planemask == 0xff000000)) { + return cfb32BitBlt (pSrcDraw, pDstDraw, + pGC, srcx, srcy, width, height, dstx, dsty, + cfbDoBitblt8To8GXcopy, 0L); + } + return(cfb32CopyArea(pSrcDraw, pDstDraw, pGC, srcx, srcy, + width, height, dstx, dsty)); + } else { + /* have to translate 32 -> 8 copies */ + return cfb32BitBlt (pSrcDraw, pDstDraw, + pGC, srcx, srcy, width, height, dstx, dsty, + cfbDoBitblt32To8, 0L); + } + } else { + if(pDstDraw->bitsPerPixel == 32) { + /* have to translate 8 -> 32 copies */ + return cfb32BitBlt (pSrcDraw, pDstDraw, + pGC, srcx, srcy, width, height, dstx, dsty, + cfbDoBitblt8To32, 0L); + } else { + return(cfbCopyArea(pSrcDraw, pDstDraw, pGC, srcx, srcy, + width, height, dstx, dsty)); + } + } +} + + + + +void +cfbDoBitblt8To32( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm +){ + BoxPtr pbox = REGION_RECTS(prgnDst); + int nbox = REGION_NUM_RECTS(prgnDst); + unsigned char *ptr8, *ptr32; + unsigned char *data8, *data32; + int pitch8, pitch32; + int height, width, i; + + cfbGetByteWidthAndPointer(pSrc, pitch8, ptr8); + cfbGetByteWidthAndPointer(pDst, pitch32, ptr32); + ptr32 += 3; /* point to the top byte */ + + pm >>= 24; + + if((pm == 0xff) && (rop == GXcopy)) { + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pptSrc->y * pitch8) + pptSrc->x; + data32 = ptr32 + (pbox->y1 * pitch32) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + for(i = 0; i < width; i++) + data32[i << 2] = data8[i]; + data8 += pitch8; + data32 += pitch32; + } + } + } else { /* it ain't pretty, but hey */ + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pptSrc->y * pitch8) + pptSrc->x; + data32 = ptr32 + (pbox->y1 * pitch32) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + switch(rop) { + case GXcopy: + for(i = 0; i < width; i++) + data32[i<<2] = (data8[i] & pm) | (data32[i<<2] & ~pm); + break; + case GXor: + for(i = 0; i < width; i++) + data32[i<<2] |= data8[i] & pm; + break; + case GXclear: + for(i = 0; i < width; i++) + data32[i<<2] &= ~pm; + break; + case GXand: + for(i = 0; i < width; i++) + data32[i<<2] &= data8[i] | ~pm; + break; + case GXandReverse: + for(i = 0; i < width; i++) + data32[i<<2] = ~data32[i<<2] & (data8[i] | ~pm); + break; + case GXandInverted: + for(i = 0; i < width; i++) + data32[i<<2] &= ~data8[i] | ~pm; + break; + case GXnoop: + return; + case GXxor: + for(i = 0; i < width; i++) + data32[i<<2] ^= data8[i] & pm; + break; + case GXnor: + for(i = 0; i < width; i++) + data32[i<<2] = ~(data32[i<<2] | (data8[i] & pm)); + break; + case GXequiv: + for(i = 0; i < width; i++) + data32[i<<2] = ~(data32[i<<2] ^ (data8[i] & pm)); + break; + case GXinvert: + for(i = 0; i < width; i++) + data32[i<<2] ^= pm; + break; + case GXorReverse: + for(i = 0; i < width; i++) + data32[i<<2] = ~data32[i<<2] | (data8[i] & pm); + break; + case GXcopyInverted: + for(i = 0; i < width; i++) + data32[i<<2] = (~data8[i] & pm) | (data32[i<<2] & ~pm); + break; + case GXorInverted: + for(i = 0; i < width; i++) + data32[i<<2] |= ~data8[i] & pm; + break; + case GXnand: + for(i = 0; i < width; i++) + data32[i<<2] = ~(data32[i<<2] & (data8[i] | ~pm)); + break; + case GXset: + for(i = 0; i < width; i++) + data32[i<<2] |= pm; + break; + } + data8 += pitch8; + data32 += pitch32; + } + } + } +} + + +void +cfbDoBitblt32To8( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm +){ + BoxPtr pbox = REGION_RECTS(prgnDst); + int nbox = REGION_NUM_RECTS(prgnDst); + unsigned char *ptr8, *ptr32; + unsigned char *data8, *data32; + int pitch8, pitch32; + int height, width, i; + + cfbGetByteWidthAndPointer(pDst, pitch8, ptr8); + cfbGetByteWidthAndPointer(pSrc, pitch32, ptr32); + ptr32 += 3; /* point to the top byte */ + + if(((pm & 0xff) == 0xff) && (rop == GXcopy)) { + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pbox->y1 * pitch8) + pbox->x1; + data32 = ptr32 + (pptSrc->y * pitch32) + (pptSrc->x << 2); + + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + for(i = 0; i < width; i++) + data8[i] = data32[i << 2]; + data8 += pitch8; + data32 += pitch32; + } + } + } else { + for(;nbox; pbox++, pptSrc++, nbox--) { + data8 = ptr8 + (pbox->y1 * pitch8) + pbox->x1; + data32 = ptr32 + (pptSrc->y * pitch32) + (pptSrc->x << 2); + + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + while(height--) { + switch(rop) { + case GXcopy: + for(i = 0; i < width; i++) + data8[i] = (data32[i<<2] & pm) | (data8[i] & ~pm); + break; + case GXor: + for(i = 0; i < width; i++) + data8[i] |= data32[i<<2] & pm; + break; + case GXclear: + for(i = 0; i < width; i++) + data8[i] &= ~pm; + break; + case GXand: + for(i = 0; i < width; i++) + data8[i] &= data32[i<<2] | ~pm; + break; + case GXandReverse: + for(i = 0; i < width; i++) + data8[i] = ~data8[i] & (data32[i<<2] | ~pm); + break; + case GXandInverted: + for(i = 0; i < width; i++) + data8[i] &= ~data32[i<<2] | ~pm; + break; + case GXnoop: + return; + case GXxor: + for(i = 0; i < width; i++) + data8[i] ^= data32[i<<2] & pm; + break; + case GXnor: + for(i = 0; i < width; i++) + data8[i] = ~(data8[i] | (data32[i<<2] & pm)); + break; + case GXequiv: + for(i = 0; i < width; i++) + data8[i] = ~(data8[i] ^ (data32[i<<2] & pm)); + break; + case GXinvert: + for(i = 0; i < width; i++) + data8[i] ^= pm; + break; + case GXorReverse: + for(i = 0; i < width; i++) + data8[i] = ~data8[i] | (data32[i<<2] & pm); + break; + case GXcopyInverted: + for(i = 0; i < width; i++) + data8[i] = (~data32[i<<2] & pm) | (data8[i] & ~pm); + break; + case GXorInverted: + for(i = 0; i < width; i++) + data8[i] |= ~data32[i<<2] & pm; + break; + case GXnand: + for(i = 0; i < width; i++) + data8[i] = ~(data8[i] & (data32[i<<2] | ~pm)); + break; + case GXset: + for(i = 0; i < width; i++) + data8[i] |= pm; + break; + } + data8 += pitch8; + data32 += pitch32; + } + } + } +} + + + +static void +Do8To8Blt( + unsigned char *SrcPtr, + int SrcPitch, + unsigned char *DstPtr, + int DstPitch, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir +){ + int i, j, width, height, ydir2; + CARD8 *src, *dst; + + SrcPtr += 3; + DstPtr += 3; + xdir *= 4; + ydir2 = ydir * DstPitch; + ydir *= SrcPitch; + + for(;nbox; pbox++, pptSrc++, nbox--) { + src = SrcPtr + (pptSrc->y * SrcPitch) + (pptSrc->x << 2); + dst = DstPtr + (pbox->y1 * DstPitch) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(ydir < 0) { + src += (height - 1) * SrcPitch; + dst += (height - 1) * DstPitch; + } + + if(xdir < 0) { + register int tmp = (width - 1) << 2; + src += tmp; + dst += tmp; + } + + while(height--) { + for(i = width, j = 0; i--; j+=xdir) + dst[j] = src[j]; + src += ydir; + dst += ydir2; + } + } +} + +static void +Do24To24Blt( + unsigned char *SrcPtr, + int SrcPitch, + unsigned char *DstPtr, + int DstPitch, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir +){ + int i, j, width, height, ydir2; + CARD8 *src, *dst; + + xdir *= 4; + ydir2 = ydir * DstPitch; + ydir *= SrcPitch; + + for(;nbox; pbox++, pptSrc++, nbox--) { + src = SrcPtr + (pptSrc->y * SrcPitch) + (pptSrc->x << 2); + dst = DstPtr + (pbox->y1 * DstPitch) + (pbox->x1 << 2); + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(ydir < 0) { + src += (height - 1) * SrcPitch; + dst += (height - 1) * DstPitch; + } + + if(xdir < 0) { + register int tmp = (width - 1) << 2; + src += tmp; + dst += tmp; + } + + while(height--) { + for(i = width, j = 0; i--; j+=xdir) { + *((CARD16*)(dst + j)) = *((CARD32*)(src + j)); + dst[j + 2] = src[j + 2]; + } + src += ydir; + dst += ydir2; + } + } +} + + +static void +cfb8_32DoBitBlt( + DrawablePtr pSrc, + DrawablePtr pDst, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + void (*DoBlt)( + unsigned char *SrcPtr, + int SrcPitch, + unsigned char *DstPtr, + int DstPitch, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir) +){ + int nbox, careful, SrcPitch, DstPitch; + BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2; + DDXPointPtr pptTmp, pptNew1, pptNew2; + int xdir, ydir; + unsigned char *SrcPtr, *DstPtr; + + /* XXX we have to err on the side of safety when both are windows, + * because we don't know if IncludeInferiors is being used. + */ + careful = ((pSrc == pDst) || + ((pSrc->type == DRAWABLE_WINDOW) && + (pDst->type == DRAWABLE_WINDOW))); + + pbox = REGION_RECTS(prgnDst); + nbox = REGION_NUM_RECTS(prgnDst); + + pboxNew1 = NULL; + pptNew1 = NULL; + pboxNew2 = NULL; + pptNew2 = NULL; + if (careful && (pptSrc->y < pbox->y1)) { + /* walk source botttom to top */ + ydir = -1; + + if (nbox > 1) { + /* keep ordering in each band, reverse order of bands */ + pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox); + if(!pboxNew1) + return; + pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox); + if(!pptNew1) { + xfree(pboxNew1); + return; + } + pboxBase = pboxNext = pbox+nbox-1; + while (pboxBase >= pbox) { + while ((pboxNext >= pbox) && + (pboxBase->y1 == pboxNext->y1)) + pboxNext--; + pboxTmp = pboxNext+1; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp <= pboxBase) { + *pboxNew1++ = *pboxTmp++; + *pptNew1++ = *pptTmp++; + } + pboxBase = pboxNext; + } + pboxNew1 -= nbox; + pbox = pboxNew1; + pptNew1 -= nbox; + pptSrc = pptNew1; + } + } else { + /* walk source top to bottom */ + ydir = 1; + } + + if (careful && (pptSrc->x < pbox->x1)) { + /* walk source right to left */ + xdir = -1; + + if (nbox > 1) { + /* reverse order of rects in each band */ + pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox); + pptNew2 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox); + if(!pboxNew2 || !pptNew2) { + if (pptNew2) xfree(pptNew2); + if (pboxNew2) xfree(pboxNew2); + if (pboxNew1) { + xfree(pptNew1); + xfree(pboxNew1); + } + return; + } + pboxBase = pboxNext = pbox; + while (pboxBase < pbox+nbox) { + while ((pboxNext < pbox+nbox) && + (pboxNext->y1 == pboxBase->y1)) + pboxNext++; + pboxTmp = pboxNext; + pptTmp = pptSrc + (pboxTmp - pbox); + while (pboxTmp != pboxBase) { + *pboxNew2++ = *--pboxTmp; + *pptNew2++ = *--pptTmp; + } + pboxBase = pboxNext; + } + pboxNew2 -= nbox; + pbox = pboxNew2; + pptNew2 -= nbox; + pptSrc = pptNew2; + } + } else { + /* walk source left to right */ + xdir = 1; + } + + cfbGetByteWidthAndPointer(pSrc, SrcPitch, SrcPtr); + cfbGetByteWidthAndPointer(pDst, DstPitch, DstPtr); + + (*DoBlt)(SrcPtr,SrcPitch,DstPtr,DstPitch,nbox,pptSrc,pbox,xdir,ydir); + + if (pboxNew2) { + xfree(pptNew2); + xfree(pboxNew2); + } + if (pboxNew1) { + xfree(pptNew1); + xfree(pboxNew1); + } + +} + + +/* A couple routines to speed up full planemask copies */ + +void +cfbDoBitblt8To8GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm +){ + cfb8_32DoBitBlt(pSrc, pDst, prgnDst, pptSrc, Do8To8Blt); +} + + +void +cfbDoBitblt24To24GXcopy( + DrawablePtr pSrc, + DrawablePtr pDst, + int rop, + RegionPtr prgnDst, + DDXPointPtr pptSrc, + unsigned long pm +){ + cfb8_32DoBitBlt(pSrc, pDst, prgnDst, pptSrc, Do24To24Blt); +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbcpyplane.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbcpyplane.c new file mode 100644 index 000000000..e10b52525 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbcpyplane.c @@ -0,0 +1,41 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include "gcstruct.h" +#include "windowstr.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "regionstr.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" + + +RegionPtr +cfb8_32CopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + /* There's actually much more to it than this */ + + if((pDst->bitsPerPixel == 8) && (pSrc->bitsPerPixel != 32)){ + return(cfbCopyPlane(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)); + } + + + return(miCopyPlane (pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)); +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbgc.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbgc.c new file mode 100644 index 000000000..a7787caa9 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbgc.c @@ -0,0 +1,646 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + + +/* + +PSZ 8 16 24 32 +PIXEL_ADDR True True True True +NO_ONE_RECT False False False False +WriteBitGroup True True True True +FOUR_BIT_CODE True False False False +LOWMEMFTPT False False False False + +*/ + + +/* This gets built twice. Once for 8bpp and another for 32bpp */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include "cfb.h" +#include <X11/fonts/fontstruct.h> +#include "dixfontstr.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "region.h" + +#include "mistruct.h" +#include "mibstore.h" +#include "migc.h" +#include "mioverlay.h" + +#include "cfb8_32.h" +#include "cfbmskbits.h" +#include "cfb8bit.h" + + +#if PSZ == 8 +# define useTEGlyphBlt cfbTEGlyphBlt8 +#else +# ifdef WriteBitGroup +# define useTEGlyphBlt cfbImageGlyphBlt8 +# else +# define useTEGlyphBlt cfbTEGlyphBlt +# endif +#endif + +#ifdef WriteBitGroup +# define useImageGlyphBlt cfbImageGlyphBlt8 +# define usePolyGlyphBlt cfbPolyGlyphBlt8 +#else +# define useImageGlyphBlt miImageGlyphBlt +# define usePolyGlyphBlt miPolyGlyphBlt +#endif + +#ifdef FOUR_BIT_CODE +# define usePushPixels cfbPushPixels8 +#else +# define usePushPixels mfbPushPixels +#endif + +#ifdef PIXEL_ADDR +# define ZeroPolyArc cfbZeroPolyArcSS8Copy +#else +# define ZeroPolyArc miZeroPolyArc +#endif + + +static GCOps cfb8_32TEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps cfb8_32NonTEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps cfb8_32TEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, + ZeroPolyArc, + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps cfb8_32NonTEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfb8_32PutImage, + cfb8_32CopyArea, + cfb8_32CopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, +#ifdef PIXEL_ADDR + cfbZeroPolyArcSS8Copy, +#else + miZeroPolyArc, +#endif + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps * +cfb8_32MatchCommon (GCPtr pGC, cfbPrivGCPtr devPriv) +{ + if (pGC->lineWidth != 0) + return 0; + if (pGC->lineStyle != LineSolid) + return 0; + if (pGC->fillStyle != FillSolid) + return 0; + if (devPriv->rop != GXcopy) + return 0; + if (pGC->font && + FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 && + FONTMINBOUNDS(pGC->font,characterWidth) >= 0) + { + if (TERMINALFONT(pGC->font) +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) +#ifdef NO_ONE_RECT + return &cfb8_32TEOps1Rect; +#else + if (devPriv->oneRect) + return &cfb8_32TEOps1Rect; + else + return &cfb8_32TEOps; +#endif + else +#ifdef NO_ONE_RECT + return &cfb8_32NonTEOps1Rect; +#else + if (devPriv->oneRect) + return &cfb8_32NonTEOps1Rect; + else + return &cfb8_32NonTEOps; +#endif + } + return 0; +} + + +/* Clipping conventions + if the drawable is a window + CT_REGION ==> pCompositeClip really is the composite + CT_other ==> pCompositeClip is the window clip region + if the drawable is a pixmap + CT_REGION ==> pCompositeClip is the translated client region + clipped to the pixmap boundary + CT_other ==> pCompositeClip is the pixmap bounding box +*/ + +void +#if PSZ == 8 +cfb8_32ValidateGC8( +#else +cfb8_32ValidateGC32( +#endif + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +){ + int mask; /* stateChanges */ + int index; /* used for stepping through bitfields */ + int new_rrop; + int new_line, new_text, new_fillspans, new_fillarea; + /* flags for changing the proc vector */ + cfbPrivGCPtr devPriv; + int oneRect; + + pGC->lastWinOrg.x = pDrawable->x; + pGC->lastWinOrg.y = pDrawable->y; + devPriv = cfbGetGCPrivate(pGC); + + new_rrop = FALSE; + new_line = FALSE; + new_text = FALSE; + new_fillspans = FALSE; + new_fillarea = FALSE; + + /* + * if the client clip is different or moved OR the subwindowMode has + * changed OR the window's clip has changed since the last validation + * we need to recompute the composite clip + */ + + if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || + (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))) + { + miComputeCompositeClip (pGC, pDrawable); +#ifdef NO_ONE_RECT + devPriv->oneRect = FALSE; +#else + oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1; + if (oneRect != devPriv->oneRect) + new_line = TRUE; + devPriv->oneRect = oneRect; +#endif + } + + mask = changes; + while (mask) { + index = lowbit (mask); + mask &= ~index; + + switch (index) { + case GCFunction: + case GCForeground: + new_rrop = TRUE; + break; + case GCPlaneMask: + new_rrop = TRUE; + new_text = TRUE; + break; + case GCBackground: + break; + case GCLineStyle: + case GCLineWidth: + new_line = TRUE; + break; + case GCJoinStyle: + case GCCapStyle: + break; + case GCFillStyle: + new_text = TRUE; + new_fillspans = TRUE; + new_line = TRUE; + new_fillarea = TRUE; + break; + case GCFillRule: + break; + case GCTile: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCStipple: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCTileStipXOrigin: + case GCTileStipYOrigin: + break; + case GCFont: + new_text = TRUE; + break; + case GCSubwindowMode: + case GCGraphicsExposures: + case GCClipXOrigin: + case GCClipYOrigin: + case GCClipMask: + case GCDashOffset: + case GCDashList: + case GCArcMode: + default: + break; + } + } + + /* + * If the drawable has changed, ensure suitable + * entries are in the proc vector. + */ + if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) + new_fillspans = TRUE; /* deal with FillSpans later */ + + if (new_rrop) + { + int old_rrop; + + old_rrop = devPriv->rop; + devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel, + pGC->planemask, + &devPriv->and, &devPriv->xor); + if (old_rrop == devPriv->rop) + new_rrop = FALSE; + else + { +#ifdef PIXEL_ADDR + new_line = TRUE; +#endif +#ifdef WriteBitGroup + new_text = TRUE; +#endif + new_fillspans = TRUE; + new_fillarea = TRUE; + } + } + + if(!pGC->ops) + pGC->ops = & cfb8_32NonTEOps; + + if (new_rrop || new_fillspans || new_text || new_fillarea || new_line) + { + GCOps *newops; + + if ((newops = cfb8_32MatchCommon (pGC, devPriv))) + { + if (pGC->ops->devPrivate.val) + miDestroyGCOps (pGC->ops); + pGC->ops = newops; + new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0; + } + else + { + if (!pGC->ops->devPrivate.val) + { + pGC->ops = miCreateGCOps (pGC->ops); + pGC->ops->devPrivate.val = 1; + } + } + } + + /* deal with the changes we've collected */ + if (new_line) + { + pGC->ops->FillPolygon = miFillPolygon; +#ifdef NO_ONE_RECT + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#else + if (devPriv->oneRect && pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#endif + if (pGC->lineWidth == 0) + { +#ifdef PIXEL_ADDR + if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)) + { + switch (devPriv->rop) + { + case GXxor: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor; + break; + case GXcopy: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy; + break; + default: + pGC->ops->PolyArc = cfbZeroPolyArcSS8General; + break; + } + } + else +#endif + pGC->ops->PolyArc = miZeroPolyArc; + } + else + pGC->ops->PolyArc = miPolyArc; + pGC->ops->PolySegment = miPolySegment; + switch (pGC->lineStyle) + { + case LineSolid: + if(pGC->lineWidth == 0) + { + if (pGC->fillStyle == FillSolid) + { +#if defined(PIXEL_ADDR) && !defined(NO_ONE_RECT) + if (devPriv->oneRect && + ((pDrawable->x >= pGC->pScreen->width - 32768) && + (pDrawable->y >= pGC->pScreen->height - 32768))) + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } else +#endif +#ifdef NO_ONE_RECT + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } +#else + { + pGC->ops->Polylines = cfbLineSS; + pGC->ops->PolySegment = cfbSegmentSS; + } +#endif + } + else + pGC->ops->Polylines = miZeroLine; + } + else + pGC->ops->Polylines = miWideLine; + break; + case LineOnOffDash: + case LineDoubleDash: + if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) + { + pGC->ops->Polylines = cfbLineSD; + pGC->ops->PolySegment = cfbSegmentSD; + } else + pGC->ops->Polylines = miWideDash; + break; + } + } + + if (new_text && (pGC->font)) + { + if (FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 || + FONTMINBOUNDS(pGC->font,characterWidth) < 0) + { + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + else + { +#ifdef WriteBitGroup + if (pGC->fillStyle == FillSolid) + { + if (devPriv->rop == GXcopy) + pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8; + else +#ifdef FOUR_BIT_CODE + pGC->ops->PolyGlyphBlt = cfbPolyGlyphRop8; +#else + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; +#endif + } + else +#endif + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + /* special case ImageGlyphBlt for terminal emulator fonts */ +#if !defined(WriteBitGroup) || PSZ == 8 + if (TERMINALFONT(pGC->font) && + (pGC->planemask & PMSK) == PMSK +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) + { + pGC->ops->ImageGlyphBlt = useTEGlyphBlt; + } + else +#endif + { +#ifdef WriteBitGroup + if (devPriv->rop == GXcopy && + pGC->fillStyle == FillSolid && + (pGC->planemask & PMSK) == PMSK) + pGC->ops->ImageGlyphBlt = cfbImageGlyphBlt8; + else +#endif + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + } + } + + + if (new_fillspans) { + switch (pGC->fillStyle) { + case FillSolid: + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillSpans = cfbSolidSpansCopy; + break; + case GXxor: + pGC->ops->FillSpans = cfbSolidSpansXor; + break; + default: + pGC->ops->FillSpans = cfbSolidSpansGeneral; + break; + } + break; + case FillTiled: + pGC->ops->FillSpans = cfbUnnaturalTileFS; + break; + case FillStippled: + case FillOpaqueStippled: + pGC->ops->FillSpans = cfbUnnaturalStippleFS; + break; + default: + FatalError("cfbValidateGC: illegal fillStyle\n"); + } + } /* end of new_fillspans */ + + if (new_fillarea) { +#ifndef FOUR_BIT_CODE + pGC->ops->PolyFillRect = miPolyFillRect; + if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) + { + pGC->ops->PolyFillRect = cfbPolyFillRect; + } +#endif +#ifdef FOUR_BIT_CODE + pGC->ops->PushPixels = mfbPushPixels; + if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy) + pGC->ops->PushPixels = cfbPushPixels8; +#endif + pGC->ops->PolyFillArc = miPolyFillArc; + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) + { + case GXcopy: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy; + break; + default: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidGeneral; + break; + } + } + } +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbgc32.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbgc32.c new file mode 100644 index 000000000..61a97b97b --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbgc32.c @@ -0,0 +1,2 @@ +#define PSZ 32 +#include "./cfbgc.c" diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbgc8.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbgc8.c new file mode 100644 index 000000000..53e4f95e4 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbgc8.c @@ -0,0 +1,2 @@ +#define PSZ 8 +#include "./cfbgc.c" diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbgcmisc.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbgcmisc.c new file mode 100644 index 000000000..f009afc0c --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbgcmisc.c @@ -0,0 +1,150 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include <X11/X.h> +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include <X11/fonts/fontstruct.h> +#include "dixfontstr.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "region.h" + +#include "mistruct.h" +#include "mibstore.h" +#include "migc.h" + + +static void cfb8_32ValidateGC(GCPtr, unsigned long, DrawablePtr); +static void cfb8_32DestroyGC(GCPtr pGC); +static void cfb32DestroyGC_Underlay(GCPtr pGC); + +static +GCFuncs cfb8_32GCFuncs = { + cfb8_32ValidateGC, + miChangeGC, + miCopyGC, + cfb8_32DestroyGC, + miChangeClip, + miDestroyClip, + miCopyClip, +}; + + +static +GCFuncs cfb32GCFuncs_Underlay = { + cfb32ValidateGC_Underlay, + miChangeGC, + miCopyGC, + cfb32DestroyGC_Underlay, + miChangeClip, + miDestroyClip, + miCopyClip, +}; + +static void +cfb32DestroyGC_Underlay(GCPtr pGC) +{ + if (pGC->freeCompClip) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + + if(pGC->ops) + miDestroyGCOps(pGC->ops); +} + + +static void +cfb8_32DestroyGC(GCPtr pGC) +{ + cfb8_32GCPtr pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC); + + if (pGC->freeCompClip) + REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); + if(pGCPriv->Ops8bpp) + miDestroyGCOps(pGCPriv->Ops8bpp); + if(pGCPriv->Ops32bpp) + miDestroyGCOps(pGCPriv->Ops32bpp); +} + +Bool +cfb8_32CreateGC(GCPtr pGC) +{ + cfb8_32GCPtr pGCPriv; + cfbPrivGC *pPriv; + + if (PixmapWidthPaddingInfo[pGC->depth].padPixelsLog2 == LOG2_BITMAP_PAD) + return (mfbCreateGC(pGC)); + + pGC->clientClip = NULL; + pGC->clientClipType = CT_NONE; + pGC->miTranslate = 1; + pGC->fExpose = TRUE; + pGC->freeCompClip = FALSE; + pGC->pRotatedPixmap = (PixmapPtr) NULL; + + pPriv = cfbGetGCPrivate(pGC); + pPriv->rop = pGC->alu; + pPriv->oneRect = FALSE; + + pGC->ops = NULL; + + if (pGC->depth == 8) { + pGC->funcs = &cfb8_32GCFuncs; + + pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC); + pGCPriv->Ops8bpp = NULL; + pGCPriv->Ops32bpp = NULL; + pGCPriv->OpsAre8bpp = FALSE; + pGCPriv->changes = 0; + } else + pGC->funcs = &cfb32GCFuncs_Underlay; + + return TRUE; +} + + +static void +cfb8_32ValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + cfb8_32GCPtr pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC); + + if(pDraw->bitsPerPixel == 32) { + if(pGCPriv->OpsAre8bpp) { + int origChanges = changes; + pGC->ops = pGCPriv->Ops32bpp; + changes |= pGCPriv->changes; + pGCPriv->changes = origChanges; + pGCPriv->OpsAre8bpp = FALSE; + } else + pGCPriv->changes |= changes; + + cfb8_32ValidateGC32(pGC, changes, pDraw); + pGCPriv->Ops32bpp = pGC->ops; + } else { /* bitsPerPixel == 8 */ + if(!pGCPriv->OpsAre8bpp) { + int origChanges = changes; + pGC->ops = pGCPriv->Ops8bpp; + changes |= pGCPriv->changes; + pGCPriv->changes = origChanges; + pGCPriv->OpsAre8bpp = TRUE; + } else + pGCPriv->changes |= changes; + + cfb8_32ValidateGC8(pGC, changes, pDraw); + pGCPriv->Ops8bpp = pGC->ops; + } +} + diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbgcunder.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbgcunder.c new file mode 100644 index 000000000..d90321355 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbgcunder.c @@ -0,0 +1,620 @@ +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +#define PSZ 32 + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include "cfb.h" +#include <X11/fonts/fontstruct.h> +#include "dixfontstr.h" +#include "gcstruct.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "region.h" + +#include "mistruct.h" +#include "mibstore.h" +#include "migc.h" +#include "mioverlay.h" + +#include "cfbmskbits.h" +#include "cfb8bit.h" +#include "cfb8_32.h" + +#ifdef WriteBitGroup +# define useTEGlyphBlt cfbImageGlyphBlt8 +#else +# define useTEGlyphBlt cfbTEGlyphBlt +#endif + +#ifdef WriteBitGroup +# define useImageGlyphBlt cfbImageGlyphBlt8 +# define usePolyGlyphBlt cfbPolyGlyphBlt8 +#else +# define useImageGlyphBlt miImageGlyphBlt +# define usePolyGlyphBlt miPolyGlyphBlt +#endif + +#ifdef FOUR_BIT_CODE +# define usePushPixels cfbPushPixels8 +#else +# define usePushPixels mfbPushPixels +#endif + +#ifdef PIXEL_ADDR +# define ZeroPolyArc cfbZeroPolyArcSS8Copy +#else +# define ZeroPolyArc miZeroPolyArc +#endif + + +static GCOps cfbTEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps cfbNonTEOps1Rect = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, +#ifdef PIXEL_ADDR + cfb8LineSS1Rect, + cfb8SegmentSS1Rect, +#else + cfbLineSS, + cfbSegmentSS, +#endif + miPolyRectangle, + ZeroPolyArc, + cfbFillPoly1RectCopy, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps cfbTEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, + ZeroPolyArc, + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useTEGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps cfbNonTEOps = { + cfbSolidSpansCopy, + cfbSetSpans, + cfbPutImage, + cfbCopyArea, + cfbCopyPlane, + cfbPolyPoint, + cfbLineSS, + cfbSegmentSS, + miPolyRectangle, +#ifdef PIXEL_ADDR + cfbZeroPolyArcSS8Copy, +#else + miZeroPolyArc, +#endif + miFillPolygon, + cfbPolyFillRect, + cfbPolyFillArcSolidCopy, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + useImageGlyphBlt, + usePolyGlyphBlt, + usePushPixels +}; + +static GCOps * +cfb32MatchCommon_Underlay( + GCPtr pGC, + cfbPrivGCPtr devPriv) +{ + if (pGC->lineWidth != 0) + return 0; + if (pGC->lineStyle != LineSolid) + return 0; + if (pGC->fillStyle != FillSolid) + return 0; + if (devPriv->rop != GXcopy) + return 0; + if (pGC->font && + FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 && + FONTMINBOUNDS(pGC->font,characterWidth) >= 0) + { + if (TERMINALFONT(pGC->font) +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) +#ifdef NO_ONE_RECT + return &cfbTEOps1Rect; +#else + if (devPriv->oneRect) + return &cfbTEOps1Rect; + else + return &cfbTEOps; +#endif + else +#ifdef NO_ONE_RECT + return &cfbNonTEOps1Rect; +#else + if (devPriv->oneRect) + return &cfbNonTEOps1Rect; + else + return &cfbNonTEOps; +#endif + } + return 0; +} + + +void +cfb32ValidateGC_Underlay( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable +){ + int mask; /* stateChanges */ + int index; /* used for stepping through bitfields */ + int new_rrop; + int new_line, new_text, new_fillspans, new_fillarea; + /* flags for changing the proc vector */ + cfbPrivGCPtr devPriv; + int oneRect; + + pGC->lastWinOrg.x = pDrawable->x; + pGC->lastWinOrg.y = pDrawable->y; + devPriv = cfbGetGCPrivate(pGC); + + new_rrop = FALSE; + new_line = FALSE; + new_text = FALSE; + new_fillspans = FALSE; + new_fillarea = FALSE; + + /* + * if the client clip is different or moved OR the subwindowMode has + * changed OR the window's clip has changed since the last validation + * we need to recompute the composite clip + */ + + if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || + (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) + ) + { + if(pDrawable->type == DRAWABLE_WINDOW) + miOverlayComputeCompositeClip (pGC, (WindowPtr)pDrawable); + else + miComputeCompositeClip (pGC, pDrawable); +#ifdef NO_ONE_RECT + devPriv->oneRect = FALSE; +#else + oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1; + if (oneRect != devPriv->oneRect) + new_line = TRUE; + devPriv->oneRect = oneRect; +#endif + } + + mask = changes; + while (mask) { + index = lowbit (mask); + mask &= ~index; + + switch (index) { + case GCFunction: + case GCForeground: + new_rrop = TRUE; + break; + case GCPlaneMask: + new_rrop = TRUE; + new_text = TRUE; + break; + case GCBackground: + break; + case GCLineStyle: + case GCLineWidth: + new_line = TRUE; + break; + case GCJoinStyle: + case GCCapStyle: + break; + case GCFillStyle: + new_text = TRUE; + new_fillspans = TRUE; + new_line = TRUE; + new_fillarea = TRUE; + break; + case GCFillRule: + break; + case GCTile: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCStipple: + new_fillspans = TRUE; + new_fillarea = TRUE; + break; + case GCTileStipXOrigin: + case GCTileStipYOrigin: + break; + case GCFont: + new_text = TRUE; + break; + case GCSubwindowMode: + case GCGraphicsExposures: + case GCClipXOrigin: + case GCClipYOrigin: + case GCClipMask: + case GCDashOffset: + case GCDashList: + case GCArcMode: + default: + break; + } + } + + /* + * If the drawable has changed, ensure suitable + * entries are in the proc vector. + */ + if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) + new_fillspans = TRUE; /* deal with FillSpans later */ + + if (new_rrop) + { + int old_rrop; + + old_rrop = devPriv->rop; + devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel, + pGC->planemask, + &devPriv->and, &devPriv->xor); + if (old_rrop == devPriv->rop) + new_rrop = FALSE; + else + { +#ifdef PIXEL_ADDR + new_line = TRUE; +#endif +#ifdef WriteBitGroup + new_text = TRUE; +#endif + new_fillspans = TRUE; + new_fillarea = TRUE; + } + } + + if(!pGC->ops) + pGC->ops = & cfbNonTEOps; + + + if (new_rrop || new_fillspans || new_text || new_fillarea || new_line) + { + GCOps *newops; + + if ((newops = cfb32MatchCommon_Underlay (pGC, devPriv))) + { + if (pGC->ops->devPrivate.val) + miDestroyGCOps (pGC->ops); + pGC->ops = newops; + new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0; + } + else + { + if (!pGC->ops->devPrivate.val) + { + pGC->ops = miCreateGCOps (pGC->ops); + pGC->ops->devPrivate.val = 1; + } + } + } + + /* deal with the changes we've collected */ + if (new_line) + { + pGC->ops->FillPolygon = miFillPolygon; +#ifdef NO_ONE_RECT + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#else + if (devPriv->oneRect && pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillPolygon = cfbFillPoly1RectCopy; + break; + default: + pGC->ops->FillPolygon = cfbFillPoly1RectGeneral; + break; + } + } +#endif + if (pGC->lineWidth == 0) + { +#ifdef PIXEL_ADDR + if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)) + { + switch (devPriv->rop) + { + case GXxor: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor; + break; + case GXcopy: + pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy; + break; + default: + pGC->ops->PolyArc = cfbZeroPolyArcSS8General; + break; + } + } + else +#endif + pGC->ops->PolyArc = miZeroPolyArc; + } + else + pGC->ops->PolyArc = miPolyArc; + pGC->ops->PolySegment = miPolySegment; + switch (pGC->lineStyle) + { + case LineSolid: + if(pGC->lineWidth == 0) + { + if (pGC->fillStyle == FillSolid) + { +#if defined(PIXEL_ADDR) && !defined(NO_ONE_RECT) + if (devPriv->oneRect && + ((pDrawable->x >= pGC->pScreen->width - 32768) && + (pDrawable->y >= pGC->pScreen->height - 32768))) + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } else +#endif +#ifdef NO_ONE_RECT + { + pGC->ops->Polylines = cfb8LineSS1Rect; + pGC->ops->PolySegment = cfb8SegmentSS1Rect; + } +#else + { + pGC->ops->Polylines = cfbLineSS; + pGC->ops->PolySegment = cfbSegmentSS; + } +#endif + } + else + pGC->ops->Polylines = miZeroLine; + } + else + pGC->ops->Polylines = miWideLine; + break; + case LineOnOffDash: + case LineDoubleDash: + if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) + { + pGC->ops->Polylines = cfbLineSD; + pGC->ops->PolySegment = cfbSegmentSD; + } else + pGC->ops->Polylines = miWideDash; + break; + } + } + + if (new_text && (pGC->font)) + { + if (FONTMAXBOUNDS(pGC->font,rightSideBearing) - + FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 || + FONTMINBOUNDS(pGC->font,characterWidth) < 0) + { + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + else + { +#ifdef WriteBitGroup + if (pGC->fillStyle == FillSolid) + { + if (devPriv->rop == GXcopy) + pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8; + else +#ifdef FOUR_BIT_CODE + pGC->ops->PolyGlyphBlt = cfbPolyGlyphRop8; +#else + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; +#endif + } + else +#endif + pGC->ops->PolyGlyphBlt = miPolyGlyphBlt; + /* special case ImageGlyphBlt for terminal emulator fonts */ +#if !defined(WriteBitGroup) || PSZ == 8 + if (TERMINALFONT(pGC->font) && + (pGC->planemask & PMSK) == PMSK +#ifdef FOUR_BIT_CODE + && FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB +#endif + ) + { + pGC->ops->ImageGlyphBlt = useTEGlyphBlt; + } + else +#endif + { +#ifdef WriteBitGroup + if (devPriv->rop == GXcopy && + pGC->fillStyle == FillSolid && + (pGC->planemask & PMSK) == PMSK) + pGC->ops->ImageGlyphBlt = cfbImageGlyphBlt8; + else +#endif + pGC->ops->ImageGlyphBlt = miImageGlyphBlt; + } + } + } + + + if (new_fillspans) { + switch (pGC->fillStyle) { + case FillSolid: + switch (devPriv->rop) { + case GXcopy: + pGC->ops->FillSpans = cfbSolidSpansCopy; + break; + case GXxor: + pGC->ops->FillSpans = cfbSolidSpansXor; + break; + default: + pGC->ops->FillSpans = cfbSolidSpansGeneral; + break; + } + break; + case FillTiled: + pGC->ops->FillSpans = cfbUnnaturalTileFS; + break; + case FillStippled: + case FillOpaqueStippled: + pGC->ops->FillSpans = cfbUnnaturalStippleFS; + break; + default: + FatalError("cfbValidateGC: illegal fillStyle\n"); + } + } /* end of new_fillspans */ + + if (new_fillarea) { +#ifndef FOUR_BIT_CODE + pGC->ops->PolyFillRect = miPolyFillRect; + if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) + { + pGC->ops->PolyFillRect = cfbPolyFillRect; + } +#endif +#ifdef FOUR_BIT_CODE + pGC->ops->PushPixels = mfbPushPixels; + if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy) + pGC->ops->PushPixels = cfbPushPixels8; +#endif + pGC->ops->PolyFillArc = miPolyFillArc; + if (pGC->fillStyle == FillSolid) + { + switch (devPriv->rop) + { + case GXcopy: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy; + break; + default: + pGC->ops->PolyFillArc = cfbPolyFillArcSolidGeneral; + break; + } + } + } +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbimage.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbimage.c new file mode 100644 index 000000000..01a5a5eb6 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbimage.c @@ -0,0 +1,174 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> +#include <string.h> + +#include <X11/X.h> +#include "windowstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#include "gcstruct.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "servermd.h" +#include "mi.h" + + +void +cfb8_32GetImage ( + DrawablePtr pDraw, + int sx, int sy, int w, int h, + unsigned int format, + unsigned long planemask, + char *pdstLine +){ + if(!w || !h) return; + + if (!cfbDrawableEnabled (pDraw)) + return; + + if(pDraw->depth == 24){ + cfb32GetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); + return; + } + + if((pDraw->bitsPerPixel == 8) || (pDraw->bitsPerPixel == 1)){ + cfbGetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); + return; + } + + /* source is depth 8, 32 bpp */ + if(format != ZPixmap) { + miGetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine); + return; + } else { + BoxRec box; + DDXPointRec ptSrc; + RegionRec rgnDst; + ScreenPtr pScreen; + PixmapPtr pPixmap; + + pScreen = pDraw->pScreen; + pPixmap = GetScratchPixmapHeader(pScreen, w, h, 8, 8, + PixmapBytePad(w,8), (pointer)pdstLine); + if (!pPixmap) + return; + if ((planemask & 0xff) != 0xff) + memset((char *)pdstLine, 0, pPixmap->devKind * h); + ptSrc.x = sx + pDraw->x; + ptSrc.y = sy + pDraw->y; + box.x1 = 0; + box.y1 = 0; + box.x2 = w; + box.y2 = h; + REGION_INIT(pScreen, &rgnDst, &box, 1); + cfbDoBitblt32To8(pDraw, (DrawablePtr)pPixmap, GXcopy, &rgnDst, + &ptSrc, planemask); + REGION_UNINIT(pScreen, &rgnDst); + FreeScratchPixmapHeader(pPixmap); + } +} + +void +cfb8_32PutImage ( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + if(!w || !h) return; + + if((pDraw->bitsPerPixel == 8) || (format != XYPixmap)){ + cfbPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage); + return; + } else { /* moving an 8bpp XYPixmap to a 32bpp screen */ + unsigned long oldFg, oldBg; + XID gcv[3]; + unsigned long oldPlanemask; + unsigned long i; + long bytesPer; + + oldPlanemask = pGC->planemask; + oldFg = pGC->fgPixel; + oldBg = pGC->bgPixel; + gcv[0] = ~0L; + gcv[1] = 0; + DoChangeGC(pGC, GCForeground | GCBackground, gcv, 0); + bytesPer = (long)h * BitmapBytePad(w + leftPad); + + for (i = 0x80000000; i & 0xff000000; i >>= 1, pImage += bytesPer) + { + if (i & oldPlanemask) + { + gcv[0] = i; + DoChangeGC(pGC, GCPlaneMask, gcv, 0); + ValidateGC(pDraw, pGC); + (*pGC->ops->PutImage)(pDraw, pGC, 1, x, y, w, h, leftPad, + XYBitmap, pImage); + } + } + gcv[0] = oldPlanemask; + gcv[1] = oldFg; + gcv[2] = oldBg; + DoChangeGC(pGC, GCPlaneMask | GCForeground | GCBackground, gcv, 0); + ValidateGC(pDraw, pGC); + } +} + + + + +void +cfb8_32GetSpans( + DrawablePtr pDraw, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, + char *pDst +){ + int pitch, i; + CARD8 *ptr, *ptrBase; + + if (!cfbDrawableEnabled (pDraw)) + return; + + if(pDraw->bitsPerPixel == 1) { + mfbGetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); + return; + } + + if(pDraw->depth == 24) { + cfb32GetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); + return; + } else if(pDraw->bitsPerPixel == 8) { + cfbGetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst); + return; + } + + /* gotta get spans from a depth 8 window */ + cfbGetByteWidthAndPointer(pDraw, pitch, ptrBase); + ptrBase += 3; /* point to top byte */ + + while(nspans--) { + ptr = ptrBase + (ppt->y * pitch) + (ppt->x << 2); + + for(i = *pwidth; i--; ptr += 4) + *(pDst++) = *ptr; + + pDst = (char*)((long)(pDst + 3) & ~3L); + + ppt++; pwidth++; + } +} + + diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbpntwin.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbpntwin.c new file mode 100644 index 000000000..fbf597d22 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbpntwin.c @@ -0,0 +1,51 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "windowstr.h" +#include "regionstr.h" +#include "pixmapstr.h" +#include "scrnintstr.h" + +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" + +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif + +void +cfb8_32FillBoxSolid8( + DrawablePtr pDraw, + int nbox, + BoxPtr pbox, + unsigned long color +){ + CARD8 *ptr, *data; + int pitch, height, width, i; + CARD8 c = (CARD8)color; + + cfbGetByteWidthAndPointer(pDraw, pitch, ptr); + ptr += 3; /* point to the top byte */ + + while(nbox--) { + data = ptr + (pbox->y1 * pitch) + (pbox->x1 << 2); + width = (pbox->x2 - pbox->x1) << 2; + height = pbox->y2 - pbox->y1; + + while(height--) { + for(i = 0; i < width; i+=4) + data[i] = c; + data += pitch; + } + pbox++; + } +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbscrinit.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbscrinit.c new file mode 100644 index 000000000..c3432b803 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbscrinit.c @@ -0,0 +1,311 @@ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include "misc.h" +#include "servermd.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "resource.h" +#include "colormap.h" +#include "colormapst.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mi.h" +#include "micmap.h" +#include "mistruct.h" +#include "dix.h" +#include "mibstore.h" +#include "mioverlay.h" +#include "xf86.h" +#include "xf86str.h" +#include "globals.h" + +/* CAUTION: We require that cfb8 and cfb32 were NOT + compiled with CFB_NEED_SCREEN_PRIVATE */ + +static DevPrivateKey cfb8_32GCPrivateKey = &cfb8_32GCPrivateKey; +DevPrivateKey cfb8_32GetGCPrivateKey(void) +{ + return cfb8_32GCPrivateKey; +} + +static DevPrivateKey cfb8_32ScreenPrivateKey = &cfb8_32ScreenPrivateKey; +DevPrivateKey cfb8_32GetScreenPrivateKey(void) +{ + return cfb8_32ScreenPrivateKey; +} + +static Bool +cfb8_32AllocatePrivates(ScreenPtr pScreen) +{ + cfb8_32ScreenPtr pScreenPriv; + + if (!(pScreenPriv = xalloc(sizeof(cfb8_32ScreenRec)))) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, pScreenPriv); + + + /* All cfb will have the same GC and Window private indicies */ + if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateKey)) + return FALSE; + + if(!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC))) + return FALSE; + + if(!dixRequestPrivate(cfb8_32GCPrivateKey, sizeof(cfb8_32GCRec))) + return FALSE; + + return TRUE; +} + +static void DestroyColormapNoop( + ColormapPtr pColormap) +{ + /* NOOP */ +} + +static void StoreColorsNoop( + ColormapPtr pColormap, + int ndef, + xColorItem * pdef) +{ + /* NOOP */ +} + +static Bool +cfb8_32SetupScreen( + ScreenPtr pScreen, + pointer pbits, /* pointer to screen bitmap */ + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy, /* dots per inch */ + int width /* pixel width of frame buffer */ +){ + if (!cfb8_32AllocatePrivates(pScreen)) + return FALSE; + pScreen->defColormap = FakeClientID(0); + /* let CreateDefColormap do whatever it wants for pixels */ + pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0; + pScreen->QueryBestSize = mfbQueryBestSize; + /* SaveScreen */ + pScreen->GetImage = cfb8_32GetImage; + pScreen->GetSpans = cfb8_32GetSpans; + pScreen->CreateWindow = cfb8_32CreateWindow; + pScreen->DestroyWindow = cfb8_32DestroyWindow; + pScreen->PositionWindow = cfb8_32PositionWindow; + pScreen->ChangeWindowAttributes = cfb8_32ChangeWindowAttributes; + pScreen->RealizeWindow = cfb32MapWindow; /* OK */ + pScreen->UnrealizeWindow = cfb32UnmapWindow; /* OK */ + pScreen->CopyWindow = cfb8_32CopyWindow; + pScreen->CreatePixmap = cfb32CreatePixmap; /* OK */ + pScreen->DestroyPixmap = cfb32DestroyPixmap; /* OK */ + pScreen->RealizeFont = mfbRealizeFont; + pScreen->UnrealizeFont = mfbUnrealizeFont; + pScreen->CreateGC = cfb8_32CreateGC; + pScreen->CreateColormap = miInitializeColormap; + pScreen->DestroyColormap = DestroyColormapNoop; + pScreen->InstallColormap = miInstallColormap; + pScreen->UninstallColormap = miUninstallColormap; + pScreen->ListInstalledColormaps = miListInstalledColormaps; + pScreen->StoreColors = StoreColorsNoop; + pScreen->ResolveColor = miResolveColor; + pScreen->BitmapToRegion = mfbPixmapToRegion; + + mfbRegisterCopyPlaneProc (pScreen, cfb8_32CopyPlane); + return TRUE; +} + +typedef struct { + pointer pbits; + int width; +} miScreenInitParmsRec, *miScreenInitParmsPtr; + +static Bool +cfb8_32CreateScreenResources(ScreenPtr pScreen) +{ + miScreenInitParmsPtr pScrInitParms; + int pitch; + Bool retval; + + /* get the pitch before mi destroys it */ + pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate; + pitch = pScrInitParms->width << 2; + + if((retval = miCreateScreenResources(pScreen))) { + /* fix the screen pixmap */ + PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate; + pPix->drawable.bitsPerPixel = 32; + pPix->drawable.depth = 8; + pPix->devKind = pitch; + } + + return retval; +} + + +static Bool +cfb8_32CloseScreen (int i, ScreenPtr pScreen) +{ + cfb8_32ScreenPtr pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + if(pScreenPriv->visualData) + xfree(pScreenPriv->visualData); + + xfree((pointer) pScreenPriv); + dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, NULL); + + return(cfb32CloseScreen(i, pScreen)); +} + +static void +cfb8_32TransFunc( + ScreenPtr pScreen, + int nbox, + BoxPtr pbox +){ + cfb8_32FillBoxSolid8(&(WindowTable[pScreen->myNum]->drawable), + nbox, pbox, xf86Screens[pScreen->myNum]->colorKey); +} + +static Bool +cfb8_32InOverlayFunc(WindowPtr pWin) +{ + return (pWin->drawable.depth == 8); +} + +static Bool +cfb8_32FinishScreenInit( + ScreenPtr pScreen, + pointer pbits, /* pointer to screen bitmap */ + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy, /* dots per inch */ + int width /* pixel width of frame buffer */ +){ + VisualPtr visuals; + DepthPtr depths; + int nvisuals; + int ndepths; + int rootdepth; + VisualID defaultVisual; + + rootdepth = 0; + if (!miInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth, + &defaultVisual,((unsigned long)1<<(32-1)), 8, -1)) + return FALSE; + if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, + rootdepth, ndepths, depths, + defaultVisual, nvisuals, visuals)) + return FALSE; + + pScreen->CreateScreenResources = cfb8_32CreateScreenResources; + pScreen->CloseScreen = cfb8_32CloseScreen; + pScreen->GetScreenPixmap = cfb32GetScreenPixmap; /* OK */ + pScreen->SetScreenPixmap = cfb32SetScreenPixmap; /* OK */ + + if (! miInitOverlay(pScreen, cfb8_32InOverlayFunc, cfb8_32TransFunc)) + return FALSE; + + return TRUE; +} + +static void +cfb8_32EnableDisableFBAccess ( + int index, + Bool enable +){ + ScreenPtr pScreen = screenInfo.screens[index]; + cfb8_32ScreenPtr pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + + miOverlaySetRootClip(pScreen, enable); + + (*pScreenPriv->EnableDisableFBAccess) (index, enable); +} + +static Atom overlayVisualsAtom; + +typedef struct { + CARD32 overlay_visual; + CARD32 transparent_type; + CARD32 value; + CARD32 layer; +} overlayVisualRec; + +static void +cfb8_32SetupVisuals (ScreenPtr pScreen) +{ + cfb8_32ScreenPtr pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + char atomString[] = {"SERVER_OVERLAY_VISUALS"}; + overlayVisualRec *overlayVisuals; + VisualID *visuals = NULL; + int numVisuals = 0; + DepthPtr pDepth = pScreen->allowedDepths; + int numDepths = pScreen->numDepths; + int i; + + /* find depth 8 visuals */ + for(i = 0; i < numDepths; i++, pDepth++) { + if(pDepth->depth == 8) { + numVisuals = pDepth->numVids; + visuals = pDepth->vids; + break; + } + } + + if(!numVisuals || !visuals) { + ErrorF("No overlay visuals found!\n"); + return; + } + + if(!(overlayVisuals = xalloc(numVisuals * sizeof(overlayVisualRec)))) + return; + + for(i = 0; i < numVisuals; i++) { + overlayVisuals[i].overlay_visual = visuals[i]; + overlayVisuals[i].transparent_type = 1; /* transparent pixel */ + overlayVisuals[i].value = pScreenPriv->key; + overlayVisuals[i].layer = 1; + } + + overlayVisualsAtom = MakeAtom(atomString, sizeof(atomString) - 1, TRUE); + xf86RegisterRootWindowProperty(pScreen->myNum, overlayVisualsAtom, + overlayVisualsAtom, 32, numVisuals * 4, overlayVisuals); + pScreenPriv->visualData = (pointer)overlayVisuals; +} + +Bool +cfb8_32ScreenInit( + ScreenPtr pScreen, + pointer pbits, /* pointer to screen bitmap */ + int xsize, int ysize, /* in pixels */ + int dpix, int dpiy, /* dots per inch */ + int w /* pixel width of frame buffer */ +){ + cfb8_32ScreenPtr pScreenPriv; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + if (!cfb8_32SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, w)) + return FALSE; + + pScreenPriv = CFB8_32_GET_SCREEN_PRIVATE(pScreen); + pScreenPriv->key = pScrn->colorKey; + pScreenPriv->visualData = NULL; + + + pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; + pScrn->EnableDisableFBAccess = cfb8_32EnableDisableFBAccess; + + + if(cfb8_32FinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, w)) + { + cfb8_32SetupVisuals(pScreen); + return TRUE; + } + return FALSE; +} diff --git a/xorg-server/hw/xfree86/xf8_32bpp/cfbwindow.c b/xorg-server/hw/xfree86/xf8_32bpp/cfbwindow.c new file mode 100644 index 000000000..2e6057f12 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/cfbwindow.c @@ -0,0 +1,116 @@ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> + +#include <X11/X.h> +#include "scrnintstr.h" +#include "windowstr.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb32.h" +#include "cfb8_32.h" +#include "mistruct.h" +#include "regionstr.h" +#include "cfbmskbits.h" +#include "mioverlay.h" + + +/* We don't bother with cfb's fastBackground/Border so we don't + need to use the Window privates */ + + +Bool +cfb8_32CreateWindow(WindowPtr pWin) +{ + pWin->drawable.bitsPerPixel = 32; + return TRUE; +} + + +Bool +cfb8_32DestroyWindow(WindowPtr pWin) +{ + return TRUE; +} + +Bool +cfb8_32PositionWindow( + WindowPtr pWin, + int x, int y +){ + return TRUE; +} + +void +cfb8_32CopyWindow(pWin, ptOldOrg, prgnSrc) + WindowPtr pWin; + DDXPointRec ptOldOrg; + RegionPtr prgnSrc; +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DDXPointPtr ppt, pptSrc; + RegionRec rgnDst; + RegionPtr borderClip = &pWin->borderClip; + BoxPtr pbox; + int dx, dy, i, nbox; + WindowPtr pwinRoot; + Bool doUnderlay = miOverlayCopyUnderlay(pScreen); + Bool freeReg = FALSE; + + pwinRoot = WindowTable[pScreen->myNum]; + + if(doUnderlay) + freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip); + + REGION_NULL(pScreen, &rgnDst); + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); + REGION_INTERSECT(pScreen, &rgnDst, borderClip, prgnSrc); + + pbox = REGION_RECTS(&rgnDst); + nbox = REGION_NUM_RECTS(&rgnDst); + if(!nbox || + !(pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec)))) + { + REGION_UNINIT(pScreen, &rgnDst); + return; + } + ppt = pptSrc; + + for (i = nbox; --i >= 0; ppt++, pbox++) + { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + if(doUnderlay) + cfbDoBitblt24To24GXcopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + GXcopy, &rgnDst, pptSrc, ~0); + else + cfbDoBitblt8To8GXcopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + GXcopy, &rgnDst, pptSrc, ~0); + + xfree(pptSrc); + REGION_UNINIT(pScreen, &rgnDst); + if(freeReg) + REGION_DESTROY(pScreen, borderClip); +} + +Bool +cfb8_32ChangeWindowAttributes( + WindowPtr pWin, + unsigned long mask +){ + return TRUE; +} + + + + diff --git a/xorg-server/hw/xfree86/xf8_32bpp/xf86overlay.c b/xorg-server/hw/xfree86/xf8_32bpp/xf86overlay.c new file mode 100644 index 000000000..c63b3cfd1 --- /dev/null +++ b/xorg-server/hw/xfree86/xf8_32bpp/xf86overlay.c @@ -0,0 +1,1179 @@ + +/* + Copyright (C) 1998. The XFree86 Project Inc. + + Written by Mark Vojkovich (mvojkovi@ucsd.edu) +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include <X11/X.h> +#include "scrnintstr.h" +#include "regionstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "migc.h" +#include "gcstruct.h" +#include "pixmapstr.h" +#include "colormapst.h" +#include "cfb8_32.h" + +#define IS_DIRTY 1 +#define IS_SHARED 2 + +/** Screen Functions **/ + +static Bool OverlayCloseScreen (int, ScreenPtr); +static Bool OverlayCreateGC(GCPtr pGC); +static Bool OverlayDestroyPixmap(PixmapPtr); +static PixmapPtr OverlayCreatePixmap(ScreenPtr, int, int, int, unsigned); +static Bool OverlayChangeWindowAttributes(WindowPtr, unsigned long); + +/** Funcs **/ +static void OverlayValidateGC(GCPtr, unsigned long, DrawablePtr); +static void OverlayChangeGC(GCPtr, unsigned long); +static void OverlayCopyGC(GCPtr, unsigned long, GCPtr); +static void OverlayDestroyGC(GCPtr); +static void OverlayChangeClip(GCPtr, int, pointer, int); +static void OverlayDestroyClip(GCPtr); +static void OverlayCopyClip(GCPtr, GCPtr); + + +static PixmapPtr OverlayRefreshPixmap(PixmapPtr); + +static GCFuncs OverlayGCFuncs = { + OverlayValidateGC, OverlayChangeGC, + OverlayCopyGC, OverlayDestroyGC, + OverlayChangeClip, OverlayDestroyClip, + OverlayCopyClip +}; + + +/** Pixmap Ops */ +static void PixmapFillSpans(DrawablePtr, GCPtr, int, DDXPointPtr, int *, + int); +static void PixmapSetSpans(DrawablePtr, GCPtr, char *, DDXPointPtr, + int *, int, int); +static void PixmapPutImage(DrawablePtr, GCPtr, int, int, int, int, int, + int, int, char *); +static void PixmapPushPixels(GCPtr, PixmapPtr, DrawablePtr, int, int, + int, int); +static RegionPtr PixmapCopyArea(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int); +static RegionPtr PixmapCopyPlane(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int, unsigned long); +static void PixmapPolyPoint(DrawablePtr, GCPtr, int, int, xPoint *); +static void PixmapPolylines(DrawablePtr, GCPtr, int, int, DDXPointPtr); +static void PixmapPolySegment(DrawablePtr, GCPtr, int, xSegment *); +static void PixmapPolyRectangle(DrawablePtr, GCPtr, int, xRectangle *); +static void PixmapPolyArc(DrawablePtr, GCPtr, int, xArc *); +static void PixmapFillPolygon(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void PixmapPolyFillRect(DrawablePtr, GCPtr, int, xRectangle *); +static void PixmapPolyFillArc(DrawablePtr, GCPtr, int, xArc *); +static int PixmapPolyText8(DrawablePtr, GCPtr, int, int, int, char *); +static int PixmapPolyText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void PixmapImageText8(DrawablePtr, GCPtr, int, int, int, char *); +static void PixmapImageText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void PixmapImageGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); +static void PixmapPolyGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); + +static GCOps PixmapGCOps = { + PixmapFillSpans, PixmapSetSpans, + PixmapPutImage, PixmapCopyArea, + PixmapCopyPlane, PixmapPolyPoint, + PixmapPolylines, PixmapPolySegment, + PixmapPolyRectangle, PixmapPolyArc, + PixmapFillPolygon, PixmapPolyFillRect, + PixmapPolyFillArc, PixmapPolyText8, + PixmapPolyText16, PixmapImageText8, + PixmapImageText16, PixmapImageGlyphBlt, + PixmapPolyGlyphBlt, PixmapPushPixels, + {NULL} /* devPrivate */ +}; + + +/** Window Ops **/ +static void WindowFillSpans(DrawablePtr, GCPtr, int, DDXPointPtr, int *, + int); +static void WindowSetSpans(DrawablePtr, GCPtr, char *, DDXPointPtr, + int *, int, int); +static void WindowPutImage(DrawablePtr, GCPtr, int, int, int, int, int, + int, int, char *); +static void WindowPushPixels(GCPtr, PixmapPtr, DrawablePtr, int, int, + int, int); +static RegionPtr WindowCopyArea(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int); +static RegionPtr WindowCopyPlane(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int, unsigned long); +static void WindowPolyPoint(DrawablePtr, GCPtr, int, int, xPoint *); +static void WindowPolylines(DrawablePtr, GCPtr, int, int, DDXPointPtr); +static void WindowPolySegment(DrawablePtr, GCPtr, int, xSegment *); +static void WindowPolyRectangle(DrawablePtr, GCPtr, int, xRectangle *); +static void WindowPolyArc(DrawablePtr, GCPtr, int, xArc *); +static void WindowFillPolygon(DrawablePtr, GCPtr, int, int, int, + DDXPointPtr); +static void WindowPolyFillRect(DrawablePtr, GCPtr, int, xRectangle *); +static void WindowPolyFillArc(DrawablePtr, GCPtr, int, xArc *); +static int WindowPolyText8(DrawablePtr, GCPtr, int, int, int, char *); +static int WindowPolyText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void WindowImageText8(DrawablePtr, GCPtr, int, int, int, char *); +static void WindowImageText16(DrawablePtr, GCPtr, int, int, int, + unsigned short *); +static void WindowImageGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); +static void WindowPolyGlyphBlt(DrawablePtr, GCPtr, int, int, + unsigned int, CharInfoPtr *, pointer); + +static GCOps WindowGCOps = { + WindowFillSpans, WindowSetSpans, + WindowPutImage, WindowCopyArea, + WindowCopyPlane, WindowPolyPoint, + WindowPolylines, WindowPolySegment, + WindowPolyRectangle, WindowPolyArc, + WindowFillPolygon, WindowPolyFillRect, + WindowPolyFillArc, WindowPolyText8, + WindowPolyText16, WindowImageText8, + WindowImageText16, WindowImageGlyphBlt, + WindowPolyGlyphBlt, WindowPushPixels, + {NULL} /* devPrivate */ +}; + +/** privates **/ + +typedef struct { + CloseScreenProcPtr CloseScreen; + CreateGCProcPtr CreateGC; + CreatePixmapProcPtr CreatePixmap; + DestroyPixmapProcPtr DestroyPixmap; + ChangeWindowAttributesProcPtr ChangeWindowAttributes; + int LockPrivate; +} OverlayScreenRec, *OverlayScreenPtr; + +typedef struct { + GCFuncs *wrapFuncs; + GCOps *wrapOps; + GCOps *overlayOps; + unsigned long fg; + unsigned long bg; + unsigned long pm; + PixmapPtr tile; +} OverlayGCRec, *OverlayGCPtr; + +typedef struct { + PixmapPtr pix32; + CARD32 dirty; +} OverlayPixmapRec, *OverlayPixmapPtr; + + +static DevPrivateKey OverlayScreenKey = &OverlayScreenKey; +static DevPrivateKey OverlayGCKey = &OverlayGCKey; +static DevPrivateKey OverlayPixmapKey = &OverlayPixmapKey; + +/** Macros **/ + +#define TILE_EXISTS(pGC) (!(pGC)->tileIsPixel && (pGC)->tile.pixmap) + +#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) ((OverlayPixmapPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, OverlayPixmapKey)) + +#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) ((OverlayScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, OverlayScreenKey)) + +#define OVERLAY_GET_GC_PRIVATE(pGC) ((OverlayGCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, OverlayGCKey)) + +#define OVERLAY_GC_FUNC_PROLOGUE(pGC)\ + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ + (pGC)->funcs = pGCPriv->wrapFuncs;\ + if(pGCPriv->overlayOps) \ + (pGC)->ops = pGCPriv->wrapOps + +#define OVERLAY_GC_FUNC_EPILOGUE(pGC)\ + pGCPriv->wrapFuncs = (pGC)->funcs;\ + (pGC)->funcs = &OverlayGCFuncs;\ + if(pGCPriv->overlayOps) { \ + pGCPriv->wrapOps = (pGC)->ops;\ + (pGC)->ops = pGCPriv->overlayOps;\ + } + +#define WINDOW_GC_OP_PROLOGUE(pGC)\ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE((pGC)->pScreen);\ + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ + unsigned long oldfg = (pGC)->fgPixel;\ + unsigned long oldbg = (pGC)->bgPixel;\ + unsigned long oldpm = (pGC)->planemask;\ + PixmapPtr oldtile = (pGC)->tile.pixmap;\ + (pGC)->fgPixel = pGCPriv->fg;\ + (pGC)->bgPixel = pGCPriv->bg;\ + (pGC)->planemask = pGCPriv->pm;\ + if(pGCPriv->tile) (pGC)->tile.pixmap = pGCPriv->tile;\ + (pGC)->funcs = pGCPriv->wrapFuncs;\ + (pGC)->ops = pGCPriv->wrapOps;\ + pScreenPriv->LockPrivate++ + + +#define WINDOW_GC_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = (pGC)->ops;\ + pGCPriv->wrapFuncs = (pGC)->funcs;\ + (pGC)->fgPixel = oldfg;\ + (pGC)->bgPixel = oldbg;\ + (pGC)->planemask = oldpm;\ + (pGC)->tile.pixmap = oldtile;\ + (pGC)->funcs = &OverlayGCFuncs;\ + (pGC)->ops = &WindowGCOps;\ + pScreenPriv->LockPrivate-- + + +#define PIXMAP_GC_OP_PROLOGUE(pGC)\ + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ + OverlayPixmapPtr pPixPriv = OVERLAY_GET_PIXMAP_PRIVATE((PixmapPtr)pDraw);\ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps + +#define PIXMAP_GC_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = pGC->ops;\ + pGC->funcs = &OverlayGCFuncs;\ + pGC->ops = &PixmapGCOps;\ + pPixPriv->dirty |= IS_DIRTY + + +Bool +xf86Overlay8Plus32Init (ScreenPtr pScreen) +{ + OverlayScreenPtr pScreenPriv; + + if (!dixRequestPrivate(OverlayGCKey, sizeof(OverlayGCRec))) + return FALSE; + + if (!dixRequestPrivate(OverlayPixmapKey, sizeof(OverlayPixmapRec))) + return FALSE; + + if (!(pScreenPriv = xalloc(sizeof(OverlayScreenRec)))) + return FALSE; + + dixSetPrivate(&pScreen->devPrivates, OverlayScreenKey, pScreenPriv); + + pScreenPriv->CreateGC = pScreen->CreateGC; + pScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreenPriv->CreatePixmap = pScreen->CreatePixmap; + pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap; + pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; + + pScreen->CreateGC = OverlayCreateGC; + pScreen->CloseScreen = OverlayCloseScreen; + pScreen->CreatePixmap = OverlayCreatePixmap; + pScreen->DestroyPixmap = OverlayDestroyPixmap; + pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes; + + pScreenPriv->LockPrivate = 0; + + /* allocate the key in the default map */ + if(pScreen->defColormap) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ColormapPtr pmap; + xColorItem color; + + pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, RT_COLORMAP); + + pmap->red[pScrn->colorKey].refcnt = AllocPrivate; + pmap->red[pScrn->colorKey].fShared = FALSE; + pmap->freeRed--; + + color.red = color.blue = color.green = 0; + color.pixel = pScrn->colorKey; + color.flags = DoRed | DoGreen | DoBlue; + + StoreColors(pmap, 1, &color); + } + + return TRUE; +} + + +/*********************** Screen Funcs ***********************/ + +Bool +OverlayCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC); + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + Bool ret; + + pScreen->CreateGC = pScreenPriv->CreateGC; + + if((ret = (*pScreen->CreateGC)(pGC)) && (pGC->depth != 1)) { + pGCPriv->wrapFuncs = pGC->funcs; + pGC->funcs = &OverlayGCFuncs; + pGCPriv->wrapOps = NULL; + pGCPriv->overlayOps = NULL; + pGCPriv->tile = NULL; + } + + pScreen->CreateGC = OverlayCreateGC; + + return ret; +} + +static PixmapPtr +OverlayCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, + unsigned usage_hint) +{ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + PixmapPtr pPix; + + pScreen->CreatePixmap = pScreenPriv->CreatePixmap; + pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint); + pScreen->CreatePixmap = OverlayCreatePixmap; + + /* We initialize all the privates */ + if(pPix) { + OverlayPixmapPtr pPriv = OVERLAY_GET_PIXMAP_PRIVATE(pPix); + pPriv->pix32 = NULL; + pPriv->dirty = IS_DIRTY; + if(!w || !h) + pPriv->dirty |= IS_SHARED; + } + + return pPix; +} + +static Bool +OverlayDestroyPixmap(PixmapPtr pPix) +{ + ScreenPtr pScreen = pPix->drawable.pScreen; + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + Bool result; + + pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap; + + if((pPix->refcnt == 1) && (pPix->drawable.bitsPerPixel == 8)) { + OverlayPixmapPtr pPriv = OVERLAY_GET_PIXMAP_PRIVATE(pPix); + if(pPriv->pix32) { + if(pPriv->pix32->refcnt != 1) + ErrorF("Warning! private pix refcnt = %i\n", pPriv->pix32->refcnt); + (*pScreen->DestroyPixmap)(pPriv->pix32); + } + pPriv->pix32 = NULL; + } + + result = (*pScreen->DestroyPixmap) (pPix); + pScreen->DestroyPixmap = OverlayDestroyPixmap; + + return result; +} + +static Bool +OverlayCloseScreen (int i, ScreenPtr pScreen) +{ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + + pScreen->CreateGC = pScreenPriv->CreateGC; + pScreen->CloseScreen = pScreenPriv->CloseScreen; + pScreen->CreatePixmap = pScreenPriv->CreatePixmap; + pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap; + pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes; + + xfree ((pointer) pScreenPriv); + + return (*pScreen->CloseScreen) (i, pScreen); +} + + + +static Bool +OverlayChangeWindowAttributes (WindowPtr pWin, unsigned long mask) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + Bool result; + + if(pWin->drawable.depth == 8) { + if((mask & CWBackPixmap) && + (pWin->backgroundState == BackgroundPixmap)) + OverlayRefreshPixmap(pWin->background.pixmap); + + if((mask & CWBorderPixmap) && !pWin->borderIsPixel) + OverlayRefreshPixmap(pWin->border.pixmap); + } + + pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes; + result = (*pScreen->ChangeWindowAttributes) (pWin, mask); + pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes; + + return result; +} + +/*********************** GC Funcs *****************************/ + + +static PixmapPtr +OverlayRefreshPixmap(PixmapPtr pix8) +{ + OverlayPixmapPtr pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(pix8); + ScreenPtr pScreen = pix8->drawable.pScreen; + + if(!pixPriv->pix32) { + PixmapPtr newPix; + + newPix = (*pScreen->CreatePixmap)(pScreen, pix8->drawable.width, + pix8->drawable.height, 24, 0); + newPix->drawable.depth = 8; /* Bad Mark! Bad Mark! */ + pixPriv->pix32 = newPix; + } + + if(pixPriv->dirty) { + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen); + GCPtr pGC; + + pGC = GetScratchGC(8, pScreen); + + pScreenPriv->LockPrivate++; /* don't modify this one */ + ValidateGC((DrawablePtr)pixPriv->pix32, pGC); + + (*pGC->ops->CopyArea)((DrawablePtr)pix8, (DrawablePtr)pixPriv->pix32, + pGC, 0, 0, pix8->drawable.width, pix8->drawable.height, 0, 0); + pScreenPriv->LockPrivate--; + FreeScratchGC(pGC); + + pixPriv->dirty &= ~IS_DIRTY; + pixPriv->pix32->drawable.serialNumber = NEXT_SERIAL_NUMBER; + } + + return pixPriv->pix32; +} + + +static void +OverlayValidateGC( + GCPtr pGC, + unsigned long changes, + DrawablePtr pDraw +){ + OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pGC->pScreen); + OVERLAY_GC_FUNC_PROLOGUE (pGC); + + if(pScreenPriv->LockPrivate < 0) { + ErrorF("Something is wrong in OverlayValidateGC!\n"); + pScreenPriv->LockPrivate = 0; + } + + if(pGC->depth == 24) { + unsigned long oldpm = pGC->planemask; + pGCPriv->overlayOps = NULL; + + if(pDraw->type == DRAWABLE_WINDOW) + pGC->planemask &= 0x00ffffff; + else + pGC->planemask |= 0xff000000; + + if(oldpm != pGC->planemask) changes |= GCPlaneMask; + + (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); + + } else { /* depth == 8 */ + unsigned long newChanges = 0; + + if(pDraw->bitsPerPixel == 32) { + + if(pGC->fillStyle == FillTiled) + pGCPriv->tile = OverlayRefreshPixmap(pGC->tile.pixmap); + else pGCPriv->tile = NULL; + + if(pGCPriv->overlayOps != &WindowGCOps) { + newChanges = GCForeground | GCBackground | GCPlaneMask; + if(pGCPriv->tile) + newChanges |= GCTile; + } + pGCPriv->overlayOps = &WindowGCOps; + + if(!pScreenPriv->LockPrivate) { + unsigned long oldfg = pGC->fgPixel; + unsigned long oldbg = pGC->bgPixel; + unsigned long oldpm = pGC->planemask; + PixmapPtr oldtile = pGC->tile.pixmap; + + pGC->fgPixel = pGCPriv->fg = oldfg << 24; + pGC->bgPixel = pGCPriv->bg = oldbg << 24; + pGC->planemask = pGCPriv->pm = oldpm << 24; + if(pGCPriv->tile) + pGC->tile.pixmap = pGCPriv->tile; + + (*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw); + + pGC->fgPixel = oldfg; + pGC->bgPixel = oldbg; + pGC->planemask = oldpm; + pGC->tile.pixmap = oldtile; + } else { + pGCPriv->fg = pGC->fgPixel; + pGCPriv->bg = pGC->bgPixel; + pGCPriv->pm = pGC->planemask; + + (*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw); + } + + } else { /* bitsPerPixel == 8 */ + if(pGCPriv->overlayOps == &WindowGCOps) { + newChanges = GCForeground | GCBackground | GCPlaneMask; + if(pGCPriv->tile) + newChanges |= GCTile; + } + pGCPriv->overlayOps = &PixmapGCOps; + + (*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw); + } + } + + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + + +static void +OverlayDestroyGC(GCPtr pGC) +{ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->DestroyGC)(pGC); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + +static void +OverlayChangeGC ( + GCPtr pGC, + unsigned long mask +){ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + +static void +OverlayCopyGC ( + GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst +){ + OVERLAY_GC_FUNC_PROLOGUE (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + OVERLAY_GC_FUNC_EPILOGUE (pGCDst); +} +static void +OverlayChangeClip ( + GCPtr pGC, + int type, + pointer pvalue, + int nrects +){ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + +static void +OverlayCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + OVERLAY_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + OVERLAY_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +OverlayDestroyClip(GCPtr pGC) +{ + OVERLAY_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + OVERLAY_GC_FUNC_EPILOGUE (pGC); +} + + + +/******************* Window GC ops ***********************/ + +static void +WindowFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static RegionPtr +WindowCopyArea( + DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + RegionPtr ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static RegionPtr +WindowCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + RegionPtr ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +WindowPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static int +WindowPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + int ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static int +WindowPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + int ret; + + WINDOW_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +WindowImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + WINDOW_GC_OP_EPILOGUE(pGC); +} + +static void +WindowPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg +){ + WINDOW_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + WINDOW_GC_OP_EPILOGUE(pGC); +} + + +/******************* Pixmap GC ops ***********************/ + +static void +PixmapFillSpans( + DrawablePtr pDraw, + GC *pGC, + int nInit, + DDXPointPtr pptInit, + int *pwidthInit, + int fSorted +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapSetSpans( + DrawablePtr pDraw, + GCPtr pGC, + char *pcharsrc, + register DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPutImage( + DrawablePtr pDraw, + GCPtr pGC, + int depth, + int x, int y, int w, int h, + int leftPad, + int format, + char *pImage +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, + leftPad, format, pImage); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static RegionPtr +PixmapCopyArea( + DrawablePtr pSrc, + DrawablePtr pDraw, + GC *pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty +){ + RegionPtr ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyArea)(pSrc, pDraw, + pGC, srcx, srcy, width, height, dstx, dsty); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static RegionPtr +PixmapCopyPlane( + DrawablePtr pSrc, + DrawablePtr pDraw, + GCPtr pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + unsigned long bitPlane +){ + RegionPtr ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->CopyPlane)(pSrc, pDraw, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +PixmapPolyPoint( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + xPoint *pptInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolylines( + DrawablePtr pDraw, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pptInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolySegment( + DrawablePtr pDraw, + GCPtr pGC, + int nseg, + xSegment *pSeg +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyRectangle( + DrawablePtr pDraw, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapFillPolygon( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, + xRectangle *prectInit +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyFillArc( + DrawablePtr pDraw, + GCPtr pGC, + int narcs, + xArc *parcs +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static int +PixmapPolyText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + int ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static int +PixmapPolyText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + int ret; + + PIXMAP_GC_OP_PROLOGUE(pGC); + ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); + return ret; +} + +static void +PixmapImageText8( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + char *chars +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapImageText16( + DrawablePtr pDraw, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapImageGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPolyGlyphBlt( + DrawablePtr pDraw, + GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, + ppci, pglyphBase); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + +static void +PixmapPushPixels( + GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDraw, + int dx, int dy, int xOrg, int yOrg +){ + PIXMAP_GC_OP_PROLOGUE(pGC); + (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); + PIXMAP_GC_OP_EPILOGUE(pGC); +} + + diff --git a/xorg-server/hw/xfree86/xorg.c b/xorg-server/hw/xfree86/xorg.c new file mode 100644 index 000000000..e69de29bb diff --git a/xorg-server/hw/xfree86/xorgconf.cpp b/xorg-server/hw/xfree86/xorgconf.cpp new file mode 100644 index 000000000..acf90f13f --- /dev/null +++ b/xorg-server/hw/xfree86/xorgconf.cpp @@ -0,0 +1,604 @@ +XCOMM $XdotOrg$ +XCOMM +XCOMM Copyright (c) 1994-1998 by The XFree86 Project, Inc. +XCOMM +XCOMM Permission is hereby granted, free of charge, to any person obtaining a +XCOMM copy of this software and associated documentation files (the "Software"), +XCOMM to deal in the Software without restriction, including without limitation +XCOMM the rights to use, copy, modify, merge, publish, distribute, sublicense, +XCOMM and/or sell copies of the Software, and to permit persons to whom the +XCOMM Software is furnished to do so, subject to the following conditions: +XCOMM +XCOMM The above copyright notice and this permission notice shall be included in +XCOMM all copies or substantial portions of the Software. +XCOMM +XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +XCOMM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +XCOMM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +XCOMM THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +XCOMM WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +XCOMM OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +XCOMM SOFTWARE. +XCOMM +XCOMM Except as contained in this notice, the name of the XFree86 Project shall +XCOMM not be used in advertising or otherwise to promote the sale, use or other +XCOMM dealings in this Software without prior written authorization from the +XCOMM XFree86 Project. +XCOMM +XCOMM $XConsortium: XF86Conf.cpp /main/22 1996/10/23 11:43:51 kaleb $ + +XCOMM ********************************************************************** +XCOMM This is a sample configuration file only, intended to illustrate +XCOMM what a config file might look like. Refer to the XF86Config(4/5) +XCOMM man page for details about the format of this file. This man page +XCOMM is installed as MANPAGE +XCOMM ********************************************************************** + +XCOMM The ordering of sections is not important in version 4.0 and later. + +XCOMM ********************************************************************** +XCOMM Files section. This allows default font and rgb paths to be set +XCOMM ********************************************************************** + +Section "Files" + +XCOMM Multiple FontPath entries are allowed (which are concatenated together), +XCOMM as well as specifying multiple comma-separated entries in one FontPath +XCOMM command (or a combination of both methods) + + FontPath LOCALFONTPATH + FontPath MISCFONTPATH + FontPath T1FONTPATH + FontPath TRUETYPEFONTPATH + FontPath DPI75FONTPATH + FontPath DPI100FONTPATH + +XCOMM ModulePath can be used to set a search path for the X server modules. +XCOMM The default path is shown here. + +XCOMM ModulePath MODULEPATH + +EndSection + +XCOMM ********************************************************************** +XCOMM Module section -- this is an optional section which is used to specify +XCOMM which run-time loadable modules to load when the X server starts up. +XCOMM ********************************************************************** + +Section "Module" + +XCOMM This loads the DBE extension module. + + Load "dbe" + +XCOMM This loads the miscellaneous extensions module, and disables +XCOMM initialisation of the XFree86-DGA extension within that module. + + SubSection "extmod" + Option "omit xfree86-dga" + EndSubSection + +XCOMM This loads the Type1 and FreeType font modules + + Load "type1" + Load "freetype" + +EndSection + + +XCOMM ********************************************************************** +XCOMM Server flags section. This contains various server-wide Options. +XCOMM ********************************************************************** + +Section "ServerFlags" + +XCOMM Uncomment this to cause a core dump at the spot where a signal is +XCOMM received. This may leave the console in an unusable state, but may +XCOMM provide a better stack trace in the core dump to aid in debugging + +XCOMM Option "NoTrapSignals" + +XCOMM Uncomment this to disable the <Crtl><Alt><Fn> VT switch sequence +XCOMM (where n is 1 through 12). This allows clients to receive these key +XCOMM events. + +XCOMM Option "DontVTSwitch" + +XCOMM Uncomment this to disable the <Crtl><Alt><BS> server abort sequence +XCOMM This allows clients to receive this key event. + +XCOMM Option "DontZap" + +XCOMM Uncomment this to disable the <Crtl><Alt><KP_+>/<KP_-> mode switching +XCOMM sequences. This allows clients to receive these key events. + +XCOMM Option "DontZoom" + +XCOMM Uncomment this to disable tuning with the xvidtune client. With +XCOMM it the client can still run and fetch card and monitor attributes, +XCOMM but it will not be allowed to change them. If it tries it will +XCOMM receive a protocol error. + +XCOMM Option "DisableVidModeExtension" + +XCOMM Uncomment this to enable the use of a non-local xvidtune client. + +XCOMM Option "AllowNonLocalXvidtune" + +XCOMM Uncomment this to disable dynamically modifying the input device +XCOMM (mouse and keyboard) settings. + +XCOMM Option "DisableModInDev" + +XCOMM Uncomment this to enable the use of a non-local client to +XCOMM change the keyboard or mouse settings (currently only xset). + +XCOMM Option "AllowNonLocalModInDev" + +XCOMM Set the basic blanking screen saver timeout. + + Option "blank time" "10" # 10 minutes + +XCOMM Set the DPMS timeouts. These are set here because they are global +XCOMM rather than screen-specific. These settings alone don't enable DPMS. +XCOMM It is enabled per-screen (or per-monitor), and even then only when +XCOMM the driver supports it. + + Option "standby time" "20" + Option "suspend time" "30" + Option "off time" "60" + +XCOMM On some platform the server needs to estimate the sizes of PCI +XCOMM memory and pio ranges. This is done by assuming that PCI ranges +XCOMM don't overlap. Some broken BIOSes tend to set ranges of inactive +XCOMM devices wrong. Here one can adjust how aggressive the assumptions +XCOMM should be. Default is 0. + +XCOMM Option "EstimateSizesAggresively" "0" + +EndSection + +XCOMM ********************************************************************** +XCOMM Input devices +XCOMM ********************************************************************** + +XCOMM ********************************************************************** +XCOMM Core keyboard's InputDevice section +XCOMM ********************************************************************** + +Section "InputDevice" + + Identifier "Keyboard1" + Driver "kbd" + +XCOMM Set the keyboard auto repeat parameters. Not all platforms implement +XCOMM this. + + Option "AutoRepeat" "500 5" + +XCOMM Specifiy which keyboard LEDs can be user-controlled (eg, with xset(1)). + +XCOMM Option "Xleds" "1 2 3" + +XCOMM To disable the XKEYBOARD extension, uncomment XkbDisable. + +XCOMM Option "XkbDisable" + +XCOMM To customise the XKB settings to suit your keyboard, modify the +XCOMM lines below (which are the defaults). For example, for a European +XCOMM keyboard, you will probably want to use one of: +XCOMM +XCOMM Option "XkbModel" "pc102" +XCOMM Option "XkbModel" "pc105" +XCOMM +XCOMM If you have a Microsoft Natural keyboard, you can use: +XCOMM +XCOMM Option "XkbModel" "microsoft" +XCOMM +XCOMM If you have a US "windows" keyboard you will want: +XCOMM +XCOMM Option "XkbModel" "pc104" +XCOMM +XCOMM Then to change the language, change the Layout setting. +XCOMM For example, a german layout can be obtained with: +XCOMM +XCOMM Option "XkbLayout" "de" +XCOMM +XCOMM or: +XCOMM +XCOMM Option "XkbLayout" "de" +XCOMM Option "XkbVariant" "nodeadkeys" +XCOMM +XCOMM If you'd like to switch the positions of your capslock and +XCOMM control keys, use: +XCOMM +XCOMM Option "XkbOptions" "ctrl:swapcaps" + + +XCOMM These are the default XKB settings for xorg +XCOMM +XCOMM Option "XkbRules" "xorg" +XCOMM Option "XkbModel" "pc101" +XCOMM Option "XkbLayout" "us" +XCOMM Option "XkbVariant" "" +XCOMM Option "XkbOptions" "" + +EndSection + + +XCOMM ********************************************************************** +XCOMM Core Pointer's InputDevice section +XCOMM ********************************************************************** + +Section "InputDevice" + +XCOMM Identifier and driver + + Identifier "Mouse1" + Driver "mouse" + +XCOMM The mouse protocol and device. The device is normally set to /dev/mouse, +XCOMM which is usually a symbolic link to the real device. + + Option "Protocol" "Microsoft" + Option "Device" "/dev/mouse" + +XCOMM On platforms where PnP mouse detection is supported the following +XCOMM protocol setting can be used when using a newer PnP mouse: + +XCOMM Option "Protocol" "Auto" + +XCOMM When using mouse connected to a PS/2 port (aka "MousePort"), set the +XCOMM the protocol as follows. On some platforms some other settings may +XCOMM be available. + +XCOMM Option "Protocol" "PS/2" + +XCOMM Baudrate and SampleRate are only for some older Logitech mice. In +XCOMM almost every case these lines should be omitted. + +XCOMM Option "BaudRate" "9600" +XCOMM Option "SampleRate" "150" + +XCOMM Emulate3Buttons is an option for 2-button mice +XCOMM Emulate3Timeout is the timeout in milliseconds (default is 50ms) + +XCOMM Option "Emulate3Buttons" +XCOMM Option "Emulate3Timeout" "50" + +XCOMM ChordMiddle is an option for some 3-button Logitech mice, or any +XCOMM 3-button mouse where the middle button generates left+right button +XCOMM events. + +XCOMM Option "ChordMiddle" + +EndSection + +Section "InputDevice" + Identifier "Mouse2" + Driver "mouse" + Option "Protocol" "MouseMan" + Option "Device" "/dev/mouse2" +EndSection + +XCOMM Some examples of extended input devices + +XCOMM Section "InputDevice" +XCOMM Identifier "spaceball" +XCOMM Driver "magellan" +XCOMM Option "Device" "/dev/cua0" +XCOMM EndSection +XCOMM +XCOMM Section "InputDevice" +XCOMM Identifier "spaceball2" +XCOMM Driver "spaceorb" +XCOMM Option "Device" "/dev/cua0" +XCOMM EndSection +XCOMM +XCOMM Section "InputDevice" +XCOMM Identifier "touchscreen0" +XCOMM Driver "microtouch" +XCOMM Option "Device" "/dev/ttyS0" +XCOMM Option "MinX" "1412" +XCOMM Option "MaxX" "15184" +XCOMM Option "MinY" "15372" +XCOMM Option "MaxY" "1230" +XCOMM Option "ScreenNumber" "0" +XCOMM Option "ReportingMode" "Scaled" +XCOMM Option "ButtonNumber" "1" +XCOMM Option "SendCoreEvents" +XCOMM EndSection +XCOMM +XCOMM Section "InputDevice" +XCOMM Identifier "touchscreen1" +XCOMM Driver "elo2300" +XCOMM Option "Device" "/dev/ttyS0" +XCOMM Option "MinX" "231" +XCOMM Option "MaxX" "3868" +XCOMM Option "MinY" "3858" +XCOMM Option "MaxY" "272" +XCOMM Option "ScreenNumber" "0" +XCOMM Option "ReportingMode" "Scaled" +XCOMM Option "ButtonThreshold" "17" +XCOMM Option "ButtonNumber" "1" +XCOMM Option "SendCoreEvents" +XCOMM EndSection + +XCOMM ********************************************************************** +XCOMM Monitor section +XCOMM ********************************************************************** + +XCOMM Any number of monitor sections may be present + +Section "Monitor" + +XCOMM The identifier line must be present. + + Identifier "Generic Monitor" + +XCOMM HorizSync is in kHz unless units are specified. +XCOMM HorizSync may be a comma separated list of discrete values, or a +XCOMM comma separated list of ranges of values. +XCOMM NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR'S +XCOMM USER MANUAL FOR THE CORRECT NUMBERS. + +XCOMM HorizSync 31.5 # typical for a single frequency fixed-sync monitor +XCOMM HorizSync 30-64 # multisync +XCOMM HorizSync 31.5, 35.2 # multiple fixed sync frequencies +XCOMM HorizSync 15-25, 30-50 # multiple ranges of sync frequencies + +XCOMM VertRefresh is in Hz unless units are specified. +XCOMM VertRefresh may be a comma separated list of discrete values, or a +XCOMM comma separated list of ranges of values. +XCOMM NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR'S +XCOMM USER MANUAL FOR THE CORRECT NUMBERS. + +XCOMM VertRefresh 60 # typical for a single frequency fixed-sync monitor + +XCOMM VertRefresh 50-100 # multisync +XCOMM VertRefresh 60, 65 # multiple fixed sync frequencies +XCOMM VertRefresh 40-50, 80-100 # multiple ranges of sync frequencies + +XCOMM Modes can be specified in two formats. A compact one-line format, or +XCOMM a multi-line format. + +XCOMM A generic VGA 640x480 mode (hsync = 31.5kHz, refresh = 60Hz) +XCOMM These two are equivalent + +XCOMM ModeLine "640x480" 25.175 640 664 760 800 480 491 493 525 + + Mode "640x480" + DotClock 25.175 + HTimings 640 664 760 800 + VTimings 480 491 493 525 + EndMode + +XCOMM These two are equivalent + +XCOMM ModeLine "1024x768i" 45 1024 1048 1208 1264 768 776 784 817 Interlace + +XCOMM Mode "1024x768i" +XCOMM DotClock 45 +XCOMM HTimings 1024 1048 1208 1264 +XCOMM VTimings 768 776 784 817 +XCOMM Flags "Interlace" +XCOMM EndMode + +XCOMM If a monitor has DPMS support, that can be indicated here. This will +XCOMM enable DPMS when the monitor is used with drivers that support it. + +XCOMM Option "dpms" + +XCOMM If a monitor requires that the sync signals be superimposed on the +XCOMM green signal, the following option will enable this when used with +XCOMM drivers that support it. Only a relatively small range of hardware +XCOMM (and drivers) actually support this. + +XCOMM Option "sync on green" + +EndSection + +XCOMM ********************************************************************** +XCOMM Graphics device section +XCOMM ********************************************************************** + +XCOMM Any number of graphics device sections may be present + +Section "Device" + +XCOMM The Identifier must be present. + + Identifier "Generic VGA" + +XCOMM The Driver line must be present. When using run-time loadable driver +XCOMM modules, this line instructs the server to load the specified driver +XCOMM module. Even when not using loadable driver modules, this line +XCOMM indicates which driver should interpret the information in this section. + + Driver "vga" + +XCOMM The chipset line is optional in most cases. It can be used to override +XCOMM the driver's chipset detection, and should not normally be specified. + +XCOMM Chipset "generic" + +XCOMM Various other lines can be specified to override the driver's automatic +XCOMM detection code. In most cases they are not needed. + +XCOMM VideoRam 256 +XCOMM Clocks 25.2 28.3 + +XCOMM The BusID line is used to specify which of possibly multiple devices +XCOMM this section is intended for. When this line isn't present, a device +XCOMM section can only match up with the primary video device. For PCI +XCOMM devices a line like the following could be used. This line should not +XCOMM normally be included unless there is more than one video device +XCOMM intalled. + +XCOMM BusID "PCI:0:10:0" + +XCOMM Various option lines can be added here as required. Some options +XCOMM are more appropriate in Screen sections, Display subsections or even +XCOMM Monitor sections. + +XCOMM Option "hw cursor" "off" + +EndSection + +Section "Device" + Identifier "any supported Trident chip" + Driver "trident" +EndSection + +Section "Device" + Identifier "MGA Millennium I" + Driver "mga" + Option "hw cursor" "off" + BusID "PCI:0:10:0" +EndSection + +Section "Device" + Identifier "MGA G200 AGP" + Driver "mga" + BusID "PCI:1:0:0" + Option "pci retry" +EndSection + + +XCOMM ********************************************************************** +XCOMM Screen sections. +XCOMM ********************************************************************** + +XCOMM Any number of screen sections may be present. Each describes +XCOMM the configuration of a single screen. A single specific screen section +XCOMM may be specified from the X server command line with the "-screen" +XCOMM option. + +Section "Screen" + +XCOMM The Identifier, Device and Monitor lines must be present + + Identifier "Screen 1" + Device "Generic VGA" + Monitor "Generic Monitor" + +XCOMM The favoured Depth and/or Bpp may be specified here + + DefaultDepth 8 + + SubSection "Display" + Depth 8 + Modes "640x480" + ViewPort 0 0 + Virtual 800 600 + EndSubsection + + SubSection "Display" + Depth 4 + Modes "640x480" + EndSubSection + + SubSection "Display" + Depth 1 + Modes "640x480" + EndSubSection + +EndSection + + +Section "Screen" + Identifier "Screen MGA1" + Device "MGA Millennium I" + Monitor "Generic Monitor" + Option "no accel" + DefaultDepth 16 +XCOMM DefaultDepth 24 + + SubSection "Display" + Depth 8 + Modes "1280x1024" + Option "rgb bits" "8" + Visual "StaticColor" + EndSubSection + SubSection "Display" + Depth 16 + Modes "1280x1024" + EndSubSection + SubSection "Display" + Depth 24 + Modes "1280x1024" + EndSubSection +EndSection + + +Section "Screen" + Identifier "Screen MGA2" + Device "MGA G200 AGP" + Monitor "Generic Monitor" + DefaultDepth 8 + + SubSection "Display" + Depth 8 + Modes "1280x1024" + Option "rgb bits" "8" + Visual "StaticColor" + EndSubSection +EndSection + + +XCOMM ********************************************************************** +XCOMM ServerLayout sections. +XCOMM ********************************************************************** + +XCOMM Any number of ServerLayout sections may be present. Each describes +XCOMM the way multiple screens are organised. A specific ServerLayout +XCOMM section may be specified from the X server command line with the +XCOMM "-layout" option. In the absence of this, the first section is used. +XCOMM When now ServerLayout section is present, the first Screen section +XCOMM is used alone. + +Section "ServerLayout" + +XCOMM The Identifier line must be present + + Identifier "Main Layout" + +XCOMM Each Screen line specifies a Screen section name, and optionally +XCOMM the relative position of other screens. The four names after +XCOMM primary screen name are the screens to the top, bottom, left and right +XCOMM of the primary screen. In this example, screen 2 is located to the +XCOMM right of screen 1. + + Screen "Screen MGA 1" "" "" "" "Screen MGA 2" + Screen "Screen MGA 2" "" "" "Screen MGA 1" "" + +XCOMM Each InputDevice line specifies an InputDevice section name and +XCOMM optionally some options to specify the way the device is to be +XCOMM used. Those options include "CorePointer", "CoreKeyboard" and +XCOMM "SendCoreEvents". In this example, "Mouse1" is the core pointer, +XCOMM and "Mouse2" is an extended input device that also generates core +XCOMM pointer events (i.e., both mice will move the standard pointer). + + InputDevice "Mouse1" "CorePointer" + InputDevice "Mouse2" "SendCoreEvents" + InputDevice "Keyboard1" "CoreKeyboard" + +EndSection + + +Section "ServerLayout" + Identifier "another layout" + Screen "Screen 1" + Screen "Screen MGA 1" + InputDevice "Mouse1" "CorePointer" + InputDevice "Keyboard1" "CoreKeyboard" +EndSection + + +Section "ServerLayout" + Identifier "simple layout" + Screen "Screen 1" + InputDevice "Mouse1" "CorePointer" + InputDevice "Keyboard1" "CoreKeyboard" +EndSection + -- cgit v1.2.3